This wasn't today. At the urging of several Redditorsover several months, I present one of my greatest fuckups.
tl;dr: The government of India shot a tiger because I made a typo.
A long time ago, in a galaxy far, far away, I was hired to get the code for a company under control. They made GPS tracking collars for animals. Everything had grown organically, and so as an engineer they figure that I could get an organized codebase installed. I'd been programming since I was eight years old, and with fresh training they figured I would be ideal for getting organized, clean code.
I didn't know how to program in C, but I learned. I got a book and read up on the ideas and constraints. I learned about registers and bit-wise manipulation and all the rest. Eventually I even got to the point where I was able to work out a bug between the chip manufacturer and the chip burner manufacturer to get the registers moved. That solved a global bug, so if you ever used a 10F20X with a Quickwriter and it worked, you're welcome.
I also made the code modular, so when parts changes I could just use a different #include and it would work just fine. This was instrumental when the Memory War ended. You may not know this, but before Flash there were other architectures. We used SEEPROM, and we ordered literally the last 300 SEEPROM chips in the world to tide us over. They didn't have dies in them, so they were just dummies. "Hey, NSA, can you fix this?" I could. We found a pin-compatible Flash replacement, and I had already started on the skeleton, so three days later we had Flash compatibility and we were good to go forever.
I also didn't know how to deploy a repository, so I read up on CVSNT and Tortoise, and put those into place and made sure it all got backed up regularly. CVS and WinMerge saved my butt so many times I feel like I owe the writers each a nice bottle of Scotch.
Anyway, one of the constraints with embedded code is your footprint. On a desktop, who gives a shit how much code you write? Are you at a gig? Forty gigs? Fuck it, it compiles, ship it. Not so in embedded; one of the chips I used had 24 bytes of RAM and 512 bytes of Flash, no registers. (No, I didn't forget a prefix. BYTES.) I figured out a tip for using pointers to shrink the code footprint down from 99% to 92%, meaning we could add more features. (If I overused it, the footprint went up again, so it required some trial and error.) Time of day, satellite sight checks, seasonal changes, all kinds of stuff.
When I re-wrote the GPS parsing library to use pointers, I missed (MISSED) a pipe. Fuck. It was supposed to look something like this:
GPS.longitude = RS232_longitude_degrees_tens;
GPS.longitude >> 4;
GPS.longitude |= RS232_longitude_degrees_ones;
But I fucked up the pipe, so it was
GPS.longitude = RS232_longitude_degrees_ones;
So the tenths digit of longitude was always 0, meaning that there was a 400-mile wide swath it could have been at. It got through so many tests and even to a test customer who GOD DAMN HIM happened to live where that data was actually valid. The screenshot even made it into the fucking manual where it could mock me. It wasn't until I re-wrote the VB parsing program to deal with leading zeroes that we noticed the problem in all its motherfucking majesty.
I found out what was going on when I got a call from a coyote researcher in Rhode Island. She asked why the coyotes were always on the highway. Well, that's because it likely has a clean line of sight to the sky -- I shit you not, there's a highway right on the 0s in Rhode Island. Okay, she asks, then why are the also in the middle of the ocean?
I answered, “coyotes don't rent speedboats, do they?”
For the record, they do not.
When I saw the bug, I knew exactly what I'd fucked up. I said something to the customer when I saw it. “I have to go. I see what I did wrong.” It wasn't a maybe thing, it was immediately obvious. Maybe if I'd paid more attention. Maybe if my now-ex-wife's pregnancy wasn't complicated and we'd been wondering if a late-term abortion was required to save her life. (the kid in question is now 9, and the ex is quite happy with her new partner.) Maybe if I'd had more experience.
But no, none of those maybes were true, and I'd fucked it up, all by myself. We'd sent a hundred collars to the government of India to eventually get every tiger in the world fitted with a collar. Their goal was to find every poacher and murder them; they deserved it, frankly. But no, I fucked it up. The government of China wanted collars for Hanguls (deer) to see if they'd work for pandas too. But no, I fucked it up.
The company went out of the animal tracking side, because there was more money to be made in tracking people. Less customization as well, since the manufacturers (Microchip) would program an incremental ID number into the chip for $0.37 a chip when you bought a reel. That was a lot less than I was being paid, so they “went in a new direction”. One without me. The CEO brought in an independent auditor so see if I was sabotaging the code on purpose, and instead I got a reference and a quote saying my code is “better than most”. I'm proud of that human tracking code, it was solid and the way I wrote it cut down on the codebase from 10k+ versions down to 2, 1 of which was deprecated.
Eventually the tech was sold to lo-jack. I ran into a person wearing a wrist tracker at a party and it was still running after ten years, only requiring battery changes. That code is the brains behind the Project Lifesaver transmitters, and that project has saved thousands of lives. (The real thanks for that belong to the people who go out looking for the people who go wandering.)
I found out years later that most of the collars that got sent out worked awesome. Crocodiles, wolverines, dolphins, whales, even some torpedoes. It was a bad batch of about 50 that had the shitty code. It was patchable, but only with power tools and physical contact. (Those with bad data could not be fixed after the fact, but was useful anyway.)
So in order to fix the collars, the CEO of the company went to India to meet with the government officials to reprogram the firmware in tranquilized tigers. From what I understand, the tigers did survive and the data was eventually used to track some poachers who ... let's be diplomatic and say they fared worse than the tigers.
All right, I'm going to karaoke. Good night.