Thanks. It turned out that the problem was that (after I fixed the obvious pointer problem) I was calling "RangeTableNew " with "io" and not "vi". This results in a "General Protection Fault" problem (see attached).
Which leads me to the next question: when does one use io (generated by io = Ivi_IOSession(vi);) and when use vi (the ViSession passed in and originally generated in the Init function by Ivi_SpecificDriverNew()?
Thanks
Paul
/*****************************************************************************
* Function: NPESP300_DefaultInstrSetup
* Purpose: This function sends a default setup to the instrument. The
* NPESP300_reset function calls this function. The
* NPESP300_IviInit function calls this function when the
* user passes VI_FALSE for the reset parameter. This function is
* useful for configuring settings that other instrument driver
* functions require.
*
* Note: Call this function only when the session is locked.
*****************************************************************************/
static ViStatus NPESP300_DefaultInstrSetup (ViSession vi)
{
ViStatus error = VI_SUCCESS;
IviRangeTablePtr rangeTablePtr;
/* Invalidate all attributes */
checkErr( Ivi_InvalidateAllAttributes (vi));
if (!Ivi_Simulating(vi))
{
ViSession io = Ivi_IOSession(vi); /* call only when locked */
checkErr( Ivi_SetNeedToCheckStatus (vi, VI_TRUE));
/*=CHANGE:===============================================================*
Change the following command string so that it executes the default
setup for your instrument. The example does the following:
*CLS clears the event/status registers
*ESE 1 sets the standard event status enable register to recognize
operation complete.
*SRE 32 sets the service request register to enable a service
request on operation complete
These settings are required for the default implementation of the
WaitForOPCCallback to work correctly.
viCheckErr( viPrintf (io, "*CLS;*ESE 1;*SRE 32"));
*============================================================END=CHANGE=*/
//Create range tables
rangeTablePtr = VI_NULL;
checkErr( Ivi_RangeTableNew (vi, 5, 1, VI_TRUE, VI_TRUE, &rangeTablePtr));
//Max/Min for (0) Position; (1) Velocity; (2) Acceleration; (3) Jog
checkErr( Ivi_SetAttrRangeTableCallback (vi,
NPESP300_ATTR_CurrentPosition,
NPESP300AttrCurrentposition_RangeTableCallback));
}
Error:
return error;
}