From 59d9791446c8b2dd728960876b05f7f108445e7e Mon Sep 17 00:00:00 2001 From: Jef Driesen Date: Mon, 10 Feb 2020 22:52:55 +0100 Subject: [PATCH 1/2] Limit the depth value to 11 bits The depth value is encoded with only 11 bits instead of 12 bits. The extra bit contains the gas mix index. This resulted in wrong depths, with values larger than 204.8m. --- src/cressi_goa_parser.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cressi_goa_parser.c b/src/cressi_goa_parser.c index cc99d2c..bd89a54 100644 --- a/src/cressi_goa_parser.c +++ b/src/cressi_goa_parser.c @@ -190,7 +190,7 @@ cressi_goa_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callback_t c if (type == DEPTH) { // Depth (1/10 m). - unsigned int depth = value & 0x0FFF; + unsigned int depth = value & 0x07FF; sample.depth = depth / 10.0; if (callback) callback (DC_SAMPLE_DEPTH, sample, userdata); complete = 1; From 5dc7e54596448be828ea695e5e999cd620d1bc60 Mon Sep 17 00:00:00 2001 From: Jef Driesen Date: Mon, 10 Feb 2020 22:53:27 +0100 Subject: [PATCH 2/2] Implement the gas mix sample The current gas mix index is stored in the 11th bit of the sample value. --- src/cressi_goa_parser.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/cressi_goa_parser.c b/src/cressi_goa_parser.c index bd89a54..d7599dc 100644 --- a/src/cressi_goa_parser.c +++ b/src/cressi_goa_parser.c @@ -170,6 +170,7 @@ cressi_goa_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callback_t c unsigned int time = 0; unsigned int interval = 5; unsigned int complete = 1; + unsigned int gasmix_previous = 0xFFFFFFFF; unsigned int offset = SZ_HEADER; while (offset + 2 <= size) { @@ -193,6 +194,15 @@ cressi_goa_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callback_t c unsigned int depth = value & 0x07FF; sample.depth = depth / 10.0; if (callback) callback (DC_SAMPLE_DEPTH, sample, userdata); + + // Gas change. + unsigned int gasmix = (value & 0x0800) >> 11; + if (gasmix != gasmix_previous) { + sample.gasmix = gasmix; + if (callback) callback (DC_SAMPLE_GASMIX, sample, userdata); + gasmix_previous = gasmix; + } + complete = 1; } else if (type == TEMPERATURE) { // Temperature (1/10 °C).