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

« Previous Version 5 Next »

Sending and receiving CAN frames can be implemented in different ways. The simplest way is to disable all upper layers and use the CAN frames directly. When using an operating system (e.g. μC/OS), the RX and TX communication could be performed within two tasks.

Example

The CAN frame reception shall be done within a single RX-Task. Any received CAN frame shall be send back with the fixed CAN Identifier: 0x100.

Source code

Description

  1. Local variable to hold the received and echoed CAN frame.
  2. Set the RX timeout to 0 to enable the blocking mode, e.g. the function CanBusRead() will wait for a CAN frame forever. Otherwise set a timeout and check returned error code of -3- if a timeout has occurred.
  3. Wait for the next received CAN frame.
  4. After reception, change the CAN-Identifier in received frame
  5. Send the received CAN frame with changed CAN-Identifier
  • No labels