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