.\" man page for Munts Technologies Linux Simple I/O Library .\" .\" Copyright (C)2016-2023, Philip Munts dba Munts Technologies. .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions are met: .\" .\" * Redistributions of source code must retain the above copyright notice, .\" this list of conditions and the following disclaimer. .\" .\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" .\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE .\" ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE .\" LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR .\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF .\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS .\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN .\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE .\" POSSIBILITY OF SUCH DAMAGE. .\" .TH libserial 2 "21 December 2018" "version 1" "Linux Simple I/O Library" .SH NAME .B libserial \-\- Linux Simple I/O Library: Asynchronous Serial Port Module .SH SYNOPSIS .nf .B #include .B typedef enum .B { .B " SERIAL_PARITY_NONE," .B " SERIAL_PARITY_EVEN," .B " SERIAL_PARITY_ODD," .B } SERIAL_PARITY_t; .BI "void SERIAL_open(const char *" name ", int32_t " baudrate ", int32_t " parity "," .BI " int32_t " databits ", int32_t " stopbits ", int32_t *"fd ", int32_t *" error ");" .BI "void SERIAL_close(int32_t " fd ", int32_t *" error ");" .BI "void SERIAL_send(int32_t " fd ", void *" buf ", int32_t " bufsize "," .BI " int32_t *" count ", int32_t *" error ");" .BI "void SERIAL_receive(int32_t " fd ", void *" buf ", int32_t " bufsize "," .BI " int32_t *" count ", int32_t *" error ");" .fi Link with .BR -lsimpleio . .SH DESCRIPTION .nh All functions return either .B 0 (upon success) or an .B errno value (upon failure) in .IR *error . .PP .B SERIAL_open() opens and configures a serial port device. The device name must be passed in the .I name parameter. The .I baudrate parameter sets the serial port bit rate. Allowed values are .BR 50 ", " 75 ", " 110 ", " 134 ", " 150 ", " 200 ", " 300 ", " 600 ", " .BR 1200 ", " 1800 ", " 2400 ", " 4800 ", " 9600 ", " 19200 ", " 38400 ", " .BR 57600 ", " 115200 ", " 230400 ", " 460800 ", " 500000 ", " 576000 ", " .BR 921600 ", and " 1000000 "." The .I parity parameter sets the parity mode. Allowed values are .BR SERIAL_PARITY_NONE ", " SERIAL_PARITY_EVEN ", and " SERIAL_PARITY_ODD . The .I databits parameter sets the number of bits per character, and may be from .BR 5 " to " 8 . The .I stopbits parameter sets the number of stop bits per character, and may be .BR 1 " or " 2 . Upon success, a file descriptor for the serial port device is returned in .IR *fd . .PP .B SERIAL_close() closes a previously opened serial port device. The serial port device file descriptor is passed in .IR fd . .P .B SERIAL_send() sends data to the serial port device. The serial port device file descriptor is passed in .IR fd . The transmit buffer address is passed in .IR buf and its size is passed in .IR bufsize . Upon success, the number of bytes actually sent will be returned in .IR *count . .PP .B SERIAL_receive() receives data from the serial port device. The serial port device file descriptor is passed in .IR fd . The receive buffer address is passed in .IR buf and its size is passed in .IR bufsize . Upon success, the number of bytes actually received will be returned in .IR *count . .PP .SH SEE ALSO .BR libsimpleio "(2), " libadc "(2), " libdac "(2), " libevent "(2), " libgpio "(2)," .br .BR libhidraw "(2), " libi2c "(2), " libipv4 "(2), " liblinux "(2), " liblinx "(2)," .br .BR libpwm "(2), " libspi "(2), " libstream "(2), " libwatchdog "(2)" .SH AUTHOR Philip Munts dba Munts Technologies.