CAN API V3 Wrapper Library for Kvaser CAN Interfaces (Windows)

The Kvaser CANlib SDK is a software development kit providing everything you need to develop software for the Kvaser CAN and LIN interfaces on Windows. For the realization of multi-vendor CAN applications UV Software provides a CAN API V3 compatible wrapper library build upon Kvaser´s CANlib 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 KvaserCAN wrapper library provides a CAN API V3 compatible API for Kvaser´s CANlib DLL on Windows.

The GitHub repository contains the source code for the KvaserCAN wrapper library and several alternatives to build dynamic link libraries, either as a C++ class library (uvKvaserCAN.dll), or as a CAN API V3 wrapper library (u3cankvl.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) :heavy_check_mark: enabled by default
- Extended frames disable/enable (NXTD) :heavy_check_mark: enabled by default
- Shared access enable/disable (SHRD) :heavy_check_mark: disabled by default
- Non-ISO CAN FD enable/disable (NISO) :heavy_check_mark: disabled by default
- 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 :heavy_check_mark: wait up to 65’534 milliseconds
- 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: u3cankvl.dll, uvKvaserCAN.dll
- Static library :heavy_check_mark: u3cankvl.lib, uvKvaserCAN.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.2 (Commit 5799eff of June 3, 2021):

  • Migrated to Visual Studio 2019 and adapted the MSC build environments
  • Switched to a dual-license: BSD-2-Clause OR GPL-3.0-or-later
  • Updated to Kvaser´s CANlib SDK version 5.35
  • Realized class CKvaserCAN: public CCANAPI (uvKvaserCAN.dll)
  • Implemented operation mode NXTD and NRTR
  • Added a check for operation mode bit FDOE when bit BRSE is set
  • Added a check for valid identifier range in can_write
  • Added a check for operation capability in can_init
  • Fixed a mistake with channel name displayed instead of device name
  • Fixed an out-of-bound violation in companion module can_btr
  • Fixed a bug with wrong return values from kvaser_capacity
  • Fixed an unnecessary decl-specifier on can_boards[]
  • Added my beloved CAN utilities
  • Added two simple C++ examples
  • Added a Doxygen configuration

Version 0.1 (Commit bc8301d of January 19, 2021):

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

Supported Devices

For a list of supported device see Kvaser´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.
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.