Monday, November 6, 2017

Paradise ponders: winter approaches edition...

Paradise ponders: winter approaches edition...  Yesterday's weather was a little nasty – cold, wet gloppy snow on the ground, and not too much sunshine.  We went on a quest for moose (we start seeing them in Blacksmith Fork Canyon in the winter), with no success.  We were treated to some pretty scenery (as in the view at right, from near the mouth of canyon), saw about a bazillion turkeys, and a few deer.  There were quite a few hunters in the back country, all scanning the hillsides – Debbie tells me that cougar (mountain lion) season is now open here, so that may be what they're looking for.

My little C program is shaping up nicely.  It's not so little any more – it's just over 3kloc (three thousand lines of code, for all you non-geeks).  It's been a terrific learning exercise for me, just what I needed for “reentry” into the world of low-level programming.

When I quit working on code yesterday afternoon, I had a problem that was vexing me: unreliable communications (via serial port) with the GPS, using the U-Blox proprietary UBX protocol.  Fixed in my head was the notion that the problem was caused by the fact that the GPS was transmitting both UBX and NMEA data on the same wire.  I imagined that the GPS was behaving stupidly, interleaving the bytes from each protocol.  This morning while I was taking my morning shower, an alternative theory came to me – one that would be much simpler to fix.  It's amazing how often I have solved (or at least made progress on) problems while taking a shower.  Something about that activity is conducive to insights.  Anyway, the alternative theory was simply that when I was sending a UBX command the host computer's UART receiver was out of sync with the data stream being transmitted by the GPS.  This would only be an issue if the receiver had been fed a stream of NMEA data before trying to read a UBX message.  I made a quick change to my code to force synchronization before any UBX operation, and poof! – just like that my reliability problem disappeared.

Obviously I need to take more showers!  :)