LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

CNVCreateBufferedWriter - Could not complete operation in specified time

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?

Vix
-------------------------------------------
In claris non fit interpretatio

-------------------------------------------
Using LV from 7
Using LW/CVI from 6.0
0 Kudos
Message 1 of 40
(3,852 Views)

I haven't been able to solve this problem yet.

Could someone help me?

Vix
-------------------------------------------
In claris non fit interpretatio

-------------------------------------------
Using LV from 7
Using LW/CVI from 6.0
0 Kudos
Message 2 of 40
(3,827 Views)

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

0 Kudos
Message 3 of 40
(3,815 Views)

Hi NickB,

you're right: my post is a little confused.

 

Here is a more complete code snippet:

  • wait until network 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.));

 

  • create the process if it doesn't exists

errChk(CNVProcessExists (processName, &isExistent));
if (!isExistent) {
   errChk(CNVNewProcess (processName));

}

  • create a variable called "type" if it doesn't exists

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));

 

  • start process and wait until is running

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));

}

 

  • create buffered writer

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"

Vix
-------------------------------------------
In claris non fit interpretatio

-------------------------------------------
Using LV from 7
Using LW/CVI from 6.0
0 Kudos
Message 4 of 40
(3,810 Views)

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

0 Kudos
Message 5 of 40
(3,804 Views)

If I'm right I've never tried this, so I'll try ASAP and I'll let you know.

Vix
-------------------------------------------
In claris non fit interpretatio

-------------------------------------------
Using LV from 7
Using LW/CVI from 6.0
0 Kudos
Message 6 of 40
(3,801 Views)

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

Vix
-------------------------------------------
In claris non fit interpretatio

-------------------------------------------
Using LV from 7
Using LW/CVI from 6.0
0 Kudos
Message 7 of 40
(3,792 Views)

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

0 Kudos
Message 8 of 40
(3,790 Views)

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)

Vix
-------------------------------------------
In claris non fit interpretatio

-------------------------------------------
Using LV from 7
Using LW/CVI from 6.0
0 Kudos
Message 9 of 40
(3,787 Views)

Unfortunately, I haven't been able to solve this problem yet...

Vix
-------------------------------------------
In claris non fit interpretatio

-------------------------------------------
Using LV from 7
Using LW/CVI from 6.0
0 Kudos
Message 10 of 40
(3,769 Views)