Convert the gasmix id into an array index.
The gasmix value in the sample data is the id of the gasmix. Depending how the user manipulated the gasmix settings, this id is not necessary identical to the index into the gasmix array. The array index can be found by searching the array for a mix with the correct id.
This commit is contained in:
parent
8edc765e6b
commit
9db9e970cf
@ -237,12 +237,19 @@ atomics_cobalt_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callback
|
||||
|
||||
// Current gas mix
|
||||
unsigned int gasmix = data[offset + 4];
|
||||
if (gasmix >= ngasmixes) {
|
||||
return DC_STATUS_DATAFORMAT;
|
||||
}
|
||||
if (gasmix != gasmix_previous) {
|
||||
unsigned int o2 = data[SZ_HEADER + SZ_GASMIX * gasmix + 4];
|
||||
unsigned int he = data[SZ_HEADER + SZ_GASMIX * gasmix + 5];
|
||||
unsigned int idx = 0;
|
||||
while (idx < ngasmixes) {
|
||||
if (data[SZ_HEADER + SZ_GASMIX * idx + 0] == gasmix)
|
||||
break;
|
||||
idx++;
|
||||
}
|
||||
if (idx >= ngasmixes) {
|
||||
ERROR (abstract->context, "Invalid gas mix index.");
|
||||
return DC_STATUS_DATAFORMAT;
|
||||
}
|
||||
unsigned int o2 = data[SZ_HEADER + SZ_GASMIX * idx + 4];
|
||||
unsigned int he = data[SZ_HEADER + SZ_GASMIX * idx + 5];
|
||||
sample.event.type = SAMPLE_EVENT_GASCHANGE2;
|
||||
sample.event.time = 0;
|
||||
sample.event.flags = 0;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user