← index #8867Issue #6576
Related · high · value 1.184
QUERY · ISSUE

esp32 - uart - uasyncio streamreader, always receive b"" from RS485

openby stragaopened 2022-07-05updated 2022-11-15
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)

closedby gtomassiopened 2020-10-28updated 2021-05-13
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:

  1. Open a UART connection using the stream reader 'streamReader = asyncio.StreamReader(uart)'
  2. Listen to the stream reader using streamReader.read(n)
  3. Close the stream reader
  4. 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.

Keyboard

j / / n
next pair
k / / p
previous pair
1 / / h
show query pane
2 / / l
show candidate pane
c
copy suggested comment
r
toggle reasoning
g i
go to index
?
show this help
esc
close overlays

press ? or esc to close

copied