#include "serial.h"
#include <sys/stat.h>
#include <sys/time.h>
#include <fcntl.h>
#include <termios.h>
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include <errno.h>
Defines | |
| #define | debug(prg) { if (debug_flag) { prg } } |
| Run debug code if debugging is enabled. | |
Functions | |
| int | SERGetBaud (const char *baud_string, speed_t *serial_speed) |
| Get the baud rate from a string, and return the speed_t value. | |
| SerialPort * | new_SerialPort () |
| Create and initialise a new SerialPort structure. | |
| SerialPort * | SEROpenPort (const char *serialportname, speed_t serial_speed, char *logfilename) |
| Open a serial port, and set the baud rate. | |
| void | SERClosePort (SerialPort *sp) |
| Close and free a serial port. | |
| BYTE | SERGetByte (SerialPort *sp) |
| Get a byte from a serial port. | |
| void | SERPutByte (SerialPort *sp, BYTE b) |
| Put a byte to a serial port. | |
| int | SERPutString (SerialPort *sp, const char *s) |
| Put a string of bytes to a serial port. | |
| void | SERFlushChannel (SerialPort *sp, int usec) |
| Clear any bytes that arrive at a serial port for a period of time. | |
| int | SERQueryChannel (SerialPort *sp, int usec) |
| Test whether there is data waiting on a serial port. | |
| int | SERGetByteTimeout (SerialPort *sp, int usec) |
| Read a byte from a serial port with a timeout. | |
| int | SERGetBytesTimeout (SerialPort *sp, BYTE *buffer, int count, int usec) |
| Read some bytes from a serial port with a timeout. | |
Variables | |
| const int | debug_flag = 0 |
| Control whether debug code is run. | |
Copyright (C) 2003, 2004 Kirk Martinez, Alistair Riddoch, The University of Southampton
|
|
Create and initialise a new SerialPort structure. For internal use only.
|
|
|
Close and free a serial port. Cleans up, closes and deletes a serial port. If the port had a log file, close the file.
|
|
||||||||||||
|
Clear any bytes that arrive at a serial port for a period of time. Use select to wait for data to arrive at the serial port, and then read all data available.
|
|
||||||||||||
|
Get the baud rate from a string, and return the speed_t value. Accepts the baud name as a string. Any of the standard baud rates supported by standard serial ports should be accepted.
|
|
|
Get a byte from a serial port. Read a byte from a serial port. This blocks if no data is available.
|
|
||||||||||||||||||||
|
Read some bytes from a serial port with a timeout. Wait at most usec microseconds for data to be available on the given serial port, and then read some bytes if it they are available. This is repeated until enough bytes have been read. Behavoir on timeout is a little weird. Needs to be examined if you plan to use this code.
|
|
||||||||||||
|
Read a byte from a serial port with a timeout. Wait at most usec microseconds for data to be available on the given serial port, and then read one byte if it is available.
|
|
||||||||||||||||
|
Open a serial port, and set the baud rate.
|
|
||||||||||||
|
Put a byte to a serial port. Write a byte to a serial port. This blocks if the serial port is not ready to accept new data.
|
|
||||||||||||
|
Put a string of bytes to a serial port. Write a sequence of bytes to a serial port. This blocks if the serial port is not ready to accept new data.
|
|
||||||||||||
|
Test whether there is data waiting on a serial port. Use select to wait for data to be available at the serial port for a certain period of time.
|
|
|
Control whether debug code is run. Set to non-zero if debug code should be run. |
1.3.5