DASYLab

cancel
Showing results for 
Search instead for 
Did you mean: 

RS232 awkward data, need help with parsing string

Hi,

 

I have been struggling to figure out the measurement data format strings to split out the following into seperate channels:

 

<CR>
07/12/11;10:44:21;1;<CR><LF>
CO2 ; 0.25;% ; ;0;<CR><LF>
;;<CR><LF>
67.8;29.9; 61.8; 2.17;291808;560656; 1; 1; 1; 1;<CR><LF>
5319;<CR><LF>
<CR><LF>

 

The instrument I am connecting too will spit out these 7 lines every 10 seconds. It does not require a data request command to output data.

 

I have tried 'Fixed and Flexible Format' strings for passing data but it does not seem to behave as expected. I trawled through many of the forum posts but it does not seem to treat foward slashes, colons, etc as ASCII and parse them with an 'a' string.

 

Can anyone assist me in where I am going wrong?

 

Thanks in advance,

 

Tom

0 Kudos
Message 1 of 5
(7,222 Views)

Hello Thom,

 

The string you are recieving, is it a fixed length every time or do the values change such that the length of each line can be different?

 

Please can you attach your code for me to have a look at.

 

Thanks

Jack. W
Applications Engineer
National Instruments
0 Kudos
Message 2 of 5
(7,198 Views)

Hi Jack,

 

The length of each line will be different, each parameter shouldn't be more than 6 characters long and always delimited with a semi-colon. Unfortunately I don't have any code to really give you, if I try a/r the RS232 monitor view gives me this:

 

rs232 monitor view.png

 

I assume the initial <CR> is my first problem.

0 Kudos
Message 3 of 5
(7,189 Views)

Hello Thom,

 

If the length of your data is changeable then Flexible is the one you need. Have a look at the following post "Parsing variable length data measurementt format for Newport THP/N"

 

http://forums.ni.com/t5/DASYLab/Parsing-variable-length-data-measurement-format-for-Newport-THP/m-p/...

 

Searching the word "Parse" in the DASYLab Forum I found more examples similar to this that may be of help to you too

 

Hope this helps,

 

Jack

Jack. W
Applications Engineer
National Instruments
0 Kudos
Message 4 of 5
(7,183 Views)

<CR>
07/12/11;10:44:21;1;<CR><LF>
CO2 ; 0.25;% ; ;0;<CR><LF>
;;<CR><LF>
67.8;29.9; 61.8; 2.17;291808;560656; 1; 1; 1; 1;<CR><LF>
5319;<CR><LF>
<CR><LF>

 

With 1x you can skip one character of the string in the module's puffer.

 

Format-String in chan 0 of Rs232-Input module:

 

1x $1 \x3b --> This skips the leading <CR>, and puts everything until the first semicolon (hex-code 3b) into DASYLab's global String 1 (so, the Date is in glob-string 1).

 

Format-String in chan 1 of Rs232-Input module:

 

$2 \x3b --> puts the time into glob-string 2.

 

Format-String in chan 2 of Rs232-Input module:

 

a \x3b --> outputs the 1 via output of chan 2

 

Format-String in chan 3 of Rs232-Input module:

 

2x $3 \x3b --> skips the <CR><LF>, and puts CO2 into glob-string 3

 

Format-String in chan 4 of Rs232-Input module:

 

a \x3b --> outputs the 0.25 via output of chan 4

 

Format-String in chan 5 of Rs232-Input module:

 

$4 \x3b --> puts % into glob-string 4

 

etc pp.

 

 

M.Sc. Holger Wons | measX GmbH&Co. KG, Mönchengladbach, Germany | DASYLab, DIAdem, LabView --- Support, Projects, Training | Platinum NI Alliance Partner | www.measx.com
0 Kudos
Message 5 of 5
(7,124 Views)