A Complete Tech 2 Kit |
My assignment was with the team that developed and maintained the core operating system for this tool. Our code was the first bit of code that ran in the system, bringing it from power-up to functional, and providing all the real-time scheduling and communications protocols for the rest of the more vehicle-specific stuff. It was pretty challenging stuff for a newbie fresh out of college, but I ran with it and enjoyed it a lot.
One of the challenges we faced was that we basically had a 10MB flash "hard drive" that we could only access 1MB at a time, and that flash drive was filling up fast. Mind you, there was no file system, so we addressed the flash directly by address and used a card page register to pick which 1MB we wanted to see at any given time. This made for some .. interesting .. code constructs, and made it necessary to copy certain parts of the software into RAM at boot time - things like the OS's API layer, which was contained on the flash drive at an addressed specified in a look-up table that started at address 0. You still with me? Good.
I had written the code that would locate this API code and transfer it from the flash drive into it's designated spot in the RAM during the tool's boot-up sequence. In the name of defensive coding, I had written a block of code to detect the absence of this file and react accordingly - by disabling all interrupts and entering an infinite loop after printing an error message in the center of the screen. My downfall was having the error message read, simply, "WE'RE HOSED." I figured it was ok, though .. the API binary was an integral part of every release .. surely this error message would NEVER be displayed, right? Right??
Needless to say, I was mortified. We quickly rushed a new release into production that not only replaced "we're hosed" with a more appropriate error message, but also made sure the API binary was included this time. As far as I know, the more appropriate error message was never seen .. which is a good thing.
The moral of the story? When you're coding error messages, never ever assume they won't be seen, because if you make that assumption even once, chances are that's the one time you'll be ... hosed.
No comments:
Post a Comment