How do you clear the Java serial InputStream?

I use JavaComm and get inputStream from the serial port object. My problem is that sometimes, when the system starts up, there are noise characters in the buffer that I don't want. I want to initialize the serial port, and then somehow clear the input of all data before processing starts.

Is there any way to do this?

TY Fred

+3
source share
2 answers

How would the flush () method know what garbage is and what real data? Only you know, and your program should be prepared to ignore the leading garbage.

EDIT: , , , - , .

+5

- , , . , .

+2

Source: https://habr.com/ru/post/1780529/


All Articles