One of the first things I wanted to know about our new vehicle is whether or not my extremely cheap ELM327-knock-off OBD2 cable would work on it. It should, as it's a GM LS1 and a GM 4L60E transmission, but that doesn't necessarily imply that Holden wouldn't find a way to fuck things up.
As it turns out it did, but once again I'm faced with the exceptionally piss-poor state of free OBD2 software. The only software I've ever had working reliably with this cable is a pirate copy of PCMScan that it came with, and while I'm not averse to paying for the software (and I may well do that if my attention span runs out) I thought it'd be an interesting exercise trying to write my own.
I decided that for the learning and experimenting portion of the exercise, to write it as a simple API in Python. If I wanted to I could then use one of the many Python GUI toolkits and turn it into a usable (if suboptimal) piece of software, but for a hacker-type like I am a Python interface is probably okay.
This was also my first attempt at mucking around with lambda functions in Python, which I think solve the problem of interpreting PIDs handily. Overall I'm rather proud of the result so far, which I've open sourced on Github. Fetching DTCs should be rather trivial:
from elm327 import elm327, pids with elm327.ELM327(2) as elm: print("Device reports as: %s" % elm.id) print elm.fetchDTCs()
I say "should", because I haven't tested it yet.