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.

Download the linux-gpib package, unpack and build. Get python-setuptools first for later Python bindings support.

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
sudo apt-get update
sudo apt-get install python-dev libboost-python-dev python-setuptools --yes
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 http://linux-gpib.sourceforge.net/firmware/gpib_firmware-2008-08-10.tar.gz
tar xvfz gpib_firmware-2008-08-10.tar.gz
cd ..

Use fxload 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 say

board_type = "agilent_82357a"
name = "agi"

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

...
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. For more advanced applications, consider using the visa (PyVISA) libraries.

import gpib
dev = gpib.find("hp3456a")      # N.B. define device ID in ``/etc/gpib.conf``
print dev.read()

References

[pyvisa]PyVISA https://pyvisa.readthedocs.io/en/stable/
[linux-gpib]linux-gpib : http://linux-gpib.sourceforge.net/
@zamora18
Copy link

zamora18 commented Jan 16, 2018

Hello. This was very useful. However, after following these instructions when I run the simple script:

import gpib
dev = gpib.find("hp3456a")
print gpib.read(dev, 99)

I get this error

InternalReceiveSetup: command failed
Traceback (most recent call last):
  File "/home/ubuntu/vna_comm_test/hello_world.py", line 3, in <module>
    print gpib.read(dev, 99)
gpib.GpibError: read() failed: An attempt to write command bytes to the bus has timed out.

Could you give me some insight as to why this could be happening? Thank you.

@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