$search

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 88 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 173 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 102 of file tcpserial.h.

const int cTCPSerial::INVALID_SOCKET = -1 [static, protected]

Definition at line 103 of file tcpserial.h.

std::string cTCPSerial::tcp_adr [protected]

Definition at line 93 of file tcpserial.h.

int cTCPSerial::tcp_port [protected]

the TCP port to use

Definition at line 96 of file tcpserial.h.

Definition at line 113 of file tcpserial.h.

Definition at line 115 of file tcpserial.h.

struct timeval cTCPSerial::timeout_timeval [private]

timeout for setsockopt

Definition at line 107 of file tcpserial.h.

long cTCPSerial::timeout_us [private]

cached timeout in us for read()

Definition at line 109 of file tcpserial.h.

double const cTCPSerial::TIMEOUT_WAIT_FOR_EVER_S [static]

Definition at line 112 of file tcpserial.h.

Definition at line 114 of file tcpserial.h.


The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines


schunk_sdh
Author(s): Florian Weisshardt
autogenerated on Sat Mar 2 13:36:44 2013