Merge branch 'shearwaterPNFfix' of github.com:Subsurface-divelog/libdc into Subsurface-DS9

Pull Shearwater PNF parsing fix from Dirk:
 "The parser assumed that all opening/closing records were required.

  But it seems that for the Petrel / Petrel 2 they actually aren't,
  specifically record 5 is missing.

  Which makes sense, as that one only contains air integration stuff
  plus the sample interval (which isn't configurable on the older dive
  computers)"

* 'shearwaterPNFfix' of github.com:Subsurface-divelog/libdc:
  fix Shearwater PNF parsing for Petrel / Petrel 2
This commit is contained in:
Linus Torvalds 2020-09-19 12:01:02 -07:00
commit 8cfd2aacaf

View File

@ -562,7 +562,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;
@ -739,7 +742,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);