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:
parent
20f813d5bc
commit
9297e390a8
@ -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;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user