Lacita

Socket UDP Send not working

11 posts in this topic

I got the problem with this FB. This work:9.PNG

But this doesn't! Its error is 0400, the Input value is out of range(?)7.PNG

This is variable table.

8.PNG

Help me check this. Thank you guys.

 

Edited by Lacita

Share this post


Link to post
Share on other sites

How come you use port 60001 and not 6001?

Can you try with 6001, I know the range is up to 65535 but you can give it a try.

Edited by andrei.apopei

Share this post


Link to post
Share on other sites

Port Number does not matter AFAIK, as long as it's not the common port number used in other TCP/UDP protocol (like port 80) or not being used by another Socket.

I see in your variable tables that you are Initializing some values, such as the Socket definition.
I think, prevent to Initialize the "Handle" value of the Socket. When you are Creating a Socket by the Create FB, you will get a new value assign to that Handle, just as a pointer. This is later on Outputted by the Create FB.

Try checking the current value of the Handle in your Socket. It will not be able to send anything if the value is 0.

Share this post


Link to post
Share on other sites
12 hours ago, innoaloe said:

Port Number does not matter AFAIK, as long as it's not the common port number used in other TCP/UDP protocol (like port 80) or not being used by another Socket.

I see in your variable tables that you are Initializing some values, such as the Socket definition.
I think, prevent to Initialize the "Handle" value of the Socket. When you are Creating a Socket by the Create FB, you will get a new value assign to that Handle, just as a pointer. This is later on Outputted by the Create FB.

Try checking the current value of the Handle in your Socket. It will not be able to send anything if the value is 0.

I checked that Handle value, it's different from my initial value (= 0), it's 1 as you can see.

But Send FB still not work. 

What value should that Handle be? Or what shoul I do now?

10.PNG

Share this post


Link to post
Share on other sites

I think I'm starting to get what's happening... but you need to try it.
Delete all of the Initial Values set for your Socket variable. In the SktUDPCreate documentation it describes that both SrcAdr and DstAdr sections will be filled with zero once the socket is created. As UDP is an unconnected communication, you don't need to specify any source IP Address.

If the UDPCreate is successful, fill the DstAdr with your target device IPAddress and PortNumber, then try the UDPSend command.


The Handle value is basically just a pointer. If you Create a socket one time in the entire program, it will be filled with 1. If you create another socket, it will have 2 as the handle value. If say socket 1 is closed properly, next time you open a socket it will get 1 as the handle value. So it's predetermined by the CPU.

Share this post


Link to post
Share on other sites
5 hours ago, innoaloe said:

I think I'm starting to get what's happening... but you need to try it.
Delete all of the Initial Values set for your Socket variable. In the SktUDPCreate documentation it describes that both SrcAdr and DstAdr sections will be filled with zero once the socket is created. As UDP is an unconnected communication, you don't need to specify any source IP Address.

If the UDPCreate is successful, fill the DstAdr with your target device IPAddress and PortNumber, then try the UDPSend command.


The Handle value is basically just a pointer. If you Create a socket one time in the entire program, it will be filled with 1. If you create another socket, it will have 2 as the handle value. If say socket 1 is closed properly, next time you open a socket it will get 1 as the handle value. So it's predetermined by the CPU.

Oh wow thank you very much innoaloe, it works!!!

This is my setup, hope it will help for anyone have to face this problem.

 

 

13.PNG

Edited by Lacita

Share this post


Link to post
Share on other sites

Good to know that it solved the issue :)

Share this post


Link to post
Share on other sites

It wish it worked for me. When I bring up _sSOCKET Variable in Watch window Dst Port is set to 0 and Ip is null and I can not modify them either

PLcPic.jpg

Share this post


Link to post
Share on other sites

You need to set up the entire _sSocket variable prior to executing the SktUDPCreate function block.  Notice in the very first post in this thread where the initial value of the Socket variable is set.  

Share this post


Link to post
Share on other sites

Hello people

I'm trying to send data via UTP socket in the SocketTest program, but I haven't been successful yet, below is an image of error 0400 on the send FB


can someone help me with an application example using FB send UTP sending any data and I monitoring this data in any software such socketest for example?

 

Thanks for read and help

CnGWaCR

 

Share this post


Link to post
Share on other sites

Good Morning I am a beginner in PLC programming using the Sysmac Studio software and please help me if you can :-D I'm trying to make an omron NX1P2 PLC read some message via Socket UDP to my PC through the Socket Test program, do you have or know any program with an example application in ladder? thank you

  •  

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now