LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Avoid waiting of "create network stream writer" if no reader is running

Solved!
Go to solution

Unbenannt.pngHello there,

i want to start a network stream and i tried to understand this with the "simple network streams - Host/Target"

i've reduced the example in the way, that only the host ist sending data to the target.

For the real measurement system i want, that the host try to send all the time, also if the reader is not reachable.

In the example, if i try to run the host and not the target and change the values the create network stream writer don't pass any value, not even an error, so the whole program gets stucked.

Is there any possibility to skip this step (something like: after 1 second, if no reader was found restart)?

Kind regards,

Filos92

0 Kudos
Message 1 of 8
(4,204 Views)

If you set the Create Endpoint function with a TimeOut (other than the default -1, which waits for 7 weeks, at least), when the TimeOut expires without a connection, the function will return an Error.  You can use that Error to do whatever you want, such as loop back and wait again, or "proceed without a Network Stream Connection" (be sure to clear the Error -- the Clear Error function does a clean job of this).

 

Bob Schor

 

P.S. -- attaching a Project file for your project is almost useless, as it points to files on your hard drive.  Better would have been to say "I'm using the Simple Network Stream Example that ships with LabVIEW".  Sending a picture of a Block Diagram is also not as helpful as actual code, i.e. a .VI file.

0 Kudos
Message 2 of 8
(4,169 Views)

At first thanks for your quick awnser!

I'm sorry for the circumstances, hopefully this time the VIs works.

I'am a little confused because as long as no timeout is connected (and as long the reader is running) it works.

If i connect the default value of -1 it get stucked.

for every other value (1, 100, 1000) i get the timeout error.Unbenannt.png

0 Kudos
Message 3 of 8
(4,119 Views)

@Filos92 wrote:

I'am a little confused because as long as no timeout is connected (and as long the reader is running) it works.

Yes.  If the Reader is running when you try to connect with the Writer, the connection should immediately succeed, regardless of the TimeOut value.

If i connect the default value of -1 it get stucked.

If the Reader is not running, the default "Wait Forever" (or 7 weeks, whichever comes first) setting will wait a very long time before it times out!

for every other value (1, 100, 1000) i get the timeout error.

That's exactly the point!  When/if this occurs, your program can "tell" that the Reader is not running, and you can make a programmatic decision about what to do.  Suggestions are:

  • Repeat the whole thing 3 times, just in case the Reader is slow getting going, and then fail (this is what I did for my LabVIEW RT system).
  • Fail, giving a message "Hey, Dummy, the Reader needs to be turned on!".
  • Combine the above two approaches -- tell the Operator that the Reader is not running and offer some options, including "Start the Reader and Try Again", "Stop/Exit, Start the Reader, then Rerun the Program", or "Go have Dinner and Try Again Tomorrow".

The point here is that if you see an Error on the Error Line, you can "trap" it in a Case Statement (wire the Error Line to the Case Selector), and in the Error Case, you can place a Clear Error function and whatever code you want to use in the "Reader Is Not Running" case.

 

Bob Schor

0 Kudos
Message 4 of 8
(4,115 Views)

for every other value (1, 100, 1000) i get the timeout error.

 

Sorry, i was a little inaccurate here.

If the reader is running and no timeout is set it works. But if i set the timeout (even if i try -1 to wait forever) I get the timeout error even when the reader is running.

 

0 Kudos
Message 5 of 8
(4,107 Views)
Solution
Accepted by topic author Filos92

That seems strange to me.  Let me describe the system I have for Network Streams, and how it works for me (it may turn out to depend whether the Host or Remote is the one with the IP Address ...).

  • My Project is a LabVIEW RT Project, with the Host being My Computer and the Remote being a LabVIEW RT system running on a PXI Controller.
  • There are four Network Streams connecting Host and Remote.  A pair are Message Streams being sent to the other's Queued Message Handler.  One is a Data Stream sending continuous multi-channel Samples from Remote to Host for display and streaming to disk (on the Host).  The final Stream contains Point-in-Time Events (like digital I/O line changes, button presses, State Machine changes, etc.).
  • The Remote generally starts running first (the PXI is set to auto-run its program when turned on).  The first thing it does is to Initialize Network Streams, using the form of Create Network Stream Endpoint that does not specify the URL.  The four Streams are created in parallel, with a 15 second timeout -- if they all complete without error, then the connection with the Host has been established and the loop exits.  Otherwise, the Error is cleared and we repeat (this is in a While Loop).
  • The Host similarly starts with Initialize Network Streams.  This uses the form of Create Network Stream Endpoint that specifies the URL of the Remote.  [Note that the Host starts one Writer and three Readers, but all have the same "style" of Create Endpoint, requiring the URL].  Here we try to create the Endpoints in series (so if any error, they all error), again with a 15 second timeout.  If an Error occurs, we try again, but here we are in a For Loop with N = 3.  If we fail three times, we exit with the Error set, and the Main Program informs us and aborts.

So ordinarily, the Remote is running and waiting, and we have no problems.  However, when the Host ends, we tell the Remote to reboot, which can take a few seconds to accomplish.  In some instances, we tell the Host to "Start over again" -- the Host code stays in memory, the Remote is told to reboot, and then the Host once again calls its Initialize Network Streams routine, but now the Remote is not (yet) running (as it is busy rebooting).  What we observe is that the Host "hangs" for 20-30 seconds, then starts running, having made the connection with the Remote.

 

Sorry for the long-winded explanation.  It is curious to me why you are not seeing a comparable behavior.  However, if you have Network Streams running in both directions and you are trying to establish them "bi-directionally" (where each side has initialization code specifying the URL of the other side) instead of "uni-directionally" (where all the URL specifications are on either the Host or Remote, as I've done), there may be some "interesting" behavior, depending on "Who goes First".

 

Bob Schor

Message 6 of 8
(4,089 Views)

I'm very thankfull for your effort.

I will test your tips as soon as possible, but i'm not in my institute for the next time.

So I can only responde in a few days, sorry.

But up to then,

many many thanks for your help!

0 Kudos
Message 7 of 8
(4,081 Views)

I didn't solved the problem for Network streams. If i set a timeout nothing happens anymore.

But I solved it by using a TCP connection. Again thanks for your help!

0 Kudos
Message 8 of 8
(4,056 Views)