From 27ea07992836076ebb0718e29ee01f5a9e418bfa Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Thu, 3 Dec 2015 09:47:46 -0800 Subject: 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 --- uemis-downloader.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'uemis-downloader.c') 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 */ -- cgit v1.2.3-70-g09d2