Lely core libraries  1.9.2
lely::canopen::Device Class Reference

The CANopen device description. More...

#include <device.hpp>

Inheritance diagram for lely::canopen::Device:

Data Structures

struct  Impl_
 The internal implementation of the CANopen device description. More...
 

Public Member Functions

 Device (const ::std::string &dcf_txt, const ::std::string &dcf_bin="", uint8_t id=0xff, BasicLockable *mutex=nullptr)
 Creates a new CANopen device description. More...
 
uint8_t netid () const noexcept
 Returns the network-ID.
 
uint8_t id () const noexcept
 Returns the node-ID.
 
template<class T >
typename ::std::enable_if< detail::IsCanopenType< T >::value, T >::type Read (uint16_t idx, uint8_t subidx) const
 Submits an SDO upload request to the local object dictionary. More...
 
template<class T >
typename ::std::enable_if< detail::IsCanopenType< T >::value, T >::type Read (uint16_t idx, uint8_t subidx, ::std::error_code &ec) const
 Submits an SDO upload request to the local object dictionary. More...
 
template<class T >
typename ::std::enable_if< detail::IsCanopenBasic< T >::value >::type Write (uint16_t idx, uint8_t subidx, T value)
 Submits an SDO download request to the local object dictionary. More...
 
template<class T >
typename ::std::enable_if< detail::IsCanopenBasic< T >::value >::type Write (uint16_t idx, uint8_t subidx, T value, ::std::error_code &ec)
 Submits an SDO download request to the local object dictionary. More...
 
template<class T >
typename ::std::enable_if< detail::IsCanopenArray< T >::value >::type Write (uint16_t idx, uint8_t subidx, const T &value)
 Submits an SDO download request to the local object dictionary. More...
 
template<class T >
typename ::std::enable_if< detail::IsCanopenArray< T >::value >::type Write (uint16_t idx, uint8_t subidx, const T &value, ::std::error_code &ec)
 Submits an SDO download request to the local object dictionary. More...
 
void Write (uint16_t idx, uint8_t subidx, const char *value)
 Submits an SDO download request to the local object dictionary. More...
 
void Write (uint16_t idx, uint8_t subidx, const char *value, ::std::error_code &ec)
 Submits an SDO download request to the local object dictionary. More...
 
void Write (uint16_t idx, uint8_t subidx, const char16_t *value)
 Submits an SDO download request to the local object dictionary. More...
 
void Write (uint16_t idx, uint8_t subidx, const char16_t *value, ::std::error_code &ec)
 Submits an SDO download request to the local object dictionary. More...
 
void Write (uint16_t idx, uint8_t subidx, const void *p, ::std::size_t n)
 Submits an SDO download request to the local object dictionary. More...
 
void Write (uint16_t idx, uint8_t subidx, const void *p, ::std::size_t n, ::std::error_code &ec)
 Submits an SDO download request to the local object dictionary. More...
 

Protected Member Functions

CODevdev () const noexcept
 Returns a pointer to the internal CANopen device from <lely/co/dev.hpp>.
 
const ::std::type_info & Type (uint16_t idx, uint8_t subidx) const
 Returns the type of a sub-object. More...
 
const ::std::type_info & Type (uint16_t idx, uint8_t subidx, ::std::error_code &ec) const
 Returns the type of a sub-object. More...
 
template<class T >
typename ::std::enable_if< detail::IsCanopenType< T >::value, T >::type Get (uint16_t idx, uint8_t subidx) const
 Reads the value of a sub-object. More...
 
template<class T >
typename ::std::enable_if< detail::IsCanopenType< T >::value, T >::type Get (uint16_t idx, uint8_t subidx, ::std::error_code &ec) const
 Reads the value of a sub-object. More...
 
template<class T >
typename ::std::enable_if< detail::IsCanopenBasic< T >::value >::type Set (uint16_t idx, uint8_t subidx, T value)
 Writes a CANopen basic value to a sub-object. More...
 
template<class T >
typename ::std::enable_if< detail::IsCanopenBasic< T >::value >::type Set (uint16_t idx, uint8_t subidx, T value, ::std::error_code &ec)
 Writes a CANopen basic value to a sub-object. More...
 
template<class T >
typename ::std::enable_if< detail::IsCanopenArray< T >::value >::type Set (uint16_t idx, uint8_t subidx, const T &value)
 Writes a CANopen array value to a sub-object. More...
 
template<class T >
typename ::std::enable_if< detail::IsCanopenArray< T >::value >::type Set (uint16_t idx, uint8_t subidx, const T &value, ::std::error_code &ec)
 Writes a CANopen array value to a sub-object. More...
 
void Set (uint16_t idx, uint8_t subidx, const char *value)
 Writes a VISIBLE_STRING to a sub-object. More...
 
void Set (uint16_t idx, uint8_t subidx, const char *value, ::std::error_code &ec)
 Writes a VISIBLE_STRING to a sub-object. More...
 
void Set (uint16_t idx, uint8_t subidx, const char16_t *value)
 Writes a UNICODE_STRING to a sub-object. More...
 
void Set (uint16_t idx, uint8_t subidx, const char16_t *value, ::std::error_code &ec)
 Writes a UNICODE_STRING to a sub-object. More...
 
void Set (uint16_t idx, uint8_t subidx, const void *p, ::std::size_t n)
 Writes an OCTET_STRING or DOMAIN value to a sub-object. More...
 
void Set (uint16_t idx, uint8_t subidx, const void *p, ::std::size_t n, ::std::error_code &ec)
 Writes an OCTET_STRING or DOMAIN value to a sub-object. More...
 

Detailed Description

The CANopen device description.

This class manages the object dictionary and device setttings such as the network-ID and node-ID.

Definition at line 42 of file device.hpp.

Constructor & Destructor Documentation

◆ Device()

lely::canopen::Device::Device ( const ::std::string &  dcf_txt,
const ::std::string &  dcf_bin = "",
uint8_t  id = 0xff,
BasicLockable mutex = nullptr 
)

Creates a new CANopen device description.

Parameters
dcf_txtthe path of the text EDS or DCF containing the device description.
dcf_binthe path of the (binary) concise DCF containing the values of (some of) the objets in the object dictionary. If dcf_bin is empty, no concise DCF is loaded.
idthe node-ID (in the range [1..127, 255]). If id is 255 (unconfigured), the node-ID is obtained from the DCF.
mutexan (optional) pointer to the mutex to be locked while the internal device description is accessed. The mutex MUST be unlocked when any member function is invoked.

Definition at line 78 of file device.cpp.

Member Function Documentation

◆ Read() [1/2]

template<class T >
typename ::std::enable_if<detail::IsCanopenType<T>::value, T>::type lely::canopen::Device::Read ( uint16_t  idx,
uint8_t  subidx 
) const

Submits an SDO upload request to the local object dictionary.

This function reads the value of a sub-object while honoring all access checks and executing any registered callback function.

Parameters
idxthe object index.
subidxthe object sub-index
Returns
the result of the SDO request.
Exceptions
lely::canopen::SdoErroron error.

◆ Read() [2/2]

template<class T >
typename ::std::enable_if<detail::IsCanopenType<T>::value, T>::type lely::canopen::Device::Read ( uint16_t  idx,
uint8_t  subidx,
::std::error_code &  ec 
) const

Submits an SDO upload request to the local object dictionary.

This function reads the value of a sub-object while honoring all access checks and executing any registered callback function.

Parameters
idxthe object index.
subidxthe object sub-index
econ error, the SDO abort code is stored in ec.
Returns
the result of the SDO request, or an empty value on error.

◆ Write() [1/10]

template<class T >
typename ::std::enable_if<detail::IsCanopenBasic<T>::value>::type lely::canopen::Device::Write ( uint16_t  idx,
uint8_t  subidx,
value 
)

Submits an SDO download request to the local object dictionary.

This function writes a CANopen basic value to a sub-object while honoring all access and range checks and executing any registered callback function.

Parameters
idxthe object index.
subidxthe object sub-index
valuethe value to be written.
Exceptions
lely::canopen::SdoErroron error.

◆ Write() [2/10]

template<class T >
typename ::std::enable_if<detail::IsCanopenBasic<T>::value>::type lely::canopen::Device::Write ( uint16_t  idx,
uint8_t  subidx,
value,
::std::error_code &  ec 
)

Submits an SDO download request to the local object dictionary.

This function writes a CANopen basic value to a sub-object while honoring all access and range checks and executing any registered callback function.

Parameters
idxthe object index.
subidxthe object sub-index
valuethe value to be written.
econ error, the SDO abort code is stored in ec.

◆ Write() [3/10]

template<class T >
typename ::std::enable_if<detail::IsCanopenArray<T>::value>::type lely::canopen::Device::Write ( uint16_t  idx,
uint8_t  subidx,
const T &  value 
)

Submits an SDO download request to the local object dictionary.

This function writes a CANopen array value to a sub-object while honoring all access checks and executing any registered callback function.

Parameters
idxthe object index.
subidxthe object sub-index
valuethe value to be written.
Exceptions
lely::canopen::SdoErroron error.

◆ Write() [4/10]

template<class T >
typename ::std::enable_if<detail::IsCanopenArray<T>::value>::type lely::canopen::Device::Write ( uint16_t  idx,
uint8_t  subidx,
const T &  value,
::std::error_code &  ec 
)

Submits an SDO download request to the local object dictionary.

This function writes a CANopen array value to a sub-object while honoring all access checks and executing any registered callback function.

Parameters
idxthe object index.
subidxthe object sub-index
valuethe value to be written.
econ error, the SDO abort code is stored in ec.

◆ Write() [5/10]

void lely::canopen::Device::Write ( uint16_t  idx,
uint8_t  subidx,
const char *  value 
)

Submits an SDO download request to the local object dictionary.

This function writes a VISIBLE_STRING to a sub-object while honoring all access checks and executing any registered callback function.

Parameters
idxthe object index.
subidxthe object sub-index
valuea pointer to the (null-terminated) string to be written.
Exceptions
lely::canopen::SdoErroron error.

Definition at line 328 of file device.cpp.

◆ Write() [6/10]

void lely::canopen::Device::Write ( uint16_t  idx,
uint8_t  subidx,
const char *  value,
::std::error_code &  ec 
)

Submits an SDO download request to the local object dictionary.

This function writes a VISIBLE_STRING to a sub-object while honoring all access checks and executing any registered callback function.

Parameters
idxthe object index.
subidxthe object sub-index
valuea pointer to the (null-terminated) string to be written.
econ error, the SDO abort code is stored in ec.

Definition at line 335 of file device.cpp.

◆ Write() [7/10]

void lely::canopen::Device::Write ( uint16_t  idx,
uint8_t  subidx,
const char16_t *  value 
)

Submits an SDO download request to the local object dictionary.

This function writes a UNICODE_STRING to a sub-object while honoring all access checks and executing any registered callback function.

Parameters
idxthe object index.
subidxthe object sub-index
valuea pointer to the (null-terminated) UCS-2 string to be written.
Exceptions
lely::canopen::SdoErroron error.

Definition at line 341 of file device.cpp.

◆ Write() [8/10]

void lely::canopen::Device::Write ( uint16_t  idx,
uint8_t  subidx,
const char16_t *  value,
::std::error_code &  ec 
)

Submits an SDO download request to the local object dictionary.

This function writes a UNICODE_STRING to a sub-object while honoring all access checks and executing any registered callback function.

Parameters
idxthe object index.
subidxthe object sub-index
valuea pointer to the (null-terminated) UCS-2 string to be written.
econ error, the SDO abort code is stored in ec.

Definition at line 348 of file device.cpp.

◆ Write() [9/10]

void lely::canopen::Device::Write ( uint16_t  idx,
uint8_t  subidx,
const void *  p,
::std::size_t  n 
)

Submits an SDO download request to the local object dictionary.

This function writes an OCTET_STRING or DOMAIN value to a sub-object while honoring all access checks and executing any registered callback function.

Parameters
idxthe object index.
subidxthe object sub-index
pa pointer to the bytes to be written.
nthe number of bytes to write.
Exceptions
lely::canopen::SdoErroron error.

Definition at line 365 of file device.cpp.

◆ Write() [10/10]

void lely::canopen::Device::Write ( uint16_t  idx,
uint8_t  subidx,
const void *  p,
::std::size_t  n,
::std::error_code &  ec 
)

Submits an SDO download request to the local object dictionary.

This function writes an OCTET_STRING or DOMAIN value to a sub-object while honoring all access checks and executing any registered callback function.

Parameters
idxthe object index.
subidxthe object sub-index
pa pointer to the bytes to be written.
nthe number of bytes to write.
econ error, the SDO abort code is stored in ec.

Definition at line 372 of file device.cpp.

◆ Type() [1/2]

const ::std::type_info & lely::canopen::Device::Type ( uint16_t  idx,
uint8_t  subidx 
) const
protected

Returns the type of a sub-object.

Parameters
idxthe object index.
subidxthe object sub-index
Returns
a reference to an std::type_info object representing the type, or typeid(void) if unknown.
Exceptions
lely::canopen::SdoErrorif the sub-object does not exist.

Definition at line 392 of file device.cpp.

◆ Type() [2/2]

const ::std::type_info & lely::canopen::Device::Type ( uint16_t  idx,
uint8_t  subidx,
::std::error_code &  ec 
) const
protected

Returns the type of a sub-object.

Parameters
idxthe object index.
subidxthe object sub-index
ecif the sub-object does not exist, the SDO abort code is stored in ec.
Returns
a reference to an std::type_info object representing the type, or typeid(void) if unknown.

Definition at line 400 of file device.cpp.

◆ Get() [1/2]

template<class T >
typename ::std::enable_if<detail::IsCanopenType<T>::value, T>::type lely::canopen::Device::Get ( uint16_t  idx,
uint8_t  subidx 
) const
protected

Reads the value of a sub-object.

This function reads the value directly from the object dictionary and bypasses any access checks or registered callback functions.

Parameters
idxthe object index.
subidxthe object sub-index
Returns
a copy of the value of the sub-object.
Exceptions
lely::canopen::SdoErrorif the sub-object does not exist or the type does not match.

◆ Get() [2/2]

template<class T >
typename ::std::enable_if<detail::IsCanopenType<T>::value, T>::type lely::canopen::Device::Get ( uint16_t  idx,
uint8_t  subidx,
::std::error_code &  ec 
) const
protected

Reads the value of a sub-object.

This function reads the value directly from the object dictionary and bypasses any access checks or registered callback functions.

Parameters
idxthe object index.
subidxthe object sub-index
ecif the sub-object does not exist or the type does not match, the SDO abort code is stored in ec.
Returns
a copy of the value of the sub-object, or an empty value on error.

◆ Set() [1/10]

template<class T >
typename ::std::enable_if<detail::IsCanopenBasic<T>::value>::type lely::canopen::Device::Set ( uint16_t  idx,
uint8_t  subidx,
value 
)
protected

Writes a CANopen basic value to a sub-object.

This function writes the value directly to the object dictionary and bypasses any access and range checks or registered callback functions.

Parameters
idxthe object index.
subidxthe object sub-index
valuethe value to be written.
Exceptions
lely::canopen::SdoErrorif the sub-object does not exist or the type does not match.

◆ Set() [2/10]

template<class T >
typename ::std::enable_if<detail::IsCanopenBasic<T>::value>::type lely::canopen::Device::Set ( uint16_t  idx,
uint8_t  subidx,
value,
::std::error_code &  ec 
)
protected

Writes a CANopen basic value to a sub-object.

This function writes the value directly to the object dictionary and bypasses any access and range checks or registered callback functions.

Parameters
idxthe object index.
subidxthe object sub-index
valuethe value to be written.
ecif the sub-object does not exist or the type does not match, the SDO abort code is stored in ec.

◆ Set() [3/10]

template<class T >
typename ::std::enable_if<detail::IsCanopenArray<T>::value>::type lely::canopen::Device::Set ( uint16_t  idx,
uint8_t  subidx,
const T &  value 
)
protected

Writes a CANopen array value to a sub-object.

This function writes the array directly to the object dictionary and bypasses any access checks or registered callback functions.

Parameters
idxthe object index.
subidxthe object sub-index
valuethe value to be written.
Exceptions
lely::canopen::SdoErrorif the sub-object does not exist or the type does not match.

◆ Set() [4/10]

template<class T >
typename ::std::enable_if<detail::IsCanopenArray<T>::value>::type lely::canopen::Device::Set ( uint16_t  idx,
uint8_t  subidx,
const T &  value,
::std::error_code &  ec 
)
protected

Writes a CANopen array value to a sub-object.

This function writes the array directly to the object dictionary and bypasses any access checks or registered callback functions.

Parameters
idxthe object index.
subidxthe object sub-index
valuethe value to be written.
ecif the sub-object does not exist or the type does not match, the SDO abort code is stored in ec.

◆ Set() [5/10]

void lely::canopen::Device::Set ( uint16_t  idx,
uint8_t  subidx,
const char *  value 
)
protected

Writes a VISIBLE_STRING to a sub-object.

This function writes the string directly to the object dictionary and bypasses any access checks or registered callback functions.

Parameters
idxthe object index.
subidxthe object sub-index
valuea pointer to the (null-terminated) string to be written.
Exceptions
lely::canopen::SdoErrorif the sub-object does not exist or the type does not match.

Definition at line 664 of file device.cpp.

◆ Set() [6/10]

void lely::canopen::Device::Set ( uint16_t  idx,
uint8_t  subidx,
const char *  value,
::std::error_code &  ec 
)
protected

Writes a VISIBLE_STRING to a sub-object.

This function writes the string directly to the object dictionary and bypasses any access checks or registered callback functions.

Parameters
idxthe object index.
subidxthe object sub-index
valuea pointer to the (null-terminated) string to be written.
ecif the sub-object does not exist or the type does not match, the SDO abort code is stored in ec.

Definition at line 671 of file device.cpp.

◆ Set() [7/10]

void lely::canopen::Device::Set ( uint16_t  idx,
uint8_t  subidx,
const char16_t *  value 
)
protected

Writes a UNICODE_STRING to a sub-object.

This function writes the string directly to the object dictionary and bypasses any access checks or registered callback functions.

Parameters
idxthe object index.
subidxthe object sub-index
valuea pointer to the (null-terminated) UCS-2 string to be written.
Exceptions
lely::canopen::SdoErrorif the sub-object does not exist or the type does not match.

Definition at line 677 of file device.cpp.

◆ Set() [8/10]

void lely::canopen::Device::Set ( uint16_t  idx,
uint8_t  subidx,
const char16_t *  value,
::std::error_code &  ec 
)
protected

Writes a UNICODE_STRING to a sub-object.

This function writes the string directly to the object dictionary and bypasses any access checks or registered callback functions.

Parameters
idxthe object index.
subidxthe object sub-index
valuea pointer to the (null-terminated) UCS-2 string to be written.
ecif the sub-object does not exist or the type does not match, the SDO abort code is stored in ec.

Definition at line 684 of file device.cpp.

◆ Set() [9/10]

void lely::canopen::Device::Set ( uint16_t  idx,
uint8_t  subidx,
const void *  p,
::std::size_t  n 
)
protected

Writes an OCTET_STRING or DOMAIN value to a sub-object.

This function writes the bytes directly to the object dictionary and bypasses any access checks or registered callback functions.

Parameters
idxthe object index.
subidxthe object sub-index
pa pointer to the bytes to be written.
nthe number of bytes to write.
Exceptions
lely::canopen::SdoErrorif the sub-object does not exist or the type does not match.

Definition at line 690 of file device.cpp.

◆ Set() [10/10]

void lely::canopen::Device::Set ( uint16_t  idx,
uint8_t  subidx,
const void *  p,
::std::size_t  n,
::std::error_code &  ec 
)
protected

Writes an OCTET_STRING or DOMAIN value to a sub-object.

This function writes the bytes directly to the object dictionary and bypasses any access checks or registered callback functions.

Parameters
idxthe object index.
subidxthe object sub-index
pa pointer to the bytes to be written.
nthe number of bytes to write.
ecif the sub-object does not exist or the type does not match, the SDO abort code is stored in ec.

Definition at line 697 of file device.cpp.


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