libicsc  1.0.0
 All Data Structures Files Functions Modules
Functions
Serial

Helper functions to make working with serial devices easier. More...

Functions

int icsc_serial_open (const char *path, unsigned long baud)
 Open a serial device at a specific baud rate. More...
 
int icsc_serial_wait_available (int fd, unsigned long timeout)
 Wait for serial data to arrive up until the timeout expires. More...
 
int icsc_serial_available (int fd)
 Look to see if serial data is available. More...
 
int icsc_serial_read (int fd)
 Read a byte from the serial port. More...
 
void icsc_serial_flush (int fd)
 Wait until all data sent to the serial port has been delivered to the wire. More...
 
int icsc_serial_write (int fd, uint8_t c)
 Write a byte to a serial port. More...
 
void icsc_serial_close (int fd)
 Close the serial port. More...
 

Detailed Description

Helper functions to make working with serial devices easier.

Function Documentation

int icsc_serial_available ( int  fd)

Look to see if serial data is available.

Parameters
fdThe file descriptor of the port opened by icsc_serial_open()
Returns
1 if data is available, 0 if there is none, or -1 on an error.
void icsc_serial_close ( int  fd)

Close the serial port.

Parameters
fdThe file descriptor of the port opened by icsc_serial_open()
Returns
nothing
void icsc_serial_flush ( int  fd)

Wait until all data sent to the serial port has been delivered to the wire.

Parameters
fdThe file descriptor of the port opened by icsc_serial_open()
Returns
nothing
int icsc_serial_open ( const char *  path,
unsigned long  baud 
)

Open a serial device at a specific baud rate.

Parameters
pathPath to the serial device (e.g., /dev/ttyAMA0)
baudSymbolic baud rate for the port in the form Bxxx (e.g., B115200)
Returns
The file descriptor for the newly opened port or -1 on an error.
int icsc_serial_read ( int  fd)

Read a byte from the serial port.

Parameters
fdThe file descriptor of the port opened by icsc_serial_open()
Returns
A byte from the serial buffer, or -1 if no bytes are available.
int icsc_serial_wait_available ( int  fd,
unsigned long  timeout 
)

Wait for serial data to arrive up until the timeout expires.

Parameters
fdThe file descriptor of the port opened by icsc_serial_open()
timeoutThe maximum number of microseconds to wait for data to arrive
Returns
1 if data is available, 0 if it timed out, or -1 on an error.
int icsc_serial_write ( int  fd,
uint8_t  c 
)

Write a byte to a serial port.

Parameters
fdThe file descriptor of the port opened by icsc_serial_open()
cThe byte to write to the port
Returns
0 if the byte was written, -1 on error.