DEV Community

Discussion on: I used to work with vessel tracking data. Ask Me Anything!

Collapse
 
ben profile image
Ben Halpern

I once heard someone who worked on the New York City subway system talk about how they used data from the number of rotations each wheel made in order to track certain data, but over time the wheels would wear down at different rates, so the wheel sizes would change over time. They had to hack around this and make all sorts of workarounds.

Do you have any of these kinds of stories about hacks to make the data tracking work in a real-world scenario?

Collapse
 
cathodion profile image
Dustin King

So, the AIS protocol has messages that are each a string of bits. Sometimes there will be a selector number that's a few bits long which tells what fields make up the next block of however many bits of data. In some cases, that number is after the bits it describes. Which is fine, though I wished I had learned that before I started writing a parser, for a feature I was adding not long after I started there. Fine... as long as the described block is a fixed number of bits.

When we started adding transmit capability (this was several years later), there were some new types of messages we had to generate (actually sub-messages called "Application Specific Messages", but same principle). In the case of two of these message types, the thing that described which type it was came after the block, and the block was a different size depending on which type it was! And there was some other thing that made the whole message the same length. Which meant that whatever was parsing these kinds of messages would sometimes misinterpret them as the wrong type. So I ended up doing binary math to figure out that the way around this was that some auto-generated field (sequence number?) had to always skip number 48 or something like that.