On 15 December, 2014 - Jef Driesen wrote:
On 21-11-14 21:28, Anton Lundin wrote:
diff --git a/src/hw_ostc3.c b/src/hw_ostc3.c index 7fa38f8..4d6bf83 100644 --- a/src/hw_ostc3.c +++ b/src/hw_ostc3.c @@ -50,6 +50,7 @@ #define RB_LOGBOOK_SIZE 256 #define RB_LOGBOOK_COUNT 256
+#define S_READY 0x4C #define READY 0x4D #define HEADER 0x61 #define CLOCK 0x62 @@ -71,6 +72,7 @@ typedef struct hw_ostc3_device_t { NONE, OPEN, DOWNLOAD,
} state;SERVICE,
} hw_ostc3_device_t;
@@ -196,7 +198,7 @@ hw_ostc3_transfer (hw_ostc3_device_t *device, }
// Verify the ready byte.
if (ready[0] != READY) {
}if (!(ready[0] == READY || ready[0] == S_READY)) { ERROR (abstract->context, "Unexpected ready byte."); return DC_STATUS_PROTOCOL;
I assume in service mode, S_READY is returned instead of READY? If that's correct, then I think it's better to accept only the correct one. Something like this:
unsigned char expected = (device->state == SERVICE ? S_READY : READY); if (ready[0] != expected) { ... }
You guessed correctly. This was a artifact from the previous code where the device state was unknown to the hw_ostc3_transfer() function.
Fixed.
//Anton