Garmin support: ignore FIT files that aren't dives

Linus Torvalds torvalds at linux-foundation.org
Tue Sep 4 18:11:26 PDT 2018


On Tue, Sep 4, 2018 at 4:38 PM Linus Torvalds
<torvalds at linux-foundation.org> wrote:
>
> > - in the FIT file, the Descent Mk1 is identified as product 2859; I think this would
> > make sense to use as model number (instead of 0)
>
> I'll take a look.

I took all your commits. Minor changes, like not checking that
device_index, because it actually changes *after* you've already seen
the values.

The garmin field numbering is confusing. For example, device_index is
indeed field #0, but it's not the first field in the record stream.
It's one of the last fields because it's a small one-byte field.

So when the FIT file stream is parsed, you will see things in this order

first DEVICE_INFO message:
 - firmware field
 - device index: 0

second DEVICE_INFO message
 - firmware field
 - device index: 1

so when you checked "is device index 0", that check triggered for both
of those firmware fields, because the device index updated to 1 only
_after_ you'd seen the second firmware field.

I could have done it the "proper" way with actually batching it up
using the record_data thing, but it seemed unnecessary, and I just did
that "only overwrite firmware when the old number was zero".

Which isn't necessarily the technically proper way to do it, but it
gets the right result, and we get the firmware field details from the
first/main DEVICE_INFO message.

Of course, the serial number and the product data we could have just
gotten from the FILE message, which only happens once. But that one
doesn't contain the firmware information, and yeah, the firmware field
has different values for the different device_index values. I don't
know why, but at least now it takes that first one.

It all seems to work for me still.

               Linus


More information about the subsurface mailing list