O2S C Library 1.8.2
Provide high-level data-structures and other fundamental tools for C projects
Loading...
Searching...
No Matches
get_options.c
1/* ************************************************************************** */
2/* ____ _ _____ ____ _ _ _ _____ _ _ ____ ____ */
3/* / ___| / \ | ___| _ \ / \ | \ | | |_ _| || | | _ \/ ___| */
4/* \___ \ / _ \ | |_ | |_) | / _ \ | \| | | | | || |_| | | \___ \ */
5/* ___) / ___ \| _| | _ < / ___ \| |\ | | | |__ _| |_| |___) | */
6/* |____/_/ \_|_| |_| \_/_/ \_|_| \_| |_| |_| |____/|____/ */
7/* */
8/* Copyright 2023, SAFRAN T4DS, ALL RIGHTS RESERVED */
9/* */
10/* @file get_options.c */
11/* @author Antoine GAGNIERE */
12/* */
13/* ************************************************************************** */
14
15#include "o2s/log.h"
16#include "o2s/serial.h"
17
18#include <termios.h> // tcgetattr
19
20#include <errno.h>
21#include <stdbool.h>
22#include <string.h> // strerror
23
27bool serial_get_options(serial_port_t* port)
28{
29 if (port->got_options)
30 return true;
31 if (tcgetattr(port->file.descriptor, &port->options.termios) != 0)
32 {
33 log_error("Unable to get the attributes of the terminal: %s", strerror(errno));
34 return false;
35 }
36 port->got_options = true;
37 return true;
38}
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.