-
Notifications
You must be signed in to change notification settings - Fork 597
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
PCAN MAC message ID type issue (c_ulong vs c_uint) #1117
Comments
Thanks so much for opening this issue. I was facing the exact same thing and changing the ID field to
class TPCANMsgMac (Structure):
"""
Represents a PCAN message
"""
_fields_ = [ ("ID", c_uint), # CHANGED FROM C_ULONG
("MSGTYPE", TPCANMessageType), # Type of the message
("LEN", c_ubyte), # Data Length Code of the message (0..8)
("DATA", c_ubyte * 8) ] # Data of the message (DATA[0]..DATA[7]) |
Confirmed that libPCBUSB v0.8.0 works with python-can as-is ( |
I went with this terrible monkey patch hack in order to stay version 9:
|
I am seeing similar with 0.10.1. I'm using CanAnalyzer to receive the messages and can see they are sent out with the wrong ID and always have a DLC of 0. Diffing the PCANBasic.py example file that ships with MacCAN against basic.py shows they are basically the same, with the MacCAN version possibly being more up-to-date (except it uses 'print' instead of 'logger') and correctly using c_uint (it does not have the Mac specific classes). It looks as if this can be used, provided the Darwin specific calls in pcan.py are removed? |
Description
Using PCAN interface on the mac using version >=0.9 of
libPCBUSB
results in ID and DLC errors.The ID has unexpected bits well beyond bit 29.
And the DLC is always zero.
Reproduce
install version >=0.9 of
libPCBUSB
.Read a message from a connected device on a MAC using PCAN interface.
Expected Behaviour
The ID will be 11 or 29 bits.
The DLC will be the data byte count in the message.
Further explanation
I am using
python-can
on a MAC test some my firmware using a PEAK CANFD analyzer. The FW will loopback known messages.The test python code is this:
The output is:
40200018000
is not a valid ID. And the DLC should be 4.Theory
The PCAN MACOS implementation specializes the
TPCANMsg
to usec_ulong
instead ofc_uint
. This change was made about two years ago.Looking at the
PCBUSB.h
file include in version 0.9 and 0.10 there is a statement to the effect that the ID has changed from 64 to 32 bits.To test this theory I changed
TPCANMsgMac
's ID field to be typec_uint
.Rerunning the above code the result is correct:
(the ID in the response is supposed to be shifted up 15 bits).
System
OS-version: 10.15.7
Python version: 3.7.4
python-can version: 3.3.4
python-can interface/s: PCAN
The text was updated successfully, but these errors were encountered: