LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

reset hub

If you close a UDP port and try to open it a nanosecond later, it is possible that the OS hasn't released it yet. There is absolutely no need to ever do that.

 

UDP is a connectionless protocol, so just open the port and keep it open for the duration of the program run.

 

Can you show us some code?

0 Kudos
Message 11 of 16
(504 Views)

here is the simple version of the code. thx

0 Kudos
Message 12 of 16
(493 Views)

 


@sbz wrote:

here is the simple version of the code. thx


 

Well, that code is exceedingly complicated. All that logic mess can be replaced with autoindexing. The delay has an error in/out, so no sequence is needed.

 

Why is there no top-level while loop? Are you running this on demand or are you using the "continuous run" button?

 

You are only sending commands via UDP and you never receive anything. Since you seem to run an UDP client, the local port should be unimportant. Maybe you should leave it unwired so the OS can pick an unused ephemeral port and you don't need to rely for a certain local port to be unused. Even if your server (instrument) sends replies back, you can program it to reply to whatever the source port of the request is, again making the local port of the client irrelevant.

 

You should only set a fixed local port if you are planning to run it as a server where clients establish new connections from the outside.

 

Anyway, you should only open the UDP session once for the entire duration of the program.

 

Here's a quick rewrite that does basically the same thing. Whenever you press the button, both instruments are contacted.

The local port is kept open until the program ends. Let me know if it makes sense.

Message 13 of 16
(485 Views)

hi,

 

thanks for taking the time & modifying the code. the code i sent you is just part of a huge code, and the part i sent you only triggers the lasers. the problem is not with the code, it works fine with 1 device but not with 2. i ran your code & it doesn't run but again thanks for your time.

sbz

0 Kudos
Message 14 of 16
(467 Views)

One thing I noticed is that the "con\n" constant is set to normal display mode. I believe the intent here is to send "con" followed by a linefeed. In this case you need to change the display mode of that constant to '\' codes display and remove one of the backslashes that will appear once you do this. Also, some of the other strings have spaces at the end. Don't know if that matters.

0 Kudos
Message 15 of 16
(458 Views)

 


@sbz wrote:

i ran your code & it doesn't run ...


That seems like a contradiction 😄

 

0 Kudos
Message 16 of 16
(454 Views)