Add a workaround for a missing initial gas mix.

In some rare cases, the initial gas mix contains the value 0xFF. This
value is obviously outside the expected range (1-5), and therefore
causes the parsing to fail. It's not really clear how this can happen.

As a workaround for the fatal error, we now ignore the invalid value and
simply proceed without a gas mix.
This commit is contained in:
Jef Driesen 2015-11-17 20:48:39 +01:00
parent 842c4ca466
commit 9ee3a10390

View File

@ -239,11 +239,15 @@ hw_ostc_parser_cache (hw_ostc_parser_t *parser)
gasmix[i].helium = data[19 + 2 * i + 1];
}
}
if (initial < 1 || initial > ngasmixes) {
ERROR(abstract->context, "Invalid initial gas mix.");
return DC_STATUS_DATAFORMAT;
if (initial != 0xFF) {
if (initial < 1 || initial > ngasmixes) {
ERROR(abstract->context, "Invalid initial gas mix.");
return DC_STATUS_DATAFORMAT;
}
initial--; /* Convert to a zero based index. */
} else {
WARNING(abstract->context, "No initial gas mix available.");
}
initial--; /* Convert to a zero based index. */
// Cache the data for later use.
parser->version = version;
@ -611,7 +615,7 @@ hw_ostc_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callback_t call
if (callback) callback (DC_SAMPLE_TIME, sample, userdata);
// Initial gas mix.
if (time == samplerate) {
if (time == samplerate && parser->initial != 0xFF) {
unsigned int idx = parser->initial;
unsigned int o2 = parser->gasmix[idx].oxygen;
unsigned int he = parser->gasmix[idx].helium;