ROBOTIS-GIT / OpenCR

Software for ROS Embedded board (a.k.a. OpenCR). OpenCR means Open-source Control Module for ROS.
Apache License 2.0
386 stars 238 forks source link

Serial.flush - is not implemented #92

Closed KurtE closed 6 years ago

KurtE commented 6 years ago

Currently the USB Serial.flush() is an empty function.

Would be nice if it would force any outstanding write requests to be output, like it does on Hardware Serial ports.

I know it is implemented on a few different platforms, like Teensy and I believe at least some of the AVR platforms.

I personally use it for at least two reasons: a) Debug: What I was doing now... If I have code that might Crash/Hang - I might do something like:

Serial.println("Before Foo");Serial.flush()
(something that may crash) 
Serial.println("After Foo"); Serial.flush();

b) To reduce latency. Example if the board is used to listen to requests from a host board, who is waiting for our reply, You may want to call flush right after generating the reply, to shorten the time for the host to get the reply (I do that on my Servo controller boards...)

I don't yet know enough of the USB code here on how to emulate a timeout...

OpusK commented 6 years ago

Implemented by e2915f5