Joke Collection Website - Public benefit messages - Using LabVIEW serial port to read data

Using LabVIEW serial port to read data

This is mainly because the string you read has a terminator (for example, some communication protocols use 0x0D (carriage return) as the terminator). Suppose there is an ending character, then after you read a string with a corresponding length in the receiving buffer, it will stay in the buffer because the ending character is not considered, and the first character of your next string will move to the next line (carriage return can wrap at the same time), so that you can read the first character of the last time and the rest of the characters except the first character this time. It will produce the phenomenon you said.

solution

Add an operation to clear the buffer after each read.

If you read 12 characters at a time and the ending character is one character, then read one more character at a time, that is, read 13 characters.

In short, just make sure that the receive buffer is empty every time you read it.