Fix the OSTC4 diluent changes

The hwos devices support 5 gas mixes for open-circuit and 5 diluents for
CCR dives. Internally, both sets are stored separately, but depending on
the dive mode only one of both sets gets stored in the dive header. The
gas change event contains the index of the corresponding gas mix or
diluent, and should always be in the range 1 to 5.

The OSTC4 behaves a bit different from the other hwOS models and uses
index 6 to 10 for the diluents. That means the index needs to be
adjusted to refer to the correct mix in the dive header.

Reported-by: Michael Keller <github@ike.ch>
This commit is contained in:
Jef Driesen 2023-02-15 21:29:17 +01:00
parent 255a2dbb9a
commit 2ba9904757

View File

@ -953,6 +953,10 @@ hw_ostc_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callback_t call
return DC_STATUS_DATAFORMAT;
}
unsigned int idx = data[offset];
if (parser->model == OSTC4 && ccr && idx > parser->nfixed) {
// Fix the OSTC4 diluent index.
idx -= parser->nfixed;
}
if (idx < 1 || idx > parser->nfixed) {
ERROR(abstract->context, "Invalid gas mix (%u).", idx);
return DC_STATUS_DATAFORMAT;