23 #ifndef LELY_CO_CSDO_HPP_ 24 #define LELY_CO_CSDO_HPP_ 27 #error "include <lely/co/csdo.h> for the C interface" 43 dnReq(
CODev& dev, co_unsigned16_t idx, co_unsigned8_t subidx,
const void* ptr,
50 dnReq(
CODev& dev, co_unsigned16_t idx, co_unsigned8_t subidx,
const void* ptr,
51 size_t n, F* f) noexcept {
52 return dnReq(dev, idx, subidx, ptr, n,
54 static_cast<void*>(f));
57 template <class T, typename c_mem_fn<co_csdo_dn_con_t*, T>::type M>
59 dnReq(
CODev& dev, co_unsigned16_t idx, co_unsigned8_t subidx,
const void* ptr,
60 size_t n, T* t) noexcept {
61 return dnReq(dev, idx, subidx, ptr, n,
63 static_cast<void*>(t));
66 template <co_
unsigned16_t N>
68 dnReq(
CODev& dev, co_unsigned16_t idx, co_unsigned8_t subidx,
73 template <co_
unsigned16_t N,
class F>
75 dnReq(
CODev& dev, co_unsigned16_t idx, co_unsigned8_t subidx,
76 const COVal<N>& val, F* f) noexcept {
77 return dnReq<N>(dev, idx, subidx, val,
79 static_cast<void*
>(f));
82 template <co_unsigned16_t N,
class T,
85 dnReq(
CODev& dev, co_unsigned16_t idx, co_unsigned8_t subidx,
86 const COVal<N>& val, T* t) noexcept {
87 return dnReq<N>(dev, idx, subidx, val,
89 static_cast<void*
>(t));
93 upReq(
const CODev& dev, co_unsigned16_t idx, co_unsigned8_t subidx,
98 template <class T, typename COCSDOUpCon<T>::type M>
100 upReq(
const CODev& dev, co_unsigned16_t idx, co_unsigned8_t subidx,
101 void* data) noexcept {
105 template <
class T,
class F>
107 upReq(
const CODev& dev, co_unsigned16_t idx, co_unsigned8_t subidx,
109 return upReq(dev, idx, subidx,
112 static_cast<void*>(f));
115 template <
class T,
class C,
118 upReq(
const CODev& dev, co_unsigned16_t idx, co_unsigned8_t subidx,
120 return upReq(dev, idx, subidx,
123 static_cast<void*>(obj));
137 return __co_csdo_alloc();
140 free(
void* ptr) noexcept {
145 init(pointer p,
CANNet* net,
CODev* dev, co_unsigned8_t num) noexcept {
146 return __co_csdo_init(p, net, dev, num);
150 fini(pointer p) noexcept {
163 getNet()
const noexcept {
167 getDev()
const noexcept {
171 getNum()
const noexcept {
176 getPar()
const noexcept {
181 getTimeout()
const noexcept {
186 setTimeout(
int timeout) noexcept {
191 getDnInd(
co_csdo_ind_t** pind,
void** pdata)
const noexcept {
202 setDnInd(F* f) noexcept {
206 template <class C, typename c_mem_fn<co_csdo_ind_t*, C>::type M>
208 setDnInd(C* obj) noexcept {
210 static_cast<void*>(obj));
214 getUpInd(
co_csdo_ind_t** pind,
void** pdata)
const noexcept {
225 setUpInd(F* f) noexcept {
229 template <class C, typename c_mem_fn<co_csdo_ind_t*, C>::type M>
231 setUpInd(C* obj) noexcept {
233 static_cast<void*>(obj));
237 isIdle()
const noexcept {
247 dnReq(co_unsigned16_t idx, co_unsigned8_t subidx,
const void* ptr,
size_t n,
254 dnReq(co_unsigned16_t idx, co_unsigned8_t subidx,
const void* ptr,
size_t n,
256 return dnReq(idx, subidx, ptr, n,
258 static_cast<void*>(f));
261 template <class T, typename c_mem_fn<co_csdo_dn_con_t*, T>::type M>
263 dnReq(co_unsigned16_t idx, co_unsigned8_t subidx,
const void* ptr,
size_t n,
265 return dnReq(idx, subidx, ptr, n,
267 static_cast<void*>(t));
270 template <co_
unsigned16_t N>
272 dnReq(co_unsigned16_t idx, co_unsigned8_t subidx,
const COVal<N>& val,
277 template <co_
unsigned16_t N,
class F>
279 dnReq(co_unsigned16_t idx, co_unsigned8_t subidx,
const COVal<N>& val,
281 return dnReq<N>(idx, subidx, val,
283 static_cast<void*
>(f));
286 template <co_unsigned16_t N,
class T,
289 dnReq(co_unsigned16_t idx, co_unsigned8_t subidx,
const COVal<N>& val,
291 return dnReq<N>(idx, subidx, val,
293 static_cast<void*
>(t));
298 void* data) noexcept {
302 template <class T, typename COCSDOUpCon<T>::type M>
304 upReq(co_unsigned16_t idx, co_unsigned8_t subidx,
void* data) noexcept {
308 template <
class T,
class F>
310 upReq(co_unsigned16_t idx, co_unsigned8_t subidx, F* f) noexcept {
311 return upReq(idx, subidx,
314 static_cast<void*>(f));
317 template <
class T,
class C,
318 typename c_mem_fn<typename COCSDOUpCon<T>::type, C>::type M>
320 upReq(co_unsigned16_t idx, co_unsigned8_t subidx, C* obj) noexcept {
325 static_cast<void*>(obj));
329 blkDnReq(co_unsigned16_t idx, co_unsigned8_t subidx,
const void* ptr,
336 blkDnReq(co_unsigned16_t idx, co_unsigned8_t subidx,
const void* ptr,
337 size_t n, F* f) noexcept {
338 return blkDnReq(idx, subidx, ptr, n,
340 static_cast<void*>(f));
343 template <class C, typename c_mem_fn<co_csdo_dn_con_t*, C>::type M>
345 blkDnReq(co_unsigned16_t idx, co_unsigned8_t subidx,
const void* ptr,
346 size_t n, C* obj) noexcept {
347 return blkDnReq(idx, subidx, ptr, n,
349 static_cast<void*>(obj));
353 blkUpReq(co_unsigned16_t idx, co_unsigned8_t subidx, co_unsigned8_t pst,
358 template <class T, typename COCSDOUpCon<T>::type M>
360 blkUpReq(co_unsigned16_t idx, co_unsigned8_t subidx, co_unsigned8_t pst,
361 void* data) noexcept {
366 template <
class T,
class F>
368 blkUpReq(co_unsigned16_t idx, co_unsigned8_t subidx, co_unsigned8_t pst,
374 static_cast<void*>(f));
377 template <
class T,
class C,
378 typename c_mem_fn<typename COCSDOUpCon<T>::type, C>::type M>
380 blkUpReq(co_unsigned16_t idx, co_unsigned8_t subidx, co_unsigned8_t pst,
386 static_cast<void*>(obj));
401 typedef void (*type)(
COCSDO* sdo, co_unsigned16_t idx, co_unsigned8_t subidx,
402 co_unsigned32_t ac, T val,
void* data);
406 function(
COCSDO* sdo, co_unsigned16_t idx, co_unsigned8_t subidx,
407 co_unsigned32_t ac,
const void* ptr,
size_t n,
void* data) noexcept {
409 if (!ptr || n <
sizeof(T)) {
411 }
else if (n >
sizeof(T)) {
417 return (*M)(sdo, idx, subidx, ac, val, data);
429 typedef void (*type)(
COCSDO* sdo, co_unsigned16_t idx, co_unsigned8_t subidx,
430 co_unsigned32_t ac,
const char* vs,
void* data);
434 function(
COCSDO* sdo, co_unsigned16_t idx, co_unsigned8_t subidx,
435 co_unsigned32_t ac,
const void* ptr,
size_t n,
void* data) noexcept {
438 return (*M)(sdo, idx, subidx, ac, val, data);
450 typedef void (*type)(
COCSDO* sdo, co_unsigned16_t idx, co_unsigned8_t subidx,
451 co_unsigned32_t ac, ::std::string vs,
void* data);
455 function(
COCSDO* sdo, co_unsigned16_t idx, co_unsigned8_t subidx,
456 co_unsigned32_t ac,
const void* ptr,
size_t n,
void* data) noexcept {
457 const char* vs =
static_cast<const char*
>(ptr);
458 if (!ac && vs && n) {
459 #if !__cpp_exceptions 462 return (*M)(sdo, idx, subidx, ac, ::std::string(vs, vs + n), data);
463 #if !__cpp_exceptions 469 return (*M)(sdo, idx, subidx, ac, ::std::string(), data);
481 typedef void (*type)(
COCSDO* sdo, co_unsigned16_t idx, co_unsigned8_t subidx,
482 co_unsigned32_t ac,
const uint_least8_t* os,
size_t n,
487 function(
COCSDO* sdo, co_unsigned16_t idx, co_unsigned8_t subidx,
488 co_unsigned32_t ac,
const void* ptr,
size_t n,
void* data) noexcept {
489 const uint_least8_t* os =
static_cast<const uint_least8_t*
>(ptr);
490 return (*M)(sdo, idx, subidx, ac, n ? os : 0, n, data);
502 typedef void (*type)(
COCSDO* sdo, co_unsigned16_t idx, co_unsigned8_t subidx,
503 co_unsigned32_t ac, ::std::vector<uint_least8_t> os,
508 function(
COCSDO* sdo, co_unsigned16_t idx, co_unsigned8_t subidx,
509 co_unsigned32_t ac,
const void* ptr,
size_t n,
void* data) noexcept {
510 const uint_least8_t* os =
static_cast<const uint_least8_t*
>(ptr);
511 if (!ac && os && n) {
512 #if !__cpp_exceptions 515 return (*M)(sdo, idx, subidx, ac,
516 ::std::vector<uint_least8_t>(os, os + n), data);
517 #if !__cpp_exceptions 523 return (*M)(sdo, idx, subidx, ac, ::std::vector<uint_least8_t>(), data);
535 typedef void (*type)(
COCSDO* sdo, co_unsigned16_t idx, co_unsigned8_t subidx,
536 co_unsigned32_t ac,
const char16_t* us,
void* data);
540 function(
COCSDO* sdo, co_unsigned16_t idx, co_unsigned8_t subidx,
541 co_unsigned32_t ac,
const void* ptr,
size_t n,
void* data) noexcept {
544 return (*M)(sdo, idx, subidx, ac, val, data);
556 typedef void (*type)(
COCSDO* sdo, co_unsigned16_t idx, co_unsigned8_t subidx,
557 co_unsigned32_t ac, ::std::basic_string<char16_t> us,
562 function(
COCSDO* sdo, co_unsigned16_t idx, co_unsigned8_t subidx,
563 co_unsigned32_t ac,
const void* ptr,
size_t n,
void* data) noexcept {
566 const char16_t* us = val;
567 if (!ac && us && n) {
568 #if !__cpp_exceptions 571 return (*M)(sdo, idx, subidx, ac,
572 ::std::basic_string<char16_t>(us, us + n), data);
573 #if !__cpp_exceptions 579 return (*M)(sdo, idx, subidx, ac, ::std::basic_string<char16_t>(), data);
591 typedef void (*type)(
COCSDO* sdo, co_unsigned16_t idx, co_unsigned8_t subidx,
592 co_unsigned32_t ac,
const void* dom,
size_t n,
597 function(
COCSDO* sdo, co_unsigned16_t idx, co_unsigned8_t subidx,
598 co_unsigned32_t ac,
const void* ptr,
size_t n,
void* data) noexcept {
599 return (*M)(sdo, idx, subidx, ac, n ? ptr : 0, n, data);
605 #endif // !LELY_CO_CSDO_HPP_ void co_csdo_set_timeout(co_csdo_t *sdo, int timeout)
Sets the timeout of a Client-SDO.
int co_dev_dn_req(co_dev_t *dev, co_unsigned16_t idx, co_unsigned8_t subidx, const void *ptr, size_t n, co_csdo_dn_con_t *con, void *data)
Submits a download request to a local device.
co_dev_t * co_csdo_get_dev(const co_csdo_t *sdo)
Returns a pointer to the CANopen device of a Client-SDO.
void co_csdo_get_up_ind(const co_csdo_t *sdo, co_csdo_ind_t **pind, void **pdata)
Retrieves the indication function used to notify the user of the progress of the current SDO upload r...
This header file is part of the CAN library; it contains the C++ interface of the CAN network interfa...
int co_dev_up_req(const co_dev_t *dev, co_unsigned16_t idx, co_unsigned8_t subidx, co_csdo_up_con_t *con, void *data)
Submits an upload request to a local device.
int co_csdo_blk_up_req(co_csdo_t *sdo, co_unsigned16_t idx, co_unsigned8_t subidx, co_unsigned8_t pst, co_csdo_up_con_t *con, void *data)
Submits a block upload request to a remote Server-SDO.
#define CO_SDO_AC_ERROR
SDO abort code: General error.
An opaque CANopen Client-SDO service type.
int co_csdo_is_idle(const co_csdo_t *sdo)
Returns 1 if the specified Client-SDO service is idle, and 0 if a transfer is ongoing.
The base class for a C++ interface to an incomplete C type.
An opaque CANopen device type.
int co_csdo_dn_val_req(co_csdo_t *sdo, co_unsigned16_t idx, co_unsigned8_t subidx, co_unsigned16_t type, const void *val, co_csdo_dn_con_t *con, void *data)
Submits a download request to a remote Server-SDO.
This header file is part of the CANopen library; it contains the Client-SDO declarations.
void co_csdo_dn_con_t(co_csdo_t *sdo, co_unsigned16_t idx, co_unsigned8_t subidx, co_unsigned32_t ac, void *data)
The type of a CANopen Client-SDO download confirmation callback function, invoked when a download req...
This header file is part of the CANopen library; it contains the C++ interface of the CANopen value d...
#define CO_SDO_AC_TYPE_LEN_HI
SDO abort code: Data type does not match, length of service parameter too high.
const struct co_sdo_par * co_csdo_get_par(const co_csdo_t *sdo)
Returns a pointer to the SDO parameter record of a Client-SDO.
void co_csdo_up_con_t(co_csdo_t *sdo, co_unsigned16_t idx, co_unsigned8_t subidx, co_unsigned32_t ac, const void *ptr, size_t n, void *data)
The type of a CANopen Client-SDO upload confirmation callback function, invoked when an upload reques...
co_unsigned8_t co_csdo_get_num(const co_csdo_t *sdo)
Returns the SDO number of a Client-SDO.
void co_csdo_abort_req(co_csdo_t *sdo, co_unsigned32_t ac)
Submits an abort transfer request to a remote Server-SDO.
int co_dev_dn_val_req(co_dev_t *dev, co_unsigned16_t idx, co_unsigned8_t subidx, co_unsigned16_t type, const void *val, co_csdo_dn_con_t *con, void *data)
Submits a download request to a local device.
void co_csdo_set_dn_ind(co_csdo_t *sdo, co_csdo_ind_t *ind, void *data)
Sets the indication function used to notify the user of the progress of the current SDO download requ...
co_unsigned32_t co_val_read_sdo(co_unsigned16_t type, void *val, const void *ptr, size_t n)
Reads a value of the specified data type from an SDO buffer.
void co_csdo_ind_t(const co_csdo_t *sdo, co_unsigned16_t idx, co_unsigned8_t subidx, size_t size, size_t nbyte, void *data)
The type of a CANopen Client-SDO request progress indication function, used to notify the user of the...
void co_csdo_get_dn_ind(const co_csdo_t *sdo, co_csdo_ind_t **pind, void **pdata)
Retrieves the indication function used to notify the user of the progress of the current SDO download...
int co_csdo_up_req(co_csdo_t *sdo, co_unsigned16_t idx, co_unsigned8_t subidx, co_csdo_up_con_t *con, void *data)
Submits an upload request to a remote Server-SDO.
A CANopen value containing an array of (16-bit) Unicode characters.
A CANopen Client-SDO upload confirmation callback wrapper that deserializes the received value on suc...
A CANopen value containing an array of visible characters.
#define CO_SDO_AC_NO_MEM
SDO abort code: Out of memory.
int co_csdo_dn_req(co_csdo_t *sdo, co_unsigned16_t idx, co_unsigned8_t subidx, const void *ptr, size_t n, co_csdo_dn_con_t *con, void *data)
Submits a download request to a remote Server-SDO.
can_net_t * co_csdo_get_net(const co_csdo_t *sdo)
Returns a pointer to the CAN network of a Client-SDO.
An opaque CAN network interface type.
int co_csdo_get_timeout(const co_csdo_t *sdo)
Returns the timeout (in milliseconds) of a Client-SDO.
void co_csdo_set_up_ind(co_csdo_t *sdo, co_csdo_ind_t *ind, void *data)
Sets the indication function used to notify the user of the progress of the current SDO upload reques...
#define CO_SDO_AC_TYPE_LEN_LO
SDO abort code: Data type does not match, length of service parameter too low.
int co_csdo_blk_dn_req(co_csdo_t *sdo, co_unsigned16_t idx, co_unsigned8_t subidx, const void *ptr, size_t n, co_csdo_dn_con_t *con, void *data)
Submits a block download request to a remote Server-SDO.
A class template supplying a uniform interface to certain attributes of C types.