Quantcast
Viewing all articles
Browse latest Browse all 5359

MicroPython • Pico serial communication via USB

I have written python code that reads and writes a byte via serial to a pico w.

This is the pico code that reads a byte sent from the python code and it works perfectly the first time. The second call to the read_char function returns "'\x04Traceback (most recent call last):'".

I've spent days trying to solve the problem but without success. Any suggestions will be greatly appreciated.

By the way, the same python code works perfectly with an old arduino board so I know for certain that the problem is multiple reads in the pico code.

I'm wondering if what I'm tying to is not possible via the board's USB socket and if I need to attach some sort of hardware to pins 1 and 2 to achieve real serial communication?

Code:

def read_char():    poll_obj = uselect.poll()    poll_obj.register(sys.stdin,1)        if poll_obj.poll(0):        #read one character        ch = sys.stdin.read(1)    else:        ch = None    return ch

Statistics: Posted by Dragon12 — Sun Dec 10, 2023 4:00 am



Viewing all articles
Browse latest Browse all 5359

Trending Articles