libserial

Section: Linux Simple I/O Library (2)
Updated: 21 December 2018
Index Return to Main Contents
 

NAME

libserial -- Linux Simple I/O Library: Asynchronous Serial Port Module  

SYNOPSIS

#include <libsimpleio/libserial.h>

typedef enum
{
  SERIAL_PARITY_NONE,
  SERIAL_PARITY_EVEN,
  SERIAL_PARITY_ODD,
} SERIAL_PARITY_t;

void SERIAL_open(const char *name, int32_t baudrate, int32_t parity,
  int32_t databits, int32_t stopbits, int32_t *fd, int32_t *error);

void SERIAL_close(int32_t fd, int32_t *error);

void SERIAL_send(int32_t fd, void *buf, int32_t bufsize,
  int32_t *count, int32_t *error);

void SERIAL_receive(int32_t fd, void *buf, int32_t bufsize,
  int32_t *count, int32_t *error);

Link with -lsimpleio.  

DESCRIPTION

All functions return either 0 (upon success) or an errno value (upon failure) in *error.

SERIAL_open() opens and configures a serial port device. The device name must be passed in the name parameter. The baudrate parameter sets the serial port bit rate. Allowed values are 50, 75, 110, 134, 150, 200, 300, 600, 1200, 1800, 2400, 4800, 9600, 19200, 38400, 57600, 115200, 230400, 460800, 500000, 576000, 921600, and 1000000. The parity parameter sets the parity mode. Allowed values are SERIAL_PARITY_NONE, SERIAL_PARITY_EVEN, and SERIAL_PARITY_ODD. The databits parameter sets the number of bits per character, and may be from 5 to 8. The stopbits parameter sets the number of stop bits per character, and may be 1 or 2. Upon success, a file descriptor for the serial port device is returned in *fd.

SERIAL_close() closes a previously opened serial port device. The serial port device file descriptor is passed in fd.

SERIAL_send() sends data to the serial port device. The serial port device file descriptor is passed in fd. The transmit buffer address is passed in buf and its size is passed in bufsize. Upon success, the number of bytes actually sent will be returned in *count.

SERIAL_receive() receives data from the serial port device. The serial port device file descriptor is passed in fd. The receive buffer address is passed in buf and its size is passed in bufsize. Upon success, the number of bytes actually received will be returned in *count.

 

SEE ALSO

libsimpleio(2), libadc(2), libdac(2), libevent(2), libgpio(2),
libhidraw(2), libi2c(2), libipv4(2), liblinux(2), liblinx(2),
libpwm(2), libspi(2), libstream(2), libwatchdog(2)  

AUTHOR

Philip Munts dba Munts Technologies


 

Index

NAME
SYNOPSIS
DESCRIPTION
SEE ALSO
AUTHOR

This document was created by man2html, using the manual pages.
Time: 03:28:51 GMT, October 30, 2023