Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save turingbirds/6eb05c9267a6437183a9567700e8581a to your computer and use it in GitHub Desktop.
Save turingbirds/6eb05c9267a6437183a9567700e8581a to your computer and use it in GitHub Desktop.
Agilent 82357B GPIB interface programming on Ubuntu Linux

GPIB interfacing using Agilent 82357B on Ubuntu Linux

I initially had some problems installing on my laptop, so decided to boot Ubuntu 12.04.5 LTS, 3.13.0-32-generic from USB and work from there.

For an automated installation script, see gpib_install.sh (and gpib.conf) below. The rest of this document describes the actions of the installation script step-by-step.

First, get the packages that are necessary to support Python bindings:

sudo apt-get update
sudo apt-get install python-dev libboost-python-dev python-setuptools --yes

Download the linux-gpib package, unpack and build:

wget --content-disposition --no-check-certificate https://sourceforge.net/projects/linux-gpib/files/linux-gpib%20for%203.x.x%20and%202.6.x%20kernels/3.2.20/linux-gpib-3.2.20.tar.gz/download
tar xvfz linux-gpib-3.2.20.tar.gz
cd linux-gpib-3.2.20
./configure
make -j8
sudo make install
cd ..

Also download the firmware binary for the 82357B:

wget --content-disposition --no-check-certificate http://linux-gpib.sourceforge.net/firmware/gpib_firmware-2008-08-10.tar.gz
tar xvfz gpib_firmware-2008-08-10.tar.gz

fxload is used to upload firmware to the GPIB interface.

wget --content-disposition --no-check-certificate https://downloads.sourceforge.net/project/linux-hotplug/fxload/2008_10_13/fxload-2008_10_13.tar.gz
tar xvfz fxload-2008_10_13.tar.gz
cd fxload-2008_10_13
make
sudo make install
cd ..

Edit /etc/gpib.conf (as superuser) to fill in the correct board type:

interface {
        board_type = "agilent_82357a"
        name = "agi"
        ...
}

See the attached gpib.conf for the full contents of the file (other parameters were left at their default values).

Load kernel module(s):

sudo modprobe gpib_common
sudo modprobe agilent_82357a

Insert the dongle into the USB port. Only the red "FAIL" LED should be on. Find the bus and device ID:

lsusb

e.g.

...
Bus 002 Device 005: ID 0957:0518 Agilent Technologies, Inc.
...

Plug the found bus and device ID into the command for fxload:

sudo fxload -D /dev/bus/usb/002/005  -t fx2 -I gpib_firmware-2008-08-10/agilent_82357a/measat_releaseX1.8.hex

Still only the "FAIL" LED is on.

The USB bus and device ID have now changed. Wait a moment and get the new ID:

lsusb

e.g.

...
Bus 002 Device 006: ID 0957:0518 Agilent Technologies, Inc.
...

Run fxload again with the new bus and device ID:

sudo fxload -D /dev/bus/usb/002/006  -t fx2 -I gpib_firmware-2008-08-10/agilent_82357a/measat_releaseX1.8.hex

All lights should be on.

Change permissions on /dev/gpib0 (ideally, you would manage this with a "gpib" usergroup instead):

sudo chmod 666 /dev/gpib0

Now, initialize the dongle. gpib_config has some trouble finding the library, so create a symbolic link first:

sudo ln -s /usr/local/lib/libgpib.so.0 /lib/libgpib.so.0
sudo gpib_config

Only the green "READY" LED should now be on.

Now, make an entry for your device in /etc/gpib.conf. Default HP3456B factory address is ASCII "V" (22 dec) for talk and "6" for listen.

device {
        name = "hp3456a"
        pad = 22
        ...
}

You can use ibtest to do some testing.

ibtest

A simple Python interface can now be made using the linux-gpib Python bindings:

import gpib
dev = gpib.find("hp3456a")      # corresponds to device ID in ``/etc/gpib.conf``
print gpib.read(dev, 99)

For more advanced applications, consider using the visa (PyVISA) libraries.

References

[pyvisa]PyVISA https://pyvisa.readthedocs.io/en/stable/
[linux-gpib]linux-gpib : http://linux-gpib.sourceforge.net/
/***********************************************************************
GPIB.CONF IEEE488 library config file
-------------------
copyright : (C) 2002 by Frank Mori Hess
(C) 1994 by C.Schroeter
email : fmhess@users.sourceforge.net
***************************************************************************/
/***************************************************************************
*
* Syntax:
*
* interface { ... } starts new interface board section
* device {...} device configuration
*
***************************************************************************/
/* This section configures the configurable driver characteristics
* for an interface board, such as board address, and interrupt level.
* minor = 0 configures /dev/gpib0, minor = 1 configures /dev/gpib1, etc.
*/
interface {
minor = 0 /* board index, minor = 0 uses /dev/gpib0, minor = 1 uses /dev/gpib1, etc. */
board_type = "agilent_82357a" /* type of interface board being used */
name = "agi" /* optional name, allows you to get a board descriptor using ibfind() */
pad = 0 /* primary address of interface */
sad = 0 /* secondary address of interface */
timeout = T3s /* timeout for commands */
eos = 0x0a /* EOS Byte, 0xa is newline and 0xd is carriage return */
set-reos = yes /* Terminate read if EOS */
set-bin = no /* Compare EOS 8-bit */
set-xeos = no /* Assert EOI whenever EOS byte is sent */
set-eot = yes /* Assert EOI with last byte on writes */
/* settings for boards that lack plug-n-play capability */
base = 0 /* Base io ADDRESS */
irq = 0 /* Interrupt request level */
dma = 0 /* DMA channel (zero disables) */
/* pci_bus and pci_slot can be used to distinguish two pci boards supported by the same driver */
/* pci_bus = 0 */
/* pci_slot = 7 */
master = yes /* interface board is system controller */
}
/* This is how you might set up a pcIIa board on /dev/gpib1, uncomment to use. */
/*******************
interface {
minor = 1
board_type = "pcIIa"
pad = 0
sad = 0
timeout = T3s
eos = 0x0a
set-reos = yes
set-bin = no
base = 0x2e1
irq = 7
dma = 1
master = yes
}
*********************/
/* Now the device sections define the device characteristics for each device.
* These are only used if you want to open the device using ibfind() (instead
* of ibdev() )
*/
device {
minor = 0
name = "hp3456a"
pad = 22
}
#!/usr/bin/env bash
sudo apt-get update
sudo apt-get install python-dev libboost-python-dev python-setuptools --yes
wget --content-disposition --no-check-certificate https://sourceforge.net/projects/linux-gpib/files/linux-gpib%20for%203.x.x%20and%202.6.x%20kernels/3.2.20/linux-gpib-3.2.20.tar.gz/download
tar xvfz linux-gpib-3.2.20.tar.gz
cd linux-gpib-3.2.20
./configure
make -j8
sudo make install
cd ..
wget --content-disposition --no-check-certificate http://linux-gpib.sourceforge.net/firmware/gpib_firmware-2008-08-10.tar.gz
tar xvfz gpib_firmware-2008-08-10.tar.gz
wget --content-disposition --no-check-certificate https://downloads.sourceforge.net/project/linux-hotplug/fxload/2008_10_13/fxload-2008_10_13.tar.gz
tar xvfz fxload-2008_10_13.tar.gz
cd fxload-2008_10_13
make
sudo make install
cd ..
sudo ln -s /usr/local/lib/libgpib.so.0 /lib/libgpib.so.0
sudo cp -v gpib.conf /etc/gpib.conf
sudo modprobe gpib_common
sudo modprobe agilent_82357a
sudo fxload -D /dev/bus/usb/`lsusb | grep Agilent | cut -f 2 -d " "`/`lsusb | grep Agilent | cut -f 4 -d " " | cut -f 1 -d ":"` -t fx2 -I gpib_firmware-2008-08-10/agilent_82357a/measat_releaseX1.8.hex
sleep 10
sudo fxload -D /dev/bus/usb/`lsusb | grep Agilent | cut -f 2 -d " "`/`lsusb | grep Agilent | cut -f 4 -d " " | cut -f 1 -d ":"` -t fx2 -I gpib_firmware-2008-08-10/agilent_82357a/measat_releaseX1.8.hex
sleep 10
sudo gpib_config
echo "See https://gist.github.com/turingbirds/6eb05c9267a6437183a9567700e8581a for troubleshooting/further instructions"
This file has been truncated, but you can view the full file.
@vishnubpatel
Copy link

vishnubpatel commented Feb 19, 2018

I am getting error with Agilent 82357b
$ sudo fxload -D /dev/bus/usb/003/010 -t fx2 -I gpib_firmware-2008-08-10/agilent_82357a/measat_releaseX1.8.hex
$ sudo chmod 666 /dev/gpib0
$ sudo ln -s /usr/local/lib/libgpib.so.0 /lib/libgpib.so.0

$ sudo gpib_config
syntax error, unexpected $undefined
parameter error on line 1 of /etc/gpib.conf
libgpib: failed to parse configuration file
failed to parse config file /etc/gpib.conf

$

@hemanti0503
Copy link

hemanti0503 commented Jul 5, 2018

I get the same error as @vishnubpatel.

$ sudo gpib_config
syntax error, unexpected $undefined
parameter error on line 1 of /etc/gpib.conf
libgpib: failed to parse configuration file
failed to parse config file /etc/gpib.conf

ibtest and the Python "Gbip" module (from the linux-gpib tree) fail with the same error message. Can anyone help on this, please?

@zamora18
Copy link

I am going back through this on a new machine (Ubuntu 16.04, kernel 4.15.0-34-generic) and I get this error when attempting sudo modprobe gpib_common:

modprobe: FATAL: Module gpib_common not found in directory /lib/modules/4.15.0-34-generic

I get a similar error when running sudo modprobe agilent_82357a:

modprobe: FATAL: Module agilent_82357a not found in directory /lib/modules/4.15.0-34-generic

Is there any way we can get help with this? It would be much appreciated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment