Roberto Viola

cansend: CanOpen Example

A simple note as I could not find anything on the net.

An example of how to write digital outputs 1 to 16 in CanOPEN in PDO with “cansend” command on Linux.

ifconfig can0 down
ip link set can0 type can bitrate 500000
ip link set up can0
cansend can0 -i 0 0x0101
while [ 1 ]; do
  cansend can0 -i 0x601 0x2f 0x00 0x62 0x01 0x01
  sleep 0.1
  cansend can0 -i 0x601 0x2f 0x00 0x62 0x01 0x02
  sleep 0.1
  cansend can0 -i 0x601 0x2f 0x00 0x62 0x01 0x04
  sleep 0.1
  cansend can0 -i 0x601 0x2f 0x00 0x62 0x01 0x08
  sleep 0.1
  cansend can0 -i 0x601 0x2f 0x00 0x62 0x01 0x10
  sleep 0.1
  cansend can0 -i 0x601 0x2f 0x00 0x62 0x01 0x20
  sleep 0.1
  cansend can0 -i 0x601 0x2f 0x00 0x62 0x01 0x40
  sleep 0.1
  cansend can0 -i 0x601 0x2f 0x00 0x62 0x01 0x80
  sleep 0.1
  cansend can0 -i 0x601 0x2f 0x00 0x62 0x01 0x00
  sleep 0.1
  cansend can0 -i 0x601 0x2f 0x00 0x62 0x02 0x01
  sleep 0.1
  cansend can0 -i 0x601 0x2f 0x00 0x62 0x02 0x02
  sleep 0.1
  cansend can0 -i 0x601 0x2f 0x00 0x62 0x02 0x04
  sleep 0.1
  cansend can0 -i 0x601 0x2f 0x00 0x62 0x02 0x08
  sleep 0.1
  cansend can0 -i 0x601 0x2f 0x00 0x62 0x02 0x10
  sleep 0.1
  cansend can0 -i 0x601 0x2f 0x00 0x62 0x02 0x20
  sleep 0.1
  cansend can0 -i 0x601 0x2f 0x00 0x62 0x02 0x40
  sleep 0.1
  cansend can0 -i 0x601 0x2f 0x00 0x62 0x02 0x80
  sleep 0.1
  cansend can0 -i 0x601 0x2f 0x00 0x62 0x02 0x00
  sleep 0.1
done