LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

TCP Read Error Code 1

I met a problem in using "TCP Read" in LabView;
First I use "TCP Open Connection" building connection successful with a instrument; and seem the connection ID as the global,equal to a "TCP Network Connection Refnum";

Then I use the global as the connection ID,and use "TCP Write" send a command to a instrument;and use "TCP Read" Receive the instrument return message;this time a 56 error occurs,it is normal.

But after I use this method Send/Receive two times successfully,when i use "TCP Read" receive message, the error 1 occurs,and nothing received.

In each TCP operation,use the global "TCP Network Connection Refnum" as the "Connection ID" input.

someone can tell me,why does it occur?
0 Kudos
Message 1 of 3
(5,367 Views)
If I'm not mistaken error 1 is invalid input. Is it possible your global variable changes somewhere during the way or that you're using the close TCP VI somewhere? Try using a probe to see if the read VI recieves the proper connection ID and if that doesn't help, try making a small test VI which will run without globals. This will help you narrow down the problem.

___________________
Try to take over the world!
0 Kudos
Message 2 of 3
(5,358 Views)
JiangYu wrote:

> I met a problem in using "TCP Read" in LabView;<br>First I use
> "TCP Open Connection" building connection successful with a instrument;
> and seem the connection ID as the global,equal to a "TCP Network
> Connection Refnum";<br><br>Then I use the global as the connection ID,
> and use "TCP Write" send a command to a instrument;and use "TCP Read"
> Receive the instrument return message;this time a 56 error occurs,it is
> normal.<br><br>But after I use this method Send/Receive two times successfully,
> when i use "TCP Read" receive message, the error 1 occurs,and nothing received.
> In each TCP operation,use the global "TCP Network Connection Refnum"
> as the "Connection ID" input.<br><br>someone can tell me,why does it occur?

Ouch, globals! That is usually the first sign of a bad application design.

For the rest just watch out. LabVIEW refnums are garbage collected
whenever the VI hierarchy which opened them goes idle (stops executing).

So Executing a VI which Opens the TCP refnum and writes it into a global
and then quits and then executing another VI which tries to use that
refnum from the global will simply fail with error 1 as the refnum has
been already automagically closed and is therefore invalid.

Rolf Kalbermatter
Rolf Kalbermatter
My Blog
Message 3 of 3
(5,347 Views)