summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Miika Turkia <miika.turkia@gmail.com>2015-02-21 20:55:06 +0200
committerGravatar Dirk Hohndel <dirk@hohndel.org>2015-02-22 07:47:54 -0800
commit27d0cd68fcafc8c6a73b5d36b158929a24996406 (patch)
tree489e5db3dd9a738999f505fb5ba4fa1bc69aac3b
parent5330a612c57df55c53513411fe5f87eb7b399944 (diff)
downloadsubsurface-27d0cd68fcafc8c6a73b5d36b158929a24996406.tar.gz
Import DC info properly from DM5 log
Using serial number as device ID here for simplicity. We also need the DC info for the divecomputer tag per dive. And it seems that serial number is in SerialNumber, SourceSerialNumber or both. Signed-off-by: Miika Turkia <miika.turkia@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
-rw-r--r--parse-xml.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/parse-xml.c b/parse-xml.c
index d656ed31a..530a41db3 100644
--- a/parse-xml.c
+++ b/parse-xml.c
@@ -2267,12 +2267,13 @@ extern int dm5_dive(void *param, int columns, char **data, char **column)
*/
settings_start();
dc_settings_start();
- if (data[4])
+ if (data[4]) {
utf8_string(data[4], &cur_settings.dc.serial_nr);
+ cur_settings.dc.deviceid = atoi(data[4]);
+ }
if (data[5])
utf8_string(data[5], &cur_settings.dc.model);
- cur_settings.dc.deviceid = 0xffffffff;
dc_settings_end();
settings_end();
@@ -2283,9 +2284,11 @@ extern int dm5_dive(void *param, int columns, char **data, char **column)
if (data[9])
cur_dive->dc.watertemp.mkelvin = C_to_mkelvin(atoi(data[9]));
- /*
- * TODO: handle multiple cylinders
- */
+ if (data[4]) {
+ cur_dive->dc.deviceid = atoi(data[4]);
+ }
+ if (data[5])
+ utf8_string(data[5], &cur_dive->dc.model);
snprintf(get_events, sizeof(get_events) - 1, get_cylinders_template, cur_dive->number);
retval = sqlite3_exec(handle, get_events, &dm5_cylinders, 0, &err);
@@ -2404,7 +2407,7 @@ int parse_dm5_buffer(sqlite3 *handle, const char *url, const char *buffer, int s
/* StartTime is converted from Suunto's nano seconds to standard
* time. We also need epoch, not seconds since year 1. */
- char get_dives[] = "select D.DiveId,StartTime/10000000-62135596800,Note,Duration,SourceSerialNumber,Source,MaxDepth,SampleInterval,StartTemperature,BottomTemperature,D.StartPressure,D.EndPressure,Size,CylinderWorkPressure,SurfacePressure,DiveTime,SampleInterval,ProfileBlob,TemperatureBlob,PressureBlob,Oxygen,Helium,MIX.StartPressure,MIX.EndPressure,SampleBlob FROM Dive AS D JOIN DiveMixture AS MIX ON D.DiveId=MIX.DiveId";
+ char get_dives[] = "select D.DiveId,StartTime/10000000-62135596800,Note,Duration,coalesce(SourceSerialNumber,SerialNumber),Source,MaxDepth,SampleInterval,StartTemperature,BottomTemperature,D.StartPressure,D.EndPressure,Size,CylinderWorkPressure,SurfacePressure,DiveTime,SampleInterval,ProfileBlob,TemperatureBlob,PressureBlob,Oxygen,Helium,MIX.StartPressure,MIX.EndPressure,SampleBlob FROM Dive AS D JOIN DiveMixture AS MIX ON D.DiveId=MIX.DiveId";
retval = sqlite3_exec(handle, get_dives, &dm5_dive, handle, &err);