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.
This commit is contained in:
Jef Driesen 2013-04-29 20:47:26 +02:00
parent 20f813d5bc
commit 9297e390a8

View File

@ -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;