Getting GPIB working on Linux

Introduction

GPIB is a very old communication standard which is, even to this date, very popular for instrument communication in labs. Getting it to work in our favourite operating system (Linux of course!), is not very easy because in general there are not pre-compiled packages for the GPIB drivers on linux distros. Furthermore, the suggested GPIB drivers for linux to compile doesn't work in newer linux distros (at least it didn't work for me). This tutorial, will detail the steps I had to discover in order to make GPIB work in Ubuntu Linux.

Installing GPIB Drivers

NOTE: As for April 2020, the steps I had to take involve using two versions of gpib-linux drivers, hopefully when you read this, this problem is solved. Also, I used Ubuntu 18.04 for this installation. These instructions are based in the link at the bottom of the page.

The main difficulty I had with the installation of the drivers is that I had to use two version of the linux-gpib drivers, one is the "main" version released on the internet, and the second one is a "snapshot" of a new version.

  1. Install python-libboost in order to compile the python libraries (later used by the pyvisa package).
    • sudo apt install libboost-python-dev
  2. Download and install the linux-GPIB drivers from https://sourceforge.net/projects/linux-gpib/. Follow the instructions to install both the kernel modules and the user space software
    1. For the kernel modules use the list of commands in the root folder:
      • make
      • sudo make install (you may get some errors, it's okay)
    2. For the user space software use the list of commands in the root folder:
      • ./configure --sysconfdir=/etc
      • make
      • make install
  3. At this point I figured out that this installation alone is note enough (again, I hope this is not the case in the future). Instead, you must add the kernel modules for a newer version, not officially released. Download the lasted snapshot of linux-gpib: https://sourceforge.net/p/linux-gpib/code/HEAD/tarball (for me the latest commit is r1879).
  4. Install the snapshot kernel modules, the same as the previous modules (make, sudo make install). You may get some errors, that is okay.
  5. Follow the instruction from here, ignoring the gpib-linux install part. That should be for the GPIB drivers.

Installing pyvisa

The pyvisa library is used to control instruments from python.

  1. Install pyvisa: sudo apt install python-pyvisa
  2. Install pyvisa provided drivers: sudo apt install python-pyvisa-py

That's it. To start instrument communication follow the example here. Remember to use a GPIB string.

Hopefully these instruction allowed you to use GPIB communication. If not, it is probably of an incompatibility between your distribution/kernel version and the gpib drivers. Please contact me if you find a better solution.