Using uart on pico #16419
-
I've not actually used the pico uart before (or uart on anything so forgive a noob question), but I have 2 pico's and wired their serial gpio pins together (rx/tx swapped and grounds connected)
if the receiver pico has the following (uart0.read() )
I get: If the receiver pico has the following (uart0.readline() )
I get: I was expecting the printouts to be the other way round - i.e. the uart0.readline() would only print out once a '\n' was received, and the read would print out each character, but to my surprise its the other way round. This is probably my misunderstanding, but I would appreciate it is someone would confirm the pico is working as expected, and thats the way the uart is supposed to work. (or perhaps to point out that my test received code is flawed, as I cant find appropriate examples with a quick google of micropython uart) |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
You want to add: |
Beta Was this translation helpful? Give feedback.
-
Thanks for that quick response. Putting in the timeouts you suggest makes the readline() work as I though it should. |
Beta Was this translation helpful? Give feedback.
You want to add:
timeout=: specifies the time to wait for the first character (in ms).
timeout_char=: specifies the time to wait between characters (in ms).
on the receiver side. Maybe 10ms…
Otherwise the UART doesn't wait for the rest of the line.
uart0 = UART(0, baudrate=9600, tx=Pin(0), rx=Pin(1), timeout=10, timeout_char=10)