CAN
The Pigeon has one CAN port. The CAN controller supports both CAN frame formats as specified in ISO 11898-1:2015: the Classical format (CAN 2.0B) and the CAN Flexible Data Rate (CAN FD) format.
Features:
- Supports both CAN 2.0B and CAN FD,
- Arbitration Bit Rate up to 1Mbps,
- Data Bit Rate up to 8Mbps,
- Bus pins protected against transients,
- Connection via screw terminal.
By default, the CAN interface is automatically configured at startup using the settings in the /etc/systemd/network/80-can.network file.
Useful commands
- Check state of the CAN interface:
$ ifconfig can0
Link encap:UNSPEC HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00
UP RUNNING NOARP MTU:16 Metric:1
RX packets:20 errors:0 dropped:0 overruns:0 frame:0
TX packets:20 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:10
RX bytes:160 (160.0 B) TX bytes:160 (160.0 B)
- Display CAN device details:
$ ip -details link show can0
3: can0: <NOARP,UP,LOWER_UP,ECHO> mtu 16 qdisc pfifo_fast state UP mode DEFAULT group default qlen 10
link/can promiscuity 0 allmulti 0 minmtu 0 maxmtu 0
can state ERROR-ACTIVE (berr-counter tx 0 rx 0) restart-ms 100
bitrate 500000 sample-point 0.875
tq 25 prop-seg 34 phase-seg1 35 phase-seg2 10 sjw 5 brp 1
mcp251xfd: tseg1 2..256 tseg2 1..128 sjw 1..128 brp 1..256 brp_inc 1
mcp251xfd: dtseg1 1..32 dtseg2 1..16 dsjw 1..16 dbrp 1..256 dbrp_inc 1
tdcv 0..63 tdco 0..63
clock 40000000 numtxqueues 1 numrxqueues 1 gso_max_size 65536 gso_max_segs 65535 tso_max_size 65536 tso_max_segs 65535 gro_max_size 65536 gso_ipv4_max_size 65536 gro_ipv4_max_size 65536 parentbus spi parentdev spi0.0
- Configure a 500 kbit/s arbitration bitrate and a 4 Mbit/s data bitrate, and enable CAN FD mode:
$ ip link set can0 up type can bitrate 500000 sample-point 0.75 dbitrate 4000000 dsample-point 0.8 fd on
- Bring down the device:
$ ip link set can0 down
- Bring up the device:
$ ip link set can0 up
can-utils
CAN interfaces can be operated using the can-utils utilities. Detailed usage instructions and examples are provided in the documentation can-utils.