Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

tcp ip data synchronization

Hi;

I have a basic server application that send an integer data to a client with Labview TCP-IP blocks. I converted my Labview client into  labview (initiate, read close) dlls. I am calling the Labview dlls from my C++ application. This way, I am able to read the labview server output with my c++ application, which is a visualization program. My problem is that when I change the integer from the front panel of my Labview server, my c++ application can not read the new values immediately. What it does,  it reads the old values for a while and then, after a couple of moments,  it spits out the new value. In other words, there is a delay between the Labview server and the labview-dll based client. My guess is that my server client writes faster than does the client read, and as a result, the client ends up reading old values until the new term gets its turn. Does this mean that TCP-IP has an internal buffer and keeps the values in that buffer until they are read.

 

In my application, I need to read the values that are written last to the port and can ignore the values written to the port in between my consecutive  read calls in my C++ application. I am wondering if there is any way to do that. Since I can convert my labview client into dll, I can accept any solution on the client side as well.

 

I would really appreciate any help. 

Kind Regards, 

 

0 Kudos
Message 1 of 4
(3,876 Views)

Hello,

 

I believe that the information in this forum will help you out: http://forums.ni.com/ni/board/message?board.id=170&message.id=439745&requireLogin=False


-Zach

0 Kudos
Message 2 of 4
(3,837 Views)

Hi ;

Thank you so much for the answer. Differently from the case where you link deals with, in my case I don't know the rate of the client side as it is called from my C++ application (Note that I first created the client in Labview and converted it into dll so that I could call it from my c++ application). So I think what I should do, I should read the whole data on the port and take the last value of it as I am interested in the last value written on the port by the server at the time of the call from C++. So my question is that is there any way to do this with Labview TCP-IP blocks? If yes, could you please telll me how, and If no, what methods can I use to do this?

Thank you so much!

 

0 Kudos
Message 3 of 4
(3,833 Views)

Hello,

 

If you do no know how many bytes are at the port, you need to keep track of it somehow. One way is to send alternating packets. The first packet is a fixed byte size that you can always read and will tell you how many bytes were used for you data. If you are constantly reading, you will have to do this until you receive a timeout and then only keep the most recent one. Otherwise, there is no other way to determine exactly how many bytes are presently at the port using TCP/IP.  Alternatively, you could have some sort communication strean between your TCP write and read client that would store how many total bytes you had written.

 

-Zach

0 Kudos
Message 4 of 4
(3,806 Views)