LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Parse Serial Data

I am communicating with an instrument that takes a query and puts out a status packet. I have to parse the data and get information about the instrument status. The status packet is a multi byte data with MSB first and all bytes are 8 bit.

 

I get a string output with that says something like this..."CC\B0\CC\B0\CC\D0\CC\D0\CC\B0\CC\D0\00\...". I have not posted the entire string. But I need to parse thsi string and get meaningful values out of it.

 

I read some of the previous posts which suggest using the Type Cast function. But I am not sure how it works and how to use it. Also tried using the String to Byte Array function but do not know how to use the array to obatin values that correspond to a voltage.

 

Thanks.

0 Kudos
Message 1 of 6
(3,395 Views)
You need to have some information on what the data represents before you can use the Type Cast function properly. What does the documentation on the instrument say?
0 Kudos
Message 2 of 6
(3,384 Views)

 I have attached a word document that exhows the information provided by the manufacturer.

 

There are total 149 bytes in the status packet. The doucment shows just a few of them to provide an example.

 

Please provide any suggestions on how to use the type cast function to obtain the voltage values from the string that I read from the serial port.

 

Thanks.

0 Kudos
Message 3 of 6
(3,349 Views)

Try this.

 

I don't understand the meaning of -4 to -2 and -1.  I'll assume that once you get your string of serial data, you are able to parse the string to extract the bytes that relate to a long list of voltages.

 

Once you have your bytes that represent voltages (where every two bytes are used for a 16 bit number and math done to convert to a voltage, this piece of code will yield an array of those voltages.

 

Message Edited by Ravens Fan on 01-25-2010 10:04 PM
0 Kudos
Message 4 of 6
(3,343 Views)

LabVIEW uses Big Endian format for its binary numbers, while most Windows programs use Little Endian format. LabVIEW uses Big Endian, because that is what the MacOS uses, and LabVIEW was created first for the Macintosh. So must test and see what is correct.  In my example I have assumed that the datatype is I16, but it could also be U16

 



Besides which, my opinion is that Express VIs Carthage must be destroyed deleted
(Sorry no Labview "brag list" so far)
0 Kudos
Message 5 of 6
(3,317 Views)
Thank you very much for your help. Its working now.
0 Kudos
Message 6 of 6
(3,275 Views)