Skip to content

Commit

Permalink
garmin: fix up some leftovers
Browse files Browse the repository at this point in the history
When importing FIT files, we may not have serial numbers or firmware
versions in the result, so don't report them when they don't exist.

Also, add the product name to the FILE message field list, which can
contain relevant information.  Not that we report it right now, but now
we *could* do so.

This concludes the Suunto FIT file export saga.  It's not great, but it
looks like it should be usable.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
  • Loading branch information
torvalds committed Jul 16, 2023
1 parent e81eca6 commit 3e39cb4
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/garmin_parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -523,6 +523,7 @@ DECLARE_FIELD(FILE, serial, UINT32Z) { }
DECLARE_FIELD(FILE, creation_time, UINT32) { }
DECLARE_FIELD(FILE, number, UINT16) { }
DECLARE_FIELD(FILE, other_time, UINT32) { }
DECLARE_FIELD(FILE, product_name, STRING) { }

// SESSION msg
DECLARE_FIELD(SESSION, start_time, UINT32) { garmin->dive.time = data; }
Expand Down Expand Up @@ -897,7 +898,7 @@ struct msg_desc {
static const struct msg_desc name##_msg_desc

DECLARE_MESG(FILE) = {
.maxfield = 8,
.maxfield = 9,
.field = {
SET_FIELD(FILE, 0, file_type, ENUM),
SET_FIELD(FILE, 1, manufacturer, UINT16),
Expand All @@ -906,6 +907,7 @@ DECLARE_MESG(FILE) = {
SET_FIELD(FILE, 4, creation_time, UINT32),
SET_FIELD(FILE, 5, number, UINT16),
SET_FIELD(FILE, 7, other_time, UINT32),
SET_FIELD(FILE, 8, product_name, STRING),
}
};

Expand Down Expand Up @@ -1633,9 +1635,11 @@ garmin_parser_set_data (dc_parser_t *abstract, const unsigned char *data, unsign
traverse_data(garmin);

// Device information
dc_field_add_string_fmt(&garmin->cache, "Serial", "%u", garmin->dive.serial);
dc_field_add_string_fmt(&garmin->cache, "Firmware", "%u.%02u",
garmin->dive.firmware / 100, garmin->dive.firmware % 100);
if (garmin->dive.serial)
dc_field_add_string_fmt(&garmin->cache, "Serial", "%u", garmin->dive.serial);
if (garmin->dive.firmware)
dc_field_add_string_fmt(&garmin->cache, "Firmware", "%u.%02u",
garmin->dive.firmware / 100, garmin->dive.firmware % 100);

// These seem to be the "real" GPS dive coordinates
add_gps_string(garmin, "GPS1", &garmin->gps.SESSION.entry);
Expand Down

0 comments on commit 3e39cb4

Please sign in to comment.