02-14-2017 09:09 AM
Hello,
I have built a small test udp program which listens to a port and displays a message as shown in the figure and attached vi (labview 2009 format). But when I press the stop button on the front panel, it does not stop. I have to do abort. What is going wrong in here.
Thank you for your time.
Solved! Go to Solution.
02-14-2017 09:22 AM
Your "UDP Read" has a default timeout of 25 seconds... so depending on when you click Stop it will be somewhere between 0 and 25 seconds before you loop actually stops.
Just change the timeout to 200ms or something and it'll work.
02-14-2017 09:24 AM
What's your timeout for the UDP read? Your loop can only stop after a read/timeout.
/Y
02-14-2017 09:27 AM
It could actually be nearly 50 seconds.
The stop button is probably read very early in the loop. So the Stop button is read as false, and the UDP Read begins trying to read.
If you then hit stop, you still have to wait the nearly 25 seconds of the UDP timeout, but the stop button as already been read as false.
UDP timesout, loop doesn't stop because it was initially false. Loop reiterates.
Stop button is now read as true, but another UDP Read takes another 25 seconds to timeout. Finally it times out and the loop stops.
Total time any where from 25-49.99999999 seconds after you originally hit the stop button.
02-14-2017 09:35 AM - edited 02-14-2017 09:37 AM
The timeout on the UDP session is 25 Seconds. So, if there is no datagram the while loop will need up to 25 seconds to time-out and exit with error. Try wiring something reasonable to the timeout and see if error 56 occurs.
Edit: Oops I forgot to look at the responses first. Hey, RF! error 56 gets thrown on a timeout and the while loop exits on error, 50 seconds is not possible.
02-14-2017 09:41 AM - edited 02-14-2017 09:42 AM
yes, error 56 occurred when I changed the timeout to 200ms. What if I want the UDP to listen continuously until I manually click stop. I added "-1" to timeout so that I can continuously listen. In this case there is no way to stop it at all sanely?
02-14-2017 09:43 AM
Don't wire the error wire to the stop terminal. Or if you do, at least clear the error if it is a timeout error.
02-14-2017 09:49 AM
Even when the error wire is not connected to the stop terminal, the stop button on the Front panel does not seem to work.
02-14-2017 09:54 AM
-1 means never timeout. So it will sit there and wait forever until it receives data, then the while loop will stop.
02-14-2017 10:08 AM - edited 02-14-2017 10:19 AM
@johndoe1920 wrote:
yes, error 56 occurred when I changed the timeout to 200ms. What if I want the UDP to listen continuously until I manually click stop. I added "-1" to timeout so that I can continuously listen. In this case there is no way to stop it at all sanely?
Nope, no way to stop that sanely at all if there are no Datagrams under that condition.
Worse, (as Raven's Fan alluded to but did not state) with the original code exiting with error 56 there is a great possibility that the Stop Boolean does not get read after it is latched and stays True when the vi finishes. A simple work around for that is to use a sequence structure to control when the latcher is read
Now onto mods needed to " I want the UDP to listen continuously until I manually click stop."
To meet that requirement you need a different design pattern.
See the pdf attachment for hidden cases EDIT: Forgot to close the UDP Connection in the original