From 52d8f0828135dde3c70d8ec96a511da1a5eb4fd8 Mon Sep 17 00:00:00 2001 From: Jef Driesen Date: Wed, 23 May 2012 21:45:46 +0200 Subject: [PATCH] Enable the model hint to speedup the autodetection. --- examples/suunto_d9_test.c | 4 ++-- examples/universal.c | 2 +- src/suunto_d9.c | 6 +++--- src/suunto_d9.h | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/examples/suunto_d9_test.c b/examples/suunto_d9_test.c index a2fb938..8899676 100644 --- a/examples/suunto_d9_test.c +++ b/examples/suunto_d9_test.c @@ -32,7 +32,7 @@ test_dump_sdm (const char* name) device_t *device = NULL; message ("suunto_d9_device_open\n"); - device_status_t rc = suunto_d9_device_open (&device, name); + device_status_t rc = suunto_d9_device_open (&device, name, 0); if (rc != DEVICE_STATUS_SUCCESS) { WARNING ("Error opening serial port."); return rc; @@ -72,7 +72,7 @@ test_dump_memory (const char* name, const char* filename) device_t *device = NULL; message ("suunto_d9_device_open\n"); - device_status_t rc = suunto_d9_device_open (&device, name); + device_status_t rc = suunto_d9_device_open (&device, name, 0); if (rc != DEVICE_STATUS_SUCCESS) { WARNING ("Error opening serial port."); return rc; diff --git a/examples/universal.c b/examples/universal.c index 2cfe565..5a25622 100644 --- a/examples/universal.c +++ b/examples/universal.c @@ -604,7 +604,7 @@ dowork (device_type_t backend, unsigned int model, const char *devname, const ch rc = suunto_vyper2_device_open (&device, devname); break; case DEVICE_TYPE_SUUNTO_D9: - rc = suunto_d9_device_open (&device, devname); + rc = suunto_d9_device_open (&device, devname, model); break; case DEVICE_TYPE_UWATEC_ALADIN: rc = uwatec_aladin_device_open (&device, devname); diff --git a/src/suunto_d9.c b/src/suunto_d9.c index 8decadb..8e6298f 100644 --- a/src/suunto_d9.c +++ b/src/suunto_d9.c @@ -123,7 +123,7 @@ suunto_d9_device_autodetect (suunto_d9_device_t *device, unsigned int model) device_status_t -suunto_d9_device_open (device_t **out, const char* name) +suunto_d9_device_open (device_t **out, const char* name, unsigned int model) { if (out == NULL) return DEVICE_STATUS_ERROR; @@ -182,7 +182,7 @@ suunto_d9_device_open (device_t **out, const char* name) serial_flush (device->port, SERIAL_QUEUE_BOTH); // Try to autodetect the protocol variant. - device_status_t status = suunto_d9_device_autodetect (device, 0); + device_status_t status = suunto_d9_device_autodetect (device, model); if (status != DEVICE_STATUS_SUCCESS) { WARNING ("Failed to identify the protocol variant."); serial_close (device->port); @@ -191,7 +191,7 @@ suunto_d9_device_open (device_t **out, const char* name) } // Override the base class values. - unsigned int model = device->version[0]; + model = device->version[0]; if (model == D4i || model == D6i || model == D9tx) device->base.layout = &suunto_d9tx_layout; else diff --git a/src/suunto_d9.h b/src/suunto_d9.h index eeb1dfc..d49e44a 100644 --- a/src/suunto_d9.h +++ b/src/suunto_d9.h @@ -34,7 +34,7 @@ extern "C" { #define SUUNTO_D9_VERSION_SIZE 0x04 device_status_t -suunto_d9_device_open (device_t **device, const char* name); +suunto_d9_device_open (device_t **device, const char* name, unsigned int model); device_status_t suunto_d9_device_reset_maxdepth (device_t *device);