uasyncio StreamReader uart problem.
uasyncio StreamReader uart problem.
Hi. How to solve simultaneous get data from UART, and a task in another async function. I have a problem because when another function that is quite heavy on the system is looping etc, the data from the UART is truncated. I am using one StreamWriter. Thanks.
- pythoncoder
- Posts: 5956
- Joined: Fri Jul 18, 2014 8:01 am
- Location: UK
- Contact:
Re: uasyncio StreamReader uart problem.
You haven't given us much to go on here. What hardware are you using? The following is based on my impression of what may be going on in your code.
If you have coroutines which block for significant periods of time it is possible for the UART receive buffer to overrun. Currently uasyncio services I/O in round-robin fashion with the other tasks. This is not ideal and improvements are planned.
If you are losing received data options are:
If you have coroutines which block for significant periods of time it is possible for the UART receive buffer to overrun. Currently uasyncio services I/O in round-robin fashion with the other tasks. This is not ideal and improvements are planned.
If you are losing received data options are:
- Reduce the worst-case blocking times in your tasks to increase the UART polling frequency.
- Increase the UART receive buffer size (a constructor option on some platforms).
- Reduce baud rate.
- Implement RTS/CTS UART flow control (supported in hardware on some platforms).
- Implement software flow control in code (XON/XOFF or other).
Peter Hinch
Index to my micropython libraries.
Index to my micropython libraries.
Re: uasyncio StreamReader uart problem.
Ok. Reduce worst-case blocking times it helped. Thanks for the explanation.