From dbb6b1aa2116ab654de5f6e7289439f1851cc964 Mon Sep 17 00:00:00 2001 From: Jef Driesen Date: Sat, 12 Jan 2013 22:17:38 +0100 Subject: [PATCH] Fix the decoding of the Suunto serial numbers. The serial numbers were not decoded at all. The raw bytes where simply converted into an arbitrary 32 bit integer. Now the serial number matches the real serial number as shown by the device. --- src/suunto_common2.c | 6 +++++- src/suunto_eon.c | 6 +++++- src/suunto_solution.c | 6 +++++- src/suunto_vyper.c | 6 +++++- 4 files changed, 20 insertions(+), 4 deletions(-) diff --git a/src/suunto_common2.c b/src/suunto_common2.c index 28b3858..2bfbd11 100644 --- a/src/suunto_common2.c +++ b/src/suunto_common2.c @@ -268,7 +268,11 @@ suunto_common2_device_foreach (dc_device_t *abstract, dc_dive_callback_t callbac dc_event_devinfo_t devinfo; devinfo.model = device->version[0]; devinfo.firmware = array_uint24_be (device->version + 1); - devinfo.serial = array_uint32_be (serial); + devinfo.serial = 0; + for (unsigned int i = 0; i < 4; ++i) { + devinfo.serial *= 100; + devinfo.serial += serial[i]; + } device_event_emit (abstract, DC_EVENT_DEVINFO, &devinfo); // Read the header bytes. diff --git a/src/suunto_eon.c b/src/suunto_eon.c index fb61b53..9354c57 100644 --- a/src/suunto_eon.c +++ b/src/suunto_eon.c @@ -227,7 +227,11 @@ suunto_eon_device_foreach (dc_device_t *abstract, dc_dive_callback_t callback, v dc_event_devinfo_t devinfo; devinfo.model = 0; devinfo.firmware = 0; - devinfo.serial = array_uint24_be (data + 244); + devinfo.serial = 0; + for (unsigned int i = 0; i < 3; ++i) { + devinfo.serial *= 100; + devinfo.serial += bcd2dec (data[244 + i]); + } device_event_emit (abstract, DC_EVENT_DEVINFO, &devinfo); rc = suunto_eon_extract_dives (abstract, diff --git a/src/suunto_solution.c b/src/suunto_solution.c index 9af41b2..625eb3c 100644 --- a/src/suunto_solution.c +++ b/src/suunto_solution.c @@ -279,7 +279,11 @@ suunto_solution_device_foreach (dc_device_t *abstract, dc_dive_callback_t callba dc_event_devinfo_t devinfo; devinfo.model = 0; devinfo.firmware = 0; - devinfo.serial = array_uint24_be (data + 0x1D); + devinfo.serial = 0; + for (unsigned int i = 0; i < 3; ++i) { + devinfo.serial *= 100; + devinfo.serial += bcd2dec (data[0x1D + i]); + } device_event_emit (abstract, DC_EVENT_DEVINFO, &devinfo); rc = suunto_solution_extract_dives (abstract, diff --git a/src/suunto_vyper.c b/src/suunto_vyper.c index f644883..84bc24c 100644 --- a/src/suunto_vyper.c +++ b/src/suunto_vyper.c @@ -527,7 +527,11 @@ suunto_vyper_device_foreach (dc_device_t *abstract, dc_dive_callback_t callback, dc_event_devinfo_t devinfo; devinfo.model = header[hoffset + 0]; devinfo.firmware = header[hoffset + 1]; - devinfo.serial = array_uint32_be (header + hoffset + 2); + devinfo.serial = 0; + for (unsigned int i = 0; i < 4; ++i) { + devinfo.serial *= 100; + devinfo.serial += header[hoffset + 2 + i]; + } device_event_emit (abstract, DC_EVENT_DEVINFO, &devinfo); // Allocate a memory buffer.