RIO Developer Essentials Guide for Academia
RT PC code example
Check Internet access (HTTP method)
Determine whether or not Internet access is available by attempting an HTTP connection to the "Microsoft Network Connectivity Status Indicator" (NCSI) web service.
Determine whether or not the RT target can connect to other Internet hosts
Validate the connection by checking the returned string from the web service
Keep in mind
Requires the “HTTP Client with SSL Support” Academic RIO Device software set add-on
If your application does not otherwise require HTTP services, use the alternative
TCP-based Internet access check method which simply checks if it is possible to connect to the NCSI service LabVIEW block diagram elements
Locate these elements with "Quick Drop" (press Ctrl+Space and start typing the name); click on an icon to see more sample code that uses that element:
Connect your Academic RIO Device to your PC using USBLAN, Ethernet, or Wi-Fi. NOTE: Not all Academic RIO Devices have Ethernet and Wi-Fi connectivity options.
Download and unpack the
rt_check-internet-access-http.zip (for use with NI myRIO 1900)
archive, and then double-click the ".lvproj" file to open the project. NOTE: This project was written for a NI myRIO 1900 or NI ELVIS III connected by USBLAN at IP address 172.22.11.2.
If you are using a different IP address or another Academic RIO Device (Example: NI myRIO 1950 or NI RIO Control Module) do the following:
NIELVISIII-rt_check-internet-access-http.zip (for use with NI ELVIS III)
If using the NI myRIO 1950 or NI RIO Control Module start with the NI myRIO 1900 Archive.
Different IP address: Right-click on the "NI myRIO 1900" Device, choose "Properties", and then enter the new IP address
Right-click on the top of the project hierarchy, select "New Targets and Devices", keep the "Existing target or device" option, and then find and select your particular device
Select all of the components under the "NI myRIO 1900" device: click the first one and then shift+click the last one
Drag the selected components to the new device
Right-click the "NI myRIO 1900" device and select "Remove from project"
Run “RT Main” and “PC Main” and observe the following:
Each VI executes the same subVI “check internet access (http).vi” once every five seconds and displays its result as the “Internet OK” Boolean indicator
Each VI also executes the same subVI “
show available IP addresses.vi” once every half second and displays its results Click the “dot-decimal notation?” control to switch between the machine name and the IP address
If you are using the USB cable to establish the network link between the Academic RIO Device and the PC, you should observe that the PC is host #1 (172.22.11.1) and the RT is host #2 (172.22.11.2) on the USBLAN network 172.22.11.0
“PC Main” will likely show other networks such as your wireless connection
“RT Main” will also show address 127.0.0.1 (“localhost”) – this address is for loopback testing and is internal to the RT target (in fact, every network host has its own loopback address)
Enable the Academic RIO Device wireless connection to a consumer-grade wireless router (press the Device wireless button if connection was established earlier) while “RT Main” is running:
A third IP address appears
If your wireless connection provides Internet service (e.g., with your consumer-grade wireless router) you can expect to see the “Internet OK” indicator activated
Try disabling your PC network connection to see the “Internet OK” indicator go out
“check Internet access (http)” VI
“GET” VI sends web request to the Microsoft “Network Connectivity Status Indicator” web service
Conclude Internet access is OK when returned webpage body is the string “Microsoft NCSI”
Case structure implements standard error behavior
Same VI runs without modification on RT or PC
Process Loop #1: run “show available IP addresses” VI every half second
Process Loop #2: run “check Internet access (http)” VI every five seconds
Use local variable technique to stop both process loops from one button
PC Main – same code as “RT Main”
Stop parallel process loops
Use local variable
Set mechanical action of “stop” button to “Switch When Pressed”
For more information
Appendix K: Network Connectivity Status Indicator and Resulting Internet Communication in Windows Vista ( https://technet.microsoft.com/en-us/library/cc766017)
A complete discussion of the Microsoft NCSI web service.
"check internet connection" thread on NI Community Forum ( http://forums.ni.com/t5/LabVIEW/check-internet-connection/td-p/1724074)
The original idea for the example code presented here.
© 2018 National Instruments. All rights reserved.