Example Code

Using Network Streams to Check the Connection Between a Host (e.g. PC) and a Target (e.g. cRIO)

Products and Environment

This section reflects the products and operating system used to create the example.

To download NI software, including the products shown below, visit ni.com/downloads.

    Software

  • LabVIEW Real-Time Module
  • LabVIEW

Code and Documents

Attachment

Overview

The example demonstrates how to check the network connection between a host and a target application.

 

Description

If you build a system that involves multiple targets that are connected with a network connection, it is imperative that you can monitor the network connection. If the status of the network connection is not monitored, it is hard to know if no message is received because there was no need for communication or if the message could just not have been received because of problems with the network connection.

network communication.png

The system depicted above consists of a personal computer that is used for monitoring and configuration and a CompactRIO system.

 

To monitor the network connection the example shows the use of Network Streams. Network Streams are a National Instruments technology that is able data with high throughput as well as with low latency when needed. Also Network Streams are lossless and have network monitoring functions included and can automatically reestablish a interrupted network connection.

Network Streams are normally used to - as you would expect - communicate over the network. But you can also use a Network Stream connection inside a target (mostly for demonstration purposes). Therefore the example uses only one VI that demonstrates both endpoints of the network connection monitoring. Of course this can be adapted to real world use cases putting one part of the algorithm on the host and the other part of the algorithm on another target, e.g. a Real-Time target like the CompactRIO platform.

 

Requirements

 Software

  • LabVIEW 2012 Base Development System (or compatible)
  • (Optional) LabVIEW 2012 Real-Time Module (or compatible)

 Hardware

  • No hardware is necessary to use this example VI

 

Steps to Implement or Execute Code

  1. Open the attached file
  2. Run the VI
  3. Stop the target to simulate a connection loss
  4. Watch the connection status go to red 

 

Additional Information or References

Check Network Connection with Network Streams - Front Panel.png

 

Check Network Connection with Network Streams - Block Diagram.png

 

White Paper: Lossless Communication with Network Streams: Components, Architecture, and Performance
http://www.ni.com/white-paper/12267/en/

 

**The code for this example has been edited to meet the new Community Example Style Guidelines. The edited copy is marked with the text 'NIVerified'. Read here for more information about the new Example Guidelines and Community Platform.**

Marshall B
Applications Engineer
National Instruments UK & Ireland

Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.

Comments
PGP
Member
Member
on

BS

IainGE
Member
Member
on

worked for me! thanks