diff --git a/src/shearwater_predator_parser.c b/src/shearwater_predator_parser.c index 81f6826e..908dddb7 100644 --- a/src/shearwater_predator_parser.c +++ b/src/shearwater_predator_parser.c @@ -680,12 +680,26 @@ shearwater_predator_parser_cache (shearwater_predator_parser_t *parser) nsensors++; } } - if (nsensors && nsensors == ndefaults) { + if (nsensors && nsensors == ndefaults && !pnf) { // If all (calibrated) sensors still have their factory default // calibration values (2100), they are probably not calibrated // properly. To avoid returning incorrect ppO2 values to the // application, they are manually disabled (e.g. marked as // uncalibrated). + // + // Submersion patch (Shearwater PNF O2 cells): restricted to the + // legacy layout this heuristic was written for. The Petrel Native + // Format records an explicit per-cell calibrated flag in the same + // byte read above, and a Petrel 3 sets it for all three cells while + // writing 2100 for each of them -- so on PNF the default value says + // nothing about whether the diver calibrated, and suppressing on it + // discards cells the computer itself reports as calibrated. 2100 is + // also the factor the computer uses: it displays ppO2 1.3 where the + // cells read 62/65/62 mV, and median(62) * 0.021 = 1.302. Verified + // against the log in test/native/fixtures/petrel3_ccr_o2_cells.bin, + // whose cells track the computer's own voted ppO2 within 0.05 bar + // across the whole dive. See + // packages/libdivecomputer_plugin/patches/0005-shearwater-pnf-o2-cell-calibration.patch. WARNING (abstract->context, "Disabled all O2 sensors due to a default calibration value."); parser->calibrated = 0; } else {