libosmocore UNKNOWN
Osmocom core library
Loading...
Searching...
No Matches
Utility functions to deal with serial ports

Osmocom serial port helpers More...

Files

file  include/osmocom/core/serial.h
 Osmocom serial port helpers.
file  src/core/serial.c
 Utility functions to deal with serial ports.

Macros

#define dbg_perror(x)

Functions

int osmo_serial_init (const char *dev, speed_t baudrate)
 Open serial device and does base init.
int osmo_serial_set_baudrate (int fd, speed_t baudrate)
 Change current baudrate.
int osmo_serial_set_custom_baudrate (int fd, int baudrate)
 Change current baudrate to a custom one using OS specific method.
int osmo_serial_clear_custom_baudrate (int fd)
 Clear any custom baudrate.
int osmo_serial_speed_t (unsigned int baudrate, speed_t *speed)
 Convert unsigned integer value to speed_t.
static int _osmo_serial_set_baudrate (int fd, speed_t baudrate)

Detailed Description

Osmocom serial port helpers

Macro Definition Documentation

◆ dbg_perror

Function Documentation

◆ _osmo_serial_set_baudrate()

int _osmo_serial_set_baudrate ( int fd,
speed_t baudrate )
static

◆ osmo_serial_clear_custom_baudrate()

int osmo_serial_clear_custom_baudrate ( int fd)

Clear any custom baudrate.

Parameters
[in]fdFile descriptor of the open device
Returns
0 for success or negative errno.

This function might not work on all OS or with all type of serial adapters

References dbg_perror.

Referenced by osmo_serial_set_baudrate().

◆ osmo_serial_init()

int osmo_serial_init ( const char * dev,
speed_t baudrate )

Open serial device and does base init.

Parameters
[in]devPath to the device node to open
[in]baudrateBaudrate constant (speed_t: B9600, B...)
Returns
>=0 file descriptor in case of success or negative errno.

References dbg_perror.

◆ osmo_serial_set_baudrate()

int osmo_serial_set_baudrate ( int fd,
speed_t baudrate )

Change current baudrate.

Parameters
[in]fdFile descriptor of the open device
[in]baudrateBaudrate constant (speed_t: B9600, B...)
Returns
0 for success or negative errno.

References _osmo_serial_set_baudrate(), and osmo_serial_clear_custom_baudrate().

◆ osmo_serial_set_custom_baudrate()

int osmo_serial_set_custom_baudrate ( int fd,
int baudrate )

Change current baudrate to a custom one using OS specific method.

Parameters
[in]fdFile descriptor of the open device
[in]baudrateBaudrate as integer
Returns
0 for success or negative errno.

This function might not work on all OS or with all type of serial adapters

References _osmo_serial_set_baudrate(), and dbg_perror.

◆ osmo_serial_speed_t()

int osmo_serial_speed_t ( unsigned int baudrate,
speed_t * speed )

Convert unsigned integer value to speed_t.

Parameters
[in]baudrateinteger value containing the desired standard baudrate
[out]speedthe standrd baudrate requested in speed_t format
Returns
0 for success or negative errno.