I'm using JavaComm, and getting the inputStream from the serial port object. I have a problem in that sometimes when the system starts up there are noise characters in the buffer that I do not want. I want to initialize the serial port then somehow flush the input of all data before I begin my processing.
Is there any way to do that?
TY Fred
How would a "flush()" method know what is garbage and what is real data? Only you know, and your program should be prepared to ignore leading garbage.
EDIT: If you can be absolutely certain that all data in the input buffer prior to sending the request is garbage, then just read until there is no more input data -- i.e. flush it yourself.
Before sending any requests to your device read all that you can. Once there's nothing left to read you can start sending requests.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With