From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How do I parse binary string

Solved!
Go to solution

Hi folks,

 

I am reading a binary string from a campbell sonic anemometer. It is transmitted via RS 232 9600 baud. The problem is as follows:

I am reading the input buffer once in a while(every 300 ms). The outpit of the sonic is much faster(every 30ms). Then there are a certain amount of bytes stored which I read. To get a proper value I have to find 2 termination bytes HEX AA and  HEX 55. A complete sentence consists of 12 bytes 10 bytes each U8 values and 2 bytes termination. How do I search for them?

 

My idea was to see how much bytes I read, convert each to a binary array and then show them as boolean array all together(see attached VI). this works but I can't find the right binary expression for Hex AA and 55. And it is also interersting that the first collumn(bit 0) and the last one (bit 7) always stay "false". Am I doing something wrong?

Download All
0 Kudos
Message 1 of 4
(2,831 Views)
Solution
Accepted by topic author azavarsky

So it would have been more useful if you would have posted example data that was read.  Since I didn't have any I made some up.  The attached VI will search for locations where the hex byte AA then 55 are found.  It then breaks up the sections of data using this information.  I wrote it two ways because as I was typing this I thought of a better way that uses string functions to break up the data into an array of data.

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

Thanks,

I added my data to your little program, attached. It seems to work. Attached is also a pic with sample data viewed in a terminal program. I will try it now with my serial routine.

 

Alex

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

Attached is my solution.

Thanks a lot.

any suggestions and improvements are very welcome.

 

ALex

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