LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

TCP

Solved!
Go to solution

Hi everyone,

 

I am trying to send datas over tcpserver using LV vi as in the picture.I am using the while loop in order to keep running the SW, so when I send the first bytes pressing on TM button it is working fine, but when trying to send again the same bytes(which worked perfectly) I got error message.no clue what could be?is the whileloop guilty?

Any help are welcome.

TCP error.JPG

0 Kudos
Message 1 of 11
(3,552 Views)

You are opening the connection at the start and you are trying to send the data whenever you press the boolean button. But you are closing the connection once you send the data and you keep on running inside the loop so when you execute the next time the TCP connection is no more open and the reference becomes invalid and thats why you are getting the error. Just remove the close connection function inside the case structure in the while loop.

-----

The best solution is the one you find it by yourself
0 Kudos
Message 2 of 11
(3,541 Views)

Hi P Anand,

 

Thanks for your quick reply.I have removed the TCP Close connection and I don't have anymore the error message thanks,

But when I try to send again the same byte the client doesn't react so I need to stop the via and starting again then I have something.

It looks like when the connection is closed out of the while loop whatever I send after is ignored unless I stop the vi and start again.

 

Thanks for any help

0 Kudos
Message 3 of 11
(3,534 Views)

Then you have to check the Client device that you are using at the other end how it has to recieve the data.

-----

The best solution is the one you find it by yourself
0 Kudos
Message 4 of 11
(3,521 Views)

TCP.JPGIt could be that the close vi outside the while loop is the problem, not allowing further data transmission??

 

0 Kudos
Message 5 of 11
(3,516 Views)

No unless and untill you stop your code or an error occurs in your code the close connection has nothing to do with. Are you using this as a sub vi?

-----

The best solution is the one you find it by yourself
0 Kudos
Message 6 of 11
(3,509 Views)

No, I am not using this as subvi, and of course when I remove the whileloop it is working but I need everytime to rerun the vi or put it in continous mode (from the taskbar).

this is not convenient at all.

0 Kudos
Message 7 of 11
(3,500 Views)
Solution
Accepted by topic author BENIO

It seems to me like that whenever you are establishing the connection for the first time the data is recieved properly and when you do it for the next time you are facing the problem. Then Keep the Open connection and close the connection inside the case structure inside the while loop and check ( but I am not sure that this is a right way of doing )

-----

The best solution is the one you find it by yourself
Message 8 of 11
(3,495 Views)

Using the local variable for the "ENTER TM"  might be resetting the button after you push it. It all depends on the timing of the push. This may not be your problem, but I'm sure it isn't helping. Make sure your button is "Latch when released" and delete the local variable. The button will reset on it's own when read.

Josh
Software is never really finished, it's just an acceptable level of broken
Message 9 of 11
(3,491 Views)

Thanks for the advise

0 Kudos
Message 10 of 11
(3,475 Views)