The SDO class represents Service Data Objects (SDO) that are used for slow access of the canOpen object dictionary. It uses the COB-ID which identifies entry with a 16bit index and 8 bit sub index and allows read and write operations. The SDO is mainly used to set up the system before the actual cyclic operation starts. This class holds the generic data, provides the up- and download functionality and parses incoming SDOs to ensure that they are correct. More...
#include <SDO.h>
Public Types | |
typedef boost::shared_ptr < const SDO > | ConstPtr |
typedef boost::shared_ptr< SDO > | Ptr |
Public Member Functions | |
bool | download (const bool normal_transfer, const uint16_t index, const uint8_t subindex, const std::vector< uint8_t > &usrdata) |
Downloads SDO data from the master to the slave (From PC to node). | |
template<typename T > | |
bool | download (const bool normal_transfer, const uint16_t index, const uint8_t subindex, const T &usrdata) |
Downloads SDO data from the master to the slave (From PC to node) | |
uint32_t | getResponseWaitTime () const |
Get the current SDO transfer response wait time. | |
SDO (const uint8_t &node_id, const CanDevPtr &can_device) | |
void | setResponseWaitTime (const uint32_t wait_time_ms) |
Set the time in milliseconds that should be waited for an SDO response when performing a transfer. | |
void | update (const CanMsg &msg) |
update updates the SDO data with newly received messages | |
bool | upload (const bool normal_transfer, const uint16_t index, const uint8_t subindex, std::vector< uint8_t > &uploaded_data) |
Uploads data from a slave (node) to a master (PC). | |
template<typename T > | |
bool | upload (const bool normal_transfer, const uint16_t index, const uint8_t subindex, T &uploaded_data) |
Uploads data from a slave (node) to a master (PC). | |
Static Public Member Functions | |
static void | addErrorMapFromFile (const std::string &filename) |
Adds an error map from an INI file to all SDOs. This should be called once to get human readable errors. | |
Static Public Attributes | |
static unsigned char const | SDO_SEG_ABORT_TRANSFER = 0x80 |
static unsigned char const | SDO_SEG_REQ_INIT_DOWNLOAD_1BYTE = 0x2F |
static unsigned char const | SDO_SEG_REQ_INIT_DOWNLOAD_2BYTE = 0x2B |
static unsigned char const | SDO_SEG_REQ_INIT_DOWNLOAD_3BYTE = 0x27 |
static unsigned char const | SDO_SEG_REQ_INIT_DOWNLOAD_4BYTE = 0x23 |
static unsigned char const | SDO_SEG_REQ_INIT_DOWNLOAD_xBYTE = 0x22 |
static unsigned char const | SDO_SEG_REQ_INIT_UPLOAD = 0x40 |
static unsigned char const | SDO_SEG_REQ_UPLOAD0 = 0x60 |
static unsigned char const | SDO_SEG_REQ_UPLOAD1 = 0x70 |
static unsigned char const | SDO_SEG_RES_INIT_DOWNLOAD = 0x60 |
static unsigned char const | SDO_SEG_RES_INIT_UPLOAD_1BYTE = 0x4F |
static unsigned char const | SDO_SEG_RES_INIT_UPLOAD_2BYTE = 0x4B |
static unsigned char const | SDO_SEG_RES_INIT_UPLOAD_3BYTE = 0x47 |
static unsigned char const | SDO_SEG_RES_INIT_UPLOAD_4BYTE = 0x43 |
static unsigned char const | SDO_SEG_RES_INIT_UPLOAD_nBYTE = 0x41 |
static unsigned char const | SDO_SEG_RES_INIT_UPLOAD_xBYTE = 0x42 |
static uint16_t const | SDORX_ID = 0x600 |
static uint16_t const | SDOTX_ID = 0x580 |
Static Private Member Functions | |
static std::string | lookupErrorString (const uint32_t error_code) |
Private Attributes | |
CanDevPtr | m_can_device |
std::vector< uint8_t > | m_data_buffer |
boost::mutex | m_data_buffer_mutex |
boost::condition_variable | m_data_buffer_updated_cond |
bool | m_data_update_received |
uint8_t | m_node_id |
uint32_t | m_response_wait_time_ms |
Static Private Attributes | |
static std::map< uint32_t, std::string > | m_error_map |
The SDO class represents Service Data Objects (SDO) that are used for slow access of the canOpen object dictionary. It uses the COB-ID which identifies entry with a 16bit index and 8 bit sub index and allows read and write operations. The SDO is mainly used to set up the system before the actual cyclic operation starts. This class holds the generic data, provides the up- and download functionality and parses incoming SDOs to ensure that they are correct.
typedef boost::shared_ptr<const SDO> icl_hardware::canopen_schunk::SDO::ConstPtr |
typedef boost::shared_ptr<SDO> icl_hardware::canopen_schunk::SDO::Ptr |
icl_hardware::canopen_schunk::SDO::SDO | ( | const uint8_t & | node_id, |
const CanDevPtr & | can_device | ||
) |
void icl_hardware::canopen_schunk::SDO::addErrorMapFromFile | ( | const std::string & | filename | ) | [static] |
bool icl_hardware::canopen_schunk::SDO::download | ( | const bool | normal_transfer, |
const uint16_t | index, | ||
const uint8_t | subindex, | ||
const std::vector< uint8_t > & | usrdata | ||
) |
Downloads SDO data from the master to the slave (From PC to node).
There exist expedited and normal (segmented) downloads in the DS301 standard. Currently, only expedited downloads are supported, which send data of up to 4 bytes directly with the download request.
normal_transfer | expedited (false) or segmented (true) downloads |
index | Index to where the data should be written (in the node) |
subindex | Subindex to where the data should be written (in the node) |
usrdata | Data that would be downloaded to the node. |
ProtocolException | or any exception inherited from that on errors |
bool icl_hardware::canopen_schunk::SDO::download | ( | const bool | normal_transfer, |
const uint16_t | index, | ||
const uint8_t | subindex, | ||
const T & | usrdata | ||
) | [inline] |
Downloads SDO data from the master to the slave (From PC to node)
This is just an overloaded interface to the vector interface. (see function definition without template). It accepts all kind of userdata types that can fit into 4 bytes of data. They will be automatically converted to a vector of bytes.
*
normal_transfer | expedited (false) or segmented (true, not yet supported) downloads |
index | Index to where the data should be written (in the node) |
subindex | Subindex to where the data should be written (in the node) |
usrdata | Data that should be downloaded to the node. This can be any basic datatype that fits into 4 bytes. |
ProtocolException | or any exception inherited from that on errors |
uint32_t icl_hardware::canopen_schunk::SDO::getResponseWaitTime | ( | ) | const [inline] |
std::string icl_hardware::canopen_schunk::SDO::lookupErrorString | ( | const uint32_t | error_code | ) | [static, private] |
void icl_hardware::canopen_schunk::SDO::setResponseWaitTime | ( | const uint32_t | wait_time_ms | ) | [inline] |
void icl_hardware::canopen_schunk::SDO::update | ( | const CanMsg & | msg | ) |
update updates the SDO data with newly received messages
msg | can message that was preciously identified as SDO message |
ProtocolException | on errors |
bool icl_hardware::canopen_schunk::SDO::upload | ( | const bool | normal_transfer, |
const uint16_t | index, | ||
const uint8_t | subindex, | ||
std::vector< uint8_t > & | uploaded_data | ||
) |
Uploads data from a slave (node) to a master (PC).
There exist expedited and normal (segmented) uploads in the DS301 standard. Currently, only expedited uploads are supported, which send data of up to 4 bytes directly with the first upload response.
[in] | normal_transfer | expedited (false) or segmented (true, not yet supported) uploads |
[in] | index | Index to where the data should be read (in the node) |
[in] | subindex | Subindex to where the data should be read (in the node) |
[out] | uploaded_data | uploaded data will be in this vector, if upload succeeds. |
ProtocolException | or any exception inherited from that on errors |
bool icl_hardware::canopen_schunk::SDO::upload | ( | const bool | normal_transfer, |
const uint16_t | index, | ||
const uint8_t | subindex, | ||
T & | uploaded_data | ||
) | [inline] |
Uploads data from a slave (node) to a master (PC).
There exist expedited and normal (segmented) uploads in the DS301 standard. Currently, only expedited uploads are supported, which send data of up to 4 bytes directly with the first upload response.
[in] | normal_transfer | expedited (false) or segmented (true, not yet supported) uploads |
[in] | index | Index to where the data should be read (in the node) |
[in] | subindex | Subindex to where the data should be read (in the node) |
[out] | uploaded_data | uploaded data will be in here, if upload succeeds. |
ProtocolException | or any exception inherited from that on errors |
boost::mutex icl_hardware::canopen_schunk::SDO::m_data_buffer_mutex [private] |
boost::condition_variable icl_hardware::canopen_schunk::SDO::m_data_buffer_updated_cond [private] |
bool icl_hardware::canopen_schunk::SDO::m_data_update_received [private] |
std::map< uint32_t, std::string > icl_hardware::canopen_schunk::SDO::m_error_map [static, private] |
unsigned char const icl_hardware::canopen_schunk::SDO::SDO_SEG_ABORT_TRANSFER = 0x80 [static] |
unsigned char const icl_hardware::canopen_schunk::SDO::SDO_SEG_REQ_INIT_DOWNLOAD_1BYTE = 0x2F [static] |
unsigned char const icl_hardware::canopen_schunk::SDO::SDO_SEG_REQ_INIT_DOWNLOAD_2BYTE = 0x2B [static] |
unsigned char const icl_hardware::canopen_schunk::SDO::SDO_SEG_REQ_INIT_DOWNLOAD_3BYTE = 0x27 [static] |
unsigned char const icl_hardware::canopen_schunk::SDO::SDO_SEG_REQ_INIT_DOWNLOAD_4BYTE = 0x23 [static] |
unsigned char const icl_hardware::canopen_schunk::SDO::SDO_SEG_REQ_INIT_DOWNLOAD_xBYTE = 0x22 [static] |
unsigned char const icl_hardware::canopen_schunk::SDO::SDO_SEG_REQ_INIT_UPLOAD = 0x40 [static] |
unsigned char const icl_hardware::canopen_schunk::SDO::SDO_SEG_REQ_UPLOAD0 = 0x60 [static] |
unsigned char const icl_hardware::canopen_schunk::SDO::SDO_SEG_REQ_UPLOAD1 = 0x70 [static] |
unsigned char const icl_hardware::canopen_schunk::SDO::SDO_SEG_RES_INIT_DOWNLOAD = 0x60 [static] |
unsigned char const icl_hardware::canopen_schunk::SDO::SDO_SEG_RES_INIT_UPLOAD_1BYTE = 0x4F [static] |
unsigned char const icl_hardware::canopen_schunk::SDO::SDO_SEG_RES_INIT_UPLOAD_2BYTE = 0x4B [static] |
unsigned char const icl_hardware::canopen_schunk::SDO::SDO_SEG_RES_INIT_UPLOAD_3BYTE = 0x47 [static] |
unsigned char const icl_hardware::canopen_schunk::SDO::SDO_SEG_RES_INIT_UPLOAD_4BYTE = 0x43 [static] |
unsigned char const icl_hardware::canopen_schunk::SDO::SDO_SEG_RES_INIT_UPLOAD_nBYTE = 0x41 [static] |
unsigned char const icl_hardware::canopen_schunk::SDO::SDO_SEG_RES_INIT_UPLOAD_xBYTE = 0x42 [static] |
uint16_t const icl_hardware::canopen_schunk::SDO::SDORX_ID = 0x600 [static] |
uint16_t const icl_hardware::canopen_schunk::SDO::SDOTX_ID = 0x580 [static] |