From 53b4a1c225d28eb8a1d615101e839eb684bd2e34 Mon Sep 17 00:00:00 2001 From: Jef Driesen Date: Sun, 3 Jun 2012 22:13:38 +0200 Subject: [PATCH 1/9] Post release version bump to 0.1.1 --- configure.ac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index a3e8f58..056b087 100644 --- a/configure.ac +++ b/configure.ac @@ -1,7 +1,7 @@ # Versioning. m4_define([dc_version_major],[0]) m4_define([dc_version_minor],[1]) -m4_define([dc_version_micro],[0]) +m4_define([dc_version_micro],[1]) # Libtool versioning. m4_define([dc_version_lt_current],[0]) From fa54a55a89c7eb77c395a6a7b6b52462c8e72217 Mon Sep 17 00:00:00 2001 From: Jef Driesen Date: Fri, 27 Apr 2012 23:56:20 +0200 Subject: [PATCH 2/9] Add a version suffix. For development snapshots, a 'devel' suffix is added to distinguish from the final release. If necessary, the suffix can also be used for 'alpha' and 'beta' releases. --- configure.ac | 5 ++++- src/version.h.in | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/configure.ac b/configure.ac index 056b087..a41caab 100644 --- a/configure.ac +++ b/configure.ac @@ -2,6 +2,8 @@ m4_define([dc_version_major],[0]) m4_define([dc_version_minor],[1]) m4_define([dc_version_micro],[1]) +m4_define([dc_version_suffix],[devel]) +m4_define([dc_version],dc_version_major.dc_version_minor.dc_version_micro[]m4_ifdef([dc_version_suffix],-[dc_version_suffix])) # Libtool versioning. m4_define([dc_version_lt_current],[0]) @@ -10,7 +12,7 @@ m4_define([dc_version_lt_age],[0]) # Initialize autoconf. AC_PREREQ([2.60]) -AC_INIT([libdivecomputer],[dc_version_major.dc_version_minor.dc_version_micro]) +AC_INIT([libdivecomputer],[dc_version]) AC_CONFIG_SRCDIR([config.h.in]) AC_CONFIG_HEADERS([config.h]) AC_CONFIG_MACRO_DIR([m4]) @@ -76,6 +78,7 @@ AC_CHECK_HEADERS([IOKit/serial/ioss.h]) AC_CHECK_FUNCS([localtime_r gmtime_r]) # Versioning. +AC_SUBST([DC_VERSION],[dc_version]) AC_SUBST([DC_VERSION_MAJOR],[dc_version_major]) AC_SUBST([DC_VERSION_MINOR],[dc_version_minor]) AC_SUBST([DC_VERSION_MICRO],[dc_version_micro]) diff --git a/src/version.h.in b/src/version.h.in index 5e64e01..6ac63d4 100644 --- a/src/version.h.in +++ b/src/version.h.in @@ -26,7 +26,7 @@ extern "C" { #endif /* __cplusplus */ -#define DC_VERSION "@DC_VERSION_MAJOR@.@DC_VERSION_MINOR@.@DC_VERSION_MICRO@" +#define DC_VERSION "@DC_VERSION@" #define DC_VERSION_MAJOR @DC_VERSION_MAJOR@ #define DC_VERSION_MINOR @DC_VERSION_MINOR@ #define DC_VERSION_MICRO @DC_VERSION_MICRO@ From 9c59563d4c874e12177012615eb7a91cd02b58b6 Mon Sep 17 00:00:00 2001 From: Jef Driesen Date: Thu, 31 May 2012 09:04:00 +0200 Subject: [PATCH 3/9] Add support for eeprom bank number 2. Devices with firmware version 2.22 (or greater) have an additional eeprom bank with new custom functions. --- src/hw_ostc.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/hw_ostc.c b/src/hw_ostc.c index ff112b8..a0ff652 100644 --- a/src/hw_ostc.c +++ b/src/hw_ostc.c @@ -403,7 +403,7 @@ hw_ostc_device_eeprom_read (device_t *abstract, unsigned int bank, unsigned char if (! device_is_hw_ostc (abstract)) return DEVICE_STATUS_TYPE_MISMATCH; - if (bank > 1) { + if (bank > 2) { WARNING ("Invalid eeprom bank specified."); return DEVICE_STATUS_ERROR; } @@ -414,8 +414,8 @@ hw_ostc_device_eeprom_read (device_t *abstract, unsigned int bank, unsigned char } // Send the command. - unsigned char command = (bank == 0) ? 'g' : 'j'; - device_status_t rc = hw_ostc_send (device, command, 0); + const unsigned char command[] = {'g', 'j', 'm'}; + device_status_t rc = hw_ostc_send (device, command[bank], 0); if (rc != DEVICE_STATUS_SUCCESS) return rc; @@ -438,7 +438,7 @@ hw_ostc_device_eeprom_write (device_t *abstract, unsigned int bank, const unsign if (! device_is_hw_ostc (abstract)) return DEVICE_STATUS_TYPE_MISMATCH; - if (bank > 1) { + if (bank > 2) { WARNING ("Invalid eeprom bank specified."); return DEVICE_STATUS_ERROR; } @@ -449,8 +449,8 @@ hw_ostc_device_eeprom_write (device_t *abstract, unsigned int bank, const unsign } // Send the command. - unsigned char command = (bank == 0) ? 'd' : 'i'; - device_status_t rc = hw_ostc_send (device, command, 1); + const unsigned char command[] = {'d', 'i', 'n'}; + device_status_t rc = hw_ostc_send (device, command[bank], 1); if (rc != DEVICE_STATUS_SUCCESS) return rc; From 80f5c7025e110a2c4f1e9eda5f7c62f3a558948e Mon Sep 17 00:00:00 2001 From: Jef Driesen Date: Sat, 2 Jun 2012 09:27:01 +0200 Subject: [PATCH 4/9] Fix the detection of the last dive. It looks like the Icon HD erases old dives partially with 0xFF bytes before overwriting them with new dives. If the head of the oldest dive has been erased, the length field which is stored in the first 4 bytes is erased as well, and we can use it to detect the last dive. --- src/mares_iconhd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mares_iconhd.c b/src/mares_iconhd.c index 9ac25d7..6fb10c2 100644 --- a/src/mares_iconhd.c +++ b/src/mares_iconhd.c @@ -441,7 +441,7 @@ mares_iconhd_extract_dives (device_t *abstract, const unsigned char data[], unsi // equals the calculated length. If both values are different, // something is wrong and an error is returned. unsigned int length = array_uint32_le (buffer + offset); - if (length == 0) + if (length == 0 || length == 0xFFFFFFFF) break; if (length != nbytes) { WARNING ("Calculated and stored size are not equal."); From 6423edffc86f0e3f573c498c1ffb5da837eee311 Mon Sep 17 00:00:00 2001 From: Jef Driesen Date: Thu, 21 Jun 2012 20:45:12 +0200 Subject: [PATCH 5/9] Fix the profile ringbuffer end. The profile ringbuffer is smaller than expected. The purpose of the extra area after the profile ringbuffer is currently unknown. --- src/suunto_d9.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/suunto_d9.c b/src/suunto_d9.c index 8decadb..488b740 100644 --- a/src/suunto_d9.c +++ b/src/suunto_d9.c @@ -75,7 +75,7 @@ static const suunto_common2_layout_t suunto_d9tx_layout = { 0x10000, /* memsize */ 0x0024, /* serial */ 0x019A, /* rb_profile_begin */ - 0xFFFE /* rb_profile_end */ + 0xEBF0 /* rb_profile_end */ }; static int From 2f4a9abf8842de1d629cc74d67f9a804085e6baa Mon Sep 17 00:00:00 2001 From: Grischa Toedt Date: Sat, 7 Jul 2012 22:54:42 +0200 Subject: [PATCH 6/9] Fix a build error with automake 1.12 or newer. Since automake 1.12, the warnings in the category 'extra-portability' are now enabled by '-Wall'. Because of this change, linking libtool archives requires the new AM_PROG_AR macro. --- configure.ac | 3 +++ 1 file changed, 3 insertions(+) diff --git a/configure.ac b/configure.ac index a41caab..efd2c23 100644 --- a/configure.ac +++ b/configure.ac @@ -20,6 +20,9 @@ AC_CONFIG_MACRO_DIR([m4]) # Initialize automake. AM_INIT_AUTOMAKE([-Wall -Werror foreign]) +# Fix for automake >= 1.12 +m4_ifdef([AM_PROG_AR], [AM_PROG_AR]) + # Initialize libtool. LT_PREREQ([2.2.0]) LT_INIT([win32-dll]) From 0e1809aac9fe66fdee043236a869ba72d73103bf Mon Sep 17 00:00:00 2001 From: Pascal Manchon Date: Sun, 8 Jul 2012 08:28:49 +0200 Subject: [PATCH 7/9] Fix some ioctl calls on 64bit Mac OS X. On Mac OS X (and probably the other BSD's too), the ioctl() syscall takes an 'unsigned long' integer as the request parameter. On 64bit systems this is a 64bit type, while on 32bit systems it's a 32bit type. Some of the request constants are defined as 32 bit negative numbers. Casting it to a 64bit value will perform a sign extension operation to preserve the negative value. Because this results in a different request code when interpreted as an unsigned integer, the ioctl() call fails with ENOTTY. For example TIOCMBIS is defined as 0x8004746c and becomes 0xffffffff8004746 after the sign extension. Linux 64bit is unaffected by this problem. None of the request constants has the sign bit set, and thus the sign extension has no effect. For example TIOCMBIS is defined as 0x5416. By using an unsigned integer type, the sign extension can be avoided. We use the 'unsigned long' type in case one of the request constants happens to be defined as a 64bit number. --- src/serial_posix.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/serial_posix.c b/src/serial_posix.c index 50f09e1..ad9712e 100644 --- a/src/serial_posix.c +++ b/src/serial_posix.c @@ -663,7 +663,7 @@ serial_set_break (serial_t *device, int level) if (device == NULL) return -1; // EINVAL (Invalid argument) - int action = (level ? TIOCSBRK : TIOCCBRK); + unsigned long action = (level ? TIOCSBRK : TIOCCBRK); if (ioctl (device->fd, action, NULL) != 0) { TRACE ("ioctl"); @@ -677,7 +677,7 @@ serial_set_break (serial_t *device, int level) static int serial_set_status (int fd, int value, int level) { - int action = (level ? TIOCMBIS : TIOCMBIC); + unsigned long action = (level ? TIOCMBIS : TIOCMBIC); if (ioctl (fd, action, &value) != 0) { TRACE ("ioctl"); From 58d0e0a62a61b23c3a29a807d5ddbcda76cd2821 Mon Sep 17 00:00:00 2001 From: Jef Driesen Date: Sat, 11 Aug 2012 23:08:24 +0200 Subject: [PATCH 8/9] Fix the libusb timeout handling. A bulk transfer of more than 8K of data takes about one second with the Cobalt. Because we use a one second timeout combined with a 10K buffer, such a transfer can easily exceed the timeout. Normally this shouldn't be a problem because the leftover data is supposed to be received with the next transfer. However to break out of the loop we check the actual number of bytes received, and ignore the libusb LIBUSB_ERROR_TIMEOUT return code. To fix this problem, the internal buffer is reduced to 8K, and the timeout is increased to 2 seconds. This should avoid hitting the timeout and allows to consider LIBUSB_ERROR_TIMEOUT a fatal error. --- src/atomics_cobalt.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/atomics_cobalt.c b/src/atomics_cobalt.c index e7f1cde..ee949e6 100644 --- a/src/atomics_cobalt.c +++ b/src/atomics_cobalt.c @@ -36,9 +36,11 @@ #include "utils.h" #include "array.h" +#define EXITCODE(rc) (rc == LIBUSB_ERROR_TIMEOUT ? DEVICE_STATUS_TIMEOUT : DEVICE_STATUS_IO) + #define VID 0x0471 #define PID 0x0888 -#define TIMEOUT 1000 +#define TIMEOUT 2000 #define FP_OFFSET 20 @@ -218,7 +220,7 @@ atomics_cobalt_device_version (device_t *abstract, unsigned char data[], unsigne bRequest, 0, 0, NULL, 0, TIMEOUT); if (rc != LIBUSB_SUCCESS) { WARNING ("Failed to send the command."); - return DEVICE_STATUS_IO; + return EXITCODE(rc); } // Receive the answer from the dive computer. @@ -228,7 +230,7 @@ atomics_cobalt_device_version (device_t *abstract, unsigned char data[], unsigne packet, sizeof (packet), &length, TIMEOUT); if (rc != LIBUSB_SUCCESS || length != sizeof (packet)) { WARNING ("Failed to receive the answer."); - return DEVICE_STATUS_IO; + return EXITCODE(rc); } // Verify the checksum of the packet. @@ -274,19 +276,19 @@ atomics_cobalt_read_dive (device_t *abstract, dc_buffer_t *buffer, int init, dev bRequest, 0, 0, NULL, 0, TIMEOUT); if (rc != LIBUSB_SUCCESS) { WARNING ("Failed to send the command."); - return DEVICE_STATUS_IO; + return EXITCODE(rc); } unsigned int nbytes = 0; while (1) { // Receive the answer from the dive computer. int length = 0; - unsigned char packet[10 * 1024] = {0}; + unsigned char packet[8 * 1024] = {0}; rc = libusb_bulk_transfer (device->handle, 0x82, packet, sizeof (packet), &length, TIMEOUT); - if (rc != LIBUSB_SUCCESS && rc != LIBUSB_ERROR_TIMEOUT) { + if (rc != LIBUSB_SUCCESS) { WARNING ("Failed to receive the answer."); - return DEVICE_STATUS_IO; + return EXITCODE(rc); } // Update and emit a progress event. From 6242978fc010b1bc59e001209f8a4ebe0432e102 Mon Sep 17 00:00:00 2001 From: Jef Driesen Date: Wed, 15 Aug 2012 07:18:12 +0200 Subject: [PATCH 9/9] Add support for the Aeris Manta. The last memory page is marked as unreadable, and the profile ringbuffer end is set to 0xFE00. --- src/oceanic_atom2.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/oceanic_atom2.c b/src/oceanic_atom2.c index 4231b50..30fb325 100644 --- a/src/oceanic_atom2.c +++ b/src/oceanic_atom2.c @@ -63,6 +63,7 @@ static const device_backend_t oceanic_atom2_device_backend = { oceanic_atom2_device_close /* close */ }; +static const unsigned char aeris_manta_version[] = "MANTA R\0\0 512K"; static const unsigned char aeris_atmosai_version[] = "ATMOSAI R\0\0 512K"; static const unsigned char aeris_epic_version[] = "2M EPIC r\0\0 512K"; static const unsigned char aeris_f10_version[] = "FREEWAER \0\0 512K"; @@ -85,7 +86,6 @@ static const unsigned char tusa_element2_version[] = "ELEMENT2 \0\0 512K"; static const unsigned char tusa_zen_version[] = "TUSAZEN \0\0 512K"; static const unsigned char tusa_zenair_version[] = "TUZENAIR \0\0 512K"; - static const oceanic_common_layout_t aeris_f10_layout = { 0x10000, /* memsize */ 0x0000, /* cf_devinfo */ @@ -382,6 +382,7 @@ oceanic_atom2_device_open (device_t **out, const char* name) device->base.layout = &oceanic_atom1_layout; else if (oceanic_common_match (sherwood_insight_version, device->version, sizeof (device->version)) || oceanic_common_match (sherwood_wisdom2_version, device->version, sizeof (device->version)) || + oceanic_common_match (aeris_manta_version, device->version, sizeof (device->version)) || oceanic_common_match (aeris_atmosai_version, device->version, sizeof (device->version)) || oceanic_common_match (oceanic_geo2_version, device->version, sizeof (device->version)) || oceanic_common_match (oceanic_veo3_version, device->version, sizeof (device->version)) ||