- printf("<datetime>%04i-%02i-%02i %02i:%02i:%02i</datetime>\n",
- dt.year, dt.month, dt.day,
- dt.hour, dt.minute, dt.second);
-
- parser_destroy(parser);
- return PARSER_STATUS_SUCCESS;
-}
-
-
-static device_status_t import_device_data(device_t *device, device_data_t *devicedata)
-{
- return device_foreach(device, dive_cb, devicedata);
-}
-
-static device_status_t device_open(const char *devname,
- device_type_t type,
- device_t **device)
-{
- switch (type) {
- case DEVICE_TYPE_SUUNTO_SOLUTION:
- return suunto_solution_device_open(device, devname);
-
- case DEVICE_TYPE_SUUNTO_EON:
- return suunto_eon_device_open(device, devname);
-
- case DEVICE_TYPE_SUUNTO_VYPER:
- return suunto_vyper_device_open(device, devname);
-
- case DEVICE_TYPE_SUUNTO_VYPER2:
- return suunto_vyper2_device_open(device, devname);
-
- case DEVICE_TYPE_SUUNTO_D9:
- return suunto_d9_device_open(device, devname);
-
- case DEVICE_TYPE_UWATEC_ALADIN:
- return uwatec_aladin_device_open(device, devname);
-
- case DEVICE_TYPE_UWATEC_MEMOMOUSE:
- return uwatec_memomouse_device_open(device, devname);
-
- case DEVICE_TYPE_UWATEC_SMART:
- return uwatec_smart_device_open(device);
-
- case DEVICE_TYPE_REEFNET_SENSUS:
- return reefnet_sensus_device_open(device, devname);
-
- case DEVICE_TYPE_REEFNET_SENSUSPRO:
- return reefnet_sensuspro_device_open(device, devname);
-
- case DEVICE_TYPE_REEFNET_SENSUSULTRA:
- return reefnet_sensusultra_device_open(device, devname);
-
- case DEVICE_TYPE_OCEANIC_VTPRO:
- return oceanic_vtpro_device_open(device, devname);
-
- case DEVICE_TYPE_OCEANIC_VEO250:
- return oceanic_veo250_device_open(device, devname);
-
- case DEVICE_TYPE_OCEANIC_ATOM2:
- return oceanic_atom2_device_open(device, devname);
-
- case DEVICE_TYPE_MARES_NEMO:
- return mares_nemo_device_open(device, devname);
+ tm.tm_year = dt.year;
+ tm.tm_mon = dt.month-1;
+ tm.tm_mday = dt.day;
+ tm.tm_hour = dt.hour;
+ tm.tm_min = dt.minute;
+ tm.tm_sec = dt.second;
+ dive->when = utc_mktime(&tm);
+
+ // Parse the divetime.
+ dev_info(devdata, "Dive %d: %s %d %04d", import_dive_number,
+ monthname(tm.tm_mon), tm.tm_mday, year(tm.tm_year));
+ unsigned int divetime = 0;
+ rc = dc_parser_get_field (parser, DC_FIELD_DIVETIME, 0, &divetime);
+ if (rc != DC_STATUS_SUCCESS && rc != DC_STATUS_UNSUPPORTED) {
+ dev_info(devdata, "Error parsing the divetime");
+ dc_parser_destroy(parser);
+ return rc;
+ }
+ dive->duration.seconds = divetime;
+
+ // Parse the maxdepth.
+ double maxdepth = 0.0;
+ rc = dc_parser_get_field(parser, DC_FIELD_MAXDEPTH, 0, &maxdepth);
+ if (rc != DC_STATUS_SUCCESS && rc != DC_STATUS_UNSUPPORTED) {
+ dev_info(devdata, "Error parsing the maxdepth");
+ dc_parser_destroy(parser);
+ return rc;
+ }
+ dive->maxdepth.mm = maxdepth * 1000 + 0.5;
+
+ // Parse the gas mixes.
+ unsigned int ngases = 0;
+ rc = dc_parser_get_field(parser, DC_FIELD_GASMIX_COUNT, 0, &ngases);
+ if (rc != DC_STATUS_SUCCESS && rc != DC_STATUS_UNSUPPORTED) {
+ dev_info(devdata, "Error parsing the gas mix count");
+ dc_parser_destroy(parser);
+ return rc;
+ }