LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

All GPIB boards available in system

Solved!
Go to solution
I would like to find the names of all available GPIB boards present in a computer. How to do it in LabWindows/CVI? For DAQmx boards it is possible by DAQmxGetSystemInfoAttribute function with the first parameter set to DAQmx_Sys_DevNames. However, I can't find similar function for GPIB boards.
0 Kudos
Message 1 of 6
(3,984 Views)

Hi,

 

you may find some useful informations in this discussion



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 2 of 6
(3,974 Views)
The above mentioned discussion doesn't’t bring any solution. The function viFindRsrc doesn't’t show the names of GPIB boards installed in computer if I don’t have an instrument connected to them. There are any other ideas?
0 Kudos
Message 3 of 6
(3,913 Views)
I have used 'ibfind' to determine whether a GPIB board is present before.  You could just cycle through all the possible names and see which ones return a positive number indicating that a gpib board with that name exists.  I think the only possible names are 'gpib' followed by a number ("gpib0", "gpib1", etc.) so this could work.
0 Kudos
Message 4 of 6
(3,898 Views)
Solution
Accepted by topic author MirKoz

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;
}

 

 

 

 

Message Edited by MirKoz on 07-08-2009 01:16 AM
0 Kudos
Message 5 of 6
(3,877 Views)

Small correction. Instead of

 

strcpy (*gpibList[brd], gpib);

should be

 

strcpy (*(*gpibList+brd), gpib);

 

 

0 Kudos
Message 6 of 6
(3,870 Views)