Just added error code support. There are a couple calls into the data generator API to get and clear trouble codes, they're explicitly handled separately by the sim.
I then added a data generator that does nothing but spit out a few [for now] hardcoded errors. Next up is adding error code stuff to the gui data generator so it can be done on demand. In the interest of simplicity, the error generator continues to generate the same errors, even after 0x04 is called.
Note that the error data generator is "just another ecu". You can load it up with a bunch of ECUs like usual, and just make one of them an error reporter. For clarity, with only one ecu:
chunky@mills:~/src/obdgpslogger/build$ ../bin/obdsim -g Error
SimPort name: /dev/pts/7
Successfully initialised obdsim, entering main loop
[I'm not sure what to put in those other three bytes on 0101, mostly because I haven't checked the spec yet]. I also don't yet gracefully handle the fact that it's meant to be a specific number of bytes returned.
7E0 06 41 00 80 00 00 00
7E0 06 41 01 83 00 00 00
7E0 07 43 01 04 80 03 41 23
There is a [small] disjoint in the API. I have decided not to treat 0101 specially, so that's passed to the generator in the usual way [mode 01, PID 01, the generator responds as it pleases], but modes 03 and 04 are handled via a pair of separate functions. After much consideration, this seems the best way to do it. It's worth noting that they all go through the generator, but there are potentially two entrypoints to talk about trouble codes, so it's just the responsibility of the generator writer to get it right.