@@ -773,48 +773,50 @@ shearwater_predator_parser_cache (shearwater_predator_parser_t *parser)
773
773
774
774
dc_field_add_string_fmt (& parser -> cache , "Logversion" , "%d%s" , logversion , pnf ? "(PNF)" : "" );
775
775
776
- // Cache sensor calibration for later use
777
- unsigned int base = parser -> opening [3 ] + (pnf ? 6 : 86 );
778
- parser -> calibrated = data [base ];
776
+ // Get the dive mode from the header (if available).
777
+ if (logversion >= 8 ) {
778
+ divemode = data [parser -> opening [4 ] + (pnf ? 1 : 112 )];
779
+ }
779
780
780
- unsigned int calibration_count = 0 ;
781
- unsigned int calibration_default_count = 0 ;
782
- for (size_t i = 0 ; i < 3 ; ++ i ) {
783
- if (parser -> calibrated & (1 << i )) {
784
- unsigned int calibration = array_uint16_be (data + base + 1 + i * 2 );
781
+ if (divemode == M_CC || divemode == M_CC2 || divemode == M_SC ) {
782
+ // Cache sensor calibration for later use
783
+ unsigned int base = parser -> opening [3 ] + (pnf ? 6 : 86 );
784
+ parser -> calibrated = data [base ];
785
785
786
- calibration_count ++ ;
787
- if (calibration == SENSOR_CALIBRATION_DEFAULT ) {
788
- calibration_default_count ++ ;
789
- }
786
+ unsigned int calibration_count = 0 ;
787
+ unsigned int calibration_default_count = 0 ;
788
+ for (size_t i = 0 ; i < 3 ; ++ i ) {
789
+ if (parser -> calibrated & (1 << i )) {
790
+ unsigned int calibration = array_uint16_be (data + base + 1 + i * 2 );
790
791
791
- parser -> calibration [i ] = calibration / 100000.0 ;
792
- if (parser -> model == PREDATOR ) {
793
- // The Predator expects the mV output of the cells to be
794
- // within 30mV to 70mV in 100% O2 at 1 atmosphere. If the
795
- // calibration value is scaled with a factor 2.2, then the
796
- // sensors lines up and matches the average.
797
- parser -> calibration [i ] *= 2.2 ;
792
+ calibration_count ++ ;
793
+ if (calibration == SENSOR_CALIBRATION_DEFAULT ) {
794
+ calibration_default_count ++ ;
795
+ }
796
+
797
+ parser -> calibration [i ] = calibration / 100000.0 ;
798
+ if (parser -> model == PREDATOR ) {
799
+ // The Predator expects the mV output of the cells to be
800
+ // within 30mV to 70mV in 100% O2 at 1 atmosphere. If the
801
+ // calibration value is scaled with a factor 2.2, then the
802
+ // sensors lines up and matches the average.
803
+ parser -> calibration [i ] *= 2.2 ;
804
+ }
798
805
}
799
806
}
800
- }
801
807
802
- if (calibration_count > 0 ) {
803
- if (calibration_default_count < calibration_count ) {
804
- print_calibration (parser );
805
- } else {
806
- // All calibrated sensors report the default calibration value
807
- // so this could be a DiveCAN controller, where the calibration values
808
- // are stored in the CCR's sensor module.
809
- parser -> needs_divecan_calibration_estimate = true;
808
+ if (calibration_count > 0 ) {
809
+ if (calibration_default_count < calibration_count ) {
810
+ print_calibration (parser );
811
+ } else {
812
+ // All calibrated sensors report the default calibration value
813
+ // so this could be a DiveCAN controller, where the calibration values
814
+ // are stored in the CCR's sensor module.
815
+ parser -> needs_divecan_calibration_estimate = true;
816
+ }
810
817
}
811
818
}
812
819
813
- // Get the dive mode from the header (if available).
814
- if (logversion >= 8 ) {
815
- divemode = data [parser -> opening [4 ] + (pnf ? 1 : 112 )];
816
- }
817
-
818
820
// Get the correct model number from the final block.
819
821
if (parser -> final != UNDEFINED ) {
820
822
parser -> model = data [parser -> final + 13 ];
0 commit comments