Jump to content

String to Array


evergood

Recommended Posts

Hello

I'm receiveing data form a linux pc over RS-232 about 12 times in 10 seconds. See RS-232_com_v1.vi (picture below)

This data is coming out as a string. I'm going to use this data for "realtime" graphic and alarm monitoring. I want them presented as an array, for use in an already excisting program.

My recived data looks like

|2007-02-20 10:30:30

{ 00.0260.043

{ 10.0260.045

{ 20.0260.044

...

Look her for a sample of a file: Data

The Time and Date is not important at the moment.

The first colums is the Channel the data is coming from, the second colums is a RMS value and the third colums is a Peak value.

Want the array to be 3x16=48 rows big, so its will be easy to pick out the data.

Would like the data in a form like this!!

post-7619-1171983483.jpg?width=400

post-7619-1171983351.jpg?width=400

Link to comment

Fist off, I think you need to do some modifications to your loop. For a start you could move the initialization of the serial port outside the loop, and look into using a termination char, so you read data line by line in stead of reading all the bytes present in the serial input buffer.

Once you have taken care of this, parsing of the data should be a lot easier.

-Mikkel :)

Link to comment

QUOTE(evergood @ Feb 26 2007, 09:11 AM)

Thanks, will do. ;)

Here is a tip

Put that puppy in a shift register (while loop) and use the match string function with the period '.' delimeter

to parse out the values then auto index em out as an array.

Attach the comparison operator <0 to the index output of the match string function to tell the loop to stop parsing.

This is the essense of parsing strings.

Unfortunately I don't have an example.

Link to comment

QUOTE(John Rouse @ Feb 27 2007, 06:35 PM)

Here is a tip

Put that puppy in a shift register (while loop) and use the match string function with the period '.' delimeter

to parse out the values then auto index em out as an array.

Attach the comparison operator <0 to the index output of the match string function to tell the loop to stop parsing.

This is the essense of parsing strings.

Unfortunately I don't have an example.

I think I would prefer using the 'Scan from String' function with format string "{ %d.%d.%d" - but it's a matter of taste...

-Mikkel :)

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.