Slashdot Mirror


Court Orders Breathalyzer Code Opened, Reveals Mess

Death Metal writes with an excerpt from the website of defense attorney Evan Levow: "After two years of attempting to get the computer based source code for the Alcotest 7110 MKIII-C, defense counsel in State v. Chun were successful in obtaining the code, and had it analyzed by Base One Technologies, Inc. By making itself a party to the litigation after the oral arguments in April, Draeger subjected itself to the Supreme Court's directive that Draeger ultimately provide the source code to the defendants' software analysis house, Base One. ... Draeger reviewed the code, as well, through its software house, SysTest Labs, which agreed with Base One, that the patchwork code that makes up the 7110 is not written well, nor is it written to any defined coding standard. SysTest said, 'The Alcotest NJ3.11 source code appears to have evolved over numerous transitions and versioning, which is responsible for cyclomatic complexity.'" Bruce Schneier comments on the same report and neatly summarizes the take-away lesson: "'You can't look at our code because we don't want you to' simply isn't good enough."

126 of 707 comments (clear)

  1. But does it work? by will+this+name+work · · Score: 4, Insightful

    Poorly written code is one thing, but does it ultimately work?

    1. Re:But does it work? by Jason1729 · · Score: 4, Insightful

      Does it matter? The real question is "Can a prosecutor convince a computer illiterate judge beyond reasonable doubt that it does ultimately work?".

    2. Re:But does it work? by Yold · · Score: 5, Insightful

      I read the report earlier, and there are some very valid issues with the source. The first is that in incorrectly averages readings taken, assigning more weight to the first reading than the subsequent ones. It also has a buffer overflow issue, where an array is being written past its end, and even if this results in an error, it goes unreported.

      You would have to be a fricken moron not to have a problem with mis-averaging, however in my experiences with law-people, they can be even worse than PHBs.

    3. Re:But does it work? by gd2shoe · · Score: 4, Insightful

      Good question, but it needs to be reworded. Does it always work for all inputs?

      Also important, if it's a poorly written mess, why is the company claiming that it works? I see no indication that they've done due diligence for a device used to convict people. Just because they've never observed it to fail, doesn't mean a thing.

      --
      I won't join Slashcott. OTOH, If Beta goes live, I just won't be back until it's fixed. Sorry Dice.
    4. Re:But does it work? by geekgirlandrea · · Score: 5, Informative

      Read the article. The code in question, among other things, calculates an arithmetic mean of a sequence of values by successively averaging each value with the mean of all the previous ones, and reduces 12 bits of precision coming from the hardware sensor to 4 for some unspecified but undoubtedly stupid reason.

    5. Re:But does it work? by mea37 · · Score: 4, Insightful

      My first thought as well.

      Of course, with poorly written code, it's hard to show whether or not the code ultimately works by examination of the code.

      Then again, proving that the code works (which should be the standard when the code is analyzed in court) by code examination is very difficult even for well-written code.

      Perhaps a better approach would be documented, repeatable testing of the device. When I challenge a radar gun, I get to ask about its calibration documents, but I don't think I get to debate the blueprints from which it was built.

      My personal opinion - and before getting on an "innocent until proven guilty" kick bear in mind that I'm not a part of the court system in this case - is that the defense realizes that almost all software systems look awful and are trying to game their way out of a conviction they've probably earned.

      That said, if for no other reason then to eliminate such gaming, there should be standards for testing and documenting the proper function of these devices. Any device that can't be calibrated and tested with sufficient certainty should be banned from use as evidence in court. If the device passes the test, then exactly how it does it shouldn't really matter.

    6. Re:But does it work? by MozeeToby · · Score: 4, Insightful

      I'd be more interested in their test plan and test results than their source code if I were trying to convince a computer illiterate judge of something. Find a missing test case or an uncovered corner condition and you might have a decent case, code that doesn't pass static analysis and is ugly... well that pretty much defines 99% of the code out there.

    7. Re:But does it work? by vertinox · · Score: 4, Insightful

      Of course, with poorly written code, it's hard to show whether or not the code ultimately works by examination of the code.

      Of course it works because it gives an end result instead of an error message.

      The question every should ask is "Does it work accurately?" or "Does poorly written code skew the results?"

      Can the defense prove that the code was written so haphazardly that it ignores some data or does it round incorrectly like Excel does? These things do and can happen with sloppy code.

      That said, if the code is just poorly commended and indented correctly (*wink*) but does the math right and makes sure there isn't a sampling or rounding problem, then it isn't a problem.

      --
      "I am the king of the Romans, and am superior to rules of grammar!"
      -Sigismund, Holy Roman Emperor (1368-1437)
    8. Re:But does it work? by plague3106 · · Score: 4, Insightful

      code that doesn't pass static analysis and is ugly... well that pretty much defines 99% of the code out there.

      It's more than ugly, it's difficult to maintain. Also, this point is largely irrelevent; 99% of the code out there isn't spitting out a number that says you're guilty of a serious offense.

    9. Re:But does it work? by wiredlogic · · Score: 3, Insightful

      Regardless of the state of the code no breathalyzer truly "works". None of them can directly detect blood alcohol content. All they do is use a proxy to estimate using the reaction products from your breath. These devices are wholly unscientific. There is no possible way they can derive a credible estimate with a precision of 0.001% or even 0.01%. There is no accounting for body size, type, or metabolic rate. Furthermore these devices can be triggered by more than just ethanol. Chocolate is reported to cause a false reading as well as other common foods. This is why one should always refuse a breathalyzer test even if you haven't been drinking. There are too many chances for a false positive to risk it.

      --
      I am becoming gerund, destroyer of verbs.
    10. Re:But does it work? by internerdj · · Score: 4, Insightful

      Also it looks like their out of range error scheme was to set it to the closest legal value and report it if it was recurring and continuous. Assume for a moment you took a test right after the last good reading, you took 32 samples. It would only report an error if all 32 samples failed. Otherwise 31 of the 32 will report the maximum legal extreme closest to that reading. Couple that with the fact that the averages were taken incorrectly, this isn't just reasonable doubt it is worse than using a RNG to find if they are drunk.

    11. Re:But does it work? by Volante3192 · · Score: 3, Insightful

      If I read the report right, they coded the thing to never actually fail in the first place. It'll always return what can be passed off as a legitimate answer.

    12. Re:But does it work? by digitalunity · · Score: 3, Insightful

      Looks like the answer is no. It's a black box that doesn't report internal errors except when it can't ultimately decide on an answer.

      The source code is useful only for showing the machines can be unreliable in certain circumstances, but unless he has substantiating evidence to show it gave an incorrect result he is unlikely to prevail.

      Example: Guy blows .09 after drinking 2 beers. He might have a case that the machine was wrong. Example 2: Guy drinks 8 beers and blows .18. Machine might be wrong, but even if it was off by a bit due to rounding averages, he's still guilty as sin.

      Sucks, but that's just the way the law looks at it.

      Someone mentioned earlier that the weighting of samples under repeat tests give weight to the first blow, which is a big red flag. The initial blow is probably the sample most likely to be contaminated by liquid from the mouth which will skew the reading dramatically, leading to higher BAC's than actuality. If someone blew a .12 and then a .07 on the same machine, he could be found guilty but it's possible the second sample is more accurate.

      --
      You can't legislate goodness. Let each to his own destiny, by will of his freely made choices.
    13. Re:But does it work? by Carnildo · · Score: 5, Insightful

      Perhaps a better approach would be documented, repeatable testing of the device. When I challenge a radar gun, I get to ask about its calibration documents, but I don't think I get to debate the blueprints from which it was built.

      Calibration and testing won't reveal all the edge cases that might cause errors. Consider a radar gun designed to take the average of five samples. You've got a car moving away from you at 70 MPH, and a duck flies into the beam for one sample, moving towards you at 5 MPH. This gives the following five samples:

      70 70 70 -5 70

      I can see a way that badly-written code would turn that into an average speed of 106 MPH (storing a signed char as an unsigned char, which would turn the -5 into a 251), and yet it would pass calibration and every test someone's likely to perform.

      --
      "They redundantly repeated themselves over and over again incessantly without end ad infinitum" -- ibid.
    14. Re:But does it work? by DnemoniX · · Score: 2, Insightful

      Well the problem with calculating the averages should honestly be enough to get this tossed. The defense can put up an exhibit with a set of numbers using the flawed methodology which shows a person to be over the limit. Then call an expert witness with a math degree, or an accountant for that matter. Show that the average when calculated normally is below the the legal limit. Even better is if you can show that the machine has calculated an average that falls below the legal limit but should have been above. That would show the device to be a public safety hazard for clearing persons who are actually impaired.

    15. Re:But does it work? by Hognoxious · · Score: 2, Insightful

      There is no accounting for body size, type,

      There's no need to. It measures a concentration (per unit volume), not how many beers you drank.

      or metabolic rate.

      Irrelevant. Just because you'll sober up quicker doesn't mean you aren't drunk now.

      Try not to hit anybody on your way home.

      --
      Confucius say, "Find worm in apple - bad. Find half a worm - worse."
    16. Re:But does it work? by Yold · · Score: 2, Insightful

      In Minnesota (and other states), it is a crime to refuse a roadside breathalyzer test due to "implied consent" laws.

    17. Re:But does it work? by Anonymous Coward · · Score: 5, Informative

      >> assigning more weight to the first reading than the subsequent ones.

      It seems to apply more weight to later readings:

      where a1=1, b1=2, c1=3, d1=4
      (A1+B1+C1+D1)/4 = 2.5 (the correct average)
          and
      (((((A1+B1)/2)+C1)/2)+D1)/2 = 3.125

    18. Re:But does it work? by Yold · · Score: 4, Informative

      correction, you may refuse a roadside breath test, but not one at the police station.

    19. Re:But does it work? by fracai · · Score: 5, Insightful

      Presuming it's the same summary that I read, it contained a mistake.

      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.

      This actually places more weight on the final reading, not the first.

      --
      -- i am jack's amusing sig file
    20. Re:But does it work? by MozeeToby · · Score: 4, Interesting

      No, but some no trivial amount of code is running the x-ray machine at the dentist, processing my credit card, managing my fuel injection, saving my thesis paper, and timing stoplights throughout my city.

      We trust our lives and livelihoods to shitty code every day and the plain fact of the matter is that shitty code usually works. As programmers we like to think of ourselves as artists; creating a master piece of perfectly engineered code. In reality, all projects face budget and time constraints, most projects have legacy code which is hard to maintain, and most teams have at least one guy who just doesn't get it.

      If the code works, and you can show empirically that the code works, that is proven beyond a reasonable doubt it my opinion. Not beyond any doubt, but that isn't the standard that our justice system is based upon.

    21. Re:But does it work? by Man+On+Pink+Corner · · Score: 2, Insightful

      The code in question, among other things, calculates an arithmetic mean of a sequence of values by successively averaging each value with the mean of all the previous ones, and reduces 12 bits of precision coming from the hardware sensor to 4 for some unspecified but undoubtedly stupid reason.

      Well, it's not hard to imagine why they throw away all those bits. Prospective LEO customer: "Wow, this thing never gives the same reading twice. How am I supposed to secure convictions with numbers this flaky?"

      The averaging thing, on the other hand... that's just a dumbass bug. One that's probably wrecked a few peoples' lives.

    22. Re:But does it work? by digitalunity · · Score: 4, Interesting

      Actually, research I read when I got my DUI in 2007 seemed to indicate the release of alcohol vapors into the air by the lungs can vary widely between persons, by as much as 20%.

      This has nothing to do with body size, type or metabolic rates that I'm aware of, but more research is obviously needed for the scientific community to reach a consensus. The sampling process is fundamentally flawed but the courts have routinely rejected any evidence to the contrary.

      I don't know about 49 of the states, but in Washington state, if you want something more accurate than a breathalyzer, you have to demand the police take you to the hospital to have blood drawn at your own expense. They are required by law to comply, but 99% of DUI suspects know nothing of their rights.

      If I got pulled over again that same night, I would have driven home without a DUI and even if they did manage to get me to perform parking lot special olympics(also called the field sobriety test), I would have asked for a lawyer. Like most first time offenders, I took a plea deal to avoid significant jail time and paid the ridiculous fine and took alcohol awareness classes. The whole thing was a farce, intended to make money.

      I blew .086% and easily could have challenged the results in court, given the breathalyzer had a sticker on it that said it hadn't been calibrated in 2 years.

      --
      You can't legislate goodness. Let each to his own destiny, by will of his freely made choices.
    23. Re:But does it work? by erroneus · · Score: 3, Insightful

      Whether or not it "works" isn't quite enough in my opinion. It needs to be clearly written in such a way that the purpose and methods used in sampling input from hardware and the making of calculations are verifiably accurate and true in all cases. This is an instrument that measures whether or not someone is within a prescribed legal limit and needs to be as provably clear and accurate as possible. We are talking about taking away freedoms from people as a result of this test machine and there should be as little room for error as possible.

      If I were to prescribe a system for analyzing breath for alcohol content, I would require that a single test unit be comprised of two machines from two different manufacturers and that any single sample be split equally between the two machines for measurement such that when both machines return results and are both in agreement within a prescribed "reasonable" difference from one another, then we might begin to say we have a reasonably accurate measure from which judgements can be reasonably made.

      In the mean time, software architecture needs to be held to the same legal standards as ACTUAL architecture and engineering. I recall being involved in a cabling project where all terminations were reading perfectly, but when I inspected the raceways, the bed radius of the cabling was way too tight and much of the cable was tied to various pipes and conduits and not fixed to the hardware intended for the handling of the cable. All of the cabling was not installed according to clear and complete specification and I was furious at what I found. The first answer offered to me was "but it all works right?"

      If you took your car in for repair and they charged you the full price of the repair with parts and you found that it was repaired with duct tape and bailing wire, would you accept "but it works!" as a reasonable answer to your complaint? I think not!

      Back to this situation: "Does it work?" The real answer? If you cannot read the code and make clear sense of it, you cannot prove that it works, only that it works under the practical conditions of testing. That is simply NOT good enough for any scientific measurement and especially not good enough for measurements that may be used to determine whether or not a person is sent to prison.

    24. Re:But does it work? by JCSoRocks · · Score: 5, Insightful

      I'm not generally someone that insists everything needs to be open source. However, in a situation like this, where this device makes the difference between a life changing conviction and exoneration, it's pretty obvious that people should have the right to examine it. The court was able to order it opened here, but it makes you wonder how many people have been screwed by this.

      Sadly in the majority of cases where evidence based on something like this (DNA, hair analysis, etc) is shown to be based on someone or something that's not good - nothing comes of it. I saw a blurb about a "forensic expert" that would give the prosecution any testimony they wanted. The state he was based in refused to reexamine the cases he was involved in even after he was shown to be a liar.

      It's depressing but it's one reason I steer clear of the law as much as I can. As much as we Americans like to think of our legal system as dispensing justice, the sad fact is that it frequently doesn't.

      --
      You are using English. Please learn the difference between loose and lose; they're, there, and their; your and you're.
    25. Re:But does it work? by mea37 · · Score: 2, Insightful

      Yes, but to GP's point - if the code had been subjected to proper tests, then it wouldn't matter how hard it was to maintain. Either the maintainers overcame that difficulty and it passed the test, or they didn't and it failed.

    26. Re:But does it work? by sexconker · · Score: 4, Insightful

      Show me a programmer creating "perfectly engineered code", and I'll show you a programmer building up its resume.

    27. Re:But does it work? by wfstanle · · Score: 4, Informative

      "Just because they've never observed it to fail, doesn't mean a thing."

      Correct! This is a point that many people fail to understand. Testing can't prove that there aren't bugs. All it proves is that a bug did not occur. Failing a test just proves that a bug exists while passing all test just proves that you failed to find a bug. Passing many tests can boost your confidence that there are no bugs. Verification can prove that your code is correct but for most programs it is unfeasible.

    28. Re:But does it work? by digitalunity · · Score: 5, Informative

      In all 50 states, refusal to take a breathalyzer at the police station will result in a 1 year(minimum) suspension of your drivers license.

      In all 50 states, you can refuse to take a roadside breathalyzer as they're inadmissable in a court of law. If you have had even 1 drink, always ask to go to the station for a real breathalyzer. The PBT's, or portable breath testers, are wildly inaccurate and only give the police probable cause to arrest. It will not work in your favor to take it.

      --
      You can't legislate goodness. Let each to his own destiny, by will of his freely made choices.
    29. Re:But does it work? by digitalunity · · Score: 2, Informative

      Several states such as Washington state will let you get a blood test, but the breathalyzer at the station is still legally required and you have to pay for the blood test out of your own pocket.

      --
      You can't legislate goodness. Let each to his own destiny, by will of his freely made choices.
    30. Re:But does it work? by mea37 · · Score: 2, Insightful

      "Calibration and testing won't reveal all the edge cases that might cause errors"

      Then you aren't testing correctly.

      "I can see a way that badly-written code would turn that into an average speed of 106 MPH "

      You may need to revisit the legal definition of "reasonable doubt". Being able to contemplate a scenario where the evidence could be wrong is not sufficient to overturn the evidence.

      Regardless, if the testers don't know that "an input suffered overflow or underflow" is an edge case they need to test, then they aren't testers.

    31. Re:But does it work? by HisOmniscience · · Score: 3, Insightful

      ...programmer building up its resume.

      I always knew programmers weren't human.

    32. Re:But does it work? by geekgirlandrea · · Score: 4, Interesting

      Well, if we assume the machine was sensitive up to the LD50 for ethanol of 0.5% BAC, then with only 4 bits of precision the uncertainty just from the rounding error is comparable to the difference between being over the limit and being completely sober. This was covered in the comments on Bruce Schneier's blog. That one's probably wrecked a few peoples' lives too.

    33. Re:But does it work? by Darkness404 · · Score: 3, Insightful

      The problem isn't that it can break, the problem is it can return bad readings. For example, a dentist's X Ray machine isn't suddenly going to show cavities everywhere because there is no code in the X-ray. Worst thing with a credit card machine is that it doesn't work, most of the time it doesn't overcharge you or something like that, or if it does a few phone calls will sort it out. Again, the worst thing that happens with fuel injectors is they break, your car doesn't run, you pay a few hundred and get it fixed. Worst thing with stoplights is they break, there is always a human driver who can figure out if all the lights are on red or green and call the police to manage traffic.

      Breathalyzers are basically black boxes, there is no human to really check them out. With the code more apt to return false readings then simply break, it is dangerous code, when those readings can be the difference between a crime and a non-crime.

      --
      Taxation is legalized theft, no more, no less.
    34. Re:But does it work? by DeadCatX2 · · Score: 5, Insightful

      You are correct. In the biz, we refer to this as an exponentially-weighted moving-average-filter. Recent samples are weighted more heavily than older samples.

      y(n) = alpha*x(n) + (1 - alpha)*y(n-1)

      The alpha value controls how much of the current input makes it to the output and how much of the old output stays. i.e. with an alpha value of 0.5, half of the new value is added to half of the old value. With an alpha of 0.1, 10% of the new value gets added to 90% of the old value.

      This filter is nice because it doesn't require you to remember all the values that you want to average together, but it's a horrible way to get over the inherent noisiness in sensors.

      --
      :(){ :|:& };:
    35. Re:But does it work? by Rene+S.+Hollan · · Score: 2, Interesting

      Yes, but in WA you can be convicted under DUI with 0% BAC.

      The "influence" does not have to be alcohol, nor an identifiable chemical intoxicant.

      Driving erratically is evidence enough of being "influenced".

      --
      In Liberty, Rene
    36. Re:But does it work? by Anonymous Coward · · Score: 3, Interesting

      To get more convictions... this makes sense now.

      Common wisdom holds that the end of a breath from the "bottom" of the lungs contains a higher percentage of alcohol than the main body of the breath, this is held to be why the officer will tend to tell you to push harder to get that last higher sample into the device. If anything sets off the machine, it'll be that last bit with a more concentrated sample.

      Whether that reflects the *actual* blood alcohol level in any well defined and useful fashion needs to be explored some more.

    37. Re:But does it work? by Mateo13 · · Score: 3, Funny

      I wonder if they're hiring QA testers...

    38. Re:But does it work? by Hatta · · Score: 3, Informative

      It measures a concentration (per unit volume), not how many beers you drank.

      It measures a concentration per unit volume of breath. There are many assumptions in extrapolating this to concentration per unit volume of blood.

      --
      Give me Classic Slashdot or give me death!
    39. Re:But does it work? by Tanktalus · · Score: 3, Insightful

      No, writing lousy code is not a prerequisite for being considered great and invaluable. As /.ers are so fond of saying, correlation is not causation.

      It's just that if you are a lousy coder, you probably have time for proper amounts of sucking up, while if you're a great coder, you probably are too busy getting things to work properly to concern yourself with interpersonal relationships. And it's easy to see why the former get more promotions than the latter.

    40. Re:But does it work? by TheEldest · · Score: 5, Interesting

      This seems to make sense to me. The breathalizer is supposed to measure the blood alcohol content, and this is done by measuring the alcohol content in air expelled by the *lungs* (with a knowlege of partial pressures).

      But if you equally weight beginning readings with ending readings, then you can be skewed by the first reading, which comes from the air in the mouth, instead of the lungs (giving low scores for people with time since their last drink, and people high scores with a recent last drink).

      I would think that this method would give a more accurate reading by filtering out the readings from 'mouth air' and giving preference to 'lung air'.

      But regardles, tests should have been done using both methods, and comparing to blood test to see which returns more consistantly accurate results. I wonder if those tests need to be made public as well.

    41. Re:But does it work? by SoupGuru · · Score: 4, Interesting

      Remember when it used to be you couldn't drunk drive?
      Then it was you couldn't be behind the wheel while drunk?
      Then it became you couldn't even be in the driver's seat with the car off while drunk?
      Then it became you couldn't drive if you couldn't get out and walk in a straight line?
      Then it became reciting your alphabet backwards...
      Then suddenly, you couldn't have an arbitrary percentage of alcohol in your blood to do all those things.
      Then it became whatever the machine said your blood alcohol might be.

      There are no laws against drunk driving anymore. There are laws about not being able to potentially operate a vehicle if a machine determines you have enough alcohol on your breath.

      --
      What doesn't kill you only delays the inevitable
    42. Re:But does it work? by pjt33 · · Score: 4, Insightful

      This filter is nice because it doesn't require you to remember all the values that you want to average together

      Why would you need to remember all the values? As long as you remember the number of values and their total you're fine.

    43. Re:But does it work? by bcrowell · · Score: 4, Insightful

      Like most first time offenders, I took a plea deal to avoid significant jail time and paid the ridiculous fine and took alcohol awareness classes. The whole thing was a farce, intended to make money.

      When you use words like "farce" and "ridiculous," it makes it sound like you don't want to take responsibility for your own actions. I don't think DUI laws are "a farce, intended to make money." I think they're intended to protect people like me from getting killed by people like you.

    44. Re:But does it work? by Grishnakh · · Score: 4, Insightful

      Our legal system and government are about as non-corrupt as Mexico's. Ours just isn't quite as blatant about it.

    45. Re:But does it work? by Man+On+Pink+Corner · · Score: 2, Informative

      Very true. To some extent, it's reasonable to truncate a few bits of precision if the noise floor of the BAC sensor is substantially higher than the dynamic range of a 12-bit ADC. No reason to display a bunch of meaningless flickering digits extending far to the right of the decimal point.

      But when you're displaying a decimal value, every place value with full 0-9 range takes about 3.3 bits of precision. If you're going to return numbers like "0.18" from a device with a range of 0.00 to 0.99, you need to keep at least 7 bits intact, or you're making stuff up. If their BAC sensor's uncertainty is insufficient to provide consistent, monotonic 7-bit values, or if they're deliberately throwing away all but four bits, then they're making stuff up.

      So, yeah. Conclusion: they're making stuff up.

    46. Re:But does it work? by camperdave · · Score: 3, Funny

      We trust our lives and livelihoods to shitty code every day

      Well, like the saying goes: If builders built buildings the way that programmers write programs, the first woodpecker to come along would destroy civilization.

      --
      When our name is on the back of your car, we're behind you all the way!
    47. Re:But does it work? by Grishnakh · · Score: 4, Interesting

      I disagree. Anything upon which guilt or innocence rests on needs to be held to a higher standard.

      For many other applications, especially non-government ones, if the code doesn't work well, then customers probably aren't going to buy it, and changes will be made. For instance, your example of fuel-injection code. If you don't do that correctly, you're going to have an engine that runs like crap and get poor economy. Cars that run poorly generally don't sell well. They might sell some, but as we see with GM and Chrysler, you have to do better than that to avoid bankruptcy.

      Saving your thesis paper? The code in TeX is probably some of the most bug-free code around. At least I hope you're using TeX and not something crappy like MS Word for a thesis. But even MS Word isn't that bad, since so many businesses rely on it and don't have problems with random data corruption to my knowledge.

      Timing stoplights is a good counterpoint to your example. In my experience, stop lights have horrible timing most places I go. It's almost like they're intentionally designed to make you stop at every single light, unless you drive at > 80mph on surface streets. Why is such poor performance accepted from our traffic lights? Because they're run by the government, and we the people don't have a choice. That's exactly the same as this breathalyzer crap: if you're accused, you don't get a choice about which breathalyzer they use on you. It's decided by the government (probably with help from bribes), and that's what they use, whether it works well or not.

    48. Re:But does it work? by The+Moof · · Score: 5, Interesting

      Don't always assume the judge will, in fact, look at the evidence and arguments. In their eyes, it doesn't look good to overturn a DUI conviction. Period.

      Had a buddy of mine leave a night club and he got pulled over for supposedly making an illegal left turn. Blew over the state's .07 and got arrested per the usual.

      However, the judge didn't care that there was no reason to be pulled over (with photos of the left-turn sign) since the cop explicitly said it wasn't due to erratic driving, *only* the 'illegal' left turn. Examples must be made. DUI upheld.

      Hell, even I got pulled over once for simply driving at 2am, but my breathalyzer revealed a stunning 0.00% BAC. After chatting with the cop for a bit, turns out they were just looking for easy DUI targets, and I happened to be driving on the same road as them.

    49. Re:But does it work? by evanbd · · Score: 4, Informative

      If you have a noisy sensor and are trying to keep a low-noise estimate of the input, while that input is changing, you do some sort of filtering on the data. The weighted rolling average described above is nice for a number of reasons, mainly it's simple to implement and simple to analyze. In some cases, other filters are better.

      If you have a noisy sensor and want to measure a single unchanging input, you would want a different sort of filter. In this case, the simple arithmetic average works quite well.

      As you correctly observe, the two filters of similar complexity. Which one you use should depend on the sort of input you're trying to measure. In this case, they used the former type of filter on the latter type of data, which is a definite no-no. This will result in data that is far noisier than you would otherwise expect from the raw sensor noise and the number of samples taken. When that noise could be the difference between a DUI conviction and and the cop telling you to drive home carefully, I'd say that's worth worrying about.

    50. Re:But does it work? by Chirs · · Score: 2, Informative

      A moving average is useful if you don't have a large enough data type to store the sum of all the values.

    51. Re:But does it work? by Stormwatch · · Score: 3, Funny

      Oops, I moderated the wrong tag by accident.

      Browsing under the influence, I see.

    52. Re:But does it work? by jonbryce · · Score: 3, Informative

      In Britain, the breathalysers decide whether or not you get taken to the police station.

      When you arrive at the police station, they take a blood sample. They test half of it, and that decides whether or not you get convicted. You get the other half and can arrange for your own tests on it.

    53. Re:But does it work? by Timmmm · · Score: 2, Insightful

      You know you don't actually need to do that.

      average = (new_value-average)/++n + average;

      I think that should work.

    54. Re:But does it work? by Thinboy00 · · Score: 2, Informative

      This seems to make sense to me. The breathalizer is supposed to measure the blood alcohol content, and this is done by measuring the alcohol content in air expelled by the *lungs* (with a knowlege of partial pressures).

      Actually, it measures presence/absence of ketones in the air. Also, they have you blow "continuously" for several seconds (the mouth doesn't hold that much). Finally, .08 is considerably drunk, but it isn't you're-falling-over-how-could-you-possibly-think-you-could-drive drunk.

      --
      $ make available
    55. Re:But does it work? by Grishnakh · · Score: 2, Insightful

      You need to get your head out of your ass and learn to read. My point is that any car company putting out engines that run like crap and get poor economy (relative to their competition for the same vehicle type of course) will not last long. I did not say that GM and Chrysler are going down because of crappy engines. In fact, I'd say that every engine out there by any major manufacturer runs just fine these days; I don't think any of them have highly shoddy FI code.

      What I said there was that a car company has to do better than selling some [cars] to survive. I.e., you might be able to get a few morons to buy a car that runs like crap, but it's not going to be enough customers to keep the company afloat. Especially in today's economy, a company needs to do well in most aspects of its business in order to survive.

      But that doesn't apply to this breathalyzer company, because their customer is the government, and you don't have to even make a decent product when the government is your customer; you just have to secure a contact, maybe with a few bribes. It also helps a lot when the customer (law enforcement) doesn't care about how well your product works, as long as they can use it to make lots of money, even if it's fraudulent. This is the same situation we have with red-light and speed photo enforcement. If you get snapped by a speed camera, and you're sure you were under the speed limit, what are you going to do? Threaten to take your business away from Redflex? Your local police department or municipal government certainly doesn't care if the ticket was in error, because they're making money from you because of it. What are you going to do, vote them out? Good luck with that.

    56. Re:But does it work? by cayenne8 · · Score: 2, Interesting
      "Actually, it measures presence/absence of ketones in the air. Also, they have you blow "continuously" for several seconds (the mouth doesn't hold that much). Finally, .08 is considerably drunk, but it isn't you're-falling-over-how-could-you-possibly-think-you-could-drive drunk."

      Keytones!?!

      So, I wonder if you could make an argument against this evidence if you are on Atkins or some other form of low carb diet that puts you into a constant state of ketosis?

      And as for .08...that is NOT drunk, not for most people. The .1 was more fair, but, .08 can get a grown man on just a few glasses of wine with a meal depending on situation.

      It really should be more subjective somehow...I mean, you can have someone that is severely impared on 2 drinks, and another big fella that can have 4-6 beers in a short period and be perfectly fine. I guess they had to have a number somewhere, but, .08 is WAY too low.

      I really hope some of the attempts to break the feds power over the states by blackmailing them over funding can work here soon. It was the MADD groups that are really after NO drinking permitted that forced them to force all the states to raise the drinking age to 21...and lower the limit to .08.

      The feds should NOT have that power.

      --
      Light travels faster than sound. This is why some people appear bright until you hear them speak.........
    57. Re:But does it work? by decoy256 · · Score: 4, Insightful

      No, our system doesn't dispense "justice", which is why I'm a defense attorney.

    58. Re:But does it work? by 0100010001010011 · · Score: 4, Insightful

      The majority of crashes and deaths aren't caused by people that blow a 0.086. They're habitual offenders who blow .25s.

    59. Re:But does it work? by brainiac+ghost1991 · · Score: 3, Interesting

      but why were you driving while over the limit anyway. Driving a car is dangerous, not just for you, but for those around you, by being under the influance of alcohol you are risking killing someone. Why take the risk? if you need to drive don't drink any alcohol.

    60. Re:But does it work? by Toonol · · Score: 2, Insightful

      That may or may not be a flaw. It certainly isn't a true average, but an average isn't the only legitimate way to combine successive data values.

      That said, I'm not sure why a rolling average like this would be used for this purpose. Is there a medically sound, scientifically reviewed 'proper' procedure to measure alcohol in breath? I have a fear that this was just thrown together by some programmers.

    61. Re:But does it work? by drsmithy · · Score: 3, Insightful

      If I were to get pulled over, and knew I was over the now ridiculously LOW limit of .08...

      That's not a "ridiculously LOW" limit. Indeed, for most of the world it's _over_ the limit.

    62. Re:But does it work? by Skater · · Score: 2, Informative

      Wasn't there an X-ray machine with a coding error that caused people to get many times the dose they should've? Yep, here it is.

    63. Re:But does it work? by bcrowell · · Score: 2, Insightful

      a first offense can cost the driver as much as $10,000 in fines and penalties alone

      A drunk driver could kill me. I don't think $10,000 is excessive as a deterrent. My life is worth a lot more to me than $10,000.

    64. Re:But does it work? by JackieBrown · · Score: 2, Insightful

      It really should be more subjective somehow...I mean, you can have someone that is severely impared on 2 drinks, and another big fella that can have 4-6 beers in a short period and be perfectly fine.

      As much as .08 sucks, I'd rather have that than a cop "subjectively" deciding if I am drunk.

    65. Re:But does it work? by cayenne8 · · Score: 2, Insightful
      "You're an idiot. Blood alcohol is blood alcohol. The big guy can drink a little more than the little woman. Just not as much as you'd like."

      Sure, BAC is BAC....but, different people can handle and function to MUCH different levels at given BAC. At .04, someone might be really out of it...but, others at .08 are just barely starting to show any signs of intoxication at all. Some people just have more tolerance than others.

      --
      Light travels faster than sound. This is why some people appear bright until you hear them speak.........
    66. Re:But does it work? by ClosedSource · · Score: 2, Insightful

      But laws are usually based on the measured value rather then unmeasurable and subjective determination of the driver's ability to function.

    67. Re:But does it work? by bh_doc · · Score: 2, Insightful

      "Its" referring to a person is almost certainly not correct. "His" is arguably correct, as it is both the male-specific and, historically, gender neutral pronoun. In recent time it has been assumed almost exclusively to be male-specific and its gender-neutral use has fallen out of favour. "Their" as a singular gender-neutral pronoun has since become popular. Welcome to evolving English. http://en.wikipedia.org/wiki/Gender-neutral_pronoun#Historical_solutions

    68. Re:But does it work? by ppanon · · Score: 4, Insightful

      You can think that you're doing fine because you've gotten good at compensating. For instance, dancers and figure skaters can learn to compensate for inner ear/balance issues from spinning at speeds and duration that would have most people nauseous or throwing up, but the spinning doesn't affect their reflexes. However you don't have to have your cochlear sense of balance feel impaired for intoxication to be affecting your ability to drive. It doesn't take much alcohol for your reflexes and cognitive response to be impaired enough to cause an accident, even if it's not obviously apparent. While there is some variation, the acceptable BAC levels were based on correlation with average results from testing for significant reflex and attention deficits.

      You might be one of the outliers, but the odds are much better that you might are one of the myriad of people who delude themselves into thinking that they are outliers because their judgement is impaired. Unless you've actually personally undergone reflex/response testing by a third party in conjunction with BAC testing to judge your personal susceptibility to alcohol, your judgement on the subject after alcohol consumption is unreliable. However your ability to compensate for impairment in normal driving conditions wouldn't save you from an accident in an unexpected situation the way unimpaired reflexes would.

      The small restriction on the few outliers is not a high price to pay for the safety of innocents. Nobody says you can't drink or drive, just that you have to exercise some level of personal responsibility and not do both (or for that matter, drive and consume any other drug that impairs your ability to drive safely)

      --
      Laissez lire, et laissez danser; ces deux amusements ne feront jamais de mal au monde. - Voltaire
    69. Re:But does it work? by SnowZero · · Score: 2, Informative

      So, let's assume that individual readings are the true value plus some zero-mean error (it's supposed to be calibrated, after all). Using the exponential average that was in the actual device's code, your error will never be better than 1/2 of an individual reading (the last one). To beat this with a array to implement a sliding-window average, you'd need only 5 entries to get a more accurate reading than their approach (error is proportional to sqrt(N) for an arithmetic mean). That's 10 bytes. How cheap of a processor do you expect them to be using, such that 10 bytes is unacceptable? With 16 bytes, you get twice the accuracy, as well as the ability to take the average by a bit shift (likely not worth bothering with since you would convert it to base-10 for display anyway).

    70. Re:But does it work? by ppanon · · Score: 2, Interesting

      That's close. Since you want to take the previous average, turn it back into a running total by multiplying it by the old item count, sum that with the new value, and finally dividing by the new item count, we get:

      n++
      new average = old average*((n-1)/n) + new_value/n

      which, simplified into your format would actually make it:

      average = (new_value-average)/n++ + average;

      From a numerical analysis point of view though, you're probably better off getting separate totals and count and calculating the average at the end. There will be less accumulated error.

      --
      Laissez lire, et laissez danser; ces deux amusements ne feront jamais de mal au monde. - Voltaire
    71. Re:But does it work? by centuren · · Score: 2, Insightful

      "You're an idiot. Blood alcohol is blood alcohol. The big guy can drink a little more than the little woman. Just not as much as you'd like."

      Sure, BAC is BAC....but, different people can handle and function to MUCH different levels at given BAC. At .04, someone might be really out of it...but, others at .08 are just barely starting to show any signs of intoxication at all. Some people just have more tolerance than others.

      Police officers, at least in this state, still use their judgement when interviewing and observing someone suspected of driving drunk. For example, you don't actually have to have .08 to be arrested. If you're below .08 but still relatively high, you can be arrested for reckless driving. Obviously you can be arrested for reckless driving without a breathalyser if you are driving recklessly, but it's my understanding they can use their judgement applying that charge to drivers who are intoxicated but within the legal BAC.

      Of course, that doesn't mean they'll judge you to be fit to drive if you're over .08, but the line has to be drawn somewhere. Since it is so low for some people when comparing BAC to motor skill impairment, the best advice is always to not drink at all if you know you'll be driving, or not drive at all if you find you've had more than one drink. All the same, I wouldn't be surprised if I found out the average DUI arrest recorded a BAC of well over .1.

    72. Re:But does it work? by dasunt · · Score: 2, Interesting

      The majority of crashes and deaths aren't caused by people that blow a 0.086. They're habitual offenders who blow .25s.

      Don't forget the statistics are sometimes utterly bullshit.

      Here in Minnesota, we had an interstate bridge collapse (the I35W bridge) into a major river a few years ago.

      Officially, all those deaths from the bridge collapse count as alcohol-related fatalities, due to the fact that a few of the people who died had detectable levels of alcohol in their blood.

      Note, they weren't necessarily drunk or even impaired, but since they had detectable levels, it counts.

    73. Re:But does it work? by Splab · · Score: 4, Interesting

      Since I'm not an American I don't know how a drunk stop works, but here in Denmark, you get to blow on a mobile device, if it shows up as drunk you are taken to the hospital for a blood sample and only that blood sample will be used against you.

      Are only the mechanical readings being used in the US?

    74. Re:But does it work? by Timmmm · · Score: 2, Informative

      That's the same. You just started n at a different value... :-)

  2. Ballmer Peak by Anonymous Coward · · Score: 2, Funny

    Clearly their programmers were not drunk enough when making this. Or, they were too drunk.

    1. Re:Ballmer Peak by Anonymous Coward · · Score: 3, Funny

      Clearly their programmers were not drunk enough when making this. Or, they were too drunk.

      How else would you suggest they test whether or not it works? Huh, smartguy?

  3. Code by Quiet_Desperation · · Score: 5, Insightful

    not written well, nor is it written to any defined coding standard

    Ah, so it's like most of the code in the world.

  4. Re:Coding Standard by kailoran · · Score: 4, Insightful

    Because the output is used as evidence in court?

  5. Good! by SanityInAnarchy · · Score: 4, Insightful

    Ok, I'm not happy that some people almost certainly were measured inaccurately by these things. I'm not happy that this company was allowed to pull this kind of shit -- when you do government contracting, the government should own what you do.

    However, I am very glad that the precedent has been set.

    And I am especially glad that not only is there precedent, but there's a real live example of why we need this stuff to be open.

    --
    Don't thank God, thank a doctor!
    1. Re:Good! by Red+Flayer · · Score: 5, Insightful

      when you do government contracting, the government should own what you do

      But they weren't doing government contracting. The produced a good that was purchased by the government. There's a very big difference.

      The key here is not that the government, or anyone, should own what they produced -- it's that when what they produced is used to convict someone, that person has the right to examine the methods used.

      It's not about openness, at all. It's about the right to a fair trial; openness is just a side effect.

      --
      "Trolls they were, but filled with the evil will of their master: a fell race..." -- J.R.R. Tolkien on Olog-hai
    2. Re:Good! by Midnight+Thunder · · Score: 3, Insightful

      The key here is not that the government, or anyone, should own what they produced -- it's that when what they produced is used to convict someone, that person has the right to examine the methods used.

      I will call out the company for doing shoddy work. The question is whether the device was ever certified for the purpose, and if it was who did it and what was the process used. If you are going to use something to prosecute, then there needs to be evidence that the device was tested and certified using a publicly documented process. This is black box testing and if the government never did it, then why is it allowed in court?

      --
      Jumpstart the tartan drive.
  6. Watch those comments... by tcopeland · · Score: 2, Funny

    ...from the article:

    Several sections are marked as "temporary, for now".

    So, make sure to strip out those TODOs before checking in the code. Bah!

  7. No surprise by infinite9 · · Score: 4, Insightful

    80% of the code in business fits this description. With 20 year old legacy code written by 50 consultants, then upgraded in India, then ported from one platform to another to another, and a database engine switch or two. Code gets senile. What do they expect? Good thing we're all just commodities... human lego bricks easily replaced with cheaper plastic.

    --
    Disconnect your television. Do your own research. Draw your own conclusions. They're probably lying. Don't be a sheep.
    1. Re:No surprise by legirons · · Score: 4, Insightful

      80% of the code in business fits this description

      how much of that code is given police powers to arrest someone?

    2. Re:No surprise by hondo77 · · Score: 2, Funny

      80% of the code in business fits this description. With 20 year old legacy code written by 50 consultants, then upgraded in India, then ported from one platform to another to another, and a database engine switch or two. Code gets senile.

      Ah, a co-worker!

      --
      I live ze unknown. I love ze unknown. I am ze unknown.
  8. not written to a coding standard? by AliasMarlowe · · Score: 2, Insightful

    Just because code is not written to some official standard does not mean it is guaranteed to be buggy. Undisciplined coding is as bad as undisciplined specifications - results can indeed be ugly. It is preferable if the coders follow good practices, and there ideally would be a clear system for specifying program behaviour in testable ways. It is easier to produce good code with robust behaviour if good practices are followed from design through coding to testing and documentation, but it is not impossible to achieve good results in other ways also.
    Did they find any coding bugs, or did they just criticize the approach to coding?

    --
    Those who can make you believe absurdities can make you commit atrocities. - Voltaire
    1. Re:not written to a coding standard? by SanityInAnarchy · · Score: 5, Insightful

      Did they find any coding bugs,

      Yes. RTFA.

      2. 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.

      There you go. It's also inaccurate:

      The A/D converters measuring the IR readings and the fuel cell readings can produce values between 0 and 4095. However, the software divides the final average(s) by 256... Further, because of an attribute in the IR calculations, the result value is further divided in half. This means that only 8 values are possible for the IR detection...

      And, if there were a catastrophic bug, you wouldn't know it, you'd just keep getting readings:

      An interrupt that detects that the microprocessor is trying to execute an illegal instruction is disabled, meaning that the Alcotest software could appear to run correctly while executing wild branches or invalid code for a period of time. Other interrupts ignored are the Computer Operating Property (a watchdog timer), and the Software Interrupt.

      This belongs on The Daily WTF.

      --
      Don't thank God, thank a doctor!
  9. No. by SanityInAnarchy · · Score: 5, Informative

    Just read Schneier's comments. He cites some of the more important things:

    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... 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.

    That alone should be enough -- the readings are not averaged correctly. But it goes on:

    The A/D converters measuring the IR readings and the fuel cell readings can produce values between 0 and 4095. However, the software divides the final average(s) by 256, meaning the final result can only have 16 values to represent the five-volt range (or less), or, represent the range of alcohol readings possible. This is a loss of precision in the data; of a possible twelve bits of information, only four bits are used. Further, because of an attribute in the IR calculations, the result value is further divided in half. This means that only 8 values are possible for the IR detection, and this is compared against the 16 values of the fuel cell.

    So we know it's buggy and inaccurate, to a moronic degree. If that wasn't enough:

    Catastrophic Error Detection Is Disabled: An interrupt that detects that the microprocessor is trying to execute an illegal instruction is disabled, meaning that the Alcotest software could appear to run correctly while executing wild branches or invalid code for a period of time. Other interrupts ignored are the Computer Operating Property (a watchdog timer), and the Software Interrupt.

    So, basically, it's designed to always return some value, even if it's wildly inaccurate, and even if the software is executing garbage at the time.

    In other words: It appears to be a very low-level equivalent of Visual Basic's "on error resume next".

    Whiskey. Tango. Foxtrot.

    So to answer your question: No, it does not work. Even if it did somehow work, there's obviously an unacceptably poor level of quality control here.

    --
    Don't thank God, thank a doctor!
    1. Re:No. by Ohio+Calvinist · · Score: 5, Insightful

      The problem in a lot of states is that .01 can make a huge difference between a DUI, a DUI with a "high BAC kicker", a wet-reckless, or nothing at all. It has to be accurate to at least a few 9's or for those "on the bubble" cases do have a severe level of doubt. Because driving with a .07 is not illegal (for the most part), but .08 is. The question in court is not "were you drinking tonight", but "how much did you drink" which is a very specific very objective, very deturminable piece of information.

      As states lower their legal limits to the point where they intersect with non-impaired drinking drivers, especially with a .01 or more margin of error, you're going to get a lot of overzealous cops in cities with revenue shortfalls taking innocent people in for DUIs and hopefully more and more of these "border cases" will bring these devices into question more than the over-the-top blacking out, pissing his pants multiple-offender does in court.

      --
      Forgive my spelling from time to time. I'm often posting during short breaks.
    2. Re:No. by spun · · Score: 2, Informative

      Sure, one bit would be enough to make a pass/fail decision. But they throw away info BEFORE making that determination. You can make a determination and round it down to one bit, but you can't round down to one bit and then make an accurate determination, this is an analog sensing device we are talking about. Throw away everything but one bit, and you don't have a yes/no on the legal limit, you have 'above 2.5v, or below 2.5v.' What's the legal limit, translated into volts, hmmm?

      --
      - None can love freedom heartily, but good men; the rest love not freedom, but license. -- John Milton
    3. Re:No. by FatAlb3rt · · Score: 2, Insightful

      Do you really think that you should receive the same consideration as a guy that's 3x over the limit? Blowing .08 and .18 are quite different in terms of state of mind.

      Definitely possible that there's no false negatives, but for a device that can have such this level of an impact on someone's life, you'd think it would be held to a higher standard.

    4. Re:No. by Lord+Ender · · Score: 3, Insightful

      In embedded systems programming, it is common practice to disable interrupts if they are not used. It is certainly possible that this app simply does not need to handle these interrupts, whether they are enabled or not.

      It is also possible that the other flaws mentioned, which clearly reduce accuracy, do not do so sufficiently to change the outcome in a meaningful way.

      The problem with drunk driving law is not primarily one of testing. It is that it presumes someone is incapable of driving with even trace amounts of alcohol, while treating other forms of more dangerous driving (such as driving while texting or on the phone) as being OK or far far less severe.

      The way the laws themselves are written is a horrible miscarriage of justice. This is the result of the perverse and hypocritical views of MADD and its ilk, the bastard children of the prohibition movement.

      --
      A slashdotter who didn't build his own computer is like a Jedi who didn't build his own lightsaber.
    5. Re:No. by LearnToSpell · · Score: 3, Funny

      You're spelling begs the question -- how much have you had to drink today?

      These threads never fail to please.

    6. Re:No. by MadShark · · Score: 2, Insightful

      > In embedded systems programming, it is common practice to disable interrupts if they are not used. It is certainly possible that this app simply does not need to handle these interrupts, whether they are enabled or not.

      There is rarely a good reason to shut off the interrupt for an illegal instruction if it exists on your micro. It is entirely possible for a stray bit of electromagnetic radiation(cosmic ray, electric motors turning on or off, etc) to flip a bit in the micro, causing an illegal instruction. The illegal instruction interrupt exists for situations like this. It should be caught and handled in an appropriate manner, ESPECIALLY in safety critical or (as in this case) legal evidence gathering applications. I've seen it happen at work when we do our electromagnetic interference testing.

    7. Re:No. by osu-neko · · Score: 2, Insightful

      Maybe that is the intention? Just because Schneier *thinks* it is an average, doesn't make it so. Maybe the device becomes more accurate as more samples are taken, and therefore gives more weight to the last (not the first!) sample.

      It damn well better be an average -- having worked with cheap, 12-bit ADC chips before, I know you're getting trash for data if you aren't taking multiple readings and averaging. You must average the readings because the readings are noisy, particularly "in the field". The point of the averaging is to get rid of the noise. The noise doesn't go away as more samples are taken. The average needs to be done properly across the range because if you're giving greater weight to the last reading, your failing entirely to eliminate the noise.

      I'm certain it's throwing away that least-significant bits from the 12-bit ADC precisely because they're effectively RNG output. The problem is, that's the wrong way to do it. Keeping the entire value and then averaging properly gives a reasonably accurate value, even from a noisy ADC. You can discard the lower bits after the averaging (it's false precision anyhow), but not before, and you do it by rounding, not truncation. Doing what is described in the article gives you trash.

      --
      "Convictions are more dangerous enemies of truth than lies."
    8. Re:No. by MadShark · · Score: 2, Informative

      Cosmic rays can cause bit flips, but in my experience it is more likely to happen to electrostatic discharge or other electromagnetic interference of terrestrial origin. The odds of cosmic rays hitting your device is partially dependent on altitude.

      There was a study done by IBM that indicated that a semiconductor based device could expect one such event every year. Other studies have shown that as the number of transistors in a device goes up, the chances increase. Just because an event occurs does not mean it will be visible. It could happen in unused memory, not affect a calculation significantly, etc.

      I dug up an article written by some guys at Cyprus Semiconductor(complete article at http://www.edn.com/article/CA454636.html);

      The interesting bit is this: "The potential impact on typical memory applications illustrates the importance of considering soft errors. A cell phone with one 4-Mbit, low-power memory with an SER of 1000 FITs per megabit will likely have a soft error every 28 years. A high-end router with 10 Gbits of SRAM and an SER of 600 FITs per megabit can experience an error every 170 hours. For a router farm that uses 100 Gbits of memory, a potential networking error interrupting its proper operation could occur every 17 hours. Finally, consider a person on an airplane over the Atlantic at 35,000 ft working on a laptop with 256 Mbytes (2 Gbits) of memory. At this altitude, the SER of 600 FITs per megabit becomes 100,000 FITs per megabit, resulting in a potential error every five hours. The FIT rate of soft errors is more than 10 times the typical FIT rate for a hard reliability failure. Soft errors are not the same concern for cell phones as they can be for systems using a large amount of memory."

  10. Re:Coding Standard by SirGeek · · Score: 3, Insightful

    Er, why would it need or be expected to be? It's a commercial product. I don't think most bank websites are "coded" to any specific standard either.

    From the article:

    1. The Alcotest Software Would Not Pass U.S. Industry Standards for Software Development and Testing: The program presented shows ample evidence of incomplete design, incomplete verification of design, and incomplete "white box" and "black box" testing. Therefore the software has to be considered unreliable and untested, and in several cases it does not meet stated requirements. The planning and documentation of the design is haphazard. Sections of the original code and modified code show evidence of using an experimental approach to coding, or use what is best described as the "trial and error" method. Several sections are marked as "temporary, for now". Other sections were added to existing modules or inserted in a code stream, leading to a patchwork design and coding style.

    Ok. Would you want to have something that can cause you to get convicted because it wasn't documented or even tested fully - ("Oh, Crap. That constant should have been 0.001, not 0.01. Ooops. Blood Alcohol level was 0.008, not .08. Sorry !")

    Common sense (if it WERE common) should indicate that there should be full tests for a wide range of values performed with the written tests and expected values verified and available to prove that the device/software actually does detect the proper levels of alcohol.

  11. Just remember by captnbmoore · · Score: 5, Insightful

    This will not stop the state from using this to make a felon of you.

    --
    The Navy Motto "IF it ain't broke Fix It" "A day is wasted if you don't learn something new"
  12. DUH.... by Lumpy · · Score: 4, Interesting

    If you got your hands on and analyzed the sourcecode to most DVD' players, TV's (Panasonic runs linux!) and other devices that are complex you will discover that in order to ship it earlier the code is an utter mess.

    Programmers are not joking when we complain about the "It compiles? Ship it!" statement.

    the fault is the Executive staff that refuse to listen to their experts (programmers) and do what they recommend. Instead we get morons that know nothing about programming making unrealistic deadlines and forcing death march coding marathons to give up the mess we have today.

    --
    Do not look at laser with remaining good eye.
    1. Re:DUH.... by shutdown+-p+now · · Score: 2, Insightful

      The fault is the State using output of a device which is an undocumented, unverified black box in legal proceedings.

      Yes, of course, most of code out there is a similar mess. But if it fails, the worst that can happen is that your desktop crashes, or your iPod hangs... which is bad, of course, but not as bad as getting a criminal conviction for drunk driving.

      These things should be held to the same standards as code in military equipment or nuclear reactors - mistakes are inexcusable.

    2. Re:DUH.... by Tablizer · · Score: 2, Insightful

      the fault is the Executive staff that refuse to listen to their experts (programmers) and do what they recommend. Instead we get morons that know nothing about programming making unrealistic deadlines and forcing death march coding marathons to give up the mess we have today.

      The US's comparative advantage is speed-to-market, for good or bad. Any service or product that becomes a stable commodity flows to lower-wage countries. Thus, churn-and-burn is the order of the day in the 'merica's.

      Now if you could show through some kind of statistical analysis that companies that spend more time planning are more profitable, you may get more listen. I've worked with some crappy code for big, well-known companies that otherwise are financially successful. Thus, bad code and practices are not dooming them (although it would give a sense of satisfaction if it did).

      One required 12 programmers because it was a combinatorial mess of factors being reported. They said they tried to use a meta-programming approach once before, but the programmer, who was otherwise well-regarded, got confused. They just instead switched to an army to produce the copy-and-paste combinations. They should have perhaps recruited somebody better at meta-techniques, but that was outside of their familiarity zone. Rather than experiment in their unfamiliar meta-land, they decided to byte the bullet and hire the army. I almost felt like building a demo at home and then showing them. Sometimes that's what it takes to break thru the status-quo.
           

    3. Re:DUH.... by D+Ninja · · Score: 2, Insightful

      the fault is the Executive staff that refuse to listen to their experts (programmers) and do what they recommend. Instead we get morons that know nothing about programming making unrealistic deadlines and forcing death march coding marathons to give up the mess we have today.

      To some extent, you are correct. However, I also blame the developers. There are many "software engineers" and "computer scientists" I have worked with who didn't understand the basics of algorithms, design, testing, and other topics that are necessary to our field.

  13. Here's a little jem. by needs2bfree · · Score: 2, Funny

    I thought it was funny.
    12. Defects In Three Out Of Five Lines Of Code: A universal tool in the open-source community, called Lint, was used to analyze the source code written in C. This program uncovers a range of problems from minor to serious problems that can halt or cripple the program operation. This Lint program has been used for many years. It uncovered that there are 3 error lines for every 5 lines of source code in C.

    While Draeger's counsel claims that the "The Alcotest [7110] is the single best microprocessor-driven evidential breath tester on the market", Draeger has already replaced the antiquated 7110 with a newer Windows® based version, the 9510.

  14. Re:Coding Standard by 0100010001010011 · · Score: 2, Interesting

    Some of this stuff is elementary math.

    2. 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 .... the comments say that the values should be averaged, and they are not.

    It's been a while but didn't the teacher in 5th grade show you why that wouldn't work?

    Or how about this:

    The A/D converters measuring the IR readings and the fuel cell readings can produce values between 0 and 4095. However, the software divides the final average(s) by 256, meaning the final result can only have 16 values to represent the five-volt range (or less), or, represent the range of alcohol readings possible.

    Who the hell didn't pay attention in the A/D quantization error in controls class?

    I don't want to fill my whole comment with copy and paste from TFA, but not only is this a code standard issue. It's just plain stupidity. Error checking, out of range checking all sound like something a first year programmer should have gotten right.

    I can't say all my MATlab and CANape scripts look pretty or are up to any coding standards, but I try to at least get the basic shit right.

  15. Re:Lint is crap by TigerNut · · Score: 4, Interesting
    The thing is that probably 95% of the Lint reports could have been fixed by the code designers, just by making appropriate declarations or a bit of type casting. The fact that 60% of the source is reported by Lint, indicates that the designers never bothered to do any kind of static code checking or to clean up warnings, and that points to a lack of care during development and testing.

    At a previous job we had to buy a third-party driver for an embedded PCMCIA controller. The software vendor delivered code that (the first time around) produced about 1200 lines of warnings when we compiled it. We queried them about it and they responded that "we don't compile with warning output enabled". Our reply to them was that our coding standard was that the compile would fail on warnings, and we wouldn't accept their code unless they fixed all the warnings... they cleaned up their act, and fixed a couple of previously unresolved problems in the process.

    --

    Less is more.

  16. Re:Lint is crap by Trahald · · Score: 2, Informative

    Which is why things like this http://en.wikipedia.org/wiki/MISRA_C exist.

  17. Don't forget the false positives by Chmcginn · · Score: 2, Insightful

    In general, I was under the impression that the standard for criminal cases were weighted heavily to reject any technique, evidence, or device that had any appreciable chance of a false positive.

    --
    Have you been touched by his noodly appendage?
  18. Looks like the NJ Supreme Court doesn't care by kelnos · · Score: 4, Informative

    It appears that the NJ Supreme Court wasn't swayed too much by the source code evaluation. They're planning on reinstating the device with only minor modifications.

    --
    Xfce: Lighter than some, heavier than others. Just right.
  19. The code in question by Linker3000 · · Score: 3, Funny

    10 REM Alky 0.1 A. Coder 2001
    20 REM Turn off lights and buzzer
    24 POKE 201,0
    26 POKE 202,0
    28 POKE 53280,0
    29 REM Any Breath?
    30 IF PEEK(200) = 0 THEN GOTO 30
    32 REM Buzzer
    33 POKE 53280,1
    34 PAUSE(2)
    35 POKE 53280,0
    36 REM Lights...
    40 A = 10 * RND(1)
    50 IF A > 5 GOTO 80
    60 REM Red light
    70 POKE 201,1
    75 GOTO 100
    76 REM Green Light
    80 POKE 202,1
    100 PAUSE(3)
    120 GOTO 20

    --
    AT&ROFLMAO
  20. stop paying lawyers, pay a programmer by bcrowell · · Score: 3, Interesting

    If I were the manufacturer, at this point I'd say: (1) lawyers are expensive; (2) competent programmers are expensive, but less expensive than lawyers; (3) our business is selling the beathalyzer, not the software, so we gain nothing by keeping the source secret; (4) this publicity is hurting us; (5) let's hire some more competent programmers to clean up the code, and then we can make it public; (6) profit!

    This is different from the case of the voting machines. In the case of a voting machine, there are lots of people who might be motivated to hack it, lots of people have access to the machines, and it only takes one compromised machine to throw a close election. If you believe in security by obscurity, then there is at least some logical argument for keeping the voting machine code secret. In the case of the breathalyzer, there's not even that lame argument.

  21. A pyhrric victory for open source and code review. by Darth_brooks · · Score: 4, Insightful

    The good: This particular breathalyzer has been proven to be the unreliable POS that it apparently is. This unit, and others like it, will finally start being held to a stronger coding standard.

    The bad: every sleezeball, ambulance chasing, "call lee free", douchebag of a lawyer will use this case to attack the credibility of any and all breathalyzers made in the past, present, or future, spreading enough FUD to juries everywhere that an unacceptable number of drunken idiots get the God given right to keep their license until they finally end up killing someone.

    As a person, I think groups like MADD spend most of their time trying to scare monger politicians into pushing us as close to prohibition as possible. I believe that alcohol can be used responsibly. But I also know that this case is going to result in DUI's getting overturned for people that damn sure don't deserve it. Borderline cases will get knocked down, cases will get thrown out, and the people that broke the law, that did something wrong, will walk out of a court room 'vindicated.' They didn't do anything wrong when they had six beers and drove home, it was that confounded *machine* that *said* they broke the law. The *machine* was busted, ergo they didn't break the law. In short, this case is going to make a lot of O.J. Simpson's. The jury said they didn't commit a crime, so they didn't. No harm no foul. Technicality? Bah! They're as innocent as the sweet baby Jesus.

    I'd like to think things will wash out in the end. This case will probably end up making it harder to get off on this particular technicality in the long term. In the short term? Here come the appeals. Maybe the state is partially at fault for buying shoddy equipment. (Or maybe not. Did they do a code review? Do they have the resources to one? Probably not. Did you do a code review of the 3com switch in your server room? Their selection criteria can certainly be questioned, but it probably doesn't change the fact that someone drank enough to blow a .22 then decided to drive home.)

    But in the end, the drunks are still going to be drunks. And tomorrow some of them will probably get to file appeals, and some of the ones that shouldn't be on the road, or even in public, will get to slip out of this brand new loophole. I'm not sure that that deserves a cork-popping celebration.

    (and yes: We all handle our booze differently. Arbitrary limits that determine "drunk" may or may not be the answer. Hardcore drunks will keep driving even after losing their license. DUI's are as much moneymakers for the States as speeding tickets. Yadda yadda yadda.)

    --
    There are some people that if they don't know, you can't tell 'em.
  22. Re:And does it work? by legirons · · Score: 3, Insightful

    Perhaps they're coded inelegantly or poorly, but do they actually spit out inaccurate numbers?

    Irrelevant - the test is: do they always spit-out provably correct numbers?

  23. Re:It has to be proven to work by djupedal · · Score: 2, Funny

    If a breathalyzer was a person, it would be bent over a bar stool, pants down, with the impression of a bullet-proof chest-buckle somewhere in the vicinity of a very reddened butt-crack.

  24. Re:"Reveals Mess" by cdrguru · · Score: 2, Insightful

    The code is protected in the US by copyright. It is not protected anywhere else, especially in countries where it is cheap to reproduce the hardware. US Customs has proven over and over they will not block the import of infringing devices.

    This means that once the software gets out - and it is - look for cheap copies that will put the original manufacturer out of business. Because law enforcement and just about everyone else in the market for such devices is going to jump on the price difference. Same functionality for 1/10th the price.

    Do not believe for a second that there are any safeguards left for this sort of thing. There are not.

  25. Re:Coding Standard by 0100010001010011 · · Score: 2, Insightful

    An example of a DUI conviction using 5 numbers (Assuming 0.10 for simplicity):

    Say the breathalyzer gets 5 numbers: [0.0625,0.0625,0.1,0.12,0.15].

    If you average the numbers you get 0.099. However if you do a 'rolling' average, you get 0.13. Quite a bit of difference (not to mention, legal vs not legal).

    Now imagine that last number was a burped packet of gas that had a ton of alcohol in it and was a 0.25.

    Instead of the average being 0.119 (yes still illegal) it's now .18, at which point you hear on the news "he was nearly twice the legal limit!".

    (Although playing with the numbers, it looks like the site is wrong, it incorrectly weights the later numbers because one wild number can instantly pull it up very high, or low.)

  26. Re:Lint is crap by MadShark · · Score: 5, Interesting

    I work on embedded system stuff every day. At the end of the day, there are NO lint warnings in my code. First, I tend to avoid coding practices and designs that generate lint warnings. By and large, lint warns for a good reason most of the time. Second, in the limited number of situations where lint flags something incorrectly, there are methods for silencing the warnings via special comments. I'm currently working on a 50000 line project, and there are about 70 places in the entire code base were we had to tell lint to ignore a warning. Each warning suppression is documented as to why lint is incorrect.

    Lint isn't a perfect tool by any means but in my opinion, anyone developing C code without it is not acting in a professional manner.

  27. Re:Coding Standard by Jack9 · · Score: 2, Interesting

    Lots of evidence in court (like say, testimony) are not held to a documented standard. That isn't a very good argument imo.

    --

    Often wrong but never in doubt.
    I am Jack9.
    Everyone knows me.
  28. FARK was right on point by tjonnyc999 · · Score: 3, Funny

    "DUI defendant finally gets access to breathalyzer code, ironically finds developers were probably drunk when they wrote it". http://www.fark.com/cgi/comments.pl?IDLink=4387892

  29. Re:who tested and approved the things? by John+Hasler · · Score: 2, Funny

    > Before these things came into service, who approved them and what was their test
    > procedure? Did they just look at the brochure?

    No. They also went out to lunch with the salesman.

    --
    Warning: this article may contain humor, sarcasm, parody, and perhaps even irony. Read at your own risk.
  30. But is it broken? HELL YES!!! by swordgeek · · Score: 5, Informative

    OK, LOTS of strange posts from people who claim to have read the article but only see that it's bad code, not actually broken.

    Read it again. It's broken from a legal liability and trustworthiness standpoint. It's broken from a precision standpoint. It's broken from an algorithm standpoint. It is not trusworthy, precise, accurate, or correct.

    "It is clear that, as submitted, the Alcotest software would not pass development standards and testing for the U.S. Government or Military. It would fail software standards for the Federal Aviation Administration (FAA) and Federal Drug Administration (FDA), as well as commercial standards used in devices for public safety. This means the Alcotest would not be considered for military applications such as analyzing breath alcohol for fighter pilots. If the FAA imposed mandatory alcohol testing for all commercial pilots, the Alcotest would be rejected based upon the FAA safety and software standards."

    Nobody in the government or military would be allowed to trust this, if it weren't already in use.

    "Results Limited to Small, Discrete Values"

    Sixteen values is all it displays! It throws away almost all of the precision of the 12-bit ADC, and reduces it to 4 bits! This is NOT precise enough!

    "Catastrophic Error Detection Is Disabled"
    "Diagnostics Adjust/Substitute Data Readings"
    "Range Limits Are Substituted for Incorrect Average Measurements"
    "The software design detects measurement errors, but ignores these errors unless they occur a consecutive total number of times."

    It's not correct. It's not accurate. It's not good enough. The odds are VERY good that some people over the limit have gotten off lucky, and also that some people below the limit now have criminal records.

    --

    "People who do stupid things with hazardous materials often die." -- Jim Davidson on alt.folklore.urban
  31. Re:Is this 1968? by DeadCatX2 · · Score: 5, Insightful

    With an attitude like that, it's obvious that you have little experience with embedded systems...

    --
    :(){ :|:& };:
  32. traffic light conflict monitor by Joe+The+Dragon · · Score: 3, Interesting

    Equipment can break down and programming errors do occur. Because of the safety issues involved, signals are equipped with a "conflict monitor." A conflict monitor is a simple device, completely independent of the controller, that watches the signal operate. It does this by monitoring a number of conditions, including the voltage to the individual bulbs in the heads.

    If a condition occurs which is not normal (for example opposing greens) the conflict monitor detects the condition and shuts down the intersection. Normally, it places the signal on "flash mode." The main street is given a flashing yellow, to indicate that the situation is not normal and caution is needed. The secondary street is given a flashing red light that should be treated like a stop sign. For safety reasons, the signal will not normally reset itself. A technician must visit the intersection, determine the problem and reset the controller.

  33. Re:Coding Standard by colinrichardday · · Score: 3, Insightful

    Testimony is subject to cross-examination (at least in the US). Opposing counsel has the opportunity to exploit weaknesses in the witness's testimony. Also, the witness is subject to prosecution for perjury for lying. What penalty does a faulty (if it be faulty) device face?

  34. Re:Is this 1968? by SnowZero · · Score: 3, Insightful

    Assuming the microcontroller has a 10-bit A/D converter to get the reading, I'm pretty sure such a chip could add 32 numbers together. With the speed of 8-bit microcontrollers these days exceeding 1MHz even at ~$1 price points, emulating 16 bit numbers to get your sum is not a problem. Take a power-of-two number of readings and your average can be a simple bit shift. It will take more horsepower to convert to base-10 on the display than to take the average.

    This is not a cheap child's toy or a toaster, it's a law-enforcment grade breathalyzer going for above $100; there is no excuse for being so lazy. Code that runs on small systems should be *clean* because bugs are harder to find without easy I/O, and the efficiency of it needs to be obvious. Also, code that can put someone in jail should not be spaghetti, regardless of the scale of the system running it.

  35. Simple test by SmallFurryCreature · · Score: 2, Interesting

    Get a driving game or any other skill/reaction based game. I used Grand Prix Legends. Start driving, give yourself time to adjust to get into a grove. Note your average time and accidents. Don't worry to much about speeding, just about making incident free rounds at the maximum of your capibilty BUT in a race so there is traffic.

    Then start drinking. Slowly, alcohol doesn't work instantly. EVEN half a beer will impact your performance.

    Anyone with any brains can reason this out. We drink alcohol because it affects our brain. To say alcohol does not affect you is just silly. It would be like saying being dipped into icy cold water does not affect you.

    When I see people denying alcohol affects them, even to the extent that 0.8 don't means they are drunk, I see someone who is debating with basic chemistry. What would they argue next, that if their blood has no oxygen they ain't dead?

    Really, test it with a game. An objective game in which you can measure a simple statistic but one that reflects the task of driving. Doing something repetitive that you think you can do on auto-pilot but still requires split second reactions when you least expect it. GTA4 come to think of it might be better. Oh and if you hit anything, anything at all, well. Hand in your drivers license.

    --

    MMO Quests are like orgasms:

    You may solo them, I prefer them in a group.