Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

IVI driver error: specified handle is invalid or of an incorrect type

I've attached a zip file with the entire workspace for the drivers, including the test program that I wrote (MotionStageTest.exe). I've also included the IVI Store xml file for the computer; I think that the fact that it didn't have the proper entries was what was giving you your errors. No I'm not particularly checking for errors in either the MCP_ReturnAvailableControllers () or MCP_Scan_Stages () routines, but I am single-stepping through them in the debugger, and get no errors anywhere. (I added checks after making the .zip file, and discovered none that way either). The errors in the STAGE_InitWithOptions () driver call (line 110) are consistant, however. If I make the call before MCP_Scan_Stages() there is no error, if I call it afterwards there is the error.
_

Download All
0 Kudos
Message 11 of 18
(1,659 Views)

Hi

 

I can't compile your MotionStageTest.prj as NVESD_Utilities.h file is lost. Please give me a complete project. 

0 Kudos
Message 12 of 18
(1,651 Views)

Sorry about that.

0 Kudos
Message 13 of 18
(1,639 Views)

Ok, I've figured it out - but it doesn't make any sense.

 

I found ConfigStoreExample.zip. (http://digital.ni.com/public.nsf/allkb/F25F9B0E8DA4BB2386256DEF00729F81 ).

I should be using "IviConfig_DisposeHandle (ConfigStoreHandle)" at the end of MCP_Scan_Stages() instead of "IviConfig_Close(); 

 

The problem is that IviConfig_Close() returns 0 (indicating no error) and causes things to crash, while IviConfig_DisposeHandle() returns -1074130400 (bad handle) and lets things work fine. If I compile the project found in ConfigStoreExample it also returns this value (that program simply ignores it). Go figure. 

0 Kudos
Message 14 of 18
(1,634 Views)

I am sorry but when I compiled, I got

 

Failed to open external module.

Aborted load of library "c:\Program Files\Level 1\Bin\NVESD_Utilities_dbg.lib"

 

 

0 Kudos
Message 15 of 18
(1,624 Views)

Hi pblase,

 

I am doing research about IviConfig_DisposeHandle function, I will give you my research result when I find the problem.

0 Kudos
Message 16 of 18
(1,621 Views)

Hi pblase,

 

The code (IviConfig_DisposeHandle(csHandle))in our example is wrong, as in IVI-3.5 specification section 5.2.3:

 

"The user must not pass a handle of type IviConfigStoreHandle as the value of the Handle parameter. The user may pass a handle of any other type. If a handle of type IviConfigStoreHandle is passed as the value of the Handle parameter, this function will return the Invalid Handle error. "

 

Since the IviConfigStoreHandle in this example is created by the IVI Engine, you must not call IviConfig_Close() on it. The IVI Engine will do that on process terminate. So, our modification of this example will be just deleting this line of code, leaving the IVI Engine closes the csHandle.

 

I hope this may be helpful for you. Also thanks for your help to find the problem.

 

Message 17 of 18
(1,603 Views)

Ok. I just hate to leave handles open.

Paul

0 Kudos
Message 18 of 18
(1,589 Views)