Lely core libraries  2.2.5
nmt_srv.c
Go to the documentation of this file.
1 
24 #include "co.h"
25 #include <lely/util/diag.h>
26 #ifndef LELY_NO_CO_CSDO
27 #include <lely/co/csdo.h>
28 #endif
29 #include <lely/co/dev.h>
30 #ifndef LELY_NO_CO_EMCY
31 #include <lely/co/emcy.h>
32 #endif
33 #ifndef LELY_NO_CO_LSS
34 #include <lely/co/lss.h>
35 #endif
36 #ifndef LELY_NO_CO_RPDO
37 #include <lely/co/rpdo.h>
38 #endif
39 #include <lely/co/ssdo.h>
40 #ifndef LELY_NO_CO_SYNC
41 #include <lely/co/sync.h>
42 #endif
43 #ifndef LELY_NO_CO_TIME
44 #include <lely/co/time.h>
45 #endif
46 #ifndef LELY_NO_CO_TPDO
47 #include <lely/co/tpdo.h>
48 #endif
49 #include "nmt_srv.h"
50 
51 #include <assert.h>
52 #include <stdlib.h>
53 
54 #if !defined(LELY_NO_CO_RPDO) || !defined(LELY_NO_CO_TPDO)
55 static void co_nmt_srv_init_pdo(
57  struct co_nmt_srv *srv, can_net_t *net, co_dev_t *dev);
59 static void co_nmt_srv_fini_pdo(struct co_nmt_srv *srv);
60 #ifndef LELY_NO_CO_RPDO
61 static void co_nmt_srv_rpdo_err(co_rpdo_t *pdo, co_unsigned16_t eec,
63  co_unsigned8_t er, void *data);
64 #endif
65 #endif
66 
68 static void co_nmt_srv_init_sdo(
69  struct co_nmt_srv *srv, can_net_t *net, co_dev_t *dev);
71 static void co_nmt_srv_fini_sdo(struct co_nmt_srv *srv);
72 
73 #ifndef LELY_NO_CO_SYNC
74 static void co_nmt_srv_init_sync(
76  struct co_nmt_srv *srv, can_net_t *net, co_dev_t *dev);
78 static void co_nmt_srv_fini_sync(struct co_nmt_srv *srv);
80 static void co_nmt_srv_sync_ind(
81  co_sync_t *sync, co_unsigned8_t cnt, void *data);
83 static void co_nmt_srv_sync_err(co_sync_t *sync, co_unsigned16_t eec,
84  co_unsigned8_t er, void *data);
85 #endif
86 
87 #ifndef LELY_NO_CO_TIME
88 static void co_nmt_srv_init_time(
90  struct co_nmt_srv *srv, can_net_t *net, co_dev_t *dev);
92 static void co_nmt_srv_fini_time(struct co_nmt_srv *srv);
93 #endif
94 
95 #ifndef LELY_NO_CO_EMCY
96 static void co_nmt_srv_init_emcy(
98  struct co_nmt_srv *srv, can_net_t *net, co_dev_t *dev);
100 static void co_nmt_srv_fini_emcy(struct co_nmt_srv *srv);
101 #endif
102 
103 #ifndef LELY_NO_CO_LSS
104 static void co_nmt_srv_init_lss(struct co_nmt_srv *srv, co_nmt_t *nmt);
107 static void co_nmt_srv_fini_lss(struct co_nmt_srv *srv);
108 #endif
109 
111 #define CO_NUM_PDO 512
112 
114 #define CO_NUM_SDO 128
115 
116 void
118 {
119  assert(srv);
120  assert(nmt);
121 
122  srv->nmt = nmt;
123 
124  srv->set = 0;
125 
126  srv->rpdos = NULL;
127  srv->nrpdo = 0;
128  srv->tpdos = NULL;
129  srv->ntpdo = 0;
130 
131  srv->ssdos = NULL;
132  srv->nssdo = 0;
133  srv->csdos = NULL;
134  srv->ncsdo = 0;
135 
136  srv->sync = NULL;
137  srv->time = NULL;
138  srv->emcy = NULL;
139 
140  srv->lss = NULL;
141 }
142 
143 void
145 {
146  assert(srv);
147 
148  co_nmt_srv_set(srv, NULL, 0);
149 }
150 
151 void
152 co_nmt_srv_set(struct co_nmt_srv *srv, co_nmt_t *nmt, int set)
153 {
154  assert(srv);
155 
156 #ifndef LELY_NO_CO_LSS
157  if ((srv->set & ~set) & CO_NMT_SRV_LSS)
158  co_nmt_srv_fini_lss(srv);
159 #endif
160 #ifndef LELY_NO_CO_EMCY
161  if ((srv->set & ~set) & CO_NMT_SRV_EMCY)
163 #endif
164 #ifndef LELY_NO_CO_TIME
165  if ((srv->set & ~set) & CO_NMT_SRV_TIME)
167 #endif
168 #ifndef LELY_NO_CO_SYNC
169  if ((srv->set & ~set) & CO_NMT_SRV_SYNC)
171 #endif
172  if ((srv->set & ~set) & CO_NMT_SRV_SDO)
173  co_nmt_srv_fini_sdo(srv);
174 #if !defined(LELY_NO_CO_RPDO) || !defined(LELY_NO_CO_TPDO)
175  if ((srv->set & ~set) & CO_NMT_SRV_PDO)
176  co_nmt_srv_fini_pdo(srv);
177 #endif
178 
179  if (nmt) {
180  can_net_t *net = co_nmt_get_net(nmt);
181  co_dev_t *dev = co_nmt_get_dev(nmt);
182 #if !defined(LELY_NO_CO_RPDO) || !defined(LELY_NO_CO_TPDO)
183  if ((set & ~srv->set) & CO_NMT_SRV_PDO)
184  co_nmt_srv_init_pdo(srv, net, dev);
185 #endif
186  if ((set & ~srv->set) & CO_NMT_SRV_SDO)
187  co_nmt_srv_init_sdo(srv, net, dev);
188 #ifndef LELY_NO_CO_SYNC
189  if ((set & ~srv->set) & CO_NMT_SRV_SYNC)
190  co_nmt_srv_init_sync(srv, net, dev);
191 #endif
192 #ifndef LELY_NO_CO_TIME
193  if ((set & ~srv->set) & CO_NMT_SRV_TIME)
194  co_nmt_srv_init_time(srv, net, dev);
195 #endif
196 #ifndef LELY_NO_CO_EMCY
197  if ((set & ~srv->set) & CO_NMT_SRV_EMCY)
198  co_nmt_srv_init_emcy(srv, net, dev);
199 #endif
200 #ifndef LELY_NO_CO_LSS
201  if ((set & ~srv->set) & CO_NMT_SRV_LSS)
202  co_nmt_srv_init_lss(srv, nmt);
203 #endif
204  }
205 }
206 
207 #if !defined(LELY_NO_CO_RPDO) || !defined(LELY_NO_CO_TPDO)
208 
209 static void
211 {
212  assert(srv);
213  assert(!(srv->set & CO_NMT_SRV_PDO));
214  assert(!srv->rpdos);
215  assert(!srv->nrpdo);
216  assert(!srv->tpdos);
217  assert(!srv->ntpdo);
218 
219  srv->set |= CO_NMT_SRV_PDO;
220 
221 #ifndef LELY_NO_CO_RPDO
222  // Create the Receive-PDOs.
223  for (co_unsigned16_t i = 0; i < CO_NUM_PDO; i++) {
224  co_obj_t *obj_1400 = co_dev_find_obj(dev, 0x1400 + i);
225  co_obj_t *obj_1600 = co_dev_find_obj(dev, 0x1600 + i);
226  if (!obj_1400 || !obj_1600)
227  continue;
228 
229  co_rpdo_t **rpdos =
230  realloc(srv->rpdos, (i + 1) * sizeof(*rpdos));
231  if (!rpdos) {
232  set_errc(errno2c(errno));
233  goto error;
234  }
235  srv->rpdos = rpdos;
236 
237  for (size_t j = srv->nrpdo; j < i; j++)
238  srv->rpdos[j] = NULL;
239  srv->rpdos[i] = co_rpdo_create(net, dev, i + 1);
240  if (!srv->rpdos[i])
241  goto error;
242  co_rpdo_set_err(srv->rpdos[i], &co_nmt_srv_rpdo_err, srv->nmt);
243 
244  srv->nrpdo = i + 1;
245  }
246 #endif
247 
248 #ifndef LELY_NO_CO_TPDO
249  // Create the Transmit-PDOs.
250  for (co_unsigned16_t i = 0; i < CO_NUM_PDO; i++) {
251  co_obj_t *obj_1800 = co_dev_find_obj(dev, 0x1800 + i);
252  co_obj_t *obj_1a00 = co_dev_find_obj(dev, 0x1a00 + i);
253  if (!obj_1800 || !obj_1a00)
254  continue;
255 
256  co_tpdo_t **tpdos =
257  realloc(srv->tpdos, (i + 1) * sizeof(*tpdos));
258  if (!tpdos) {
259  set_errc(errno2c(errno));
260  goto error;
261  }
262  srv->tpdos = tpdos;
263 
264  for (size_t j = srv->ntpdo; j < i; j++)
265  srv->tpdos[j] = NULL;
266  srv->tpdos[i] = co_tpdo_create(net, dev, i + 1);
267  if (!srv->tpdos[i])
268  goto error;
269 
270  srv->ntpdo = i + 1;
271  }
272 #endif
273 
274  return;
275 
276 error:
277  diag(DIAG_ERROR, get_errc(), "unable to initialize PDO services");
278 }
279 
280 static void
282 {
283  assert(srv);
284  assert(srv->set & CO_NMT_SRV_PDO);
285 
286  srv->set &= ~CO_NMT_SRV_PDO;
287 
288 #ifndef LELY_NO_CO_TPDO
289  // Destroy the Transmit-PDOs.
290  for (size_t i = 0; i < srv->ntpdo; i++)
291  co_tpdo_destroy(srv->tpdos[i]);
292  free(srv->tpdos);
293  srv->tpdos = NULL;
294  srv->ntpdo = 0;
295 #endif
296 
297 #ifndef LELY_NO_CO_RPDO
298  // Destroy the Receive-PDOs.
299  for (size_t i = 0; i < srv->nrpdo; i++)
300  co_rpdo_destroy(srv->rpdos[i]);
301  free(srv->rpdos);
302  srv->rpdos = NULL;
303  srv->nrpdo = 0;
304 #endif
305 }
306 
307 #ifndef LELY_NO_CO_RPDO
308 static void
309 co_nmt_srv_rpdo_err(co_rpdo_t *pdo, co_unsigned16_t eec, co_unsigned8_t er,
310  void *data)
311 {
312  (void)pdo;
313  co_nmt_t *nmt = data;
314  assert(nmt);
315 
316  co_nmt_on_err(nmt, eec, er, NULL);
317 }
318 #endif
319 
320 #endif // !LELY_NO_CO_RPDO || !LELY_NO_CO_TPDO
321 
322 static void
324 {
325  assert(srv);
326  assert(!(srv->set & CO_NMT_SRV_SDO));
327  assert(!srv->ssdos);
328  assert(!srv->nssdo);
329  assert(!srv->csdos);
330  assert(!srv->ncsdo);
331 
332  srv->set |= CO_NMT_SRV_SDO;
333 
334  // Create the Server-SDOs.
335  for (co_unsigned8_t i = 0; i < CO_NUM_SDO; i++) {
336  co_obj_t *obj_1200 = co_dev_find_obj(dev, 0x1200 + i);
337  // The default Server-SDO does not have to exist in the object
338  // dictionary.
339  if (i && !obj_1200)
340  continue;
341 
342  co_ssdo_t **ssdos =
343  realloc(srv->ssdos, (i + 1) * sizeof(*ssdos));
344  if (!ssdos) {
345  set_errc(errno2c(errno));
346  goto error;
347  }
348  srv->ssdos = ssdos;
349 
350  for (size_t j = srv->nssdo; j < i; j++)
351  srv->ssdos[j] = NULL;
352  srv->ssdos[i] = co_ssdo_create(net, dev, i + 1);
353  if (!srv->ssdos[i])
354  goto error;
355 
356  srv->nssdo = i + 1;
357  }
358 
359 #ifndef LELY_NO_CO_CSDO
360  // Create the Client-SDOs.
361  for (co_unsigned8_t i = 0; i < CO_NUM_SDO; i++) {
362  co_obj_t *obj_1280 = co_dev_find_obj(dev, 0x1280 + i);
363  if (!obj_1280)
364  continue;
365 
366  co_csdo_t **csdos =
367  realloc(srv->csdos, (i + 1) * sizeof(*csdos));
368  if (!csdos) {
369  set_errc(errno2c(errno));
370  goto error;
371  }
372  srv->csdos = csdos;
373 
374  for (size_t j = srv->ncsdo; j < i; j++)
375  srv->csdos[j] = NULL;
376  srv->csdos[i] = co_csdo_create(net, dev, i + 1);
377  if (!srv->csdos[i])
378  goto error;
379 
380  srv->ncsdo = i + 1;
381  }
382 #endif
383 
384  return;
385 
386 error:
387  diag(DIAG_ERROR, get_errc(), "unable to initialize SDO services");
388 }
389 
390 static void
392 {
393  assert(srv);
394  assert(srv->set & CO_NMT_SRV_SDO);
395 
396  srv->set &= ~CO_NMT_SRV_SDO;
397 
398 #ifndef LELY_NO_CO_CSDO
399  // Destroy the Client-SDOs.
400  for (size_t i = 0; i < srv->ncsdo; i++)
401  co_csdo_destroy(srv->csdos[i]);
402  free(srv->csdos);
403  srv->csdos = NULL;
404  srv->ncsdo = 0;
405 #endif
406 
407  // Destroy the Server-SDOs (skipping the default one).
408  for (size_t i = 0; i < srv->nssdo; i++)
409  co_ssdo_destroy(srv->ssdos[i]);
410  free(srv->ssdos);
411  srv->ssdos = NULL;
412  srv->nssdo = 0;
413 }
414 
415 #ifndef LELY_NO_CO_SYNC
416 
417 static void
419 {
420  assert(srv);
421  assert(!(srv->set & CO_NMT_SRV_SYNC));
422  assert(!srv->sync);
423 
424  srv->set |= CO_NMT_SRV_SYNC;
425 
426  co_obj_t *obj_1005 = co_dev_find_obj(dev, 0x1005);
427  if (!obj_1005)
428  return;
429 
430  srv->sync = co_sync_create(net, dev);
431  if (!srv->sync) {
433  "unable to initialize SYNC service");
434  return;
435  }
438 }
439 
440 static void
442 {
443  assert(srv);
444  assert(srv->set & CO_NMT_SRV_SYNC);
445 
446  srv->set &= ~CO_NMT_SRV_SYNC;
447 
448  co_sync_destroy(srv->sync);
449  srv->sync = NULL;
450 }
451 
452 static void
453 co_nmt_srv_sync_ind(co_sync_t *sync, co_unsigned8_t cnt, void *data)
454 {
455  (void)sync;
456  co_nmt_t *nmt = data;
457  assert(nmt);
458 
459  co_nmt_on_sync(nmt, cnt);
460 }
461 
462 static void
463 co_nmt_srv_sync_err(co_sync_t *sync, co_unsigned16_t eec, co_unsigned8_t er,
464  void *data)
465 {
466  (void)sync;
467  co_nmt_t *nmt = data;
468  assert(nmt);
469 
470  co_nmt_on_err(nmt, eec, er, NULL);
471 }
472 
473 #endif // !LELY_NO_CO_SYNC
474 
475 #ifndef LELY_NO_CO_TIME
476 
477 static void
479 {
480  assert(srv);
481  assert(!(srv->set & CO_NMT_SRV_TIME));
482  assert(!srv->time);
483 
484  srv->set |= CO_NMT_SRV_TIME;
485 
486  co_obj_t *obj_1012 = co_dev_find_obj(dev, 0x1012);
487  if (!obj_1012)
488  return;
489 
490  srv->time = co_time_create(net, dev);
491  if (!srv->time)
493  "unable to initialize TIME service");
494 }
495 
496 static void
498 {
499  assert(srv);
500  assert(srv->set & CO_NMT_SRV_TIME);
501 
502  srv->set &= ~CO_NMT_SRV_TIME;
503 
504  co_time_destroy(srv->time);
505  srv->time = NULL;
506 }
507 
508 #endif
509 
510 #ifndef LELY_NO_CO_EMCY
511 
512 static void
514 {
515  assert(srv);
516  assert(!(srv->set & CO_NMT_SRV_EMCY));
517  assert(!srv->emcy);
518 
519  srv->set |= CO_NMT_SRV_EMCY;
520 
521  co_obj_t *obj_1001 = co_dev_find_obj(dev, 0x1001);
522  if (!obj_1001)
523  return;
524 
525  srv->emcy = co_emcy_create(net, dev);
526  if (!srv->emcy)
528  "unable to initialize EMCY service");
529 }
530 
531 static void
533 {
534  assert(srv);
535  assert(srv->set & CO_NMT_SRV_EMCY);
536 
537  srv->set &= ~CO_NMT_SRV_EMCY;
538 
539  co_emcy_destroy(srv->emcy);
540  srv->emcy = NULL;
541 }
542 
543 #endif
544 
545 #ifndef LELY_NO_CO_LSS
546 
547 static void
549 {
550  assert(srv);
551  assert(!(srv->set & CO_NMT_SRV_LSS));
552  assert(!srv->lss);
553 
554  if (!co_dev_get_lss(co_nmt_get_dev(nmt)))
555  return;
556 
557  srv->set |= CO_NMT_SRV_LSS;
558 
559  srv->lss = co_lss_create(nmt);
560  if (!srv->lss)
562  "unable to initialize LSS service");
563 }
564 
565 static void
567 {
568  assert(srv);
569  assert(srv->set & CO_NMT_SRV_LSS);
570 
571  srv->set &= ~CO_NMT_SRV_LSS;
572 
573  co_lss_destroy(srv->lss);
574  srv->lss = NULL;
575 }
576 
577 #endif
void co_time_destroy(co_time_t *time)
Destroys a CANopen TIME producer/consumer service.
Definition: time.c:250
void co_sync_destroy(co_sync_t *sync)
Destroys a CANopen SYNC producer/consumer service.
Definition: sync.c:257
A CAN network interface.
Definition: net.c:37
static void co_nmt_srv_fini_lss(struct co_nmt_srv *srv)
Finalizes the EMCY master/slave service.
Definition: nmt_srv.c:566
static void co_nmt_srv_init_pdo(struct co_nmt_srv *srv, can_net_t *net, co_dev_t *dev)
Initializes all Receive/Transmit-PDO services.
Definition: nmt_srv.c:210
static void co_nmt_srv_fini_sync(struct co_nmt_srv *srv)
Finalizes the SYNC producer/consumer service.
Definition: nmt_srv.c:441
A CANopen Receive-PDO.
Definition: rpdo.c:41
This header file is part of the CANopen library; it contains the Transmit-PDO declarations.
co_rpdo_t * co_rpdo_create(can_net_t *net, co_dev_t *dev, co_unsigned16_t num)
Creates a new CANopen Receive-PDO service.
Definition: rpdo.c:273
A CANopen Server-SDO.
Definition: ssdo.c:43
void co_nmt_on_err(co_nmt_t *nmt, co_unsigned16_t eec, co_unsigned8_t er, const co_unsigned8_t msef[5])
Implements the default error handling behavior by generating an EMCY message with co_emcy_push() and ...
Definition: nmt.c:1412
static void co_nmt_srv_fini_pdo(struct co_nmt_srv *srv)
Finalizes all Receive/Transmit-PDO services.
Definition: nmt_srv.c:281
void co_rpdo_destroy(co_rpdo_t *pdo)
Destroys a CANopen Receive-PDO service.
Definition: rpdo.c:300
A CANopen Transmit-PDO.
Definition: tpdo.c:40
co_sync_t * co_sync_create(can_net_t *net, co_dev_t *dev)
Creates a new CANopen SYNC producer/consumer service.
Definition: sync.c:230
co_time_t * co_time_create(can_net_t *net, co_dev_t *dev)
Creates a new CANopen TIME producer/consumer service.
Definition: time.c:223
static void co_nmt_srv_fini_sdo(struct co_nmt_srv *srv)
Finalizes all Server/Client-SDO services.
Definition: nmt_srv.c:391
void co_nmt_srv_set(struct co_nmt_srv *srv, co_nmt_t *nmt, int set)
Enables/disables the specified CANopen services.
Definition: nmt_srv.c:152
void diag(enum diag_severity severity, int errc, const char *format,...)
Emits a diagnostic message.
Definition: diag.c:156
co_tpdo_t * co_tpdo_create(can_net_t *net, co_dev_t *dev, co_unsigned16_t num)
Creates a new CANopen Transmit-PDO service.
Definition: tpdo.c:269
static void co_nmt_srv_init_emcy(struct co_nmt_srv *srv, can_net_t *net, co_dev_t *dev)
Initializes the EMCY producer/consumer service.
Definition: nmt_srv.c:513
#define CO_NMT_SRV_PDO
The Receive/Transmit-PDO services.
Definition: nmt_srv.h:66
A CANopen NMT service manager.
Definition: nmt_srv.h:30
co_nmt_t * nmt
A pointer to the NMT master/slave service.
Definition: nmt_srv.h:32
static void co_nmt_srv_fini_time(struct co_nmt_srv *srv)
Finalizes the TIME producer/consumer service.
Definition: nmt_srv.c:497
void co_ssdo_destroy(co_ssdo_t *sdo)
Destroys a CANopen Server-SDO service.
Definition: ssdo.c:657
co_rpdo_t ** rpdos
An array of pointers to the Receive-PDO services.
Definition: nmt_srv.h:40
This header file is part of the CANopen library; it contains the Client-SDO declarations.
static void co_nmt_srv_fini_emcy(struct co_nmt_srv *srv)
Finalizes the EMCY producer/consumer service.
Definition: nmt_srv.c:532
#define CO_NMT_SRV_SYNC
The SYNC producer/consumer service.
Definition: nmt_srv.h:72
static void co_nmt_srv_rpdo_err(co_rpdo_t *pdo, co_unsigned16_t eec, co_unsigned8_t er, void *data)
Invokes co_nmt_err() to handle Receive-PDO errors.
Definition: nmt_srv.c:309
void set_errc(int errc)
Sets the current (thread-specific) native error code to errc.
Definition: errnum.c:957
co_unsigned8_t ncsdo
The number of Client-SDO services.
Definition: nmt_srv.h:54
void co_tpdo_destroy(co_tpdo_t *pdo)
Destroys a CANopen Transmit-PDO service.
Definition: tpdo.c:296
static void co_nmt_srv_init_sdo(struct co_nmt_srv *srv, can_net_t *net, co_dev_t *dev)
Initializes all Server/Client-SDO services.
Definition: nmt_srv.c:323
#define CO_NUM_PDO
The maximum number of Receive/Transmit-PDOs.
Definition: nmt_srv.c:111
co_csdo_t ** csdos
An array of pointers to the Client-SDO services.
Definition: nmt_srv.h:52
co_tpdo_t ** tpdos
An array of pointers to the Transmit-PDO services.
Definition: nmt_srv.h:44
co_unsigned8_t nssdo
The number of Server-SDO services.
Definition: nmt_srv.h:50
co_unsigned16_t nrpdo
The number of Receive-PDO services.
Definition: nmt_srv.h:42
static void co_nmt_srv_sync_ind(co_sync_t *sync, co_unsigned8_t cnt, void *data)
Invokes co_nmt_sync() to handle SYNC objects.
Definition: nmt_srv.c:453
This header file is part of the CANopen library; it contains the emergency (EMCY) object declarations...
void co_nmt_srv_init(struct co_nmt_srv *srv, co_nmt_t *nmt)
Initializes a CANopen NMT service manager.
Definition: nmt_srv.c:117
#define CO_NMT_SRV_EMCY
The EMCY producer/consumer service.
Definition: nmt_srv.h:78
#define CO_NMT_SRV_TIME
The TIME producer/consumer service.
Definition: nmt_srv.h:75
This is the internal header file of the CANopen library.
#define CO_NUM_SDO
The maximum number of Client/Server-SDOs.
Definition: nmt_srv.c:114
int get_errc(void)
Returns the last (thread-specific) native error code set by a system call or library function...
Definition: errnum.c:947
co_ssdo_t ** ssdos
An array of pointers to the Server-SDO services.
Definition: nmt_srv.h:48
A CANopen Client-SDO.
Definition: csdo.c:45
void co_nmt_on_sync(co_nmt_t *nmt, co_unsigned8_t cnt)
Implements the default behavior after a SYNC object is received or transmitted.
Definition: nmt.c:1386
A CANopen NMT master/slave service.
Definition: nmt.c:104
This header file is part of the CANopen library; it contains the Receive-PDO declarations.
void co_emcy_destroy(co_emcy_t *emcy)
Destroys a CANopen EMCY producer/consumer service.
Definition: emcy.c:351
An error.
Definition: diag.h:49
static void co_nmt_srv_sync_err(co_sync_t *sync, co_unsigned16_t eec, co_unsigned8_t er, void *data)
Invokes co_nmt_err() to handle SYNC errors.
Definition: nmt_srv.c:463
int errno2c(int errnum)
Transforms a standard C error number to a native error code.
Definition: errnum.c:43
This header file is part of the utilities library; it contains the diagnostic declarations.
co_emcy_t * co_emcy_create(can_net_t *net, co_dev_t *dev)
Creates a new CANopen EMCY producer/consumer service.
Definition: emcy.c:324
void co_nmt_srv_fini(struct co_nmt_srv *srv)
Finalizes a CANopen NMT service manager.
Definition: nmt_srv.c:144
void co_sync_set_err(co_sync_t *sync, co_sync_err_t *err, void *data)
Sets the error handling function of a SYNC consumer service.
Definition: sync.c:314
can_net_t * co_nmt_get_net(const co_nmt_t *nmt)
Returns a pointer to the CAN network of an NMT master/slave service.
Definition: nmt.c:1077
A CANopen device.
Definition: dev.c:41
co_csdo_t * co_csdo_create(can_net_t *net, co_dev_t *dev, co_unsigned8_t num)
Creates a new CANopen Client-SDO service.
Definition: csdo.c:868
This header file is part of the CANopen library; it contains the time stamp (TIME) object declaration...
void co_sync_set_ind(co_sync_t *sync, co_sync_ind_t *ind, void *data)
Sets the indication function invoked after a CANopen SYNC message is received or transmitted.
Definition: sync.c:294
can_net_t * net
A pointer to a CAN network interface.
Definition: nmt_hb.c:35
co_nmt_t * nmt
A pointer to an NMT master/slave service.
Definition: nmt_hb.c:37
void co_csdo_destroy(co_csdo_t *sdo)
Destroys a CANopen Client-SDO service.
Definition: csdo.c:895
This header file is part of the CANopen library; it contains the Layer Setting Services (LSS) and pro...
This header file is part of the CANopen library; it contains the synchronization (SYNC) object declar...
co_unsigned16_t ntpdo
The number of Transmit-PDO services.
Definition: nmt_srv.h:46
void co_lss_destroy(co_lss_t *lss)
Destroys a CANopen LSS master/slave service.
Definition: lss.c:797
co_emcy_t * emcy
A pointer to the EMCY producer/consumer service.
Definition: nmt_srv.h:60
This header file is part of the CANopen library; it contains the device description declarations...
co_lss_t * lss
A pointer to the LSS master/slave service.
Definition: nmt_srv.h:62
co_time_t * time
A pointer to the TIME producer/consumer service.
Definition: nmt_srv.h:58
co_sync_t * sync
A pointer to the SYNC producer/consumer service.
Definition: nmt_srv.h:56
#define CO_NMT_SRV_SDO
The Server/Client-SDO services.
Definition: nmt_srv.h:69
This header file is part of the CANopen library; it contains the Server-SDO declarations.
int set
The currently enabled CANopen services (any combination of CO_NMT_SRV_PDO, CO_NMT_SRV_SDO, CO_NMT_SRV_SYNC, CO_NMT_SRV_TIME and CO_NMT_SRV_EMCY).
Definition: nmt_srv.h:38
This header file is part of the C11 and POSIX compatibility library; it includes <stdlib.h> and defines any missing functionality.
co_ssdo_t * co_ssdo_create(can_net_t *net, co_dev_t *dev, co_unsigned8_t num)
Creates a new CANopen Server-SDO service.
Definition: ssdo.c:630
int co_dev_get_lss(const co_dev_t *dev)
Returns 1 if LSS is supported and 0 if not.
Definition: dev.c:524
#define CO_NMT_SRV_LSS
The LSS master/slave service.
Definition: nmt_srv.h:81
static void co_nmt_srv_init_sync(struct co_nmt_srv *srv, can_net_t *net, co_dev_t *dev)
Initializes the SYNC producer/consumer service.
Definition: nmt_srv.c:418
A CANopen SYNC producer/consumer service.
Definition: sync.c:40
co_dev_t * co_nmt_get_dev(const co_nmt_t *nmt)
Returns a pointer to the CANopen device of an NMT master/slave service.
Definition: nmt.c:1085
A CANopen object.
Definition: obj.h:32
co_obj_t * co_dev_find_obj(const co_dev_t *dev, co_unsigned16_t idx)
Finds an object in the object dictionary of a CANopen device.
Definition: dev.c:288
This is the internal header file of the NMT service manager declarations.
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
static void co_nmt_srv_init_time(struct co_nmt_srv *srv, can_net_t *net, co_dev_t *dev)
Initializes the TIME producer/consumer service.
Definition: nmt_srv.c:478
static void co_nmt_srv_init_lss(struct co_nmt_srv *srv, co_nmt_t *nmt)
Initializes the LSS master/slave service.
Definition: nmt_srv.c:548
co_lss_t * co_lss_create(co_nmt_t *nmt)
Creates a new CANopen LSS master/slave service.
Definition: lss.c:770