Lely core libraries
2.2.5
|
The base class for drivers for remote CANopen nodes. More...
#include <driver.hpp>
Public Member Functions | |
BasicDriver (ev_exec_t *exec, BasicMaster &master, uint8_t id) | |
Creates a new driver for a remote CANopen node and registers it with the master. More... | |
BasicDriver (BasicMaster &master, uint8_t id) | |
Creates a new driver for a remote CANopen node and registers it with the master. | |
ev::Executor | GetExecutor () const noexcept final |
Returns the executor used to execute event handlers for this driver, including SDO confirmation functions. | |
uint8_t | netid () const noexcept final |
Returns the network-ID. | |
uint8_t | id () const noexcept final |
Returns the node-ID. | |
void | ConfigHeartbeat (const ::std::chrono::milliseconds &ms, ::std::error_code &ec) |
Configures heartbeat consumption by updating CANopen object 1016 (Consumer heartbeat time). More... | |
void | ConfigHeartbeat (const ::std::chrono::milliseconds &ms) |
Configures heartbeat consumption by updating CANopen object 1016 (Consumer heartbeat time). More... | |
bool | Boot () |
Requests the NMT 'boot slave' process for the remote node. More... | |
bool | IsReady () const |
Returns true if the remote node is ready (i.e., the NMT boot slave process has successfully completed and no subsequent boot-up event has been received) and false if not. More... | |
void | Error () |
Indicates the occurrence of an error event on the remote node and triggers the error handling process. More... | |
template<class F > | |
void | SubmitWait (const time_point &t, F &&f) |
Submits a wait operation. More... | |
template<class F > | |
void | SubmitWait (const duration &d, F &&f) |
Submits a wait operation. More... | |
SdoFuture< void > | AsyncWait (const time_point &t) |
Submits an asynchronous wait operation and creates a future which becomes ready once the wait operation completes (or is canceled). More... | |
SdoFuture< void > | AsyncWait (const duration &d) |
Submits an asynchronous wait operation and creates a future which becomes ready once the wait operation completes (or is canceled). More... | |
template<class T , class F > | |
void | SubmitRead (uint16_t idx, uint8_t subidx, F &&con) |
Equivalent to SubmitRead(uint16_t idx, uint8_t subidx, F&& con, const ::std::chrono::milliseconds& timeout), except that it uses the SDO timeout given by lely::canopen::BasicMaster::GetTimeout(). | |
template<class T , class F > | |
void | SubmitRead (uint16_t idx, uint8_t subidx, F &&con, ::std::error_code &ec) |
Equivalent to SubmitRead(uint16_t idx, uint8_t subidx, F&& con, const ::std::chrono::milliseconds& timeout, ::std::error_code& ec), except that it uses the SDO timeout given by lely::canopen::BasicMaster::GetTimeout(). | |
template<class T , class F > | |
void | SubmitRead (uint16_t idx, uint8_t subidx, F &&con, const ::std::chrono::milliseconds &timeout) |
Equivalent to SubmitRead(uint16_t idx, uint8_t subidx, F&& con, const ::std::chrono::milliseconds& timeout, ::std::error_code& ec), except that it throws lely::canopen::SdoError on error. | |
template<class T , class F > | |
void | SubmitRead (uint16_t idx, uint8_t subidx, F &&con, const ::std::chrono::milliseconds &timeout, ::std::error_code &ec) |
Queues an asynchronous read (SDO upload) operation. More... | |
template<class T , class F > | |
void | SubmitWrite (uint16_t idx, uint8_t subidx, T &&value, F &&con) |
Equivalent to SubmitWrite(uint16_t idx, uint8_t subidx, T&& value, F&& con, const ::std::chrono::milliseconds& timeout), except that it uses the SDO timeout given by lely::canopen::BasicMaster::GetTimeout(). | |
template<class T , class F > | |
void | SubmitWrite (uint16_t idx, uint8_t subidx, T &&value, F &&con, ::std::error_code &ec) |
Equivalent to SubmitWrite(uint16_t idx, uint8_t subidx, T&& value, F&& con, const ::std::chrono::milliseconds& timeout, ::std::error_code& ec), except that it uses the SDO timeout given by lely::canopen::BasicMaster::GetTimeout(). | |
template<class T , class F > | |
void | SubmitWrite (uint16_t idx, uint8_t subidx, T &&value, F &&con, const ::std::chrono::milliseconds &timeout) |
Equivalent to SubmitWrite(uint16_t idx, uint8_t subidx, T&& value, F&& con, const ::std::chrono::milliseconds& timeout, ::std::error_code& ec), except that it throws lely::canopen::SdoError on error. | |
template<class T , class F > | |
void | SubmitWrite (uint16_t idx, uint8_t subidx, T &&value, F &&con, const ::std::chrono::milliseconds &timeout, ::std::error_code &ec) |
Queues an asynchronous write (SDO download) operation. More... | |
template<class T > | |
SdoFuture< T > | AsyncRead (uint16_t idx, uint8_t subidx) |
Equivalent to AsyncRead(uint16_t idx, uint8_t subidx, const ::std::chrono::milliseconds& timeout), except that it uses the SDO timeout given by lely::canopen::BasicMaster::GetTimeout(). | |
template<class T > | |
SdoFuture< T > | AsyncRead (uint16_t idx, uint8_t subidx, const ::std::chrono::milliseconds &timeout) |
Queues an asynchronous read (SDO upload) operation and creates a future which becomes ready once the request completes (or is canceled). More... | |
template<class T > | |
SdoFuture< void > | AsyncWrite (uint16_t idx, uint8_t subidx, T &&value) |
Equivalent to AsyncWrite(uint16_t idx, uint8_t subidx, T&& value, const ::std::chrono::milliseconds& timeout), except that it uses the SDO timeout given by lely::canopen::BasicMaster::GetTimeout(). | |
template<class T > | |
SdoFuture< void > | AsyncWrite (uint16_t idx, uint8_t subidx, T &&value, const ::std::chrono::milliseconds &timeout) |
Queues an asynchronous write (SDO download) operation and creates a future which becomes ready once the request completes (or is canceled). More... | |
void | Insert (LogicalDriverBase &driver) |
Registers a logical device driver for the remote node. More... | |
void | Erase (LogicalDriverBase &driver) |
Unregisters a logical device driver for the remote node. More... | |
template<class F , class... Args> | |
void | Post (F &&f, Args &&... args) |
Schedules the specified Callable object for execution by the executor for this driver. More... | |
Data Fields | |
BasicMaster & | master |
A reference to the master with which this driver is registered. | |
class BasicMaster::RpdoMapped | rpdo_mapped |
An accessor providing read-only access to RPDO-mapped objects in the remote object dictionary. More... | |
class BasicMaster::TpdoMapped | tpdo_mapped |
A mutator providing read/write access to TPDO-mapped objects in the remote object dictionary. More... | |
TpdoEventMutex & | tpdo_event_mutex |
Protected Member Functions | |
void | OnCanState (io::CanState new_state, io::CanState old_state) noexcept override |
The default implementation notifies all registered logical device drivers. More... | |
void | OnCanError (io::CanError error) noexcept override |
The default implementation notifies all registered logical device drivers. More... | |
void | OnRpdoWrite (uint16_t idx, uint8_t subidx) noexcept override |
The default implementation notifies all registered logical device drivers, unless the object index is part of the standardized profile area of a logical device (6000..9FFF). More... | |
void | OnCommand (NmtCommand cs) noexcept override |
The default implementation notifies all registered logical device drivers. More... | |
void | OnNodeGuarding (bool occurred) noexcept override |
The default implementation notifies all registered logical device drivers. More... | |
void | OnHeartbeat (bool occurred) noexcept override |
The default implementation notifies all registered logical device drivers. More... | |
void | OnState (NmtState st) noexcept override |
The default implementation notifies all registered logical device drivers. More... | |
void | OnBoot (NmtState st, char es, const ::std::string &what) noexcept override |
The default implementation notifies all registered logical device drivers. More... | |
void | OnConfig (::std::function< void(::std::error_code ec)> res) noexcept override |
The default implementation invokes AsyncConfig() to start the configuration process for all registered logical device drivers. More... | |
void | OnDeconfig (::std::function< void(::std::error_code ec)> res) noexcept override |
The default implementation invokes AsyncDeconfig() to start the deconfiguration process for all registered logical device drivers. More... | |
void | OnSync (uint8_t cnt, const time_point &t) noexcept override |
The default implementation notifies all registered logical device drivers. More... | |
void | OnSyncError (uint16_t eec, uint8_t er) noexcept override |
The default implementation notifies all registered logical device drivers. More... | |
void | OnTime (const ::std::chrono::system_clock::time_point &abs_time) noexcept override |
The default implementation notifies all registered logical device drivers. More... | |
void | OnEmcy (uint16_t eec, uint8_t er, uint8_t msef[5]) noexcept override |
The default implementation notifies all registered logical device drivers. More... | |
SdoFuture< void > | AsyncConfig (int num=0) |
Invokes LogicalDriverBase::AsyncConfig() for the specified logical device driver. More... | |
SdoFuture< void > | AsyncDeconfig (int num=0) |
Invokes LogicalDriverBase::AsyncDeconfig() for the specified logical device driver. More... | |
The base class for drivers for remote CANopen nodes.
Definition at line 278 of file driver.hpp.
|
explicit |
Creates a new driver for a remote CANopen node and registers it with the master.
exec | the executor used to execute event handlers for this driver, including SDO confirmation functions. If exec is a null pointer, the CANopen master executor is used. |
master | a reference to a CANopen master. |
id | the node-ID of the remote node (in the range [1..127]). |
std::out_of_range | if the node-ID is invalid or already registered. |
Definition at line 40 of file driver.cpp.
|
inline |
Configures heartbeat consumption by updating CANopen object 1016 (Consumer heartbeat time).
ms | the heartbeat timeout (in milliseconds). |
ec | if heartbeat consumption cannot be configured, the SDO abort code is stored in ec. |
Definition at line 334 of file driver.hpp.
|
inline |
Configures heartbeat consumption by updating CANopen object 1016 (Consumer heartbeat time).
ms | the heartbeat timeout (in milliseconds). |
lely::canopen::SdoError | if heartbeat consumption cannot be configured. |
Definition at line 349 of file driver.hpp.
|
inline |
Requests the NMT 'boot slave' process for the remote node.
OnBoot() is invoked once the boot-up process completes.
Definition at line 360 of file driver.hpp.
|
inline |
Returns true if the remote node is ready (i.e., the NMT boot slave
process has successfully completed and no subsequent boot-up event has been received) and false if not.
If this function returns true, the default client-SDO service is available.
Definition at line 374 of file driver.hpp.
|
inline |
Indicates the occurrence of an error event on the remote node and triggers the error handling process.
Definition at line 385 of file driver.hpp.
|
inline |
Submits a wait operation.
The completion task is submitted for execution once the specified absolute timeout expires.
t | the absolute expiration time of the wait operation. |
f | the function to be called on completion of the wait operation. |
Definition at line 398 of file driver.hpp.
|
inline |
Submits a wait operation.
The completion task is submitted for execution once the specified relative timeout expires.
d | the relative expiration time of the wait operation. |
f | the function to be called on completion of the wait operation. |
Definition at line 411 of file driver.hpp.
|
inline |
Submits an asynchronous wait operation and creates a future which becomes ready once the wait operation completes (or is canceled).
t | the absolute expiration time of the wait operation. |
Definition at line 424 of file driver.hpp.
|
inline |
Submits an asynchronous wait operation and creates a future which becomes ready once the wait operation completes (or is canceled).
d | the relative expiration time of the wait operation. |
Definition at line 437 of file driver.hpp.
|
inline |
Queues an asynchronous read (SDO upload) operation.
This function reads the value of a sub-object in a remote object dictionary.
idx | the object index. |
subidx | the object sub-index. |
con | the confirmation function to be called on completion of the SDO request. |
timeout | the 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. |
ec | the error code (0 on success). ec == SdoErrc::NO_SDO if no client-SDO is available. |
Definition at line 497 of file driver.hpp.
|
inline |
Queues an asynchronous write (SDO download) operation.
This function writes a value to a sub-object in a remote object dictionary.
idx | the object index. |
subidx | the object sub-index. |
value | the value to be written. |
con | the confirmation function to be called on completion of the SDO request. |
timeout | the 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. |
ec | the error code (0 on success). ec == SdoErrc::NO_SDO if no client-SDO is available. |
Definition at line 563 of file driver.hpp.
|
inline |
Queues an asynchronous read (SDO upload) operation and creates a future which becomes ready once the request completes (or is canceled).
idx | the object index. |
subidx | the object sub-index. |
timeout | the 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. |
Definition at line 599 of file driver.hpp.
|
inline |
Queues an asynchronous write (SDO download) operation and creates a future which becomes ready once the request completes (or is canceled).
idx | the object index. |
subidx | the object sub-index. |
value | the value to be written. |
timeout | the 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. |
Definition at line 633 of file driver.hpp.
void lely::canopen::BasicDriver::Insert | ( | LogicalDriverBase & | driver | ) |
Registers a logical device driver for the remote node.
If an event occurs for the node, or for the entire CANopen network, the corresponding method of the logical driver will be invoked.
std::out_of_range | if the logical device number is invalid or already registered. |
Definition at line 53 of file driver.cpp.
void lely::canopen::BasicDriver::Erase | ( | LogicalDriverBase & | driver | ) |
Unregisters a logical device driver for the remote node.
Definition at line 66 of file driver.cpp.
|
inline |
Schedules the specified Callable object for execution by the executor for this driver.
Definition at line 666 of file driver.hpp.
|
overrideprotectedvirtualnoexcept |
The default implementation notifies all registered logical device drivers.
Implements lely::canopen::DriverBase.
Definition at line 135 of file driver.cpp.
|
overrideprotectedvirtualnoexcept |
The default implementation notifies all registered logical device drivers.
Implements lely::canopen::DriverBase.
Definition at line 141 of file driver.cpp.
|
overrideprotectedvirtualnoexcept |
The default implementation notifies all registered logical device drivers, unless the object index is part of the standardized profile area of a logical device (6000..9FFF).
In that case, the driver registered for the corresponding logical device is notified and the object index is adjusted to the standardized profile area of the first logical device (6000..67FF).
Implements lely::canopen::DriverBase.
Definition at line 146 of file driver.cpp.
|
overrideprotectedvirtualnoexcept |
The default implementation notifies all registered logical device drivers.
Implements lely::canopen::DriverBase.
Definition at line 157 of file driver.cpp.
|
overrideprotectedvirtualnoexcept |
The default implementation notifies all registered logical device drivers.
Implements lely::canopen::DriverBase.
Definition at line 162 of file driver.cpp.
|
overrideprotectedvirtualnoexcept |
The default implementation notifies all registered logical device drivers.
Implements lely::canopen::DriverBase.
Definition at line 167 of file driver.cpp.
|
overrideprotectedvirtualnoexcept |
The default implementation notifies all registered logical device drivers.
Implements lely::canopen::DriverBase.
Definition at line 172 of file driver.cpp.
|
overrideprotectedvirtualnoexcept |
The default implementation notifies all registered logical device drivers.
Implements lely::canopen::DriverBase.
Definition at line 177 of file driver.cpp.
|
overrideprotectedvirtualnoexcept |
The default implementation invokes AsyncConfig() to start the configuration process for all registered logical device drivers.
Implements lely::canopen::DriverBase.
Definition at line 182 of file driver.cpp.
|
overrideprotectedvirtualnoexcept |
The default implementation invokes AsyncDeconfig() to start the deconfiguration process for all registered logical device drivers.
Implements lely::canopen::DriverBase.
Definition at line 213 of file driver.cpp.
|
overrideprotectedvirtualnoexcept |
The default implementation notifies all registered logical device drivers.
Implements lely::canopen::DriverBase.
Definition at line 244 of file driver.cpp.
|
overrideprotectedvirtualnoexcept |
The default implementation notifies all registered logical device drivers.
Implements lely::canopen::DriverBase.
Definition at line 249 of file driver.cpp.
|
overrideprotectedvirtualnoexcept |
The default implementation notifies all registered logical device drivers.
Implements lely::canopen::DriverBase.
Definition at line 254 of file driver.cpp.
|
overrideprotectedvirtualnoexcept |
The default implementation notifies all registered logical device drivers.
Implements lely::canopen::DriverBase.
Definition at line 260 of file driver.cpp.
|
protected |
Invokes LogicalDriverBase::AsyncConfig() for the specified logical device driver.
If num is 0, invokes LogicalDriverBase::AsyncConfig() for all registered logical device drivers and returns a future which becomes ready once all configuration processes complete.
Definition at line 72 of file driver.cpp.
|
protected |
Invokes LogicalDriverBase::AsyncDeconfig() for the specified logical device driver.
If num is 0, invokes LogicalDriverBase::AsyncDeconfig() for all registered logical device drivers and returns a future which becomes ready once all deconfiguration processes complete.
Definition at line 103 of file driver.cpp.
class BasicMaster::RpdoMapped lely::canopen::BasicDriver::rpdo_mapped |
An accessor providing read-only access to RPDO-mapped objects in the remote object dictionary.
Definition at line 679 of file driver.hpp.
class BasicMaster::TpdoMapped lely::canopen::BasicDriver::tpdo_mapped |
A mutator providing read/write access to TPDO-mapped objects in the remote object dictionary.
Definition at line 687 of file driver.hpp.
TpdoEventMutex& lely::canopen::BasicDriver::tpdo_event_mutex |
Definition at line 690 of file driver.hpp.