From edd777dbd3080490dcd0797843f4f001a9d57a50 Mon Sep 17 00:00:00 2001 From: Jef Driesen Date: Thu, 19 Mar 2015 20:17:31 +0100 Subject: [PATCH] Wait after changing the serial line settings. Without the delay, the communication immediately fails. We receive the command echo, but not the actual data packet. I suspect the device is still be busy with the initialization and needs a bit more time before it's ready to accept a request. --- src/cressi_edy.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/cressi_edy.c b/src/cressi_edy.c index d9bf813..5a51090 100644 --- a/src/cressi_edy.c +++ b/src/cressi_edy.c @@ -239,6 +239,10 @@ cressi_edy_device_open (dc_device_t **out, dc_context_t *context, const char *na return DC_STATUS_IO; } + // Make sure everything is in a sane state. + serial_sleep(device->port, 300); + serial_flush(device->port, SERIAL_QUEUE_BOTH); + // Send the init commands. cressi_edy_init1 (device); cressi_edy_init2 (device); @@ -253,6 +257,10 @@ cressi_edy_device_open (dc_device_t **out, dc_context_t *context, const char *na return DC_STATUS_IO; } + // Make sure everything is in a sane state. + serial_sleep(device->port, 300); + serial_flush(device->port, SERIAL_QUEUE_BOTH); + *out = (dc_device_t*) device; return DC_STATUS_SUCCESS;