From 0790dfdad54a0173a557ddefdd6db4f14a0c5368 Mon Sep 17 00:00:00 2001 From: glerch Date: Mon, 7 Sep 2015 20:51:49 +0200 Subject: Uemis downloader: original dive number support - enabled capturing of the original Uemis dive number - previousely the object_id was passed to dive as dive number - I am using a workaround (not nice but effective) by parsing the dive_no out of a copy of inbuf before the object_id is parsed. The reason why is that the dive_no comes before the object_id hence the normal parsing would miss it. Signed-off-by: glerch Signed-off-by: Dirk Hohndel --- uemis-downloader.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/uemis-downloader.c b/uemis-downloader.c index 325b3f2ab..1c639aa67 100644 --- a/uemis-downloader.c +++ b/uemis-downloader.c @@ -792,6 +792,7 @@ static bool process_raw_buffer(device_data_t *devdata, uint32_t deviceid, char * char *sections[10]; int s, nr_sections = 0; struct dive *dive = NULL; + char dive_no[10]; #if UEMIS_DEBUG & 4 fprintf(debugfile, "p_r_b %s\n", inbuf); @@ -835,6 +836,18 @@ static bool process_raw_buffer(device_data_t *devdata, uint32_t deviceid, char * free(buf); return false; } + /* quickhack and workaround to capture the original dive_no + * i am doing this so I dont have to change the original design + * but when parsing a dive we never parse the dive number because + * at the time it's being read the *dive varible is not set because + * the dive_no tag comes before the object_id in the uemis ans file + */ + char *dive_no_buf = strdup(inbuf); + char *dive_no_ptr = strstr(dive_no_buf, "dive_no{int{") + 12; + char *dive_no_end = strstr(dive_no_ptr, "{"); + *dive_no_end = 0; + strcpy(dive_no, dive_no_ptr); + free(dive_no_buf); } while (!done) { /* the valid buffer ends with a series of delimiters */ @@ -873,14 +886,11 @@ static bool process_raw_buffer(device_data_t *devdata, uint32_t deviceid, char * #if UEMIS_DEBUG % 2 fprintf(debugfile, "Adding new dive from log with object_id %d.\n", atoi(val)); #endif - /* glerch Sep. 2015 - * maybe I am missing something here but this seems wrong - if (keep_number) - dive->number = atoi(val); - */ } else if (is_dive && strcmp(tag, "logfilenr") == 0) { /* this one tells us which dive we are adding data to */ dive = get_dive_by_uemis_diveid(devdata, atoi(val)); + if (strcmp(dive_no, "0")) + dive->number = atoi(dive_no); if (for_dive) *for_dive = atoi(val); } else if (!is_log && dive && !strcmp(tag, "divespot_id")) { -- cgit v1.2.3-70-g09d2