Hi all,
I'm having some trouble with getting a visa session for an IVI driver. I was wondering if anyone can see what I'm doing wrong here. Here is the code that is giving me a problem:
ViStatus _VI_FUNC XanXTR_InitWithOptions( ViRsrc resourceName,
ViBoolean IDQuery,
ViBoolean resetDevice,
ViConstString optionString,
ViSession *newVi )
{
ViStatus error = VI_SUCCESS;
ViSession vi = VI_NULL;
ViChar newResourceName[ IVI_MAX_MESSAGE_BUF_SIZE ];
ViChar newOptionString[ IVI_MAX_MESSAGE_BUF_SIZE ];
ViBoolean isLogicalName;
// Debug code.
ViChar setup[ BUFFER_SIZE ],
masterchannelAddress[ BUFFER_SIZE ];
if( newVi == VI_NULL )
{
Ivi_SetErrorInfo( VI_NULL, VI_FALSE, IVI_ERROR_INVALID_PARAMETER,
VI_ERROR_PARAMETER5,
"Null address for Instrument Handle" );
checkErr( IVI_ERROR_INVALID_PARAMETER );
}
*newVi = VI_NULL;
checkErr( Ivi_GetInfoFromResourceName( resourceName,
( ViString )optionString,
newResourceName,
newOptionString, &isLogicalName ) );
/* create a new interchangeable driver */
checkErr( Ivi_SpecificDriverNew( "XanXTR", newOptionString, &vi ) );
// PROBLEM on occurs in following line: Inserted for debugging.
viSScanf(vi, "MCHADDR:1", "%*[^:]:%[0-9]%[^\n]", masterchannelAddress, setup);
/* init the driver */
checkErr( XanXTR_IviInit( newResourceName, IDQuery, resetDevice, vi ) );
if( isLogicalName )
{
checkErr( Ivi_ApplyDefaultSetup( vi ) );
}
*newVi = vi;
Error:
if( error < VI_SUCCESS )
{
Ivi_Dispose( vi );
}
return( error );
}
If I try to step through the code, I get a pair of general protection faults and then the given session or object reference is invalid error when the viSSprintf function call is made.
Does anyone have some suggestions on what to look into to trouble shoot this further or better yet see a glaring omission of mine?
Thanks for taking the time to read through my problem.