class documentation

Class representing a UART (Universal Asynchronous Receiver-Transmitter) interface.

Method __del__ Deinitialize the UART interface.
Method __init__ Initialize the UART interface.
Method clear Clear the serial buffer
Method flush Flush the UART interface.
Method println Write a message followed by a newline to the UART interface.
Method read_into Read data from the UART interface into a buffer.
Method read_line Read a line from the UART interface with timeout handling.
Method read_serial_line Read a line from the UART interface.
Method set_callback Set an interrupt handler to be called when a UART event occurs.
Method timeout.setter Set the timeout value in milliseconds.
Method write Write a message to the UART interface.
Property baud_rate Get the baud rate of the UART interface.
Property has_data Check if there is data available to read from the UART interface.
Property is_sending Check if the UART interface is currently sending data.
Property rx_pin Get the RX pin number.
Property timeout Get the timeout value in milliseconds.
Property tx_pin Get the TX pin number.
Property uart Get the UART context.
Instance Variable _baud_rate Undocumented
Instance Variable _rx_pin Undocumented
Instance Variable _timeout Undocumented
Instance Variable _tx_pin Undocumented
Instance Variable _uart Undocumented
Instance Variable _uart_id Undocumented
def __del__(self):

Deinitialize the UART interface.

def __init__(self, uart_id: int = None, tx_pin: int = None, rx_pin: int = None, baud_rate: int = 115200, timeout: int = 2000):

Initialize the UART interface.

Parameters
uart_id:int or NoneUART peripheral ID, or None for the board default. Defaults to None.
tx_pin:int or NoneTX pin number, or None for the board default. Defaults to None.
rx_pin:int or NoneRX pin number, or None for the board default. Defaults to None.
baud_rate:intBaud rate for the interface. Defaults to 115200.
timeout:intRead timeout in milliseconds. Defaults to 2000.
Raises
ExceptionIf the UART peripheral could not be initialized.
def clear(self):

Clear the serial buffer

def flush(self):

Flush the UART interface.

def println(self, message: str):

Write a message followed by a newline to the UART interface.

Parameters
message:strThe message to write.
def read_into(self, buffer: bytearray) -> int:

Read data from the UART interface into a buffer.

Parameters
buffer:bytearrayThe buffer to read data into.
Returns
intThe number of bytes read.
def read_line(self) -> str:

Read a line from the UART interface with timeout handling.

Returns
str or NoneThe line read without a trailing newline, or None on timeout.
def read_serial_line(self) -> str:

Read a line from the UART interface.

Returns
strThe decoded data read, or an empty string if none.
def set_callback(self, callback):

Set an interrupt handler to be called when a UART event occurs.

Parameters
callback:callableThe interrupt handler function.
def timeout(self, value: int):

Set the timeout value in milliseconds.

Parameters
value:intThe timeout value in milliseconds.
def write(self, message: bytes):

Write a message to the UART interface.

Parameters
message:bytesThe bytes to write.
@property
baud_rate: int =

Get the baud rate of the UART interface.

@property
has_data: bool =

Check if there is data available to read from the UART interface.

@property
is_sending: bool =

Check if the UART interface is currently sending data.

@property
rx_pin: int =

Get the RX pin number.

@property
timeout: int =

Get the timeout value in milliseconds.

@property
tx_pin: int =

Get the TX pin number.

@property
uart =

Get the UART context.

_baud_rate =

Undocumented

_rx_pin =

Undocumented

_timeout =

Undocumented

_tx_pin =

Undocumented

_uart =

Undocumented

_uart_id =

Undocumented