07-10-2012 10:54 AM
Hi,
I am currently building software for an antenna testing pedestal. I am trying to receive information and send commands through a program for the ACU. The LabVIEW program is supposed to receive information through a slave port by parsing bytes from the received information, and send a new command back.
I am having trouble with the transmission portion. Because of the limitation of the software, if I try to open a socket for both the receive and transmission ports, I get an error saying that the port is already in use. I have come to a conclusion(please tell me if this is correct) that I will need to use a single socket, but use two ports on the same socket. Is this possible? If so, how can I do this?
If this is not possible, how can I work around this?
I have attached the receive/transmit portion of my test program.
Thank you,
Aki
LabVIEW 2011 SP1 Version 11.0.1f1
Windows XP Professional Version 2002 SP3
07-10-2012 11:14 AM
First, please take some time to learn how to use data flow and program correctly in LabVIEW. Your program is very typical of someone coming from a text programming background and trying to make LabVIEW look like that. For instance, in one frame (of your many frame structures) you have four copies of the same local variable. Simply branch the wire. Your parallel frame structures will not operate independently. Each must complete a full cycle before you can move on to the next loop iteration. Speaking of frame structures, please do not use stacked frames. Take some time to learn how to use state machines. They are much more flexible. However, most of your code could be written using simple dataflow.
With respect to your UDP question, I assume based on your code that you are connecting to the remote device which is acting like a server. If this is the case you can both read and write over that same connection. (UDP does not actually have connections but when you open a UDP session it can be considered a connection.) Unless you are using different ports, which you are not since you are getting the error, you only need a single UDP open. The reference out of that can be used for both sending anf receiving data.
07-11-2012 02:39 PM
Aki,
In addition to the issues mentioned by mark above you should look at the UDP send/receive examples included in LabVIEW. It looks like the issue you are having is because you are not opening and closing the UDP connection. You shouldn't just call UDP Read.vi or UDP Write.vi. As stated, the sequential frameworks are not running independently so look into manipulating your states via a state machine. The UDP connection follows the following format:
Open UDP->Read/Write UDP-> close UDP
When you wire them they should all reference the same connection. Hope this helps.
Regards,
Isaac S