CANopenNode
CANopen protocol stack
Loading...
Searching...
No Matches
Reception of CAN messages
+ Collaboration diagram for Reception of CAN messages:

Data Structures

struct  CO_CANrx_t
 Configuration object for CAN received message for specific CANopenNode Object. More...
 

Functions

void CANrx_callback (void *object, void *rxMsg)
 CAN receive callback function which pre-processes received CAN message.
 
static uint16_t CO_CANrxMsg_readIdent (void *rxMsg)
 CANrx_callback() can read CAN identifier from received CAN message.
 
static uint8_t CO_CANrxMsg_readDLC (void *rxMsg)
 CANrx_callback() can read Data Length Code from received CAN message.
 
static const uint8_tCO_CANrxMsg_readData (void *rxMsg)
 CANrx_callback() can read pointer to data from received CAN message.
 

Detailed Description

Target specific definitions and description of CAN message reception

CAN messages in CANopenNode are usually received by its own thread or higher priority interrupt. Received CAN messages are first filtered by hardware or by software. Thread then examines its 11-bit CAN-id and mask and determines, to which CANopenNode Object it belongs to. After that it calls predefined CANrx_callback() function, which quickly pre-processes the message and fetches the relevant data. CANrx_callback() function is defined by each CANopenNode Object separately. Pre-processed fetched data are later processed in another thread.

If CANopenNode Object reception of specific CAN message, it must first configure its own CO_CANrx_t object with the CO_CANrxBufferInit() function.

Function Documentation

◆ CANrx_callback()

void CANrx_callback ( void * object,
void * rxMsg )

CAN receive callback function which pre-processes received CAN message.

It is called by fast CAN receive thread. Each CANopenNode Object defines its own and registers it with CO_CANrxBufferInit(), by passing function pointer.

Parameters
objectpointer to specific CANopenNode Object, registered with CO_CANrxBufferInit()
rxMsgpointer to received CAN message

◆ CO_CANrxMsg_readIdent()

static uint16_t CO_CANrxMsg_readIdent ( void * rxMsg)
inlinestatic

CANrx_callback() can read CAN identifier from received CAN message.

Must be defined in the CO_driver_target.h file.

This is target specific function and is specific for specific microcontroller. It is best to implement it by using inline function or macro. rxMsg parameter should cast to a pointer to structure. For best efficiency structure may have the same alignment as CAN registers inside CAN module.

Parameters
rxMsgPointer to received message
Returns
11-bit CAN standard identifier.

◆ CO_CANrxMsg_readDLC()

static uint8_t CO_CANrxMsg_readDLC ( void * rxMsg)
inlinestatic

CANrx_callback() can read Data Length Code from received CAN message.

See also CO_CANrxMsg_readIdent():

Parameters
rxMsgPointer to received message
Returns
data length in bytes (0 to 8)

◆ CO_CANrxMsg_readData()

static const uint8_t * CO_CANrxMsg_readData ( void * rxMsg)
inlinestatic

CANrx_callback() can read pointer to data from received CAN message.

See also CO_CANrxMsg_readIdent():

Parameters
rxMsgPointer to received message
Returns
pointer to data buffer