blob: 549d3c57f9573e6ab2c66902b312bdefd5d933c3 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
#ifndef HYBBX_SERIAL_PORT_H
#define HYBBX_SERIAL_PORT_H
#include "hybbx/types.h"
#include <stddef.h>
#include <stdint.h>
#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 */
|