Giter VIP home page Giter VIP logo

pcbusb-library's Introduction

Running CAN and CAN FD on Mac is the mission of the MacCAN project. There are many companies offering multifarious CAN hardware and CAN software. Unfortunately, few of them provide a driver for the Mac.

UV Software provides macOS® user-space drivers for USB-to-CAN interfaces from various vendors.

CAN API V3 on macOS® macOS® CAN User-Space Drivers:

See the MacCAN GitHub Pages website to learn more about the entire MacCAN project and its sub-projects.

A generic documentation of the CAN API V3 application programming interface can be found here.

Copyright © 2021-2024 Uwe Vogt, UV Software, Berlin.

pcbusb-library's People

Contributors

mac-can avatar uv-software avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

pcbusb-library's Issues

Messages lost on high CAN FD bit-rates

Testcase TC12.6 failed: expected != received

TC12.6 - Read CAN FD messages from the receive queue and check for amount and order:

  • 1Mbps (arbitration) and 8Mbps (data phase)
  • 131072 CAN FD messages of size 64 bytes sent back to back

Assumption:
It seems that the CAN FD capable PCAN USB devices send greater URBs than they report as endpoint packet size (512 byte. for pipe 3: input pipe for received CAN messages). The PCBUSB library provides a double buffer with size of 512 bytes (each). One buffer can hold up to 4 CAN FD message entries of 96 bytes but occasionally there is an incomplete 5th one in the packet. An incomplete entry could not be decoded, so this message get lost.

Question: Epoch for CAN Message Timestamp

Hi,

I'd like to convert the CAN message timestamps to real time (UTC). What epoch is being used for the timestamps?

On Windows, with the PCAN-Basic API, the timestamps are seconds since boot. However, on macOS, I tried using kern.boottime from sysctl() to get the boot time and add that to the timestamps. That didn't give correct times -- it seemed that the timestamps were using a later epoch (possibly first call into the library?).

Thanks in advance for any assistance!

receive lost data

  • Device: PCAN FD
  • Host: Macbook Pro M1 14
  • Source Code: pcbusb_recv.cpp
  • clang version: Apple clang version 13.1.6 (clang-1316.0.21.2.5)
  • Baudrate: PCAN_BAUD_500K
  • library version: 0.11.2
  1. when I send small amount can datas, for example send 10 can packages every 1 second, pcbusb_recv will never receive the can data.

  2. But when I send massive can data, which is can bus log file, on the bus, the pcbusb_recv will receive some data package of the can bus and massive data will not be received!

  3. I install ubuntu virtual machine in Parallels, the pcan fd device works ok in it!

  4. The lost data on receiver cannot be acceptable~~

Reception of old messages

Hello,
I have an application where I use this wonderful library to be able to use a PEAK USB CAN adapter on my Mac. An embedded device is connected to the PEAK adapter. The application on the embedded device and the application on the Mac side worked flawlessly for some years now. Recently, I had to upgrade the PCBUSB-Library to version 0.12 (before that, I've used version 0.9), because the newer version of the Apples C++ compiler was requiring a native ARM library.

The application is a bootloader and installing a new firmware takes ~ 1 minute when using 1MBit CAN bus speed. Once in a while (1 out of 5-10), the protocol between Mac and embedded device is violated. The protocol stack then starts to report the reception of messages that were already received some time before.

To make sure, that the problem is not within the implementation of the bootloader protocol, I've attached a logic analyzer and indeed I was not able to confirm the double received messages.

When I see that problem, there are always multiple messages that where twice and they are then received in the same order as they where original received. Here is an example of a message type that is reported to be received by the Mac application:

...
CTL: 401: 06 00 47 10 00 00 01 00 8
CTL: 401: 06 00 48 10 00 00 01 00 8
CTL: 401: 06 00 49 10 00 00 01 00 8
CTL: 401: 06 00 4a 10 00 00 01 00 8
CTL: 401: 06 00 4b 10 00 00 01 00 8 <-- first time
CTL: 401: 06 00 4c 10 00 00 01 00 8
CTL: 401: 06 00 4d 10 00 00 01 00 8
CTL: 401: 06 00 4e 10 00 00 01 00 8
CTL: 401: 06 00 4f 10 00 00 01 00 8
CTL: 401: 06 00 50 10 00 00 01 00 8
CTL: 401: 06 00 51 10 00 00 01 00 8
CTL: 401: 06 00 52 10 00 7e 00 00 8
CTL: 401: 06 00 54 10 00 00 01 00 8
CTL: 401: 06 00 55 10 00 00 01 00 8
CTL: 401: 06 00 56 10 00 00 01 00 8
CTL: 401: 06 00 57 10 00 00 01 00 8
CTL: 401: 06 00 58 10 00 00 01 00 8
CTL: 401: 06 00 59 10 00 00 01 00 8
CTL: 401: 06 00 5a 10 00 00 01 00 8
CTL: 401: 06 00 5b 10 00 00 01 00 8
CTL: 401: 06 00 5c 10 00 00 01 00 8
CTL: 401: 06 00 5d 10 00 00 01 00 8
CTL: 401: 06 00 5e 10 00 00 01 00 8
CTL: 401: 06 00 5f 10 00 00 01 00 8
CTL: 401: 06 00 60 10 00 00 01 00 8
CTL: 401: 06 00 61 10 00 00 01 00 8
CTL: 401: 06 00 62 10 00 00 01 00 8
CTL: 401: 06 00 63 10 00 00 01 00 8
CTL: 401: 06 00 64 10 00 00 01 00 8
CTL: 401: 06 00 65 10 00 00 01 00 8
CTL: 401: 06 00 66 10 00 00 01 00 8
CTL: 401: 06 00 67 10 00 00 01 00 8
CTL: 401: 06 00 4b 10 00 00 01 00 8 <-- second time
CTL: 401: 06 00 4c 10 00 00 01 00 8
CTL: 401: 06 00 4d 10 00 00 01 00 8
CTL: 401: 06 00 4e 10 00 00 01 00 8
....

The message acknowledges the reception of a certain bit of data. The first byte (the 06) is an opcode, the next 4 bytes are an address, followed by a 16 byte length information. After the reception of the memory for the address 0x00016700, the received block is acknowledged and then, out of a sudden, the reception of the block at 0x00014b00 is received again.

I've traced such an error situation with a logic analyzer and can see, that the double messages are not send over the CAN bus. Beside the messages above, I suspect that there are the same amount of messages received twice. But as they contain only an opcode, I can not distinguish them from the ones that are expected at that moment.

To me, this looks like there is a reception ring buffer, what when either overflows or wraps is not empty anymore, but full and thus the application will receive the data twice.

Not working on Monterey

Hello!

After upgrading my Mac to Monterey I lost access to my device. When Running the Python Example I receive the error:
Error: (0, b'The driver is not loaded')

The Mac still recognizes the PCAN-USB device and shows it on system report menu

PCAN-USB:

  Product ID:	0x000c
  Vendor ID:	0x0c72
  Version:	54.ff
  Speed:	Up to 12 Mb/s
  Manufacturer:	PEAK-System Technik GmbH
  Location ID:	0x14222000 / 9
  Current Available (mA):	500
  Current Required (mA):	200
  Extra Operating Current (mA):	0

I tried searching on how to reload Mac drivers and things like that, but I have no experience on Mac drivers, kernel....

Cannot install

Hi All,

I'm almost certainly being stupid here (and have no coding skill at all) but on my apple silicon mac I can't get the install shell file to run at all to install the library. Anyone able to explain to me how the process should work?

Cheers,

Phil

Unable to disable PCAN_LISTEN_ONLY after CAN_Initialize has been called

If PCAN_LISTEN_ONLY is enabled before CAN_Initialize has been called, then trying to disable it subsequently, as follows, has no effect.

int option = PCAN_PARAMETER_OFF;
status = CAN_SetValue(PCAN_CHANNEL, PCAN_LISTEN_ONLY, &option, sizeof(option));

Even though the parameter will be reported as OFF when CAN_GetValue is called, the PCAN_LISTEN_ONLY appears to be still active.

This problem is observed with "libPCBUSB.0.11.dylib" on macOS Catalina (Intel).

Test setup:

  • PCAN-USB FD
  • one node on bus, periodically transmitting a message containing a byte that increments at each transmit

PCAN_LISTEN_ONLY mode being active can be observed, when messages are received, but the counter is no longer increasing, suggesting that the PCAN device is not acknowledging the message.

PCAN-USB FD (IPEH-004022) cannot be initialized

Peak-System GmbH has released a new product variant of its PCAN-USB FD interfaces (item no. IPEH-004002). These interfaces cannot be operated with the PCBUSB library for macOS. The initialization of such an interface - in CAN 2.0 mode as well as in CAN FD mode - fails with error code 0x4000000 (PCAN_ERROR_INITIALIZE).

PCAN Multiple Application Access

Allowing the MAC CAN driver to send data to multiple applications that are using the PCAN dongle? Is this possible, if so, how many I do it?

The goal is to use 1 PCAN dongle but access it using multiple python scripts that are running at the same time.

PeakCanUSB is not found in QtCanBus PeakCan Plugin

PeakCanUSB is not scanned under QtCanBus PeakCan Plugin

Steps to reproduce:

  1. Ensure same Qt application running fine and able to connect PeakCan via QtCanBusPeakCanPlugin ("peakcan") on Linux
    (:+1:)
  2. Build same QtAppplication on MacOS (M1 Chip) + install https://github.com/mac-can/PCBUSB-Library/releases/download/v0.11.2/macOS_Library_for_PCANUSB_v0.11.2.tar.gz
  3. Observe that upon start, calling this snippet result on empty devices list (:-1:)
auto devices = QCanBus::instance()->availableDevices("peakcan", &errorString);

Add @rpath to PCBUSB dylib

Link dylib with -install_name @rpath, e.g. -install_name @rpath/libPCBUSB.0.11.dylib, to allow distributing the library inside an application bundle.

Distribute as a Python Pip Package?

It would be useful for users to be able to pip install pcanbasic so that can use your python library without having to manually install it themselves. I think It would have to:
1.) Install PCANBasic.py into the site-packages (pip does this for you if you follow the proper layout)
2.) Install libPCBUSB.0.10.1.dylib into a known location, like /usr/local/lib then run ldconfig. This might be some custom code.

Users would then run:

$ python3 -m pip install pcanbasic

Then in their python code they can just import it

# import the class PCANBasic from the module named PCANBasic
from PCANBasic import PCANBasic

And it works!

MacOS Monterey library issue

Dear,
I have successfully used the driver before on macOS Big Sur, but now after upgrading the system (fresh install) the driver stopped working. My code is written in python but I have also tested the MacCAN Monitor, both without success.

Further details:
CPU: Intel
macOS: 12.2.1
hardware: PCAN-USB adapter

python output: "The driver is not loaded"
MacCAN Monitor output: "Something went terribly wrong! Error 0200: The driver is not loaded"

I tried the universal_64 and Intel_x86_64 0.10.1 and 0.11 version. The result is always the same.

Apple Silicon (ARM M1) not supported

Currently this driver only seems to support x86 architectures. Is there any way to port this over to M1 chips, or is there another workaround to use to solve compatibility problems?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.