Handle more tanks than gasmixes

When Suunto Vytecs are used in gauge mode they don't record gasmixes.
If a tank pressure sensor is present they nevertheless record the
pressures. This patch handles this situation by assuming the tanks
contain air (and warning the user about this).

Reported-by: antonnorth@gmail.com
Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Robert C. Helling 2017-02-02 10:56:22 +01:00 committed by Dirk Hohndel
parent bc8c9f4c6f
commit 99595542ec

View file

@ -94,17 +94,21 @@ static int parse_gasmixes(device_data_t *devdata, struct dive *dive, dc_parser_t
unsigned int ntanks = 0;
rc = dc_parser_get_field(parser, DC_FIELD_TANK_COUNT, 0, &ntanks);
if (rc == DC_STATUS_SUCCESS) {
if (ntanks && ntanks != ngases) {
if (ntanks && ntanks < ngases) {
shown_warning = true;
report_error("different number of gases (%d) and tanks (%d)", ngases, ntanks);
report_error("Warning: different number of gases (%d) and tanks (%d)", ngases, ntanks);
} else if (ntanks > ngases) {
shown_warning = true;
report_error("Warning: smaller number of gases (%d) than tanks (%d). Assuming air.", ngases, ntanks);
}
}
#endif
bool no_volume = true;
for (i = 0; i < ngases; i++) {
for (i = 0; i < ngases || i < ntanks; i++) {
if (i < ngases) {
dc_gasmix_t gasmix = { 0 };
int o2, he;
bool no_volume = true;
rc = dc_parser_get_field(parser, DC_FIELD_GASMIX, i, &gasmix);
if (rc != DC_STATUS_SUCCESS && rc != DC_STATUS_UNSUPPORTED)
@ -133,6 +137,10 @@ static int parse_gasmixes(device_data_t *devdata, struct dive *dive, dc_parser_t
}
dive->cylinder[i].gasmix.o2.permille = o2;
dive->cylinder[i].gasmix.he.permille = he;
} else {
dive->cylinder[i].gasmix.o2.permille = 0;
dive->cylinder[i].gasmix.he.permille = 0;
}
#if DC_VERSION_CHECK(0, 5, 0) && defined(DC_GASMIX_UNKNOWN)
if (i < ntanks) {