Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

Version 1 Next »

The communication protocol uses in most cases only the CAN messages. The application is responsible for the values of the mapped CAN signals. The following source code completes the example, started in chapter 6.4 Defining CAN Signals and Messages:

Source code (Protocol RX-Task):

This task could be started within Com_Start() to enable the receive activities as soon as the CAN bus is active.

Description

  • Local variable to hold the received CAN frame.
  • Local variable to hold the handle to message of received CAN identifier
  • Set the RX timeout to 0 to enable the blocking mode, e.g. the function CanBusRead() will wait forever for a CAN frame.
  • Wait for the next received CAN frame on CAN node 0.
  • After reception, open the message with the received identifier.
  • On success, write the received CAN frame to this message. This results in decomposing the CAN frame to all linked CAN signals.
  • Source code (Protocol Transmit Status):

    This function can be called in your transmission task to transmit a specific CAN message, or called within a callback function to transmit information in response to a received CAN message.

    Description

  • Local variable to hold the CAN frame for transmission.
  • Local variable to hold the handle to message which shall be transmitted
  • Open the CAN message with the CAN-Identifier 0x150.
  • On success, read the message to the local CAN frame. This results in collecting all linked signals and writing all information to the CAN frame at the defined locations.
  • Send this constructed CAN frame via the CAN bus 0.
    • No labels