diff options
author | Dirk Hohndel <dirk@hohndel.org> | 2015-12-03 09:47:46 -0800 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2015-12-03 09:47:46 -0800 |
commit | 3499e50d0cb493ddd9fb598c84391741ab4a7332 (patch) | |
tree | f223359be9cc1288cb497a137a989bdd64e30c1f /subsurface-core | |
parent | 75d30b8d700412a26b2e752776c3b3a34ad37693 (diff) | |
download | subsurface-3499e50d0cb493ddd9fb598c84391741ab4a7332.tar.gz |
Uemis downloader: ignore leading junk in the data
One user's debug log shows valid data, only not in the format we've seen
before (with the response starting with '{'). Instead he gets a repeat of
the second word in the response to processSync prepended to the expected
output. So let's skip the data until the first '{'.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'subsurface-core')
-rw-r--r-- | subsurface-core/uemis-downloader.c | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/subsurface-core/uemis-downloader.c b/subsurface-core/uemis-downloader.c index 97ef551aa..8e7f9f60a 100644 --- a/subsurface-core/uemis-downloader.c +++ b/subsurface-core/uemis-downloader.c @@ -1278,27 +1278,30 @@ const char *do_uemis_import(device_data_t *data) param_buff[3] = 0; success = uemis_get_answer(mountpath, "getDivelogs", 3, 0, &result); uemis_mem_status = get_memory(data->download_table, UEMIS_CHECK_DETAILS); - if (success && mbuf && uemis_mem_status != UEMIS_MEM_FULL) { + /* first, remove any leading garbage... this needs to start with a '{' */ + char *realmbuf = mbuf; + if (mbuf) + realmbuf = strchr(mbuf, '{'); + if (success && realmbuf && uemis_mem_status != UEMIS_MEM_FULL) { #if UEMIS_DEBUG & 16 - do_dump_buffer_to_file(mbuf, "Divelogs"); + do_dump_buffer_to_file(realmbuf, "Divelogs"); #endif /* process the buffer we have assembled */ - - if (!process_raw_buffer(data, deviceidnr, mbuf, &newmax, keep_number, NULL)) { + if (!process_raw_buffer(data, deviceidnr, realmbuf, &newmax, keep_number, NULL)) { /* if no dives were downloaded, mark end appropriately */ if (end == -2) end = start - 1; success = false; } if (once) { - char *t = first_object_id_val(mbuf); + char *t = first_object_id_val(realmbuf); if (t && atoi(t) > start) start = atoi(t); free(t); once = false; } /* clean up mbuf */ - endptr = strstr(mbuf, "{{{"); + endptr = strstr(realmbuf, "{{{"); if (endptr) *(endptr + 2) = '\0'; /* last object_id we parsed */ |