From 9297e390a8999897335ec7dea090262059936a28 Mon Sep 17 00:00:00 2001 From: Jef Driesen Date: Mon, 29 Apr 2013 20:47:26 +0200 Subject: [PATCH] Flush the serial buffers after opening the port. Sometimes there are garbage bytes present after opening the serial port, which causes the communication to fail. Flushing the buffers after a small delay is all it takes to get rid of those bytes. --- src/cressi_leonardo.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/cressi_leonardo.c b/src/cressi_leonardo.c index f75d4bb..4411254 100644 --- a/src/cressi_leonardo.c +++ b/src/cressi_leonardo.c @@ -131,6 +131,9 @@ cressi_leonardo_device_open (dc_device_t **out, dc_context_t *context, const cha return DC_STATUS_IO; } + serial_sleep (device->port, 100); + serial_flush (device->port, SERIAL_QUEUE_BOTH); + *out = (dc_device_t *) device; return DC_STATUS_SUCCESS;