LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Labview find ethernet device address for TCP/IP VISA communication

Hi Rainer,

yes, using TCP/IP communication I can communicate to both devices. There is a parameter "board" in the TCP/IP initialization function but this has not the meaning of the network card number, funnily. This strange parameter must be zero and then I can communicate to both devices with known IP addresses without any problems. Just the UDP broadcast does return one device only, and this is the device which is connected to the network card which is the first one known to Windows (first entry in Windows network cards list).

To start an UDP broadcast, the C++ software sends two queries (in case of two network cards installed). Each query uses a socket with the IP address which corresponds to one network card of the client (local PC). This IP address is found by a function "Get Adapters Info". The receiver address is always the same (255.255.255.255) but the sender address changes. Doing the same with "INADDR_ANY" as the client IP address does only return one device - same as the LabVIEW UDP broadcast.

The LabVIEW UDP broadcast VI has none of those functions and so I also thought that it would return all devices from all network cards Smiley Sad

Greetings,

Gabs

0 Kudos
Message 21 of 39
(4,436 Views)
You can specify the subnet when broadcasting. 255.255.255.255 is general but you can also use the subnet. If the network adapters are on subnets 192.168.1.* and 192.168.2.* then make two broadcasts at  192.168.1.255 and 192.168.2.255. The last digit 255 is the broadcast address for the subnet. When the subnet is specified the corresponding network adapter is automatically selected.


Message Edité par JeanPierre le 05-29-2006 02:42 PM



LabVIEW, C'est LabVIEW

Message 22 of 39
(4,434 Views)
Hi,
aaaah - that works. But the question is - how can I find out the valid subnet mask values on an unknown PC? On our test computer here we have two network adapters. One has a subnet mask with two values (x.y.255.255), one with three values (a.b.c.255). I do not know x,y,a,b and c. Is there any LabVIEW code available to get the IP mask from the (Windows) system back? I know that there is a Windows function GetAdaptersInfo in Iphlpapi.dll, but this is very compicated to use. Also, one could use System Exec.vi to read the answer of "IPCONFIG", but then how do I parse the answer? I think this must be a common problem to get the IP mask for the installed network adapters, so I hope that somebody has a working LabVIEW code for that task... Smiley Sad
Greetings,
Gabs
0 Kudos
Message 23 of 39
(4,404 Views)
Maybe like this? 😉
Message 24 of 39
(4,399 Views)
Whao!!!! FIVE STARS are almost not enough Smiley Very Happy
Thanks a lot to Rainer and Jean-Pierre!!! This works perfectly!
Greetings from Happy Gabs
0 Kudos
Message 25 of 39
(4,391 Views)
My pleasure ! 😉
0 Kudos
Message 26 of 39
(4,386 Views)
Gabs are you still listening to this thread? If so, would you mind posting the VI you ended up with? I've tried the broadcast VI posted by Balze, but to no avail. It returns the computer's IP and 0.0.0.0, not my devices. I am connected with a crossover cable...
 
Michael
0 Kudos
Message 27 of 39
(3,933 Views)

Are you sure that the device that you are connected to has an IP address assigned?  If you are connected by way of a Xover cable, then you have your own mini network with only your PC and the device on it.  There is no DHCP server to dynamically assign an IP to that device, so it probably have a default IP of 0.0.0.0

I guess it's possible the PC could act as a DHCP server for the that mini network, but that would be over my head on how to set up.  All I know is that when I have connected a PC to a device by way of a cross over cable  (in my case a PXI to a cFP), I had to statically assign an IP to the device.



Message Edited by Ravens Fan on 11-28-2007 11:13 PM
0 Kudos
Message 28 of 39
(3,924 Views)
Hi Michael,
I used exactly the code from Rainer (Balze), it worked for me without modifications. One error source that I could think of is if your device is connected via an XPort. In that case the message you need to send with the broadcast is special bit mask (see the documentation of the XPort). If the device has no XPort, I hope that Ravens Fan's message helps you.

By the way, one thing that is really annoying about the broadcast routine is that it is much much slower than the same code in C++... very strange...

Best regards,
Gabs
0 Kudos
Message 29 of 39
(3,912 Views)


JeanPierre wrote:
You can specify the subnet when broadcasting. 255.255.255.255 is general but you can also use the subnet. If the network adapters are on subnets 192.168.1.* and 192.168.2.* then make two broadcasts at  192.168.1.255 and 192.168.2.255. The last digit 255 is the broadcast address for the subnet. When the subnet is specified the corresponding network adapter is automatically selected.


Message Edité par JeanPierre le 05-29-2006 02:42 PM


And from LabVIEW 8.2 on the UDP Open and UDP Multicast Open have an extra input "net address" that can be used to directly specify to which local network address (network adapter) the UDP refnum should be bound. That way you do not need to manipulate the broadcast address itself to only use the subnet address range.
 
Also the way to get all currently available network card IP addresses in LabVIEW since at least 7.0 is to use the String To IP node with an empty input and right clicking on the node and selecting Multiple Output. This will return an array of IP adresses with all currently active IP addresses on that computer (multiple network cards, WIFI, VPN adapter, etc). Without Multiple Output active you will get the default network adapter. That is also the adapter to which LabVIEW will bind the UDP refnum if no net address is specified (or in LabVIEW < 8.2 if you use a 255.255.255.255 braodcast address).
 
Rolf Kalbermatter


Message Edited by rolfk on 11-29-2007 09:42 AM
Rolf Kalbermatter
My Blog
0 Kudos
Message 30 of 39
(3,909 Views)