06-09-2010 11:02 AM
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
The following two pictures are the other configurations I've tried but they receive no packets.
TCP Listen with while loop
TCP Wait on Listener
If you can provide any help it will be much appreciated.
Thank you,
meanmon13
Solved! Go to Solution.
06-09-2010 11:24 AM - edited 06-09-2010 11:26 AM
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
06-09-2010 01:56 PM
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.
06-09-2010 02:59 PM
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.
06-10-2010 12:54 PM
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.