Low-level communication class to access a CAN port. More...
#include <tcpserial.h>
Inheritance diagram for SDH::cTCPSerial:
Collaboration diagram for SDH::cTCPSerial:Public Member Functions | |
| cTCPSerial (char const *_tcp_adr, int _tcp_port, double _timeout) throw (cTCPSerialException*) | |
| void | Open (void) throw (cTCPSerialException*) |
| bool | IsOpen (void) throw () |
| Return true if interface to CAN ESD is open. | |
| void | Close (void) throw (cTCPSerialException*) |
| Close the previously opened CAN ESD interface port. | |
| int | write (char const *ptr, int len=0) throw (cTCPSerialException*) |
| Write data to a previously opened port. | |
| ssize_t | Read (void *data, ssize_t size, long timeout_us, bool return_on_less_data) throw (cTCPSerialException*) |
| void | SetTimeout (double _timeout) throw (cSerialBaseException*) |
| set the timeout for next readline() calls (negative value means: no timeout, wait for ever) | |
| virtual tErrorCode | GetErrorNumber () |
Static Public Attributes | |
| static double const | TIMEOUT_WAIT_FOR_EVER_S = -1.0 |
| static double const | TIMEOUT_RETURN_IMMEDITELY_S = 0.0 |
| static long const | TIMEOUT_WAIT_FOR_EVER_US = -1 |
| static long const | TIMEOUT_RETURN_IMMEDITELY_US = 0 |
Protected Attributes | |
| std::string | tcp_adr |
| int | tcp_port |
| the TCP port to use | |
| int | fd |
| the file descriptor of the socket | |
Static Protected Attributes | |
| static const int | INVALID_SOCKET = -1 |
Low-level communication class to access a CAN port.
| cTCPSerial::cTCPSerial | ( | char const * | _tcp_adr, |
| int | _tcp_port, | ||
| double | _timeout | ||
| ) | throw (cTCPSerialException*) |
Constructor: constructs an object to communicate with an SDH via TCP on _tcp_adr and _tcp_port.
| void cTCPSerial::Close | ( | void | ) | throw (cTCPSerialException*) [virtual] |
Close the previously opened CAN ESD interface port.
Implements SDH::cSerialBase.
| virtual tErrorCode SDH::cTCPSerial::GetErrorNumber | ( | ) | [inline, virtual] |
Overloaded helper function that returns the last TCP error number.
Reimplemented from SDH::cSerialBase.
| bool cTCPSerial::IsOpen | ( | void | ) | throw () [virtual] |
Return true if interface to CAN ESD is open.
Implements SDH::cSerialBase.
| void cTCPSerial::Open | ( | void | ) | throw (cTCPSerialException*) [virtual] |
Open the device as configured by the parameters given to the constructor
Implements SDH::cSerialBase.
| ssize_t cTCPSerial::Read | ( | void * | data, |
| ssize_t | size, | ||
| long | timeout_us, | ||
| bool | return_on_less_data | ||
| ) | throw (cTCPSerialException*) [virtual] |
Read data from device. This function waits until max_time_us us passed or the expected number of bytes are received via serial line. if (return_on_less_data is true (default value), the number of bytes that have been received are returned and the data is stored in data If the return_on_less_data is false, data is only read from serial line, if at least size bytes are available.
Implements SDH::cSerialBase.
| void cTCPSerial::SetTimeout | ( | double | _timeout | ) | throw (cSerialBaseException*) [virtual] |
set the timeout for next readline() calls (negative value means: no timeout, wait for ever)
Reimplemented from SDH::cSerialBase.
| int cTCPSerial::write | ( | char const * | ptr, |
| int | len = 0 |
||
| ) | throw (cTCPSerialException*) [virtual] |
Write data to a previously opened port.
Write len bytes from *ptr to the CAN device
| ptr | - pointer the byte array to send in memory |
| len | - number of bytes to send |
Implements SDH::cSerialBase.
int SDH::cTCPSerial::fd [protected] |
the file descriptor of the socket
const int SDH::cTCPSerial::INVALID_SOCKET = -1 [static, protected] |
std::string SDH::cTCPSerial::tcp_adr [protected] |
int SDH::cTCPSerial::tcp_port [protected] |
the TCP port to use
double const cTCPSerial::TIMEOUT_RETURN_IMMEDITELY_S = 0.0 [static] |
long const cTCPSerial::TIMEOUT_RETURN_IMMEDITELY_US = 0 [static] |
double const cTCPSerial::TIMEOUT_WAIT_FOR_EVER_S = -1.0 [static] |
long const cTCPSerial::TIMEOUT_WAIT_FOR_EVER_US = -1 [static] |