summaryrefslogtreecommitdiffstats
path: root/uemis-downloader.c
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2015-11-09 17:58:36 -0800
committerGravatar Dirk Hohndel <dirk@hohndel.org>2015-12-06 09:27:45 -0800
commitf29cf77b4e3f841ff11126d1914083bc970eb986 (patch)
tree02a76ad900b33783817bf0d2fd534a813195dd9d /uemis-downloader.c
parent31cdc9320eeb8c668bf2cdf15f2f8f6b7fc11603 (diff)
downloadsubsurface-f29cf77b4e3f841ff11126d1914083bc970eb986.tar.gz
Uemis downloader: recover if dive info is completely missing
I user had a Uemis that had a dive log entry for a certain internal id but no dive info for it. This appeared to be one of those dreaded dives when the Uemis decides to start a dive at the end of a flight and then stays in dive mode until it runs out of battery. Anyway, if we see a number above and a number below, just give up and move on. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'uemis-downloader.c')
-rw-r--r--uemis-downloader.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/uemis-downloader.c b/uemis-downloader.c
index 2d837f0cb..24c879cb6 100644
--- a/uemis-downloader.c
+++ b/uemis-downloader.c
@@ -1119,6 +1119,8 @@ static bool get_matching_dive(int idx, char *newmax, int *uemis_mem_status, stru
char log_file_no_to_find[20];
char dive_to_read_buf[10];
bool found = false;
+ bool found_below = false;
+ bool found_above = false;
int deleted_files = 0;
snprintf(log_file_no_to_find, sizeof(log_file_no_to_find), "logfilenr{int{%d", dive->dc.diveid);
@@ -1176,13 +1178,19 @@ static bool get_matching_dive(int idx, char *newmax, int *uemis_mem_status, stru
char *logfilenr = strstr(mbuf, "logfilenr");
if (logfilenr) {
sscanf(logfilenr, "logfilenr{int{%u", &nr_found);
- if (nr_found >= dive->dc.diveid)
+ if (nr_found >= dive->dc.diveid) {
+ found_above = true;
dive_to_read = dive_to_read - 2;
+ } else {
+ found_below = true;
+ }
if (dive_to_read < -1)
dive_to_read = -1;
}
}
}
+ if (found_above && found_below)
+ break;
dive_to_read++;
} else {
/* At this point the memory of the UEMIS is full, let's cleanup all divelog files were