summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Jef Driesen <jefdriesen@telenet.be>2014-01-07 20:38:36 +0100
committerGravatar Dirk Hohndel <dirk@hohndel.org>2014-01-09 09:30:05 +0800
commit8626778918b4dd5a304cbe970eded6cad759431b (patch)
tree33fb9288050be45c416c4cbd63cda97f1e4c86f9
parent7d56e404fdd09c1ec24b966eb00ba31c8f87ba70 (diff)
downloadsubsurface-8626778918b4dd5a304cbe970eded6cad759431b.tar.gz
Write the event data to the libdivecomputer log.
For some devices, the event data contains important data that is required for parsing the dives, but which is not present in the full memory dump. Signed-off-by: Jef Driesen <jefdriesen@telenet.be> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
-rw-r--r--libdivecomputer.c23
-rw-r--r--libdivecomputer.h1
2 files changed, 23 insertions, 1 deletions
diff --git a/libdivecomputer.c b/libdivecomputer.c
index 78d3808f9..48b8151d2 100644
--- a/libdivecomputer.c
+++ b/libdivecomputer.c
@@ -610,6 +610,7 @@ static void event_cb(dc_device_t *device, dc_event_type_t event, const void *dat
const dc_event_progress_t *progress = data;
const dc_event_devinfo_t *devinfo = data;
const dc_event_clock_t *clock = data;
+ const dc_event_vendor_t *vendor = data;
device_data_t *devdata = userdata;
unsigned int serial;
@@ -627,6 +628,12 @@ static void event_cb(dc_device_t *device, dc_event_type_t event, const void *dat
devinfo->model, devinfo->model,
devinfo->firmware, devinfo->firmware,
devinfo->serial, devinfo->serial);
+ if (devdata->libdc_logfile) {
+ fprintf(devdata->libdc_logfile, "Event: model=%u (0x%08x), firmware=%u (0x%08x), serial=%u (0x%08x)\n",
+ devinfo->model, devinfo->model,
+ devinfo->firmware, devinfo->firmware,
+ devinfo->serial, devinfo->serial);
+ }
/*
* libdivecomputer doesn't give serial numbers in the proper string form,
* so we have to see if we can do some vendor-specific munging.
@@ -640,6 +647,18 @@ static void event_cb(dc_device_t *device, dc_event_type_t event, const void *dat
case DC_EVENT_CLOCK:
dev_info(devdata, translate("gettextFromC","Event: systime=%"PRId64", devtime=%u\n"),
(uint64_t)clock->systime, clock->devtime);
+ if (devdata->libdc_logfile) {
+ fprintf(devdata->libdc_logfile, "Event: systime=%"PRId64", devtime=%u\n",
+ (uint64_t)clock->systime, clock->devtime);
+ }
+ break;
+ case DC_EVENT_VENDOR:
+ if (devdata->libdc_logfile) {
+ fprintf(devdata->libdc_logfile, "Event: vendor=");
+ for (unsigned int i = 0; i < vendor->size; ++i)
+ fprintf(devdata->libdc_logfile, "%02X", vendor->data[i]);
+ fprintf(devdata->libdc_logfile,"\n");
+ }
break;
default:
break;
@@ -662,7 +681,7 @@ static const char *do_device_import(device_data_t *data)
data->model = str_printf("%s %s", data->vendor, data->product);
// Register the event handler.
- int events = DC_EVENT_WAITING | DC_EVENT_PROGRESS | DC_EVENT_DEVINFO | DC_EVENT_CLOCK;
+ int events = DC_EVENT_WAITING | DC_EVENT_PROGRESS | DC_EVENT_DEVINFO | DC_EVENT_CLOCK | DC_EVENT_VENDOR;
rc = dc_device_set_events(device, events, event_cb, data);
if (rc != DC_STATUS_SUCCESS)
return translate("gettextFromC","Error registering the event handler.");
@@ -724,6 +743,8 @@ const char *do_libdivecomputer_import(device_data_t *data)
if (data->libdc_log && logfile_name)
fp = subsurface_fopen(logfile_name, "w");
+ data->libdc_logfile = fp;
+
rc = dc_context_new(&data->context);
if (rc != DC_STATUS_SUCCESS)
return translate("gettextFromC","Unable to create libdivecomputer context");
diff --git a/libdivecomputer.h b/libdivecomputer.h
index 754a98f44..8285f5a9f 100644
--- a/libdivecomputer.h
+++ b/libdivecomputer.h
@@ -26,6 +26,7 @@ typedef struct device_data_t {
bool force_download;
bool libdc_log;
bool libdc_dump;
+ FILE *libdc_logfile;
} device_data_t;
const char *do_libdivecomputer_import(device_data_t *data);