Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

Read SN from GPIB-USB-HS

Hi, I have a program running in several machines and it uses the GPIB-USB-HS controller. There has been strange failures in some of them, so I have a suspicion the controller could be the culprit. And for that reason I would like to write SN in the log file to be able to track to a particular controller.

Using pyvisa on Mac

Thanks

0 Kudos
Message 1 of 4
(4,949 Views)

nisyscfg.dll  is the only way you might be able to get at that device property.  

 

I am not sure what support is available for a MAC.


"Should be" isn't "Is" -Jay
Message 2 of 4
(4,938 Views)

@JÞB wrote:

nisyscfg.dll  is the only way you might be able to get at that device property.  

 

I am not sure what support is available for a MAC.


I don't believe this mechanism is yet available for NI-488.2 users on Mac OS X. Unfortunately the serial number is also not available from NI-VISA. The serial number can be retrieved from the NI4882 framework directly by doing something similar to the following, but I don't know how difficult it would be to do from Python.

 

Option 1: Access it from C calls

 

The following is what it would look like in C.

 

int ud = ibfind("gpib0");

int serialNumber = 0;

ibask(ud, IbaSerialNumber, &serialNumber);

 

 

Option 2: Parse it from command line output from Interactive Control

 

An alternative mechanism may be for you to access it from the command line. You could pipe commands into the Interactive Control utility installed with NI-488.2, and parse the serial number from the output.

 

Your Interactive Control command file should be something like:

 

ibfind gpib0

ibask ibaserialnumber

q

 

You can then pipe it to Interactive Control using:

 

cat <filename> | /Applications/National\ Instruments/NI-488.2/Interactive\ Control

 

Your output will then look something like this:

 

Interactive Control
Copyright 2007 National Instruments Corporation
All rights reserved.

Type 'help' for help or 'q' to quit.


:
gpib0: [0100]   ( cmpl )
Current Value:  0x123456 (decimal:1193046)

gpib0:

 

The number in bold in the above text is the hexadecimal serial number, which you could parse out using command-line tools or some Python code.

 

 

Option 3: Parse it from built-in Mac OS X functions

 

You can do something like the following to parse it from system information you get from Mac OS X. In the command below, 0x3923 is the USB Product ID of the GPIB-USB-HS, so this could be somewhat fragile if other devices from other vendors use the same ID, but you could tweak the parsing to be more specific if you wanted.  This is also specific to the formatting I see from the system_profiler command on a 10.8 machine I had handy, I'm not sure if it will be consistent on other versions of Mac OS X.

 

system_profiler SPUSBDataType | grep --context=2 0x3923 | grep Serial | awk '{ print $3 }'

 

This command is performing the following steps:

 

1. List all USB devices in the system.

2. Search for a line containing the GPIB-USB-HS product ID, out output 2 lines above and below it.

3. Search that result for the string "Serial", and output that line only.

4. Print the 3rd token on that line, which is the serial number.

 

 

 

Hopefully one of these ideas will be suitable for what you need. It was interesting trying to come up with ideas to get the information you need, and hopefully it will be made easier in the future.

 

-Jason Smith

Message 3 of 4
(4,826 Views)

Thanks to all !

 

0 Kudos
Message 4 of 4
(4,818 Views)