From 469d3ee17728d0e4c31bc0205d2cd13245d7f9f0 Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Sat, 19 Sep 2020 10:29:55 -0700 Subject: [PATCH] fix Shearwater PNF parsing for Petrel / Petrel 2 At some point (possibly around v71 of their firmware), Shearwater implemented PNF for the Petrel and Petrel 2. Those are of course not air integrated, and apparently don't support adjustable sample rate, so the log data doesn't include opening and closing record 5. Instead of failing when those aren't found, we should simply only access those when they actually exist. Signed-off-by: Dirk Hohndel --- src/shearwater_predator_parser.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/shearwater_predator_parser.c b/src/shearwater_predator_parser.c index 7ccbc97..43eefa8 100644 --- a/src/shearwater_predator_parser.c +++ b/src/shearwater_predator_parser.c @@ -468,7 +468,10 @@ shearwater_predator_parser_cache (shearwater_predator_parser_t *parser) } // Verify the required opening/closing records. - for (unsigned int i = 0; i < NRECORDS - 2; ++i) { + // At least in firmware v71 and newer, Petrel and Petrel 2 also use PNF, + // and there opening/closing record 5 (which contains AI information plus + // the sample interval) don't appear to exist - so don't mark them as required + for (unsigned int i = 0; i <= 4; ++i) { if (parser->opening[i] == UNDEFINED || parser->closing[i] == UNDEFINED) { ERROR (abstract->context, "Opening or closing record %u not found.", i); return DC_STATUS_DATAFORMAT; @@ -627,7 +630,7 @@ shearwater_predator_parser_samples_foreach (dc_parser_t *abstract, dc_sample_cal // Sample interval. unsigned int time = 0; unsigned int interval = 10; - if (parser->pnf && parser->logversion >= 9) { + if (parser->pnf && parser->logversion >= 9 && parser->opening[5] != UNDEFINED) { interval = array_uint16_be (data + parser->opening[5] + 23); if (interval % 1000 != 0) { ERROR (abstract->context, "Unsupported sample interval (%u ms).", interval);