Skip to content

Instantly share code, notes, and snippets.

@mac-can
Created February 13, 2022 17:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mac-can/a43f08e530714dd74689762f62f88dca to your computer and use it in GitHub Desktop.
Save mac-can/a43f08e530714dd74689762f62f88dca to your computer and use it in GitHub Desktop.
PCBUSB Library on macOS Monterey and/or Apple Silicon

Troubleshooting Guide for PCBUSB Library on macOS Monterey and/or Apple Silicon

If you encounter problems installing or using libPCBUSB.dylib on macOS Monterey (12.x) and/or Apple Silicon (M1 chip), this guide may help you isolate the problem.

1. Try out the utilities from the PCBUSB-Utilities repo

To basically check whether the PCAN hardware runs on your Mac or is supported by the PCBUSB driver, you can try the PCBUSB-Utilities. The utilities can_test and can_moni are standalone programs that run in user space and do not require the PCBUSB dylib to be installed.

Download and unzip the artifact(s) from latest tag. Do not run the install.sh script. Instead, run the binaries directly in a terminal session. Type either can_test --help or can_moni --help to see all program options.

If this does not work, open a new Issue in the repo or post a comment on an existing issue. Otherwise, continue with step 2.

2. Try out the C++ examples from the PCBUSB-Library repo

The PCBUSB library repo contains two C++ examples as source code. Both examples link libPCBUSB.dylib at compile time using the linker option -lPCBUSB.

Clone the repo or download it as .zip file and execute the Makefile. Prerequisite is that you have a) the Xcode Commandline Tools and b) the libPCBUSB.dylib installed.

The example pcbusb_recv receives incoming CAN messages over the channel PCAN-USB1 until you press Ctrl+C. pcbusb_send sends 2048 CAN messages over the channel PCAN-USB2 and exits.

If this does not work, open a new Issue in the repo or post a comment on an existing issue. Otherwise, continue with step 3.

3. Try out the Python example from the PCBUSB-Library repo

The PCBUSB library repo contains also a Python example. The Python interpreter loads the dynamic library libPCBUSB.dylib at run time by a call to cdll.LoadLibrary(find_library("libPCBUSB.dylib")).

The Python example pcbusb_recv receives incoming CAN messages over the channel PCAN-USB1 until you press Ctrl+C as in the C++ example. (I recommend using Python 3.x, since Python 2.x on macOS did not allow file system relative paths in hardened programs.)

If this does not work, open a new Issue in the repo or post a comment on an existing issue. Optionally, continue with step 4.

4. Try out the PCBUSB Monitor App from the PCBUSB-Monitor repo

The PCBUSB Monitor App is a little demo program to show the functionally of the PCBUSB library: the macOS Library for PCAN-USB interfaces. The App is written in Objective-C. It is open source. And it loads the libPCBUSB.dylib at run time.

Read the README.md file to learn how to build and install the App or download the pre-build binary from the MacCAN website.

If steps 1 to 3 have not solved your problem so far, there is little hope that this step will bring enlightenment :(


Remarks:

  1. If you have encountered an issue running the dynamic library libPCBUSB.dylib with hardbyte/python-can please refer to issue #1117.

  2. On 64-bit Unix based OS type long is 64 bit wide. I´ve stopped using primitive data types with version 0.9 and replaced them by Mac data types. A break in downward compatibility was intentional and has been documented.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment