![]() |
O2S C Library 1.8.2
Provide high-level data-structures and other fundamental tools for C projects
|
Configure and read from serial ports as buffered input streams. More...
#include "o2s/file_input_stream.h"
#include "o2s/serial_options.h"
#include <stdbool.h>
#include <stdint.h>
Go to the source code of this file.
Data Structures | |
struct | serial_port_t |
Serial port handler, includes a buffer. More... |
Macros | |
#define | Serial |
Use the RAII with serial ports. |
Functions | |
Contructor and destructor | |
serial_port_t | serial_open_readonly (const char *port_name) |
Open the port in read-only, and allocate the buffer. | |
serial_port_t | serial_open_readwrite (const char *port_name) |
Open the port in read and write, and allocate the buffer. | |
void | serial_close (serial_port_t *port) |
Closes the specified serial port. | |
serial_port_t * | serial_new_readwrite (const char *port_name) |
Allocates a serial port and opens it. | |
void | serial_free (serial_port_t **port) |
Close and free a serial port created with serial_new_readwrite. | |
Modifiers | |
bool | serial_get_options (serial_port_t *port) |
Ask the port for its configuration. | |
bool | serial_apply_options (serial_port_t *port) |
Apply the options immediatly. | |
bool | serial_set_options_raw (serial_port_t *port) |
Modify the copy of the options, but do not apply them. | |
bool | serial_set_options_speed (serial_port_t *port, int64_t speed_bps) |
Modify the copy of the options about speed, but do not apply them. | |
bool | serial_make_raw (serial_port_t *port, int64_t speed_bps) |
General configuration for non-canonical mode. | |
Utilities | |
int64_t | serial_decode_baudrate (speed_t flag) |
Convert the baudrate from termios to bits per second. | |
speed_t | serial_encode_baudrate (int64_t speed_in_bps) |
Convert the baudrate to a system specific enum. |
Configure and read from serial ports as buffered input streams.
Definition in file serial.h.
#define Serial |
Use the RAII with serial ports.
In a situation where one wants to declare a serial port variable on the stack in the local scope, this "typedef" can be used for the port to be closed automatically when the variable goes out of scope.
It means this "typedef" can only be used like this :
void serial_close | ( | serial_port_t * | port | ) |
int64_t serial_decode_baudrate | ( | speed_t | flag | ) |
Convert the baudrate from termios to bits per second.
Definition at line 28 of file baudrate.c.
speed_t serial_encode_baudrate | ( | int64_t | speed_in_bps | ) |
Convert the baudrate to a system specific enum.
Definition at line 74 of file baudrate.c.
bool serial_make_raw | ( | serial_port_t * | port, |
int64_t | speed_bps ) |
General configuration for non-canonical mode.
Sets the terminal to something like the "raw" mode of the old Version 7 terminal driver: input is available character by character, echoing is disabled, and all special processing of terminal input and output characters is disabled.
Definition at line 88 of file make_raw.c.
bool serial_set_options_raw | ( | serial_port_t * | port | ) |
Modify the copy of the options, but do not apply them.
Definition at line 29 of file make_raw.c.