Add support for the new D4i and D6i data format.

One of the newer D4i and D6i firmware versions (for example v1.5.9),
introduces a new variant of the data format. The new dive header is 8
bytes larger. The correct variant can be detected by means of the
logbook id tag at the start of the header.
This commit is contained in:
Jef Driesen 2016-03-08 20:01:20 +01:00 committed by Dirk Hohndel
parent 2fc31b72e7
commit 784844d8dd

View File

@ -47,6 +47,12 @@
#define D9tx 0x1B
#define DX 0x1C
#define ID_D6I_V1_MIX2 0x1871C062
#define ID_D6I_V1_MIX3 0x1871C063
#define ID_D6I_V2 0x18724062
#define ID_D4I_V1 ID_D6I_V1_MIX2
#define ID_D4I_V2 ID_D6I_V2
#define AIR 0
#define NITROX 1
#define GAUGE 2
@ -120,6 +126,9 @@ suunto_d9_parser_cache (suunto_d9_parser_t *parser)
return DC_STATUS_SUCCESS;
}
// Get the logbook id tag.
unsigned int id = array_uint32_le (data + 1);
// Gasmix information.
unsigned int gasmode_offset = 0x19;
unsigned int gasmix_offset = 0x21;
@ -130,12 +139,18 @@ suunto_d9_parser_cache (suunto_d9_parser_t *parser)
gasmix_count = 8;
} else if (parser->model == D4i) {
gasmode_offset = 0x1D;
gasmix_offset = 0x5F;
if (id == ID_D4I_V2)
gasmix_offset = 0x67;
else
gasmix_offset = 0x5F;
gasmix_count = 1;
} else if (parser->model == D6i) {
gasmode_offset = 0x1D;
gasmix_offset = 0x5F;
if (data[1] == 0x63)
if (id == ID_D6I_V2)
gasmix_offset = 0x67;
else
gasmix_offset = 0x5F;
if (id == ID_D6I_V1_MIX3)
gasmix_count = 3;
else
gasmix_count = 2;
@ -193,7 +208,11 @@ suunto_d9_parser_cache (suunto_d9_parser_t *parser)
parser->gasmix = data[0x26];
} else if (parser->model == D4i || parser->model == D6i ||
parser->model == D9tx) {
parser->gasmix = data[0x28];
if (id == ID_D4I_V2 || id == ID_D6I_V2) {
parser->gasmix = data[0x2D];
} else {
parser->gasmix = data[0x28];
}
}
}
parser->config = config;