I use AsyncStream in prefix mode. Everything is OK, but if I open serial port and it's input buffer already contains some data I naturally got application crash with diagnostic like:
"java.lang.NegativeArraySizeException" or similar.
So, I have to reopen port once again to establish connection.
Two questions arise:
1. Is there a way to clear port buffer inside the program before opening connection?
I do not think so.
I could clear it via opening e.g. some terminal emulator, but it is external effort.
2. Is there a way to prevent application crash and handle the error inside the program?
Thanks in advance.
"java.lang.NegativeArraySizeException" or similar.
So, I have to reopen port once again to establish connection.
Two questions arise:
1. Is there a way to clear port buffer inside the program before opening connection?
I do not think so.
I could clear it via opening e.g. some terminal emulator, but it is external effort.
2. Is there a way to prevent application crash and handle the error inside the program?
Thanks in advance.
Last edited: