LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

TCP IP to recieve and split data in real time

Solved!
Go to solution

Only the first three values after P is shown. I can see only 10 as output. I need it to update as 10 then 11 then 12 and so on as the data comes in. How do I do that?

0 Kudos
Message 11 of 21
(940 Views)

It sounds like perhaps you are not indexing the array of output values, there should be three elements.  The code in the snippet looks fine.

 

And to defend the honor of Scan from String, Mark misspoke slightly as I quote from the LV Help:

 

"A space in format string matches any amount of white space, such as spaces, tabs, linefeeds, and form feeds."

Message 12 of 21
(930 Views)

Here is the problem. The file data is anexample of how the data I get looks like. When I try a simple splitstring I do get the desired data but the output displays only now and then. meaning it skips most of the data in between. The kishortcp should work but it keeps saying that the input string is not of the expected order. This is because the number of bytes I read doesnot end exactly at the end of the pattern we want. I am not sure what to do. Kindly help

Download All
0 Kudos
Message 13 of 21
(900 Views)

You are not processing the data correctly. In your one example you are reading new data every iteration of the loop and your are effectively overwriting the data which was not processed in the prior iteration. IN the other example you are only reading one sample from the string. Did you look at the code that I posted earlier? I suggest you use one loop to read data and another to process it. You will need to either split the string so you remove the data you already processed from it or keep track of the index into the string for the point you need to process next. When you receive new data you simply concatenate it with the data you have not processed yet.



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
Message 14 of 21
(889 Views)

I based my code entirely on yours. I am grateful for your help. So you suggest that I read the data in a seperate loop, split it when P occurs using splt string and then send it to the processing loop?

0 Kudos
Message 15 of 21
(869 Views)

I can see it now. Everytime i read the data from tcp I overwrite the data I read from the last loop. But how do I solve this? I tried writing to a xml file but it keeps overwriting it. Please help

0 Kudos
Message 16 of 21
(851 Views)

I finally tried what you said and it is working but the delay is a lot between me receiveing the data and the processing side displaying the output in clusters. Is there a way to solve this?

0 Kudos
Message 17 of 21
(839 Views)

What do you consider to be a lot of delay?

 

One thing in the first loop is that you open the file but never close it. More commonly the file is opened outside the loop then the writes recur within the loop and the file is closed after the loop ends. Repeatedly opening the file without ever closing it could create problems with your references. The open process is probably slow. Although you are not writing large quantities of data as the file grows, maybe it has to reallocate space for the files.That process may also be slow.

 

In your read file loop it appears that you read the entire file each time even though the data hasn't changed from the previous read. If you keep track of the read file position in a shift register or feedback node, then you would only read the data that has been appended. I'm not sure that would be faster but it seems like it would worth trying.  There is nothing in the second loop which knows whether the first loop has written new data to the file. You might consider checking file size and comparing it with the previous file size before reading to avoid reading the same data again.  you could also check the File/Directory Info function to get the modification time date information.

 

Nothing to do with speed but using constants for the file paths means that you have to change constants two places anytime you want to change the file path. Move the constant outside both loops and just use one. 

 

Lynn

Message 18 of 21
(827 Views)

@kishorgenius wrote:

I finally tried what you said and it is working but the delay is a lot between me receiveing the data and the processing side displaying the output in clusters. Is there a way to solve this?


That is the general idea but I wouldn't use a file to transfer data between two loops. I would use a queue to pass the data. Queues will be much more efficient. You will also need to keep track of where you are in the data buffer in terms of processing it. It would be easiest to remove the data from the buffer once it is processed that way your processing will always take place at the start of the buffer. If you process all the data then you simply wait for more.

 



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
Message 19 of 21
(820 Views)

The problem i am facing with queue is I receive no data outside the loop. Hence I am made to do the reading and processing in the same loop. Is there a way out?

0 Kudos
Message 20 of 21
(797 Views)