Lely core libraries  2.2.5
wtm.h
Go to the documentation of this file.
1 
22 #ifndef LELY_CO_WTM_H_
23 #define LELY_CO_WTM_H_
24 
25 #include <lely/can/msg.h>
26 #include <lely/co/co.h>
27 #include <lely/libc/time.h>
28 
33 #define CO_WTM_MAX_LEN 261
34 
36 #define CO_WTM_AC_ERROR UINT32_C(0x01000000)
37 
39 #define CO_WTM_AC_TIMEOUT UINT32_C(0x01000001)
40 
42 #define CO_WTM_AC_NO_MEM UINT32_C(0x01000002)
43 
45 #define CO_WTM_AC_HARDWARE UINT32_C(0x01000003)
46 
51 #define CO_WTM_AC_DATA UINT32_C(0x01000004)
52 
57 #define CO_WTM_AC_DATA_CTL UINT32_C(0x01000005)
58 
63 #define CO_WTM_AC_DATA_DEV UINT32_C(0x01000006)
64 
66 #define CO_WTM_AC_NO_DATA UINT32_C(0x01000007)
67 
69 #define CO_WTM_AC_NO_IF UINT32_C(0x01000008)
70 
72 #define CO_WTM_AC_IF_DOWN UINT32_C(0x01000009)
73 
75 #define CO_WTM_AC_DIAG UINT32_C(0x0100000a)
76 
81 #define CO_WTM_AC_DIAG_CAN UINT32_C(0x0100000b)
82 
87 #define CO_WTM_AC_DIAG_WTM UINT32_C(0x0100000c)
88 
90 #define CO_WTM_AC_FRAME UINT32_C(0x02000000)
91 
93 #define CO_WTM_AC_PREAMBLE UINT32_C(0x02000001)
94 
96 #define CO_WTM_AC_SEQ UINT32_C(0x02000002)
97 
99 #define CO_WTM_AC_TYPE UINT32_C(0x02000003)
100 
102 #define CO_WTM_AC_PAYLOAD UINT32_C(0x02000004)
103 
105 #define CO_WTM_AC_CRC UINT32_C(0x02000005)
106 
108 #define CO_WTM_AC_CAN UINT32_C(0x02000006)
109 
110 struct __co_wtm;
111 #ifndef __cplusplus
112 typedef struct __co_wtm co_wtm_t;
114 #endif
115 
116 #ifdef __cplusplus
117 extern "C" {
118 #endif
119 
144 typedef void co_wtm_diag_can_con_t(co_wtm_t *wtm, uint_least8_t nif,
145  uint_least8_t st, uint_least8_t err, uint_least8_t load,
146  uint_least16_t ec, uint_least16_t foc, uint_least16_t coc,
147  void *data);
148 
159 typedef void co_wtm_diag_wtm_con_t(co_wtm_t *wtm, uint_least8_t nif,
160  uint_least8_t quality, void *data);
161 
171  co_wtm_t *wtm, uint_least8_t nif, void *data);
172 
180 typedef void co_wtm_diag_wtm_ind_t(co_wtm_t *wtm, void *data);
181 
190 typedef void co_wtm_diag_ac_ind_t(co_wtm_t *wtm, uint_least32_t ac, void *data);
191 
206 typedef int co_wtm_recv_func_t(co_wtm_t *wtm, uint_least8_t nif,
207  const struct timespec *tp, const struct can_msg *msg,
208  void *data);
209 
222 typedef int co_wtm_send_func_t(
223  co_wtm_t *wtm, const void *buf, size_t nbytes, void *data);
224 
226 const char *co_wtm_ac_str(uint_least32_t ac);
227 
228 void *__co_wtm_alloc(void);
229 void __co_wtm_free(void *ptr);
230 struct __co_wtm *__co_wtm_init(struct __co_wtm *wtm);
231 void __co_wtm_fini(struct __co_wtm *wtm);
232 
241 co_wtm_t *co_wtm_create(void);
242 
248 void co_wtm_destroy(co_wtm_t *wtm);
249 
255 uint_least8_t co_wtm_get_nif(const co_wtm_t *wtm);
256 
268 int co_wtm_set_nif(co_wtm_t *wtm, uint_least8_t nif);
269 
295 int co_wtm_set_diag_can(co_wtm_t *wtm, uint_least8_t nif, uint_least8_t st,
296  uint_least8_t err, uint_least8_t load, uint_least16_t ec,
297  uint_least16_t foc, uint_least16_t coc);
298 
309 int co_wtm_set_diag_wtm(co_wtm_t *wtm, uint_least8_t quality);
310 
324  void **pdata);
325 
338  co_wtm_t *wtm, co_wtm_diag_can_con_t *con, void *data);
339 
353  void **pdata);
354 
367  co_wtm_t *wtm, co_wtm_diag_wtm_con_t *con, void *data);
368 
382  void **pdata);
383 
396  co_wtm_t *wtm, co_wtm_diag_can_ind_t *con, void *data);
397 
411  void **pdata);
412 
425  co_wtm_t *wtm, co_wtm_diag_wtm_ind_t *con, void *data);
426 
440  const co_wtm_t *wtm, co_wtm_diag_ac_ind_t **pind, void **pdata);
441 
456  co_wtm_t *wtm, co_wtm_diag_ac_ind_t *ind, void *data);
457 
467 void co_wtm_recv(co_wtm_t *wtm, const void *buf, size_t nbytes);
468 
482  const co_wtm_t *wtm, co_wtm_recv_func_t **pfunc, void **pdata);
483 
495 void co_wtm_set_recv_func(co_wtm_t *wtm, co_wtm_recv_func_t *func, void *data);
496 
509 int co_wtm_get_time(
510  const co_wtm_t *wtm, uint_least8_t nif, struct timespec *tp);
511 
525 int co_wtm_set_time(
526  co_wtm_t *wtm, uint_least8_t nif, const struct timespec *tp);
527 
541 int co_wtm_send(co_wtm_t *wtm, uint_least8_t nif, const struct can_msg *msg);
542 
550 int co_wtm_send_alive(co_wtm_t *wtm);
551 
562 int co_wtm_send_diag_can_req(co_wtm_t *wtm, uint_least8_t nif);
563 
574 int co_wtm_send_diag_wtm_req(co_wtm_t *wtm, uint_least8_t nif);
575 
585 int co_wtm_send_diag_can_rst(co_wtm_t *wtm, uint_least8_t nif);
586 
596 int co_wtm_send_diag_wtm_rst(co_wtm_t *wtm, uint_least8_t nif);
597 
608 int co_wtm_send_diag_ac(co_wtm_t *wtm, uint_least32_t ac);
609 
617 int co_wtm_flush(co_wtm_t *wtm);
618 
632  const co_wtm_t *wtm, co_wtm_send_func_t **pfunc, void **pdata);
633 
645 void co_wtm_set_send_func(co_wtm_t *wtm, co_wtm_send_func_t *func, void *data);
646 
647 #ifdef __cplusplus
648 }
649 #endif
650 
651 #endif // !LELY_CO_WTM_H_
A CAN or CAN FD format frame.
Definition: msg.h:87
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:790
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:990
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:434
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:425
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:1065
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:1008
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:413
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:347
uint_least8_t nif
The WTM interface indicator.
Definition: wtm.c:90
This is the public header file of the CANopen library.
int co_wtm_flush(co_wtm_t *wtm)
Flushes the current send buffer of a CANopen WTM interface.
Definition: wtm.c:1023
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:806
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:455
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:518
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:781
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
uint_least8_t co_wtm_get_nif(const co_wtm_t *wtm)
Returns the interface indicator of a CANopen WTM interface.
Definition: wtm.c:324
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
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:972
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:509
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:476
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:332
uint_least8_t quality
The link quality percentage (in the range [0..100], or 0xff if the information is not available)...
Definition: wtm.c:95
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_send_diag_can_req(co_wtm_t *wtm, uint_least8_t nif)
Sends a CAN communication quality request.
Definition: wtm.c:936
int co_wtm_send_diag_wtm_req(co_wtm_t *wtm, uint_least8_t nif)
Sends a WTM communication quality request.
Definition: wtm.c:954
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:1053
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_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:446
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:840
A CANopen Wireless Transmission Media (WTM) interface.
Definition: wtm.c:88
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:769
int co_wtm_send_alive(co_wtm_t *wtm)
Sends a keep-alive message from a CANopen WTM interface.
Definition: wtm.c:922
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:398
const char * co_wtm_ac_str(uint_least32_t ac)
Returns a string describing a CANopen WTM abort code.
Definition: wtm.c:181
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
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_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:488
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:497
co_wtm_t * co_wtm_create(void)
Creates a new CANopen Wireless Transmission Media (WTM) interface.
Definition: wtm.c:290
This header file is part of the CAN library; it contains the CAN frame declarations.
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
This header file is part of the C11 and POSIX compatibility library; it includes <time.h> and defines any missing functionality.
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:467
void co_wtm_destroy(co_wtm_t *wtm)
Destroys a CANopen Wireless Transmission Media (WTM) interface.
Definition: wtm.c:315