CAN Usage
The EC-A8550JD4 provides 1 CAN interface. The interface locations are shown in the figure below. When wiring, connect CAN_H to CAN_H and CAN_L to CAN_L.
The CAN device is recognized as can0 in the system (the device node is subject to the actual system). The communication test commands are as follows:
# Shut down the can0 device
ip link set can0 down
# Set the bitrate to 250Kbps
ip link set can0 type can bitrate 250000
# Bring up the can0 device
ip link set can0 up
# Run candump on the receiving end, blocking and waiting for frames
candump can0
# Run cansend on the sending end to send a frame
cansend can0 123#1122334455667788The candump and cansend tools are included in the SDK, and can also be obtained from can-utils.
Debugging and verification notes:
- The bitrates of both communication ends must be configured to be the same, otherwise no frames can be received; you can use
ip -details link show can0to view the detailed configuration and status of the CAN device. - If no frames are received after sending, please check whether the bus CAN_H and CAN_L are loose or reversed.
More Command
1、 ip link set canX down //turn off CAN device
2、 ip link set canX up //turn on CAN device
3、 ip -details link show canX //show CAN device details
4、 candump canX //Receive data from CAN bus
5、 ifconfig canX down //shutdown CAN device
6、 ip link set canX up type can bitrate 250000 //Set CAN Baudrate
7、 conconfig canX bitrate + (Baudrate)
8、 canconfig canX start //start CAN device
9、 canconfig canX ctrlmode loopback on //loopback test
10、canconfig canX restart //restart CAN device
11、canconfig canX stop //stop CAN device
12、canecho canX //check CAN device bus status
13、cansend canX --identifier=ID+data //send data
14、candump canX --filter=ID:mask //Use the filter to receive ID matching dataFAQS
Summarize several problems and solutions encountered during debugging:
Frames are received after a long delay, or not received at all.
Check whether the bus CAN_H and CAN_L, and the jumper wires, are loose or reversed.