LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

ip address

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.11014761_10205389865098377_415785165_n.jpg

0 Kudos
Message 1 of 14
(3,891 Views)

@RosasFR wrote:

[...] All comments will be appreciated.


You don't need a camera to share your code in a post.

 

snip.png

Jim
You're entirely bonkers. But I'll tell you a secret. All the best people are. ~ Alice
For he does not know what will happen; So who can tell him when it will occur? Eccl. 8:7

0 Kudos
Message 2 of 14
(3,877 Views)

Thanks but i dont have the file right now and I somehow have that 🙂

0 Kudos
Message 3 of 14
(3,873 Views)

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.

0 Kudos
Message 4 of 14
(3,857 Views)
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.

Are they on the same network? If so use the "ipconfig" command in the command prompt and look for the ipv4 address of the adaptor which you are connecting to the network with. Use this address on the second computer so that it can talk to the first.

UDP can also be used for multicast, where the message is sent to all the computers on the local network.
Craig H. | CLA CTA CLED | Applications Engineer | NI Employee 2012-2023
0 Kudos
Message 5 of 14
(3,836 Views)

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



Message 6 of 14
(3,828 Views)
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!
Craig H. | CLA CTA CLED | Applications Engineer | NI Employee 2012-2023
0 Kudos
Message 7 of 14
(3,820 Views)

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



0 Kudos
Message 8 of 14
(3,817 Views)

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:

Simple UDP Read.png


LabVIEW Champion, CLA, CLED, CTD
(blog)
0 Kudos
Message 9 of 14
(3,807 Views)

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

0 Kudos
Message 10 of 14
(3,735 Views)