Add support for the new D6i firmware.

After the new firmware upgrade, up to three gas mixes are available
instead of only two. This causes the parsing to fail because there is
now an extra 6 byte gasmix block in the header.

Unfortunately, we can't rely on the firmware version to detect whether
this extra gasmix is present or not. In theory the dive computer can
contain dives in both the old and the new format. Because the firmware
version is a property of the device, and not stored inside each dive,
using the firmware version would either cause the old or the new dives
to fail parsing. This appears to be the approach DM4 is using.

According to some sources on the internet, the logbook gets erased
during the firmware update. However, according to the memory dumps I
received, that appears to be incorrect. The old dives are still
present, and it seems it's only DM4 that fails to download them.

So we need an alternative solution. After a detailed analysis of all
the Suunto dives at my disposal, I noticed something interesting. The
first 5 bytes of each dive are almost static. There are only 5
different variations:

0061906216
0061A06216
0062909118
0062C07118
0063C07118

The interpretation of these bytes is currently unknown, but the second
byte might be some kind of data format version. Each model always has
the same value here, and for the D6i it changes after the firmware
update:

0x61: D4, D6, D9, Cobra 2, Cobra3, Vyper 2, Vyper Air
0x62: D4i, D6i (old firmware), D9tx, HelO2
0x63: D6i (new firmware)

This can't be coincidence, so we use this byte to detect the presence
of the extra gasmix.
This commit is contained in:
Jef Driesen 2013-02-02 23:30:41 +01:00
parent 038c603719
commit a4d46b2477

View File

@ -196,7 +196,10 @@ suunto_d9_parser_get_field (dc_parser_t *abstract, dc_field_type_t type, unsigne
gasmix_count = 1;
} else if (parser->model == D6i) {
gasmix_offset = 0x5F;
gasmix_count = 2;
if (data[1] == 0x63)
gasmix_count = 3;
else
gasmix_count = 2;
} else if (parser->model == D9tx) {
gasmix_offset = 0x87;
gasmix_count = 8;
@ -289,7 +292,10 @@ suunto_d9_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callback_t ca
gasmix_count = 1;
} else if (parser->model == D6i) {
gasmix_offset = 0x5F;
gasmix_count = 2;
if (data[1] == 0x63)
gasmix_count = 3;
else
gasmix_count = 2;
} else if (parser->model == D9tx) {
gasmix_offset = 0x87;
gasmix_count = 8;