Low-level communication class to access a CAN port. More...
#include <tcpserial.h>
Public Member Functions | |
void | Close (void) throw (cTCPSerialException*) |
Close the previously opened CAN ESD interface port. | |
cTCPSerial (char const *_tcp_adr, int _tcp_port, double _timeout) throw (cTCPSerialException*) | |
virtual tErrorCode | GetErrorNumber () |
bool | IsOpen (void) throw () |
Return true if interface to CAN ESD is open. | |
void | Open (void) throw (cTCPSerialException*) |
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) | |
int | write (char const *ptr, int len=0) throw (cTCPSerialException*) |
Write data to a previously opened port. | |
Static Public Attributes | |
static double const | TIMEOUT_RETURN_IMMEDITELY_S |
static long const | TIMEOUT_RETURN_IMMEDITELY_US |
static double const | TIMEOUT_WAIT_FOR_EVER_S |
static long const | TIMEOUT_WAIT_FOR_EVER_US |
Protected Attributes | |
int | fd |
the file descriptor of the socket | |
std::string | tcp_adr |
int | tcp_port |
the TCP port to use | |
Static Protected Attributes | |
static const int | INVALID_SOCKET = -1 |
Private Attributes | |
struct timeval | timeout_timeval |
timeout for setsockopt | |
long | timeout_us |
cached timeout in us for read() |
Low-level communication class to access a CAN port.
Definition at line 105 of file tcpserial.h.
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 cSerialBase.
virtual tErrorCode cTCPSerial::GetErrorNumber | ( | ) | [inline, virtual] |
Overloaded helper function that returns the last TCP error number.
Reimplemented from cSerialBase.
Definition at line 190 of file tcpserial.h.
bool cTCPSerial::IsOpen | ( | void | ) | throw () [virtual] |
Return true if interface to CAN ESD is open.
Implements cSerialBase.
void cTCPSerial::Open | ( | void | ) | throw (cTCPSerialException*) [virtual] |
Open the device as configured by the parameters given to the constructor
Implements 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 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 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 cSerialBase.
int cTCPSerial::fd [protected] |
the file descriptor of the socket
Definition at line 119 of file tcpserial.h.
const int cTCPSerial::INVALID_SOCKET = -1 [static, protected] |
Definition at line 120 of file tcpserial.h.
std::string cTCPSerial::tcp_adr [protected] |
Definition at line 110 of file tcpserial.h.
int cTCPSerial::tcp_port [protected] |
the TCP port to use
Definition at line 113 of file tcpserial.h.
double const cTCPSerial::TIMEOUT_RETURN_IMMEDITELY_S [static] |
Definition at line 130 of file tcpserial.h.
long const cTCPSerial::TIMEOUT_RETURN_IMMEDITELY_US [static] |
Definition at line 132 of file tcpserial.h.
struct timeval cTCPSerial::timeout_timeval [private] |
timeout for setsockopt
Definition at line 124 of file tcpserial.h.
long cTCPSerial::timeout_us [private] |
cached timeout in us for read()
Definition at line 126 of file tcpserial.h.
double const cTCPSerial::TIMEOUT_WAIT_FOR_EVER_S [static] |
Definition at line 129 of file tcpserial.h.
long const cTCPSerial::TIMEOUT_WAIT_FOR_EVER_US [static] |
Definition at line 131 of file tcpserial.h.