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 () |
| bool | open (const SerialFlags &flags) |
| 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
| driver_svh::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 70 of file Serial.cpp.
| driver_svh::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 83 of file Serial.cpp.
| driver_svh::serial::Serial::~Serial | ( | ) |
Restore old serial settings and close device
Definition at line 804 of file Serial.cpp.
|
private |
| int driver_svh::serial::Serial::changeBaudrate | ( | SerialFlags::BaudRate | speed | ) |
speed is one of the followind values :
Definition at line 260 of file Serial.cpp.
| int driver_svh::serial::Serial::clearReceiveBuffer | ( | ) |
Clears the serial port's receive buffer.
Definition at line 370 of file Serial.cpp.
| int driver_svh::serial::Serial::clearSendBuffer | ( | ) |
Clears the serial port's send buffer.
Definition at line 403 of file Serial.cpp.
| void driver_svh::serial::Serial::close | ( | ) |
Close the serial interface.
Definition at line 759 of file Serial.cpp.
|
inline |
|
private |
Definition at line 249 of file Serial.cpp.
|
inline |
| bool driver_svh::serial::Serial::isOpen | ( | ) | const |
Returns true if the serial interface is opened. false otherwhise.
Definition at line 748 of file Serial.cpp.
| bool driver_svh::serial::Serial::open | ( | ) |
Opens the serial interface.
Definition at line 97 of file Serial.cpp.
|
inline |
| ssize_t driver_svh::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 492 of file Serial.cpp.
|
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 driver_svh::serial::Serial::statusText | ( | ) | const |
Definition at line 718 of file Serial.cpp.
| ssize_t driver_svh::serial::Serial::write | ( | const void * | data, |
| ssize_t | size | ||
| ) |
Write data to serial out.
Definition at line 436 of file Serial.cpp.
|
private |