Skip to main content

Configuring and Testing CAN Interfaces

Configuring CAN

If DCAN0 is used on a BeagleBone Black, then it conflicts with the I2C-2 functionality. Therefore, DCAN1 is typically used with P9 pin24 (Rx) and P9 pin26 (Tx).

Requirement: You are connected to the BeagleBone Black via an SSH client, for example with "Putty".

  1. To configure and test the CAN manually, use the following commands:

    sudo modprobe can
    sudo modprobe can-dev
    sudo modprobe can-raw
  2. The following command loads the kernel module (a different module might have to be loaded for different hardware):

    sudo modprobe c_can_platform

    A different module might have to be loaded for different hardware.

  3. Enter all drivers that are required for operating the CAN cape into the file "../etc/modules".

    Example:

    can
    can-dev
    can-raw

    Now the Linux mechanism "socketcan" can be used. By default, this is supported by CODESYS Control for BeagleBone.

    The kernel modules are loaded automatically when BeagleBone Black is started.

  4. Set the baud rate:

    sudo ip link set can0 up type can bitrate 125000
  5. Activate the interface:

    sudo ifconfig can0 up

    The CAN interface is configured.

Testing CAN

To test the CAN directly from the command line, you can use "can-utils" for the Debian package:

  1. Install the Debian package:

    sudo apt-get install can-utils
  2. Send a CAN message:

    cansend can0 5A1#ABCDABCD
  3. Receive a CAN message:

    candump can0