Shearwater: extrac log version from header

The earliest document I have references log version 6. There are
apparently older versions, but I don't know what the differences
are. Before version 7, the log version wasn't always reliably
stored, so we assume 6 is the minimum and use 7 (or later) if we
find it.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Dirk Hohndel 2017-07-07 07:03:13 -07:00
parent 0143be5497
commit d85481cefd

View File

@ -74,6 +74,7 @@ struct shearwater_predator_parser_t {
double calibration[3];
unsigned int serial;
dc_divemode_t mode;
unsigned char logversion;
};
static dc_status_t shearwater_predator_parser_set_data (dc_parser_t *abstract, const unsigned char *data, unsigned int size);
@ -236,6 +237,13 @@ shearwater_predator_parser_cache (shearwater_predator_parser_t *parser)
return DC_STATUS_DATAFORMAT;
}
// Log versions before 6 weren't reliably stored in the data, but
// 6 is also the oldest version that we assume in our code
parser->logversion = 6;
if (data[127] > 6)
parser->logversion = data[127];
INFO(abstract->context, "Shearwater log version %u\n", parser->logversion);
// Adjust the footersize for the final block.
if (parser->petrel || array_uint16_be (data + size - footersize) == 0xFFFD) {
footersize += SZ_BLOCK;