OBDII CAN-Bus PID greater then 256

41 views
Skip to first unread message

stephane Simard

unread,
Feb 25, 2022, 12:35:20 AM2/25/22
to python-can
Hi, 

I am trying to receive and decode a car OBDII CAN-Bus data however I have run into a problem. The PID for engine rpm is 140 (Hex) which is 320 decimal, when I put this PID into the code, I receive the error shown in the picture below. Most of the car's PIDs are over 256 (decimal) as shown in the autosportlabs forum linked at the end. 

I was wondering if there is any way to use a PID with a decimal higher than 256? I am rather new to coding with memory and CAN-Bus data so any input helps!

The code I am using is the chupacarbrah.py in the GitHub attached below. 

Thank you for your time.

SUBARU BRZ CAN-Bus PIDs:

Code I'm using:
IMG_3802.jpg

Felix Divo

unread,
Mar 1, 2022, 1:14:22 PM3/1/22
to python-can
Hey!

Do you mean PID as in (Unix) process ID? Those can indeed exceed 2^8-1=255, the maximum that one byte can hold. Each entry in the data array of a message must therefore be within 0 and 255, each inclusive. I don't know what message format (=what do the bytes mean) you are using. CAN only transports them from sender to receiver(s) without being concerned with the semantics of the data. You will therefore have to look at the protocol to see if there is maybe more then one byte of space for the PID and "split up" your value among them. See also this for common ways of doing this. In general, this mailing list is probably not the right place to track this further (since CAN is not really the problem here). However, I hope I could give you some useful hints to get started with solving your problem.

Best
Felix
Reply all
Reply to author
Forward
0 new messages