Skip to content

Instantly share code, notes, and snippets.

@ochococo
Last active May 9, 2026 05:01
Show Gist options
  • Select an option

  • Save ochococo/8362414fff28fa593bc8f368ba94d46a to your computer and use it in GitHub Desktop.

Select an option

Save ochococo/8362414fff28fa593bc8f368ba94d46a to your computer and use it in GitHub Desktop.
National Instruments GPIB-USB-HS via PyVISA on UBUNTU.md

National Instruments GPIB-USB-HS + PYVISA on Ubuntu

LINUX-GPIB

Install depedencies:

sudo apt-get install tk-dev build-essential texinfo texi2html libcwidget-dev libncurses5-dev libx11-dev binutils-dev bison flex libusb-1.0-0 libusb-dev libmpfr-dev libexpat1-dev tofrodos subversion autoconf automake libtool mercurial

Checkout the LINUX-GPIB to user home dir:

cd ~
svn checkout svn://svn.code.sf.net/p/linux-gpib/code/trunk linux-gpib-code

Install the kernel part:

cd ~/linux-gpib-code/linux-gpib-kernel
make
sudo make install

Instal the user part:

cd ~/linux-gpib-code/linux-gpib-user
sudo make install

Check if USB dongle is connected:

lsusb | grep GPIB

expected result:

Bus 001 Device 006: ID 3923:709b National Instruments Corp. GPIB-USB-HS

Load kernel module:

sudo modprobe ni_usb_gpib

Update cache for linker

sudo ldconfig

Check if kernel module loaded:

lsmod | grep gpib

expected result:

ni_usb_gpib            36864  0
gpib_common            45056  1 ni_usb_gpib

Create config file

interface {
        minor = 0
        board_type = "ni_usb_b"
        pad = 0
        master = yes
}

File location for Ubuntu:

/usr/local/etc/gpib.conf

Test GPIB configuration:

sudo gpib_config

expected result:

no output, no error

Try to communicate with the device:

sudo ibtest
  • d ENTER,
  • address of your instrument ex. 3
  • w ENTER.
  • type *IDN? ENTER,
  • r ENTER
  • 100 ENTER

Expected result:

Example: KEITHLEY INSTRUMENTS INC.,MODEL 2000,0000,A05 /A02

If that works it means that linux-gpib can talk to the adapter and instrument. Success.

Python3

Install Python3 depedencies

sudo apt-get install python3-dev python3-distutils python3-pip python3-setuptools

Install Python bindings

cd linux-gpib-code/linux-gpib-user/
cd language/python/
sudo python3 setup.py install

Test script

~/testgpib.py

import Gpib
# X is your interface number (usually 0)
# Y is your instrument address (should be configured on the device)
inst = Gpib.Gpib(X,Y) 
inst.write("*IDN?")
print(inst.read(100))
python3 ~/testgpib.py

expected result:

Example: KEITHLEY INSTRUMENTS INC.,MODEL 2000,0000,A05 /A02

PyVISA

Install pyvisa

pip3 install pyvisa

Install pyvisa-py backend

pip3 install pyvisa-py

Install gpib-ctypes

pip3 install gpib-ctypes

Verify configuration

python3 -m visa info

Expected result:

(...)
Backends:
   ni:
      (not important)
   py:
      Version: X.X.X
      GPIB INSTR: Available via Linux GPIB (b'X.X.X r[XXXX]')
      GPIB INTFC: Available via Linux GPIB (b'X.X.X r[XXXXX]')

Test script

~/testvisa.py

import pyvisa
resources = pyvisa.ResourceManager('@py')
# X means your instrument address
k2000 = resources.open_resource('GPIB::X::INSTR')
print(k2000.query('*IDN?'))
python3 ~/testvisa.py

expected result:

Example: KEITHLEY INSTRUMENTS INC.,MODEL 2000,0000,A05 /A02

Sources

While compiling this instruction I used different sources including:

@MicroAlign
Copy link
Copy Markdown

I'm getting the following errors when trying to install the kernel part.

sudo make install
make -C /lib/modules/`uname -r`/build V=0 modules_install\
	M="/home/antonio/linux-gpib-code/linux-gpib-kernel/drivers/gpib" \
	GPIB_TOP_DIR=/home/antonio/linux-gpib-code/linux-gpib-kernel \
	INSTALL_MOD_DIR=gpib
make[1]: Entering directory '/usr/src/linux-headers-5.4.0-96-generic'
  INSTALL /home/antonio/linux-gpib-code/linux-gpib-kernel/drivers/gpib/agilent_82350b/agilent_82350b.ko
At main.c:160:
- SSL error:02001002:system library:fopen:No such file or directory: ../crypto/bio/bss_file.c:72
- SSL error:2006D080:BIO routines:BIO_new_file:no such file: ../crypto/bio/bss_file.c:79
sign-file: certs/signing_key.pem: No such file or directory
  INSTALL /home/antonio/linux-gpib-code/linux-gpib-kernel/drivers/gpib/agilent_82357a/agilent_82357a.ko
At main.c:160:
- SSL error:02001002:system library:fopen:No such file or directory: ../crypto/bio/bss_file.c:72
- SSL error:2006D080:BIO routines:BIO_new_file:no such file: ../crypto/bio/bss_file.c:79
sign-file: certs/signing_key.pem: No such file or directory
  INSTALL /home/antonio/linux-gpib-code/linux-gpib-kernel/drivers/gpib/cb7210/cb7210.ko
At main.c:160:
- SSL error:02001002:system library:fopen:No such file or directory: ../crypto/bio/bss_file.c:72
- SSL error:2006D080:BIO routines:BIO_new_file:no such file: ../crypto/bio/bss_file.c:79
sign-file: certs/signing_key.pem: No such file or directory
  INSTALL /home/antonio/linux-gpib-code/linux-gpib-kernel/drivers/gpib/cec/cec_gpib.ko
At main.c:160:
- SSL error:02001002:system library:fopen:No such file or directory: ../crypto/bio/bss_file.c:72
- SSL error:2006D080:BIO routines:BIO_new_file:no such file: ../crypto/bio/bss_file.c:79
sign-file: certs/signing_key.pem: No such file or directory
  INSTALL /home/antonio/linux-gpib-code/linux-gpib-kernel/drivers/gpib/gpio/gpib_bitbang.ko
At main.c:160:
- SSL error:02001002:system library:fopen:No such file or directory: ../crypto/bio/bss_file.c:72
- SSL error:2006D080:BIO routines:BIO_new_file:no such file: ../crypto/bio/bss_file.c:79
sign-file: certs/signing_key.pem: No such file or directory
  INSTALL /home/antonio/linux-gpib-code/linux-gpib-kernel/drivers/gpib/hp_82335/hp82335.ko
At main.c:160:
- SSL error:02001002:system library:fopen:No such file or directory: ../crypto/bio/bss_file.c:72
- SSL error:2006D080:BIO routines:BIO_new_file:no such file: ../crypto/bio/bss_file.c:79
sign-file: certs/signing_key.pem: No such file or directory
  INSTALL /home/antonio/linux-gpib-code/linux-gpib-kernel/drivers/gpib/hp_82341/hp_82341.ko
At main.c:160:
- SSL error:02001002:system library:fopen:No such file or directory: ../crypto/bio/bss_file.c:72
- SSL error:2006D080:BIO routines:BIO_new_file:no such file: ../crypto/bio/bss_file.c:79
sign-file: certs/signing_key.pem: No such file or directory
  INSTALL /home/antonio/linux-gpib-code/linux-gpib-kernel/drivers/gpib/ines/ines_gpib.ko
At main.c:160:
- SSL error:02001002:system library:fopen:No such file or directory: ../crypto/bio/bss_file.c:72
- SSL error:2006D080:BIO routines:BIO_new_file:no such file: ../crypto/bio/bss_file.c:79
sign-file: certs/signing_key.pem: No such file or directory
  INSTALL /home/antonio/linux-gpib-code/linux-gpib-kernel/drivers/gpib/lpvo_usb_gpib/lpvo_usb_gpib.ko
At main.c:160:
- SSL error:02001002:system library:fopen:No such file or directory: ../crypto/bio/bss_file.c:72
- SSL error:2006D080:BIO routines:BIO_new_file:no such file: ../crypto/bio/bss_file.c:79
sign-file: certs/signing_key.pem: No such file or directory
  INSTALL /home/antonio/linux-gpib-code/linux-gpib-kernel/drivers/gpib/nec7210/nec7210.ko
At main.c:160:
- SSL error:02001002:system library:fopen:No such file or directory: ../crypto/bio/bss_file.c:72
- SSL error:2006D080:BIO routines:BIO_new_file:no such file: ../crypto/bio/bss_file.c:79
sign-file: certs/signing_key.pem: No such file or directory
  INSTALL /home/antonio/linux-gpib-code/linux-gpib-kernel/drivers/gpib/ni_usb/ni_usb_gpib.ko
At main.c:160:
- SSL error:02001002:system library:fopen:No such file or directory: ../crypto/bio/bss_file.c:72
- SSL error:2006D080:BIO routines:BIO_new_file:no such file: ../crypto/bio/bss_file.c:79
sign-file: certs/signing_key.pem: No such file or directory
  INSTALL /home/antonio/linux-gpib-code/linux-gpib-kernel/drivers/gpib/sys/gpib_common.ko
At main.c:160:
- SSL error:02001002:system library:fopen:No such file or directory: ../crypto/bio/bss_file.c:72
- SSL error:2006D080:BIO routines:BIO_new_file:no such file: ../crypto/bio/bss_file.c:79
sign-file: certs/signing_key.pem: No such file or directory
  INSTALL /home/antonio/linux-gpib-code/linux-gpib-kernel/drivers/gpib/tms9914/tms9914.ko
At main.c:160:
- SSL error:02001002:system library:fopen:No such file or directory: ../crypto/bio/bss_file.c:72
- SSL error:2006D080:BIO routines:BIO_new_file:no such file: ../crypto/bio/bss_file.c:79
sign-file: certs/signing_key.pem: No such file or directory
  INSTALL /home/antonio/linux-gpib-code/linux-gpib-kernel/drivers/gpib/tnt4882/tnt4882.ko
At main.c:160:
- SSL error:02001002:system library:fopen:No such file or directory: ../crypto/bio/bss_file.c:72
- SSL error:2006D080:BIO routines:BIO_new_file:no such file: ../crypto/bio/bss_file.c:79
sign-file: certs/signing_key.pem: No such file or directory
  DEPMOD  5.4.0-96-generic
Warning: modules_install: missing 'System.map' file. Skipping depmod.
make[1]: Leaving directory '/usr/src/linux-headers-5.4.0-96-generic'
/sbin/depmod -A

I'm running Ubuntu 18.04 - kernel version 5.4.0-96-generic

@michael-antonelli
Copy link
Copy Markdown

@MicroAlign I had this issue as well, you have to generate the signing key with following commands:

cd /lib/modules/$(uname -r)/build/certs

sudo tee x509.genkey > /dev/null << 'EOF'
[ req ]
default_bits = 4096
distinguished_name = req_distinguished_name
prompt = no
string_mask = utf8only
x509_extensions = myexts
[ req_distinguished_name ]
CN = Modules
[ myexts ]
basicConstraints=critical,CA:FALSE
keyUsage=digitalSignature
subjectKeyIdentifier=hash
authorityKeyIdentifier=keyid
EOF

sudo openssl req -new -nodes -utf8 -sha512 -days 36500 -batch -x509 -config x509.genkey -outform DER -out signing_key.x509 -keyout signing_key.pem

@ArrestedLightning
Copy link
Copy Markdown

FYI, The linux-gpib-user directory does not have a Makefile in it when you check the driver out from SVN. In order to run make on it, you first need to run ./bootstrap, followed by ./configure --sysconfdir=/etc. The argument to the config script is important; without it, things like udev rules won't be installed.

@ilockerbie
Copy link
Copy Markdown

ilockerbie commented Jun 23, 2022

I solved the issue below.
sudo strace gpib_config showed that the config file is at /etc/gpib.conf. Moving the file to this location fixed the issue for me.


I am trying to follow the procedure and have run into an issue.
When I execute the command:
sudo gpib_config

I get the following error:

failed to configure boardtype: ni_pci
failed to configure board
main: Invalid argument

The device is showing up as expected: Bus 001 Device 003: ID 3923:709b National Instruments Corp. GPIB-USB-HS

I'm running Ubuntu 20.04.4 LTS

I assume this is related to the config file, but I'm not sure what's wrong. Any suggestions?

interface {
        minor = 0
        board_type = "ni_usb_b"
        pad = 0
        master = yes
}

@ctrimare
Copy link
Copy Markdown

Have you solved this issue?

@dforero1
Copy link
Copy Markdown

How do you create this file? like a .py file or?:
Create config file
interface {
minor = 0
board_type = "ni_usb_b"
pad = 0
master = yes
}

@mdpunch
Copy link
Copy Markdown

mdpunch commented Mar 17, 2023

Hi,

Thanks for putting this up, and the careful documention!

I am trying to get this working with an NI-USB-HS and currently xUbuntu 22.04.1 LTS (5.19.0-35-generic kernel).

After the step
cd ~/linux-gpib-code/linux-gpib-user; sudo make install
I get
make: *** No rule to make target 'install'. Stop.

So, I do
./bootstrap; ./configure
to create the make file.

Then then
sudo make install
works, and I see the device on the usb bus.

$ lsusb | grep GPIB
Bus 002 Device 004: ID 3923:709b National Instruments Corp. GPIB-USB-HS

I follow then next steps, and can see the kernel module okay:

$ lsmod | grep gpib
ni_usb_gpib            40960  0
gpib_common            53248  1 ni_usb_gpib

For the next steps in Python, I had to change the group of /dev/gpib0 from root to dialout (for which I had already added $USER to that group). This also means that I can execute ibtest without doing sudo, by the way.

Correction: I just had to create a group gpib, add the $USER to that group, and then the udev rules ensure persistence between reboots.

Warning: from habit, I was working in a conda/mamba environment, for which the Python step didn't work (ModuleNotFoundError: No module named 'gpib'), so I reverted to the non-conda environment.

Then, in Python, since I didn't know the address of my instrument, I could find it with this adapted version of your code example:

import Gpib
# X is your interface number (usually 0)
# Y is your instrument address (should be configured on the device)
for i in range(30):
    inst = Gpib.Gpib(0,i) 
    try:
        inst.write("*IDN?")
        print("address",i,"is",inst.read(100))
    except:
        pass

which gives
Address 8 is b'Stanford_Research_Systems,SR830,s/n83502,ver1.07 \n'

Hope this can help for other users who might hit the same problems (I started the post as a request for help, but got it working along the way),

//Michael Punch.

@sgodec
Copy link
Copy Markdown

sgodec commented Jul 10, 2023

Warning: modules_install: missing 'System.map' file. Skipping depmod.
make[1]: Leaving directory '/usr/src/linux-headers-5.19.0-46-generic'
/sbin/depmod -A
I still get this error, tried everything

@Stoyno
Copy link
Copy Markdown

Stoyno commented Aug 14, 2023

I am getting the following error when trying to communicate with a device :

InternalReceiveSetup: command failed
received string: ''
Number of bytes read: 0
gpib status is:
ibsta = 0x8100 < ERR CMPL >
iberr= 0
EDVR 0: OS error

Any ideas what is causing this behavior ?

@christofferkrook
Copy link
Copy Markdown

christofferkrook commented Sep 5, 2023

This wasn't trivial to install and get working correctly, however I am quite sure I managed it now.

There are installation instructions in the INSTALL files which supplement these quite nicely, however the step

cd ~/linux-gpib-code/linux-gpib-user
sudo make install

should be
cd ~/linux-gpib-code/linux-gpib-user
./bootstrap
./configure --sysconfdir=/etc
sudo make
sudo make install

Otherwise it wont install and link all the stuff correctly. This procedure is described in the -user INSTALL file.

The device (ESP300 Motion stage controller) has now positively told me its name through ibtest() so that means i've a channel to work with now.

@RavingEnginerd
Copy link
Copy Markdown

I solved the issue below. sudo strace gpib_config showed that the config file is at /etc/gpib.conf. Moving the file to this location fixed the issue for me.

I am trying to follow the procedure and have run into an issue. When I execute the command: sudo gpib_config

I get the following error:

failed to configure boardtype: ni_pci
failed to configure board
main: Invalid argument

The device is showing up as expected: Bus 001 Device 003: ID 3923:709b National Instruments Corp. GPIB-USB-HS

I'm running Ubuntu 20.04.4 LTS

I assume this is related to the config file, but I'm not sure what's wrong. Any suggestions?

interface {
        minor = 0
        board_type = "ni_usb_b"
        pad = 0
        master = yes
}

Hi. I'm running into the same issue.

Have you managed to solve it?

Regards

@fqbe
Copy link
Copy Markdown

fqbe commented May 25, 2024

$ cd ~/linux-gpib-code/linux-gpib-kernel
$ make
make -C /lib/modules/uname -r/build V=0 modules
M="/home/integse/linux-gpib-code/linux-gpib-kernel/drivers/gpib"
GPIB_TOP_DIR=/home/integse/linux-gpib-code/linux-gpib-kernel
CONFIG_GPIB_ISA=""
GPIB_CONFIG_PCMCIA="0"
HAVE_DEV_OF_NODE=
GPIB_CONFIG_KERNEL_DEBUG=0
make[1]: Entering directory '/usr/src/linux-headers-6.5.0-35-generic'

ERROR: Kernel configuration is invalid.
include/generated/autoconf.h or include/config/auto.conf are missing.
Run 'make oldconfig && make prepare' on kernel src to fix it.

$ cd /usr/src/linux-headers-$(uname -r)
/usr/src/linux-headers-6.5.0-35-generic$ sudo make oldconfig
LEX scripts/kconfig/lexer.lex.c
YACC scripts/kconfig/parser.tab.[ch]
HOSTCC scripts/kconfig/lexer.lex.o
HOSTCC scripts/kconfig/menu.o
HOSTCC scripts/kconfig/parser.tab.o
HOSTCC scripts/kconfig/preprocess.o
HOSTCC scripts/kconfig/symbol.o
HOSTCC scripts/kconfig/util.o
HOSTLD scripts/kconfig/conf

configuration written to .config

$ sudo make prepare
SYNC include/config/auto.conf.cmd
make[2]: *** No rule to make target 'arch/x86/entry/syscalls/syscall_32.tbl', needed by 'arch/x86/include/generated/uapi/asm/unistd_32.h'. Stop.

@jhamlin-ufl
Copy link
Copy Markdown

jhamlin-ufl commented Jun 27, 2024

I solved the issue below. sudo strace gpib_config showed that the config file is at /etc/gpib.conf. Moving the file to this location fixed the issue for me.
I am trying to follow the procedure and have run into an issue. When I execute the command: sudo gpib_config
I get the following error:

failed to configure boardtype: ni_pci
failed to configure board
main: Invalid argument

The device is showing up as expected: Bus 001 Device 003: ID 3923:709b National Instruments Corp. GPIB-USB-HS
I'm running Ubuntu 20.04.4 LTS
I assume this is related to the config file, but I'm not sure what's wrong. Any suggestions?

interface {
        minor = 0
        board_type = "ni_usb_b"
        pad = 0
        master = yes
}

Hi. I'm running into the same issue.

Have you managed to solve it?

Regards

This worked for me on Debian Bookworm. Instead of /usr/local/etc/gpib.conf, I had to move the file to /etc/gpib.conf. Then when I run sudo gpib_config I get back no errors.

@tnixa
Copy link
Copy Markdown

tnixa commented Jul 25, 2024

I have two Agilent 34970A data loggers connected to my Ubuntu 22.04 laptop. Each one has a GPIB-USB-HS. I have configured the device address for one of the instruments to 8 and the other to 9. I can see both with the lsusb command...

pwrtest@pwrtest-ThinkPad-P71:~/linux-gpib-code/linux-gpib-kernel$ lsusb
Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 001 Device 003: ID 138a:0097 Validity Sensors, Inc. 
Bus 001 Device 002: ID 04ca:7066 Lite-On Technology Corp. Integrated Camera
Bus 001 Device 015: ID 3923:709b National Instruments Corp. GPIB-USB-HS
Bus 001 Device 014: ID 3923:709b National Instruments Corp. GPIB-USB-HS
Bus 001 Device 005: ID 8087:0a2b Intel Corp. Bluetooth wireless interface
Bus 001 Device 004: ID 0765:5010 X-Rite, Inc. X-Rite Pantone Color Sensor
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

But only one device is showing up in pyvisa...

rm.list_resources()
('ASRL/dev/ttyS4::INSTR', 'GPIB0::9::INSTR')

If I unplug 9 and plug in 8 then 8 will show up. So I believe both are working but when both are plugged in only one shows up. Any help with getting this working would be greatly appreciated!

@tnixa
Copy link
Copy Markdown

tnixa commented Jul 26, 2024

I found this issue below about multiple GPIB controllers. I was able to get both my my devices to show up by linking them together with a GPIB cable and then using a single GPIB-USB-HS
pyvisa/pyvisa-py#57

@lmsb
Copy link
Copy Markdown

lmsb commented Sep 24, 2024

Hi, I'm getting this error:
sudo modprobe ni_usb_gpib
modprobe: ERROR: could not insert 'ni_usb_gpib': Key was rejected by service

I searched and find its related with the driver not having a signature and related with Secure Boot enabled.
How can I ensure the driver is signed?

I followed the instructions below but it still didn't work. My setup is Ubuntu 22.04.4 LTS.

sudo tee x509.genkey > /dev/null << 'EOF'

[ req ]
default_bits = 4096
distinguished_name = req_distinguished_name
prompt = no
string_mask = utf8only
x509_extensions = myexts
[ req_distinguished_name ]
CN = Modules
[ myexts ]
basicConstraints=critical,CA:FALSE
keyUsage=digitalSignature
subjectKeyIdentifier=hash
authorityKeyIdentifier=keyid
EOF

@montanaviking
Copy link
Copy Markdown

Thanks!
I was wondering if this could be used to utilize the GPIB-USB-HS+ with C and/or C++? I think one would use the VISA libraries for C?
Thanks!
Phil

@montanaviking
Copy link
Copy Markdown

Hi,
I cannot get the installation to work if fails at step:
$ sudo gpib_config
[sudo] password for viking:
failed to configure boardtype: ni_pci
failed to configure board
main: Invalid argument
###############
running with strace gives:
#######################################################

$ sudo strace gpib_config
execve("/usr/local/sbin/gpib_config", ["gpib_config"], 0x7ffe1e164e30 /* 16 vars /) = 0
brk(NULL) = 0x625ba0c0f000
mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x797080eaf000
access("/etc/ld.so.preload", R_OK) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=84899, ...}) = 0
mmap(NULL, 84899, PROT_READ, MAP_PRIVATE, 3, 0) = 0x797080e9a000
close(3) = 0
openat(AT_FDCWD, "/usr/local/lib/libgpib.so.0", O_RDONLY|O_CLOEXEC) = 3
read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\0\0\0\0\0\0\0\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0755, st_size=476688, ...}) = 0
mmap(NULL, 365016, PROT_READ, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x797080e40000
mmap(0x797080e43000, 57344, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x3000) = 0x797080e43000
mmap(0x797080e51000, 28672, PROT_READ, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x11000) = 0x797080e51000
mmap(0x797080e58000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x17000) = 0x797080e58000
mmap(0x797080e5a000, 258520, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x797080e5a000
close(3) = 0
openat(AT_FDCWD, "/lib/x86_64-linux-gnu/libc.so.6", O_RDONLY|O_CLOEXEC) = 3
read(3, "\177ELF\2\1\1\3\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\220\243\2\0\0\0\0\0"..., 832) = 832
pread64(3, "\6\0\0\0\4\0\0\0@\0\0\0\0\0\0\0@\0\0\0\0\0\0\0@\0\0\0\0\0\0\0"..., 784, 64) = 784
fstat(3, {st_mode=S_IFREG|0755, st_size=2125328, ...}) = 0
pread64(3, "\6\0\0\0\4\0\0\0@\0\0\0\0\0\0\0@\0\0\0\0\0\0\0@\0\0\0\0\0\0\0"..., 784, 64) = 784
mmap(NULL, 2170256, PROT_READ, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x797080c00000
mmap(0x797080c28000, 1605632, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x28000) = 0x797080c28000
mmap(0x797080db0000, 323584, PROT_READ, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x1b0000) = 0x797080db0000
mmap(0x797080dff000, 24576, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x1fe000) = 0x797080dff000
mmap(0x797080e05000, 52624, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x797080e05000
close(3) = 0
mmap(NULL, 12288, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x797080e3d000
arch_prctl(ARCH_SET_FS, 0x797080e3d740) = 0
set_tid_address(0x797080e3da10) = 79543
set_robust_list(0x797080e3da20, 24) = 0
rseq(0x797080e3e060, 0x20, 0, 0x53053053) = 0
mprotect(0x797080dff000, 16384, PROT_READ) = 0
mprotect(0x797080e58000, 4096, PROT_READ) = 0
mprotect(0x625b7ec1c000, 4096, PROT_READ) = 0
mprotect(0x797080ee7000, 8192, PROT_READ) = 0
prlimit64(0, RLIMIT_STACK, NULL, {rlim_cur=8192
1024, rlim_max=RLIM64_INFINITY}) = 0
munmap(0x797080e9a000, 84899) = 0
getrandom("\xb2\xec\xa8\xa7\xc2\x25\xc8\xcc", 8, GRND_NONBLOCK) = 8
brk(NULL) = 0x625ba0c0f000
brk(0x625ba0c30000) = 0x625ba0c30000
openat(AT_FDCWD, "/etc./gpib.conf", O_RDONLY) = 3
ioctl(3, TCGETS, 0x7fffbdbff220) = -1 ENOTTY (Inappropriate ioctl for device)
fstat(3, {st_mode=S_IFREG|0644, st_size=2838, ...}) = 0
read(3, "/*******************************"..., 8192) = 2838
read(3, "", 4096) = 0
read(3, "", 8192) = 0
ioctl(3, TCGETS, 0x7fffbdbfdd20) = -1 ENOTTY (Inappropriate ioctl for device)
close(3) = 0
openat(AT_FDCWD, "/dev/gpib0", O_RDWR) = 3
ioctl(3, _IOC(_IOC_WRITE, 0xa0, 0x27, 0x10), 0x7fffbdbff3c0) = 0
ioctl(3, _IOC(_IOC_WRITE, 0xa0, 0x18, 0x64), 0x7fffbdbff440) = -1 EINVAL (Invalid argument)
write(2, "failed to configure boardtype: n"..., 38failed to configure boardtype: ni_pci
) = 38
write(2, "failed to configure board\n", 26failed to configure board
) = 26
write(2, "main: Invalid argument\n", 23main: Invalid argument
) = 23
exit_group(-1) = ?
+++ exited with 255 +++
#################################################################

OS is Ubuntu 24.04
kernel is: 6.8.0-55-generic #57-Ubuntu SMP PREEMPT_DYNAMIC Wed Feb 12 23:42:21 UTC 2025 x86_64 x86_64 x86_64 GNU/Linux

gpib.conf file is at /etc/gpib.conf AND /usr/local/etc/gpib.conf

cat /etc/gpib.conf
interface {
minor = 0
board_type = "ni_usb_b"
pad = 0
master = yes
}
$ cat /usr/local/etc/gpib.conf

cat /usr/local/etc/gpib.conf

interface {
minor = 0
board_type = "ni_usb_b"
pad = 0
master = yes
}
$ lsusb
c$ lsusb
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 001 Device 002: ID 3923:709b National Instruments Corp. GPIB-USB-HS
Bus 001 Device 003: ID 067b:2303 Prolific Technology, Inc. PL2303 Serial Port / Mobile Phone Data Cable
Bus 001 Device 004: ID 1058:2621 Western Digital Technologies, Inc. Elements 2621
Bus 001 Device 005: ID 3923:709b National Instruments Corp. GPIB-USB-HS
Bus 001 Device 006: ID 046d:0994 Logitech, Inc. QuickCam Orbit/Sphere AF
Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 002 Device 005: ID 0547:139b Anchor Chips, Inc. USB3.0 Camera
#######################
$ $ lsmod | grep gpib
ni_usb_gpib 45056 0
gpib_common 57344 1 ni_usb_gpib
################################

Any ideas why the gpib_conf command won't run?
Thanks!
Phil

@mcgowanRochnu
Copy link
Copy Markdown

Thank you for sharing this! Following your instructions, plus some fixes along the way, I successfully deployed a National Instruments GPIB-USB-HS on Ubuntu 24.04 LTS, reading input from three Keithley 2000 multimeters. This was working on kernel 6.14.0-37-generic #37-24.04.1-Ubuntu, and any later kernels until update to 6.17.0-14-generic #14-24.04.1-Ubuntu. With this kernel, testgpib.py fails with:

libgpib: ibBoardOpen failed to open device file /dev/gpib0
libgpib: No such file or directory
libgpib: error in is_cic()!
Traceback (most recent call last):
  File "/home/instructor/Desktop/workingSC_2026/testgpib.py", line 5, in <module>
    inst = Gpib.Gpib(0,14)
           ^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/dist-packages/gpib-1.0-py3.12-linux-x86_64.egg/Gpib.py", line 26, in __init__
    self.id = gpib.dev(name, pad, sad, timeout, send_eoi, eos_mode)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
gpib.GpibError: dev() error: Bad file descriptor (errno: 9)

I obliterated the original installation and started over, which yields a new error that I did not encounter in my initial installation, and I have not yet found a fix for. This is in the earliest make command in the instructions:

~/linux-gpib-code/linux-gpib-kernel$ make
make -C /lib/modules/`uname -r`/build V=0 modules \
	M="/home/instructor/linux-gpib-code/linux-gpib-kernel/drivers/gpib" \
	GPIB_TOP_DIR=/home/instructor/linux-gpib-code/linux-gpib-kernel \
	CONFIG_GPIB_ISA="" \
	GPIB_CONFIG_PCMCIA="0" \
	HAVE_DEV_OF_NODE= \
	GPIB_CONFIG_KERNEL_DEBUG=0
make[1]: Entering directory '/usr/src/linux-headers-6.17.0-14-generic'
make[2]: Entering directory '/home/instructor/linux-gpib-code/linux-gpib-kernel/drivers/gpib'
warning: the compiler differs from the one used to build the kernel
  The kernel was built by: x86_64-linux-gnu-gcc-13 (Ubuntu 13.3.0-6ubuntu2~24.04) 13.3.0
  You are using:           gcc-13 (Ubuntu 13.3.0-6ubuntu2~24.04) 13.3.0
  CC [M]  agilent_82357a/agilent_82357a.o
In file included from /usr/src/linux-headers-6.17.0-14-generic/include/linux/uprobes.h:18,
                 from /usr/src/linux-headers-6.17.0-14-generic/include/linux/mm_types.h:16,
                 from /usr/src/linux-headers-6.17.0-14-generic/include/linux/mmzone.h:22,
                 from /usr/src/linux-headers-6.17.0-14-generic/include/linux/gfp.h:7,
                 from /usr/src/linux-headers-6.17.0-14-generic/include/linux/umh.h:4,
                 from /usr/src/linux-headers-6.17.0-14-generic/include/linux/kmod.h:9,
                 from /usr/src/linux-headers-6.17.0-14-generic/include/linux/module.h:18,
                 from /home/instructor/linux-gpib-code/linux-gpib-kernel/compat/include/linux/module.h:61,
                 from agilent_82357a/agilent_82357a.c:23:
agilent_82357a/agilent_82357a.c: In function ‘agilent_82357a_timeout_handler’:
/home/instructor/linux-gpib-code/linux-gpib-kernel/compat/include/linux/timer.h:50:9: error: implicit declaration of function ‘from_timer’; did you mean ‘mod_timer’? [-Werror=implicit-function-declaration]
   50 |         from_timer(var, callback_timer, timer_fieldname)
      |         ^~~~~~~~~~
agilent_82357a/agilent_82357a.c:51:44: note: in expansion of macro ‘COMPAT_FROM_TIMER’
   51 |         agilent_82357a_private_t *a_priv = COMPAT_FROM_TIMER(a_priv, t, bulk_timer);
      |                                            ^~~~~~~~~~~~~~~~~
agilent_82357a/agilent_82357a.c:51:73: error: ‘bulk_timer’ undeclared (first use in this function)
   51 | ent_82357a_private_t *a_priv = COMPAT_FROM_TIMER(a_priv, t, bulk_timer);
      |                                                             ^~~~~~~~~~

/home/instructor/linux-gpib-code/linux-gpib-kernel/compat/include/linux/timer.h:50:41: note: in definition of macro ‘COMPAT_FROM_TIMER’
   50 |         from_timer(var, callback_timer, timer_fieldname)
      |                                         ^~~~~~~~~~~~~~~
agilent_82357a/agilent_82357a.c:51:73: note: each undeclared identifier is reported only once for each function it appears in
   51 | ent_82357a_private_t *a_priv = COMPAT_FROM_TIMER(a_priv, t, bulk_timer);
      |                                                             ^~~~~~~~~~

/home/instructor/linux-gpib-code/linux-gpib-kernel/compat/include/linux/timer.h:50:41: note: in definition of macro ‘COMPAT_FROM_TIMER’
   50 |         from_timer(var, callback_timer, timer_fieldname)
      |                                         ^~~~~~~~~~~~~~~
agilent_82357a/agilent_82357a.c: In function ‘agilent_82357a_send_bulk_msg’:
agilent_82357a/agilent_82357a.c:121:25: error: implicit declaration of function ‘del_timer_sync’ [-Werror=implicit-function-declaration]
  121 |                         del_timer_sync(&a_priv->bulk_timer);
      |                         ^~~~~~~~~~~~~~
cc1: some warnings being treated as errors
make[5]: *** [/usr/src/linux-headers-6.17.0-14-generic/scripts/Makefile.build:287: agilent_82357a/agilent_82357a.o] Error 1
make[4]: *** [/usr/src/linux-headers-6.17.0-14-generic/scripts/Makefile.build:556: agilent_82357a] Error 2
make[3]: *** [/usr/src/linux-headers-6.17.0-14-generic/Makefile:2016: .] Error 2
make[2]: *** [/usr/src/linux-headers-6.17.0-14-generic/Makefile:248: __sub-make] Error 2
make[2]: Leaving directory '/home/instructor/linux-gpib-code/linux-gpib-kernel/drivers/gpib'
make[1]: *** [Makefile:248: __sub-make] Error 2
make[1]: Leaving directory '/usr/src/linux-headers-6.17.0-14-generic'
make: *** [Makefile:10: all] Error 2

Anyone out there with a similar configuration?
Thanks in advance for any assistance!

@lumipallero
Copy link
Copy Markdown

Thank you for sharing this! Following your instructions, plus some fixes along the way, I successfully deployed a National Instruments GPIB-USB-HS on Ubuntu 24.04 LTS, reading input from three Keithley 2000 multimeters. This was working on kernel 6.14.0-37-generic #37-24.04.1-Ubuntu, and any later kernels until update to 6.17.0-14-generic #14-24.04.1-Ubuntu. With this kernel, testgpib.py fails with:

libgpib: ibBoardOpen failed to open device file /dev/gpib0
libgpib: No such file or directory
libgpib: error in is_cic()!
Traceback (most recent call last):
  File "/home/instructor/Desktop/workingSC_2026/testgpib.py", line 5, in <module>
    inst = Gpib.Gpib(0,14)
           ^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/dist-packages/gpib-1.0-py3.12-linux-x86_64.egg/Gpib.py", line 26, in __init__
    self.id = gpib.dev(name, pad, sad, timeout, send_eoi, eos_mode)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
gpib.GpibError: dev() error: Bad file descriptor (errno: 9)

I obliterated the original installation and started over, which yields a new error that I did not encounter in my initial installation, and I have not yet found a fix for. This is in the earliest make command in the instructions:

~/linux-gpib-code/linux-gpib-kernel$ make
make -C /lib/modules/`uname -r`/build V=0 modules \
	M="/home/instructor/linux-gpib-code/linux-gpib-kernel/drivers/gpib" \
	GPIB_TOP_DIR=/home/instructor/linux-gpib-code/linux-gpib-kernel \
	CONFIG_GPIB_ISA="" \
	GPIB_CONFIG_PCMCIA="0" \
	HAVE_DEV_OF_NODE= \
	GPIB_CONFIG_KERNEL_DEBUG=0
make[1]: Entering directory '/usr/src/linux-headers-6.17.0-14-generic'
make[2]: Entering directory '/home/instructor/linux-gpib-code/linux-gpib-kernel/drivers/gpib'
warning: the compiler differs from the one used to build the kernel
  The kernel was built by: x86_64-linux-gnu-gcc-13 (Ubuntu 13.3.0-6ubuntu2~24.04) 13.3.0
  You are using:           gcc-13 (Ubuntu 13.3.0-6ubuntu2~24.04) 13.3.0
  CC [M]  agilent_82357a/agilent_82357a.o
In file included from /usr/src/linux-headers-6.17.0-14-generic/include/linux/uprobes.h:18,
                 from /usr/src/linux-headers-6.17.0-14-generic/include/linux/mm_types.h:16,
                 from /usr/src/linux-headers-6.17.0-14-generic/include/linux/mmzone.h:22,
                 from /usr/src/linux-headers-6.17.0-14-generic/include/linux/gfp.h:7,
                 from /usr/src/linux-headers-6.17.0-14-generic/include/linux/umh.h:4,
                 from /usr/src/linux-headers-6.17.0-14-generic/include/linux/kmod.h:9,
                 from /usr/src/linux-headers-6.17.0-14-generic/include/linux/module.h:18,
                 from /home/instructor/linux-gpib-code/linux-gpib-kernel/compat/include/linux/module.h:61,
                 from agilent_82357a/agilent_82357a.c:23:
agilent_82357a/agilent_82357a.c: In function ‘agilent_82357a_timeout_handler’:
/home/instructor/linux-gpib-code/linux-gpib-kernel/compat/include/linux/timer.h:50:9: error: implicit declaration of function ‘from_timer’; did you mean ‘mod_timer’? [-Werror=implicit-function-declaration]
   50 |         from_timer(var, callback_timer, timer_fieldname)
      |         ^~~~~~~~~~
agilent_82357a/agilent_82357a.c:51:44: note: in expansion of macro ‘COMPAT_FROM_TIMER’
   51 |         agilent_82357a_private_t *a_priv = COMPAT_FROM_TIMER(a_priv, t, bulk_timer);
      |                                            ^~~~~~~~~~~~~~~~~
agilent_82357a/agilent_82357a.c:51:73: error: ‘bulk_timer’ undeclared (first use in this function)
   51 | ent_82357a_private_t *a_priv = COMPAT_FROM_TIMER(a_priv, t, bulk_timer);
      |                                                             ^~~~~~~~~~

/home/instructor/linux-gpib-code/linux-gpib-kernel/compat/include/linux/timer.h:50:41: note: in definition of macro ‘COMPAT_FROM_TIMER’
   50 |         from_timer(var, callback_timer, timer_fieldname)
      |                                         ^~~~~~~~~~~~~~~
agilent_82357a/agilent_82357a.c:51:73: note: each undeclared identifier is reported only once for each function it appears in
   51 | ent_82357a_private_t *a_priv = COMPAT_FROM_TIMER(a_priv, t, bulk_timer);
      |                                                             ^~~~~~~~~~

/home/instructor/linux-gpib-code/linux-gpib-kernel/compat/include/linux/timer.h:50:41: note: in definition of macro ‘COMPAT_FROM_TIMER’
   50 |         from_timer(var, callback_timer, timer_fieldname)
      |                                         ^~~~~~~~~~~~~~~
agilent_82357a/agilent_82357a.c: In function ‘agilent_82357a_send_bulk_msg’:
agilent_82357a/agilent_82357a.c:121:25: error: implicit declaration of function ‘del_timer_sync’ [-Werror=implicit-function-declaration]
  121 |                         del_timer_sync(&a_priv->bulk_timer);
      |                         ^~~~~~~~~~~~~~
cc1: some warnings being treated as errors
make[5]: *** [/usr/src/linux-headers-6.17.0-14-generic/scripts/Makefile.build:287: agilent_82357a/agilent_82357a.o] Error 1
make[4]: *** [/usr/src/linux-headers-6.17.0-14-generic/scripts/Makefile.build:556: agilent_82357a] Error 2
make[3]: *** [/usr/src/linux-headers-6.17.0-14-generic/Makefile:2016: .] Error 2
make[2]: *** [/usr/src/linux-headers-6.17.0-14-generic/Makefile:248: __sub-make] Error 2
make[2]: Leaving directory '/home/instructor/linux-gpib-code/linux-gpib-kernel/drivers/gpib'
make[1]: *** [Makefile:248: __sub-make] Error 2
make[1]: Leaving directory '/usr/src/linux-headers-6.17.0-14-generic'
make: *** [Makefile:10: all] Error 2

Anyone out there with a similar configuration? Thanks in advance for any assistance!

The files from checkout have commands that do not work with current kernel. Replacing the files directly from Linux GPIB project git (https://sourceforge.net/p/linux-gpib/git/ci/master/tree/) and then following the tutorial worked for me.

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