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 |
Read data from the UART interface into a buffer. |
| Method | read |
Read a line from the UART interface with timeout handling. |
| Method | read |
Read a line from the UART interface. |
| Method | set |
Set an interrupt handler to be called when a UART event occurs. |
| Method | timeout |
Set the timeout value in milliseconds. |
| Method | write |
Write a message to the UART interface. |
| Property | baud |
Get the baud rate of the UART interface. |
| Property | has |
Check if there is data available to read from the UART interface. |
| Property | is |
Check if the UART interface is currently sending data. |
| Property | rx |
Get the RX pin number. |
| Property | timeout |
Get the timeout value in milliseconds. |
| Property | tx |
Get the TX pin number. |
| Property | uart |
Get the UART context. |
| Instance Variable | _baud |
Undocumented |
| Instance Variable | _rx |
Undocumented |
| Instance Variable | _timeout |
Undocumented |
| Instance Variable | _tx |
Undocumented |
| Instance Variable | _uart |
Undocumented |
| Instance Variable | _uart |
Undocumented |
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 | |
uartint or None | UART peripheral ID, or None for the board default. Defaults to None. |
txint or None | TX pin number, or None for the board default. Defaults to None. |
rxint or None | RX pin number, or None for the board default. Defaults to None. |
baudint | Baud rate for the interface. Defaults to 115200. |
timeout:int | Read timeout in milliseconds. Defaults to 2000. |
| Raises | |
Exception | If the UART peripheral could not be initialized. |
Write a message followed by a newline to the UART interface.
| Parameters | |
message:str | The message to write. |
Read data from the UART interface into a buffer.
| Parameters | |
buffer:bytearray | The buffer to read data into. |
| Returns | |
int | The number of bytes read. |
Read a line from the UART interface with timeout handling.
| Returns | |
str or None | The line read without a trailing newline, or None on timeout. |
Set an interrupt handler to be called when a UART event occurs.
| Parameters | |
callback:callable | The interrupt handler function. |