wrote:
I am receiving 26 bytes. Is it posible to work like that:Read bytes, and when 2 bytes of head appear, read next 24 bytes.
Or is it some better solution for reading like that?
You give a lot better information than most when asking these types of questions.
So one thing to hit first: Since we are dealing with raw/binary/hex data, make sure the Termination Character is turned OFF. It defaults to TRUE with the VISA Configure Serial Port. So just set that input to FALSE.
Now as far as code structure, I have found it best to read 1 byte at a time until you read 0xFF. Then you read another byte and verify it is also 0xFF. If verified, read the rest of your message (24 bytes). Then you can repeat the process from there. I say to read 1 byte at a time instead of 2 because you could be out of sync by that 1 byte and you will therefore never catch the FFFF. Using your example, you could read 89FF and then FFF4. Neither of your two reads would match your FFFF requirement and you miss your entire message. So read 1 byte at a time to find the sync.
Note 1: Notice the FF constants. I have those set to be in Hex display. Right-click on the string constant and choose Visible Items->Display Style. You should see a little 'n' show up as part of the constant. That is showing you are in "Normal" display. You can then click on that 'n' and choose Hex Display.
Note 2: All FALSE cases just pass the VISA Reference and error straight through.