Use a default tank when populating tank data after download

This is super-simplistic and also is kinda wrong. It forces all tanks that
haven't been specified by the DC (so far only Atomics Aquatics Cobalt and
UEMIS Zurich (which doesn't even use libdivecomputer) to be AL80. Just as
we used AL80 as default for manually adding tanks.

Obviously this needs to become an option where the user can pick.

See #145

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Dirk Hohndel 2013-11-23 14:54:42 -08:00
parent 450fd9c7bd
commit 03a0678b00

View file

@ -54,7 +54,7 @@ struct atomics_gas_info {
#define COBALT_CFATBAR 2
#define COBALT_WETINDL 3
static void get_tanksize(device_data_t *devdata, const unsigned char *data, cylinder_t *cyl, int idx)
static bool get_tanksize(device_data_t *devdata, const unsigned char *data, cylinder_t *cyl, int idx)
{
/* I don't like this kind of match... I'd love to have an ID and
* a firmware version or... something; and even better, just get
@ -69,7 +69,7 @@ static void get_tanksize(device_data_t *devdata, const unsigned char *data, cyli
* right data */
if (*(uint32_t *)data != 0xFFFEFFFE) {
printf("incorrect header for Atomics dive\n");
return;
return FALSE;
}
atomics_gas_info = (void*)(data + COBALT_HEADER);
switch (atomics_gas_info[idx].tankspecmethod) {
@ -89,7 +89,9 @@ static void get_tanksize(device_data_t *devdata, const unsigned char *data, cyli
cyl[idx].type.size.mliter = atomics_gas_info[idx].tanksize * 100;
break;
}
return TRUE;
}
return FALSE;
}
static int parse_gasmixes(device_data_t *devdata, struct dive *dive, dc_parser_t *parser, int ngases,
@ -121,7 +123,8 @@ 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;
get_tanksize(devdata, data, dive->cylinder, i);
if (!get_tanksize(devdata, data, dive->cylinder, i))
fill_default_cylinder(&dive->cylinder[i]);
}
return DC_STATUS_SUCCESS;
}