From c72bdfe4e4175cb7ad2eb3dc4caa0e9fd9c12962 Mon Sep 17 00:00:00 2001 From: Jef Driesen Date: Mon, 7 Sep 2015 22:51:44 +0200 Subject: [PATCH] Add support for logging I/O operations. The Atomics Cobalt backend uses libusb directly, without going through an internal I/O layer that support logging. Therefore the logging needs to be done in the backend itself. --- src/atomics_cobalt.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/atomics_cobalt.c b/src/atomics_cobalt.c index 1ee9018..88febec 100644 --- a/src/atomics_cobalt.c +++ b/src/atomics_cobalt.c @@ -215,6 +215,8 @@ atomics_cobalt_device_version (dc_device_t *abstract, unsigned char data[], unsi return EXITCODE(rc); } + HEXDUMP (abstract->context, DC_LOGLEVEL_INFO, "Write", &bRequest, 1); + // Receive the answer from the dive computer. int length = 0; unsigned char packet[SZ_VERSION + 2] = {0}; @@ -225,6 +227,8 @@ atomics_cobalt_device_version (dc_device_t *abstract, unsigned char data[], unsi return EXITCODE(rc); } + HEXDUMP (abstract->context, DC_LOGLEVEL_INFO, "Read", packet, length); + // Verify the checksum of the packet. unsigned short crc = array_uint16_le (packet + SZ_VERSION); unsigned short ccrc = checksum_add_uint16 (packet, SZ_VERSION, 0x0); @@ -271,6 +275,8 @@ atomics_cobalt_read_dive (dc_device_t *abstract, dc_buffer_t *buffer, int init, return EXITCODE(rc); } + HEXDUMP (abstract->context, DC_LOGLEVEL_INFO, "Write", &bRequest, 1); + unsigned int nbytes = 0; while (1) { // Receive the answer from the dive computer. @@ -283,6 +289,8 @@ atomics_cobalt_read_dive (dc_device_t *abstract, dc_buffer_t *buffer, int init, return EXITCODE(rc); } + HEXDUMP (abstract->context, DC_LOGLEVEL_INFO, "Read", packet, length); + // Update and emit a progress event. if (progress) { progress->current += length;