06-24-2009 02:33 AM
Solved! Go to Solution.
06-24-2009 11:10 AM
Hi,
you may find some useful informations in this discussion
07-07-2009 01:33 AM
07-07-2009 08:24 AM
07-08-2009 01:14 AM - edited 07-08-2009 01:16 AM
Thank you for the next advice. Querying all possible GPIB board isn't good solution because I don know the range of boards' numbers. I think I have found better solution based on the functions viFindRsrc and viFindNext. The clue was to properly specify the second parameter of the function viFindRsrc. The code is listed below. Maybe it helps someone. The presented function returns the table of pointers to string which describe all available GPIB boards.
int FindGpibBoards (char ***gpibList)
{
ViStatus status;
ViSession defaultRM, instr;
ViFindList fList;
ViChar desc[VI_FIND_BUFLEN], *gpib;
ViUInt32 numBrds, brd=0;
int i;
status = viOpenDefaultRM (&defaultRM);
if (status < VI_SUCCESS)
{
// Error initializing VISA ... exiting
return -1;
}
// Find all GPIB boards in the system
status = viFindRsrc (defaultRM, "GPIB[0-9]*::INTFC", &fList, &numBrds, desc);
if (status < VI_SUCCESS)
{
// Error finding resources ... exiting
viClose (defaultRM);
// 0xBFFF0011 = Insufficient location information or the device or resource
// is not present in the system. It happens when there is not a GPIB board.
if (status == 0xBFFF0011)
return -2;
else
return -3;
}
if (numBrds > 0)
{
*gpibList = (char **)malloc (numBrds*sizeof(char **));
while (brd < numBrds)
{
gpib = strtok (desc, ":");
*(*gpibList+brd) = malloc ((strlen(gpib)+1)*sizeof(char));
strcpy (*gpibList[brd], gpib);
brd++;
if (brd < numBrds)
viFindNext (fList, desc);
}
}
viClose (defaultRM);
return (int)numBrds;
}
07-08-2009 02:26 AM
Small correction. Instead of
strcpy (*gpibList[brd], gpib);
should be
strcpy (*(*gpibList+brd), gpib);