07-07-2023 02:27 PM
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).
Solved! Go to Solution.
07-07-2023 02:31 PM
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!)
07-07-2023 02:46 PM
Sorry about that, here is the cleaned up vi.
07-07-2023 05:17 PM
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.
07-07-2023 06:54 PM
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.
07-09-2023 01:57 PM
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.
07-10-2023 11:49 AM - edited 07-10-2023 11:53 AM
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.
07-10-2023 12:06 PM
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!
07-10-2023 01:22 PM
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!
07-10-2023 02:57 PM
Sounds good. Let us know how it goes when you modify your code to TCP.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~Proverbs 16: 3 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~