Helper functions to make working with serial devices easier.
More...
Helper functions to make working with serial devices easier.
int icsc_serial_available |
( |
int |
fd | ) |
|
Look to see if serial data is available.
- Parameters
-
- 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
-
- Returns
- nothing
void icsc_serial_flush |
( |
int |
fd | ) |
|
Wait until all data sent to the serial port has been delivered to the wire.
- Parameters
-
- Returns
- nothing
int icsc_serial_open |
( |
const char * |
path, |
|
|
unsigned long |
baud |
|
) |
| |
Open a serial device at a specific baud rate.
- Parameters
-
path | Path to the serial device (e.g., /dev/ttyAMA0) |
baud | Symbolic 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
-
- 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
-
fd | The file descriptor of the port opened by icsc_serial_open() |
timeout | The 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
-
fd | The file descriptor of the port opened by icsc_serial_open() |
c | The byte to write to the port |
- Returns
- 0 if the byte was written, -1 on error.