Our full technical support staff does not monitor this forum. If you need assistance from a member of our staff, please submit your question from the Ask a Question page.


Log in or register to post/reply in the forum.

Process Complex Serial Data Stream


Terrapin Dec 7, 2017 09:00 PM

I'm new to trying to acquire and process serial data from a Vaisala WXT520 sensor using a CR1000.  I can sucessfully acquire the data for the various data outputs, but I can't figure out how to process the data into data variables given that each variable in the serial string is separated by a , contains text denoting what the variable is, and has some text at the end for the units of measurement. 

Does anyone have any suggestions how I can Split the String so that the initial characters, 0R2, are stripped out and only the remaining numeric values are kept?  I've tried various combinations of Split Options to get this result but haven't found the proper way to do it.  

Public SearchString(2) As String * 30
Public ResultString(5) As String * 20

BeginProg
SearchString() = "0R2,Ta=23.6C,Ua=14.2P,Pa=1026.6H<cr><lf>"

Scan (1,Sec,3,0)

SplitStr (ResultString(),SearchString(),0,5,0)
NextScan

EndProg


JDavis Dec 7, 2017 09:28 PM

Instead of putting the results of SplitStr in an array of strings, try using an array of Float.

Public SearchString(2) As String * 30 
Public Result(5)

BeginProg
SearchString() = "0R2,Ta=23.6C,Ua=14.2P,Pa=1026.6H<cr><lf>"

Scan (1,Sec,3,0)

SplitStr (Result(),SearchString(),0,5,0)
NextScan

EndProg


Terrapin Dec 7, 2017 10:20 PM

That certainly helps, but I still end up with the extraneous 2 from the 0R2 at the beginning of the record.  I can easily capture that value and just not process it in any way.  Thanks for your suggestion.  


JDavis Dec 7, 2017 10:39 PM

One trick that might be a bit confusing, is read the string with a later starting point.

SearchString(1,1,4) is the string starting on the fourth character.

Public SearchString(2) As String * 30 
Public Result(5)

BeginProg
SearchString() = "0R2,Ta=23.6C,Ua=14.2P,Pa=1026.6H<cr><lf>"

Scan (1,Sec,3,0)

SplitStr (Result(),SearchString(1,1,4),0,5,0)
NextScan

EndProg


Terrapin Dec 7, 2017 11:48 PM

This seems like a great solution to the issue.  I didn't realize we could "filter" the SearchString, but your example clearly shows how.  Thanks for sharing your ideas and tips.  This works really well now.


Terrapin Dec 8, 2017 04:41 PM

Hi JDavis,

I thought I understood the SearchString(?,?,?) solution you proposed, but after thinking about last night I'm not sure I do.  Can you descrribe for me what each element in SearchString(?,?,?) refers to?  Thanks.


JDavis Dec 8, 2017 08:41 PM

Strings are 3 dimension arrays on the datalogger.

(first array index, second array index, character index)

Log in or register to post/reply in the forum.