From cbe03fd88d8c065d12a1825eef7119252037c150 Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Mon, 29 May 2017 20:56:42 -0700 Subject: FTDI support: add minimal debugging output Copied the libdivecomputer macros for convenience. Signed-off-by: Dirk Hohndel --- core/libdivecomputer.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'core/libdivecomputer.c') diff --git a/core/libdivecomputer.c b/core/libdivecomputer.c index db4a7a434..d6492d162 100644 --- a/core/libdivecomputer.c +++ b/core/libdivecomputer.c @@ -38,6 +38,16 @@ static int stoptime, stopdepth, ndl, po2, cns; static bool in_deco, first_temp_is_air; static int current_gas_index; +/* logging bits from libdivecomputer */ +#ifndef __ANDROID__ +#define INFO(context, fmt, ...) fprintf(stderr, "INFO: " fmt "\n", ##__VA_ARGS__) +#define ERROR(context, fmt, ...) fprintf(stderr, "ERROR: " fmt "\n", ##__VA_ARGS__) +#else +#include +#define INFO(context, fmt, ...) __android_log_print(ANDROID_LOG_DEBUG, __FILE__, "INFO: " fmt "\n", ##__VA_ARGS__) +#define ERROR(context, fmt, ...) __android_log_print(ANDROID_LOG_DEBUG, __FILE__, "ERROR: " fmt "\n", ##__VA_ARGS__) +#endif + /* * Directly taken from libdivecomputer's examples/common.c to improve * the error messages resulting from libdc's return codes @@ -1076,6 +1086,9 @@ const char *do_libdivecomputer_import(device_data_t *data) #ifdef SERIAL_FTDI } else if (!strcmp(data->devname, "ftdi")) { rc = dc_context_set_custom_serial(data->context, &serial_ftdi_ops); + INFO(0, "setting up ftdi ops"); +#else + INFO(0, "FTDI disabled"); #endif } @@ -1086,7 +1099,7 @@ const char *do_libdivecomputer_import(device_data_t *data) { #endif rc = dc_device_open(&data->device, data->context, data->descriptor, data->devname); - + INFO(0, "dc_deveice_open error value of %d", rc); if (rc != DC_STATUS_SUCCESS && subsurface_access(data->devname, R_OK | W_OK) != 0) err = translate("gettextFromC", "Insufficient privileges to open the device %s %s (%s)"); } -- cgit v1.2.3-70-g09d2