LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

TCP Listen only accepts 1 packet

Solved!
Go to solution

Hello,

 

I am trying to create a RS232 to TCP/IP converter VI. I am trying to use this VI to allow my main VI to communicate with a microcontroller (using rs232) over a network and I do not have access to a hardware converter.  The VI works great for sending data from the microcontroller ( rs232 -->TCP) but I am having problems getting information to the microcontroller (TCP --> rs232). I have tried numerous server configurations using the TCP Listen and Create Socket. For some reason I can only seem to receive a packet when using TCP Listen and no while loop but then it only receives 1 packet and none after that. I have used other programs to verify that the main VI is correctly sending the packet to that port and have verified that the problem is in this VI. 

 

The following image is the "working" version that only receives the first packet sent to it 

 RS232_to_TCP.JPG

 

 

 

The following two pictures are the other configurations I've tried but they receive no packets.  

 

TCP Listen with while loop 

RS232_to_TCP2.JPG

 

TCP Wait on Listener

RS232_to_TCP3.JPG

 

 

 

 

 

 If you can provide any help it will be much appreciated.

 

 Thank you,

 

             meanmon13

 

0 Kudos
Message 1 of 5
(2,884 Views)
Solution
Accepted by topic author meanmon13

Those wont work because you aren't thinking dataflow. Dataflow means each piece will execute when all the inputs to it are available. Your first while loop runs forever. There is an input to the second while loop coming from the first while loop. Hence, it will never get to your second while loop, and thats why you aren't receiving anything.

 

Put everything in one loop and use error wires to control the order

Message Edited by for(imstuck) on 06-09-2010 11:26 AM
Message 2 of 5
(2,873 Views)

One thing that you are doing wrong, is that you are closing the tcp/ip connect inside the while loop.

You could only close the connection when you end the program, not before that. 

Move the TCP/IP Close Connection vi out of the last while loop, and your secound try will recieve more packets.

Message 3 of 5
(2,852 Views)

I took into account the points your made and adjusted my VI design accordingly. After tweaking it a little I was able to get it working correctly.  Thank you for your prompt reply and helpful response.  

 

~meanmon13

 

ps: In case someone stumbles upon this post while researching a similar issue I will post a picture of my fixed VI.

 

RS232_to_TCP_Working2.JPG

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

I'd also STRONGLY suggest replacing your True constant with a button to stop your loop.  Otherwise you are never closing the VISA and TCP resources and could cause yourself more headaches in the future. 

 

One thing I try to stress when I teach the LabVIEW Core class is that you should almost never ever ever ever ever ever use the abort button on your VI.  Always create a way to safely end your VI.

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