03-26-2015 05:21 AM
Hello.
I'm making a program to receive datagrams using the UDP protocol from a software which controls a motion sensor. So basically, I just open-read-close with the UDP functions in a UDP port named 5000, but the problem is that the IP address seems to be wrong, I have an error coded as 54 that is a incorrect format of IP address. I used the string to IP function and wrote the same IP add. configured in my computer, I tried 127.0.0.1 and 172.0.0.1, I also used no IP add at all to conect by default with the computer as indicated in the description of the string IP function but nothing seems to work. All comments will be appreciated.
Thank you all for your time.
03-26-2015 05:55 AM
@RosasFR wrote:
[...] All comments will be appreciated.
You don't need a camera to share your code in a post.
03-26-2015 05:58 AM
Thanks but i dont have the file right now and I somehow have that 🙂
03-26-2015 06:50 AM
Unless you have multiple network cards on that machine, I don't think it's necessary to wire the net address at all. I believe specifying the port is all you need to do. Someone please correct me if I'm wrong.
03-26-2015 07:20 AM
03-26-2015 07:32 AM - edited 03-26-2015 07:36 AM
@Craig_ wrote:
127.0.0.1 is the net address of localhost. Packets you send to localhost don't go anywhere, though they can be read back on the same machine (this is actually a way you can talk between separate applications on your computer).
You need to use the actual IP of the computer to send messages across the network.
True, but that shouldn't produce an error 54.
I am able to use the UDP Open function with localhost without it generating an error. Providing no input to the net address terminal should also work, it just selects whichever network interface the OS gives it.
I suspect that the problem may be with the network interface configuratin itself. OP said that he used the IP address configured on his computer. If he meant that it was configured to use the localhost address 127.0.0.1 as its external address, I wouldn't expect this to work properly, in which case the UDP Open function may be having trouble when it asks the OS to open the socket.
Edit: Actually, I don't get an error no matter what I wire into net address as long as it is generated using the String To IP function. I do get an error 54 if I wire in a random U32 that is not formatted properly.
03-26-2015 07:39 AM
03-26-2015 07:41 AM
@Craig_ wrote:
I see what you mean about error 54.
It looks like the ip is connected to the wrong function.
UDP Open help: http://zone.ni.com/reference/en-XX/help/371361H-01/lvcomm/udp_open/
UDP Write help: http://zone.ni.com/reference/en-XX/help/371361H-01/lvcomm/udp_write/
Note how the top input to UDP Open is the net address (leave this unwired as others have noted) and that one of the top inputs of UDP Write is address. This is where you want to connect the IP!
The function that OP was using was UDP Read, not UDP Write.
Connecting the IP address to UDP Open is where you want to connect if if you have multiple network interfaces and want to open a socket on a specific network interface.
03-26-2015 07:59 AM
Yeah, the IP address isn't needed unless you want to listen on one specific network adapter for the packets (e.g. if you have multiple network adapters). Leaving it blank will attempt to connect on all interfaces.
Is the device sending out multicast UDP data (e.g. broadcasting) - if so I think you need to use the Multicast Open function and set the multicast address to match the one used by the device. If it's not multicast, then you should just be able to read:
03-29-2015 08:05 AM
Yes. I will check the multicast function but right now I just left the IP address blank now the error is coded as 60 which means that The specified network address is currently in use, is it because my sensor is using the IP address to conect to the computer? but then how can conect the software with labview ??(in the same computer by the way).