Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adafruit_pio_uart.receive() should return None on no bytes received #3

Merged
merged 1 commit into from
Oct 12, 2024

Conversation

todbot
Copy link
Contributor

@todbot todbot commented Oct 11, 2024

To match busio.UART.receive(), adafruit_pio_uart.receive() should return None when no bytes are received.

E.g. This code below should print nothing until bytes are received. Currently it prints continuously because receive() returns an empty list.

import time
import board, busio
import adafruit_pio_uart
uart = adafruit_pio_uart.UART(tx=None, rx=board.SCL1, baudrate=31250, timeout=0.001)
while True:
    data = uart.read(3)  # read up to 3 bytes
    if data is not None:
        print("data:", ["%02x" % x for x in data])

Copy link
Contributor

@FoamyGuy FoamyGuy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense to me, the docs here confirm the behavior of returning None: https://docs.circuitpython.org/en/latest/shared-bindings/busio/index.html#busio.UART.read

Thank you!

@FoamyGuy FoamyGuy merged commit dbd647b into adafruit:main Oct 12, 2024
1 check passed
adafruit-adabot added a commit to adafruit/Adafruit_CircuitPython_Bundle that referenced this pull request Oct 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants