CO_error.h
Go to the documentation of this file.
#ifndef CO_ERROR_H
#define CO_ERROR_H
#include <stdint.h>
#include <errno.h>
#include <string.h>
#include <linux/can.h>
#include <net/if.h>
#if __has_include("CO_error_custom.h")
#include "CO_error_custom.h"
#else
#include "CO_error_msgs.h"
#endif
#ifdef __cplusplus
extern "C" {
#endif
void log_printf(int priority, const char *format, ...);
typedef enum {
CO_INTERFACE_ACTIVE,
CO_INTERFACE_LISTEN_ONLY,
CO_INTERFACE_BUS_OFF
} CO_CANinterfaceState_t;
#define CO_CANerror_NOACK_MAX 16
#define CO_CANerror_LISTEN_ONLY 10
typedef struct {
int fd;
char ifName[IFNAMSIZ];
uint32_t noackCounter;
volatile unsigned char listenOnly;
struct timespec timestamp;
uint16_t CANerrorStatus;
} CO_CANinterfaceErrorhandler_t;
void CO_CANerror_init(
CO_CANinterfaceErrorhandler_t *CANerrorhandler,
int fd,
const char *ifname);
void CO_CANerror_disable(
CO_CANinterfaceErrorhandler_t *CANerrorhandler);
void CO_CANerror_rxMsg(
CO_CANinterfaceErrorhandler_t *CANerrorhandler);
CO_CANinterfaceState_t CO_CANerror_txMsg(
CO_CANinterfaceErrorhandler_t *CANerrorhandler);
CO_CANinterfaceState_t CO_CANerror_rxMsgError(
CO_CANinterfaceErrorhandler_t *CANerrorhandler,
const struct can_frame *msg);
#ifdef __cplusplus
}
#endif /*__cplusplus*/
#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