|
This function allows a user-defined function to be called when certain events occur on the bus.
canNOTIFY_RX | CAN message reception notification. |
canNOTIFY_TX | CAN message transmission notification. |
canNOTIFY_ERROR | CAN bus error notification. |
canNOTIFY_STATUS | CAN chip status change. |
None.
canOK (zero) if success
canERR_xxx (negative) if failure.
When one of the above events take place, the 'callback function is called with a canNotityData struct as an argument which looks like:
typedef struct canNotifyData {
void *tag;
int eventType;
union {
struct {
unsigned long time;
} busErr;
struct {
long id;
unsigned long time;
} rx;
struct {
long id;
unsigned long time;
} tx;
struct {
unsigned char busStatus;
unsigned char txErrorCounter;
unsigned char rxErrorCounter;
unsigned long time;
} status;
} info;
} canNotifyData;
The 'info' field in the struct is a union that depends on eventType as follows:
canEVENT_RX | A CAN message has been received. The struct info.rx contains the id and reception time of the received message. |
canEVENT_TX | A CAN message has been transmitted. The struct info.tx contains the id and transmission time of the transmitted message. |
canEVENT_ERROR | A CAN bus error is reported by the CAN controller The struct info.busErr contains the time the error was detected. |
canEVENT_STATUS | The CAN controller changes state The struct info.status contains busstatus, transmit and receive errorcounters and time of the statechange. |
The tag field in canNotifyData is a void pointer. This can be used as a reference to some data associated with a specific channel/handle.