CANopenNode
CO_error.h
Go to the documentation of this file.
1 
28 #ifndef CO_ERROR_H
29 #define CO_ERROR_H
30 
31 #include <stdint.h>
32 #include <errno.h>
33 #include <string.h>
34 #include <linux/can.h>
35 #include <net/if.h>
36 
37 #if __has_include("CO_error_custom.h")
38  #include "CO_error_custom.h"
39 #else
40  #include "CO_error_msgs.h"
41 #endif
42 
43 #ifdef __cplusplus
44 extern "C" {
45 #endif
46 
75 void log_printf(int priority, const char *format, ...);
76 
77 
86 typedef enum {
91 
92 
98 #define CO_CANerror_NOACK_MAX 16
99 
100 
107 #define CO_CANerror_LISTEN_ONLY 10
108 
109 
113 typedef struct {
114  int fd;
115  char ifName[IFNAMSIZ];
117  volatile unsigned char listenOnly;
118  struct timespec timestamp;
121 
122 
132 void CO_CANerror_init(
133  CO_CANinterfaceErrorhandler_t *CANerrorhandler,
134  int fd,
135  const char *ifname);
136 
137 
144  CO_CANinterfaceErrorhandler_t *CANerrorhandler);
145 
146 
155 void CO_CANerror_rxMsg(
156  CO_CANinterfaceErrorhandler_t *CANerrorhandler);
157 
158 
168  CO_CANinterfaceErrorhandler_t *CANerrorhandler);
169 
170 
181  CO_CANinterfaceErrorhandler_t *CANerrorhandler,
182  const struct can_frame *msg);
183 
184 
187 #ifdef __cplusplus
188 }
189 #endif /*__cplusplus*/
190 
191 #endif /* CO_ERROR_H */
uint32_t
unsigned long int uint32_t
UNSIGNED32 in CANopen (0007h), 32-bit unsigned integer.
Definition: CO_driver.h:155
log_printf
void log_printf(int priority, const char *format,...)
Message logging function.
Definition: CO_main_basic.c:137
CO_CANinterfaceErrorhandler_t::CANerrorStatus
uint16_t CANerrorStatus
CAN error status bitfield, see CO_CAN_ERR_status_t.
Definition: CO_error.h:119
uint16_t
unsigned int uint16_t
UNSIGNED16 in CANopen (0006h), 16-bit unsigned integer.
Definition: CO_driver.h:153
CO_CANerror_disable
void CO_CANerror_disable(CO_CANinterfaceErrorhandler_t *CANerrorhandler)
Reset CAN error handler.
Definition: CO_error.c:224
CO_INTERFACE_LISTEN_ONLY
@ CO_INTERFACE_LISTEN_ONLY
CAN error passive/active, but currently no other device on bus.
Definition: CO_error.h:88
CO_INTERFACE_BUS_OFF
@ CO_INTERFACE_BUS_OFF
CAN bus off.
Definition: CO_error.h:89
CO_CANinterfaceState_t
CO_CANinterfaceState_t
driver interface state
Definition: CO_error.h:86
CO_INTERFACE_ACTIVE
@ CO_INTERFACE_ACTIVE
CAN error passive/active.
Definition: CO_error.h:87
CO_CANerror_rxMsgError
CO_CANinterfaceState_t CO_CANerror_rxMsgError(CO_CANinterfaceErrorhandler_t *CANerrorhandler, const struct can_frame *msg)
Error message received event.
Definition: CO_error.c:277
CO_CANerror_rxMsg
void CO_CANerror_rxMsg(CO_CANinterfaceErrorhandler_t *CANerrorhandler)
Message received event.
Definition: CO_error.c:237
CO_CANinterfaceErrorhandler_t::noackCounter
uint32_t noackCounter
counts no ACK on CAN transmission
Definition: CO_error.h:116
CO_CANinterfaceErrorhandler_t::listenOnly
volatile unsigned char listenOnly
set to listen only mode
Definition: CO_error.h:117
CO_CANerror_txMsg
CO_CANinterfaceState_t CO_CANerror_txMsg(CO_CANinterfaceErrorhandler_t *CANerrorhandler)
Check if interface is ready for message transmission.
Definition: CO_error.c:253
CO_CANinterfaceErrorhandler_t::fd
int fd
interface FD
Definition: CO_error.h:114
CO_CANerror_init
void CO_CANerror_init(CO_CANinterfaceErrorhandler_t *CANerrorhandler, int fd, const char *ifname)
Initialize CAN error handler.
Definition: CO_error.c:204
CO_CANinterfaceErrorhandler_t
socketCAN interface error handling
Definition: CO_error.h:113