PyBoard - Non-blocking console I/O #10183
Replies: 3 comments
-
Do you mean you want to use the USB interface on the pyboard in the form of serial communication? This is possible, you can refer to the USB_VCP part of the documentation, it works very much like a UART. As for the usage of non-blocking, there are two ways that I know, one is to use multi-threading (use Tips: If you need to use |
Beta Was this translation helpful? Give feedback.
-
If you're using it via stdin, you can use select/poll. https://docs.micropython.org/en/latest/library/select.html (This is easy to use via asyncio as @IlysvlVEizbr mentions above. See for example the If you detach the USB_VCP from stdin (via dupterm), then you can also use it directly as a stream. It implements the necessary bits to be used via select/poll too (I haven't tested it recently, but it's supposed to work). |
Beta Was this translation helpful? Give feedback.
-
Got it! Thanks to all. |
Beta Was this translation helpful? Give feedback.
-
I have tried a couple of searches with no luck. It seems obvious (to me) that a board designed for real-time and IoT functions should be able to do console I/O (character- or byte-wise) without blocking the idle loop. I can find docs that indicate this is possible with STM32 UARTS, but not with the USB console on the PyBoard. There are work-arounds that allow this with mainstream Python. Does anyone have code snippet? It would be a lot easier than having to lash up RS-232 comms via a UART.
Beta Was this translation helpful? Give feedback.
All reactions