LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to get TCP/IP live data

I have a program (which is an executable) which detects the signal from a hardware and then transfer the signal into the local host TCP/IP socket.

 

When I run the program by itself and count the bytes it sends to the TCP/IP socket, the frequency is 128Hz, which means in around 10 seconds, 1280 packets are sent to the TCP/IP server.

 

But when I use LabVIEW to get them, I only managed to get for about 400-500 packets (in 10 seconds), although the packets are correct in sequence, but I can't get enough.

 

How can I solve this problem? I also try to adjust the bytes read in the TCP/IP Read vi and change the miliseconds to wait in the loop, but it gets nothing (see file attached).

0 Kudos
Message 1 of 3
(3,190 Views)

Honestly i am not sure why you read less than expected. BUT: What is it, what you read less? Bytes?

Regarding your "packets": How do you know that you miss some, but are confident that they are correctly ordered?

Are the missing ones always the newest?

 

I think a possible reason could be the file handling in the loop. You open, modify, save and close the file in each iteration. This is a performance killer.

But it should eat up that much time that it should delay the TCP reading for that long (as it seems).....

Nevertheless, move the file handling out of the loop. Obviously, the amount of data from TCP is rather low, so collect all data using a shift register first (best pre-allocated with replace substring). Write that complete string to disk after the loops execution.

 

Norbert

Norbert
----------------------------------------------------------------------------------------------------
CEO: What exactly is stopping us from doing this?
Expert: Geometry
Marketing Manager: Just ignore it.
0 Kudos
Message 2 of 3
(3,148 Views)

Thank you Norbert.

 

When I run my program by only itself, it will print out the  results in the command prompt windows, and I can write them into a text file so I can get its frequency. Each second the program sends out 128 lines, each line provides 32 sensor values in JSON format.

 

The program also supports serve the data via TCP/IP socket.

 

I will try your solution later and announce the result. Beside of that, I discover that I can use the SystemExec to run the program by itself to write the result to a file, then I can use LabVIEW to process the data later. It seems OK, but that way cannot process the live data stream.

0 Kudos
Message 3 of 3
(3,116 Views)