can-utils
This section describes the use of can-utils utilities on Pigeon computers.
The can-utils package is installed by default.
- Transmit 8 bytes with ID 0x100 (dots are optional):
$ cansend can0 100#31.32.33.34.35.36.37.38
- Before sending CAN FD frames, the interface must be started in CAN FD mode:
$ ip link set can0 down
$ ip link set can0 up type can bitrate 500000 sample-point 0.75 dbitrate 4000000 dsample-point 0.8 fd on
- Transmit a CAN FD message with BRS (Bit Rate Switch):
$ cansend can0 100##131.32.33.34.35.36.37.38
- Transmit a CAN FD message without BRS:
$ cansend can0 100##031.32.33.34.35.36.37.38
- Cansend usage:
$ cansend
:
#{data} for Classical CAN 2.0 data frames
#R{len} for Classical CAN 2.0 data frames
#{data}_{dlc} for Classical CAN 2.0 data frames
#R{len}_{dlc} for Classical CAN 2.0 data frames
##{data} for CAN FD frames
: 3 (SFF) or 8 (EFF) hex chars
{data}: 0..8 (0..64 CAN FD) ASCII hex-values (optionally separated by '.')
{len}: an optional 0..8 value as RTR frames can contain a valid dlc field
{dlc}: an optional 9..F data length code value when payload length is 8
: a single ASCII Hex value (0 .. F)
CANFD_BRS 0x01 - bit rate switch (second bitrate for payload data)
CANFD_ESI 0x02 - bit error state indicator of the transmitting node
CANFD_FDF 0x04 - bit mark CAN FD for dual use of struct canfd_frame
- Receive packets:
$ candump -cae can0,0:0,#FFFFFFFF can0 100 [8] 31 32 33 34 35 36 37 38 '12345678'
- Dump data with a specific ID (e.g., 0x100):
$ candump -cae can0,100:7ff
- Save all received packets to a log file:
$ candump -l can0,0:0,#FFFFFFFF
- Use cansniffer to group messages by ID:
$ cansniffer can0