UART Events Service

group UART Events Service
group Structures

Defines

UART_SERVICE_UID
UART_EVENT_PACKET_RECEIVED
UART_EVENT_ERROR_DETECTED
UART_EVENT_TX_COMPLETE
UART_RX_MAX_PACKET_SIZE
UART_PACKET_POOL_SIZE

Enums

enum uart_event_id_t

Values:

enumerator UART_PACKET_RECEIVED

Published when a valid OSUSatPacket is decoded. Payload: OSUSatPacket.

enumerator UART_ERROR_DETECTED

Published on hardware errors (Overrun, Noise) or CRC failures. Payload: uart_error_t (or generic error code)

enumerator UART_TX_COMPLETE

Published when a packet is successfully transmitted. Payload: NULL.

enum rx_state_t

Values:

enumerator RX_STATE_WAIT_START_BYTE

Waiting until a start byte is received

enumerator RX_STATE_READ_HEADER

Currently reading the packet header

enumerator RX_STATE_READ_PAYLOAD

Currently reading the packet payload

struct uart_events_t
#include <uart_events.h>

UART Service State Object.

Public Members

bool initialized

Whether the UART events service is initialized

uart_port_t port

The UART port the service is acting on

uint32_t rx_byte_count

Telemetry: total received bytes

uint32_t rx_packet_count

Telemetry: total packets decoded

uint32_t rx_crc_error_count

Telemetry: total errors counted

uint8_t pool_index

Index of the buffer currently being filled

uint16_t decode_index

Write position within the current buffer

rx_state_t rx_state

Current Rx state

uint16_t expected_packet_len

The expected packet length

group Public API

Functions

void uart_events_init(uart_events_t *uart, uart_port_t port)

Initialize the UART service.

Parameters:
  • uart[out] Service instance

  • port[in] Physical HAL port to use

void uart_events_send_packet(uart_events_t *uart, const OSUSatPacket *packet)

Queue a packet for transmission.

Uses osusat_packet_pack() to serialize before sending.

Parameters:
  • uart[inout] Service instance

  • packet[in] Pointer to the packet to send