summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Oliver Schwaneberg <oliver.schwaneberg@gmail.com>2018-01-28 20:20:02 +0100
committerGravatar Jan Mulder <jlmulder@xs4all.nl>2018-01-31 14:46:30 +0100
commit5a9faf2fead68df70c9e660c1ebb9b6fad90ba33 (patch)
tree89c3c8815e4f3680ae6cbb7cc020167de755c5d4
parentcd759a3b1e35b75bb51c44453b7883dfcb9701ad (diff)
downloadsubsurface-5a9faf2fead68df70c9e660c1ebb9b6fad90ba33.tar.gz
uemis: Fix mapping of object_ids to dive numbers
When performing a factory reset to an uemis, the object_ids within the divelog will not be reset. Nevertheless, the dive numbers are reset to 1. So, the first log will have a positive offset n to the first dive number. The uemis-downloader used the object_id from the logs as a start point for getDive, if dives were already synced before. This causes the sync to stall. I prevent this by subtracting the lowest object_id from the requested before using it as dive number. Signed-off-by: Oliver Schwaneberg <oliver.schwaneberg@gmail.com>
-rw-r--r--core/uemis-downloader.c20
1 files changed, 15 insertions, 5 deletions
diff --git a/core/uemis-downloader.c b/core/uemis-downloader.c
index 2939b3cf6..ff0027f7b 100644
--- a/core/uemis-downloader.c
+++ b/core/uemis-downloader.c
@@ -73,6 +73,7 @@ static int mbuf_size = 0;
static int max_mem_used = -1;
static int next_table_index = 0;
static int dive_to_read = 0;
+static uint32_t mindiveid;
static int max_deleted_seen = -1;
@@ -1034,6 +1035,7 @@ static char *uemis_get_divenr(char *deviceidstr, int force)
char divenr[10];
struct dive_table *table;
deviceid = atoi(deviceidstr);
+ mindiveid = 0xFFFFFFFF;
/*
* If we are are retrying after a disconnect/reconnect, we
@@ -1055,9 +1057,12 @@ static char *uemis_get_divenr(char *deviceidstr, int force)
continue;
for_each_dc (d, dc) {
if (dc->model && !strcmp(dc->model, "Uemis Zurich") &&
- (dc->deviceid == 0 || dc->deviceid == 0x7fffffff || dc->deviceid == deviceid) &&
- dc->diveid > maxdiveid)
- maxdiveid = dc->diveid;
+ (dc->deviceid == 0 || dc->deviceid == 0x7fffffff || dc->deviceid == deviceid)) {
+ if (dc->diveid > maxdiveid)
+ maxdiveid = dc->diveid;
+ if (dc->diveid < mindiveid)
+ mindiveid = dc->diveid;
+ }
}
}
if (max_deleted_seen >= 0 && maxdiveid < (uint32_t)max_deleted_seen) {
@@ -1216,6 +1221,7 @@ static bool get_matching_dive(int idx, char *newmax, int *uemis_mem_status, devi
bool found_below = false;
bool found_above = false;
int deleted_files = 0;
+ int fail_count = 0;
snprintf(log_file_no_to_find, sizeof(log_file_no_to_find), "logfilenr{int{%d", dive->dc.diveid);
#if UEMIS_DEBUG & 2
@@ -1283,6 +1289,10 @@ static bool get_matching_dive(int idx, char *newmax, int *uemis_mem_status, devi
}
if (dive_to_read < -1)
dive_to_read = -1;
+ } else if (!strstr(mbuf, "act{") && ++fail_count == 10) {
+ if (verbose)
+ fprintf(stderr, "Uemis downloader: Cannot access dive details - searching from start\n");
+ dive_to_read = -1;
}
}
}
@@ -1347,10 +1357,10 @@ const char *do_uemis_import(device_data_t *data)
param_buff[1] = "notempty";
newmax = uemis_get_divenr(deviceid, force_download);
if (verbose)
- fprintf(stderr, "Uemis downloader: start looking at dive nr %s", newmax);
+ fprintf(stderr, "Uemis downloader: start looking at dive nr %s\n", newmax);
first = start = atoi(newmax);
- dive_to_read = first;
+ dive_to_read = mindiveid < first ? first - mindiveid : first;
for (;;) {
#if UEMIS_DEBUG & 2
debug_round++;