취소
다음에 대한 결과 표시 
다음에 대한 검색 
다음을 의미합니까? 

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 포인트
11/16 메시지
1,035 조회수

here is the simple version of the code. thx

0 포인트
12/16 메시지
1,024 조회수

 


@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.

13/16 메시지
1,016 조회수

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 포인트
14/16 메시지
998 조회수

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 포인트
15/16 메시지
989 조회수

 


@sbz wrote:

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


That seems like a contradiction 😄

 

0 포인트
16/16 메시지
985 조회수