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.
This commit is contained in:
Jef Driesen 2015-09-07 22:51:44 +02:00
parent 55afe711f7
commit c72bdfe4e4

View File

@ -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;