1

I'm trying to read out a USB-connected device hooked onto my Raspberry Pi Pico using Micropython. In CPython it's quite easily done using the pyserial lib:

import serial # <-- the problem: not available in micropython?

ser = serial.Serial()   
ser.baudrate = 115200
ser.bytesize = serial.EIGHTBITS
ser.parity = serial.PARITY_NONE
ser.stopbits = serial.STOPBITS_ONE
ser.xonxoff = 0
ser.rtscts = 0
ser.timeout = 12

# configure usb port
ser.port = "/dev/ttyUSB0"
ser.close()

try:
    ser.open()

    raw_msg = ser.readline()
    decoded = raw_msg.decode('ascii').strip()
except:
    sys.exit(f'Error on {ser.name}')
finally:
    ser.close

However, considering pyserial isn't available in micropython, how can I achieve the same without pyserial? I.e. how to read data from a USB connected device using Micropython.

Please note that I'm new to specifically micropython and I haven't found a good example for reading out USB data yet.

Juliën
  • 9,047
  • 7
  • 49
  • 80

0 Answers0