[PATCH 3/6] Cochran: Dump function no longer assumes reads begin at byte 0

John Van Ostrand john at vanostrand.com
Sat Jul 15 13:39:38 PDT 2017


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 bc10fc9..6b168ed 100644
--- a/src/cochran_commander.c
+++ b/src/cochran_commander.c
@@ -754,6 +754,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)) {
@@ -762,14 +763,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
@@ -783,7 +784,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;
-- 
2.4.11



More information about the devel mailing list