I am implementing VISA communication for an instrument that functions differently from my all of my other instruments. Every second the instruments emits a data packet of 24 bytes of binary data with no stop character. The problem is that in the first read it always reads 6 bytes instead of 24. Then, in every consecutive read, the 24 bytes are offset by 6 bytes. This is without calling VISA clear after every read. If I do that, I get 6 bytes every time. I assume that I will need to clear it after every read or else it will be reading old information and will eventually overflow.
Here is the manual of the instrument. It talks about serial communication on page 26.
Thanks for the help.
Solved! Go to Solution.
I guess something is wrong with the code you have written.
My code is just configure serial port -> visa open -> visa read.
I get the same result by clearing and reading bytes manually in NI MAX.
I'm not going to speculate. It won't do either of us any good.
Did you disable the termination character in your Serial configure?
Since your data appears to be binary, the default termination character of line feed which is enabled by default, could very well be showing up in your data stream at byte 6. The next 24 characters read will give you bytes 7-24 and bytes 1-6 of the following packet.