SDHLibrary-CPP 0.0.2.10 C++ access library for SCHUNK Dextrous Hand SDH

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- Class List
- Class Hierarchy
- Class Members

Public Member Functions | Protected Member Functions | Protected Attributes

# SDH::cCANSerial_ESD Class Reference

Low-level communication class to access a CAN port from company ESD (http://www.esd.eu/) More...

`#include <canserial-esd.h>`

Inheritance diagram for SDH::cCANSerial_ESD:
[legend]
Collaboration diagram for SDH::cCANSerial_ESD:
[legend]

List of all members.

## Public Member Functions
| cCANSerial_ESD (int _net, unsigned long _baudrate, double _timeout, int _id_read, int _id_write) throw (cCANSerial_ESDException*)
| cCANSerial_ESD (tDeviceHandle _ntcan_handle, double _timeout, int _id_read, int _id_write) throw (cCANSerial_ESDException*)
| ~cCANSerial_ESD ()
| destructor: clean up
void | Open (void) throw (cCANSerial_ESDException*)
bool | IsOpen (void) throw ()
| Return true if interface to CAN ESD is open.
void | Close (void) throw (cCANSerial_ESDException*)
| Close the previously opened CAN ESD interface port.
int | write (char const *ptr, int len=0) throw (cCANSerial_ESDException*)
| Write data to a previously opened port.
ssize_t | Read (void *data, ssize_t size, long timeout_us, bool return_on_less_data) throw (cCANSerial_ESDException*)
void | SetTimeout (double _timeout) throw (cSerialBaseException*)
| set the timeout for next readline() calls (negative value means: no timeout, wait for ever)
virtual tErrorCode | GetErrorNumber ()
virtual char const * | GetErrorMessage (tErrorCode dw)
tDeviceHandle | GetHandle ()
| return the internally used NTCAN_HANDLE cast to a tDeviceHandle
## Protected Member Functions
unsigned int | BaudrateToBaudrateCode (unsigned long baudrate) throw (cCANSerial_ESDException*)
| Translate a baudrate given as unsigned long into a baudrate code for struct termios.
## Protected Attributes
int | net
| the ESD CAN net to use
unsigned long | baudrate
| the baudrate to use in bit/s
int | id_read
| the CAN ID used for reading
int | id_write
| the CAN ID used for writing
int | status

## Detailed Description

Low-level communication class to access a CAN port from company ESD (http://www.esd.eu/)

Since SDHLibrary-C++ release 0.0.2.0 implementation specific parts of the access to ESD CAN devices have been removed from the header file here in order to get rid of dependencies from the weird ntcan.h. Specifically the ntcan_handle of type NTCAN_HANDLE member was removed. You can still provide an existing handle for reuse on construction, but you must cast your NTCAN_HANDLE to a tDeviceHandle. You can get the internally used NTCAN_HANDLE cast to a tDeviceHandle with GetHandle().

## Constructor & Destructor Documentation

cCANSerial_ESD::cCANSerial_ESD | ( | int | _net,
|  | unsigned long | _baudrate,
|  | double | _timeout,
|  | int | _id_read,
|  | int | _id_write
| ) |  | throw (cCANSerial_ESDException*)

Constructor: constructs an object to communicate with an SDH via CAN bus using an ESD CAN card.

Parameters:

  _net | - the ESD CAN net to use
  _baudrate | - the baudrate in bit/s. Only some bitrates are valid: (1000000,800000,500000,250000,125000,100000,50000,20000,10000)
  _timeout | - the timeout in seconds (0 for no timeout = wait for ever)
  _id_read | - the CAN ID to use for reading (The SDH sends data on this ID)
  _id_write | - the CAN ID to use for writing (The SDH receives data on this ID)

cCANSerial_ESD::cCANSerial_ESD | ( | tDeviceHandle | _ntcan_handle,
|  | double | _timeout,
|  | int | _id_read,
|  | int | _id_write
| ) |  | throw (cCANSerial_ESDException*)

Constructor: constructs an object to communicate with an SDH via CAN bus using an ESD CAN card by reusing an already existing handle.

Parameters:

  _ntcan_handle | - the ESD CAN handle to reuse (please cast your NTCAN_HANDLE to tDeviceHandle! It is save to do that!)
  _timeout | - the timeout in seconds (0 for no timeout = wait for ever)
  _id_read | - the CAN ID to use for reading (The SDH sends data on this ID)
  _id_write | - the CAN ID to use for writing (The SDH receives data on this ID)

cCANSerial_ESD::~cCANSerial_ESD | ( |  | ) |

destructor: clean up

## Member Function Documentation

unsigned int cCANSerial_ESD::BaudrateToBaudrateCode | ( | unsigned long | baudrate | ) | throw (cCANSerial_ESDException*)`[protected]`

Translate a baudrate given as unsigned long into a baudrate code for struct termios.

void cCANSerial_ESD::Close | ( | void |  | ) | throw (cCANSerial_ESDException*)`[virtual]`

Close the previously opened CAN ESD interface port.

Implements SDH::cSerialBase.

char const * cCANSerial_ESD::GetErrorMessage | ( | tErrorCode | dw | ) | `[virtual]`

Overloaded helper function that returns an ESD error message for ESD error code dw.

Remarks:
  The string returned will be overwritten by the next call to the function

Reimplemented from SDH::cSerialBase.

cSerialBase::tErrorCode cCANSerial_ESD::GetErrorNumber | ( |  | ) | `[virtual]`

Overloaded helper function that returns the last ESD error number.

Reimplemented from SDH::cSerialBase.

tDeviceHandle cCANSerial_ESD::GetHandle | ( |  | ) |

return the internally used NTCAN_HANDLE cast to a tDeviceHandle

bool cCANSerial_ESD::IsOpen | ( | void |  | ) | throw ()`[virtual]`

Return true if interface to CAN ESD is open.

Implements SDH::cSerialBase.

void cCANSerial_ESD::Open | ( | void |  | ) | throw (cCANSerial_ESDException*)`[virtual]`

Open the device as configured by the parameters given to the constructor

Implements SDH::cSerialBase.

ssize_t cCANSerial_ESD::Read | ( | void * | data,
|  | ssize_t | size,
|  | long | timeout_us,
|  | bool | return_on_less_data
| ) |  | throw (cCANSerial_ESDException*)`[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 cCANSerial_ESD::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 cCANSerial_ESD::write | ( | char const * | ptr,
|  | int | len = `0`
| ) |  | throw (cCANSerial_ESDException*)`[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 SDH::cSerialBase.

## Member Data Documentation

unsigned long SDH::cCANSerial_ESD::baudrate`[protected]`

the baudrate to use in bit/s

int SDH::cCANSerial_ESD::id_read`[protected]`

the CAN ID used for reading

int SDH::cCANSerial_ESD::id_write`[protected]`

the CAN ID used for writing

int SDH::cCANSerial_ESD::net`[protected]`

the ESD CAN net to use

int SDH::cCANSerial_ESD::status`[protected]`

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

- sdh/canserial-esd.h
- sdh/canserial-esd.cpp