|
| int | setup (const char *device, unsigned int speed) |
| int | read (char *buf, size_t len, int timeoutMs=-1) |
| int | write (const char *buf, size_t len=-1) |
| void | cleanup () |
◆ setup()
| int Serial::setup |
( |
const char * | device, |
|
|
unsigned int | speed ) |
Initialize the device
- Parameters
-
| device | path to the device file (e.g.: /dev/ttyS4 for UART4) |
| speed | the speed of the communication, for instance 9600 or 115200. Only values in /usr/include/arm-linux-gnueabihf/ are valid. |
- Returns
- 0 on success, an error code otherwise.
◆ read()
| int Serial::read |
( |
char * | buf, |
|
|
size_t | len, |
|
|
int | timeoutMs = -1 ) |
Read bytes from the serial port with specified timeout.
- Parameters
-
| buf | the destination for the data being read. |
| len | the maximum amount of bytes to be read. |
| timeoutMs | the timeout (in ms) after which the function call will return. A negative value means infinite timeout (default). |
- Returns
- The number of bytes read, or 0 if the timeout has expired, or a negative error code if an error occurred.
◆ write()
| int Serial::write |
( |
const char * | buf, |
|
|
size_t | len = -1 ) |
Write bytes to the serial port.
- Parameters
-
| buf | a buffer containing the data to be written. |
| len | the number of bytes to write. If omitted, buf will be the length of the string pointed at by buf. |
- Returns
- the number of bytes written, or a negative error cade if an error occurred.
◆ cleanup()
The documentation for this class was generated from the following files:
- libraries/Serial/Serial.h
- libraries/Serial/Serial.cpp