From Friday, January 17th 11 PM CDT (January 18th 5 AM UTC) through Saturday, January 18th 11:30 AM CDT (January 18th 5:30 PM UTC), ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

Keeping Serial Data when flushing buffer

Hi,

I am reading data from the serial port. The data are comming from 3 channels and arrive in this way:

[00][B](channel1)-[FF][01](channel2)-[11][F7](channel3)-[00][44](channel1)-[FF][33](channel2)-...

I've done a while loop to read these data. In the loop, I read each channel one by one (1st read=2bytes, 2nd read=2bytes and 3rd read=2bytes) before flushing the buffer and doing the loop. The baud rate=4800 and the Sample rate=240Sample/s. The problem is when I do my loop I lost data in a way that when the loop restart I don't know wich channel I am reading with the first read.

How can I solve this problem?

Thank you

Francois

0 Kudos
Message 1 of 4
(3,373 Views)
Francois,

the main idea is to flush just at the beginning and afterwards to use a kind of circular buffer to append new data and remove complete data sets. To detect a dataset you can use the match_pattern node with a  regular expression of "\00.\FF.\11.". If match_pattern did match, change the match to an array of bytes and use the bytes at 1, 3 and 5 as your data.
I have prepared an example on how to do this

Greetings from Germany!
--
Uwe
Greetings from Germany!
--
Uwe


0 Kudos
Message 2 of 4
(3,362 Views)
Thank you Uwe,

I can't open the VI  with my LabVIEW version (7.0), Can you give me the screen shot of the block diagram??

Thank you again

François



0 Kudos
Message 3 of 4
(3,350 Views)
François,
I saved it to 7.0 for you. Enjoy!
Missy S.
Project Engineer
RoviSys
0 Kudos
Message 4 of 4
(3,339 Views)