mirror of
https://github.com/subsurface/subsurface.git
synced 2024-11-28 05:00:20 +00:00
Do some basic sanity testing on the libdivecomputer gasmix data
It's quite often obvious crap for the "doesn't exist" or "plain air" case. So if it's reporting 100% O2, we just ignore it. Sure, it could be right, but for the dives I have I know it's just libdivecomputer being wrong. Same goes for obvious crap like 255% Helium. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
parent
42f627b8b1
commit
4e7161efd6
1 changed files with 12 additions and 2 deletions
|
@ -124,6 +124,7 @@ static int parse_gasmixes(struct dive *dive, parser_t *parser, int ngases)
|
||||||
for (i = 0; i < ngases; i++) {
|
for (i = 0; i < ngases; i++) {
|
||||||
int rc;
|
int rc;
|
||||||
gasmix_t gasmix = {0};
|
gasmix_t gasmix = {0};
|
||||||
|
int o2, he;
|
||||||
|
|
||||||
rc = parser_get_field(parser, FIELD_TYPE_GASMIX, i, &gasmix);
|
rc = parser_get_field(parser, FIELD_TYPE_GASMIX, i, &gasmix);
|
||||||
if (rc != PARSER_STATUS_SUCCESS && rc != PARSER_STATUS_UNSUPPORTED)
|
if (rc != PARSER_STATUS_SUCCESS && rc != PARSER_STATUS_UNSUPPORTED)
|
||||||
|
@ -132,8 +133,17 @@ static int parse_gasmixes(struct dive *dive, parser_t *parser, int ngases)
|
||||||
if (i >= MAX_CYLINDERS)
|
if (i >= MAX_CYLINDERS)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
dive->cylinder[i].gasmix.o2.permille = gasmix.oxygen * 1000 + 0.5;
|
o2 = gasmix.oxygen * 1000 + 0.5;
|
||||||
dive->cylinder[i].gasmix.he.permille = gasmix.helium * 1000 + 0.5;
|
he = gasmix.helium * 1000 + 0.5;
|
||||||
|
|
||||||
|
/* Ignore bogus data - libdivecomputer does some crazy stuff */
|
||||||
|
if (o2 < 210 || o2 >= 1000)
|
||||||
|
o2 = 0;
|
||||||
|
if (he < 0 || he >= 800 || o2+he >= 1000)
|
||||||
|
he = 0;
|
||||||
|
|
||||||
|
dive->cylinder[i].gasmix.o2.permille = o2;
|
||||||
|
dive->cylinder[i].gasmix.he.permille = he;
|
||||||
}
|
}
|
||||||
return PARSER_STATUS_SUCCESS;
|
return PARSER_STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue