06-17-2013 07:15 AM
Hi
I wrote two vis that communicates through network streaming, They are working fine. I made an application (Build .exe) and try to run them as two stand alone applications. They can't allocates each other.
Probably, the definition of the endpoint URL should be changed because of the building.
Please advice.
Gabi
Solved! Go to Solution.
06-17-2013 02:55 PM
Do a search on the NI site for Specifying Network Stream Endpoint URLs, and see if that answers your question. If not, say a bit more about the nature of your connection -- is it between two PCs, within a PC, between a PC and an RT Target? Do you have one or multiple streams?
06-18-2013 02:34 AM
Hi
I read the article, I didn't get an answer.
I attached a simple project to demonstrate the problem. I took two vi from the Labview examples, Host.vi and Target vi. The two vi are on the same PC. The vi runs fine. I compiled both of them (Host.exe and Target.exe) The two exe can't identify each other.
Regards
Gabi
06-18-2013 08:47 AM
Congratuations -- you have run into a very subtle point that NI has not adequately explained! The "formal" name of an endpoint is the following:
ni.dex://host_name:context_name/endpoint_name. As NI explains somewhere, the protocol name, "ni.dex:", is not required. They also explain that, where the host_name is "localhost", it also isn't required. What is less clear is "What is the context_name?"
This turns out to be the name of the application under which the particular endpoint is running. When you are running in Development mode, programming your application and testing it by pressing the Run Arrow, the application is "LabVIEW" (technically, it is "LabVIEW.exe", but the .exe is also not necessary). As this is the (undocumented) Default context_name, you don't need to put it in the string.
However, when you build Executables, the context changes! To clarify, I built executables called "My Host" and "My Target" (mainly so there would be no mistake between the VI, "Host.vi", and the executable, "My Host.exe" instead of "Host.exe"). In Target.vi, I changed the Stream strings to start //localhost:My Target, and in Host.vi, I changed the specification for the Target URL to include ":My Target". Snippets showing these changes are included here.
Incidentally, I could not get the Host and Target VIs you included in your ZIP file to work in Development mode, so I started over, taking the Host and Target VIs from my LabVIEW 2012 Examples directory, copying them to my LabVIEW folder in My Documents, and building a new Project.
Note that, as written, this version of the code will work only as an Executable (since the context_name is no longer LabVIEW). If you want to write a routine that will work in both Development and Run-Time environments, you just need to examine some properties of the Application. I didn't think about doing this until I was already writing this note, which is why this code isn't in the earlier examples. However, it is probably better written as a sub-VI, as it should be used by both the Host and Target VIs.
Good luck. Let us know if this fixes the problem for you.
Bob Schor
06-18-2013 10:10 AM
Bob
Thanks for your prompt reply.
Its great, when someone understand clearly the problem and gives the right answer - THANKS
Gabi
06-18-2013 11:39 AM
You are welcome. [Consider giving it a Kudo, but only after you read this message ...].
One "bug" in the solution concerns the Getting Context sub-VI. If you run the same sub-VI on both the Host and Target, it won't work, since on the Host it will return "My Host", and on the target it will return "My Target". That's what comes of being Too Clever For Your Own Good! The fix, of course, is to not use App.Name, but to simply put the constant string ":My Target" in the Run Time System case statement. [The other case, Default, returns a blank string since I'm using "Use Default if Unwired" -- since the "other case" is "Development Mode", and the "correct" context, "LabVIEW", is also the default, a blank works here].
BS
06-18-2013 01:53 PM
Sigh. I just found another stupid error in the "get the Context" snippet I posted. The code was supposed to remove the .exe extension, but I was day-dreaming when I clicked on the Strings palette. Here is both the Code I Intended (which gets the App Name of the Run Time System from the Property Node, adds a colon, and strips off .exe) and the Better Code that works on both the Host and Target, adding the (fixed) context of the Target if running in an Executable.
The Good News is that at least I found it before too many people were misled ...
BS
10-12-2015 10:42 PM - edited 10-12-2015 10:42 PM
Hey Bob,
Is there a way to communicate using network streaming from an executible to a VI in development mode? I can't seem to nut it out.
10-13-2015 01:56 PM
Hi Hornless.Rhino,
Can you create a new forum post for this question? This is an old thread, and we are not able to track this thread any longer.
05-08-2020 09:20 AM
Can you post the source code for this? I still can not get it to work
Thanks in advance!