Lely core libraries  2.2.5
attr.c File Reference

This file is part of the I/O library; it contains the implementation of the serial I/O attributes functions. More...

#include "attr.h"
#include "io.h"
#include <lely/util/errnum.h>
#include <assert.h>
Include dependency graph for attr.c:

Go to the source code of this file.

Functions

int io_attr_get_speed (const io_attr_t *attr)
 Returns the baud rate from the attributes of a serial I/O device, or -1 on error. More...
 
int io_attr_set_speed (io_attr_t *attr, int speed)
 Sets the baud rate of a serial I/O device. More...
 
int io_attr_get_flow_control (const io_attr_t *attr)
 Checks if flow control is enabled in the attributes of a serial I/O device. More...
 
int io_attr_set_flow_control (io_attr_t *attr, int flow_control)
 Disables flow control for a serial I/O device if flow_control is zero, and enables it otherwise. More...
 
int io_attr_get_parity (const io_attr_t *attr)
 Obtains the parity scheme from the attributes of a serial I/O device. More...
 
int io_attr_set_parity (io_attr_t *attr, int parity)
 Sets the parity scheme of a serial I/O device. More...
 
int io_attr_get_stop_bits (const io_attr_t *attr)
 Obtains the number of stop bits used from the attributes of a serial I/O device. More...
 
int io_attr_set_stop_bits (io_attr_t *attr, int stop_bits)
 Sets the number of stop bits used in a serial I/O device to one if stop_bits is zero, and two otherwise. More...
 
int io_attr_get_char_size (const io_attr_t *attr)
 Obtains the character size (in bits) from the attributes of a serial I/O device. More...
 
int io_attr_set_char_size (io_attr_t *attr, int char_size)
 Sets the character size (in bits) of a serial I/O device. More...
 

Detailed Description

This file is part of the I/O library; it contains the implementation of the serial I/O attributes functions.

See also
lely/io/attr.h
Author
J. S. Seldenthuis jseld.nosp@m.enth.nosp@m.uis@l.nosp@m.ely..nosp@m.com

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Definition in file attr.c.

Function Documentation

◆ io_attr_get_speed()

int io_attr_get_speed ( const io_attr_t attr)

Returns the baud rate from the attributes of a serial I/O device, or -1 on error.

See also
io_attr_set_speed()

Definition at line 33 of file attr.c.

◆ io_attr_set_speed()

int io_attr_set_speed ( io_attr_t attr,
int  speed 
)

Sets the baud rate of a serial I/O device.

Note that the new device attributes will not take effect until a call to io_serial_set_attr().

Parameters
attra pointer to the current device attributes.
speedthe input and output baud rate. Note that not all possible values are supported.
Returns
0 on success, or -1 on error. In the latter case, the error number can be obtained with get_errc().
See also
io_attr_get_speed()

Definition at line 108 of file attr.c.

◆ io_attr_get_flow_control()

int io_attr_get_flow_control ( const io_attr_t attr)

Checks if flow control is enabled in the attributes of a serial I/O device.

Returns
1 if flow control is enabled and 0 if not, or -1 on error. In the latter case, the error number can be obtained with get_errc().
See also
io_attr_set_flow_control()

Definition at line 193 of file attr.c.

◆ io_attr_set_flow_control()

int io_attr_set_flow_control ( io_attr_t attr,
int  flow_control 
)

Disables flow control for a serial I/O device if flow_control is zero, and enables it otherwise.

Note that the new device attributes will not take effect until a call to io_serial_set_attr().

Returns
0 on success, or -1 on error. In the latter case, the error number can be obtained with get_errc().
See also
io_attr_get_flow_control()

Definition at line 206 of file attr.c.

◆ io_attr_get_parity()

int io_attr_get_parity ( const io_attr_t attr)

Obtains the parity scheme from the attributes of a serial I/O device.

Returns
IO_PARITY_NONE, IO_PARITY_ODD or IO_PARITY_EVEN, or -1 on error. In the latter case, the error number can be obtained with get_errc().
See also
io_attr_set_parity()

Definition at line 237 of file attr.c.

◆ io_attr_set_parity()

int io_attr_set_parity ( io_attr_t attr,
int  parity 
)

Sets the parity scheme of a serial I/O device.

Note that the new device attributes will not take effect until a call to io_serial_set_attr().

Parameters
attra pointer to the current device attributes.
paritythe parity scheme to be used (one of IO_PARITY_NONE, IO_PARITY_ODD or IO_PARITY_EVEN).
Returns
0 on success, or -1 on error. In the latter case, the error number can be obtained with get_errc().
See also
io_attr_get_parity()

Definition at line 256 of file attr.c.

◆ io_attr_get_stop_bits()

int io_attr_get_stop_bits ( const io_attr_t attr)

Obtains the number of stop bits used from the attributes of a serial I/O device.

Returns
1 is two stop bits are used and 0 if one bit is used, or -1 on error. In the latter case, the error number can be obtained with get_errc().
See also
io_attr_set_stop_bits()

Definition at line 301 of file attr.c.

◆ io_attr_set_stop_bits()

int io_attr_set_stop_bits ( io_attr_t attr,
int  stop_bits 
)

Sets the number of stop bits used in a serial I/O device to one if stop_bits is zero, and two otherwise.

Note that the new device attributes will not take effect until a call to io_serial_set_attr().

Returns
0 on success, or -1 on error. In the latter case, the error number can be obtained with get_errc().
See also
io_attr_get_stop_bits()

Definition at line 313 of file attr.c.

◆ io_attr_get_char_size()

int io_attr_get_char_size ( const io_attr_t attr)

Obtains the character size (in bits) from the attributes of a serial I/O device.

Returns
the character size, or -1 on error. In the latter case, the error number can be obtained with get_errc().
See also
io_attr_set_char_size()

Definition at line 337 of file attr.c.

◆ io_attr_set_char_size()

int io_attr_set_char_size ( io_attr_t attr,
int  char_size 
)

Sets the character size (in bits) of a serial I/O device.

Note that the new device attributes will not take effect until a call to io_serial_set_attr().

Returns
0 on success, or -1 on error. In the latter case, the error number can be obtained with get_errc().
See also
io_attr_get_char_size()

Definition at line 355 of file attr.c.