Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

IVI-COM

hi, all
 
I am using VISA2.4 from NI, and install IVI-shared-comcopents from IVI. after that, i  install Driver-ivicom-34401 from Agilent for my device34401,.  And i am using MS Visualstudio 60 with SP4 on WIN2K SP6.
 
 
!!!IMPORTANT!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
If you are using NI VISA version 3.3 or earlier, you may need to manually register the Basic Formatted I/O
component. This file is called BasFrmIO.dll and is located in C:\VXIPnP\VisaCom directory.
As noticed from ivi readme.txt listed above,   i registe this dll file by regsvr32 C:\VXIPnP\VisaCom\basfrmio.dll, mannually.
 
 
#import "IviDriverTypeLib.dll"
#import "IviDmmTypeLib.dll"
#import "visacom.tlb"
#import "Agilent34401.dll"
using namespace IviDriverLib;
using namespace Agilent34401Lib;
But in my vc project whose header file cotaing several lines above, i canot complie correctly .the IDE saying that: cannot open this file "visacom.tlb".  So i search my disk, and truly canot find this .tlb file,  i dot know HOW.
 
0 Kudos
Message 1 of 15
(9,354 Views)

so i want to convert from NIVisaCom.dll to VisaCom.tlb  by the tools TlbExp.exe supported bt Visual.Net from MS, but this little tools says that the dll file was not in correct format and canot be converd.:(

and so i google the VisaCom.tlb file from internet,   funny , i find one topic  reply by Agilent, the reply without any words,  but just with a attatced file VisaCom.tlb.   so download this file  and move to my  project location, compling and building was all okay 🙂  

 but,  ifi run the exe ,  it says Runtime error , and abnormal program teninate.    If  i debug the application in IDE , it says Unhandled exception in XXXX.exe Kernel32.dll and crashed:(  

0 Kudos
Message 2 of 15
(9,344 Views)
As I know, IVI-COM drivers from Agilent all require VISA COM software at runtime.  VISA COM is supported from NI-VISA 3.0.x .  Therefore your NI-VISA version (2.4?) is probably insufficient.  I recommend you to upgrade to the latest NI-VISA.
0 Kudos
Message 3 of 15
(9,337 Views)
thank u Makoto
 
that's a mistake of my spelling .
 i am using 4882 V2.4 and VISA 3.4.1 full version. both from NI.
 
now an inportant issue,  i  can not find the visacom.tlb file,     
i guess,  maybe the  visacom.tlb i have downloaded from Agilent website was wrong.
 
so any way can u or somebody sent a copy of this file?
0 Kudos
Message 4 of 15
(9,332 Views)

You can find GlobMgr.DLL placed at C:\VXIpnp\VisaCom directory.  Instead of importing from VisaCom.TLB, you can #import the same contents (Type Library info) from this DLL.  Now the GlobMgr.DLL is of VISA 3.0 spec, therefore it does match with the latest NI-VISA DLLs.

#import "C:/VXIpnp/VisaCom/GlobMgr.DLL"

 

0 Kudos
Message 5 of 15
(9,323 Views)
makoto:
 
both #import "C:\VXIPNP\VisaCom\GlobMgr.dll"  and #import "//"visacom.tlb"  can compile and build okay,  no question, and exe file can be generated.  But,  the problem was occured while running or debugging.
 
i step into these lines:
  if (FAILED(hr = dmm->Initialize(m_address.AllocSysString(), VARIANT_TRUE, VARIANT_TRUE, ""))){
   AfxMessageBox("Fail Initialize() ");   exit(1);
  }
 
i  debug  Initialize()  into a intermedia file---iviDriverTypeLib.tli :
inline HRESULT IIviDriver::Initialize ( _bstr_t ResourceName, VARIANT_BOOL IdQuery, VARIANT_BOOL Reset, _bstr_t OptionString ) {
    HRESULT _hr = raw_Initialize(ResourceName, IdQuery, Reset, OptionString);
    if (FAILED(_hr)) _com_issue_errorex(_hr, this, __uuidof(this));  <---Here--- Unhandled Exception in XXX.exe (KERNEL32.DLL) 
    return _hr;
}

can u give any suggestion about it?
0 Kudos
Message 6 of 15
(9,305 Views)

What error code (HRESULT) was returned from raw_Initialize() call ?

Also, how did you initialize the variable "dmm" ?

0 Kudos
Message 7 of 15
(9,288 Views)

initalizing process is as following, all was okay.

 HRESULT hr;
 try{
      if (FAILED(hr = CoInitialize(NULL))){               <------no question, hr= -858993460
         AfxMessageBox("Fail CoInitialize() method");
         return FALSE;
      }
   dmm = NULL;
      // Create a safe pointer for interface access
      if (FAILED(hr = dmm.CreateInstance(__uuidof(Agilent34401)))){
         AfxMessageBox("Fail CreateInstance() method");
         return FALSE;
      }
   }
   catch(_com_error err){
      AfxMessageBox (err.Description());
   }

 

  if (FAILED(hr = dmm->Initialize(m_address.AllocSysString(), VARIANT_TRUE, VARIANT_TRUE, ""))){
   AfxMessageBox("Fail Initialize() method");
   exit(1);
  }

the initialize() funtion goes into following ::initialize()

inline HRESULT IIviDriver::Initialize ( _bstr_t ResourceName, VARIANT_BOOL IdQuery, VARIANT_BOOL Reset, _bstr_t OptionString ) {
    HRESULT _hr = raw_Initialize(ResourceName, IdQuery, Reset, OptionString);  <---here, fitstly hr= -858993460 the same as before
    if (FAILED(_hr)) _com_issue_errorex(_hr, this, __uuidof(this));                            <--- but,  finally hr= -2147219965 and error occured 😞
    return _hr;
}

0 Kudos
Message 8 of 15
(9,285 Views)

The HRESULT code -858993460 (= 0xcccccccc) is very strange because it is an uninitialized junk value.  Does your code returns 0xcccccccc when calling CoInitialize() function?

Also I suspect the calling result of dmm.CreateInstance().  Does it surely return S_OK (= 0) and the "dmm" (probably a VC++ smart pointer, IAgilent34401Ptr type) contains a valid IAgilent34401 interface pointer address after the CreateInstance() call?  If it fails, your problem is at the initialization process of the IVI-COM Agilent34401 object instance. 

The error code -2147219965 (= 0x80040603) is likely categorized to VISA-COM error code area, but I could not find it in VISA specifications.  I also checked it with Error Lookup tool but no message was found therefore it was not a Microsoft error code too.

0 Kudos
Message 9 of 15
(9,283 Views)
As I drive the Agilent34401 IVI-COM driver, I could see the same error code 0x80040603 and its error description string was "Agilent34401: IO error: IDS_ERR_CLSID_UNAVAILABLE".  Although I don't know what componet class was tried to load, the symptom was genereted only when I attempt to connect the instrument through "ASRL1::INSTR".  No problem generated when "GPIB0::1::INSTR".  (Mind that I do not have 34401A right here, so other errors such as "ID query failed" were generated by connecting a different SCPI instrument just for connectivity check, but not a big deal here.  *IDN? query was surely sent if using GPIB.)
 
It is very strange, that when the IDS_ERR_CLSID_UNAVAILABLE (0x80040603) was generated ASRL resource was openned through VISA but *IDN? query was never sent.  I also confirmed that GlobMgr.DLL, BasFmtIO.DLL, Agilent34401.DLL are being REGISTERED in the system registry.  So I can't see what is causing the problem.
 
What IO resource type (GPIB, RS232) are you trying?  And I recommend you to contact Agilent support regarding the case when you use Agilent34401 IVI-COM driver with NI-VISA environment. 

このメッセージは 11-24-2005 02:49 PMに Makoto が編集しています。

このメッセージは 11-24-2005 02:50 PMに Makoto が編集しています。

0 Kudos
Message 10 of 15
(9,275 Views)