From 1d8f25ba9b73e094286df4b098ab5859cf61e881 Mon Sep 17 00:00:00 2001 From: John Van Ostrand Date: Sat, 15 Jul 2017 16:39:38 -0400 Subject: [PATCH] Dump function no longer assumes reads begin at byte 0 For previously supported Cochran computers high-speed read of log and profile data started at byte 0. Older models that lack the high-speed transfer function use the standard speed read commands and so the log and profile data are read at higher addresses. --- src/cochran_commander.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/cochran_commander.c b/src/cochran_commander.c index c782fb9..7728b4f 100644 --- a/src/cochran_commander.c +++ b/src/cochran_commander.c @@ -728,6 +728,7 @@ cochran_commander_device_dump (dc_device_t *abstract, dc_buffer_t *buffer) cochran_commander_device_t *device = (cochran_commander_device_t *) abstract; dc_status_t rc = DC_STATUS_SUCCESS; unsigned char config[1024]; + unsigned int size = device->layout->rb_profile_end - device->layout->rb_logbook_begin; // Make sure buffer is good. if (!dc_buffer_clear(buffer)) { @@ -736,14 +737,14 @@ cochran_commander_device_dump (dc_device_t *abstract, dc_buffer_t *buffer) } // Reserve space - if (!dc_buffer_resize(buffer, device->layout->rb_profile_end)) { + if (!dc_buffer_resize(buffer, size)) { ERROR(abstract->context, "Insufficient buffer space available."); return DC_STATUS_NOMEMORY; } // Determine size for progress dc_event_progress_t progress = EVENT_PROGRESS_INITIALIZER; - progress.maximum = sizeof(config) + device->layout->rb_profile_end; + progress.maximum = sizeof(config) + size; device_event_emit (abstract, DC_EVENT_PROGRESS, &progress); // Emit ID block @@ -757,7 +758,7 @@ cochran_commander_device_dump (dc_device_t *abstract, dc_buffer_t *buffer) return rc; // Read the sample data, from 0 to sample end will include logbook - rc = cochran_commander_read (device, &progress, 0, dc_buffer_get_data(buffer), device->layout->rb_profile_end); + rc = cochran_commander_read (device, &progress, device->layout->rb_logbook_begin, dc_buffer_get_data(buffer), device->layout->rb_profile_end); if (rc != DC_STATUS_SUCCESS) { ERROR (abstract->context, "Failed to read the sample data."); return rc;