diff --git a/src/mares_common.c b/src/mares_common.c index 51e0722..94e71b7 100644 --- a/src/mares_common.c +++ b/src/mares_common.c @@ -152,7 +152,6 @@ mares_common_packet (mares_common_device_t *device, const unsigned char command[ // Verify the echo. if (memcmp (echo, command, csize) != 0) { WARNING ("Unexpected echo."); - return DEVICE_STATUS_PROTOCOL; } } @@ -196,6 +195,9 @@ mares_common_transfer (mares_common_device_t *device, const unsigned char comman // Abort if the maximum number of retries is reached. if (nretries++ >= MAXRETRIES) return rc; + + // Discard any garbage bytes. + serial_flush (device->port, SERIAL_QUEUE_INPUT); } return rc; diff --git a/src/mares_darwin.c b/src/mares_darwin.c index ab1766d..e41f99a 100644 --- a/src/mares_darwin.c +++ b/src/mares_darwin.c @@ -158,6 +158,7 @@ mares_darwin_device_open (device_t **out, const char* name, unsigned int model) } // Make sure everything is in a sane state. + serial_sleep (100); serial_flush (device->base.port, SERIAL_QUEUE_BOTH); // Override the base class values.