Tweaks to the Uemis debugging code

Make it less verbose to make it easier to follow the progress along.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Dirk Hohndel 2012-11-19 14:08:14 -08:00
parent fb60143d35
commit a32f3857cb
2 changed files with 21 additions and 10 deletions

View file

@ -1680,12 +1680,12 @@ static GError *setup_uemis_import(device_data_t *data)
error = uemis_download(data->devname, &uemis_max_dive_data, &buf, &data->progress, data->force_download); error = uemis_download(data->devname, &uemis_max_dive_data, &buf, &data->progress, data->force_download);
if (buf && strlen(buf) > 1) { if (buf && strlen(buf) > 1) {
#ifdef DEBUGFILE #if UEMIS_DEBUG > 3
fprintf(debugfile, "xml buffer \"%s\"\n\n", buf); fprintf(debugfile, "xml buffer \"%s\"\n\n", buf);
#endif #endif
parse_xml_buffer("Uemis Download", buf, strlen(buf), &error); parse_xml_buffer("Uemis Download", buf, strlen(buf), &error);
set_uemis_last_dive(uemis_max_dive_data); set_uemis_last_dive(uemis_max_dive_data);
#if UEMIS_DEBUG #if UEMIS_DEBUG > 2
fprintf(debugfile, "uemis_max_dive_data: %s\n", uemis_max_dive_data); fprintf(debugfile, "uemis_max_dive_data: %s\n", uemis_max_dive_data);
#endif #endif
mark_divelist_changed(TRUE); mark_divelist_changed(TRUE);

View file

@ -109,19 +109,23 @@ static gboolean uemis_init(const char *path)
/* let's check if this is indeed a Uemis DC */ /* let's check if this is indeed a Uemis DC */
reqtxt_path = g_build_filename(path, "/req.txt", NULL); reqtxt_path = g_build_filename(path, "/req.txt", NULL);
reqtxt_file = g_open(reqtxt_path, O_RDONLY, 0666); reqtxt_file = g_open(reqtxt_path, O_RDONLY, 0666);
if (!reqtxt_file) if (!reqtxt_file) {
#if UEMIS_DEBUG
fprintf(debugfile, ":EE req.txt can't be opened\n");
#endif
return FALSE; return FALSE;
}
if (bytes_available(reqtxt_file) > 5) { if (bytes_available(reqtxt_file) > 5) {
char tmp[6]; char tmp[6];
read(reqtxt_file, tmp, 5); read(reqtxt_file, tmp, 5);
tmp[5] = '\0'; tmp[5] = '\0';
#if UEMIS_DEBUG > 2 #if UEMIS_DEBUG > 1
fprintf(debugfile, "::r req.txt \"%s\"\n", tmp); fprintf(debugfile, "::r req.txt \"%s\"\n", tmp);
#endif #endif
if (sscanf(tmp + 1, "%d", &filenr) != 1) if (sscanf(tmp + 1, "%d", &filenr) != 1)
return FALSE; return FALSE;
} }
#if UEMIS_DEBUG > 2 #if UEMIS_DEBUG > 1
else { else {
fprintf(debugfile, "::r req.txt skipped as there were fewer than 5 bytes\n"); fprintf(debugfile, "::r req.txt skipped as there were fewer than 5 bytes\n");
} }
@ -166,7 +170,7 @@ static void trigger_response(int file, char *command, int nr, long tailpos)
snprintf(fl, 8, "%s%04d", command, nr); snprintf(fl, 8, "%s%04d", command, nr);
#if UEMIS_DEBUG > 2 #if UEMIS_DEBUG > 2
fprintf(debugfile,"::: %s (after seeks)\n", fl); fprintf(debugfile,":tr %s (after seeks)\n", fl);
#endif #endif
lseek(file, 0, SEEK_SET); lseek(file, 0, SEEK_SET);
write(file, fl, strlen(fl)); write(file, fl, strlen(fl));
@ -503,6 +507,13 @@ static gboolean uemis_get_answer(const char *path, char *request, int n_param_in
#if UEMIS_DEBUG > 3 #if UEMIS_DEBUG > 3
tmp[100]='\0'; tmp[100]='\0';
fprintf(debugfile, "::t %s \"%s\"\n", ans_path, tmp); fprintf(debugfile, "::t %s \"%s\"\n", ans_path, tmp);
#elsif UEMIS_DEBUG > 1
char pbuf[4];
pbuf[0] = tmp[0];
pbuf[1] = tmp[1];
pbuf[2] = tmp[2];
pbuf[3] = 0;
fprintf(debugfile, "::t %s \"%s...\"\n", ans_path, pbuf);
#endif #endif
g_free(ans_path); g_free(ans_path);
if (tmp[0] == '1') { if (tmp[0] == '1') {
@ -567,7 +578,7 @@ static gboolean uemis_get_answer(const char *path, char *request, int n_param_in
lseek(ans_file, 3, SEEK_CUR); lseek(ans_file, 3, SEEK_CUR);
read(ans_file, buf, size - 3); read(ans_file, buf, size - 3);
buf[size - 3] = '\0'; buf[size - 3] = '\0';
#if UEMIS_DEBUG > 2 #if UEMIS_DEBUG > 3
fprintf(debugfile, "::r %s \"%s\"\n", ans_path, buf); fprintf(debugfile, "::r %s \"%s\"\n", ans_path, buf);
#endif #endif
} }
@ -577,7 +588,7 @@ static gboolean uemis_get_answer(const char *path, char *request, int n_param_in
} else { } else {
ismulti = FALSE; ismulti = FALSE;
} }
#if UEMIS_DEBUG > 1 #if UEMIS_DEBUG > 3
fprintf(debugfile,":r: %s\n", buf); fprintf(debugfile,":r: %s\n", buf);
#endif #endif
if (!answer_in_mbuf) if (!answer_in_mbuf)
@ -688,7 +699,7 @@ static char *process_raw_buffer(char *inbuf, char **max_divenr)
buffer_add(&conv_buffer, &conv_buffer_size, "</dive>\n"); buffer_add(&conv_buffer, &conv_buffer_size, "</dive>\n");
} }
free(buf); free(buf);
#if UEMIS_DEBUG > 2 #if UEMIS_DEBUG > 3
fprintf(debugfile,"converted to \"%s\"\n", conv_buffer); fprintf(debugfile,"converted to \"%s\"\n", conv_buffer);
#endif #endif
return strdup(conv_buffer); return strdup(conv_buffer);
@ -833,7 +844,7 @@ static char *do_uemis_download(struct argument_block *args)
*args->max_dive_data = update_max_dive_data(*max_dive_data, deviceid, newmax); *args->max_dive_data = update_max_dive_data(*max_dive_data, deviceid, newmax);
if (sscanf(newmax, "%d", &end) != 1) if (sscanf(newmax, "%d", &end) != 1)
end = start; end = start;
#if UEMIS_DEBUG > 2 #if UEMIS_DEBUG > 1
fprintf(debugfile, "done: read from object_id %d to %d\n", start, end); fprintf(debugfile, "done: read from object_id %d to %d\n", start, end);
#endif #endif
free(newmax); free(newmax);