Files | |
file | CO_error.h |
CANopenNode Linux socketCAN Error handling. | |
Data Structures | |
struct | CO_CANinterfaceErrorhandler_t |
socketCAN interface error handling More... | |
Macros | |
#define | CO_CANerror_NOACK_MAX 16 |
This is how many NO-ACKs need to be received in a row to assume that no other nodes are connected to a bus and therefore are assuming listen-only. | |
#define | CO_CANerror_LISTEN_ONLY 10 |
This is how long we are going to block transmission if listen-only mode is active. More... | |
Enumerations | |
enum | CO_CANinterfaceState_t { CO_INTERFACE_ACTIVE, CO_INTERFACE_LISTEN_ONLY, CO_INTERFACE_BUS_OFF } |
driver interface state More... | |
Functions | |
void | log_printf (int priority, const char *format,...) |
Message logging function. More... | |
void | CO_CANerror_init (CO_CANinterfaceErrorhandler_t *CANerrorhandler, int fd, const char *ifname) |
Initialize CAN error handler. More... | |
void | CO_CANerror_disable (CO_CANinterfaceErrorhandler_t *CANerrorhandler) |
Reset CAN error handler. More... | |
void | CO_CANerror_rxMsg (CO_CANinterfaceErrorhandler_t *CANerrorhandler) |
Message received event. More... | |
CO_CANinterfaceState_t | CO_CANerror_txMsg (CO_CANinterfaceErrorhandler_t *CANerrorhandler) |
Check if interface is ready for message transmission. More... | |
CO_CANinterfaceState_t | CO_CANerror_rxMsgError (CO_CANinterfaceErrorhandler_t *CANerrorhandler, const struct can_frame *msg) |
Error message received event. More... | |
CANopen Errors and System message log
#define CO_CANerror_LISTEN_ONLY 10 |
This is how long we are going to block transmission if listen-only mode is active.
Time is in seconds.
driver interface state
CAN hardware can be in the followning states:
Enumerator | |
---|---|
CO_INTERFACE_ACTIVE | CAN error passive/active. |
CO_INTERFACE_LISTEN_ONLY | CAN error passive/active, but currently no other device on bus. |
CO_INTERFACE_BUS_OFF | CAN bus off. |
void log_printf | ( | int | priority, |
const char * | format, | ||
... | |||
) |
Message logging function.
Function must be defined by application. It should record log message to some place, for example syslog() call in Linux or logging functionality in CANopen gateway Gateway ASCII mapping.
By default system stores messages in /var/log/syslog file. Log can optionally be configured before, for example to filter out less critical errors than LOG_NOTICE, specify program name, print also process PID and print also to standard error, set 'user' type of program, use:
priority | one of LOG_EMERG, LOG_ALERT, LOG_CRIT, LOG_ERR, LOG_WARNING, LOG_NOTICE, LOG_INFO, LOG_DEBUG |
format | format string as in printf |
void CO_CANerror_init | ( | CO_CANinterfaceErrorhandler_t * | CANerrorhandler, |
int | fd, | ||
const char * | ifname | ||
) |
Initialize CAN error handler.
We need one error handler per interface
CANerrorhandler | This object will be initialized. |
fd | interface file descriptor |
ifname | interface name as string |
void CO_CANerror_disable | ( | CO_CANinterfaceErrorhandler_t * | CANerrorhandler | ) |
Reset CAN error handler.
CANerrorhandler | CAN error object. |
void CO_CANerror_rxMsg | ( | CO_CANinterfaceErrorhandler_t * | CANerrorhandler | ) |
Message received event.
When a message is received at least one other CAN module is connected. Function clears listenOnly and noackCounter error flags.
CANerrorhandler | CAN error object. |
CO_CANinterfaceState_t CO_CANerror_txMsg | ( | CO_CANinterfaceErrorhandler_t * | CANerrorhandler | ) |
Check if interface is ready for message transmission.
Message mustn't be transmitted if not ready.
CANerrorhandler | CAN error object. |
CO_CANinterfaceState_t CO_CANerror_rxMsgError | ( | CO_CANinterfaceErrorhandler_t * | CANerrorhandler, |
const struct can_frame * | msg | ||
) |
Error message received event.
This handles all received error messages.
CANerrorhandler | CAN error object. |
msg | received error message |