You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
importtimeimportrandomimportboardimportbusioimportadafruit_pio_uarttime.sleep(3) # wait for serial# hardware setup: GP0 connected to GP27; GP1 connected to GP26uart_busio=busio.UART(board.GP0, board.GP1)
uart_pio=adafruit_pio_uart.UART(board.GP26, board.GP27)
forbuflenin (1, 2, 3, 7, 8, 9 ,10, 15, 16, 17, 18,):
buffer=bytearray()
for_inrange(0, buflen):
buffer.append(random.choice(b'abcdefghijklmnopqrstuvwxyz'))
print(f"\n{buflen=}{buffer=}")
# PIO to busiouart_busio.reset_input_buffer()
print(f"{uart_pio.write(buffer)=}")
print(f"{uart_busio.in_waiting=}")
print(f"{uart_busio.read(buflen)=}")
# busio to PIOuart_pio.reset_input_buffer()
print(f"{uart_busio.write(buffer)=}")
time.sleep(0.25) # w/o some wait, .in_waiting = 0print(f"{uart_pio.in_waiting=}")
print(f"{uart_pio.read(buflen)=}")
Behavior
Code above compares busio UART behavior to PIO UART behavior (using the adafruit_pio_uart library).
busio correctly shows in_waiting bytes matching the number of bytes sent. read correctly reads the number of bytes sent.
For PIO, in_waiting maxxes out at 8, and read maxxes out at 9 bytes regardless of how many bytes (>9) are written to the UART.
Description
No response
Additional information
As noted in the code comments above, .in_waiting for the PIO will return 0 unless there is some delay before checking it. This extra blocking could be a problem for efficient user code, especially asyncio.
The text was updated successfully, but these errors were encountered:
CircuitPython version and board name
Code/REPL
Behavior
Code above compares
busio
UART behavior to PIO UART behavior (using the adafruit_pio_uart library).busio
correctly showsin_waiting
bytes matching the number of bytes sent.read
correctly reads the number of bytes sent.For PIO,
in_waiting
maxxes out at 8, andread
maxxes out at 9 bytes regardless of how many bytes (>9) are written to the UART.Description
No response
Additional information
As noted in the code comments above,
.in_waiting
for the PIO will return0
unless there is some delay before checking it. This extra blocking could be a problem for efficient user code, especially asyncio.The text was updated successfully, but these errors were encountered: