Lely core libraries  2.2.5
obj.hpp
Go to the documentation of this file.
1 
22 #ifndef LELY_CO_OBJ_HPP_
23 #define LELY_CO_OBJ_HPP_
24 
25 #ifndef __cplusplus
26 #error "include <lely/co/obj.h> for the C interface"
27 #endif
28 
29 #include <lely/util/c_call.hpp>
30 #include <lely/util/c_type.hpp>
31 #include <lely/co/obj.h>
32 #include <lely/co/sdo.h>
33 #include <lely/co/val.hpp>
34 
35 #include <vector>
36 
37 namespace lely {
38 
39 template <co_unsigned16_t>
40 struct COSubDnInd;
41 template <co_unsigned16_t>
42 struct COSubUpInd;
43 
45 template <>
47  typedef __co_obj value_type;
48  typedef value_type& reference;
49  typedef const value_type& const_reference;
50  typedef value_type* pointer;
51  typedef const value_type* const_pointer;
52 
53  static void*
54  alloc() noexcept {
55  return __co_obj_alloc();
56  }
57  static void
58  free(void* ptr) noexcept {
59  __co_obj_free(ptr);
60  }
61 
62  static pointer
63  init(pointer p, co_unsigned16_t idx) noexcept {
64  return __co_obj_init(p, idx);
65  }
66 
67  static void
68  fini(pointer p) noexcept {
69  __co_obj_fini(p);
70  }
71 };
72 
74 class COObj : public incomplete_c_type<__co_obj> {
76 
77  public:
78  explicit COObj(co_unsigned16_t idx) : c_base(idx) {}
79 
80  CODev*
81  getDev() const noexcept {
82  return co_obj_get_dev(this);
83  }
84 
85  co_unsigned16_t
86  getIdx() const noexcept {
87  return co_obj_get_idx(this);
88  }
89 
90  co_unsigned8_t
91  getSubidx(co_unsigned8_t maxsubidx, co_unsigned8_t* subidx) const noexcept {
92  return co_obj_get_subidx(this, maxsubidx, subidx);
93  }
94 
95  ::std::vector<co_unsigned8_t>
96  getSubidx() const {
97  std::vector<co_unsigned8_t> subidx(getSubidx(0, 0));
98  getSubidx(subidx.size(), subidx.data());
99  return subidx;
100  }
101 
102  int
103  insert(COSub* sub) noexcept {
104  return co_obj_insert_sub(this, sub);
105  }
106  int
107  remove(COSub* sub) noexcept {
108  return co_obj_remove_sub(this, sub);
109  }
110 
111  COSub*
112  find(co_unsigned8_t subidx) const noexcept {
113  return co_obj_find_sub(this, subidx);
114  }
115 
116  const char*
117  getName() const noexcept {
118  return co_obj_get_name(this);
119  }
120 
121  int
122  setName(const char* name) noexcept {
123  return co_obj_set_name(this, name);
124  }
125 
126  co_unsigned8_t
127  getCode() const noexcept {
128  return co_obj_get_code(this);
129  }
130 
131  int
132  setCode(co_unsigned8_t code) noexcept {
133  return co_obj_set_code(this, code);
134  }
135 
136  template <co_unsigned16_t N>
137  const COVal<N>&
138  getVal(co_unsigned8_t subidx) const noexcept {
139  return *reinterpret_cast<const COVal<N>*>(co_obj_get_val(this, subidx));
140  }
141 
142  ::std::size_t
143  setVal(co_unsigned8_t subidx, const void* ptr, ::std::size_t n) noexcept {
144  return co_obj_set_val(this, subidx, ptr, n);
145  }
146 
147  template <co_unsigned16_t N>
148  ::std::size_t
149  setVal(co_unsigned8_t subidx, const COVal<N>& val) noexcept {
150  return setVal(subidx, val.address(), val.size());
151  }
152 
153  template <class T>
154  ::std::size_t
155  setVal(co_unsigned8_t subidx, const T& val) noexcept {
156  return setVal<co_type_traits_T<T>::index>(subidx, val);
157  }
158 
159  void
160  setDnInd(co_sub_dn_ind_t* ind, void* data) noexcept {
161  co_obj_set_dn_ind(this, ind, data);
162  }
163 
164  template <class F>
165  void
166  setDnInd(F* f) noexcept {
167  setDnInd(&c_obj_call<co_sub_dn_ind_t*, F>::function, static_cast<void*>(f));
168  }
169 
170  template <class C, typename c_mem_fn<co_sub_dn_ind_t*, C>::type M>
171  void
172  setDnInd(C* obj) noexcept {
174  static_cast<void*>(obj));
175  }
176 
177  void
178  setUpInd(co_sub_up_ind_t* ind, void* data) noexcept {
179  co_obj_set_up_ind(this, ind, data);
180  }
181 
182  template <class F>
183  void
184  setUpInd(F* f) noexcept {
185  setUpInd(&c_obj_call<co_sub_up_ind_t*, F>::function, static_cast<void*>(f));
186  }
187 
188  template <class C, typename c_mem_fn<co_sub_up_ind_t*, C>::type M>
189  void
190  setUpInd(C* obj) noexcept {
192  static_cast<void*>(obj));
193  }
194 
195  protected:
196  ~COObj() = default;
197 };
198 
200 template <>
202  typedef __co_sub value_type;
203  typedef value_type& reference;
204  typedef const value_type& const_reference;
205  typedef value_type* pointer;
206  typedef const value_type* const_pointer;
207 
208  static void*
209  alloc() noexcept {
210  return __co_sub_alloc();
211  }
212  static void
213  free(void* ptr) noexcept {
214  __co_sub_free(ptr);
215  }
216 
217  static pointer
218  init(pointer p, co_unsigned8_t subidx, co_unsigned16_t type) noexcept {
219  return __co_sub_init(p, subidx, type);
220  }
221 
222  static void
223  fini(pointer p) noexcept {
224  __co_sub_fini(p);
225  }
226 };
227 
229 class COSub : public incomplete_c_type<__co_sub> {
231 
232  public:
233  COSub(co_unsigned8_t subidx, co_unsigned16_t type) : c_base(subidx, type) {}
234 
235  COObj*
236  getObj() const noexcept {
237  return co_sub_get_obj(this);
238  }
239 
240  co_unsigned8_t
241  getSubidx() const noexcept {
242  return co_sub_get_subidx(this);
243  }
244 
245  const char*
246  getName() const noexcept {
247  return co_sub_get_name(this);
248  }
249 
250  int
251  setName(const char* name) noexcept {
252  return co_sub_set_name(this, name);
253  }
254 
255  co_unsigned8_t
256  getType() const noexcept {
257  return co_sub_get_type(this);
258  }
259 
260  const void*
261  addressofMin() const noexcept {
262  return co_sub_addressof_min(this);
263  }
264 
265  ::std::size_t
266  sizeofMin() const noexcept {
267  return co_sub_sizeof_min(this);
268  }
269 
270  template <co_unsigned16_t N>
271  const COVal<N>&
272  getMin() const noexcept {
273  return *reinterpret_cast<const COVal<N>*>(co_sub_get_min(this));
274  }
275 
276  ::std::size_t
277  setMin(const void* ptr, ::std::size_t n) noexcept {
278  return co_sub_set_min(this, ptr, n);
279  }
280 
281  template <co_unsigned16_t N>
282  ::std::size_t
283  setMin(const COVal<N>& val) noexcept {
284  return setMin(val.address(), val.size());
285  }
286 
287  template <class T>
288  ::std::size_t
289  setMin(const T& val) noexcept {
290  return setMin<co_type_traits_T<T>::index>(val);
291  }
292 
293  const void*
294  addressofMax() const noexcept {
295  return co_sub_addressof_max(this);
296  }
297 
298  ::std::size_t
299  sizeofMax() const noexcept {
300  return co_sub_sizeof_max(this);
301  }
302 
303  template <co_unsigned16_t N>
304  const COVal<N>&
305  getMax() const noexcept {
306  return *reinterpret_cast<const COVal<N>*>(co_sub_get_max(this));
307  }
308 
309  ::std::size_t
310  setMax(const void* ptr, ::std::size_t n) noexcept {
311  return co_sub_set_max(this, ptr, n);
312  }
313 
314  template <co_unsigned16_t N>
315  ::std::size_t
316  setMax(const COVal<N>& val) noexcept {
317  return setMax(val.address(), val.size());
318  }
319 
320  template <class T>
321  ::std::size_t
322  setMax(const T& val) noexcept {
323  return setMax<co_type_traits_T<T>::index>(val);
324  }
325 
326  const void*
327  addressofDef() const noexcept {
328  return co_sub_addressof_def(this);
329  }
330 
331  ::std::size_t
332  sizeofDef() const noexcept {
333  return co_sub_sizeof_def(this);
334  }
335 
336  template <co_unsigned16_t N>
337  const COVal<N>&
338  getDef() const noexcept {
339  return *reinterpret_cast<const COVal<N>*>(co_sub_get_def(this));
340  }
341 
342  ::std::size_t
343  setDef(const void* ptr, ::std::size_t n) noexcept {
344  return co_sub_set_def(this, ptr, n);
345  }
346 
347  template <co_unsigned16_t N>
348  ::std::size_t
349  setDef(const COVal<N>& val) noexcept {
350  return setDef(val.address(), val.size());
351  }
352 
353  template <class T>
354  ::std::size_t
355  setDef(const T& val) noexcept {
356  return setDef<co_type_traits_T<T>::index>(val);
357  }
358 
359  const void*
360  addressofVal() const noexcept {
361  return co_sub_addressof_val(this);
362  }
363 
364  ::std::size_t
365  sizeofVal() const noexcept {
366  return co_sub_sizeof_val(this);
367  }
368 
369  template <co_unsigned16_t N>
370  const COVal<N>&
371  getVal() const noexcept {
372  return *reinterpret_cast<const COVal<N>*>(co_sub_get_val(this));
373  }
374 
375  ::std::size_t
376  setVal(const void* ptr, ::std::size_t n) noexcept {
377  return co_sub_set_val(this, ptr, n);
378  }
379 
380  template <co_unsigned16_t N>
381  ::std::size_t
382  setVal(const COVal<N>& val) noexcept {
383  return setVal(val.address(), val.size());
384  }
385 
386  template <class T>
387  ::std::size_t
388  setVal(const T& val) noexcept {
389  return setVal<co_type_traits_T<T>::index>(val);
390  }
391 
392  template <co_unsigned16_t N>
393  co_unsigned32_t
394  chkVal(const COVal<N>& val) const noexcept {
395  return co_sub_chk_val(this, N, &val);
396  }
397 
398  template <class T>
399  co_unsigned32_t
400  chkVal(const T& val) const noexcept {
401  return chkVal<co_type_traits_T<T>::index>(val);
402  }
403 
404  unsigned int
405  getAccess() const noexcept {
406  return co_sub_get_access(this);
407  }
408 
409  int
410  setAccess(unsigned int access) noexcept {
411  return co_sub_set_access(this, access);
412  }
413 
414  int
415  getPDOMapping() const noexcept {
416  return co_sub_get_pdo_mapping(this);
417  }
418 
419  void
420  setPDOMapping(unsigned int pdo_mapping) noexcept {
421  co_sub_set_pdo_mapping(this, pdo_mapping);
422  }
423 
424  unsigned int
425  getFlags() const noexcept {
426  return co_sub_get_flags(this);
427  }
428 
429  void
430  setFlags(unsigned int flags) noexcept {
431  co_sub_set_flags(this, flags);
432  }
433 
434  const char*
435  getUploadFile() const noexcept {
436  return co_sub_get_upload_file(this);
437  }
438 
439  int
440  setUploadFile(const char* filename) noexcept {
441  return co_sub_set_upload_file(this, filename);
442  }
443 
444  const char*
445  getDownloadFile() const noexcept {
446  return co_sub_get_download_file(this);
447  }
448 
449  int
450  setDownloadFile(const char* filename) noexcept {
451  return co_sub_set_download_file(this, filename);
452  }
453 
454  void
455  getDnInd(co_sub_dn_ind_t** pind, void** pdata) noexcept {
456  co_sub_get_dn_ind(this, pind, pdata);
457  }
458 
459  void
460  setDnInd(co_sub_dn_ind_t* ind, void* data) noexcept {
461  co_sub_set_dn_ind(this, ind, data);
462  }
463 
464  template <co_unsigned16_t N, typename COSubDnInd<N>::type M>
465  void
466  setDnInd(void* data) noexcept {
467  setDnInd(&COSubDnInd<N>::template function<M>, data);
468  }
469 
470  template <co_unsigned16_t N, class F>
471  void
472  setDnInd(F* f) noexcept {
473  setDnInd(&COSubDnInd<N>::template function<
474  &c_obj_call<typename COSubDnInd<N>::type, F>::function>,
475  static_cast<void*>(f));
476  }
477 
478  template <co_unsigned16_t N, class C,
479  typename c_mem_fn<typename COSubDnInd<N>::type, C>::type M>
480  void
481  setDnInd(C* obj) noexcept {
482  setDnInd(&COSubDnInd<N>::template function<
483  &c_mem_call<typename COSubDnInd<N>::type, C, M>::function>,
484  static_cast<void*>(obj));
485  }
486 
487  int
488  onDn(co_sdo_req& req, co_unsigned32_t* pac) noexcept {
489  return co_sub_on_dn(this, &req, pac);
490  }
491 
492  co_unsigned32_t
493  dnInd(co_sdo_req& req) noexcept {
494  return co_sub_dn_ind(this, &req);
495  }
496 
497  template <co_unsigned16_t N>
498  co_unsigned32_t
499  dnInd(const COVal<N>& val) noexcept {
500  return co_sub_dn_ind_val(this, N, &val);
501  }
502 
503  template <co_unsigned16_t N>
504  int
505  dn(COVal<N>& val) noexcept {
506  return co_sub_dn(this, &val);
507  }
508 
509  void
510  getUpInd(co_sub_up_ind_t** pind, void** pdata) noexcept {
511  co_sub_get_up_ind(this, pind, pdata);
512  }
513 
514  void
515  setUpInd(co_sub_up_ind_t* ind, void* data) noexcept {
516  co_sub_set_up_ind(this, ind, data);
517  }
518 
519  template <co_unsigned16_t N, typename COSubUpInd<N>::type M>
520  void
521  setUpInd(void* data) noexcept {
522  setUpInd(&COSubUpInd<N>::template function<M>, data);
523  }
524 
525  template <co_unsigned16_t N, class F>
526  void
527  setUpInd(F* f) noexcept {
528  setUpInd(&COSubUpInd<N>::template function<
529  &c_obj_call<typename COSubUpInd<N>::type, F>::function>,
530  static_cast<void*>(f));
531  }
532 
533  template <co_unsigned16_t N, class C,
534  typename c_mem_fn<typename COSubUpInd<N>::type, C>::type M>
535  void
536  setUpInd(C* obj) noexcept {
537  setUpInd(&COSubUpInd<N>::template function<
538  &c_mem_call<typename COSubUpInd<N>::type, C, M>::function>,
539  static_cast<void*>(obj));
540  }
541 
542  int
543  onUp(co_sdo_req& req, co_unsigned32_t* pac) const noexcept {
544  return co_sub_on_up(this, &req, pac);
545  }
546 
547  co_unsigned32_t
548  upInd(co_sdo_req& req) const noexcept {
549  return co_sub_up_ind(this, &req);
550  }
551 
552  protected:
553  ~COSub() = default;
554 };
555 
561 template <co_unsigned16_t N>
562 struct COSubDnInd {
563  typedef co_unsigned32_t (*type)(COSub* sub, COVal<N>& val, void* data);
564 
565  template <type M>
566  static co_unsigned32_t
567  function(COSub* sub, co_sdo_req* req, void* data) noexcept {
568  co_unsigned32_t ac = 0;
569 
570  COVal<N> val;
571  if (co_sdo_req_dn_val(req, N, &val, &ac) == -1) return ac;
572 
573  if ((ac = sub->chkVal(val))) return ac;
574 
575  if ((ac = (*M)(sub, val, data))) return ac;
576 
577  sub->dn(val);
578  return ac;
579  }
580 };
581 
587 template <co_unsigned16_t N>
588 struct COSubUpInd {
589  typedef co_unsigned32_t (*type)(const COSub* sub, COVal<N>& val, void* data);
590 
591  template <type M>
592  static co_unsigned32_t
593  function(const COSub* sub, co_sdo_req* req, void* data) noexcept {
594  co_unsigned32_t ac = 0;
595 
596  COVal<N> val = sub->getVal<N>();
597 
598  if ((ac = (*M)(sub, val, data))) return ac;
599 
600  co_sdo_req_up_val(req, N, &val, &ac);
601  return ac;
602  }
603 };
604 
605 } // namespace lely
606 
607 #endif // !LELY_CO_OBJ_HPP_
A CANopen CANopen sub-object upload indication callback wrapper.
Definition: obj.hpp:42
size_t co_sub_set_def(co_sub_t *sub, const void *ptr, size_t n)
Sets the default value of a CANopen sub-object.
Definition: obj.c:656
A CANopen SDO upload/download request.
Definition: sdo.h:178
int co_obj_insert_sub(co_obj_t *obj, co_sub_t *sub)
Inserts a sub-object into a CANopen object.
Definition: obj.c:182
const char * co_sub_get_upload_file(const co_sub_t *sub)
Returns a pointer to the value of the UploadFile attribute of a CANopen sub-object, or NULL if the attribute does not exist.
Definition: obj.c:803
void co_obj_set_dn_ind(co_obj_t *obj, co_sub_dn_ind_t *ind, void *data)
Sets the download indication function for a CANopen object.
Definition: obj.c:372
size_t co_sub_sizeof_max(const co_sub_t *sub)
Returns size (in bytes) of the upper limit of the value of a CANopen sub-object.
Definition: obj.c:613
co_unsigned32_t co_sub_dn_ind_val(co_sub_t *sub, co_unsigned16_t type, const void *val)
Invokes the download indication function of a CANopen sub-object, registered with co_sub_set_dn_ind()...
Definition: obj.c:932
int co_sub_on_up(const co_sub_t *sub, struct co_sdo_req *req, co_unsigned32_t *pac)
Implements the default behavior when an upload indication is received by a CANopen sub-object...
Definition: obj.c:992
A CANopen sub-object.
Definition: obj.h:54
size_t co_sub_set_max(co_sub_t *sub, const void *ptr, size_t n)
Sets the upper limit of a value of a CANopen sub-object.
Definition: obj.c:625
const void * co_sub_addressof_max(const co_sub_t *sub)
Returns the address of the upper limit of the value of a CANopen sub-object.
Definition: obj.c:607
int co_sub_set_name(co_sub_t *sub, const char *name)
Sets the name of a CANopen sub-object.
Definition: obj.c:546
size_t co_sub_sizeof_def(const co_sub_t *sub)
Returns size (in bytes) of the default value of a CANopen sub-object.
Definition: obj.c:644
int co_obj_set_code(co_obj_t *obj, co_unsigned8_t code)
Sets the code (type) of a CANopen object.
Definition: obj.c:294
void co_sub_set_flags(co_sub_t *sub, unsigned int flags)
Sets the object flags of a CANopen sub-object.
Definition: obj.c:793
int co_sub_on_dn(co_sub_t *sub, struct co_sdo_req *req, co_unsigned32_t *pac)
Implements the default behavior when a download indication is received by a CANopen sub-object...
Definition: obj.c:879
const void * co_sub_get_min(const co_sub_t *sub)
Returns a pointer to the lower limit of the value of a CANopen sub-object.
Definition: obj.c:592
int co_sdo_req_up_val(struct co_sdo_req *req, co_unsigned16_t type, const void *val, co_unsigned32_t *pac)
Writes the specified value to a buffer and constructs a CANopen SDO upload request.
Definition: sdo.c:280
int co_sub_set_upload_file(co_sub_t *sub, const char *filename)
Sets the value of the UploadFile attribute of a CANopen sub-object.
Definition: obj.c:815
const void * co_sub_get_def(const co_sub_t *sub)
Returns a pointer to the default value of a CANopen sub-object.
Definition: obj.c:650
co_unsigned32_t co_sub_chk_val(const co_sub_t *sub, co_unsigned16_t type, const void *val)
Checks if the specifed value would be a valid value for a CANopen sub-object.
Definition: obj.c:719
The base class for a C++ interface to an incomplete C type.
Definition: c_type.hpp:249
An opaque CANopen device type.
Definition: dev.hpp:77
co_unsigned8_t co_obj_get_code(const co_obj_t *obj)
Returns the object code of a CANopen object.
Definition: obj.c:286
This header file is part of the CANopen library; it contains the Service Data Object (SDO) declaratio...
int co_sub_get_pdo_mapping(const co_sub_t *sub)
Returns 1 if it is possible to map the specified CANopen sub-object into a PDO, and 0 if not...
Definition: obj.c:769
This header file is part of the CANopen library; it contains the C++ interface of the CANopen value d...
const void * co_sub_addressof_min(const co_sub_t *sub)
Returns the address of the lower limit of the value of a CANopen sub-object.
Definition: obj.c:580
int co_sub_set_download_file(co_sub_t *sub, const char *filename)
Sets the value of the DownloadFile attribute of a CANopen sub-object.
Definition: obj.c:842
const void * co_sub_addressof_def(const co_sub_t *sub)
Returns the address of the default value of a CANopen sub-object.
Definition: obj.c:638
unsigned int co_sub_get_access(const co_sub_t *sub)
Returns the access type of a CANopen sub-object.
Definition: obj.c:745
int co_obj_remove_sub(co_obj_t *obj, co_sub_t *sub)
Removes a sub-object from a CANopen object.
Definition: obj.c:205
void co_sub_set_up_ind(co_sub_t *sub, co_sub_up_ind_t *ind, void *data)
Sets the upload indication function for a CANopen sub-object.
Definition: obj.c:981
An opaque CANopen object type.
Definition: obj.hpp:74
void co_obj_set_up_ind(co_obj_t *obj, co_sub_up_ind_t *ind, void *data)
Sets the upload indication function for a CANopen object.
Definition: obj.c:382
size_t co_sub_set_min(co_sub_t *sub, const void *ptr, size_t n)
Sets the lower limit of a value of a CANopen sub-object.
Definition: obj.c:598
This header file is part of the utilities library; it contains the C to C++ interface declarations...
size_t co_sub_sizeof_min(const co_sub_t *sub)
Returns size (in bytes) of the lower limit of the value of a CANopen sub-object.
Definition: obj.c:586
const void * co_sub_get_val(const co_sub_t *sub)
Returns a pointer to the current value of a CANopen sub-object.
Definition: obj.c:679
void co_sub_set_pdo_mapping(co_sub_t *sub, int pdo_mapping)
Enables or disables PDO mapping a CANopen sub-object.
Definition: obj.c:777
size_t co_obj_set_val(co_obj_t *obj, co_unsigned8_t subidx, const void *ptr, size_t n)
Sets the current value of a CANopen sub-object.
Definition: obj.c:330
An opaque CANopen sub-object type.
Definition: obj.hpp:229
co_unsigned32_t co_sub_up_ind(const co_sub_t *sub, struct co_sdo_req *req)
Invokes the upload indication function of a CANopen sub-object, registered with co_sub_set_up_ind().
Definition: obj.c:1019
co_dev_t * co_obj_get_dev(const co_obj_t *obj)
Returns a pointer to the CANopen device containing the specified object.
Definition: obj.c:146
const char * co_sub_get_download_file(const co_sub_t *sub)
Returns a pointer to the value of the DownloadFile attribute of a CANopen sub-object, or NULL if the attribute does not exist.
Definition: obj.c:830
int co_sub_dn(co_sub_t *sub, void *val)
Downloads (moves) a value into a CANopen sub-object if the refuse-write-on-download flag (CO_OBJ_FLAG...
Definition: obj.c:954
void co_sub_get_dn_ind(const co_sub_t *sub, co_sub_dn_ind_t **pind, void **pdata)
Retrieves the download indication function for a CANopen sub-object.
Definition: obj.c:859
unsigned int co_sub_get_flags(const co_sub_t *sub)
Returns the object flags of a CANopen sub-object.
Definition: obj.c:785
co_unsigned8_t co_obj_get_subidx(const co_obj_t *obj, co_unsigned8_t maxsubidx, co_unsigned8_t *subidx)
Retrieves a list of sub-indices in a CANopen object.
Definition: obj.c:162
size_t co_sub_set_val(co_sub_t *sub, const void *ptr, size_t n)
Sets the current value of a CANopen sub-object.
Definition: obj.c:685
co_obj_t * co_sub_get_obj(const co_sub_t *sub)
Returns the a pointer to the CANopen object containing the specified sub-object.
Definition: obj.c:520
const void * co_sub_addressof_val(const co_sub_t *sub)
Returns the address of the current value of a CANopen sub-object.
Definition: obj.c:667
int co_sub_set_access(co_sub_t *sub, unsigned int access)
Sets the access type of a CANopen sub-object.
Definition: obj.c:753
int co_sdo_req_dn_val(struct co_sdo_req *req, co_unsigned16_t type, void *val, co_unsigned32_t *pac)
Copies the next segment of the specified CANopen SDO download request to the internal buffer and...
Definition: sdo.c:165
const void * co_sub_get_max(const co_sub_t *sub)
Returns a pointer to the upper limit of the value of a CANopen sub-object.
Definition: obj.c:619
int co_obj_set_name(co_obj_t *obj, const char *name)
Sets the name of a CANopen object.
Definition: obj.c:262
A CANopen CANopen sub-object download indication callback wrapper.
Definition: obj.hpp:40
co_unsigned8_t co_sub_get_subidx(const co_sub_t *sub)
Returns the sub-index of a CANopen sub-object.
Definition: obj.c:528
const void * co_obj_get_val(const co_obj_t *obj, co_unsigned8_t subidx)
Returns a pointer to the current value of a CANopen sub-object.
Definition: obj.c:323
const char * co_obj_get_name(const co_obj_t *obj)
Returns the name of a CANopen object.
Definition: obj.c:254
Definition: buf.hpp:32
size_t co_sub_sizeof_val(const co_sub_t *sub)
Returns size (in bytes) of the current value of a CANopen sub-object.
Definition: obj.c:673
co_unsigned16_t co_sub_get_type(const co_sub_t *sub)
Returns the data type of a CANopen sub-object.
Definition: obj.c:570
co_sub_t * co_obj_find_sub(const co_obj_t *obj, co_unsigned8_t subidx)
Finds a sub-object in a CANopen object.
Definition: obj.c:225
co_unsigned32_t co_sub_dn_ind(co_sub_t *sub, struct co_sdo_req *req)
Invokes the download indication function of a CANopen sub-object, registered with co_sub_set_dn_ind()...
Definition: obj.c:916
co_unsigned16_t co_obj_get_idx(const co_obj_t *obj)
Returns the index of a CANopen object.
Definition: obj.c:154
void co_sub_set_dn_ind(co_sub_t *sub, co_sub_dn_ind_t *ind, void *data)
Sets the download indication function for a CANopen sub-object.
Definition: obj.c:870
const char * co_sub_get_name(const co_sub_t *sub)
Returns the name of a CANopen sub-object.
Definition: obj.c:538
A CANopen object.
Definition: obj.h:32
This header file is part of the CANopen library; it contains the object dictionary declarations...
This header file is part of the utilities library; it contains the C callback wrapper declarations...
co_unsigned32_t co_sub_up_ind_t(const co_sub_t *sub, struct co_sdo_req *req, void *data)
The type of a CANopen sub-object upload indication function, invoked by an SDO upload request or Tran...
Definition: obj.h:151
A CANopen value.
Definition: val.hpp:42
void co_sub_get_up_ind(const co_sub_t *sub, co_sub_up_ind_t **pind, void **pdata)
Retrieves the upload indication function for a CANopen sub-object.
Definition: obj.c:970
A class template supplying a uniform interface to certain attributes of C types.
Definition: c_type.hpp:120
co_unsigned32_t co_sub_dn_ind_t(co_sub_t *sub, struct co_sdo_req *req, void *data)
The type of a CANopen sub-object download indication function, invoked by an SDO download request or ...
Definition: obj.h:136