LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

UDP Client

Solved!
Go to solution

I am trying to make a simple UDP client to read data coming from an Arduino board. I have already read the data using a python client but I can't get the same results in labVIEW (picture below). But I keep getting Error 54: The network address is ill-formed, I am using the same port and ip address assigned in the Arduino. Does anyone know what is going on? I see there is a port argument in the UDP read block, but I can't connect a number to it so I am not sure of its purpose (The error indicates that the problem is with UDP open). 

Andy_110_1-1688757825380.png

 

 

0 Kudos
Message 1 of 12
(1,276 Views)

Hi Andy,

 

we cannot edit/debug/run images with LabVIEW. With real code we could do all that…

 


@Andy_110 wrote:

But I keep getting Error 54: The network address is ill-formed, I am using the same port and ip address assigned in the Arduino. Does anyone know what is going on?


No, as you don't show that IP address/port values…

(And you forgot to use autocleanup before posting to straighten wires!)

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 12
(1,273 Views)

Sorry about that, here is the cleaned up vi.

0 Kudos
Message 3 of 12
(1,264 Views)

Hope you have given proper Port Number, Have you tried pinging the  IP Address and got response? Make sure the Port is not occupied by other application.

----------------------------------------------------------------------------------------------------------------
Palanivel Thiruvenkadam | பழனிவேல் திருவெங்கடம்
LabVIEW™ Champion |Certified LabVIEW™ Architect |Certified TestStand Developer

Kidlin's Law -If you can write the problem down clearly then the matter is half solved.
-----------------------------------------------------------------------------------------------------------------
0 Kudos
Message 4 of 12
(1,218 Views)

UDP is a connectionless communication. As such the IP address on UDP Open is only to indicate if it should bind to a specific local network adapter address. Normally you should leave that unconnected unless you have multiple network adapters and special requirements. When unconnected, the UDP Open will bind to the localhost address and receive any messages to the specified port from any network adapter.

That address definitely must NOT be the address from the device you expect to receive messages.

Rolf Kalbermatter
My Blog
0 Kudos
Message 5 of 12
(1,208 Views)

Thank you all for the advice. I have removed the IP and now only specify the port #. I am getting an error 56 from the UDP Read block now. I have checked using cmd command: netstat -a to make sure the port is not being used. But since I have been able to access the data with a python client on the same computer I don't think that this is the issue. Below is the VI which I am trying right now.

 

If anyone has insight I would greatly appreciate it.

0 Kudos
Message 6 of 12
(1,131 Views)

First, Make sure the IP address that you are using is not being used by some other system?

The code that you attached is the client's code that tries to display data from your arduino. Do you have the server's code? If you do, make sure it is working with your arduino. If you don't have the server code, then I'm assuming you have arduino code/sketch uploaded to your arduino. 

What wifi module are you using for your wife connection?

Can you share the server's code or your arduino code?

Also, I would suggest that you try to use TCP instead of UDP and see how things go. I've been successful with TCP; I've never used UDP. Maybe it doesn't matter.

0 Kudos
Message 7 of 12
(1,106 Views)

Thank you for the information! I have talked to the building's IT department and they made sure all the ports I am using are on the same VLANs and that the ip I am using is not used by anything else. I have the arduino code (I can't upload a .ino file so I have attached a .txt file that can be copied instead). I am using an Arduino Uno Rev3 and the Ethernet Shield 2. But I have been able to successfully make a python client (other .txt file) so I think my issue is on the labVIEW side. I will try to write some TCP server and client programs to test. Thank you!

Download All
0 Kudos
Message 8 of 12
(1,099 Views)
Solution
Accepted by topic author Andy_110

Your Python client first sends the text “Red” to the server. The server doesn’t really use this text other than checking that it receives more than 0 bytes. More importantly it uses the IP address and port from that message to send back the measurement to!

Rolf Kalbermatter
My Blog
0 Kudos
Message 9 of 12
(1,074 Views)

Sounds good. Let us know how it goes when you modify your code to TCP. 

 

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~Proverbs 16: 3 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

0 Kudos
Message 10 of 12
(1,055 Views)