LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Parsing and using serial data(RS-232)

Solved!
Go to solution

I am trying to parse data coming from a device(serial communication), the data is space delimited but the number of spaces are irregular. How can I make the number of spaces even so that I can extract the data I need into individual columns of an array for further processing?

If this is my original message;  118.0 DRAW 60 0 6 98 0 9 55 1952 3235 -12 -2 0 56 [ccOOccOc] 0 5640 0 0 0 [ffff] 
119.0 DRAW 60 0 6 99 0 9 57 1952 3235 -12 -2 0 57 [ccOOccOc] 0 5640 0 0 0 [ffff] 
120.0 DRAW 60 0 6 100 0 9 58 1952 3235 -12 -2 0 58 [ccOOccOc] 0 5640 0 0 0 [ffff] 
121.0 DRAW 60 0 6 101 0 10 58 1952 3235 -12 -2 0 59 [ccOOccOc] 0 5640 0 0 0 [ffff]

 

how do I make it like this with equal spacing,

118.0 DRAW 60 0 6 98 0 9 55 1952 3235 -12 -2 0 56 [ccOOccOc] 0 5640 0 0 0 [ffff] 
119.0 DRAW 60 0 6 99 0 9 57 1952 3235 -12 -2 0 57 [ccOOccOc] 0 5640 0 0 0 [ffff] 
120.0 DRAW 60 0 6 100 0 9 58 1952 3235 -12 -2 0 58 [ccOOccOc] 0 5640 0 0 0 [ffff] 
121.0 DRAW 60 0 6 101 0 10 58 1952 3235 -12 -2 0 59 [ccOOccOc] 0 5640 0 0 0 [ffff]

Also if the device has different substates, how can I detect using a boolean when the device enters and exits a particular substate?

0 Kudos
Message 1 of 9
(2,485 Views)

I don't understand.  The two text examples are identical. 

I also have no idea what you mean by "substates".

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 2 of 9
(2,458 Views)

I am new to labview, my question may be pretty basic. Sorry for the confusion though.

 

So there are multiple lines being received through the serial data and I am trying to parse them into individual columns using a space delimiter as that is how it is being sent by the device. Some of the columns have single space which fall into the right array columns, but for the ones with extra white spaces leave gaps in the array. I am trying to even the spaces so it would be easy for me to parse the data.

 

0 Kudos
Message 3 of 9
(2,453 Views)

You could do a search and replace on our string and replace any instance of two consecutive spaces with just one.  Keep repeating until you find no more instances.  The spreadsheet string to array using space as the delimiter.

0 Kudos
Message 4 of 9
(2,431 Views)

@LVPS28 wrote:

I am new to labview, my question may be pretty basic. Sorry for the confusion though.

 

So there are multiple lines being received through the serial data and I am trying to parse them into individual columns using a space delimiter as that is how it is being sent by the device. Some of the columns have single space which fall into the right array columns, but for the ones with extra white spaces leave gaps in the array. I am trying to even the spaces so it would be easy for me to parse the data.

 


Oh, it's just that the "unconverted" data was identical to the "converted" data, and it confused me.  Or it seemed that way when I placed them into a monospaced editor.

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 5 of 9
(2,417 Views)
Solution
Accepted by topic author LVPS28

Try this and see if you can use it.

 

/Peter

0 Kudos
Message 6 of 9
(2,406 Views)

Thank you Peter, this helps for my application.

0 Kudos
Message 7 of 9
(2,395 Views)

Sorry about that Bill!

When I meant states I am trying to find a particular string from a file and detect by enabling a boolean when found and disabling the boolean when not found.

 

Thanks!

0 Kudos
Message 8 of 9
(2,394 Views)

@LVPS28 wrote:

Sorry about that Bill!

When I meant states I am trying to find a particular string from a file and detect by enabling a boolean when found and disabling the boolean when not found.

 

Thanks!


🙂

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 9 of 9
(2,385 Views)