Post

PCAN (PEAK CAN) Installation and Usage

PCAN (PEAK CAN) Installation and Usage

Introduction

Recently, I have been working with systems that require analyzing CAN (Controller Area Network) information. Since I needed to test CAN communication before our custom PCB is ready, I purchased a PEAK PCAN-USB adapter for development (PCAN (PEAK CAN) adapters are widely used for interfacing with CAN buses in automotive and industrial embedded systems.). However, I found that much of the available documentation is either in Chinese or somewhat confusing. This guide summarizes the process I followed to install and use the PCAN hardware and tools on Ubuntu Linux. It is intended to help others who might face similar challenges, providing clear, step-by-step instructions in English.


Prerequisites

  • Ubuntu Linux system (tested on Linux ubuntu 5.15.0-139-generic 20.04)
  • Internet access
  • USB PCAN adapter (e.g., PEAK PCAN-USB)

Install Required Libraries

1
2
sudo apt-get update
sudo apt-get install libpopt-dev make make-guile gcc g++

Install PCAN Driver

The link to the pcan driver: PCAN-Driver

  1. Download the PEAK Linux driver:

    1
    2
    
    tar xvf peak-linux-driver-8.15.2.tar.gz
    cd peak-linux-driver-8.15.2/
    
  2. Build and install the driver:

    1
    2
    3
    
    make clean
    make
    sudo make install
    
  3. Connect the PCAN-USB adapter. To verify the driver and device:

    1
    
    pcaninfo
    

    Example output:

    1
    2
    3
    
    PCAN driver version: 8.15.2
    PCAN-Basic version: 4.6.2.36
    * pcanusb32: "PCAN_USBBUS1" (0x051), PCAN-USB #1, devid=0x00 (/sys/class/pcan/pcanusb32)
    

(Optional) Install pcanview (CAN Bus Viewer)

  1. Add PEAK-System’s APT repository:

    1
    2
    3
    
    wget -q http://www.peak-system.com/debian/dists/$(lsb_release -cs)/peak-system.list -O- | sudo tee /etc/apt/sources.list.d/peak-system.list
    wget -q http://www.peak-system.com/debian/peak-system-public-key.asc -O- | sudo apt-key add -
    sudo apt-get update
    
  2. Install pcanview-ncurses:

    1
    
    sudo apt-get install pcanview-ncurses
    
  3. Run pcanview:

    1
    
    pcanview
    

(Optional) Testing with can-utils

Install can-utils:

1
sudo apt-get install can-utils

Example usage:

1
2
3
4
5
sudo ip link set can0 type can bitrate 500000   # Set bitrate to 500k
sudo ifconfig can0 up                           # Bring CAN interface up
cansend can0 999#DEADBEEF                       # Send CAN frame with ID 0x999 and data 0xDEADBEEF
candump can0                                    # Listen for CAN frames
sudo ifconfig can0 down                         # Bring CAN interface down

Notes on Kernel Configuration (Embedded Linux)

If you are using an embedded ARM/ARM64 board, ensure your Linux kernel has CAN and PEAK USB CAN support enabled:

  • In kernel menuconfig:

    1
    2
    3
    4
    5
    
    Networking support  --->
      CAN bus subsystem support  --->
        CAN Device Drivers  --->
          CAN USB interfaces  --->
            <*> PEAK PCAN-USB/USB Pro interfaces for CAN 2.0b/CAN-FD
    
  • After connecting the device, you should see a can0 interface:

    1
    
    ifconfig -a
    

Conclusion

Following this guide, you can install and use PEAK PCAN USB adapters on Ubuntu Linux for CAN bus communication and debugging. For further troubleshooting and advanced usage, refer to the official PEAK documentation or community forums.


This post is licensed under CC BY 4.0 by the author.