This is a quick summary of how to setup and use the linux-gpib
package
on a Debian Bullseye (stable
at the time of writing) system.
Install the following packages (assuming you are on x86_64
resp. amd64
):
sudo apt-get install linux-source linux-headers-amd64
Download the latest version of the sourcecode for linux-gpib
from their homepage:
https://linux-gpib.sourceforge.io/
At the time of writing, this is linux-gpib-4.3.4.tar.gz
Unpack the archive.
You will get linux-gpib-kernel-4.3.4.tar.gz
and linux-gpib-user-4.3.4.tar.gz
.
Unpack linux-gpib-kernel-4.3.4.tar.gz
and read the INSTALL
file contained therein.
Go into the linux-gpib-kernel-4.3.4
directory and run make
.
Then install the kernel module by running sudo make install
.
Unpack linux-gpib-user-4.3.4.tar.gz
and read the INSTALL
file contained therein.
Go to the linux-gpib-user-4.3.4
directory.
Run ./configure --sysconfdir=/etc
.
Then run make
.
Install the userspace package by running sudo make install
.
By default, an udev
permissions file is created at /etc/udev/rules.d/98-gpib-generic.rules
.
Create a group named gpib
:
sudo groupadd gpib
Add yourself to this group (assuming your account name is jonathan
):
sudo gpasswd -a jonathan gpib
The machine-specific configuration is done in /etc/gpib.conf
.
Edit it according to your GPIB setup.
Note (AFAIK) that you need to put all your instruments in there as well.
You need to reboot your computer to get
- the kernel module loaded (can also do
sudo modprobe tnt4882
if you have a NI PCI-GPIB) - update of the shared-library loader (can also do
ldconfig
) - update of the udev permissions
- update of your user account's group association
I used a HP 33120A function generator at address 9 connected to a NI PCI-GPIB (minor 0) to test this.
First, run sudo gpib_config --minor 0
to load the system-wide GPIB setup configuration
from /etc/gpib.conf
into the device memory (?).
Otherwise, the devices will not be found in below tests.
Run the ibterm
program supplied with linux-gpib
.
You can leave the interactive terminal with Ctrl-D.
jonathan@DellT3500:~$ sudo ibterm -d 9
[sudo] password for jonathan:
Attempting to open /dev/gpib0
pad = 9, sad = 0, timeout = 10, send_eoi = 1, eos_mode = 0x0000
ibterm>*IDN?
HEWLETT-PACKARD,33120A,0,6.0-2.0-1.0
ibterm>
ibterm: Done.
Test the python package.
Create a file test_gpib.py
:
import gpib
# GPIB interface 0, address 15
con = None
try:
con = gpib.dev(0,9)
except gpib.GpibError as e:
print(e)
exit()
status = gpib.write(con, "*IDN?")
deviceID = gpib.read(con, 1000).decode()
print("found device: " + deviceID)
Run it:
$ python3 test_gpib.py
found device: HEWLETT-PACKARD,33120A,0,6.0-2.0-1.0