LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

TCP read/write at different rates

As long as the sender and receiver know what the data looks like it is fairly straightforward to keep them in sync with each other without using any type of addiitonal protocol. If on the other hand your data will be variable length data then you will need to have some mechanism for deliniating the data.

 
Seems to me like that is true in all circumstances, padding bytes or not.
 
 
Steve Bird
Culverson Software - Elegant software that is a pleasure to use.
Culverson.com


LinkedIn

Blog for (mostly LabVIEW) programmers: Tips And Tricks

0 Kudos
Message 11 of 28
(2,189 Views)
I just got a tcpip different rate sender/rcvr type of algorithm working.  First I opened the connection with a listener vi, no timeout used -1, and then passed the reference to two differenct loop (threads). In both loops I use a short timeout ( 10ms) and ignore error 56. In the send loop the send msg VI works at its own rate, it works off GUI events in this case, while the other loop queues up the data msgs to pass to a processing loop (in this case a FSM that does different things depending on the msg received.  This looks like it will work well for the amount of data and packets that I am processing which is not a high rate and only sends msgs based on user events.
0 Kudos
Message 12 of 28
(2,187 Views)

In both loops I use a short timeout ( 10ms) and ignore error 56. 

 

I would recommend using ZERO timeout, using BUFFERED mode, and ignoring error 56.

In BUFFERED mode, the TCP READ returns either all the bytes you requested or nothing.

 You don't need to spend that time waiting - the data will come in when it comes in.

You can service many more connections / UI events / whatever that way. 

 

 

Steve Bird
Culverson Software - Elegant software that is a pleasure to use.
Culverson.com


LinkedIn

Blog for (mostly LabVIEW) programmers: Tips And Tricks

0 Kudos
Message 13 of 28
(2,185 Views)

Mark,

 

Thanks for the info.  Do you have a ref document or a link that explains the minimum ethernet link packet size (and the rest of the info you shared)?

Fred
*Kudos are appreciated.*
0 Kudos
Message 14 of 28
(2,174 Views)
My primary reference for all things IP is the book [u]Internetworking with TCP/IP, Volume I[/u] by Douglas Comer. If you google for the various packet headers you can generally find the information online as well.


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
0 Kudos
Message 15 of 28
(2,173 Views)

While I'm sure that's a fine book, I would offer the suggestion that, at your stage of the game (you mentioned being new to TCP/IP), you should NOT get bogged down in the fine print details of what's happening under the hood.

Whether the minimum packet size is 1 byte or 6 bytes or whatever is not germane to solving your problem, getting the thing working is.  

 

TCP/IP is organized in layers, and this padding discussion is down in the transport layer, whereas the only thing your LabVIEW program has access to is the application layer. 

 

Again, feel free to read all you like, but don't think that you have to know those details to make things work. 

Steve Bird
Culverson Software - Elegant software that is a pleasure to use.
Culverson.com


LinkedIn

Blog for (mostly LabVIEW) programmers: Tips And Tricks

0 Kudos
Message 16 of 28
(2,169 Views)

I agree with what Steve said. Although I was the one to dive into the nitty-gritty details of TCP/IP packets this information is not really relevant at the application layer. Just make sure that both your sender and receiver know what the data should look like and what to expect.

 

I apologize for the diversion. I just spend so much time down in the details working with protocols I get caught up in the details sometimes.



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
0 Kudos
Message 17 of 28
(2,166 Views)

Hello, does anyone know how to trap the timeout error (code 56) coming out of the TCP Read VI? I set the TCP Read to Buffered Mode with 0ms timeout. When there is no data, it times out and returns 0 bytes, which is what I expected. However, I need a way to recognize this condition and subsitute the 0 bytes with a constant for use downstream.

 

I tried using the Find First Error.vi but it is not what I expected; it always returns TRUE.

 

Is there another way to detect Error Code 56 and return a boolean True? Do I have to parse the error out stream cluster?

 

Thanks.

 

0 Kudos
Message 18 of 28
(2,071 Views)

Yes, just unbundle out the error number from the error cluster and compare it to 56.  If true, clear the error and set your constant into the output wire.  If false, then just wire the error and the data through.

 

Message Edited by Ravens Fan on 11-05-2009 12:53 AM
Message 19 of 28
(2,056 Views)
You can use the error to warning vi in the vi.lib!  create a constant for one of the errors and select the timeout constant.
0 Kudos
Message 20 of 28
(2,039 Views)