Added a more strict check on the ACK/NAK response.
This commit is contained in:
parent
cd20f8a02d
commit
e4ab71db47
@ -361,7 +361,7 @@ uwatec_memomouse_read (memomouse *device, unsigned char data[], unsigned int siz
|
|||||||
// Keep send the command to the device,
|
// Keep send the command to the device,
|
||||||
// until the ACK answer is received.
|
// until the ACK answer is received.
|
||||||
unsigned char answer = NAK;
|
unsigned char answer = NAK;
|
||||||
while (answer != ACK) {
|
while (answer == NAK) {
|
||||||
// Flush the input buffer.
|
// Flush the input buffer.
|
||||||
serial_flush (device->port, SERIAL_QUEUE_INPUT);
|
serial_flush (device->port, SERIAL_QUEUE_INPUT);
|
||||||
|
|
||||||
@ -380,6 +380,17 @@ uwatec_memomouse_read (memomouse *device, unsigned char data[], unsigned int siz
|
|||||||
WARNING ("Failed to recieve the answer.");
|
WARNING ("Failed to recieve the answer.");
|
||||||
return EXITCODE (rc);
|
return EXITCODE (rc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef NDEBUG
|
||||||
|
if (answer != ACK)
|
||||||
|
message ("Received unexpected response (%02x).\n", answer);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
// Verify the answer.
|
||||||
|
if (answer != ACK) {
|
||||||
|
WARNING ("Unexpected answer start byte(s).");
|
||||||
|
return UWATEC_ERROR_PROTOCOL;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Wait for the transfer and read the data.
|
// Wait for the transfer and read the data.
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user