LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

read binary data feed over data socket

Hello All,

 

I was hoping to get some help with a time-sensitive project I have. What I'm looking to do is read streaming binary data over multiple data sockets, and then convert that bianry data into an array or matrix or what have you, for further analysis/reduction. Also, my incoming data streams are asynchronous, so I would LIKE to have an efficient way to sync this data (3 or 4 data streams) before I do any analysis.

 

Specifically, any help with the first step, reading the data socket and birnging the biary data in, would be most helpful. Tips on how to sync live streaming data effciently also appreciated.

 

 

Before anyone complains....Not looking to have my work done; just looking for suggested VI's, any tips or tricks people may have, etc.I have the DataSocket Server available, and along with the DataSocket VI's that's my starting point. 

 

Thanks for any help. And thanks to all the posters on here, you make this site a great reseource.  🙂

0 Kudos
Message 1 of 5
(2,518 Views)

Not sure if it matters, but this data read is over a local wireless network.

 

Thanks!  🙂

0 Kudos
Message 2 of 5
(2,510 Views)

It shouldn't matter that its wireless, so long as you can can locate the other system on the network.  Just make sure that you set allowances properly in whatever firewall you might be using.

 

As for using DS to send streaming binary data, it might not be the best option if you want to avoid data loss.  Things like DataSocket, PSP, and Network Shared Variables are basically like global variables over the network.  They are great for asynchronous operations where you only care about the current value, but there's always a chance that data will be overwritten before you've had a chance to read it unless you create a syncing mechanism for yourself; and who needs that trouble.  It sounds like you might want something that provides buffering.  I'd suggest using Network Streams instead.  LabVIEW should have adequate examples to get you started.

0 Kudos
Message 3 of 5
(2,501 Views)

Looks like a better method...however I'm back on LV 7.1.1. So no such luck there. Thanks anyways!

0 Kudos
Message 4 of 5
(2,473 Views)

Ah, I see.  Well, the network streams are based on TCP.  The folks at NI just did the heavy lifting on development.  But there is no reason that you couldn't do something similar using regular TCP communication and and there should be a number of examples there too.  Its just that to guarantee that there is no loss of data, you'd probably want to employ some sort of framing with handshaking and checksums, etc.  You could also set up handshaking with DataSocket. 

 

For handshaking with DS, you would set up multiple DS variables.  One for sending data, and another variable or two for handshaking.  The idea is that the server (data generator) acquires data and probably buffers it into a local FIFO queue so that it can decouple the acquiring of data from transmission of data.  Then in a separate process, the server pops items off the queue and sends them over DS with handshaking to prevent data loss.  Lets presume that the handshaking lines are just simple Booleans; The server sets a "Transmit" or TX flag and the client sets a "Received" or RX flag. 

 

The server might first wait for the client's RX flag to be cleared signaling that it is ready to receive data.  It then sets new data to the "Data" variable and sets its TX flag to let the client know that new data is available.  It then waits for the RX flag to be set before completing the cycle.

 

On the Client side, the client would clear the RX flag.  It then waits for the TX flag.  When the TX flag is set, it reads the data and then sets its RX flag.

 

The problem with this sort of algorithm is that it can be slow (relatively speaking) for large amounts of data and the server and client can get out of sync. You have to decide how you will deal with syncing and timeout issues.  Obviously, you can get more sophisticated about handshaking and error handling.

0 Kudos
Message 5 of 5
(2,458 Views)