Hunting the Snark

boot-loopMicrocontroller code is simple. No memory allocation, very few pointers, simple structure. Ok, there are interrupts, but they can be managed.

But why does it always end up in hunting strange bugs? A few weeks ago I started writing the code for a smooth linear motion. I thought that would be a good exercise for more complex motion code I’d begin with soon. Then I also wrote a test for this function. I am now always developing formal tests. The time you spend on the tests is much less then hunting the bugs in the production framework. For the microcontroller I am using AceUnit.

Now a few weeks passed by and I still didn’t get much further. The test produced garbled output and did restart in a never ending loop. Strange. Luckily, that happened with a rather simple test case. I did strip it down. The output did change unpredictably. I stripped it down further, and found a few bugs in the serial output code. I use the serial output for debugging, unfortunately the Arduino doesn’t support the standard connectors for an Atmel debug device. I fixed the code, not understanding why it could have lead to a restart loop, but in good hope. After restoring the test framework, I ran the test case again, and it still looped forever. At least the output looks nicer now. It is a Boojum, for sure.

snark-its-a-boojumBy the way, ‘The Hunting of the Snark’ by Lewis Carroll is a wonderful poem, worth to read. With brilliant ideas, as you would expect from him. I have a reprint with the original steel engravings, like the one on the left.

Leave a Reply

Your email address will not be published. Required fields are marked *