import sys sys.path.append("../library/python/") import marionette_lib as ml if len(sys.argv) > 1: port = sys.argv[1] else: port = "/dev/ttyACM0" m = ml.Marionette(port) # many gpio commands require a port (A-I) and pin (0-15) on the stm32 # Note: in the future this will change to be a single string parameter # make sure pins are at a known default configuration # for most pins this is input floating m.fetch_gpio_reset() # set pin PG0 to output m.fetch_gpio_config('g', 0, 'OUTPUT_PUSHPULL') # set pin to HIGH m.fetch_gpio_write('g', 0, 1) # set pin to LOW m.fetch_gpio_write('g', 0, 0) # alternate way of setting HIGH m.fetch_gpio_set('g',0)
import serial import time import marionette_lib # Connect to the Device m = marionette_lib.Marionette( "/dev/serial/by-id/usb-APDM_Marionette_520022004115830393238353-if00") ser = serial.Serial( '/dev/serial/by-id/usb-APDM_Marionette_520022004115830393238353-if02') ser.flushInput() # reset input buffer m.adc.config( 0, 1000) # set the sample rate at 1000 samples per second for channel 0 m.adc.config( 1, 1000) # set the sample rate at 1000 samples per second for channel 1 m.adc.start(0) # start sampling channel 0 m.adc.start(1) # start sampling channel 1 # define ports UART6 = serial.Serial("/dev/ttyO5", baudrate=115200, timeout=3.0) # set in an infinit loop while True: try: # read a line from the serial port usb-APDM_Marionette_520022004115830393238353-if02 ser_bytes = ser.readline() # send the data through UART6_rxd UART6.write(str.encode(ser_bytes)) # receive the data from UART6_txd and output it to the user print(UART6.readline()) time.sleep(1) # Exiting by typing Ctrl C except: print("Keyboard Interrupt") m.adc.stop(0) # start sampling channel 0