CAN
All Pigeon computers have one CAN port. Pigeon uses the Microchip MCP2515 controller and high-speed CAN transceiver.
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 transients,
- connection via screw terminal.
By default CAN interface is configured after boot. Below command set the bitrate of the can0 interface to 500 Kbps:
/sbin/ip link set can0 up type can bitrate 500000
you can edit this command in /etc/rc.local
file.
Useful commands
-
Check state of 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)
-
Bring down the device
ip link set can0 down
-
Bring up the device
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
-
Test mode - loopback mode
ip link set can0 down type can ip link set can0 type can loopback on
- Test mode - silent mode
ip link set can0 down ip link set can0 type can listen-only on
can-utils
Can-utils is installed by default.
-
Transmit 8 bytes, id number is 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 logged file:
candump -l can0,0:0,#FFFFFFFF
- Cansniffer group the messages by ID's (identifiers):
cansniffer can0
Comments are closed.