Fix a bug in the tank pressure samples
The number of tank pressure sensors is not necessary equal to the number of gas mixes. Take for example a dive with two gas mixes, but only a single tank pressure sensor attached to one of the two tanks. Because the tank index is shared with the gas mix index, it will refer to a non-existing sensor when switching to a tank without a pressure sensor attached. The invalid tank index should not be considered a fatal error. The tank pressure values should be ignored instead. The device appears to record zero values anyway, except for the first value immediately after the gas switch. I suspect that's caused by the fact that the pressure is only recorded every 4 samples, and therefore the last pressure value is reported with a small delay.
This commit is contained in:
parent
640308c076
commit
c5d5220e28
@ -603,15 +603,13 @@ mares_iconhd_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callback_t
|
||||
// Some extra data.
|
||||
if (parser->model == ICONHDNET && (nsamples % 4) == 0) {
|
||||
// Pressure (1/100 bar).
|
||||
if (parser->ntanks > 0) {
|
||||
unsigned int pressure = array_uint16_le(data + offset);
|
||||
if (gasmix >= parser->ntanks) {
|
||||
ERROR (abstract->context, "Invalid tank index.");
|
||||
return DC_STATUS_DATAFORMAT;
|
||||
}
|
||||
unsigned int pressure = array_uint16_le(data + offset);
|
||||
if (gasmix < parser->ntanks) {
|
||||
sample.pressure.tank = gasmix;
|
||||
sample.pressure.value = pressure / 100.0;
|
||||
if (callback) callback (DC_SAMPLE_PRESSURE, sample, userdata);
|
||||
} else if (pressure != 0) {
|
||||
WARNING (abstract->context, "Invalid tank with non-zero pressure.");
|
||||
}
|
||||
|
||||
offset += 8;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user