DUI Test Machine Code Unmasked
2009-05-15 04:40:50.594416+00 by
ziffle
12 comments
In NJ the source code for the DUI Machine they use was unmasked
Some of the things they found:
Readings are Not Averaged Correctly: When the software takes a series of readings, it first averages the first two readings. Then, it averages the third reading with the average just computed. Then the fourth reading is averaged with the new average, and so on. There is no comment or note detailing a reason for this calculation, which would cause the first reading to have more weight than successive readings.
The diagnostic routines for the Analog to Digital (A/D) Converters will substitute arbitrary, favorable readings for the measured device if the measurement is out of range, either too high or too low. The values will be forced to a high or low limit, respectively
If the airflow is slower than the baseline, this would result in a negative flow measurement, so the software simply adjusts the negative reading to a positive value
Range limits used when out of range values are found, etc. etc. The best is that three of five lines of C code have errors according to Lint. Ahhh nasty fellow that Lint.
You gotta wonder what the source looks like in all the stuff they convict us with.
Ziffle in Mayberry where all C code passes Lint first time.
[ related topics:
Ziffle Interactive Drama Open Source Invention and Design Software Engineering
]
comments in ascending chronological order (reverse):
#Comment Re: made: 2009-05-15 12:35:35.842116+00 by:
Dan Lyke
So this raises all sorts of questions, but the first that came up for me was: How do you test this machine? Is there some protocol whereby the developers chug a few beers and breathe into the device, compare the results to a blood sample and adjust accordingly?
I'm guessing that may explain some of the issues with the code...
#Comment Re: made: 2009-05-15 13:02:42.546463+00 by:
m
I don't think the idea is to test the machine. You test background. ethanol free air, set that to -0.8%. This provides for the extremely rapid amortization of the equipment and "training" costs.
#Comment Re: made: 2009-05-15 13:47:20.304758+00 by:
meuon
The only test I can come up with is where a stream of air passing into the breathalyzer is also passed into a gas chromatograph or other reasonable accurate (but expensive) laboratory device which is tested and calibrated routinely.
Unfortunately, M is probably correct, it is like changing traffic light timing when installing a a traffic camera. It is about revenue generation.
#Comment Re: made: 2009-05-15 13:53:34.273037+00 by:
Dan Lyke
I'm fairly sure that once you know how much alcohol you want dissolved in how much air you can build a little chamber that creates that situation repeatably and accurately. But even figuring out what that first ratio is seems like something that'd be fun to be on the test team of.
#Comment Re: made: 2009-05-15 14:44:42.839795+00 by:
ziffle
I just think of Lint and all the instances where they took the value of a pointer instead of *pointer and so forth.
I watched Lint terrorize otherwise stable project managers... :)
#Comment Re: made: 2009-05-15 15:00:55.08725+00 by:
meuon
Dan, you'd have to compensate for the humidity, temperature, other suspended particles, etc.. lots of variables. Better to measure with something accurate to PPM (Parts Per Million).
#Comment Re: made: 2009-05-15 15:17:41.481025+00 by:
JT
We used to have a group that would come in every six months and calibrate our breathalyzers. (Manufacturer recommended every 6 months.) During the power-up, it would go through a self-test, you couldn't have the suspect within %n feet of the machine shown by a yellow line, as he could contaminate the surrounding air if he was too close. Mind you, that would only work in the favor of the suspect if the alcohol content of the room was deemed high, it would only lower the test result for the suspect. If it was out of spec, we would have to either take him to another station with a breathalyzer or to the local state police office to have them tested there, the machine also couldn't be used until it was serviced and recalibrated (no power cycling and hoping for the best). In the state of MS though, you had a right to take a blood test instead of a breathalyzer, which was deemed more accurate. (0.0800 was the blood limit standard, 0.08 was the breath limit standard)
Of course, all tests were done voluntarily. No law enforcement can ever force you to take a breathalyzer test without your consent, nor can you be forced to take a blood test unless there is more than just a traffic stop (accident, etc) or it is beyond your second offense, and both require a signed warrant from a judge.
You can always forfeit the test and just lose your license for 3-5 years. I know it sounds harsh, but driving is indeed a privilege and not a right, but it's better than getting a DUI/DWI when you know you're over the limit.
#Comment Re: made: 2009-05-15 15:45:32.155679+00 by:
Larry Burton
People keep telling me that driving is a privilege and not a right but just because people keep repeating it doesn't make it so. I claim driving as a right under the 9th amendment. ;)
#Comment Re: made: 2009-05-15 16:38:04.730337+00 by:
mvandewettering
Readings are Not Averaged Correctly: When the software takes a series of readings, it first averages the first two readings. Then, it averages the third reading with the average just computed. Then the fourth reading is averaged with the new average, and so on. There is no comment or note detailing a reason for this calculation, which would cause the first reading to have more weight than successive readings.
My guess is that some clever programmer thought that this was a good idea because it saved them the trouble of allocating an array to store the readings. Of course, you could just sum the readings, then divide by the number of readings, but that would be too straightforward.
Incidently, the quote above contains a bug itself: it isn't the first reading that has more weight, it's the last reading (it accounts for 50% of the final value).
This all points out that programming is devilishly hard, and most people don't do it very well at all, and most people do it very poorly indeed when they believe that their code will never be scrutinized by anyone.
#Comment Re: made: 2009-05-15 16:40:07.626587+00 by:
JT
There really are easier ways to beat DWI charges. Keep a pint of vodka in your glove compartment. If you ever get pulled over by the police, step out of the vehicle before he gets out, chug every drop of that vodka, then throw the bottle back into your car (don't want to get a ticket for littering). At that point, tell the cop to call a towtruck and a taxi because in 30 minutes, you're going to be wasted out of your mind.
He will have no proof that you were intoxicated before you did that, and there is a 30 minute waiting period where you're not allowed food or drink before you have a breathalyzer test, which gives time for that vodka you just drank to get into your bloodstream and skew the results. A warrant would take even longer than that so you're safe on a blood test too. You'll have to pay $100 for a tow truck and $25 for a cab, but it'll be cheaper than a DWI.
#Comment Re: made: 2009-05-15 17:06:25.963113+00 by:
Dan Lyke
I know that MarkV has sat on a jury where the details of such things were discussed (the particulars, if I remember it right, was that the guy's car broke down, he called for help, while he was waiting he had a beer or two, and then there was something involving the other guy pushing and he steered and that was what got him busted?), but I'd get legal advice specific to the jurisdiction in which you expect to be arrested before attempting that technique...
Aren't there also open container misdemeanors which could be used to make your life difficult with that technique?
#Comment Re: made: 2009-05-15 19:53:06.328988+00 by:
m
In some states just being in a stalled ncar without a key in the car, on you own property while inebriated is grounds for a DWI. In some states being drunk on a riding lawnmower on your own property will get you arrested. My neighbor was fortunate when he ran his car into a pond on his own private property -- no bust in NY, although the trooper tried hard to find some excuse.
One of the first programs anyone writes in chemistry (Beer's law -- no pun, real name). It not difficult programming. Anyone who can't get this right, doesn't want to get it right.