Lely core libraries  1.9.2
wtm.hpp
Go to the documentation of this file.
1 
23 #ifndef LELY_CO_WTM_HPP_
24 #define LELY_CO_WTM_HPP_
25 
26 #ifndef __cplusplus
27 #error "include <lely/co/wtm.h> for the C interface"
28 #endif
29 
30 #include <lely/util/c_call.hpp>
31 #include <lely/util/c_type.hpp>
32 
33 namespace lely {
34 class COWTM;
35 }
38 
39 #include <lely/co/wtm.h>
40 
41 namespace lely {
42 
44 template <>
46  typedef __co_wtm value_type;
47  typedef value_type& reference;
48  typedef const value_type& const_reference;
49  typedef value_type* pointer;
50  typedef const value_type* const_pointer;
51 
52  static void*
53  alloc() noexcept {
54  return __co_wtm_alloc();
55  }
56  static void
57  free(void* ptr) noexcept {
58  __co_wtm_free(ptr);
59  }
60 
61  static pointer
62  init(pointer p) noexcept {
63  return __co_wtm_init(p);
64  }
65  static void
66  fini(pointer p) noexcept {
67  __co_wtm_fini(p);
68  }
69 };
70 
72 class COWTM : public incomplete_c_type<__co_wtm> {
74 
75  public:
76  COWTM() : c_base() {}
77 
78  uint8_t
79  getNIF() const noexcept {
80  return co_wtm_get_nif(this);
81  }
82 
83  int
84  setNIF(uint8_t nif = 1) noexcept {
85  return co_wtm_set_nif(this, nif);
86  }
87 
88  int
89  setDiagCAN(uint8_t nif, uint8_t st = 0xf, uint8_t err = 0xf,
90  uint8_t load = 0xff, uint16_t ec = 0xffff, uint16_t foc = 0xffff,
91  uint16_t coc = 0xffff) noexcept {
92  return co_wtm_set_diag_can(this, nif, st, err, load, ec, foc, coc);
93  }
94 
95  int
96  setDiagWTM(uint8_t quality = 0xff) noexcept {
97  return co_wtm_set_diag_wtm(this, quality);
98  }
99 
100  void
101  getDiagCANCon(co_wtm_diag_can_con_t** pfunc, void** pdata) const noexcept {
102  co_wtm_get_diag_can_con(this, pfunc, pdata);
103  }
104 
105  void
106  setDiagCANCon(co_wtm_diag_can_con_t* func, void* data) noexcept {
107  co_wtm_set_diag_can_con(this, func, data);
108  }
109 
110  template <class F>
111  void
112  setDiagCANCon(F* f) noexcept {
114  static_cast<void*>(f));
115  }
116 
117  template <class C, typename c_mem_fn<co_wtm_diag_can_con_t*, C>::type M>
118  void
119  setDiagCANCon(C* obj) noexcept {
121  static_cast<void*>(obj));
122  }
123 
124  void
125  getDiagWTMCon(co_wtm_diag_wtm_con_t** pfunc, void** pdata) const noexcept {
126  co_wtm_get_diag_wtm_con(this, pfunc, pdata);
127  }
128 
129  void
130  setDiagWTMCon(co_wtm_diag_wtm_con_t* func, void* data) noexcept {
131  co_wtm_set_diag_wtm_con(this, func, data);
132  }
133 
134  template <class F>
135  void
136  setDiagWTMCon(F* f) noexcept {
138  static_cast<void*>(f));
139  }
140 
141  template <class C, typename c_mem_fn<co_wtm_diag_wtm_con_t*, C>::type M>
142  void
143  setDiagWTMCon(C* obj) noexcept {
145  static_cast<void*>(obj));
146  }
147 
148  void
149  getDiagCANInd(co_wtm_diag_can_ind_t** pfunc, void** pdata) const noexcept {
150  co_wtm_get_diag_can_ind(this, pfunc, pdata);
151  }
152 
153  void
154  setDiagCANInd(co_wtm_diag_can_ind_t* func, void* data) noexcept {
155  co_wtm_set_diag_can_ind(this, func, data);
156  }
157 
158  template <class F>
159  void
160  setDiagCANInd(F* f) noexcept {
162  static_cast<void*>(f));
163  }
164 
165  template <class C, typename c_mem_fn<co_wtm_diag_can_ind_t*, C>::type M>
166  void
167  setDiagCANInd(C* obj) noexcept {
169  static_cast<void*>(obj));
170  }
171 
172  void
173  getDiagWTMInd(co_wtm_diag_wtm_ind_t** pfunc, void** pdata) const noexcept {
174  co_wtm_get_diag_wtm_ind(this, pfunc, pdata);
175  }
176 
177  void
178  setDiagWTMInd(co_wtm_diag_wtm_ind_t* func, void* data) noexcept {
179  co_wtm_set_diag_wtm_ind(this, func, data);
180  }
181 
182  template <class F>
183  void
184  setDiagWTMInd(F* f) noexcept {
186  static_cast<void*>(f));
187  }
188 
189  template <class C, typename c_mem_fn<co_wtm_diag_wtm_ind_t*, C>::type M>
190  void
191  setDiagWTMInd(C* obj) noexcept {
193  static_cast<void*>(obj));
194  }
195 
196  void
197  getDiagACInd(co_wtm_diag_ac_ind_t** pfunc, void** pdata) const noexcept {
198  co_wtm_get_diag_ac_ind(this, pfunc, pdata);
199  }
200 
201  void
202  setDiagACInd(co_wtm_diag_ac_ind_t* func, void* data) noexcept {
203  co_wtm_set_diag_ac_ind(this, func, data);
204  }
205 
206  template <class F>
207  void
208  setDiagACInd(F* f) noexcept {
210  static_cast<void*>(f));
211  }
212 
213  template <class C, typename c_mem_fn<co_wtm_diag_ac_ind_t*, C>::type M>
214  void
215  setDiagACInd(C* obj) noexcept {
217  static_cast<void*>(obj));
218  }
219 
220  void
221  recv(const void* buf, size_t nbytes) noexcept {
222  co_wtm_recv(this, buf, nbytes);
223  }
224 
225  void
226  getRecvFunc(co_wtm_recv_func_t** pfunc, void** pdata) const noexcept {
227  co_wtm_get_recv_func(this, pfunc, pdata);
228  }
229 
230  void
231  setRecvFunc(co_wtm_recv_func_t* func, void* data) noexcept {
232  co_wtm_set_recv_func(this, func, data);
233  }
234 
235  template <class F>
236  void
237  setRecvFunc(F* f) noexcept {
239  static_cast<void*>(f));
240  }
241 
242  template <class C, typename c_mem_fn<co_wtm_recv_func_t*, C>::type M>
243  void
244  setRecvFunc(C* obj) noexcept {
246  static_cast<void*>(obj));
247  }
248 
249  int
250  getTime(uint8_t nif, timespec* tp) const noexcept {
251  return co_wtm_get_time(this, nif, tp);
252  }
253 
254  int
255  setTime(uint8_t nif, const timespec& tp) noexcept {
256  return co_wtm_set_time(this, nif, &tp);
257  }
258 
259  int
260  send(uint8_t nif, const can_msg& msg) noexcept {
261  return co_wtm_send(this, nif, &msg);
262  }
263 
264  int
265  sendAlive() noexcept {
266  return co_wtm_send_alive(this);
267  }
268 
269  int
270  sendDiagCANReq(uint8_t nif) noexcept {
271  return co_wtm_send_diag_can_req(this, nif);
272  }
273 
274  int
275  sendDiagWTMReq(uint8_t nif) noexcept {
276  return co_wtm_send_diag_wtm_req(this, nif);
277  }
278 
279  int
280  sendDiagCANRst(uint8_t nif) noexcept {
281  return co_wtm_send_diag_can_rst(this, nif);
282  }
283 
284  int
285  sendDiagWTMRst(uint8_t nif) noexcept {
286  return co_wtm_send_diag_wtm_rst(this, nif);
287  }
288 
289  int
290  sendDiagAC(uint32_t ac) noexcept {
291  return co_wtm_send_diag_ac(this, ac);
292  }
293 
294  int
295  flush() noexcept {
296  return co_wtm_flush(this);
297  }
298 
299  void
300  getSendFunc(co_wtm_send_func_t** pfunc, void** pdata) const noexcept {
301  co_wtm_get_send_func(this, pfunc, pdata);
302  }
303 
304  void
305  setSendFunc(co_wtm_send_func_t* func, void* data) noexcept {
306  co_wtm_set_send_func(this, func, data);
307  }
308 
309  template <class F>
310  void
311  setSendFunc(F* f) noexcept {
313  static_cast<void*>(f));
314  }
315 
316  template <class C, typename c_mem_fn<co_wtm_send_func_t*, C>::type M>
317  void
318  setSendFunc(C* obj) noexcept {
320  static_cast<void*>(obj));
321  }
322 
323  protected:
324  ~COWTM() {}
325 };
326 
327 } // namespace lely
328 
329 #endif // !LELY_CO_WTM_HPP_
lely::COWTM co_wtm_t
An opaque CANopen Wireless Transmission Media (WTM) interface type.
Definition: wtm.hpp:37
A CAN or CAN FD format frame.
Definition: msg.h:88
int co_wtm_send_diag_wtm_rst(co_wtm_t *wtm, uint8_t nif)
Sends a WTM communication quality reset message.
Definition: wtm.c:985
uint8_t co_wtm_get_nif(const co_wtm_t *wtm)
Returns the interface indicator of a CANopen WTM interface.
Definition: wtm.c:321
int co_wtm_send_diag_can_rst(co_wtm_t *wtm, uint8_t nif)
Sends a CAN communication quality reset message.
Definition: wtm.c:967
void co_wtm_get_diag_wtm_con(const co_wtm_t *wtm, co_wtm_diag_wtm_con_t **pcon, void **pdata)
Retrieves the confirmation function invoked when a WTM communication quality response is received by ...
Definition: wtm.c:430
int co_wtm_send_diag_ac(co_wtm_t *wtm, uint32_t ac)
Sends a diagnostic abort message from a CANopen WTM interface.
Definition: wtm.c:1003
void co_wtm_set_diag_can_con(co_wtm_t *wtm, co_wtm_diag_can_con_t *con, void *data)
Sets the confirmation function invoked when a CAN communication quality response is received by a CAN...
Definition: wtm.c:421
void co_wtm_set_send_func(co_wtm_t *wtm, co_wtm_send_func_t *func, void *data)
Sets the callback function used to send byte streams from a CANopen WTM interface.
Definition: wtm.c:1060
This header file is part of the CANopen library; it contains the Wireless Transmission Media (WTM) de...
void co_wtm_get_diag_can_con(const co_wtm_t *wtm, co_wtm_diag_can_con_t **pcon, void **pdata)
Retrieves the confirmation function invoked when a CAN communication quality response is received by ...
Definition: wtm.c:409
The base class for a C++ interface to an incomplete C type.
Definition: c_type.hpp:245
int co_wtm_set_diag_wtm(co_wtm_t *wtm, uint8_t quality)
Sets the diagnostic parameters of a WTM interface.
Definition: wtm.c:394
int co_wtm_flush(co_wtm_t *wtm)
Flushes the current send buffer of a CANopen WTM interface.
Definition: wtm.c:1018
void co_wtm_get_diag_can_ind(const co_wtm_t *wtm, co_wtm_diag_can_ind_t **pcon, void **pdata)
Retrieves the indication function invoked when a CAN communication quality reset message is received ...
Definition: wtm.c:451
void co_wtm_recv(co_wtm_t *wtm, const void *buf, size_t nbytes)
Receives and processes a byte stream with a CANopen WTM interface.
Definition: wtm.c:514
int co_wtm_set_time(co_wtm_t *wtm, uint8_t nif, const struct timespec *tp)
Sets the current time of a CANopen WTM interface.
Definition: wtm.c:802
void co_wtm_set_recv_func(co_wtm_t *wtm, co_wtm_recv_func_t *func, void *data)
Sets the callback function invoked when a CAN frame is received by a CANopen WTM interface.
Definition: wtm.c:777
void co_wtm_diag_wtm_ind_t(co_wtm_t *wtm, void *data)
The type of a CANopen WTM diagnostic indication function, invoked when a WTM communication quality re...
Definition: wtm.h:178
void co_wtm_diag_ac_ind_t(co_wtm_t *wtm, uint32_t ac, void *data)
The type of a CANopen WTM diagnostic indication function, invoked when an abort code is generated or ...
Definition: wtm.h:188
int co_wtm_get_time(const co_wtm_t *wtm, uint8_t nif, struct timespec *tp)
Retrieves the current time of a CANopen WTM interface.
Definition: wtm.c:786
int co_wtm_set_nif(co_wtm_t *wtm, uint8_t nif)
Sets the interface indicator of a CANopen WTM interface.
Definition: wtm.c:329
void co_wtm_diag_can_ind_t(co_wtm_t *wtm, uint8_t nif, void *data)
The type of a CANopen WTM diagnostic indication function, invoked when a CAN communication quality re...
Definition: wtm.h:169
This header file is part of the utilities library; it contains the C to C++ interface declarations...
void co_wtm_set_diag_ac_ind(co_wtm_t *wtm, co_wtm_diag_ac_ind_t *ind, void *data)
Sets the indication function invoked when an abort code is generated or received by a CANopen WTM int...
Definition: wtm.c:505
void co_wtm_get_diag_wtm_ind(const co_wtm_t *wtm, co_wtm_diag_wtm_ind_t **pcon, void **pdata)
Retrieves the indication function invoked when a WTM communication quality reset message is received ...
Definition: wtm.c:472
int co_wtm_send_diag_wtm_req(co_wtm_t *wtm, uint8_t nif)
Sends a WTM communication quality request.
Definition: wtm.c:949
void co_wtm_get_send_func(const co_wtm_t *wtm, co_wtm_send_func_t **pfunc, void **pdata)
Retrieves the callback function used to send byte streams from a CANopen WTM interface.
Definition: wtm.c:1048
void co_wtm_diag_wtm_con_t(co_wtm_t *wtm, uint8_t nif, uint8_t quality, void *data)
The type of a CANopen WTM diagnostic confirmation function, invoked when a WTM communication quality ...
Definition: wtm.h:158
void co_wtm_set_diag_wtm_con(co_wtm_t *wtm, co_wtm_diag_wtm_con_t *con, void *data)
Sets the confirmation function invoked when a WTM communication quality response is received by a CAN...
Definition: wtm.c:442
A CANopen Wireless Transmission Media (WTM) interface.
Definition: wtm.c:87
void co_wtm_get_recv_func(const co_wtm_t *wtm, co_wtm_recv_func_t **pfunc, void **pdata)
Retrieves the callback function invoked when a CAN frame is received by a CANopen WTM interface...
Definition: wtm.c:765
int co_wtm_send_alive(co_wtm_t *wtm)
Sends a keep-alive message from a CANopen WTM interface.
Definition: wtm.c:917
An opaque CANopen Wireless Transmission Media (WTM) interface type.
Definition: wtm.hpp:72
int co_wtm_recv_func_t(co_wtm_t *wtm, uint8_t nif, const struct timespec *tp, const struct can_msg *msg, void *data)
The type of a CANopen WTM receive callback function, invoked when a CAN frame is received.
Definition: wtm.h:204
Global namespace for the Lely Industries N.V. libraries.
Definition: buf.hpp:32
void co_wtm_set_diag_wtm_ind(co_wtm_t *wtm, co_wtm_diag_wtm_ind_t *con, void *data)
Sets the indication function invoked when a WTM communication quality reset message is received by a ...
Definition: wtm.c:484
void co_wtm_diag_can_con_t(co_wtm_t *wtm, uint8_t nif, uint8_t st, uint8_t err, uint8_t load, uint16_t ec, uint16_t foc, uint16_t coc, void *data)
The type of a CANopen WTM diagnostic confirmation function, invoked when a CAN communication quality ...
Definition: wtm.h:144
int co_wtm_set_diag_can(co_wtm_t *wtm, uint8_t nif, uint8_t st, uint8_t err, uint8_t load, uint16_t ec, uint16_t foc, uint16_t coc)
Sets the diagnostic parameters of a CAN interface.
Definition: wtm.c:344
void co_wtm_get_diag_ac_ind(const co_wtm_t *wtm, co_wtm_diag_ac_ind_t **pind, void **pdata)
Retrieves the indication function invoked when an abort code is generated or received by a CANopen WT...
Definition: wtm.c:493
int co_wtm_send(co_wtm_t *wtm, uint8_t nif, const struct can_msg *msg)
Sends a CAN frame from a CANopen WTM interface.
Definition: wtm.c:836
int co_wtm_send_diag_can_req(co_wtm_t *wtm, uint8_t nif)
Sends a CAN communication quality request.
Definition: wtm.c:931
int co_wtm_send_func_t(co_wtm_t *wtm, const void *buf, size_t nbytes, void *data)
The type of a CANopen WTM send callback function, invoked when a byte stream needs to be sent...
Definition: wtm.h:220
This header file is part of the utilities library; it contains the C callback wrapper declarations...
void co_wtm_set_diag_can_ind(co_wtm_t *wtm, co_wtm_diag_can_ind_t *con, void *data)
Sets the indication function invoked when a CAN communication quality reset message is received by a ...
Definition: wtm.c:463
A class template supplying a uniform interface to certain attributes of C types.
Definition: c_type.hpp:120