Measurement Studio for VC++

cancel
Showing results for 
Search instead for 
Did you mean: 

Get GPIB card serial number with C++ program

I manage 40+ Windows XP PCs, each of which has a NI PCI-GPIB card installed. I use hard drive cloning software (Symantec Ghost Solution Suite) to clone (copy) the hard drive image from one PC onto the hard drives in the other PCs. After a cloning task, on the clone PCs, the file

%AllUsersProfile%\Application Data\National Instruments\NI-488.2\GPIB.INI

apparently contains the wrong serial number for the installed GPIB card. This is problematic in a number of ways – e.g., Measurement & Automation Explorer won't display the installed GPIB card under "My System > Devices and Interfaces" if there's a mismatch between the serial number of the installed GPIB card and the serial number in the file GPIB.INI.

I want to write a C++ program that obtains the serial number of an installed GPIB card and, ultimately, programmatically updates the corresponding serial number field in the file GPIB.INI.

I'm currently working with Visual Studio 2008, Measurement Studio 8.6, and NI-DAQmx 8.8. I downloaded and installed the "Measurement Studio C++ Data Acquisition and Instrument Control Drivers for Visual Studio 2008" (the DAQmx 8.8 version) from NI's website:

https://lumen.ni.com/nicif/us/infomstudiodrivers/content.xhtml

In Visual Studio 2008 I created a Win32 console project, with MFC support, and I added the Measurement Studio "Hardware Class Libraries > 488.2" class libraries to my project. So far, so good.

[Side Note]

I found a LabVIEW example (serial_number_gpib.vi) that calls the function 'ibask()' within the shared library 'gpib-32.dll' to obtain the GPIB card's serial number. The parameters in the example VI's function call are

ibask(gpib_card_descriptor, 0x0023, pointer_to_int)

[/Side note]

I wrote a C++ program [attached] where I pass in the (unsupported) value 0x0023 for the "option" parameter of the class method 'NI:: CNi4882Board::GetConfigurationOption'. If the serial number in the file GPIB.INI matches the GPIB card's serial number, then the program runs fine; it obtains the serial number, outputs it to the console, and exits with an exit status of 'EXIT_SUCCESS'. If the serial number in the file GPIB.INI is different from the GPIB card's serial number, then the class method 'NI:CNi4882Board::GetConfigurationOption' throws an exception at runtime. The exception's error message is:

488.2 Exception: Status = 8000 Error = 23 Transfer Count = 0

This exception occurs whether I run the program from within the VS2008 IDE or from the Windows command prompt.

Any suggestions on how to proceed from here?

Jim
0 Kudos
Message 1 of 4
(8,700 Views)

Hi Jfisher,

 

Have you considered imaging a computer without a GPIB card installed on it? This way when you first start up a re-imaged machine the "found new hardware wizard" should take care of the serial number and .INI file for you.

 

Post back if that's no an option for you.

 

Thanks

Scott M.

 

 

Applications Engineer
National Instruments
0 Kudos
Message 2 of 4
(8,660 Views)

Running the "add new hardware" wizard on 40+ computers after the hard drives are re-imaged is not a viable solution.

 

All I need is a reliable, programmatic means for reading the GPIB card's serial number with C++ program (I'll even settle for C or Visual Basic). The means of reading the GPIB card's serial number must not depend on the (possibly incorrect) information stored in the file GPIB.INI -- i.e., the program should not crash or throw an exception if the GPIB card's serial number is different from the serial number that's stored in the file GPIB.INI, which is what happens now with the code sample I provided (see my original post). Once I have the GPIB card's actual serial number I can easily write a program -- or even a script -- that places the correct serial number into the file GPIB.INI.

 

Jim

 

 

0 Kudos
Message 3 of 4
(8,648 Views)

Hi Jim,

 

All our drivers, including the NI-488.2 driver, work through MAX, so if your GPIB card cannot be seen in MAX you wont be able to query your card, even just for the serial number. You could create a table in your program that relates the GPIB serial number to the computer name for all your computers, then query the computer name and assign the serial number accordingly.

 

It seems to me that this situation is a lot like turning off a computer, swapping GPIB cards, and then switching it back on. I've tried this with my computer, and the found new hardware wizard runs automatically (no user needed) when xp boots up, the new GPIB card is then ready for use in MAX. Do you not see this behavior?

Applications Engineer
National Instruments
0 Kudos
Message 4 of 4
(8,637 Views)