Lely core libraries  2.2.5
rpdo.hpp
Go to the documentation of this file.
1 
23 #ifndef LELY_CO_RPDO_HPP_
24 #define LELY_CO_RPDO_HPP_
25 
26 #ifndef __cplusplus
27 #error "include <lely/co/rpdo.h> for the C interface"
28 #endif
29 
30 #include <lely/can/net.hpp>
31 #include <lely/co/rpdo.h>
32 
33 namespace lely {
34 
36 template <>
38  typedef __co_rpdo value_type;
39  typedef value_type& reference;
40  typedef const value_type& const_reference;
41  typedef value_type* pointer;
42  typedef const value_type* const_pointer;
43 
44  static void*
45  alloc() noexcept {
46  return __co_rpdo_alloc();
47  }
48  static void
49  free(void* ptr) noexcept {
50  __co_rpdo_free(ptr);
51  }
52 
53  static pointer
54  init(pointer p, CANNet* net, CODev* dev, co_unsigned16_t num) noexcept {
55  return __co_rpdo_init(p, net, dev, num);
56  }
57 
58  static void
59  fini(pointer p) noexcept {
60  __co_rpdo_fini(p);
61  }
62 };
63 
65 class CORPDO : public incomplete_c_type<__co_rpdo> {
67 
68  public:
69  CORPDO(CANNet* net, CODev* dev, co_unsigned16_t num)
70  : c_base(net, dev, num) {}
71 
72  CANNet*
73  getNet() const noexcept {
74  return co_rpdo_get_net(this);
75  }
76  CODev*
77  getDev() const noexcept {
78  return co_rpdo_get_dev(this);
79  }
80 
81  co_unsigned16_t
82  getNum() const noexcept {
83  return co_rpdo_get_num(this);
84  }
85 
86  const co_pdo_comm_par&
87  getCommPar() const noexcept {
88  return *co_rpdo_get_comm_par(this);
89  }
90 
91  const co_pdo_map_par&
92  getMapPar() const noexcept {
93  return *co_rpdo_get_map_par(this);
94  }
95 
96  void
97  getInd(co_rpdo_ind_t** pind, void** pdata) const noexcept {
98  co_rpdo_get_ind(this, pind, pdata);
99  }
100 
101  void
102  setInd(co_rpdo_ind_t* ind, void* data) noexcept {
103  co_rpdo_set_ind(this, ind, data);
104  }
105 
106  template <class F>
107  void
108  setInd(F* f) noexcept {
109  setInd(&c_obj_call<co_rpdo_ind_t*, F>::function, static_cast<void*>(f));
110  }
111 
112  template <class C, typename c_mem_fn<co_rpdo_ind_t*, C>::type M>
113  void
114  setInd(C* obj) noexcept {
116  static_cast<void*>(obj));
117  }
118 
119  void
120  getErr(co_rpdo_err_t** perr, void** pdata) const noexcept {
121  co_rpdo_get_err(this, perr, pdata);
122  }
123 
124  void
125  setErr(co_rpdo_err_t* err, void* data) noexcept {
126  co_rpdo_set_err(this, err, data);
127  }
128 
129  template <class F>
130  void
131  setErr(F* f) noexcept {
132  setErr(&c_obj_call<co_rpdo_err_t*, F>::function, static_cast<void*>(f));
133  }
134 
135  template <class C, typename c_mem_fn<co_rpdo_err_t*, C>::type M>
136  void
137  setErr(C* obj) noexcept {
139  static_cast<void*>(obj));
140  }
141 
142  int
143  sync(co_unsigned8_t cnt) noexcept {
144  return co_rpdo_sync(this, cnt);
145  }
146 
147  int
148  rtr() noexcept {
149  return co_rpdo_rtr(this);
150  }
151 
152  protected:
153  ~CORPDO() = default;
154 };
155 
156 } // namespace lely
157 
158 #endif // !LELY_CO_RPDO_HPP_
void co_rpdo_set_ind(co_rpdo_t *pdo, co_rpdo_ind_t *ind, void *data)
Sets the indication function invoked when a Receive-PDO error occurs.
Definition: rpdo.c:361
A PDO mapping parameter record.
Definition: pdo.h:69
const struct co_pdo_comm_par * co_rpdo_get_comm_par(const co_rpdo_t *pdo)
Returns a pointer to the PDO communication parameter record of a Receive-PDO.
Definition: rpdo.c:334
A CANopen Receive-PDO.
Definition: rpdo.c:41
void co_rpdo_err_t(co_rpdo_t *pdo, co_unsigned16_t eec, co_unsigned8_t er, void *data)
The type of a CANopen Receive-PDO error handling function, invoked in case of a timeout or length mis...
Definition: rpdo.h:56
void co_rpdo_get_ind(const co_rpdo_t *pdo, co_rpdo_ind_t **pind, void **pdata)
Retrieves the indication function invoked when a Receive-PDO error occurs.
Definition: rpdo.c:350
This header file is part of the CAN library; it contains the C++ interface of the CAN network interfa...
A PDO communication parameter record.
Definition: pdo.h:43
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_unsigned16_t co_rpdo_get_num(const co_rpdo_t *pdo)
Returns the PDO number of a Receive-PDO.
Definition: rpdo.c:326
void co_rpdo_get_err(const co_rpdo_t *pdo, co_rpdo_err_t **perr, void **pdata)
Retrieves the error handling function of a Receive-PDO service.
Definition: rpdo.c:370
int co_rpdo_rtr(co_rpdo_t *pdo)
Requests the transmission of a PDO.
Definition: rpdo.c:390
void co_rpdo_ind_t(co_rpdo_t *pdo, co_unsigned32_t ac, const void *ptr, size_t n, void *data)
The type of a CANopen Receive-PDO indication function, invoked when a PDO is received or an error occ...
Definition: rpdo.h:44
An opaque CANopen Receive-PDO service type.
Definition: rpdo.hpp:65
This header file is part of the CANopen library; it contains the Receive-PDO declarations.
int co_rpdo_sync(co_rpdo_t *pdo, co_unsigned8_t cnt)
Triggers the actuation of a received synchronous PDO.
Definition: rpdo.c:411
const struct co_pdo_map_par * co_rpdo_get_map_par(const co_rpdo_t *pdo)
Returns a pointer to the PDO mapping parameter record of a Receive-PDO.
Definition: rpdo.c:342
Definition: buf.hpp:32
An opaque CAN network interface type.
Definition: net.hpp:85
void co_rpdo_set_err(co_rpdo_t *pdo, co_rpdo_err_t *err, void *data)
Sets the error handling function of a Receive-PDO service.
Definition: rpdo.c:381
A class template supplying a uniform interface to certain attributes of C types.
Definition: c_type.hpp:120
can_net_t * co_rpdo_get_net(const co_rpdo_t *pdo)
Returns a pointer to the CAN network of a Receive-PDO.
Definition: rpdo.c:310
co_dev_t * co_rpdo_get_dev(const co_rpdo_t *pdo)
Returns a pointer to the CANopen device of a Receive-PDO.
Definition: rpdo.c:318