Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

To get a higher level of abstraction, the CAN signals Signals and messages Messages can be used to abstract the information mappings to the bus Bus communication objects. In this topic example, the information from the 'Nodestatus' and 'CPU-Load' will be sent in a CAN Frame called 'Status' and updated through a CAN Frame called 'Command' with the following definitions:

Signal Configuration
Anchor
ex_sig&message_definitions_signals
ex_sig&message_definitions_signals

The Message Configuration below uses CAN Signals

Message Configuration

The Message Configuration can be found in can_cfg.c. However, the "Message Enumerations" are typically found in can_cfg.h. Please note that CAN Signals must be configured prior to be used in CAN Messages. For more information on CAN Messages click Here.

Code Block
languagecpp
linenumberstrue
#include  "can_msg.h"

enum {                                           [1]            /* --------------- MESSAGE ENUMERATIONS --------------- */
   M_STATUS = 0, 
   M_COMMAND, 
   M_MAX
};

const  CANMSG_PARA  CanMsg[CANMSG_N] =           [2]
{ 
                                                                /* ------------------ MESSAGE STATUS ------------------ */
   { 0x123L,                                     [3A]           /*      CAN-Identifier                                  */  
     CANMSG_TX,                                   [B]           /*      Message Type                                    */ 
     2,                                           [C]           /*      DLC of Message                                  */ 
     2,                                                         /*      No. of Links                                    */ 
      { { S_NODESTATUS,                           [D]           /*      Signal ID                                       */ 
         0 },                                     [E]           /*      Byte Position                                   */ 
        { S_CPULOAD,                                            /*      Signal ID                                       */ 
         2 }                                                    /*      Byte Position                                   */ 
      },
   },
                                                                /* ----------------- MESSAGE COMMAND ------------------ */
   { 0x122L,                                     [4A]           /*      CAN-Identifier                                  */ 
     CANMSG_RX,                                   [B]           /*      Message Type                                    */ 
     1,                                           [C]           /*      DLC of Message                                  */ 
     1,                                                         /*      No. of Links                                    */ 
     { { S_NODESTATUS,                            [D]           /*      Signal ID                                       */ 
         0 }                                      [E]           /*      Byte Position                                   */ 
     }
   }
}; 

Notes:

  • A CAN Message can be defined without any knowledge of the information generated and/or the usage of the payload. Only the mapping of the payload (and it's respective parts) must be known.

 

Example

The information Nodestatus and CPU-Load shall be sent in a CAN frame called Status with the following definition:

...

  1. The CAN signals can be defined without any CAN communication knowledge. No information about sending or receiving the information is needed during this state.
  2. The enumeration is used to simplify the message definition and ensure to get a consistent message to signal mapping.
  3. The CAN signal configuration is done as a global constant to safe RAM space and get a write protected configuration.
  4. This variable must be declared globally, because the configuration data will be read while using the CAN signal layer.
  5. The callback function definition may be omitted by configuring the CANSIG_CALLBACK_EN parameter to 0.

Source code (Part 2)

Additional Information

...