brendan-w / python-OBD

OBD-II serial module for reading engine data
GNU General Public License v2.0
1.02k stars 360 forks source link

Add ID value to all STATUS-type messages #264

Closed csurf closed 12 months ago

csurf commented 12 months ago

One quirky things I've noticed with the python-OBD code is that almost all of the commands that produce 'STATUS'-type responses will have return values that are plain English strings. This makes them rather inflexible because it forces the user to programmatically parse the strings before further processing them, such as to translate them, shorten them, customize the name or message, to hand them off to some other program routine, etc.

Ideally, these types of response values would have an associated numeric ID value that can be used in a much easier way in order to process such responses.

example: when querying the 'fuel status' command (PID 01 03), python-OBD offers these response value strings...

""
--
"Open loop due to insufficient engine temperature"
"Closed loop, using oxygen sensor feedback to determine fuel mix"
"Open loop due to engine load OR fuel cut due to deceleration"
"Open loop due to system failure"
"Closed loop, using at least one oxygen sensor but there is a fault in the feedback system"

It might be more useful to have something where each status response can be uniquely identified with a numeric value, like the following:

0: "Open loop due to insufficient engine temperature"
1: "Closed loop, using oxygen sensor feedback to determine fuel mix"
2: "Open loop due to engine load OR fuel cut due to deceleration"
3: "Open loop due to system failure"
4: "Closed loop, using at least one oxygen sensor but there is a fault in the feedback system"