Versions Compared

Key

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

To get a higher level of abstraction, CAN Signals and Messages can be used to abstract information mappings to the 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 Signal and Message definitions:

Signal Configuration
Anchor
ex_sig&message_definitions_signals
ex_sig&message_definitions_signals

The Message Configuration below uses CAN Signals. Before CAN Messages can be used, each CAN signal must be configured accordingly. The Signal Configuration can be found in can_cfg.c. However, the "Signal Enumerations" are typically found in can_cfg.h. Signals allow the user to not worry about where a given signal if found within a CAN Frame, while containing different types of data. For more information about CAN Signals click Here.

...

Code Block
languagecpp
linenumberstrue
#include  "can_sig.h"

enum {                                           [1]            /* ---------------- SIGNAL ENUMERATIONS --------------- */
   S_NODESTATUS = 0, 
   S_CPULOAD,
   S_MAX,
};

const  CANSIG_PARA  CanSig[CANSIG_N] = {         [2]
                                                                /* ---------------- SIGNAL NODESTATUS ----------------- */
    {CANSIG_UNCHANGED,                           [3A]           /*      Initial Status                                  */ 
      1,                                          [B]           /*      Width in Bytes                                  */ 
      0,                                          [C]           /*      Initial Value                                   */ 
#if (CANSIG_CALLBACK_EN > 0)
      StatusChange},                              [D]           /*      Callback Function: User Defined                 */ 
#else
    },
#endif
                                                                /* ----------------- SIGNAL CPULOAD ------------------- */ 
    {CANSIG_UNCHANGED,                           [3A]           /*      Initial Status                                  */ 
      1,                                          [B]           /*      Width in Bytes                                  */ 
      0,                                          [C]           /*      Initial Value                                   */ 
#if (CANSIG_CALLBACK_EN > 0)
      0}                                          [D]           /*      No Callback                                     */ 
#else
    },
#endif
}; 

 

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                                   */ 
     }
   }
}; 

 

Example

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

CAN-Identifier = 0x150

      DLC            = 2
      Payload Byte 0 = Current Nodestatus
      Payload Byte 1 = CPU-Load
  

The Nodestatus shall be settable via the CAN frame called Command with the following definition:

      CAN-Identifier = 0x140
      DLC            = 1
      Payload Byte 0 = New Nodestatus

If the information Nodestatus is changed, the following actions shall be done:

New Nodestatus = 1: Start the task Load-Task
New Nodestatus = 2: Stop the task Load-Task

Source code (Part 1)

Additional Information

...