Skip to content

CAN

All Pigeon computers feature a single CAN port. Pigeon computers use the Microchip MCP2515 controller along with a high-speed CAN transceiver.

Key features:

  • CAN v2.0B,
  • Transceiver fully compatible with the ISO 11898-2 Standard,
  • High-speed communication (up to 1 Mbit/s),
  • Bus pins protected against transient voltage spikes,
  • Connection via screw terminal.

By default, the CAN interface is automatically configured at startup using the settings in the /etc/network/interfaces.d/can0 file. The following command sets the bitrate of the can0 interface to 500 Kbps:

$ /sbin/ip link set can0 up type can bitrate 500000 

Note: In older versions of the operating system, the configuration was managed in the /etc/rc.local file.

Useful commands

  • Check the status of the CAN interface:

    $ ifconfig can0 
    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) 

  • Disable the CAN interface:

    $ ip link set can0 down 

  • Enable the CAN interface:

    $ ip link set can0 up 

  • Show state:

    $ ip -d -s link show can0 

  • Statistics:

    $ cat /proc/net/can/stats 

  • Set bitrate:

    $ ip link set can0 down 
    $ ip link set can0 type can bitrate 500000 

  • Enable loopback test mode:

    $ ip link set can0 down
    $ ip link set can0 type can loopback on 

  • Enable listen-only mode (silent mode):

    $ ip link set can0 down 
    $ ip link set can0 type can listen-only on 

can-utils

The can-utils package is pre-installed.

  • Transmit 8 bytes with an ID of 0x100 (dots are optional):

    $ cansend can0 100#31.32.33.34.35.36.37.38 

  • Receive packets:

    $ candump -cae can0,0:0,#FFFFFFFF can0 100 [8] 31 32 33 34 35 36 37 38 '12345678' 

  • Candump also has the ability to dump data with a specific ID, here is an example for 0x100:

    $ candump -cae can0,100:7ff 

  • Save all the received packets into a log file:

    $ candump -l can0,0:0,#FFFFFFFF 

  • Cansniffer groups messages by their identifiers (IDs):

    $ cansniffer can0