Lely core libraries 2.3.4
wtm.hpp
Go to the documentation of this file.
1
23#ifndef LELY_CO_WTM_HPP_
24#define LELY_CO_WTM_HPP_
25
26#if !defined(__cplusplus) || LELY_NO_CXX
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
33namespace lely {
34class COWTM;
35}
38
39#include <lely/co/wtm.h>
40
41namespace lely {
42
44template <>
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
72class COWTM : public incomplete_c_type<__co_wtm> {
74
75 public:
76 COWTM() : c_base() {}
77
79 getNIF() const noexcept {
80 return co_wtm_get_nif(this);
81 }
82
83 int
84 setNIF(uint_least8_t nif = 1) noexcept {
85 return co_wtm_set_nif(this, nif);
86 }
87
88 int
89 setDiagCAN(uint_least8_t nif, uint_least8_t st = 0xf, uint_least8_t err = 0xf,
90 uint_least8_t load = 0xff, uint_least16_t ec = 0xffff,
91 uint_least16_t foc = 0xffff,
92 uint_least16_t coc = 0xffff) noexcept {
93 return co_wtm_set_diag_can(this, nif, st, err, load, ec, foc, coc);
94 }
95
96 int
97 setDiagWTM(uint_least8_t quality = 0xff) noexcept {
98 return co_wtm_set_diag_wtm(this, quality);
99 }
100
101 void
102 getDiagCANCon(co_wtm_diag_can_con_t** pfunc, void** pdata) const noexcept {
104 }
105
106 void
107 setDiagCANCon(co_wtm_diag_can_con_t* func, void* data) noexcept {
108 co_wtm_set_diag_can_con(this, func, data);
109 }
110
111 template <class F>
112 void
113 setDiagCANCon(F* f) noexcept {
115 static_cast<void*>(f));
116 }
117
119 void
120 setDiagCANCon(C* obj) noexcept {
122 static_cast<void*>(obj));
123 }
124
125 void
126 getDiagWTMCon(co_wtm_diag_wtm_con_t** pfunc, void** pdata) const noexcept {
128 }
129
130 void
131 setDiagWTMCon(co_wtm_diag_wtm_con_t* func, void* data) noexcept {
132 co_wtm_set_diag_wtm_con(this, func, data);
133 }
134
135 template <class F>
136 void
137 setDiagWTMCon(F* f) noexcept {
139 static_cast<void*>(f));
140 }
141
143 void
144 setDiagWTMCon(C* obj) noexcept {
146 static_cast<void*>(obj));
147 }
148
149 void
150 getDiagCANInd(co_wtm_diag_can_ind_t** pfunc, void** pdata) const noexcept {
152 }
153
154 void
155 setDiagCANInd(co_wtm_diag_can_ind_t* func, void* data) noexcept {
156 co_wtm_set_diag_can_ind(this, func, data);
157 }
158
159 template <class F>
160 void
161 setDiagCANInd(F* f) noexcept {
163 static_cast<void*>(f));
164 }
165
167 void
168 setDiagCANInd(C* obj) noexcept {
170 static_cast<void*>(obj));
171 }
172
173 void
174 getDiagWTMInd(co_wtm_diag_wtm_ind_t** pfunc, void** pdata) const noexcept {
176 }
177
178 void
179 setDiagWTMInd(co_wtm_diag_wtm_ind_t* func, void* data) noexcept {
180 co_wtm_set_diag_wtm_ind(this, func, data);
181 }
182
183 template <class F>
184 void
185 setDiagWTMInd(F* f) noexcept {
187 static_cast<void*>(f));
188 }
189
191 void
192 setDiagWTMInd(C* obj) noexcept {
194 static_cast<void*>(obj));
195 }
196
197 void
198 getDiagACInd(co_wtm_diag_ac_ind_t** pfunc, void** pdata) const noexcept {
200 }
201
202 void
203 setDiagACInd(co_wtm_diag_ac_ind_t* func, void* data) noexcept {
204 co_wtm_set_diag_ac_ind(this, func, data);
205 }
206
207 template <class F>
208 void
209 setDiagACInd(F* f) noexcept {
211 static_cast<void*>(f));
212 }
213
215 void
216 setDiagACInd(C* obj) noexcept {
218 static_cast<void*>(obj));
219 }
220
221 void
222 recv(const void* buf, size_t nbytes) noexcept {
223 co_wtm_recv(this, buf, nbytes);
224 }
225
226 void
227 getRecvFunc(co_wtm_recv_func_t** pfunc, void** pdata) const noexcept {
229 }
230
231 void
232 setRecvFunc(co_wtm_recv_func_t* func, void* data) noexcept {
233 co_wtm_set_recv_func(this, func, data);
234 }
235
236 template <class F>
237 void
238 setRecvFunc(F* f) noexcept {
240 static_cast<void*>(f));
241 }
242
244 void
245 setRecvFunc(C* obj) noexcept {
247 static_cast<void*>(obj));
248 }
249
250 int
251 getTime(uint_least8_t nif, timespec* tp) const noexcept {
252 return co_wtm_get_time(this, nif, tp);
253 }
254
255 int
256 setTime(uint_least8_t nif, const timespec& tp) noexcept {
257 return co_wtm_set_time(this, nif, &tp);
258 }
259
260 int
261 send(uint_least8_t nif, const can_msg& msg) noexcept {
262 return co_wtm_send(this, nif, &msg);
263 }
264
265 int
266 sendAlive() noexcept {
267 return co_wtm_send_alive(this);
268 }
269
270 int
271 sendDiagCANReq(uint_least8_t nif) noexcept {
272 return co_wtm_send_diag_can_req(this, nif);
273 }
274
275 int
276 sendDiagWTMReq(uint_least8_t nif) noexcept {
277 return co_wtm_send_diag_wtm_req(this, nif);
278 }
279
280 int
281 sendDiagCANRst(uint_least8_t nif) noexcept {
282 return co_wtm_send_diag_can_rst(this, nif);
283 }
284
285 int
286 sendDiagWTMRst(uint_least8_t nif) noexcept {
287 return co_wtm_send_diag_wtm_rst(this, nif);
288 }
289
290 int
291 sendDiagAC(uint_least32_t ac) noexcept {
292 return co_wtm_send_diag_ac(this, ac);
293 }
294
295 int
296 flush() noexcept {
297 return co_wtm_flush(this);
298 }
299
300 void
301 getSendFunc(co_wtm_send_func_t** pfunc, void** pdata) const noexcept {
303 }
304
305 void
306 setSendFunc(co_wtm_send_func_t* func, void* data) noexcept {
307 co_wtm_set_send_func(this, func, data);
308 }
309
310 template <class F>
311 void
312 setSendFunc(F* f) noexcept {
314 static_cast<void*>(f));
315 }
316
318 void
319 setSendFunc(C* obj) noexcept {
321 static_cast<void*>(obj));
322 }
323
324 protected:
325 ~COWTM() = default;
326};
327
328} // namespace lely
329
330#endif // !LELY_CO_WTM_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.
A CANopen value.
Definition val.hpp:42
An opaque CANopen Wireless Transmission Media (WTM) interface type.
Definition wtm.hpp:72
The base class for a C++ interface to an incomplete C type.
Definition c_type.hpp:249
A CANopen Wireless Transmission Media (WTM) interface.
Definition wtm.c:90
A CAN or CAN FD format frame.
Definition msg.h:87
A class template supplying a uniform interface to certain attributes of C types.
Definition c_type.hpp:350
A time type with nanosecond resolution.
Definition time.h:88
This header file is part of the CANopen library; it contains the Wireless Transmission Media (WTM) de...
void co_wtm_diag_can_con_t(co_wtm_t *wtm, uint_least8_t nif, uint_least8_t st, uint_least8_t err, uint_least8_t load, uint_least16_t ec, uint_least16_t foc, uint_least16_t coc, void *data)
The type of a CANopen WTM diagnostic confirmation function, invoked when a CAN communication quality ...
Definition wtm.h:144
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:501
int co_wtm_set_diag_wtm(co_wtm_t *wtm, uint_least8_t quality)
Sets the diagnostic parameters of a WTM interface.
Definition wtm.c:402
int co_wtm_send_diag_wtm_rst(co_wtm_t *wtm, uint_least8_t nif)
Sends a WTM communication quality reset message.
Definition wtm.c:994
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:459
void co_wtm_diag_can_ind_t(co_wtm_t *wtm, uint_least8_t nif, void *data)
The type of a CANopen WTM diagnostic indication function, invoked when a CAN communication quality re...
Definition wtm.h:170
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:492
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:180
int co_wtm_get_time(const co_wtm_t *wtm, uint_least8_t nif, struct timespec *tp)
Retrieves the current time of a CANopen WTM interface.
Definition wtm.c:794
int co_wtm_send_alive(co_wtm_t *wtm)
Sends a keep-alive message from a CANopen WTM interface.
Definition wtm.c:926
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:438
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:222
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:480
int co_wtm_send_diag_ac(co_wtm_t *wtm, uint_least32_t ac)
Sends a diagnostic abort message from a CANopen WTM interface.
Definition wtm.c:1012
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:471
int co_wtm_send_diag_can_req(co_wtm_t *wtm, uint_least8_t nif)
Sends a CAN communication quality request.
Definition wtm.c:940
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:513
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:785
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:1069
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:522
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:417
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:773
int co_wtm_send(co_wtm_t *wtm, uint_least8_t nif, const struct can_msg *msg)
Sends a CAN frame from a CANopen WTM interface.
Definition wtm.c:844
int co_wtm_send_diag_wtm_req(co_wtm_t *wtm, uint_least8_t nif)
Sends a WTM communication quality request.
Definition wtm.c:958
int co_wtm_send_diag_can_rst(co_wtm_t *wtm, uint_least8_t nif)
Sends a CAN communication quality reset message.
Definition wtm.c:976
int co_wtm_flush(co_wtm_t *wtm)
Flushes the current send buffer of a CANopen WTM interface.
Definition wtm.c:1027
void co_wtm_diag_ac_ind_t(co_wtm_t *wtm, uint_least32_t ac, void *data)
The type of a CANopen WTM diagnostic indication function, invoked when an abort code is generated or ...
Definition wtm.h:190
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:429
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:1057
int co_wtm_recv_func_t(co_wtm_t *wtm, uint_least8_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:206
int co_wtm_set_diag_can(co_wtm_t *wtm, uint_least8_t nif, uint_least8_t st, uint_least8_t err, uint_least8_t load, uint_least16_t ec, uint_least16_t foc, uint_least16_t coc)
Sets the diagnostic parameters of a CAN interface.
Definition wtm.c:351
uint_least8_t co_wtm_get_nif(const co_wtm_t *wtm)
Returns the interface indicator of a CANopen WTM interface.
Definition wtm.c:328
void co_wtm_diag_wtm_con_t(co_wtm_t *wtm, uint_least8_t nif, uint_least8_t quality, void *data)
The type of a CANopen WTM diagnostic confirmation function, invoked when a WTM communication quality ...
Definition wtm.h:159
int co_wtm_set_nif(co_wtm_t *wtm, uint_least8_t nif)
Sets the interface indicator of a CANopen WTM interface.
Definition wtm.c:336
int co_wtm_set_time(co_wtm_t *wtm, uint_least8_t nif, const struct timespec *tp)
Sets the current time of a CANopen WTM interface.
Definition wtm.c:810
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:450
lely::COWTM co_wtm_t
An opaque CANopen Wireless Transmission Media (WTM) interface type.
Definition wtm.hpp:37