The PCBUSB library realizes an USB to CAN user-space driver under macOS for PCAN USB interfaces from PEAK-System Technik, Darmstadt.
It supports up to 8 PCAN-USB or PCAN-USB FD devices.
The library offers an easy to use API to read received CAN messages from a 64K message queue and to transmit CAN messages.
Standard CAN frames (11-bit identifier) as well as extended CAN frames (29-bit identifier) are supported.
PCAN-USB FD devices can be operated in CAN 2.0 and CAN FD mode.
The library comes with an Objective-C wrapper and a demo App: MacCAN Monitor App
Furthermore, it can be used with the Qt Serial Bus API on a Mac.
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.
Qt is a registered trademark of The Qt Company Ltd. and its subsidiaries.
Except where otherwise noted, all software offered below are
freeware without any warranty or support.
Please note the copyright and license agreements.
The PCBUSB library realizes a 'PCAN-USB Driver for macOS' using Apple's IOUSBKit.
The dynamic library libPCBUSB is running under macOS 10.13 and later (Intel architecture and Apple silicon).
The API is almost compatible to PEAK's PCANBasic DLL.
See the doxygen documentation and the header-file for details.
Version 0.13 (Build 1978 of July 28, 2024):
Synchronized PCBUSB header with PCANBasic header from PEAK's version 4.9.0
Realized suppression of status frames by setting parameter:
- PCAN_ALLOW_STATUS_FRAMES (default = PCAN_PARAMETER_ON)
Realized suppression of remote frames by setting parameter:
- PCAN_ALLOW_RTR_FRAMES (default = PCAN_PARAMETER_ON)
Version 0.12.2 (Build 1856 of November 1, 2023):
Synchronized PCBUSB header with PCANBasic header from PEAK's version 4.8.0
Fixed a bug with pipe numbers for PCAN-USB FD devices (hardware version 6.0; see issue #11)
Added missing linker option '-rpath /usr/local/lib' to the C++ examples (see issue #17)
Updated the README file (unsupported parameter PCAN_HARD_RESET_STATUS)
Version 0.12.1 (Build 1768 of July 9, 2023):
Fixed a bug with endianess of 32-bit device id. (issue #384: PCAN-USB [Pro] FD)
Reworked return values of CAN_Read(), CAN_ReadFD(), CAN_Write(), CAN_WriteFD()
Reset USB pipe #4 after write timed out (CAN Write stalled; macOS 11 and higher)
Version 0.12 (Build 1668 of January 31, 2023):
Realized setting of device id. for PCAN-USB FD devices
Reworked status frame handling:
- fixed some bugs in the driver layer (all device types)
- suppressed initial CAN FD status frame in CAN 2.0 mode
- corrected mapping of bus error states to PCAN status
- fixed a bug with CAN id. of status messages
- CAN_Read(), CAN_ReadFD(), CAN_Write(), CAN_WriteFD(): return bus error states
SetValue(): Set default value if argument 'BufferLength' is equal to 0:
- PCAN_LISTEN_ONLY (default = OFF)
- PCAN_DEVICE_ID (default = 0)
- PCAN_TRACE_LOCATION (default = cwd)
- PCAN_TRACE_STATUS (default = OFF)
- PCAN_TRACE_SIZE (default 0 = 100k frames!)
- PCAN_TRACE_CONFIGURE (default = SINGLE_FILE)
With the PCBUSB libraryblocking reading of CAN messages can be realized with a file descriptor and the Posix system call select.
The file descriptor is – in contrast to the Windows DLL – provided by the driver.
An example can be found as a Gist in the MacCAN GitHub repo.
To use the PCBUSB library in a cross-platform Python project, the Python wrapper from PEAK's PCANBasic DLL can be used without further modifications.
You just have to import the file PCANBasic.py from the PCANBasic DLL version 4.5.1 or higher and install the PCBUSB library in the library search path (e.g. in /usr/local/lib).
In case you have problems using the PCBUSB library on macOS Monterey (12.x) and/or Apple Silicon (M1 chip), there is a toubleshooting guide as a Gist to help you isolate the problem.
The Qt Serial Bus API is delivered with a plug-in for PCAN interfaces from PEAK-System Technik.
Under macOS this plug-in uses the PCBUSB library.
You can use it to create beautiful Qt applications that run CAN and CAN FD on a Mac with PCAN-USB interfaces.
The Qt CAN Bus example runs out-of-the-box, it only requires version 0.9 or higher of the PCBUSB library being installed.
Many thanks to Miklós Márton fom Digitroll Kft. AG Electronics who patched the PCAN-Plugin for use with macOS.
Great job!
Running CAN and CAN FD on Mac is the mission of the MacCAN project.
MacCAN-Core is an abstraction (or rather a wrapper) of Apple's IOUsbKit to create USB user-space drivers for CAN interfaces from various vendors under macOS.
Rusoku Technologies is an innovative engineering team based in Lithuania, Europe.
They offer CAN adapter at a reasonable price. Drivers and utilities for Windows and Linux are available as open-source.
A macOS user-space driver for TouCAN USB interfaces from Rusoku is provided by UV Software.
Visit MacCAN-TouCAN to learn more.
The Swedish company Kvaser AB supplies advanced CAN solutions to engineers designing and deploying systems for manifold areas of applications.
They offer a wide range of CAN hardware and CAN software, mainly for applications under Windows but also under Linux.
A macOS user-space driver for CAN Leaf Interfaces from Kvaser is provided by UV Software.
Visit MacCAN-KvaserCAN to learn more.
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 goal of the CAN API V3 project is to have a multi-vendor, cross-platform CAN Interface API (Application Programming Interface).
Each CAN adapter manufacturer provides its own CAN software SDK (Software Development Kit) for the development of CAN applications based on the provided SDK.
Unfortunately, the APIs of the different manufacturers are not compatible with each other.
The CAN Interface API by UV Software (CAN API V3) solves the problems arising from this incompatibility.
A documentation of the CAN API V3 application programming interface and
a list of CAN API V3 compatible wrapper implementations for Windows®, macOS® and Linux® can be found
here.
CAN API V3 is a wrapper specification to have a uniform CAN Interface API for various CAN interfaces from different vendors running under multiple operating systems.