07-04-2011 02:07 AM
I've developed an application that reads from Network Variables and it works as expected (CVI 2010).
Before reading I check that the Network Variable Engine is running with this code (see Known Isuue 258354)
errChk (CNVCreateBrowser(&browser));
error = CNVBrowse(browser, processName);
if (error == 0) isRunning=1;
else isRunning=0;
errChk (CNVDisposeBrowser(browser));
Then I create the process using
CNVNewProcess (processName);
and the variable with
CNVNewVariable (processName, "myVarName");
The problem is that sometimes the process is created but the variable is not (I see this in NI Distributed System Manager) but CVI doesn't return any error.
And so when I call CNVCreateBufferedWriter() it gives the run-time error "Could not complete operation in specified time".
When this situation happens, I must restart the Operating System and everything works fine. If I don't reboot my PC my application doesn't work even if I relaunch it several times.
After an OS startup, if the program works the firs time I launch it once, it works every time I launch it. If it doesn't work the first time, it never works unless I reboot my Windows 7 Professional.
What could be the problem?
Is there any additional debug I can perform?
07-12-2011 06:17 AM
I haven't been able to solve this problem yet.
Could someone help me?
07-12-2011 01:33 PM
Hey Vix -
I'm a little confused by what you've described. My understanding is that you are trying to wait until you can be sure that a particular process have been loaded by the Network Variable Engine. However, the code you've shown tries to create that same process once you've browsed for it? Without a little more context, that seems backwards to me.
Are you polling until a process you know about is available and then creating a different process?
Could you post a more complete code snippet exhibiting the problem you're seeing?
Thanks -
NickB
National Instruments
07-13-2011 01:18 AM
Hi NickB,
you're right: my post is a little confused.
Here is a more complete code snippet:
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.));
errChk(CNVProcessExists (processName, &isExistent));
if (!isExistent) {
errChk(CNVNewProcess (processName));
}
errChk(CNVVariableExists (processName, "type", &isExistent));
if (!isExistent) {
errChk(CNVNewVariable (processName, "type"));
}
errChk(CNVCreateScalarDataValue (&OPCboard->type.gdata, CNVUInt8, 0));
errChk(CNVSetVariableAttribute (processName, "type", CNVVariablePrototypeAttribute, OPCboard->type.gdata)); // set Variable Type to 'Unsigned char'
errChk(CNVSetVariableAttribute (processName, "type", CNVVariableSingleWriterAttribute, 1));
errChk(CNVSetVariableAttribute (processName, "type", CNVVariableServerBufferMaxItemsAttribute, 1));
if (!isRunning) {
errChk (CNVStartProcess (processName));
errChk (CNVCreateBrowser(&browser));
t_start = Timer();
isRunning = 0;
do {
error = CNVBrowse(browser, processName);
if (error == 0) isRunning=1;
if (!isRunning) {
t_rem = 20.0 - (Timer() - t_start);
if (t_rem > 0.) Sleep(100); //100 ms
}
} while (!isRunning && (t_rem > 0.));
errChk (CNVDisposeBrowser(browser));
}
errChk (CNVCreateBufferedWriter (NetVarPathname, DataTransferredCallback,
NetVarStatusCallback, &(OPCboard->info.IPaddr), 10, 10000, 0, &OPCboard->type.bufferedWriter));
and this gives the run-time error "Could not complete operation in specified time"
07-13-2011 08:51 AM
Vix -
The only thing that I might try differently is to start the process and wait until it is running before checking for or creating the variable. Have you already tried this at some point in the past?
NickB
National Instruments
07-13-2011 09:25 AM
If I'm right I've never tried this, so I'll try ASAP and I'll let you know.
07-15-2011 01:50 AM
Starting the process and waiting until it is running before checking for or creating the variable doesn't solve the problem. I find the same error in CNVCreateBufferedWriter
07-15-2011 08:29 AM
You can also use the CNVBrowser to wait until the variable is created, before trying to created the buffered writer. Perhaps you're running into the same issue as before, but now for the variable?
If you can post some source code that reproduces the issue, I can take a look here. Maybe this way I can come up with some better suggestions...
NickB
National Instruments
07-15-2011 09:15 AM - edited 07-15-2011 09:25 AM
The first call of CNVBrowse() before trying to create the buffered writer returns error -6396 (0xffffe704) - Unexpected error occurred.
Is the error number useful to find the reason of the problem?
The following calls return 0, so the variable should exists, but is not visible in NI Distributed System Manager (where only the process exist and is running but is "not stoppable" and I don't know why).
Then CNVCreateBufferedWriter returns the same error.
I've never seen this issue with the same code on XP machine, so I think there is something strictly related to Win 7 (64 bit)
07-26-2011 06:46 AM
Unfortunately, I haven't been able to solve this problem yet...