zephyr_serial – Zephyr UART driver for fixed busses.

Available on these boards
  • Nordic Semiconductor nRF5340 DK
  • Nordic Semiconductor nRF54L15 DK
  • Nordic Semiconductor nRF7002 DK
  • Renesas Electronics Corporation RA6M5 Evaluation Kit
  • Renesas Electronics Corporation RA8D1 Evaluation Kit
  • STMicroelectronics Nucleo U575ZI Q
  • STMicroelectronics STM32H7B3I Discovery kit

class zephyr_serial.UART
A bidirectional serial protocol. Already initialized for Zephyr defined

busses in board.

Available on these boards
    {% for board in support_matrix_reverse["zephyr_serial.UART"] %}
  • {{ board }} {% endfor %}

deinit() None

Deinitialises the UART and releases any hardware resources for reuse.

__enter__() UART

No-op used by Context Managers.

__exit__() None

Automatically deinitializes the hardware when exiting a context. See Lifetime and ContextManagers for more info.

read(nbytes: int | None = None) bytes | None

Read bytes. If nbytes is specified then read at most that many bytes. Otherwise, read everything that arrives until the connection times out. Providing the number of bytes expected is highly recommended because it will be faster. If no bytes are read, return None.

Note

When no bytes are read due to a timeout, this function returns None. This matches the behavior of io.RawIOBase.read in Python 3, but differs from pyserial which returns b'' in that situation.

Returns:

Data read

Return type:

bytes or None

readinto(buf: circuitpython_typing.WriteableBuffer) int | None

Read bytes into the buf. Read at most len(buf) bytes.

Returns:

number of bytes read and stored into buf

Return type:

int or None (on a non-blocking error)

New in CircuitPython 4.0: No length parameter is permitted.

readline() bytes

Read a line, ending in a newline character, or return None if a timeout occurs sooner, or return everything readable if no newline is found and timeout=0

Returns:

the line read

Return type:

bytes or None

write(buf: circuitpython_typing.ReadableBuffer) int | None

Write the buffer of bytes to the bus.

New in CircuitPython 4.0: buf must be bytes, not a string.

return:

the number of bytes written

rtype:

int or None

baudrate: int

The current baudrate.

in_waiting: int

The number of bytes in the input buffer, available to be read

timeout: float

The current timeout, in seconds (float).

reset_input_buffer() None

Discard any unread characters in the input buffer.