LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Syncronizing com port data

Hi,
 
I have a device that sends a 47 byte packet of data every three seconds at 1200 baud.  I want to capture the data in the serial port and display the values etc. The hex data looks like this:
 
5990 A6A2 D0E8 CFE4 BADA 99FB BFC8 9998 B6B2 0D0A 4730 4532 3244 4430 3032 3389 0D0A 4102 D8BF DCBF A4C0 E4BF 920D 0A
 
This is the data in the correct order from the buffer.  If the tool loses power or something interrupts the data stream, the buffer could be "stuck with a random few characters in it.  The next data packet will make a buffer of greater than 47 bytes.  My VI will read 47 bytes and the data will no longer be in the proper order for me to parse. 
 
How can I syncronize this data from the serial port?  OR, how can I see if the device is currently sending or not without flow control?  Any Ideas.  I understand that if I could use flow control then it would be easy.  Is there another way?
 
My sending device is fixed at 1200, N, 8, 1 and I cannot change it.   My headers are in Red.
 
Thanks for any help / Examples.
0 Kudos
Message 1 of 4
(2,917 Views)

Easy.. If you don't receive a new byte for one sec, read the buffer, so it will empty.

The next bytes will be in order...

Meaning: you will not use standard bytes to read, you will use a timeout.

0 Kudos
Message 2 of 4
(2,915 Views)

Thanks, I'll try that and let you know how it turns out.

 

 

0 Kudos
Message 3 of 4
(2,878 Views)

That worked.  I threw in another flush just after the read because the serial read needs the byte count.  So, I just read 47 bytes, dump the rest, and wait for another 47.  This helps keep it in sync even when the timing gets out of sync.

 

Thanks

0 Kudos
Message 4 of 4
(2,784 Views)