LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Parsing TCP Data

Hi all, I am trying to read strings of data in over TCP and use that to graph waveforms.  If an event has occured. 

Let me explain what I am trying to do.  I will be receiving a set of data over TCP that looks like this (all in string form, with a "\n" at the end of each line):
"Begin Transmission"
"F 0 1 2 3" (where 0 1 2 3 will be either a 0 or 1, identifying if a specific event has occurred)
"F A[i] B[i] C[i]"  (where A, B, and C each contain about 100 data points from three phases of current that I would like to plot)
"End Transmission

So, I will only receive information if an event has occurred (a 1 appears in the second line).  When I see this event, I want to note that the event happened, and record the current waveforms from each phase into a file, and display the graph of these waveforms.

I have successfully made an output file, that I like, using three waveform generators, so I think the concept works. 

I have tried to put all of this functionality together in this vi, and feel like the only thing I'm not setting up correctly and completely is the TCP read portion.  That is where I really need the help.  I've looked at a lot of sample code, but have yet to find anything that shows me how to split up strings like this.
Thanks in advance for any help you can offer.

Brendan
0 Kudos
Message 1 of 3
(2,764 Views)
You should only need to read the data once per loop. 

"Search/Split String" is one of my favorites.  It returns the location of the search match.  With a cascade of these (the match+rest of the first plugged into the input of the next), you should be able to get the set up you want.

Also, look at the "Compound Arithmetic" function.  It can do some really cool stuff with boleans.  You could bundle all your "Write Measurement File"s into one.  I am assuming, of course, that you only want to write the file once when any one of the test conditions is met.
0 Kudos
Message 2 of 3
(2,758 Views)
Thanks for that idea.  I'll deffinately try it.  I was wondering if it was possible to tell TCP Read to read a range of bytes.  If I could do this, since I know exactly what is being sent, I could have each of my read blocks read a specific portion of the data.

Thanks,
Brendan
0 Kudos
Message 3 of 3
(2,756 Views)