User Manual 48
EAR99 technology subject to restrictions on copyrights page.
/** Look for all USB TMC VISA resources in our system */
/* Then the number of resources stored in the system numInstrs
Lane */
status = viFindRsrc (defaultRM, "USB?*INSTR", &findList,
&numInstrs, instrResourceString);
if (status < VI_SUCCESS)
{
printf ("An error occurred while finding resources.\nHit enter to continue.");
fflush(stdin); getchar();
viClose (defaultRM); return status;
}
We will now open a VISA session for all USB TMC instruments. We have to use a
handle from viOpenDefaultRM, and we have to use a string to indicate the
instrument to open, which is called instrument descriptor. The format of the string
can be found in the right-click parameter description in the function panel. After
opening a session to the device, we get a handle to the instrument used later
when using the VISA feature. The AccessMode and timeout parameters in this
function are reserved for future functions. These two parameters are
given the value VI_NULL.
for (i=0; i<int(numInstrs); i++)
{
if (i > 0)
viFindNext (findList, instrResourceString);
status = viOpen (defaultRM, instrResourceString, VI_NULL, VI_NULL, &instr);
if (status < VI_SUCCESS)
{
printf ("Cannot open a session to the device %d.\n", i+1);
continue;
}
/** At this point, we now have a session open to the USB TMC instrument.
Now, we will use the viPrintf function to send the string "* IDN? \ N" to the
device, asking for the identification
*/