Public Member Functions | Static Public Attributes | Protected Attributes | Static Protected Attributes | Private Attributes
cTCPSerial Class Reference

Low-level communication class to access a CAN port. More...

#include <tcpserial.h>

Inheritance diagram for cTCPSerial:
Inheritance graph
[legend]

List of all members.

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()

Detailed Description

Low-level communication class to access a CAN port.

Definition at line 105 of file tcpserial.h.


Constructor & Destructor Documentation

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.

Parameters:
_tcp_adr- a string describing the hostname or IP address of the SDH
_tcp_port- the port number on the SDH
_timeout- the timeout when receiving / sending data:
  • < 0.0 : no timeout = wait for ever
  • == 0.0 : zero timeout = return immediately
  • > 0.0 : timeout in seconds

Member Function Documentation

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

Parameters:
ptr- pointer the byte array to send in memory
len- number of bytes to send
Returns:
the number of bytes actually written

Implements cSerialBase.


Member Data Documentation

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.

Definition at line 130 of file tcpserial.h.

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.

Definition at line 131 of file tcpserial.h.


The documentation for this class was generated from the following file:


schunk_sdh
Author(s): Mathias Luedtke , Florian Weisshardt
autogenerated on Sat Jun 8 2019 20:25:21