Lely core libraries 1.9.2
lss.hpp
Go to the documentation of this file.
1
23#ifndef LELY_CO_LSS_HPP_
24#define LELY_CO_LSS_HPP_
25
26#ifndef __cplusplus
27#error "include <lely/co/lss.h> for the C interface"
28#endif
29
30#include <lely/can/net.hpp>
31#include <lely/co/lss.h>
32
33namespace lely {
34
36template <>
38 typedef __co_lss 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_lss_alloc();
47 }
48 static void
49 free(void* ptr) noexcept {
50 __co_lss_free(ptr);
51 }
52
53 static pointer
54 init(pointer p, CONMT* nmt) noexcept {
55 return __co_lss_init(p, nmt);
56 }
57
58 static void
59 fini(pointer p) noexcept {
60 __co_lss_fini(p);
61 }
62};
63
65class COLSS : public incomplete_c_type<__co_lss> {
67
68 public:
69 explicit COLSS(CONMT* nmt) : c_base(nmt) {}
70
71 CONMT*
72 getNMT() const noexcept {
73 return co_lss_get_nmt(this);
74 }
75
76 void
77 getRateInd(co_lss_rate_ind_t** pind, void** pdata) const noexcept {
78 co_lss_get_rate_ind(this, pind, pdata);
79 }
80
81 void
82 setRateInd(co_lss_rate_ind_t* ind, void* data) noexcept {
83 co_lss_set_rate_ind(this, ind, data);
84 }
85
86 template <class F>
87 void
88 setRateInd(F* f) noexcept {
90 static_cast<void*>(f));
91 }
92
93 template <class C, typename c_mem_fn<co_lss_rate_ind_t*, C>::type M>
94 void
95 setRateInd(C* obj) noexcept {
97 static_cast<void*>(obj));
98 }
99
100 void
101 getStoreInd(co_lss_store_ind_t** pind, void** pdata) const noexcept {
102 co_lss_get_store_ind(this, pind, pdata);
103 }
104
105 void
106 setStoreInd(co_lss_store_ind_t* ind, void* data) noexcept {
107 co_lss_set_store_ind(this, ind, data);
108 }
109
110 template <class F>
111 void
112 setStoreInd(F* f) noexcept {
114 static_cast<void*>(f));
115 }
116
117 template <class C, typename c_mem_fn<co_lss_store_ind_t*, C>::type M>
118 void
119 setStoreInd(C* obj) noexcept {
121 static_cast<void*>(obj));
122 }
123
124 int
125 getTimeout() const noexcept {
126 return co_lss_get_timeout(this);
127 }
128
129 void
130 setTimeout(int timeout) noexcept {
131 co_lss_set_timeout(this, timeout);
132 }
133
134 bool
135 isMaster() const noexcept {
136 return !!co_lss_is_master(this);
137 }
138
139 bool
140 isIdle() const noexcept {
141 return !!co_lss_is_idle(this);
142 }
143
144 void
145 abortReq() noexcept {
146 co_lss_abort_req(this);
147 }
148
149 int
150 switchReq(co_unsigned8_t mode) noexcept {
151 return co_lss_switch_req(this, mode);
152 }
153
154 int
155 switchSelReq(const co_id& id, co_lss_cs_ind_t* ind, void* data) noexcept {
156 return co_lss_switch_sel_req(this, &id, ind, data);
157 }
158
159 template <class F>
160 int
161 switchSelReq(const co_id& id, F* f) noexcept {
162 return switchSelReq(id, &c_obj_call<co_lss_cs_ind_t*, F>::function,
163 static_cast<void*>(f));
164 }
165
166 template <class C, typename c_mem_fn<co_lss_cs_ind_t*, C>::type M>
167 void
168 switchSelReq(const co_id& id, C* obj) noexcept {
170 static_cast<void*>(obj));
171 }
172
173 int
174 setIdReq(co_unsigned8_t id, co_lss_err_ind_t* ind, void* data) noexcept {
175 return co_lss_set_id_req(this, id, ind, data);
176 }
177
178 template <class F>
179 int
180 setIdReq(co_unsigned8_t id, F* f) noexcept {
182 static_cast<void*>(f));
183 }
184
185 template <class C, typename c_mem_fn<co_lss_err_ind_t*, C>::type M>
186 void
187 setIdReq(co_unsigned8_t id, C* obj) noexcept {
189 static_cast<void*>(obj));
190 }
191
192 int
193 setRateReq(co_unsigned16_t rate, co_lss_err_ind_t* ind, void* data) noexcept {
194 return co_lss_set_rate_req(this, rate, ind, data);
195 }
196
197 template <class F>
198 int
199 setRateReq(co_unsigned16_t rate, F* f) noexcept {
200 return setRateReq(rate, &c_obj_call<co_lss_err_ind_t*, F>::function,
201 static_cast<void*>(f));
202 }
203
204 template <class C, typename c_mem_fn<co_lss_err_ind_t*, C>::type M>
205 void
206 setRateReq(co_unsigned16_t rate, C* obj) noexcept {
208 static_cast<void*>(obj));
209 }
210
211 int
212 switchRateReq(int delay) noexcept {
213 return co_lss_switch_rate_req(this, delay);
214 }
215
216 int
217 storeReq(co_lss_err_ind_t* ind, void* data) noexcept {
218 return co_lss_store_req(this, ind, data);
219 }
220
221 template <class F>
222 int
223 storeReq(F* f) noexcept {
225 static_cast<void*>(f));
226 }
227
228 template <class C, typename c_mem_fn<co_lss_err_ind_t*, C>::type M>
229 void
230 storeReq(C* obj) noexcept {
232 static_cast<void*>(obj));
233 }
234
235 int
236 getVendorIdReq(co_lss_lssid_ind_t* ind, void* data) noexcept {
237 return co_lss_get_vendor_id_req(this, ind, data);
238 }
239
240 template <class F>
241 int
242 getVendorIdReq(F* f) noexcept {
244 static_cast<void*>(f));
245 }
246
247 template <class C, typename c_mem_fn<co_lss_lssid_ind_t*, C>::type M>
248 void
249 getVendorIdReq(C* obj) noexcept {
251 static_cast<void*>(obj));
252 }
253
254 int
255 getProductCodeReq(co_lss_lssid_ind_t* ind, void* data) noexcept {
256 return co_lss_get_product_code_req(this, ind, data);
257 }
258
259 template <class F>
260 int
261 getProductCodeReq(F* f) noexcept {
262 return getProductCodeReq(&c_obj_call<co_lss_lssid_ind_t*, F>::function,
263 static_cast<void*>(f));
264 }
265
266 template <class C, typename c_mem_fn<co_lss_lssid_ind_t*, C>::type M>
267 void
268 getProductCodeReq(C* obj) noexcept {
270 static_cast<void*>(obj));
271 }
272
273 int
274 getRevisionReq(co_lss_lssid_ind_t* ind, void* data) noexcept {
275 return co_lss_get_revision_req(this, ind, data);
276 }
277
278 template <class F>
279 int
280 getRevisionReq(F* f) noexcept {
282 static_cast<void*>(f));
283 }
284
285 template <class C, typename c_mem_fn<co_lss_lssid_ind_t*, C>::type M>
286 void
287 getRevisionReq(C* obj) noexcept {
289 static_cast<void*>(obj));
290 }
291
292 int
293 getSerialNrReq(co_lss_lssid_ind_t* ind, void* data) noexcept {
294 return co_lss_get_serial_nr_req(this, ind, data);
295 }
296
297 template <class F>
298 int
299 getSerialNrReq(F* f) noexcept {
301 static_cast<void*>(f));
302 }
303
304 template <class C, typename c_mem_fn<co_lss_lssid_ind_t*, C>::type M>
305 void
306 getSerialNrReq(C* obj) noexcept {
308 static_cast<void*>(obj));
309 }
310
311 int
312 getIdReq(co_lss_nid_ind_t* ind, void* data) noexcept {
313 return co_lss_get_id_req(this, ind, data);
314 }
315
316 template <class F>
317 int
318 getIdReq(F* f) noexcept {
320 static_cast<void*>(f));
321 }
322
323 template <class C, typename c_mem_fn<co_lss_nid_ind_t*, C>::type M>
324 void
325 getIdReq(C* obj) noexcept {
327 static_cast<void*>(obj));
328 }
329
330 int
331 idSlaveReq(const co_id& lo, const co_id& hi, co_lss_cs_ind_t* ind,
332 void* data) noexcept {
333 return co_lss_id_slave_req(this, &lo, &hi, ind, data);
334 }
335
336 template <class F>
337 int
338 idSlaveReq(const co_id& lo, const co_id& hi, F* f) noexcept {
339 return idSlaveReq(lo, hi, &c_obj_call<co_lss_cs_ind_t*, F>::function,
340 static_cast<void*>(f));
341 }
342
343 template <class C, typename c_mem_fn<co_lss_cs_ind_t*, C>::type M>
344 void
345 idSlaveReq(const co_id& lo, const co_id& hi, C* obj) noexcept {
347 static_cast<void*>(obj));
348 }
349
350 int
351 idNonCfgSlaveReq(co_lss_cs_ind_t* ind, void* data) noexcept {
352 return co_lss_id_non_cfg_slave_req(this, ind, data);
353 }
354
355 template <class F>
356 int
357 idNonCfgSlaveReq(F* f) noexcept {
358 return idNonCfgSlaveReq(&c_obj_call<co_lss_cs_ind_t*, F>::function,
359 static_cast<void*>(f));
360 }
361
362 template <class C, typename c_mem_fn<co_lss_cs_ind_t*, C>::type M>
363 void
364 idNonCfgSlaveReq(C* obj) noexcept {
366 static_cast<void*>(obj));
367 }
368
369 int
370 slowscanReq(const co_id& lo, const co_id& hi, co_lss_scan_ind_t* ind,
371 void* data) noexcept {
372 return co_lss_slowscan_req(this, &lo, &hi, ind, data);
373 }
374
375 template <class F>
376 int
377 slowscanReq(const co_id& lo, const co_id& hi, F* f) noexcept {
378 return slowscanReq(lo, hi, &c_obj_call<co_lss_scan_ind_t*, F>::function,
379 static_cast<void*>(f));
380 }
381
382 template <class C, typename c_mem_fn<co_lss_scan_ind_t*, C>::type M>
383 void
384 slowscanReq(const co_id& lo, const co_id& hi, C* obj) noexcept {
386 static_cast<void*>(obj));
387 }
388
389 int
390 fastscanReq(const co_id* id, const co_id* mask, co_lss_scan_ind_t* ind,
391 void* data) noexcept {
392 return co_lss_fastscan_req(this, id, mask, ind, data);
393 }
394
395 template <class F>
396 int
397 fastscanReq(const co_id* id, const co_id* mask, F* f) noexcept {
398 return fastscanReq(id, mask, &c_obj_call<co_lss_scan_ind_t*, F>::function,
399 static_cast<void*>(f));
400 }
401
402 template <class C, typename c_mem_fn<co_lss_scan_ind_t*, C>::type M>
403 int
404 fastscanReq(const co_id* id, const co_id* mask, C* obj) noexcept {
405 return fastscanReq(id, mask,
407 static_cast<void*>(obj));
408 }
409
410 protected:
411 ~COLSS() {}
412};
413
414} // namespace lely
415
416#endif // !LELY_CO_LSS_HPP_
An opaque CANopen LSS master/slave service type.
Definition: lss.hpp:65
An opaque CANopen NMT master/slave service type.
Definition: nmt.hpp:70
The base class for a C++ interface to an incomplete C type.
Definition: c_type.hpp:245
This header file is part of the CANopen library; it contains the Layer Setting Services (LSS) and pro...
void co_lss_lssid_ind_t(co_lss_t *lss, co_unsigned8_t cs, co_unsigned32_t id, void *data)
The type of a CANopen LSS inquire identity indication function, invoked when an 'inquire identity ven...
Definition: lss.h:109
int co_lss_get_vendor_id_req(co_lss_t *lss, co_lss_lssid_ind_t *ind, void *data)
Requests the 'inquire identity vendor-ID' service.
Definition: lss.c:1017
int co_lss_store_ind_t(co_lss_t *lss, co_unsigned8_t id, co_unsigned16_t rate, void *data)
The type of a CANopen LSS 'store configuration' indication function, invoked when the pending node-ID...
Definition: lss.h:67
void co_lss_err_ind_t(co_lss_t *lss, co_unsigned8_t cs, co_unsigned8_t err, co_unsigned8_t spec, void *data)
The type of a CANopen LSS error received indication function, invoked when a 'configure node-ID',...
Definition: lss.h:94
int co_lss_is_master(const co_lss_t *lss)
Returns 1 if the specified CANopen LSS service is a master, and 0 if not.
Definition: lss.c:815
void co_lss_nid_ind_t(co_lss_t *lss, co_unsigned8_t cs, co_unsigned8_t id, void *data)
The type of a CANopen LSS inquire node-ID indication function, invoked when an 'inquire node-ID' requ...
Definition: lss.h:121
int co_lss_set_id_req(co_lss_t *lss, co_unsigned8_t id, co_lss_err_ind_t *ind, void *data)
Requests the 'configure node-ID' service.
Definition: lss.c:893
void co_lss_set_timeout(co_lss_t *lss, int timeout)
Sets the timeout of an LSS master service.
Definition: lss.c:802
void co_lss_scan_ind_t(co_lss_t *lss, co_unsigned8_t cs, const struct co_id *id, void *data)
The type of a CANopen LSS identify remote slave indication function, invoked when a 'Slowscan' or 'Fa...
Definition: lss.h:135
int co_lss_slowscan_req(co_lss_t *lss, const struct co_id *lo, const struct co_id *hi, co_lss_scan_ind_t *ind, void *data)
Requests the 'LSS Slowscan' service.
Definition: lss.c:1194
int co_lss_switch_rate_req(co_lss_t *lss, int delay)
Requests the 'activate bit timing parameters' service.
Definition: lss.c:966
int co_lss_get_id_req(co_lss_t *lss, co_lss_nid_ind_t *ind, void *data)
Requests the 'inquire node-ID' service.
Definition: lss.c:1119
int co_lss_get_revision_req(co_lss_t *lss, co_lss_lssid_ind_t *ind, void *data)
Requests the 'inquire identity revision-number' service.
Definition: lss.c:1067
void co_lss_set_store_ind(co_lss_t *lss, co_lss_store_ind_t *ind, void *data)
Sets the indication function invoked when an LSS 'store configuration' request is received.
Definition: lss.c:783
int co_lss_switch_sel_req(co_lss_t *lss, const struct co_id *id, co_lss_cs_ind_t *ind, void *data)
Requests the 'switch state selective' service.
Definition: lss.c:869
void co_lss_get_rate_ind(const co_lss_t *lss, co_lss_rate_ind_t **pind, void **pdata)
Retrieves the indication function invoked when an LSS 'activate bit timing' request is received.
Definition: lss.c:751
int co_lss_switch_req(co_lss_t *lss, co_unsigned8_t mode)
Requests the 'switch state global' service.
Definition: lss.c:847
int co_lss_set_rate_req(co_lss_t *lss, co_unsigned16_t rate, co_lss_err_ind_t *ind, void *data)
Requests the 'configure bit timing parameters' service.
Definition: lss.c:925
int co_lss_is_idle(const co_lss_t *lss)
Returns 1 if the specified LSS master is idle, and 0 if a request is ongoing.
Definition: lss.c:831
void co_lss_set_rate_ind(co_lss_t *lss, co_lss_rate_ind_t *ind, void *data)
Sets the indication function invoked when an LSS 'activate bit timing' request is received.
Definition: lss.c:762
int co_lss_get_timeout(const co_lss_t *lss)
Returns the timeout (in milliseconds) of an LSS master service.
Definition: lss.c:794
co_nmt_t * co_lss_get_nmt(const co_lss_t *lss)
Returns a pointer to the NMT service of an LSS master/slave service.
Definition: lss.c:743
int co_lss_get_product_code_req(co_lss_t *lss, co_lss_lssid_ind_t *ind, void *data)
Requests the 'inquire identity product-code' service.
Definition: lss.c:1042
int co_lss_id_slave_req(co_lss_t *lss, const struct co_id *lo, const struct co_id *hi, co_lss_cs_ind_t *ind, void *data)
Requests the 'LSS identify remote slave' service.
Definition: lss.c:1144
int co_lss_store_req(co_lss_t *lss, co_lss_err_ind_t *ind, void *data)
Requests the 'store configuration' service.
Definition: lss.c:992
void co_lss_cs_ind_t(co_lss_t *lss, co_unsigned8_t cs, void *data)
The type of a CANopen LSS command received indication function, invoked when a 'switch state selectiv...
Definition: lss.h:80
void co_lss_rate_ind_t(co_lss_t *lss, co_unsigned16_t rate, int delay, void *data)
The type of a CANopen LSS 'activate bit timing' indication function, invoked when a baudrate switch i...
Definition: lss.h:51
int co_lss_id_non_cfg_slave_req(co_lss_t *lss, co_lss_cs_ind_t *ind, void *data)
Requests the 'LSS identify non-configured remote slave' service.
Definition: lss.c:1168
int co_lss_fastscan_req(co_lss_t *lss, const struct co_id *id, const struct co_id *mask, co_lss_scan_ind_t *ind, void *data)
Requests the 'LSS Fastscan' service.
Definition: lss.c:1228
int co_lss_get_serial_nr_req(co_lss_t *lss, co_lss_lssid_ind_t *ind, void *data)
Requests the 'inquire identity serial-number' service.
Definition: lss.c:1093
void co_lss_abort_req(co_lss_t *lss)
Aborts the current LSS master request.
Definition: lss.c:839
void co_lss_get_store_ind(const co_lss_t *lss, co_lss_store_ind_t **pind, void **pdata)
Retrieves the indication function invoked when an LSS 'store configuration' request is received.
Definition: lss.c:771
Global namespace for the Lely Industries N.V. libraries.
Definition: buf.hpp:32
This header file is part of the CAN library; it contains the C++ interface of the CAN network interfa...
A CANopen LSS master/slave service.
Definition: lss.c:43
An identity record.
Definition: dev.h:33
A class template supplying a uniform interface to certain attributes of C types.
Definition: c_type.hpp:344