Thread-safe, non-blocking framed UART transmission for USHER. More...
#include <stdbool.h>#include <stddef.h>#include <stdint.h>

Go to the source code of this file.
Functions | |
| int | serial_tx_start (int descriptor) |
| Attach an already-open non-blocking UART descriptor. | |
| void | serial_tx_stop (void) |
| Discard pending output and detach the UART during shutdown/restart. | |
| int | serial_tx_send (uint8_t message, const uint8_t *payload, size_t length) |
| Queue and opportunistically flush one complete USHER frame. | |
| int | serial_tx_send_if_idle (uint8_t message, const uint8_t *payload, size_t length) |
| Send only when no earlier frame is queued, for low-priority probes. | |
| int | serial_tx_flush (void) |
| Continue writing queued bytes after POLLOUT reports readiness. | |
| bool | serial_tx_pending (void) |
| Report queued data or a latched output error needing event-loop handling. | |
Detailed Description
Thread-safe, non-blocking framed UART transmission for USHER.
Worker threads may finish camera jobs concurrently. This API serializes complete USHER frames through a bounded ring buffer so a slow UART cannot intermix bytes from independent messages or block a capture worker.
Definition in file serial_tx.h.
Function Documentation
◆ serial_tx_flush()
| int serial_tx_flush | ( | void | ) |
Continue writing queued bytes after POLLOUT reports readiness.
- Returns
- 0 when output remains usable, or -1 for a terminal transport failure.
Definition at line 166 of file serial_tx.c.
◆ serial_tx_pending()
| bool serial_tx_pending | ( | void | ) |
Report queued data or a latched output error needing event-loop handling.
- Returns
- True while the event loop should request POLLOUT and call serial_tx_flush().
Once set, output_error never clears itself; also report pending when it is set (even with an empty queue) so the caller's poll loop keeps asking for POLLOUT and promptly calls serial_tx_flush(), which surfaces the failure instead of leaving UART output silently and permanently stuck.
Definition at line 174 of file serial_tx.c.
◆ serial_tx_send()
| int serial_tx_send | ( | uint8_t | message, |
| const uint8_t * | payload, | ||
| size_t | length ) |
Queue and opportunistically flush one complete USHER frame.
- Parameters
-
message Protocol message ID. payload Payload bytes, or NULL when lengthis zero.length Payload size, limited by the one-byte protocol length field.
- Returns
- 0 if queued/flushed, or -1 when the buffer or transport cannot accept it.
Definition at line 156 of file serial_tx.c.
◆ serial_tx_send_if_idle()
| int serial_tx_send_if_idle | ( | uint8_t | message, |
| const uint8_t * | payload, | ||
| size_t | length ) |
Send only when no earlier frame is queued, for low-priority probes.
Avoids delaying flight-critical status traffic with a clock probe.
- Returns
- 0 on acceptance, or -1 with EAGAIN when output is busy.
Definition at line 161 of file serial_tx.c.
◆ serial_tx_start()
| int serial_tx_start | ( | int | descriptor | ) |
Attach an already-open non-blocking UART descriptor.
- Parameters
-
descriptor Descriptor configured with O_NONBLOCK.
- Returns
- 0 on success, or -1 with errno describing an invalid/busy descriptor.
Definition at line 71 of file serial_tx.c.
◆ serial_tx_stop()
| void serial_tx_stop | ( | void | ) |
Discard pending output and detach the UART during shutdown/restart.
Definition at line 92 of file serial_tx.c.