can4osx – CAN USB device driver for Mac

When it comes to embedded development, the Mac becomes more and more popular. Because of that many semiconductor nowadays provide native Mac support for there Integrated Development Environments. All the Major ones have tools for developing and debugging on Mac machines. But when it comes to embedded development on CAN based system most of us encounter the problem that there is no native support for most of  the CAN to USB interfaces. Almost none the CAN interface manufactures provide a proper device driver for Mac.

Because of that a open source project, called can4osx, startet. It’s supposed as a generic CAN interface driver for CAN-USB interfaces of different vendors.

What is can4osx?

can4osx was born as a daughter project of can4linux, a project with the aim to bring CAN interfaces to Linux since several years. can4osx is a CAN-USB device driver, completely running in the User-Space of OSX. It uses OKitLib and IOUSBLib, so it doesn’t have to run in the kernel. The driver can be directly compiled into applications, or run as a library.

How to use it

can4osx comes with an API, which is very close to the API of Kvasers CANLIB. A little example how to use it in a simple application:

void simpleSend(void)
CanHandle hdl;
int channel = 0;
int bitrate = canBITRATE_125K;

    hdl = canOpenChannel(channel, canOPEN_EXCLUSIVE | canOPEN_REQUIRE_EXTENDED);
    canSetBusParams(hdl, bitrate, 10, 5, 1, 1, 0);
    canWrite(hdl, 0x123, "can4osx", 8, 0);

Supported interfaces

At the moment only a few interfaces are officially supported. The reason for that is that only a few real hardware interface could be verified. Verified ones are:

  • Kvaser Leaf Light V.2
  • IXXAT USB-to-CAN FD Automotive
  • Kvaser Leaf Pro V.2 (unstable)

But since can4osx is open source every can implement or verify other interfaces.

Where is can4osx used

Besides in some little CAN hobby projects, can4osx is used for example in the  Mac Toolchain version of the different CAN Tools of the company emotas embedded communication GmbH.