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

The Client-SDO queue. More...

#include <sdo.hpp>

Data Structures

class  DownloadRequest
 An SDO download request. More...
 
struct  Impl_
 The internal implementation of the Client-SDO queue. More...
 
class  UploadRequest
 An SDO upload request. More...
 

Public Types

using duration = ::std::chrono::milliseconds
 The type used to represent an SDO timeout duration.
 
using DownloadSignature = void(uint16_t idx, uint8_t subidx, ::std::error_code ec)
 The signature of the callback function invoked on completion of an SDO download request. More...
 
template<class T >
using UploadSignature = void(uint16_t idx, uint8_t subidx, ::std::error_code ec, T value)
 The signature of the callback function invoked on completion of an SDO upload request. More...
 

Public Member Functions

 Sdo ()
 Default-constructs an invalid Client-SDO queue.
 
 Sdo (CANNet *net, uint8_t id)
 Constructs a Client-SDO queue for a Client-SDO from the predefined connection set (the default SDO). More...
 
 Sdo (CANNet *net, CODev *dev, uint8_t num)
 Constructs a Client-SDO queue for a pre-configured Client-SDO. More...
 
 Sdo (COCSDO *sdo)
 Constructs a Client-SDO queue from an existing Client-SDO service. More...
 
 ~Sdo ()
 Destructs the Client-SDO queue. More...
 
 operator bool () const noexcept
 Checks whether *this is a valid Client-SDO queue.
 
template<class T >
typename ::std::enable_if< detail::IsCanopenType< T >::value >::type SubmitDownload (DownloadRequest< T > &req)
 Queues an SDO download request.
 
template<class T , class F , class U = typename ::std::decay<T>::type>
typename ::std::enable_if< detail::IsCanopenType< typename ::std::decay< U >::type >::value >::type SubmitDownload (uint16_t idx, uint8_t subidx, T &&value, aio::ExecutorBase &exec, F &&con, const duration &timeout)
 Queues an SDO download request. More...
 
template<class T >
typename ::std::enable_if< detail::IsCanopenType< T >::value, ::std::size_t >::type CancelDownload (DownloadRequest< T > &req, SdoErrc ac)
 Aborts an SDO download request. More...
 
template<class T >
typename ::std::enable_if< detail::IsCanopenType< T >::value >::type SubmitUpload (UploadRequest< T > &req)
 Queues an SDO upload request.
 
template<class T , class F >
typename ::std::enable_if< detail::IsCanopenType< T >::value >::type SubmitUpload (uint16_t idx, uint8_t subidx, aio::ExecutorBase &exec, F &&con, const duration &timeout)
 Queues an SDO upload request. More...
 
template<class T >
typename ::std::enable_if< detail::IsCanopenType< T >::value, ::std::size_t >::type CancelUpload (UploadRequest< T > &req, SdoErrc ac)
 Aborts an SDO upload request. More...
 
::std::size_t Cancel (SdoErrc ac)
 Aborts the ongoing and all pending SDO requests. More...
 
template<class T , class U = typename ::std::decay<T>::type>
typename ::std::enable_if< detail::IsCanopenType< U >::value, aio::Future<::std::error_code > >::type AsyncDownload (aio::LoopBase &loop, aio::ExecutorBase &exec, int16_t idx, uint8_t subidx, T &&value, const duration &timeout)
 Queues an asynchronous SDO download request and returns a future. More...
 
template<class T >
typename ::std::enable_if< detail::IsCanopenType< T >::value, aio::Future<::std::tuple<::std::error_code, T > > >::type AsyncUpload (aio::LoopBase &loop, aio::ExecutorBase &exec, int16_t idx, uint8_t subidx, const duration &timeout)
 Queues an asynchronous SDO upload request and returns a future. More...
 

Detailed Description

The Client-SDO queue.

Definition at line 48 of file sdo.hpp.

Member Typedef Documentation

◆ DownloadSignature

using lely::canopen::Sdo::DownloadSignature = void(uint16_t idx, uint8_t subidx, ::std::error_code ec)

The signature of the callback function invoked on completion of an SDO download request.

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
idxthe object index.
subidxthe object sub-index.
ecthe SDO abort code (0 on success).

Definition at line 128 of file sdo.hpp.

◆ UploadSignature

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

The signature of the callback function invoked on completion of an SDO upload request.

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
idxthe object index.
subidxthe object sub-index.
ecthe SDO abort code (0 on success).
valuethe value received from the SDO server.

Definition at line 193 of file sdo.hpp.

Constructor & Destructor Documentation

◆ Sdo() [1/3]

lely::canopen::Sdo::Sdo ( CANNet net,
uint8_t  id 
)

Constructs a Client-SDO queue for a Client-SDO from the predefined connection set (the default SDO).

In general, only a CANopen master is allowed to use the default SDO.

Parameters
neta pointer to a CAN network interface (from <lely/can/net.hpp>).
idthe node-ID of the SDO server (in the range [1..127]).

Definition at line 324 of file sdo.cpp.

◆ Sdo() [2/3]

lely::canopen::Sdo::Sdo ( CANNet net,
CODev dev,
uint8_t  num 
)

Constructs a Client-SDO queue for a pre-configured Client-SDO.

The SDO client parameter record MUST exist in the object dictionary (object 1280 to 12FF).

Parameters
neta pointer to a CAN network interface (from <lely/can/net.hpp>).
deva pointer to a CANopen device (from <lely/co/dev.hpp>).
numthe SDO number (in the range [1..128]).

Definition at line 326 of file sdo.cpp.

◆ Sdo() [3/3]

lely::canopen::Sdo::Sdo ( COCSDO sdo)
explicit

Constructs a Client-SDO queue from an existing Client-SDO service.

It is the responsibility of the caller to ensure that the SDO service remains available during the lifetime of the queue.

Parameters
sdoa pointer to a CANopen Client-SDO service (from <lely/co/csdo.hpp>).

Definition at line 329 of file sdo.cpp.

◆ ~Sdo()

lely::canopen::Sdo::~Sdo ( )
default

Destructs the Client-SDO queue.

Any ongoing or pending SDO requests are terminated with abort code SdoErrc::DATA_CTL.

Member Function Documentation

◆ SubmitDownload()

template<class T , class F , class U = typename ::std::decay<T>::type>
typename ::std::enable_if< detail::IsCanopenType<typename ::std::decay<U>::type>::value>::type lely::canopen::Sdo::SubmitDownload ( uint16_t  idx,
uint8_t  subidx,
T &&  value,
aio::ExecutorBase &  exec,
F &&  con,
const duration timeout 
)
inline

Queues an SDO download request.

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

Parameters
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.

Definition at line 317 of file sdo.hpp.

◆ CancelDownload()

template<class T >
typename ::std::enable_if<detail::IsCanopenType<T>::value, ::std::size_t>::type lely::canopen::Sdo::CancelDownload ( DownloadRequest< T > &  req,
SdoErrc  ac 
)
inline

Aborts an SDO download request.

Parameters
reqthe request to be aborted.
acthe SDO abort code in case of an ongoing request.

Definition at line 334 of file sdo.hpp.

◆ SubmitUpload()

template<class T , class F >
typename ::std::enable_if<detail::IsCanopenType<T>::value>::type lely::canopen::Sdo::SubmitUpload ( uint16_t  idx,
uint8_t  subidx,
aio::ExecutorBase &  exec,
F &&  con,
const duration timeout 
)
inline

Queues an SDO upload request.

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

Parameters
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.

Definition at line 361 of file sdo.hpp.

◆ CancelUpload()

template<class T >
typename ::std::enable_if<detail::IsCanopenType<T>::value, ::std::size_t>::type lely::canopen::Sdo::CancelUpload ( UploadRequest< T > &  req,
SdoErrc  ac 
)
inline

Aborts an SDO upload request.

Parameters
reqthe request to be aborted.
acthe SDO abort code in case of an ongoing request.

Definition at line 377 of file sdo.hpp.

◆ Cancel()

std::size_t lely::canopen::Sdo::Cancel ( SdoErrc  ac)

Aborts the ongoing and all pending SDO requests.

Parameters
acthe SDO abort code.

Definition at line 346 of file sdo.cpp.

◆ AsyncDownload()

template<class T , class U = typename ::std::decay<T>::type>
typename ::std::enable_if<detail::IsCanopenType<U>::value, aio::Future<::std::error_code> >::type lely::canopen::Sdo::AsyncDownload ( aio::LoopBase &  loop,
aio::ExecutorBase &  exec,
int16_t  idx,
uint8_t  subidx,
T &&  value,
const duration timeout 
)
inline

Queues an asynchronous SDO download request 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.
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.

Definition at line 407 of file sdo.hpp.

◆ AsyncUpload()

template<class T >
typename ::std::enable_if< detail::IsCanopenType<T>::value, aio::Future<::std::tuple<::std::error_code, T> > >::type lely::canopen::Sdo::AsyncUpload ( aio::LoopBase &  loop,
aio::ExecutorBase &  exec,
int16_t  idx,
uint8_t  subidx,
const duration timeout 
)
inline

Queues an asynchronous SDO upload request 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.
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.

Definition at line 435 of file sdo.hpp.


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