Community Documents

cancel
Showing results for 
Search instead for 
Did you mean: 

Re-Connectable Network Communication Usable in Time Critical Loops

Greetings fellow LabVIEW enthusiasts,

I have attached a .zip file containing LabVIEW 2011 code which implements a network communication protocol with the following features:

  • Lossless (buffered) or single-value (most current) communication
  • Communication of any data type through the use of variants
  • Ability to use read and write VIs within time critical loops (network communication occurs in a background process)
  • Automatic reconnection after a connection is dropped from either endpoint
  • Time synchronization across systems with different system times (approximate)

Network communication is implemented using LVOOP. One LVOOP class (NetworkStreamReader.lvclass) is used to create a reader endpoint; the other LVOOP class (NetworkStreamWriter.lvclass) is used to create a writer endpoint. The underlying communication protocol is LabVIEW's Network Stream. For this reason, said implementation is limited to 1:1 connections, and data can only be passed unidirectionally through one connection. However, more than one endpoint can exist on a target, allowing for bidirectional communication with the use of one reader and one writer endpoint on a target.

The .zip file contains the following folders:

  • Reader: Contains NetworkStreamReader.lvclass and associated files.
  • Writer: Contains NetworkStreamWriter.lvclass and associated files.
  • Shared: Contains code shared by NetworkStreamReader.lvclass and NetworkStreamWriter.lvclass.
  • Examples: Contains an example reader and writer application which communicates through localhost (for testing), as well as some simple supporting files. Simply open both the reader and writer and run them; try stopping and re-starting one of the applications and observing what happens.

This code has been successfully used in an Autonomous Robotic Sailing vehicle, so it is tried and tested. However, I take no responsibility for any damage or injury caused directly or indirectly by use of said software.

If you have any suggestions for improvement of the implementation or the functionality of this code, please let me know. If you run into any issues with the code or have any questions, also let me know.

Happy coding,

Jared Kirschner

Electrical and Computer Engineer

Certified LabVIEW Developer

www.jaredkirschner.com

Comments
drjdpowell
Trusted Enthusiast Trusted Enthusiast
Trusted Enthusiast
on

Have a look at this conversation about opening references to "deamons".  The Actor Framework launched it's "Actors" in the same way you lauch your deamons, but it was changed for a couple of reasons.  As a simple change, drop 0x40 as an option on "OpenVI Ref" as it is not intended for the way you are using it (0x40 returns a reference to a pool of clones, rather than a specific clone, so you are creating multiple pools of clones yet only using one clone per pool).

-- James

jkirschner
Member
Member
on

James,

Thanks for the feedback. I'll look into this more when I get the chance. I'll post a corrected version at that time.

Jared

PrimaryKey
NI Employee (retired)
on

Very cool implementation - not everything has to be implemented in actor framework. After all somone needs to also understand the background. The code here is elegant and well designed. Kudos

Piotr Kruczkowski
Certified TestStand Architect
Certified LabVIEW Architect
Ancle
Member
Member
on

Dear Sir,

If I have multiple clients(readers) and clients can send data to server(writer), how to modify your code? Thank you!

B/R

Ancle

Ancle
Member
Member
on

Dear Sirs,

I test the example in development mode. It works fine. However, when I build into application file to run. It shows attached error message. How can I resolve this problem? Thank you.

reader error.PNG

writer error.PNG

B/R

Ancle

Contributors