LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Reading a UDP Broadcast

Solved!
Go to solution

I have an NCD IO relay board that broadcasts some identifying information at 10 second intervals.  I am simply trying to read this message with a labview VI.  I have a snippet of a wireshark capture that shows all the source/destination/port information; and have attached a basic vi that I have been using to try to read this broadcast.  The VI has 4 different versions of a 'read' UDP sequence.  The best result I have achieved so far is for all 4 iterations to time out.  Does anyone have any suggestions for what I have done wrong?

 

CharlesD3_0-1664392641136.png

 

0 Kudos
Message 1 of 24
(521 Views)

Hi Charles,

 

read this

 


@CharlesD3 wrote:

The VI has 4 different versions of a 'read' UDP sequence. 


What's their difference? From a first glance I can only distinguish 2 different versions…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO
0 Kudos
Message 2 of 24
(510 Views)

So I guess the variable values may not have transferred with the file, but when operating the first two are different in that I can set each one to use a different port.  The next two are also 'programmatically' the same, but operationally I can set them to different values when running.  It is just a way to try multiple options when running.

0 Kudos
Message 3 of 24
(499 Views)

All you need is listen on port 13000 and local address 255.255.255.255. Open before the loop, keep reading inside the loop, ignore timeout errors, and parse the output do your liking. Close UDP after the loop.

 

(You definitely don't what to open and close UDP connections as fast as the computer allows. the port from the previous iteration might still be reserved when you try to open a new one a nanosecond later.)

 

Here's a quick draft:

 

altenbach_0-1664397467887.png

(Still needs adjustments, e.g. use a shift register for the error wire and clear timeout errors. Stop the loop on any other errors. decide on a reasonable timeout, etc.

0 Kudos
Message 4 of 24
(470 Views)

Unfortunately, this code gives me an error 54, 'The network address is ill-formed'.  I tried several variations; display formats, representations, etc.  All get the same error.  The only way I've managed to not get an error with the 'open' function is when I use a string and the 'string to ip' function or leave the 'net address' unwired; like in the file I submitted.  That does not generate an error, but does not work.

0 Kudos
Message 5 of 24
(415 Views)

I think the net address input should be left unwired. Are you sure that the packet is not dropped by a firewall?

Paolo
-------------------
LV 7.1, 2011, 2017, 2019
Message 6 of 24
(393 Views)

@CharlesD3 wrote:

Unfortunately, this code gives me an error 54, 'The network address is ill-formed'.  I tried several variations; display formats, representations, etc.  All get the same error.  The only way I've managed to not get an error with the 'open' function is when I use a string and the 'string to ip' function or leave the 'net address' unwired; like in the file I submitted.  That does not generate an error, but does not work.


Display format is irrelevant for the data. A network address is U32. Unless you show us what you actually did (or tried), we cannot help.

 

I don't get error 54 (or any other error!) when I run the following code:

 

altenbach_0-1664465537007.png

 

This is on Windows. On Mac, linux, etc the behavior is slightly different, so check the help.

 

0 Kudos
Message 7 of 24
(372 Views)

So one other tidbit that may be relevant:  I am running 2019 SP1, 64 bit.

The error on probe 30 is code 1: 'an input parameter is invalid'; presumably because of the error generated at the 'open' command.

 

CharlesD3_0-1664466899784.png

 

0 Kudos
Message 8 of 24
(361 Views)

You already get an error on probe #32, so let's focus on that first and worry about the downstream issues later.

 

Attach your latest VI!!!

 

Also provide more information on your setup.

  • OS?
  • How many network interfaces?
  • What are your adapter configurations (I assume IPv4 is enabled, right?)
  • etc.
0 Kudos
Message 9 of 24
(343 Views)

Can you try this code? (Yes, just listen on the default local address. It will see broadcasts)

 

altenbach_0-1664470602312.png

 

0 Kudos
Message 10 of 24
(336 Views)