Ignore disabled gas mixes.

Gas mixes are disabled by setting their oxygen percentage byte to 0x00.
This is clearly an invalid gas mix, and it makes no sense to return it
back to the application.

It seems the device doesn't allow you to enable a gas mix if the
previous gas mix has already been disabled. Therefore we can simply stop
parsing the gas mixes once the first disabled gas mix has been found.
This commit is contained in:
Jef Driesen 2015-03-07 23:30:02 +01:00
parent 4fd825cdac
commit 76f93d3fe5

View File

@ -282,10 +282,16 @@ uwatec_smart_parser_cache (uwatec_smart_parser_t *parser)
}
// Get the gas mixes.
unsigned int ngasmixes = 0;
unsigned int oxygen[NGASMIXES] = {0};
unsigned int ngasmixes = (trimix ? 0 : parser->header->ngases);
for (unsigned int i = 0; i < ngasmixes; ++i) {
oxygen[i] = data[parser->header->gasmix + i * 2];
if (!trimix) {
for (unsigned int i = 0; i < parser->header->ngases; ++i) {
unsigned int o2 = data[parser->header->gasmix + i * 2];
if (o2 == 0)
break; // Skip disabled gas mixes.
oxygen[ngasmixes] = o2;
ngasmixes++;
}
}
// Cache the data for later use.