AnsweredAssumed Answered

Problem running code to talk to U2653A modules

Question asked by pennantmike on Nov 5, 2013
First off, I'm using Visual Studio 2010, C++, Windows7.

So far I've successfully written a simple test program to talk to four U2653As, based upon Agilent's own sample code.

Now I'm copying the elements of that test code into my main software (an MFC application, statically linked to ATL), and it's compiling, but crashing as in the attached screenshot.

The code excerpt is as folllows >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

#import "GlobMgr.dll"               no_namespace // I/O funtionality
#import "IviDriverTypeLib.dll"     no_namespace // IVI inherent functionality
#import "agu265x.dll"               no_namespace // Instrument specific functionality


IAgilentU265xPtr spAgDrvrSlot1;
//IAgilentU265xPtr spAgDrvrSlot2;
//IAgilentU265xPtr spAgDrvrSlot3;
//IAgilentU265xPtr spAgDrvrSlot4;


CCMDS::CCMDS( CString& strDeviceId, CString& strDeviceName, HANDLE hDeviceHandle,
                 ComWrapper_c Db, GobList_t& rGobList, CUsbInterface* pInterface )
     : CUSBDevice( strDeviceId, strDeviceName, hDeviceHandle, pInterface )
{
     // Create the items for the device
     AddLampItems( strDeviceId, Db, rGobList );

     // Must first call either CoInitialize or CoInitializeEx to initialize COM
     //HRESULT hr = S_OK;
     //hr = CoInitialize( NULL );
     //if ( hr != S_OK )
     //{
     //     if ( hr == S_FALSE )
     //     {
     //          AfxMessageBox( "Com Already Initialised" );
     //     }
     //     else
     //     {
     //          AfxMessageBox( "Co-initialise Failed" );
     //     }
     //}

     // Create and Initialise instances of the Agilent driver for
     // each of the four U2635A I/O modules in the U2781A rack
     spAgDrvrSlot1.CreateInstance( __uuidof( AgilentU265x ) );
     //spAgDrvrSlot2.CreateInstance( __uuidof( AgilentU265x ) );
     //spAgDrvrSlot3.CreateInstance( __uuidof( AgilentU265x ) );
     //spAgDrvrSlot4.CreateInstance( __uuidof( AgilentU265x ) );

     try
     {
          *spAgDrvrSlot1->Initialize( "USBInstrument1", VARIANT_FALSE, VARIANT_TRUE, "" );*
          //spAgDrvrSlot2->Initialize( "USBInstrument2", VARIANT_FALSE, VARIANT_TRUE, "" );
          //spAgDrvrSlot3->Initialize( "USBInstrument3", VARIANT_FALSE, VARIANT_TRUE, "" );
          //spAgDrvrSlot4->Initialize( "USBInstrument4", VARIANT_FALSE, VARIANT_TRUE, "" );
     }
     catch ( _com_error e )
     {
          AfxMessageBox( "Driver Initialise Failed" );
     }
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

Can anybody shed any light on why the "*spAgDrvrSlot1->Initialize(...)*" causes such a crash?

Best Regards
Mike.

Attachments

Outcomes