RFC patch: store dive computer serial / firmware again

Linus Torvalds torvalds at linux-foundation.org
Thu Nov 20 13:00:25 PST 2014


On Thu, Nov 20, 2014 at 12:48 PM, Linus Torvalds
<torvalds at linux-foundation.org> wrote:
>
> Add similar cases for other dive computer manufacturers as we figure
> out exactly what the encoding actually is.

For example, the Atomic Cobalt apparently has a encoding format like
"wwyy-xxxx", where the first two digits (ww) are the week number, the
second two digits are the year (yy), and the last four digits are just
the sequence number within the week.

How does libdivecomputer return that? Looking at how it's encoded, I
can guess. The actual encoding is as an 8 character string (so
presumably just without the dash), and libdivecomputer turns it into a
decimal number.

But note that "two first digits" really means that you must not just
print it out as a decimal number. You *have* to have the right
zero-padding, so you should at the very least use "%08u" to get it
right. Otherwise you're just setting people up for being confused.

And quite frankly, I'd suggest using

   "%04u-%04u", serial / 10000, serial % 10000

so that the end result actually matches what the recall for the Cobalt had.

At *no* point does it make sense to encode it as "0xrandomnoise".

Of course, the right solution would be to just do this right in
libdivecomputer.c and have libdivecomputer just format the string
right in the first place. Using, say, DC_STRING_FIELD.

                    Linus


More information about the subsurface mailing list