11-05-2010 08:34 AM
Using CVI 2009 SP1 I developed an application that uses Network Variable Engine:
At the beginning of main I wait in a do-loop until the Variable Engine is running
t_start = Timer(); do { CNVVariableEngineIsRunning(&running); if (!running) { t_rem = 20.0 - (Timer() - t_start); if (t_rem > 0.) Sleep(100); //100 ms } } while (!running && (t_rem > 0.));
Then I create a buffered subscriber, previously checking that the process exists and is running
CNVProcessExists (processName, &exists); if (!exists) { CNVNewProcess (processName); } CNVProcessIsRunning (processName, &isRunning); if (!isRunning) { CNVStartProcess (processName); } CNVCreateBufferedWriter (NetVarPathname, ConnTransferredCallback, ConnStatusCallback, NULL, 10, 10000, 0, bufferedWriter);
This application works perfectly when I launch it as standalone application.
But If I launch it at the Windows boot time through Start >> Programs >> Startup, CNVCreateBufferedWriter( ) returns -6337 (The network variable process was not found or is not responding).
Does CNVStartProcess( ) need a delay time?
How can I avoid this annoying error?
11-08-2010 03:26 PM
Yes, CNVStartProcess signals the network variable process to start running but does not wait for it to run. In your case, you should poll using CNVProcessIsRunning after calling CNVStartProcess to wait until the process is running. The "process" is hosted in the Network Variable Engine (NVE) which on Windows is a service that automatically startsup. The NVE is probably still loading all your processes and variables during system startup and so it is taking longer to run the process compared to when you explicitly run your program.
11-09-2010 01:35 AM
Yes, CNVStartProcess signals the network variable process to start running but does not wait for it to run. In your case, you should poll using CNVProcessIsRunning after calling CNVStartProcess to wait until the process is running.
Thanks for the information. I suggest NI to add this little reminder to CNVStartProcess( ) help.
The "process" is hosted in the Network Variable Engine (NVE) which on Windows is a service that automatically startsup. The NVE is probably still loading all your processes and variables during system startup and so it is taking longer to run the process compared to when you explicitly run your program.
For this reason I poll using CNVVariableEngineIsRunning( ) at the beginning of my application: the execution goes on only after CNVVariableEngineIsRunning( ) returns TRUE.
Does it returns TRUE before the NVE is completely loaded?
11-16-2010 04:26 AM
I did some tests, and unfortunately even polling with CNVProcessIsRunning doesn't solve the problem
Some times (every 5 or 6 Windows boots) I find the same problem: CNVCreateBufferedWriter( ) returns -6337 even if looking to all the previous functions the NVE is running, the process exists and is running
11-16-2010 03:55 PM
Hi Vix,
We were able to reproduce this problem here and I have filed corrective action request #258354. Unfortunately, there is no clean workaround for this right now. You will likely need to catch the error, wait, and try again, and continue with this process until the error no longer occurs.
11-17-2010 01:27 AM
Hi Tanya,
happy to hear that the problem has been reproduced. It's the first step to the resolution.
I'm doing some kind of workaround in the meantime.
Please let me know in this thread when this bug is fixed
11-17-2010 01:26 PM
CNVProcessIsRunning only checks if the process is configured to run when the Variable Engine is started. In most cases, this is a good indicator of whether the process is running or not because the Variable Engine is a Windows service that automatically startsup when Windows starts, and then it loads all the processes configured to run. But in cases where this function is called during system startup, it is unreliable because the Variable Engine could still have not loaded the process but CNVProcessIsRunning returns TRUE if the process is configured to run. A workaround for this problem and correct indicator of the availability of the process is to programmatically browse to the process:
CNVBrowser browser;
CNVCreateBrowser(&browser);
CNVBrowse("\\\\localhost\\your-process-name");
CNVDisposeBrowser(browser);
If CNVBrowse succeeds, then the process is running. Please let us know if you run into issues with this workaround.
11-24-2010 02:02 AM
CNVProcessIsRunning only checks if the process is configured to run when the Variable Engine is started...
I think this advice should be added to the function help.
But in cases where this function is called during system startup, it is unreliable because the Variable Engine could still have not loaded...
As I write in the first message, the first function I call in my application is CNVVariableEngineIsRunning( ), then I wait until it returns "is running". Why does the NVE could still have not loaded after "is running" has been returned?
A workaround for this problem and correct indicator of the availability of the process is to programmatically browse to the process:
CNVBrowser browser;
CNVCreateBrowser(&browser);
CNVBrowse("\\\\localhost\\your-process-name");
CNVDisposeBrowser(browser);
If CNVBrowse succeeds, then the process is running. Please let us know if you run into issues with this workaround.
Done. After this, I've never seen the error anymore... but I'll check again.
03-20-2019 12:28 AM
Hi Vix,
Have you found a permanent solution for this issue?
I am facing similar issue when the program is set as a startup DLL in Labwindows CVI Real Time running on a PXI. The program works fine otherwise (when not set as startup).
CNVVariableEngineIsRunning( ) function is not supported in real time. Any suggestions to solve this?.
As an interim solution i'm now using a delay of 60secs at the start of RT main function so that the NV engine gets started by the time variables are accessed in the code.
03-20-2019 01:48 AM
I dind't find any other solution, unfortunately.