Skip to content

CAN

CAN (Controller Area Network) is a multi-master, half-duplex, differential serial fieldbus developed by Robert Bosch in 1986 for automotive ECU communication and later standardized as ISO 11898. It focuses on highly reliable, real-time, interference-resistant short-distance communication between devices in embedded scenarios. It only defines the physical layer and data link layer, with no upper-layer network/transport layer, and extremely low protocol overhead.

Preparation

  • A Rhino Pi-A1
  • Several jumper wires
  • A Windows computer

Connection

  • Short-circuit can0 and can1 on the Rhino Pi-A1
    • Connect CAN_H0 to CAN_H1
    • Connect CAN_L0 to CAN_L1
No.Board SilkscreenGPIO/System MappingDescription
21CAN_H0CAN_H1Actually corresponds to can1
22CAN_L0CAN_L1Actually corresponds to can1
23CAN_H1CAN_H0Actually corresponds to can0
24CAN_L1CAN_L0Actually corresponds to can0

Note

The can0 and can1 on the Rhino Pi-A1 board silkscreen do not correspond to the can0 and can1 listed in the system commands. Refer to the table above for the actual correspondence.

Testing

  • Open a Windows computer and enter the Rhino Pi-A1 device IP:8000 in the browser to access the device Web page. Username/password: aidlux/aidlux.

  • Execute the following commands to configure can0 and can1:

shell
# Elevate privileges
sudo su

# can1 configuration
ip link set can1 down
ip link set can1 up type can bitrate 500000
ip link set can1 up

# can0 configuration
ip link set can0 down
ip link set can0 up type can bitrate 500000
ip link set can0 up

# Query configuration
ip --detail link show can0
ip --detail link show can1

You can see the following output:

CAN Configuration Display

  • Execute the following command to install the cansend/candump tools:
shell
sudo apt install can-utils
  • On the Web page, open two terminals and execute the following commands:
shell
# Terminal 1 - Listen to can1
candump can1
# Terminal 2 - Send data to can1
cansend can1 123#1122334455667788
cansend can1 123#11111111

You can see the following output:

CAN Test