Programming Manual MSO/UPO2000 Series
142 / 156
Instruments.uni-trend.com
{
printf("Could not open a session to the VISA Resource Manager!\n");
return status;
}
/*Find all the USB TMC VISA resources in our system and store the number of resources in the system in numInstrs.*/
status = viFindRsrc(defaultRM, "USB?*INSTR", &findList, &numInstrs, instrResourceString);
if (status<VI_SUCCESS)
{
printf("An error occurred while finding resources. \nPress Enter to continue.");
fflush(stdin);
getchar();
viClose(defaultRM);
return status;
}
/** Now we will open VISA sessions to all USB TMC instruments.
*
We must use the handle from viOpenDefaultRM and we must
*
also use a string that indicates which instrument to open. This
*
is called the instrument descriptor. The format for this string
*
can be found in the function panel by right clicking on the
*
descriptor parameter. After opening a session to the
*
device, we will get a handle to the instrument which we
*
will use in later VISA functions. The AccessMode and Timeout
*
parameters in this function are reserved for future
*
functionality. 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.
*We will now use the viPrintf function to send the device the string "*IDN?\n",
*asking for the device’s identification. */
char * cmmand = "*IDN?\n";
status = viPrintf(instr, cmmand);
if (status < VI_SUCCESS)
{
printf("Error writing to the device %d. \n", i + 1);