From 8736a6dca1aa189d5e7d19f54da0bb59973f5b3f Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Fri, 7 Jul 2017 07:05:53 -0700 Subject: [PATCH] Shearwater: extract tank sensor data for log version 7 The first dive computer to support this is the Perdix AI. Interestingly, this keeps track of two sensors at all times. I haven't seen data with two sensors active, yet. Signed-off-by: Dirk Hohndel --- src/shearwater_predator_parser.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/shearwater_predator_parser.c b/src/shearwater_predator_parser.c index 7f05e62..2be20d8 100644 --- a/src/shearwater_predator_parser.c +++ b/src/shearwater_predator_parser.c @@ -583,6 +583,30 @@ shearwater_predator_parser_samples_foreach (dc_parser_t *abstract, dc_sample_cal sample.deco.time = data[offset + 9] * 60; if (callback) callback (DC_SAMPLE_DECO, sample, userdata); + // for logversion 7 and newer (introduced for Perdix AI) + // detect tank pressure + if (parser->logversion >= 7) { + // Pressure (2 psi). + // 0xFFFF is not paired / no coms for 90 seconds + // 0xFFFE no coms for 30 seconds + // top 4 bits battery level: + // 0 - normal, 1 - critical, 2 - warning + unsigned int pressure = array_uint16_be (data + offset + 27); + if ((pressure & 0xFFF0) != 0xFFF0) { + pressure &= 0x0FFF; + sample.pressure.tank = 0; + sample.pressure.value = pressure * 2 * PSI / BAR; + if (callback) callback (DC_SAMPLE_PRESSURE, sample, userdata); + } + pressure = array_uint16_be (data + offset + 19); + if ((pressure & 0xFFF0) != 0xFFF0) { + pressure &= 0x0FFF; + sample.pressure.tank = 1; + sample.pressure.value = pressure * 2 * PSI / BAR; + if (callback) callback (DC_SAMPLE_PRESSURE, sample, userdata); + } + } + offset += parser->samplesize; }