#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.
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.