Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/adafruit_blinka/microcontroller/rp2040/uart.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,8 @@ def readline(self):
def write(self, buf):
"""Write to the UART from a buffer"""
return self._uart.write(buf)

@property
def in_waiting(self):
"""The number of bytes in the input buffer, available to be read"""
return self._uart.any()
11 changes: 11 additions & 0 deletions src/busio.py
Original file line number Diff line number Diff line change
Expand Up @@ -628,3 +628,14 @@ def readline(self):
def write(self, buf):
"""Write to the UART from a buffer"""
return self._uart.write(buf)

@property
def in_waiting(self):
"""The number of bytes in the input buffer, available to be read"""
# Custom UART implementations (e.g. RP2040) that provide in_waiting directly
if hasattr(self._uart, "in_waiting"):
return self._uart.in_waiting
# MicroPython's machine.UART uses any() for the same purpose
if hasattr(self._uart, "any"):
return self._uart.any()
raise NotImplementedError("in_waiting not supported on this platform")
Loading