To get a higher level of abstraction, the CAN signals and messages can be used to abstract the information mappings to the bus communication objects.
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
- The CAN signals can be defined without any CAN communication knowledge. No information about sending or receiving the information is needed during this state.
- The enumeration is used to simplify the message definition and ensure to get a consistent message to signal mapping.
- The CAN signal configuration is done as a global constant to safe RAM space and get a write protected configuration.
- This variable must be declared globally, because the configuration data will be read while using the CAN signal layer.
- The callback function definition may be omitted by configuring the
CANSIG_CALLBACK_EN
parameter to 0.
Source code (Part 2)
Additional Information
- The CAN messages can be defined without any knowledge of the information generation and/or usage of the payload. Only the mapping of information parts to the payload must be known.
- The enumeration is used to simplify the message handling.
- The CAN message configuration is done as a global constant to safe RAM space and get a write protected configuration.
- This variable must be declared globally, because the configuration data will be read while using the CAN message layer.