UART Packet Interface
The uart Packet Interface platform sends and receives packets over a serial port
configured with the UART component.
A serial port carries a stream of bytes with no packet boundaries, so each packet is framed:
- The byte
0x7Emarks the start and the end of each packet. - If the byte
0x7Eor0x7Dappears inside a packet, it is sent as0x7Dfollowed by the original byte XORed with0x20. For example,0x7Eis sent as0x7D 0x5E.
This is the same framing used by the UART Packet Transport platform, so a device using one can talk to a device using the other.
Received bytes outside a frame are ignored. A received packet larger than max_packet_size is discarded, and this
is logged only at the DEBUG level. A packet larger than max_packet_size is not sent: the send fails, and a warning
is logged. Use the same max_packet_size on both devices, so that neither sends packets the other discards.
Example Configuration
Section titled “Example Configuration”# Example configuration entryuart: tx_pin: GPIOXX rx_pin: GPIOXX baud_rate: 115200
packet_interface: - platform: uart id: serial_linkConfiguration Variables
Section titled “Configuration Variables”- uart_id (Optional, ID): The ID of the UART bus to use. Required only if more than one UART bus is configured.
- max_packet_size (Optional, int): The largest packet, in bytes, that can be sent or received. Range is 16 to
4096. Defaults to
508. Devices that talk to each other should use the same value. - id (Optional, ID): Manually specify the ID used for code generation.