Closed josephbriguet01 closed 3 years ago
The user in that issue had this code:
int numRead = userPort.readBytes(readBuffer, readBuffer.length);
for (int i = 0; i < readBuffer.length; i++) {
readBytes returns the number of bytes that were actually read from the port, which micht be smaller than the buffer. But the user iterates over the entire buffer anyways. Maybe you do something similar? If your buffer is 64 bytes but readBytes only reads 1 byte, only the first byte of the buffer will be valid.
I think in the original issue, there was a problem with the way the user was sending serial data (not using jSerialComm that I can tell). They were essentially adding contents to a send buffer before transmission, but never clearing that buffer or overwriting contents...just appending new data. I suspect anyone that has this problem is doing something similar, since there are no persistent buffers used in jSerialComm. Closing this issue again as it's not a jSerialComm bug, but rather a Java (or other language) coding bug.
Good evening,
I am writing this post with reference to issue #255 which is now closed. Unfortunately, the solution was not given. The person who opened this issue found a solution. But did not share it. Suddenly it seems important to me to reopen the issue. How do you empty the input buffer? I receive messages well. However, when I receive the following messages, they are identical to the very first one.