mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Improve reading of extra dive data for Uemis
When starting from the first dive on the dive computer we called getDive for every dive starting with id 0 instead of figuring out which id is actually the first one that we downloaded. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
a012ce0515
commit
240442cec9
1 changed files with 34 additions and 8 deletions
|
@ -320,15 +320,14 @@ static gboolean next_file(int max)
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ultra-simplistic; it doesn't deal with the case when the object_id is
|
static char *first_object_id_val(char* buf)
|
||||||
* split across two chunks. It also doesn't deal with the discrepancy between
|
|
||||||
* object_id and dive number as understood by the dive computer */
|
|
||||||
static void show_progress(char *buf, char *what)
|
|
||||||
{
|
{
|
||||||
char *object;
|
char *object;
|
||||||
|
if (!buf)
|
||||||
|
return NULL;
|
||||||
object = strstr(buf, "object_id");
|
object = strstr(buf, "object_id");
|
||||||
if (object) {
|
if (object) {
|
||||||
/* let the user know what we are working on */
|
/* get the value */
|
||||||
char tmp[10];
|
char tmp[10];
|
||||||
char *p = object + 14;
|
char *p = object + 14;
|
||||||
char *t = tmp;
|
char *t = tmp;
|
||||||
|
@ -337,8 +336,22 @@ static void show_progress(char *buf, char *what)
|
||||||
while (*p != '{' && t < tmp + 9)
|
while (*p != '{' && t < tmp + 9)
|
||||||
*t++ = *p++;
|
*t++ = *p++;
|
||||||
*t = '\0';
|
*t = '\0';
|
||||||
uemis_info(_("Reading %s %s"), what, tmp);
|
|
||||||
}
|
}
|
||||||
|
return strdup(tmp);
|
||||||
|
}
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ultra-simplistic; it doesn't deal with the case when the object_id is
|
||||||
|
* split across two chunks. It also doesn't deal with the discrepancy between
|
||||||
|
* object_id and dive number as understood by the dive computer */
|
||||||
|
static void show_progress(char *buf, char *what)
|
||||||
|
{
|
||||||
|
char *val = first_object_id_val(buf);
|
||||||
|
if (val) {
|
||||||
|
/* let the user know what we are working on */
|
||||||
|
uemis_info(_("Reading %s %s"), what, val);
|
||||||
|
free(val);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -415,7 +428,7 @@ static gboolean uemis_get_answer(const char *path, char *request, int n_param_in
|
||||||
#if UEMIS_DEBUG & 8
|
#if UEMIS_DEBUG & 8
|
||||||
tmp[100]='\0';
|
tmp[100]='\0';
|
||||||
fprintf(debugfile, "::t %s \"%s\"\n", ans_path, tmp);
|
fprintf(debugfile, "::t %s \"%s\"\n", ans_path, tmp);
|
||||||
#elif UEMIS_DEBUG & 2
|
#elif UEMIS_DEBUG & 4
|
||||||
char pbuf[4];
|
char pbuf[4];
|
||||||
pbuf[0] = tmp[0];
|
pbuf[0] = tmp[0];
|
||||||
pbuf[1] = tmp[1];
|
pbuf[1] = tmp[1];
|
||||||
|
@ -723,7 +736,7 @@ static char *do_uemis_download(struct argument_block *args)
|
||||||
char *deviceid = NULL;
|
char *deviceid = NULL;
|
||||||
char *result = NULL;
|
char *result = NULL;
|
||||||
char *endptr;
|
char *endptr;
|
||||||
gboolean success, keep_number = FALSE;
|
gboolean success, keep_number = FALSE, once = TRUE;
|
||||||
|
|
||||||
if (dive_table.nr == 0)
|
if (dive_table.nr == 0)
|
||||||
keep_number = TRUE;
|
keep_number = TRUE;
|
||||||
|
@ -761,6 +774,13 @@ static char *do_uemis_download(struct argument_block *args)
|
||||||
/* process the buffer we have assembled */
|
/* process the buffer we have assembled */
|
||||||
if (mbuf)
|
if (mbuf)
|
||||||
process_raw_buffer(deviceidnr, mbuf, &newmax, keep_number);
|
process_raw_buffer(deviceidnr, mbuf, &newmax, keep_number);
|
||||||
|
if (once) {
|
||||||
|
char *t = first_object_id_val(mbuf);
|
||||||
|
if (t && atoi(t) > start)
|
||||||
|
start = atoi(t);
|
||||||
|
free(t);
|
||||||
|
once = FALSE;
|
||||||
|
}
|
||||||
/* if the user clicked cancel, exit gracefully */
|
/* if the user clicked cancel, exit gracefully */
|
||||||
if (import_thread_cancelled)
|
if (import_thread_cancelled)
|
||||||
goto bail;
|
goto bail;
|
||||||
|
@ -786,6 +806,9 @@ static char *do_uemis_download(struct argument_block *args)
|
||||||
for (i = start; i < end; i++) {
|
for (i = start; i < end; i++) {
|
||||||
snprintf(objectid, sizeof(objectid), "%d", i);
|
snprintf(objectid, sizeof(objectid), "%d", i);
|
||||||
param_buff[2] = objectid;
|
param_buff[2] = objectid;
|
||||||
|
#if UEMIS_DEBUG & 2
|
||||||
|
fprintf(debugfile, "getDive %d\n", i);
|
||||||
|
#endif
|
||||||
success = uemis_get_answer(mountpath, "getDive", 3, 0, &result);
|
success = uemis_get_answer(mountpath, "getDive", 3, 0, &result);
|
||||||
if (mbuf)
|
if (mbuf)
|
||||||
process_raw_buffer(deviceidnr, mbuf, &newmax, FALSE);
|
process_raw_buffer(deviceidnr, mbuf, &newmax, FALSE);
|
||||||
|
@ -797,6 +820,9 @@ static char *do_uemis_download(struct argument_block *args)
|
||||||
char divespotnr[10];
|
char divespotnr[10];
|
||||||
snprintf(divespotnr, sizeof(divespotnr), "%d", i);
|
snprintf(divespotnr, sizeof(divespotnr), "%d", i);
|
||||||
param_buff[2] = divespotnr;
|
param_buff[2] = divespotnr;
|
||||||
|
#if UEMIS_DEBUG & 2
|
||||||
|
fprintf(debugfile, "getDivespot %d\n", i);
|
||||||
|
#endif
|
||||||
success = uemis_get_answer(mountpath, "getDivespot", 3, 0, &result);
|
success = uemis_get_answer(mountpath, "getDivespot", 3, 0, &result);
|
||||||
if (mbuf)
|
if (mbuf)
|
||||||
parse_divespot(mbuf);
|
parse_divespot(mbuf);
|
||||||
|
|
Loading…
Add table
Reference in a new issue