Fixposition SDK 0.0.0-heads/main-0-gde8559b
Collection of c++ libraries and apps for use with Fixposition products on Linux
Loading...
Searching...
No Matches
CAN bus utilities

API: fpsdk_common/can.hpp and fpsdk::common::utils

CAN frames (messages)

  • Standard frame format (SFF): 11 bits CAN ID
  • Extended frame format (EFF): 29 bits CAN ID
  • Classical CAN: 8 bytes payload
  • CAN FD: up to 72 bytes payload, with optional switching to a second bitrate for the payload (BRS)

The cansend tool (from can-utils):

cansend vcan0 123#0102030405060708                      # SFF frame, 8 bytes payload
cansend vcan0 12345678#0102030405060708                 # EFF frame, 8 bytes payload

cansend vcan0 123##0112233445566778899aabbccddeeff      # SFF FD 16 bytes, no bit rate switch ("0")
cansend vcan0 12345678##0112233445566778899aabbccddeeff # EFF FD 16 bytes, no bit rate switch ("0")

cansend vcan0 123##1112233445566778899aabbccddeeff      # SFF FD 16 bytes, with bit rate switch ("1" = BRS)
cansend vcan0 12345678##1112233445566778899aabbccddeeff # EFF FD 16 bytes, with bit rate switch ("1" = BRS)

cansend vcan0 123#01020304                              # SFF frame, only 4 bytes payload

Testing

For testing on a normal Linux box once can use a virtual CAN device:

sudo modprobe vcan
sudo ip link add dev vcan0 type vcan
sudo ip link set up vcan0

In different terminals:

candump vcan0

cansend vcan0 ... # see above

Setup a real can device:

ip link set can0 down
ip link set can0 type can bitrate 125000 dbitrate 500000 fd on fd-non-iso on restart-ms 100
ip link set can0 up
ip link set can0 txqueuelen 1000

References