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

The base class for drivers for remote CANopen nodes. More...

#include <driver.hpp>

Inheritance diagram for lely::canopen::BasicDriver:
Collaboration diagram for lely::canopen::BasicDriver:

Public Member Functions

 BasicDriver (aio::LoopBase &loop, aio::ExecutorBase &exec, BasicMaster &master, uint8_t id)
 Creates a new driver for a remote CANopen node and registers it with the master. More...
 
aio::LoopBase GetLoop () const noexcept
 Returns the event loop used to create promises and futures.
 
aio::ExecutorBase GetExecutor () const noexcept final override
 Returns the executor used to execute event handlers for this driver, including SDO confirmation functions.
 
uint8_t netid () const noexcept final override
 Returns the network-ID.
 
uint8_t id () const noexcept final override
 Returns the node-ID.
 
void Error ()
 Indicates the occurrence of an error event on the remote node and triggers the error handling process. 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, ::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, ::std::error_code &ec)
 Equivalent to SubmitRead(uint16_t idx, uint8_t subidx, F&& con, const Sdo::duration& 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 Sdo::duration &timeout)
 Equivalent to SubmitRead(uint16_t idx, uint8_t subidx, 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 (uint16_t idx, uint8_t subidx, F &&con, const Sdo::duration &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, ::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, ::std::error_code &ec)
 Equivalent to SubmitWrite(uint16_t idx, uint8_t subidx, T&& value, F&& con, const Sdo::duration& 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 Sdo::duration &timeout)
 Equivalent to SubmitWrite(uint16_t idx, uint8_t subidx, T&& value, 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 (uint16_t idx, uint8_t subidx, T &&value, 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 (uint16_t idx, uint8_t subidx)
 Equivalent to AsyncRead(uint16_t idx, uint8_t subidx, const Sdo::duration& timeout), except that it uses the SDO timeout given by lely::canopen::BasicMaster::GetTimeout().
 
template<class T >
aio::Future<::std::tuple<::std::error_code, T > > AsyncRead (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 (uint16_t idx, uint8_t subidx, T &&value)
 Equivalent to AsyncWrite(uint16_t idx, uint8_t subidx, T&& value, const Sdo::duration& timeout), except that it uses the SDO timeout given by lely::canopen::BasicMaster::GetTimeout().
 
template<class T >
aio::Future<::std::error_code > AsyncWrite (uint16_t idx, uint8_t subidx, T &&value, const Sdo::duration &timeout)
 Queues an asynchronous write (SDO download) operation and returns a future. More...
 
template<class T >
RunRead (uint16_t idx, uint8_t subidx)
 Equivalent to RunRead(uint16_t idx, uint8_t subidx, ::std::error_code& ec), except that it throws lely::canopen::SdoError on error.
 
template<class T >
RunRead (uint16_t idx, uint8_t subidx, ::std::error_code &ec)
 Equivalent to RunRead(uint16_t idx, uint8_t subidx, const Sdo::duration& timeout, ::std::error_code& ec), except that it uses the SDO timeout given by lely::canopen::BasicMaster::GetTimeout().
 
template<class T >
RunRead (uint16_t idx, uint8_t subidx, const Sdo::duration &timeout)
 Equivalent to RunRead(uint16_t idx, uint8_t subidx, const Sdo::duration& timeout, ::std::error_code& ec), except that it throws lely::canopen::SdoError on error.
 
template<class T >
RunRead (uint16_t idx, uint8_t subidx, const Sdo::duration &timeout, ::std::error_code &ec)
 Queues an asynchronous read (SDO upload) operation and runs the event loop until the operation is complete. More...
 
template<class T >
void RunWrite (uint16_t idx, uint8_t subidx, T &&value)
 Equivalent to RunWrite(uint16_t idx, uint8_t subidx, T&& value, ::std::error_code& ec), except that it throws lely::canopen::SdoError on error.
 
template<class T >
void RunWrite (uint16_t idx, uint8_t subidx, T &&value, ::std::error_code &ec)
 Equivalent to RunWrite(uint16_t idx, uint8_t subidx, T&& value, const Sdo::duration& timeout, ::std::error_code& ec), except that it uses the SDO timeout given by lely::canopen::BasicMaster::GetTimeout().
 
template<class T >
void RunWrite (uint16_t idx, uint8_t subidx, T &&value, const Sdo::duration &timeout)
 Equivalent to RunWrite(uint16_t idx, uint8_t subidx, T&& value, const Sdo::duration& timeout, ::std::error_code& ec), except that it throws lely::canopen::SdoError on error.
 
template<class T >
void RunWrite (uint16_t idx, uint8_t subidx, T &&value, const Sdo::duration &timeout, ::std::error_code &ec)
 Queues an asynchronous write (SDO download) operation and runs the event loop until the operation is complete. More...
 
template<class F >
void Post (F &&f)
 Schedules the specified Callable object for execution by the executor for this driver. More...
 

Data Fields

BasicMastermaster
 A reference to the master with which this driver is registered.
 

Detailed Description

The base class for drivers for remote CANopen nodes.

Definition at line 298 of file driver.hpp.

Constructor & Destructor Documentation

◆ BasicDriver()

lely::canopen::BasicDriver::BasicDriver ( aio::LoopBase &  loop,
aio::ExecutorBase &  exec,
BasicMaster master,
uint8_t  id 
)

Creates a new driver for a remote CANopen node and registers it with the master.

Parameters
loopthe event loop used to create promises and futures.
execthe executor used to execute event handlers for this driver, including SDO confirmation functions. The executor SHOULD be based on loop.
mastera reference to a CANopen master.
idthe node-ID of the remote node (in the range [1..127]).
Exceptions
std::out_of_rangeif the node-ID is invalid or already registered.

Definition at line 51 of file driver.cpp.

Member Function Documentation

◆ Error()

void lely::canopen::BasicDriver::Error ( )
inline

Indicates the occurrence of an error event on the remote node and triggers the error handling process.

See also
BasicMaster::Error()

Definition at line 347 of file driver.hpp.

◆ SubmitRead()

template<class T , class F >
void lely::canopen::BasicDriver::SubmitRead ( uint16_t  idx,
uint8_t  subidx,
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 the remote object dictionary.

Parameters
idxthe object index.
subidxthe object sub-index.
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 408 of file driver.hpp.

◆ SubmitWrite()

template<class T , class F >
void lely::canopen::BasicDriver::SubmitWrite ( uint16_t  idx,
uint8_t  subidx,
T &&  value,
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 the remote object dictionary.

Parameters
idxthe object index.
subidxthe object sub-index.
valuethe value to be written.
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 477 of file driver.hpp.

◆ AsyncRead()

template<class T >
aio::Future<::std::tuple<::std::error_code, T> > lely::canopen::BasicDriver::AsyncRead ( uint16_t  idx,
uint8_t  subidx,
const Sdo::duration timeout 
)
inline

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

Parameters
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 514 of file driver.hpp.

◆ AsyncWrite()

template<class T >
aio::Future<::std::error_code> lely::canopen::BasicDriver::AsyncWrite ( 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
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 551 of file driver.hpp.

◆ RunRead()

template<class T >
T lely::canopen::BasicDriver::RunRead ( uint16_t  idx,
uint8_t  subidx,
const Sdo::duration timeout,
::std::error_code &  ec 
)
inline

Queues an asynchronous read (SDO upload) operation and runs the event loop until the operation is complete.

Parameters
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.
ecthe error code (0 on success). ec == SdoErrc::NO_SDO if no client-SDO is available.
Returns
the received value.

Definition at line 626 of file driver.hpp.

◆ RunWrite()

template<class T >
void lely::canopen::BasicDriver::RunWrite ( uint16_t  idx,
uint8_t  subidx,
T &&  value,
const Sdo::duration timeout,
::std::error_code &  ec 
)
inline

Queues an asynchronous write (SDO download) operation and runs the event loop until the operation is complete.

Parameters
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.
ecthe error code (0 on success). ec == SdoErrc::NO_SDO if no client-SDO is available.

Definition at line 697 of file driver.hpp.

◆ Post()

template<class F >
void lely::canopen::BasicDriver::Post ( F &&  f)
inline

Schedules the specified Callable object for execution by the executor for this driver.

See also
GetExecutor()

Definition at line 714 of file driver.hpp.


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