Fazecast / jSerialComm

Platform-independent serial port access for Java
GNU Lesser General Public License v3.0
1.34k stars 287 forks source link

Need the command to empty (purge) Rx/Tx buffers for a clean re-start #378

Closed wenzhongliu closed 2 years ago

NathanSweet commented 2 years ago

I also just encountered this need.

hedgecrw commented 2 years ago

This has been implemented by providing the following new method: flushIOBuffers(). You can call this method on your serial port object before opening the port, in which case the buffers will be flushed as soon as the port is opened, or you can call it at any time after the port is opened to immediately flush the buffers.

Please test the following beta version of the library and see if it fits your needs:

https://drive.google.com/file/d/1QzWPJg5MU_2YrnsB1MsOWeTbjYD84D2h/view?usp=sharing

NathanSweet commented 2 years ago

Thanks! I gave it a try but I still had my issue, eventually I found it was elsewhere (one byte too few) and unrelated to buffers. Sorry for the trouble.

Having suffered other libraries, your library is really great! Cheers!

hedgecrw commented 2 years ago

Solved with new method flushIOBuffers() in release of jSerialComm v2.8.0.