LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Serial Read Buffer Format

Solved!
Go to solution

I am Receiving DATA from Serial RX Buffer from my Instrument.

My program needs  parse this DATA.

 

My string Buffer Indicator is:                                                                         \02K=2\r\n\03         Normal Display

However, what I need to to Receive in order to input to my parsing Sub is:    024B3D330D0A03      Normal Display

 

Please advice, Thanks.

0 Kudos
Message 1 of 8
(3,288 Views)
Solution
Accepted by topic author Metachnet

StringConvert.png

Omar
Message 2 of 8
(3,283 Views)
Reviewing your post I have to ask

 

Metachnet wrote:
 \02K=2\r\n\03         Normal Display

 

Are you sure this is "Normal Display" and not "\ Code Display"?

However, what I need to to Receive in order to input to my parsing Sub is:    024B3D330D0A03     

Are you sure this is a string control with normal display?

 

You are converting it from a 7 byte (7 char) message to a 14 char string (14 bytes). I would leave it in the original string and pass the original string to your parsing Sub and pars the 7 bytes. I think you are doing some unneeded converting.

Omar
Message 3 of 8
(3,276 Views)

I just reproduced your program and it works.

 

You are genius.

Thank you.

0 Kudos
Message 4 of 8
(3,267 Views)

I'm not sure about the genius part

 

But if I was parsing a string, would pars the original 7 byte string instead of converting to a hex "representation" of the ASCII codes of the string.

 

I don't think you should have to convert it if the parsing Sub VI was written correctly. 

How are you parsing the string in the Sub VI? If you post the parsing Sub VI I could advise you if there is a better way.

Omar
Message 5 of 8
(3,258 Views)

Attached is the parser with two sub messages.

The parser will be getting the string from the Rx Serial buffer.

Thanks.

Download All
0 Kudos
Message 6 of 8
(3,200 Views)

It seems your messages are of the format "some command ‘=’ some data"

 

As in

       F=3

       T=00

 

I just wanted to ask, does seeing the commands in their hex representation '46' '52' '4B' or '54' mean more to you than seeing the commands in their original stings 'F' 'R' 'K' or 'T'

 

‘46' or 'F'

'52' or 'R'

'4B' or 'K'

'54' or 'T'

 

I think leaving them in the original format and NOT converting them to the hex representation will make your code easier to read. Your case structure will have labels F R K or T instead of labels like 46 52 4B and 54.

 

Look at using “Match Regular Expression” to pars out the command and data from the '=' and all the control chars.

 

Pars String.png

 

Omar
Message 7 of 8
(3,188 Views)

Make sense,

 

Thank you.

0 Kudos
Message 8 of 8
(3,178 Views)