X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=libdivecomputer.c;h=2b62fa3652b58e556684ca87df48f7364573a6a6;hb=518ec33ba3bf9c5e9966ef108c1673223337b0fa;hp=da9b35bd3c04dd7ff321dd6ac568884f9e81046a;hpb=42f627b8b1cf7e929a30c0a07a5fb44a4cec9e1f;p=ext%2Fsubsurface.git diff --git a/libdivecomputer.c b/libdivecomputer.c index da9b35b..2b62fa3 100644 --- a/libdivecomputer.c +++ b/libdivecomputer.c @@ -18,6 +18,9 @@ #include #include +/* handling uemis Zurich SDA files */ +#include "uemis.h" + /* * I'd love to do a while-loop here for pending events, but * that seems to screw up with the dive computer reading timing. @@ -124,6 +127,7 @@ static int parse_gasmixes(struct dive *dive, parser_t *parser, int ngases) for (i = 0; i < ngases; i++) { int rc; gasmix_t gasmix = {0}; + int o2, he; rc = parser_get_field(parser, FIELD_TYPE_GASMIX, i, &gasmix); if (rc != PARSER_STATUS_SUCCESS && rc != PARSER_STATUS_UNSUPPORTED) @@ -132,8 +136,17 @@ static int parse_gasmixes(struct dive *dive, parser_t *parser, int ngases) if (i >= MAX_CYLINDERS) continue; - dive->cylinder[i].gasmix.o2.permille = gasmix.oxygen * 1000 + 0.5; - dive->cylinder[i].gasmix.he.permille = gasmix.helium * 1000 + 0.5; + o2 = gasmix.oxygen * 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; } @@ -424,12 +437,14 @@ cancel_cb(void *userdata) static void do_import(device_data_t *data) { - /* FIXME! Needs user input! */ - const char *devname = "/dev/ttyUSB0"; device_t *device = NULL; device_status_t rc; - rc = device_open(devname, data->type, &device); + if (data->type == DEVICE_TYPE_UEMIS) { + return uemis_import(); + } + + rc = device_open(data->devname, data->type, &device); if (rc != DEVICE_STATUS_SUCCESS) { error("Unable to open %s (%s)", data->name, data->devname); return; @@ -494,6 +509,7 @@ struct device_list { { "Cressi Edy", DEVICE_TYPE_CRESSI_EDY }, { "Zeagle N2iTiON 3", DEVICE_TYPE_ZEAGLE_N2ITION3 }, { "Atomics Cobalt", DEVICE_TYPE_ATOMICS_COBALT }, + { "Uemis Zurich SDA", DEVICE_TYPE_UEMIS }, { NULL } };