summaryrefslogtreecommitdiffstats
path: root/uemis-downloader.c
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2015-12-03 09:47:46 -0800
committerGravatar Dirk Hohndel <dirk@hohndel.org>2015-12-06 09:36:36 -0800
commit27ea07992836076ebb0718e29ee01f5a9e418bfa (patch)
treedd5ba1a8f05d530326557e3a4d9bb4101d6a5dc7 /uemis-downloader.c
parent3029bc872cafdbefd51f007690ad87727184f722 (diff)
downloadsubsurface-27ea07992836076ebb0718e29ee01f5a9e418bfa.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 'uemis-downloader.c')
-rw-r--r--uemis-downloader.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/uemis-downloader.c b/uemis-downloader.c
index 0abc28cf9..a9c462db1 100644
--- a/uemis-downloader.c
+++ b/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 */