SerialComm Class Reference
Class handling the serial communication under Linux/MacOS systems.
More...
#include <SerialComm.h>
List of all members.
Detailed Description
Class handling the serial communication under Linux/MacOS systems.
- Author:
- Stefano Morgani
- Version:
- 1.0
- Date:
- 11/18/08
This class contains all the functions needed to communicate with the E-Puck robot.
Member Function Documentation
int SerialComm::connect |
( |
char * |
path |
) |
|
This function is used to initialize and open the connection to the bluetooth device; the serial settings are: 115200-8-N-1 and no hw/sw control.
- Parameters:
-
| path | string indicating the path of the device to which the connection will be established (e.g. /dev/tty.e-puck_1594-COM1-1). |
- Returns:
- returns the file descriptor returned by the "open" function.
void SerialComm::disconnect |
( |
|
) |
|
This function closes the connection opened.
int SerialComm::writeData |
( |
char * |
buf, |
|
|
int |
num_bytes, |
|
|
int |
usleep_time | |
|
) |
| | |
This function is used to send data to the device.
- Parameters:
-
| buf | buffer that contains the characters (command) to be written to the serial port. |
| num_bytes | the number of bytes that will be written to the serial port (length of the buffer). |
| usleep_time | specifies the total waiting time before exiting the writing operation in case of errors; the value is specified in microseconds unit. |
- Returns:
- returns the number of bytes correctly written to the serial port.
int SerialComm::readData |
( |
char * |
buf, |
|
|
int |
num_bytes, |
|
|
int |
usleep_time | |
|
) |
| | |
This function is used to receive data from the device.
- Parameters:
-
| buf | buffer that will contain the data received from the device. |
| num_bytes | the number of bytes to be read from the device (maximum length of the buffer). |
| usleep_time | specifies the total waiting time before exiting the reading operation in case of errors; the value is specified in microseconds unit. |
- Returns:
- returns the number of bytes correctly red from the device.
void SerialComm::flush |
( |
|
) |
|
This function flushes both the input and output buffers.
void SerialComm::discard |
( |
int |
num_bytes |
) |
|
This function is used to discard data from the input buffer; note that this function is blocking, that is it will continue to read data from the buffer until all the requested bytes are discarded.
- Parameters:
-
| num_bytes | the number of bytes to be discarded from the input buffer. |
The documentation for this class was generated from the following files:
- /Users/stefano/Desktop/Lavoro/MultiPlatformMonitor/MultiPlatformMonitorSrc/SerialComm.h
- /Users/stefano/Desktop/Lavoro/MultiPlatformMonitor/MultiPlatformMonitorSrc/SerialComm.cpp