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

The CANopen master. More...

#include <master.hpp>

Inheritance diagram for lely::canopen::BasicMaster:
Collaboration diagram for lely::canopen::BasicMaster:

Data Structures

class  ConstObject
 An accessor providing read-only access to a CANopen object in a local object dictionary. More...
 
class  ConstSubObject
 An accessor providing read-only access to a CANopen sub-object in a local object dictionary. More...
 
struct  Impl_
 The internal implementation of the CANopen master. More...
 
class  Object
 A mutator providing read/write access to a CANopen object in a local object dictionary. More...
 
class  SubObject
 A mutator providing read/write access to a CANopen sub-object in a local object dictionary. More...
 

Public Types

template<class T >
using ReadSignature = void(uint8_t id, uint16_t idx, uint8_t subidx, ::std::error_code ec, T value)
 The signature of the callback function invoked on completion of an asynchronous read (SDO upload) operation from a remote object dictionary. More...
 
using WriteSignature = void(uint8_t id, uint16_t idx, uint8_t subidx, ::std::error_code ec)
 The signature of the callback function invoked on completion of an asynchronous write (SDO download) operation to a remote object dictionary. More...
 

Public Member Functions

 BasicMaster (aio::TimerBase &timer, aio::CanBusBase &bus, const ::std::string &dcf_txt, const ::std::string &dcf_bin="", uint8_t id=0xff)
 Creates a new CANopen master. More...
 
Object operator[] (uint16_t idx)
 Returns a mutator object that provides read/write access to the specified CANopen object in the local object dictionary. More...
 
ConstObject operator[] (uint16_t idx) const
 Returns an accessor object that provides read-only access to the specified CANopen object in the local object dictionary. More...
 
void Error (uint8_t id)
 Indicates the occurrence of an error event on a remote node and triggers the error handling process (see Fig. More...
 
void RpdoRtr (int num=0)
 Requests the transmission of a PDO. More...
 
void TpdoEvent (int num=0)
 Triggers the transmission of an event-driven (asynchronous) PDO. More...
 
::std::chrono::milliseconds GetTimeout () const
 Returns the SDO timeout used during the NMT 'boot slave' and 'check configuration' processes. More...
 
void SetTimeout (const ::std::chrono::milliseconds &timeout)
 Sets the SDO timeout used during the NMT 'boot slave' and 'check configuration' processes. More...
 
template<class T >
void SubmitRead (uint8_t id, Sdo::UploadRequest< T > &req)
 Equivalent to SubmitRead(uint8_t id, Sdo::UploadRequest<T>& req, ::std::error_code& ec), except that it throws lely::canopen::SdoError on error.
 
template<class T >
void SubmitRead (uint8_t id, Sdo::UploadRequest< T > &req, ::std::error_code &ec)
 Queues an asynchronous read (SDO upload) operation. More...
 
template<class T , class F >
void SubmitRead (uint8_t id, uint16_t idx, uint8_t subidx, aio::ExecutorBase &exec, F &&con)
 Equivalent to SubmitRead(uint8_t id, uint16_t idx, uint8_t subidx, aio::ExecutorBase& exec, F&& con, ::std::error_code& ec), except that it throws lely::canopen::SdoError on error.
 
template<class T , class F >
void SubmitRead (uint8_t id, uint16_t idx, uint8_t subidx, aio::ExecutorBase &exec, F &&con, ::std::error_code &ec)
 Equivalent to SubmitRead(uint8_t id, uint16_t idx, uint8_t subidx, aio::ExecutorBase& exec, F&& con, const Sdo::duration& timeout, ::std::error_code& ec), except that it uses the SDO timeout given by GetTimeout().
 
template<class T , class F >
void SubmitRead (uint8_t id, uint16_t idx, uint8_t subidx, aio::ExecutorBase &exec, F &&con, const Sdo::duration &timeout)
 Equivalent to SubmitRead(uint8_t id, uint16_t idx, uint8_t subidx, aio::ExecutorBase& exec, F&& con, const Sdo::duration& timeout, ::std::error_code& ec), except that it throws lely::canopen::SdoError on error.
 
template<class T , class F >
void SubmitRead (uint8_t id, uint16_t idx, uint8_t subidx, aio::ExecutorBase &exec, F &&con, const Sdo::duration &timeout, ::std::error_code &ec)
 Queues an asynchronous read (SDO upload) operation. More...
 
template<class T >
void SubmitWrite (uint8_t id, Sdo::DownloadRequest< T > &req)
 Equivalent to SubmitWrite(uint8_t id, Sdo::DownloadRequest<T>& req, ::std::error_code& ec), except that it throws lely::canopen::SdoError on error.
 
template<class T >
void SubmitWrite (uint8_t id, Sdo::DownloadRequest< T > &req, ::std::error_code &ec)
 Queues an asynchronous write (SDO download) operation. More...
 
template<class T , class F >
void SubmitWrite (uint8_t id, uint16_t idx, uint8_t subidx, T &&value, aio::ExecutorBase &exec, F &&con)
 Equivalent to SubmitWrite(uint8_t id, uint16_t idx, uint8_t subidx, T&& value, aio::ExecutorBase& exec, F&& con, ::std::error_code& ec), except that it throws lely::canopen::SdoError on error.
 
template<class T , class F >
void SubmitWrite (uint8_t id, uint16_t idx, uint8_t subidx, T &&value, aio::ExecutorBase &exec, F &&con, ::std::error_code &ec)
 Equivalent to SubmitWrite(uint8_t id, uint16_t idx, uint8_t subidx, T&& value, aio::ExecutorBase& exec, F&& con, const Sdo::duration& timeout, ::std::error_code& ec), except that it uses the SDO timeout given by GetTimeout().
 
template<class T , class F >
void SubmitWrite (uint8_t id, uint16_t idx, uint8_t subidx, T &&value, aio::ExecutorBase &exec, F &&con, const Sdo::duration &timeout)
 Equivalent to SubmitWrite(uint8_t id, uint16_t idx, uint8_t subidx, T&& value, aio::ExecutorBase& exec, F&& con, const Sdo::duration& timeout, ::std::error_code& ec), except that it throws lely::canopen::SdoError on error.
 
template<class T , class F >
void SubmitWrite (uint8_t id, uint16_t idx, uint8_t subidx, T &&value, aio::ExecutorBase &exec, F &&con, const Sdo::duration &timeout, ::std::error_code &ec)
 Queues an asynchronous write (SDO download) operation. More...
 
template<class T >
aio::Future<::std::tuple<::std::error_code, T > > AsyncRead (aio::LoopBase &loop, aio::ExecutorBase &exec, uint8_t id, uint16_t idx, uint8_t subidx)
 Equivalent to AsyncRead(aio::LoopBase& loop, aio::ExecutorBase& exec, uint8_t id, uint16_t idx, uint8_t subidx, const Sdo::duration& timeout), except that it uses the SDO timeout given by GetTimeout().
 
template<class T >
aio::Future<::std::tuple<::std::error_code, T > > AsyncRead (aio::LoopBase &loop, aio::ExecutorBase &exec, uint8_t id, uint16_t idx, uint8_t subidx, const Sdo::duration &timeout)
 Queues an asynchronous read (SDO upload) operation and returns a future. More...
 
template<class T >
aio::Future<::std::error_code > AsyncWrite (aio::LoopBase &loop, aio::ExecutorBase &exec, uint8_t id, uint16_t idx, uint8_t subidx, T &&value)
 Equivalent to AsyncWrite(aio::LoopBase& loop, aio::ExecutorBase& exec, uint8_t id, uint16_t idx, uint8_t subidx, T&& value, const Sdo::duration& timeout), except that it uses the SDO timeout given by GetTimeout().
 
template<class T >
aio::Future<::std::error_code > AsyncWrite (aio::LoopBase &loop, aio::ExecutorBase &exec, uint8_t id, uint16_t idx, uint8_t subidx, T &&value, const Sdo::duration &timeout)
 Queues an asynchronous write (SDO download) operation and returns a future. More...
 
void Insert (DriverBase &driver)
 Registers a driver for a remote CANopen node. More...
 
void Erase (DriverBase &driver)
 Unregisters a driver for a remote CANopen node. More...
 
- Public Member Functions inherited from lely::canopen::Node
 Node (aio::TimerBase &timer, aio::CanBusBase &bus, const ::std::string &dcf_txt, const ::std::string &dcf_bin="", uint8_t id=0xff)
 Creates a new CANopen node. More...
 
void Reset ()
 (Re)starts the node. More...
 
- Public Member Functions inherited from lely::canopen::IoContext
 IoContext (aio::TimerBase &timer, aio::CanBusBase &bus, BasicLockable *mutex=nullptr)
 Creates a new I/O context. More...
 
aio::ExecutorBase GetExecutor () const noexcept
 Returns the executor used to process I/O events on the CAN bus.
 
template<class F >
void Post (F &&f)
 Schedules the specified Callable object for execution. More...
 
- Public Member Functions inherited from 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. 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

void OnCanError (CanError error) noexcept override
 The default implementation notifies all registered drivers. More...
 
void OnCanState (CanState new_state, CanState old_state) noexcept override
 The default implementation invokes lely::canopen::Node::OnCanState() and notifies each registered driver. More...
 
void OnCommand (NmtCommand cs) noexcept override
 The default implementation notifies all registered drivers. More...
 
virtual void OnNodeGuarding (uint8_t id, bool occurred) noexcept
 The function invoked when a node guarding timeout event occurs or is resolved. More...
 
void OnHeartbeat (uint8_t id, bool occurred) noexcept override
 The default implementation notifies the driver registered for node id. More...
 
void OnState (uint8_t id, NmtState st) noexcept override
 The default implementation notifies the driver registered for node id. More...
 
virtual void OnBoot (uint8_t id, NmtState st, char es, const ::std::string &what) noexcept
 The function invoked when the NMT 'boot slave' process completes. More...
 
virtual void OnConfig (uint8_t id) noexcept
 The function invoked when the 'update configuration' step is reached during the NMT 'boot slave' process. More...
 
void ConfigResult (uint8_t id, ::std::error_code ec) noexcept
 Reports the result of the 'update configuration' step to the NMT service. More...
 
void OnRpdo (int num, ::std::error_code ec, const void *p, ::std::size_t n) noexcept override
 The default implementation notifies all registered drivers. More...
 
void OnRpdoError (int num, uint16_t eec, uint8_t er) noexcept override
 The default implementation notifies all registered drivers. More...
 
void OnTpdo (int num, ::std::error_code ec, const void *p, ::std::size_t n) noexcept override
 The default implementation notifies all registered drivers. More...
 
void OnSync (uint8_t cnt, const time_point &t) noexcept override
 The default implementation notifies all registered drivers. More...
 
void OnSyncError (uint16_t eec, uint8_t er) noexcept override
 The default implementation notifies all registered drivers. More...
 
void OnTime (const ::std::chrono::system_clock::time_point &abs_time) noexcept override
 The default implementation notifies all registered drivers. More...
 
void OnEmcy (uint8_t id, uint16_t eec, uint8_t er, uint8_t msef[5]) noexcept override
 The default implementation notifies the driver registered for node id. More...
 
SdoGetSdo (uint8_t id)
 Returns a pointer to the default client-SDO service for the given node. More...
 
void CancelSdo (uint8_t id=0)
 Aborts any ongoing or pending SDO requests for the specified slave. More...
 
- Protected Member Functions inherited from lely::canopen::Node
virtual void lock () final override
 Blocks until a lock can be obtained for the current execution agent (thread, process, task). More...
 
virtual void unlock () final override
 Releases the lock held by the execution agent. Throws no exceptions.
 
void OnCanState (CanState new_state, CanState old_state) noexcept override
 Implements the default behavior for a CAN bus state change. More...
 
CONMTnmt () const noexcept
 Returns a pointer to the internal CANopen NMT master/slave service from <lely/co/nmt.hpp>.
 
void RpdoRtr (int num=0)
 Requests the transmission of a PDO. More...
 
void TpdoEvent (int num=0)
 Triggers the transmission of an event-driven (asynchronous) PDO. More...
 
- Protected Member Functions inherited from lely::canopen::IoContext
CANNetnet () const noexcept
 Returns a pointer to the internal CAN network interface from <lely/can/net.hpp>.
 
void SetTime ()
 Update the CAN network time. More...
 
 IoContext (aio::TimerBase &timer, aio::CanBusBase &bus, BasicLockable *mutex=nullptr)
 Creates a new I/O context. More...
 
aio::ExecutorBase GetExecutor () const noexcept
 Returns the executor used to process I/O events on the CAN bus.
 
template<class F >
void Post (F &&f)
 Schedules the specified Callable object for execution. More...
 
- Protected Member Functions inherited from lely::canopen::Device
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...
 
 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...
 

Detailed Description

The CANopen master.

The master implements a CANopen node. Handling events for remote CANopen slaves is delegated to drivers (see lely::canopen::DriverBase and lely::canopen::BasicDriver), one of which can be registered for each node-ID.

For derived classes, the master behaves as an AssociativeContainer for drivers.

Definition at line 46 of file master.hpp.

Member Typedef Documentation

◆ ReadSignature

template<class T >
using lely::canopen::BasicMaster::ReadSignature = void(uint8_t id, uint16_t idx, uint8_t subidx, ::std::error_code ec, T value)

The signature of the callback function invoked on completion of an asynchronous read (SDO upload) operation from a remote object dictionary.

Note that the callback function SHOULD NOT throw exceptions. Since it is invoked from C, any exception that is thrown cannot be caught and will result in a call to std::terminate().

Parameters
idthe node-ID (in the range[1..127]).
idxthe object index.
subidxthe object sub-index.
ecthe SDO abort code (0 on success).
valuethe value received from the SDO server.

Definition at line 357 of file master.hpp.

◆ WriteSignature

using lely::canopen::BasicMaster::WriteSignature = void(uint8_t id, uint16_t idx, uint8_t subidx, ::std::error_code ec)

The signature of the callback function invoked on completion of an asynchronous write (SDO download) operation to a remote object dictionary.

Note that the callback function SHOULD NOT throw exceptions. Since it is invoked from C, any exception that is thrown cannot be caught and will result in a call to std::terminate().

Parameters
idthe node-ID (in the range[1..127]).
idxthe object index.
subidxthe object sub-index.
ecthe SDO abort code (0 on success).

Definition at line 372 of file master.hpp.

Constructor & Destructor Documentation

◆ BasicMaster()

lely::canopen::BasicMaster::BasicMaster ( aio::TimerBase &  timer,
aio::CanBusBase &  bus,
const ::std::string &  dcf_txt,
const ::std::string &  dcf_bin = "",
uint8_t  id = 0xff 
)

Creates a new CANopen master.

After creation, the master is in the NMT 'Initialisation' state and does not yet create any services or perform any communication. Call Reset() to start the boot-up process.

Parameters
timerthe timer used for CANopen events.
busa handle to the CAN bus.
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.

Definition at line 55 of file master.cpp.

Member Function Documentation

◆ operator[]() [1/2]

Object lely::canopen::BasicMaster::operator[] ( uint16_t  idx)
inline

Returns a mutator object that provides read/write access to the specified CANopen object in the local object dictionary.

Note that this function succeeds even if the object does not exist.

Parameters
idxthe object index.
Returns
a mutator object for a CANopen object in the local object dictionary.

Definition at line 405 of file master.hpp.

◆ operator[]() [2/2]

ConstObject lely::canopen::BasicMaster::operator[] ( uint16_t  idx) const
inline

Returns an accessor object that provides read-only access to the specified CANopen object in the local object dictionary.

Note that this function succeeds even if the object does not exist.

Parameters
idxthe object index.
Returns
an accessor object for a CANopen object in the local object dictionary.

Definition at line 417 of file master.hpp.

◆ Error()

void lely::canopen::BasicMaster::Error ( uint8_t  id)

Indicates the occurrence of an error event on a remote node and triggers the error handling process (see Fig.

12 in CiA 302-2 v4.1.0). Note that depending on the value of objects 1F80 (NMT startup) and 1F81 (NMT slave assignment), the occurrence of an error event MAY trigger an NMT state transition of the entire network, including the master.

Parameters
idthe node-ID (in the range[1..127]).

Definition at line 64 of file master.cpp.

◆ RpdoRtr()

void lely::canopen::BasicMaster::RpdoRtr ( int  num = 0)

Requests the transmission of a PDO.

Parameters
numthe PDO number (in the range [1..512]).

Definition at line 78 of file master.cpp.

◆ TpdoEvent()

void lely::canopen::BasicMaster::TpdoEvent ( int  num = 0)

Triggers the transmission of an event-driven (asynchronous) PDO.

Parameters
numthe PDO number (in the range [1..512]).
Exceptions
std::system_error(std::errc::resource_unavailable_try_again)if the inhibit time has not yet elapsed.

Definition at line 85 of file master.cpp.

◆ GetTimeout()

std::chrono::milliseconds lely::canopen::BasicMaster::GetTimeout ( ) const

Returns the SDO timeout used during the NMT 'boot slave' and 'check configuration' processes.

See also
SetTimeout()

Definition at line 92 of file master.cpp.

◆ SetTimeout()

void lely::canopen::BasicMaster::SetTimeout ( const ::std::chrono::milliseconds &  timeout)

Sets the SDO timeout used during the NMT 'boot slave' and 'check configuration' processes.

See also
GetTimeout()

Definition at line 99 of file master.cpp.

◆ SubmitRead() [1/2]

template<class T >
void lely::canopen::BasicMaster::SubmitRead ( uint8_t  id,
Sdo::UploadRequest< T > &  req,
::std::error_code &  ec 
)
inline

Queues an asynchronous read (SDO upload) operation.

Parameters
idthe node-ID (in the range[1..127]).
reqthe SDO upload request.
ecthe error code (0 on success). ec == SdoErrc::NO_SDO if no client-SDO is available.

Definition at line 497 of file master.hpp.

◆ SubmitRead() [2/2]

template<class T , class F >
void lely::canopen::BasicMaster::SubmitRead ( uint8_t  id,
uint16_t  idx,
uint8_t  subidx,
aio::ExecutorBase &  exec,
F &&  con,
const Sdo::duration timeout,
::std::error_code &  ec 
)
inline

Queues an asynchronous read (SDO upload) operation.

This function reads the value of a sub-object in a remote object dictionary.

Parameters
idthe node-ID (in the range[1..127]).
idxthe object index.
subidxthe object sub-index.
execthe executor used to execute the confirmation function.
conthe confirmation function to be called on completion of the SDO request.
timeoutthe SDO timeout. If, after the request is initiated, the timeout expires before receiving a response from the server, the client aborts the transfer with abort code SdoErrc::TIMEOUT.
ecthe error code (0 on success). ec == SdoErrc::NO_SDO if no client-SDO is available.

Definition at line 571 of file master.hpp.

◆ SubmitWrite() [1/2]

template<class T >
void lely::canopen::BasicMaster::SubmitWrite ( uint8_t  id,
Sdo::DownloadRequest< T > &  req,
::std::error_code &  ec 
)
inline

Queues an asynchronous write (SDO download) operation.

Parameters
idthe node-ID (in the range[1..127]).
reqthe SDO download request.
ecthe error code (0 on success). ec == SdoErrc::NO_SDO if no client-SDO is available.

Definition at line 617 of file master.hpp.

◆ SubmitWrite() [2/2]

template<class T , class F >
void lely::canopen::BasicMaster::SubmitWrite ( uint8_t  id,
uint16_t  idx,
uint8_t  subidx,
T &&  value,
aio::ExecutorBase &  exec,
F &&  con,
const Sdo::duration timeout,
::std::error_code &  ec 
)
inline

Queues an asynchronous write (SDO download) operation.

This function writes a value to a sub-object in a remote object dictionary.

Parameters
idthe node-ID (in the range[1..127]).
idxthe object index.
subidxthe object sub-index.
valuethe value to be written.
execthe executor used to execute the confirmation function.
conthe confirmation function to be called on completion of the SDO request.
timeoutthe SDO timeout. If, after the request is initiated, the timeout expires before receiving a response from the server, the client aborts the transfer with abort code SdoErrc::TIMEOUT.
ecthe error code (0 on success). ec == SdoErrc::NO_SDO if no client-SDO is available.

Definition at line 696 of file master.hpp.

◆ AsyncRead()

template<class T >
aio::Future<::std::tuple<::std::error_code, T> > lely::canopen::BasicMaster::AsyncRead ( aio::LoopBase &  loop,
aio::ExecutorBase &  exec,
uint8_t  id,
uint16_t  idx,
uint8_t  subidx,
const Sdo::duration timeout 
)
inline

Queues an asynchronous read (SDO upload) operation and returns a future.

Parameters
loopthe event loop used to create the future.
execthe executor used to create the future. The executor SHOULD be based on loop.
idthe node-ID (in the range[1..127]).
idxthe object index.
subidxthe object sub-index.
timeoutthe SDO timeout. If, after the request is initiated, the timeout expires before receiving a response from the server, the client aborts the transfer with abort code SdoErrc::TIMEOUT.
Returns
a future which, on completion, holds the SDO abort code and the received value. Note that if the client-SDO service is not available, the returned future is invalid.

Definition at line 754 of file master.hpp.

◆ AsyncWrite()

template<class T >
aio::Future<::std::error_code> lely::canopen::BasicMaster::AsyncWrite ( aio::LoopBase &  loop,
aio::ExecutorBase &  exec,
uint8_t  id,
uint16_t  idx,
uint8_t  subidx,
T &&  value,
const Sdo::duration timeout 
)
inline

Queues an asynchronous write (SDO download) operation and returns a future.

Parameters
loopthe event loop used to create the future.
execthe executor used to create the future. The executor SHOULD be based on loop.
idthe node-ID (in the range[1..127]).
idxthe object index.
subidxthe object sub-index.
valuethe value to be written.
timeoutthe SDO timeout. If, after the request is initiated, the timeout expires before receiving a response from the server, the client aborts the transfer with abort code SdoErrc::TIMEOUT.
Returns
a future which, on completion, holds the SDO abort code. Note that if the client-SDO service is not available, the returned future is invalid.

Definition at line 801 of file master.hpp.

◆ Insert()

void lely::canopen::BasicMaster::Insert ( DriverBase driver)

Registers a driver for a remote CANopen node.

If an event occurs for that node, or for the entire CANopen network, the corresponding method of the driver will be invoked.

Exceptions
std::out_of_rangeif the node-ID is invalid or already registered.
See also
Erase()

Definition at line 106 of file master.cpp.

◆ Erase()

void lely::canopen::BasicMaster::Erase ( DriverBase driver)

Unregisters a driver for a remote CANopen node.

See also
Insert()

Definition at line 123 of file master.cpp.

◆ OnCanError()

void lely::canopen::BasicMaster::OnCanError ( CanError  error)
overrideprotectedvirtualnoexcept

The default implementation notifies all registered drivers.

See also
IoContext::OnCanError(), DriverBase::OnCanError()

Reimplemented from lely::canopen::IoContext.

Reimplemented in lely::canopen::AsyncMaster.

Definition at line 131 of file master.cpp.

◆ OnCanState()

void lely::canopen::BasicMaster::OnCanState ( CanState  new_state,
CanState  old_state 
)
overrideprotectedvirtualnoexcept

The default implementation invokes lely::canopen::Node::OnCanState() and notifies each registered driver.

See also
IoContext::OnCanState(), DriverBase::OnCanState()

Reimplemented from lely::canopen::IoContext.

Reimplemented in lely::canopen::AsyncMaster.

Definition at line 139 of file master.cpp.

◆ OnCommand()

void lely::canopen::BasicMaster::OnCommand ( NmtCommand  cs)
overrideprotectedvirtualnoexcept

The default implementation notifies all registered drivers.

Unless the master enters the pre-operational or operational state, all ongoing and pending SDO requests are aborted.

See also
Node::OnCommand(), DriverBase::OnCommand()

Reimplemented from lely::canopen::Node.

Reimplemented in lely::canopen::AsyncMaster.

Definition at line 147 of file master.cpp.

◆ OnNodeGuarding()

void lely::canopen::BasicMaster::OnNodeGuarding ( uint8_t  id,
bool  occurred 
)
protectedvirtualnoexcept

The function invoked when a node guarding timeout event occurs or is resolved.

Note that depending on the value of object 1029:01 (Error behavior object), the occurrence of a node guarding event MAY trigger an NMT state transition. If so, this function is called after the state change completes.

The default implementation notifies the driver registered for node id.

Parameters
idthe node-ID (in the range [1..127]).
occurredtrue if the node guarding event occurred, false if it was resolved.
See also
DriverBase::OnNodeGuarding()

Reimplemented in lely::canopen::AsyncMaster.

Definition at line 158 of file master.cpp.

◆ OnHeartbeat()

void lely::canopen::BasicMaster::OnHeartbeat ( uint8_t  id,
bool  occurred 
)
overrideprotectedvirtualnoexcept

The default implementation notifies the driver registered for node id.

See also
Node::OnHeartbeat(), DriverBase::OnHeartbeat()

Reimplemented from lely::canopen::Node.

Reimplemented in lely::canopen::AsyncMaster.

Definition at line 167 of file master.cpp.

◆ OnState()

void lely::canopen::BasicMaster::OnState ( uint8_t  id,
NmtState  st 
)
overrideprotectedvirtualnoexcept

The default implementation notifies the driver registered for node id.

If a boot-up event (st == NmtState::BOOTUP) is detected, any ongoing or pending SDO requests for the slave are aborted. This is necessary because the master MAY need the Client-SDO service for the NMT 'boot slave' process.

See also
Node::OnState(), DriverBase::OnState()

Reimplemented from lely::canopen::Node.

Reimplemented in lely::canopen::AsyncMaster.

Definition at line 176 of file master.cpp.

◆ OnBoot()

void lely::canopen::BasicMaster::OnBoot ( uint8_t  id,
NmtState  st,
char  es,
const ::std::string &  what 
)
protectedvirtualnoexcept

The function invoked when the NMT 'boot slave' process completes.

The default implementation notifies the driver registered for node id.

Parameters
idthe node-ID (in the range [1..127]).
stthe state of the remote node (including the toggle bit (NmtState::TOGGLE) if node guarding is enabled).
esthe error status (in the range ['A'..'O'], or 0 on success):
  • 'A': The CANopen device is not listed in object 1F81.
  • 'B': No response received for upload request of object 1000.
  • 'C': Value of object 1000 from CANopen device is different to value in object 1F84 (Device type).
  • 'D': Value of object 1018:01 from CANopen device is different to value in object 1F85 (Vendor-ID).
  • 'E': Heartbeat event. No heartbeat message received from CANopen device.
  • 'F': Node guarding event. No confirmation for guarding request received from CANopen device.
  • 'G': Objects for program download are not configured or inconsistent.
  • 'H': Software update is required, but not allowed because of configuration or current status.
  • 'I': Software update is required, but program download failed.
  • 'J': Configuration download failed.
  • 'K': Heartbeat event during start error control service. No heartbeat message received from CANopen device during start error control service.
  • 'L': NMT slave was initially operational. (CANopen manager may resume operation with other CANopen devices)
  • 'M': Value of object 1018:02 from CANopen device is different to value in object 1F86 (Product code).
  • 'N': Value of object 1018:03 from CANopen device is different to value in object 1F87 (Revision number).
  • 'O': Value of object 1018:04 from CANopen device is different to value in object 1F88 (Serial number).
whatif es is non-zero, contains a string explaining the error.
See also
DriverBase::OnBoot()

Reimplemented in lely::canopen::AsyncMaster.

Definition at line 188 of file master.cpp.

◆ OnConfig()

void lely::canopen::BasicMaster::OnConfig ( uint8_t  id)
protectedvirtualnoexcept

The function invoked when the 'update configuration' step is reached during the NMT 'boot slave' process.

The 'boot slave' process is halted until the result of the 'update configuration' step is communicated to the NMT service with ConfigResult().

The default implementation delegates the configuration update to the driver, if one is registered for node id. If not, a successful result is communicated to the NMT service.

See also
DriverBase::OnConfig()

Reimplemented in lely::canopen::AsyncMaster.

Definition at line 198 of file master.cpp.

◆ ConfigResult()

void lely::canopen::BasicMaster::ConfigResult ( uint8_t  id,
::std::error_code  ec 
)
protectednoexcept

Reports the result of the 'update configuration' step to the NMT service.

Parameters
idthe node-ID (in the range [1..127]).
ecthe SDO abort code (0 on success).

Definition at line 216 of file master.cpp.

◆ OnRpdo()

void lely::canopen::BasicMaster::OnRpdo ( int  num,
::std::error_code  ec,
const void *  p,
::std::size_t  n 
)
overrideprotectedvirtualnoexcept

The default implementation notifies all registered drivers.

See also
Node::OnRpdo(), DriverBase::OnRpdo()

Reimplemented from lely::canopen::Node.

Reimplemented in lely::canopen::AsyncMaster.

Definition at line 225 of file master.cpp.

◆ OnRpdoError()

void lely::canopen::BasicMaster::OnRpdoError ( int  num,
uint16_t  eec,
uint8_t  er 
)
overrideprotectedvirtualnoexcept

The default implementation notifies all registered drivers.

See also
Node::OnRpdoError(), DriverBase::OnRpdoError()

Reimplemented from lely::canopen::Node.

Reimplemented in lely::canopen::AsyncMaster.

Definition at line 234 of file master.cpp.

◆ OnTpdo()

void lely::canopen::BasicMaster::OnTpdo ( int  num,
::std::error_code  ec,
const void *  p,
::std::size_t  n 
)
overrideprotectedvirtualnoexcept

The default implementation notifies all registered drivers.

See also
Node::OnTpdo(), DriverBase::OnTpdo()

Reimplemented from lely::canopen::Node.

Reimplemented in lely::canopen::AsyncMaster.

Definition at line 242 of file master.cpp.

◆ OnSync()

void lely::canopen::BasicMaster::OnSync ( uint8_t  cnt,
const time_point &  t 
)
overrideprotectedvirtualnoexcept

The default implementation notifies all registered drivers.

See also
Node::OnSync(), DriverBase::OnSync()

Reimplemented from lely::canopen::Node.

Reimplemented in lely::canopen::AsyncMaster.

Definition at line 251 of file master.cpp.

◆ OnSyncError()

void lely::canopen::BasicMaster::OnSyncError ( uint16_t  eec,
uint8_t  er 
)
overrideprotectedvirtualnoexcept

The default implementation notifies all registered drivers.

See also
Node::OnSyncError(), DriverBase::OnSyncError()

Reimplemented from lely::canopen::Node.

Reimplemented in lely::canopen::AsyncMaster.

Definition at line 259 of file master.cpp.

◆ OnTime()

void lely::canopen::BasicMaster::OnTime ( const ::std::chrono::system_clock::time_point &  abs_time)
overrideprotectedvirtualnoexcept

The default implementation notifies all registered drivers.

See also
Node::OnTime(), DriverBase::OnTime()

Reimplemented from lely::canopen::Node.

Reimplemented in lely::canopen::AsyncMaster.

Definition at line 267 of file master.cpp.

◆ OnEmcy()

void lely::canopen::BasicMaster::OnEmcy ( uint8_t  id,
uint16_t  eec,
uint8_t  er,
uint8_t  msef[5] 
)
overrideprotectedvirtualnoexcept

The default implementation notifies the driver registered for node id.

See also
Node::OnEmcy(), DriverBase::OnEmcy()

Reimplemented from lely::canopen::Node.

Reimplemented in lely::canopen::AsyncMaster.

Definition at line 276 of file master.cpp.

◆ GetSdo()

Sdo * lely::canopen::BasicMaster::GetSdo ( uint8_t  id)
protected

Returns a pointer to the default client-SDO service for the given node.

If the master is not in the pre-operational or operational state, or if the master needs the client-SDO to boot the node, a null pointer is returned.

Definition at line 286 of file master.cpp.

◆ CancelSdo()

void lely::canopen::BasicMaster::CancelSdo ( uint8_t  id = 0)
protected

Aborts any ongoing or pending SDO requests for the specified slave.

Parameters
idthe node-ID (0 for all nodes, [1..127] for a specific slave).

Definition at line 305 of file master.cpp.


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