Enables acces to serial devices. More...
#include <Serial.h>
Public Member Functions | |
int | ChangeBaudrate (SerialFlags::BaudRate speed) |
int | ClearReceiveBuffer () |
int | ClearSendBuffer () |
void | Close () |
const char * | DeviceName () const |
int | FileDescriptor () |
bool | IsOpen () const |
bool | Open (const SerialFlags &flags) |
bool | Open () |
ssize_t | Read (void *data, ssize_t size, unsigned long time=100, bool return_on_less_data=true) |
Serial (const char *dev_name, const SerialFlags &flags) | |
Serial (const char *dev_name, SerialFlags::BaudRate baud_rate, const SerialFlags &flags) | |
int | Status () const |
std::string | StatusText () const |
ssize_t | Write (const void *data, ssize_t size) |
~Serial () | |
Private Member Functions | |
void | DumpData (void *data, size_t length) |
Serial & | operator= (const Serial &) |
Serial (const Serial &) | |
Private Attributes | |
char * | m_dev_name |
SerialFlags | m_serial_flags |
int | m_status |
Enables acces to serial devices.
Open a serial device, change baudrates, read from and write to the device. Status-information after calling the functions get be
icl_comm::serial::Serial::Serial | ( | const char * | dev_name, |
const SerialFlags & | flags | ||
) |
Opens the device (if possible) with the given flags.
flags | can be values of the following values ORed together
|
Definition at line 72 of file Serial.cpp.
icl_comm::serial::Serial::Serial | ( | const char * | dev_name, |
SerialFlags::BaudRate | baud_rate, | ||
const SerialFlags & | flags | ||
) |
This is an overloaded constructor, provided for convenience. buad_rate overwrites the baud rate set in flags.
Definition at line 86 of file Serial.cpp.
Restore old serial settings and close device
Definition at line 983 of file Serial.cpp.
icl_comm::serial::Serial::Serial | ( | const Serial & | ) | [private] |
speed is one of the followind values :
Definition at line 353 of file Serial.cpp.
Clears the serial port's receive buffer.
Definition at line 467 of file Serial.cpp.
Clears the serial port's send buffer.
Definition at line 501 of file Serial.cpp.
void icl_comm::serial::Serial::Close | ( | ) |
Close the serial interface.
Definition at line 924 of file Serial.cpp.
const char* icl_comm::serial::Serial::DeviceName | ( | ) | const [inline] |
void icl_comm::serial::Serial::DumpData | ( | void * | data, |
size_t | length | ||
) | [private] |
Definition at line 342 of file Serial.cpp.
int icl_comm::serial::Serial::FileDescriptor | ( | ) | [inline] |
bool icl_comm::serial::Serial::IsOpen | ( | ) | const |
Returns true
if the serial interface is opened. false
otherwhise.
Definition at line 913 of file Serial.cpp.
bool icl_comm::serial::Serial::Open | ( | const SerialFlags & | flags | ) | [inline] |
bool icl_comm::serial::Serial::Open | ( | ) |
Opens the serial interface.
Definition at line 101 of file Serial.cpp.
ssize_t icl_comm::serial::Serial::Read | ( | void * | data, |
ssize_t | size, | ||
unsigned long | time = 100 , |
||
bool | return_on_less_data = true |
||
) |
Read data from device. This function waits until
time | us passed or the respected number of bytes are received via serial line. if ( |
return_on_less_data | is true (default value), the number of bytes that have been receives are returned and the data is stored in |
data. | If the parameter is false, data is only read from serial line, if at least |
size | bytes are available. |
Definition at line 621 of file Serial.cpp.
int icl_comm::serial::Serial::Status | ( | ) | const [inline] |
All routines return a negavtiv number on error. Then the global errno is stored into a private variable. Use this funtion to ask for this value. Especially the constructor cannot return an error-value. Check the succesful opening of the device by calling this function. It returns 0, if no error occured.
std::string icl_comm::serial::Serial::StatusText | ( | ) | const |
Definition at line 884 of file Serial.cpp.
ssize_t icl_comm::serial::Serial::Write | ( | const void * | data, |
ssize_t | size | ||
) |
Write data to serial out.
Definition at line 535 of file Serial.cpp.
char* icl_comm::serial::Serial::m_dev_name [private] |
int icl_comm::serial::Serial::m_status [private] |