QUERY · ISSUE
esp32 - uart - uasyncio streamreader, always receive b"" from RS485
bugextmod
after commit for uasyncio streamreader, data read from rs485 always b"". If reverse back, start works like before.
https://github.com/micropython/micropython/commit/db7682e02d3ffd3338f20effc9ad4735a48bf774
for example.
self.ac_uart = UART(2, baudrate=9600, tx=14, rx=15)
self.ac_swriter = asyncio.StreamWriter(self.ac_uart, {})
self.ac_sreader = asyncio.StreamReader(self.ac_uart)
while True:
data = await self.ac_sreader.read(-1)
log.info(f" RAW: {data}")
CANDIDATE · ISSUE
Fatal Uasyncio/Uart Stream Lifecycle Bug (STM32)
extmod
When calling aclose (maps to Stream.wait_closed) on the new implementation of Stream, something goes awry in the stream read process and begins raising exceptions. This will likely have a fatal impact on any projects using UARTs with any life cycle when migrating to uasyncio v3.
After calling aclose the following stack trace is seen:
AssertionError:
...
File "uasyncio/stream.py", line 30, in read
File "uasyncio/core.py", line 94, in queue_read
File "uasyncio/core.py", line 82, in _enqueue
It keeps repeating rapidly forever..
Steps to reproduce:
- Open a UART connection using the stream reader 'streamReader = asyncio.StreamReader(uart)'
- Listen to the stream reader using streamReader.read(n)
- Close the stream reader
- Not sure if this is required, but open a new stream reader on the same UART again
Notes:
- The read is not being "released" when closing the stream reader, and thus tries to continue to read on a closed stream reader.
yield IOReadDone(self.polls)was in the v2 implementation and no equivalent operation exists in the v3.