how to use pcan device How to use PCAN Device

Set Can bit time

http://www.bittiming.can-wiki.info/#bxCAN

How to use PCAN Device

Installation

After Installation, run 'sudo modprobe pcan' to load the driver module

USAGE

Monitor the PCAN Device

  • 'cat /proc/pcan' to see all the PCAN device
  • 'lspcan -T -t -i' can see info of PCAN device
  • 'lspcan -T -t -s -f' can refresh the screen every second with a detailed view
    of statistics clllected form all the PCAN device
  • 'candump -t a canX' to monitor the data

OPEN Socket Can Device

# Open PCAN-USB or PCAN-USB-FD as normal CAN 2.0 module
sudo ip link set can0 up type can bitrate 1000000
# Open PCAN-USB-FD as FD with Nominal Bit rate and Data Bit rate
sudo ip link set canX up type can bitrate 1000000 dbitrate 2000000 fd on 
# Or Just setting the interface down or up using, must install net-tools to use ifconfig
ifconfig canX down
ifconfig canX up

Send

# Transmit a CAN message with ID 0x123 on canX with 4 data bytes 00 11 22 33
cansend canX 123#00112233
# Transmit the same message with CAN FD (##) on canX, select the data bitrate 
#for the data bytes(BRS flags = 1)
cansend can1 123##100112233