O2S C Library 1.8.2
Provide high-level data-structures and other fundamental tools for C projects
Loading...
Searching...
No Matches
apply_options.c
Go to the documentation of this file.
1/* ************************************************************************** */
2/* ____ _ _____ ____ _ _ _ _____ _ _ ____ ____ */
3/* / ___| / \ | ___| _ \ / \ | \ | | |_ _| || | | _ \/ ___| */
4/* \___ \ / _ \ | |_ | |_) | / _ \ | \| | | | | || |_| | | \___ \ */
5/* ___) / ___ \| _| | _ < / ___ \| |\ | | | |__ _| |_| |___) | */
6/* |____/_/ \_|_| |_| \_/_/ \_|_| \_| |_| |_| |____/|____/ */
7/* */
14/* ************************************************************************** */
15
16#include "o2s/log.h"
17#include "o2s/serial.h"
18
19#include <termios.h> // tcsetattr
20
21#include <errno.h>
22#include <iso646.h> // not
23#include <stdbool.h>
24#include <string.h> // strerror
25
27bool serial_apply_options(serial_port_t* port)
28{
29 if (not port->got_options)
30 return false;
31 if (tcsetattr(port->file.descriptor, TCSANOW, &port->options.termios) != 0)
32 {
33 log_error("Unable to apply the attributes of the terminal: %s", strerror(errno));
34 return false;
35 }
36 port->got_options = false;
37 return true;
38}
bool serial_apply_options(serial_port_t *port)
Apply the options immediatly.
Simplistic logging utilities.
#define log_error(...)
Report a condition causing the current operation to abort.
Definition log.h:83
Configure and read from serial ports as buffered input streams.
Dynamic string implementation.