yarp-devices
Public Member Functions | Private Member Functions | Private Attributes | List of all members
roboticslab::SdoClient Class Referencefinal

Representation of SDO client protocol. More...

#include <SdoClient.hpp>

Public Member Functions

 SdoClient (std::uint8_t id, std::uint16_t cobRx, std::uint16_t cobTx, double timeout, ICanSenderDelegate *sender=nullptr)
 Constructor, registers CAN sender handle.
 
std::uint16_t getCobIdRx () const
 Retrieve COB ID of SDO packages received by the drive.
 
std::uint16_t getCobIdTx () const
 Retrieve COB ID of SDO packages sent by the drive.
 
void configureSender (ICanSenderDelegate *sender)
 Configure CAN sender delegate handle.
 
bool notify (const std::uint8_t *raw)
 Notify observers on an SDO package sent by the drive.
 
bool ping ()
 Test whether the node is available or not.
 
template<typename T >
bool upload (const std::string &name, T *data, std::uint16_t index, std::uint8_t subindex=0x00)
 Request an SDO package from the drive, only integral types. More...
 
template<typename T , typename Fn >
bool upload (const std::string &name, Fn &&fn, std::uint16_t index, std::uint8_t subindex=0x00)
 Request an SDO package from the drive with callback, only integral types. More...
 
template<typename T >
bool download (const std::string &name, T data, std::uint16_t index, std::uint8_t subindex=0x00)
 Send an SDO package to the drive, only integral types. More...
 
bool upload (const std::string &name, std::string &s, std::uint16_t index, std::uint8_t subindex=0x00)
 Request an SDO package from the drive, only string type. More...
 
template<typename Fn >
bool upload (const std::string &name, Fn &&fn, std::uint16_t index, std::uint8_t subindex=0x00)
 Request an SDO package from the drive with callback, only string type. More...
 
bool download (const std::string &name, const std::string &s, std::uint16_t index, std::uint8_t subindex=0x00)
 Send an SDO package to the drive, only string type. More...
 
bool download (const std::string &name, const char *s, std::uint16_t index, std::uint8_t subindex=0x00)
 String literal overload, overrides templated variant.
 

Private Member Functions

bool send (const std::uint8_t *msg)
 
bool uploadInternal (const std::string &name, void *data, std::uint32_t size, std::uint16_t index, std::uint8_t subindex)
 
bool downloadInternal (const std::string &name, const void *data, std::uint32_t size, std::uint16_t index, std::uint8_t subindex)
 
bool performTransfer (const std::string &name, const std::uint8_t *req, std::uint8_t *resp)
 

Private Attributes

std::uint8_t id
 
std::uint16_t cobRx
 
std::uint16_t cobTx
 
std::string logId
 
ICanSenderDelegatesender
 
TypedStateObserver< std::uint8_t[]> stateObserver
 

Detailed Description

Provides access to SDO reads and writes in a user-friendly manner, sparing clients the need of building char arrays and such. Uses CAN terminology ("upload" means reads from the drive, "downloads" means writes to the drive). Supports normal (segmented) and expedited transfers. Obtains data size from the upload/download data type and takes care of managing the handshake. SDO transfers block with timeout and always wait for the response or confirm message from the drive, signalizing failures accordingly. Also supports SDO abort protocol.

Member Function Documentation

◆ download() [1/2]

bool SdoClient::download ( const std::string &  name,
const std::string &  s,
std::uint16_t  index,
std::uint8_t  subindex = 0x00 
)
Parameters
nameDescription of the CAN dictionary object.
sString to be sent.
indexIndex of targeted CAN dictionary object.
indexSubindex of targeted CAN dictionary object.
Returns
True on success, false on timeout.

◆ download() [2/2]

template<typename T >
bool roboticslab::SdoClient::download ( const std::string &  name,
data,
std::uint16_t  index,
std::uint8_t  subindex = 0x00 
)
inline
Template Parameters
TIntegral data type.
Parameters
nameDescription of the CAN dictionary object.
dataValue to be sent.
indexIndex of targeted CAN dictionary object.
indexSubindex of targeted CAN dictionary object.
Returns
True on success, false on timeout.

◆ upload() [1/4]

template<typename T , typename Fn >
bool roboticslab::SdoClient::upload ( const std::string &  name,
Fn &&  fn,
std::uint16_t  index,
std::uint8_t  subindex = 0x00 
)
inline
Template Parameters
TIntegral data type.
FnFunction object type.
Parameters
nameDescription of the CAN dictionary object.
fnCallback function, will be invoked with the received CAN data as input parameter.
indexIndex of targeted CAN dictionary object.
indexSubindex of targeted CAN dictionary object.
Returns
True on success, false on timeout.

◆ upload() [2/4]

template<typename Fn >
bool roboticslab::SdoClient::upload ( const std::string &  name,
Fn &&  fn,
std::uint16_t  index,
std::uint8_t  subindex = 0x00 
)
inline
Template Parameters
FnFunction object type.
Parameters
nameDescription of the CAN dictionary object.
fnCallback function, will be invoked with the received CAN data as input parameter.
indexIndex of targeted CAN dictionary object.
indexSubindex of targeted CAN dictionary object.
Returns
True on success, false on timeout.

◆ upload() [3/4]

bool SdoClient::upload ( const std::string &  name,
std::string &  s,
std::uint16_t  index,
std::uint8_t  subindex = 0x00 
)
Parameters
nameDescription of the CAN dictionary object.
sOutput string value.
indexIndex of targeted CAN dictionary object.
indexSubindex of targeted CAN dictionary object.
Returns
True on success, false on timeout.

◆ upload() [4/4]

template<typename T >
bool roboticslab::SdoClient::upload ( const std::string &  name,
T *  data,
std::uint16_t  index,
std::uint8_t  subindex = 0x00 
)
inline
Template Parameters
TIntegral data type.
Parameters
nameDescription of the CAN dictionary object.
dataPointer to an external storage, will be populated with received CAN data.
indexIndex of targeted CAN dictionary object.
indexSubindex of targeted CAN dictionary object.
Returns
True on success, false on timeout.

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