Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

Synchronizing data with visa read

Hello guys.

Sorry for the silly question.

I'm receiving, through my serial port, the following bit package: 0x80, 0x80, 0x00, 0x40. I receve this constant package every 1 second, with a baud rate of 115200.

The block diagram print screen is at the bottom of this post.

I just need to check out the package to verify that the first two bytes start with 1 and the last two with 0. When this condition is true, I want to turn on a led.

Problem is: the visa read/shift registers are receiving the data in a messed up way. It is randomly out of order. 

For example, sometimes the shift registers receive 0x00, 0x40, 0x80, 0x80, then another random combination.

How can I make the read data synchronized with the order of the package i'm receiving?

Thank you in advance 🙂

 

 

0 Kudos
Message 1 of 2
(4,226 Views)
You have some misconceptions about serial communication. The receiver is completely asynchronous with the transmitter. The read will start at some random point and that has nothing to do with VISA or LabVIEW. Instead of reading one byte at a time, read 4 and search the returned array (string to byte array) for your start byte. Use the index found to adjust another read with a calculated byte count. After that, you should be able to continuously read 4 bytes at a time and know that the start byte is first.
Message 2 of 2
(4,221 Views)