CAN API V3 Wrapper Library for PEAK PCAN Interfaces (Windows)

The PCANBasic DLL provides an easy to use API (Application Programming Interface) for all PCAN interfaces from PEAK-System Technik, Darmstadt. For the realization of multi-vendor applications UV Software provides a CAN API V3 compatible wrapper library build upon PEAK´s PCANBasic DLL.

Download Sources (zip) Sources (tar.gz) @GitHub

CAN API V3 Wrapper

CAN API V3 is a wrapper specification by UV Software to have a uniform CAN Interface API for various CAN interfaces from different vendors running under multiple operating systems. The PCANBasic wrapper library provides a CAN API V3 compatible API for PEAK´s PCANBasic DLL on Windows.

The GitHub repository contains the source code for the PCANBasic wrapper library and several alternatives to build dynamic link libraries, either as a C++ class library (uvPeakCAN.dll), or as a CAN API V3 wrapper library (u3canpcb.dll), as well as some example programs and my beloved CAN utilities can_moni.exe and can_test.exe.

Note: UV Software also provides a CAN API V3 compatible Wrapper Library for macOS.

Features

Feature Supported Remarks
CAN 2.0 :heavy_check_mark: Classical CAN
CAN FD :heavy_check_mark: Flexible Data-rate CAN
Bit-rate, CAN 2.0 :heavy_check_mark: high speed: up to 1 Mbps
Bit-rate, CAN FD :heavy_check_mark: nominal: up to 1 Mbps
data phase: up to 8 Mbps
11-bit identifier (STD) :heavy_check_mark: CAN 2.0 and CAN FD
29-bit identifier (XTD) :heavy_check_mark: CAN 2.0 and CAN FD
Remote frames (RTR) :heavy_check_mark: CAN 2.0 only
Error frames (ERR) :heavy_check_mark: CAN 2.0 and CAN FD
Error indicator (ESI) :heavy_check_mark: CAN FD only
Bit-rate switching (BRS) :heavy_check_mark: CAN FD only
Silent operation (MON) :heavy_check_mark: CAN 2.0 and CAN FD
Identifier filtering :x: CAN 2.0 and CAN FD
Operation modes:    
- Monitor mode enable/disable (MON) :heavy_check_mark: disabled by default
- Error frames enable/disable (ERR) :heavy_check_mark: disabled by default
- Remote frames disable/enable (NRTR) :x: not supported
- Extended frames disable/enable (NXTD) :x: not supported
- Shared access enable/disable (SHRD) :x: not supported
- Non-ISO CAN FD enable/disable (NISO) :x: HW settings of the device cannot be changed by the library
- Bit-rate switching enable/disable (BRSE) :heavy_check_mark: disabled by default
- CAN FD operation enable/disable (FDOE) :heavy_check_mark: disabled by default
Bit-rate settings:    
- Pre-defined bit-timing indexes :heavy_check_mark: acc. CiA CANopen specification
- BTR register values :heavy_check_mark: register fields:
- freq (clock frequency in [Hz])
- brp (bit-rate prescaler)
- tseg1 (time segment 1)
- tseg2 (time segment 2)
- sjw (synchronization jump width)
- sam (number of samples)
Message reception:    
- Message queue (FIFO) :heavy_check_mark: queue size depends on the hardware
- Polling :heavy_check_mark: return immediately
- Timed out :heavy_check_mark: wait up to 65’534 milliseconds
- Blocking read :heavy_check_mark: wait infinitely
Message transmission:    
- Acknowledged write :x: not supported
- Buffered write :heavy_check_mark: buffer size depends on the hardware
Software Development Kit:    
- CAN API V3 :heavy_check_mark: C API and C++ API by UV Software
- Dynamic link library :heavy_check_mark: u3canpcb.dll, uvPeakCAN.dll
- Static library :heavy_check_mark: u3canpcb.lib, uvPeakCAN.lib
- 32-bit version (x86) :heavy_check_mark: supported
- 64-bit version (x64) :heavy_check_mark: supported
- Source code :heavy_check_mark: BDS-2-Clause or GPL-3.0-or-later
- Python wrapper :heavy_check_mark: Python 3.7
- macOS wrapper :heavy_check_mark: macOS Driver and SDK
- Utilities :heavy_check_mark: CLI utilities can_moni and can_test
- Examples :heavy_check_mark: C, C++, Python

Change-log

Version 0.4.1 (Commit 60fa2d4 of June 7, 2021):

  • Updated to PCANBasic DLL version 4.5.4
  • Switched to a dual-license: BSD-2-Clause OR GPL-3.0-or-later
  • Added a check operation mode bit FDOE when bit BRSE is set
  • Added a check for valid identifier range in can_write
  • Added a check for valid messages flags in can_write
  • Added a check for operation capability in can_init
  • Fixed an out-of-bound violation in companion module can_btr
  • Fixed a but with casting from CAN API channel to PCAN handle
  • Fixed a mistake with channel name displayed instead of device name
  • Repaired the C++ examples; Python examples are still broken

Version 0.4 (Commit 53db869 of February 7, 2021):

  • Applied changes from CAN API V3 specification (rev. 951 to 987)
  • Added C++ class CPeakCAN derived from abstract class CCANAPI
  • Reworked the trial program (it is now based on class CPeakCAN)
  • Reorganized the entire folder structure of the repository
  • Added my beloved CAN utilities can_moni and can_test
  • Added two simple C++ examples for sending and receiving CAN frames
  • Added a Python wrapper and two Python examples
  • Added a Doxygen configuration

Version 0.3 (Commit 8514061 of January 15, 2021):

  • Last sources from subversion repo to build version 3.3 (old versioning scheme)

Supported Devices

For a list of supported device see PEAK´s website.

Known Bugs and Caveats

For a list of known bugs and caveats see tab Issues in the GitHub repo.

Dual-License

This work is dual-licensed under the terms of the BSD 2-Clause “Simplified” License and under the terms of the GNU General Public License v3.0 (or any later version). You can choose between one of them if you use this work in whole or in part.

Trademarks

Windows is a registered trademark of Microsoft Corporation in the United States and/or other countries.
Mac and macOS are trademarks of Apple Inc., registered in the U.S. and other countries.
PCAN is a registered trademark of PEAK-System Technik GmbH, Darmstadt, Germany.
All other company, product and service names mentioned herein are trademarks, registered trademarks or service marks of their respective owners.

Hazard Note

If you connect your CAN device to a real CAN network when using this library, you might damage your application.