From 20cb29c2f8c5c87bc590896854a20b1473ceb358 Mon Sep 17 00:00:00 2001 From: "info@mode42.com" Date: Sat, 8 Aug 2026 03:54:55 +0000 Subject: #2 --- plugins/packet_radio/serial_port.h | 52 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 plugins/packet_radio/serial_port.h (limited to 'plugins/packet_radio/serial_port.h') diff --git a/plugins/packet_radio/serial_port.h b/plugins/packet_radio/serial_port.h new file mode 100644 index 0000000..549d3c5 --- /dev/null +++ b/plugins/packet_radio/serial_port.h @@ -0,0 +1,52 @@ +#ifndef HYBBX_SERIAL_PORT_H +#define HYBBX_SERIAL_PORT_H + +#include "hybbx/types.h" + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct hybbx_serial_port hybbx_serial_port_t; + +typedef enum hybbx_serial_parity { + HYBBX_SERIAL_PARITY_NONE = 0, + HYBBX_SERIAL_PARITY_EVEN = 1, + HYBBX_SERIAL_PARITY_ODD = 2 +} hybbx_serial_parity_t; + +typedef struct hybbx_serial_params { + unsigned int baud; + unsigned int data_bits; + hybbx_serial_parity_t parity; + unsigned int stop_bits; + int assert_modem_lines; +} hybbx_serial_params_t; + +void hybbx_serial_params_default(hybbx_serial_params_t *params, + unsigned int baud); + +hybbx_result_t hybbx_serial_open(hybbx_serial_port_t **out, + const char *device, + const hybbx_serial_params_t *params); + +void hybbx_serial_close(hybbx_serial_port_t *port); + +hybbx_result_t hybbx_serial_write(hybbx_serial_port_t *port, + const uint8_t *data, size_t len); + +hybbx_result_t hybbx_serial_read(hybbx_serial_port_t *port, + uint8_t *buf, size_t buf_len, + size_t *read_len); + +/** POSIX serial fd for poll/select; returns -1 when unavailable. */ +int hybbx_serial_fd(const hybbx_serial_port_t *port); + +#ifdef __cplusplus +} +#endif + +#endif /* HYBBX_SERIAL_PORT_H */ -- cgit v1.3.1