Linux-GPIB Info

The Linux GPIB Package is a support package for GPIB (IEEE 488) hardware, please see at Linux-GPIBInfo#Links. The package contains kernel driver modules, and a C user-space library with Guile, Perl, PHP, Python and TCL bindings. The API of the C library is intended to be compatible with National Instrument's GPIB library.

I like to have a GPIB interface with open source code and low cost. Because this can not archived with a commercial version, I build my own.

I started in 2010 with an open source version from lpvo. The commercial version of the lpvo USB-GPIB interface is no longer open source. Unfortunately I did not got it to work. The lpvo driver in linux-gpib (since 2011) is named lpvo_usb_gpib.
It looks like, that it is no longer in use (2016).

In 2011 an interface from Elektor was build up and works, please see at GPIBtoUSB2.

In 2016 several open source projects are using the Prologix (R) command set.

Because the CPU R8C is a little bit exotic and the output drive current capacity is quite low, I ported the program to an Arduino Nano 3 module, please see at GPIBtoUSB_Nano3.

My target was to port the driver lpvo_usb_gpio to my own interface, but it looks like to be not so easy.

The used Linux version is Ubuntu 12.04 with actual patches.

If you like to debug linux-gpib, it works with Netbeans ver. 7.4. The version 7.0.1 from the Ubuntu 12.04 repository does not work.

Compile and Install

Do the following steps:

Extract the .tgz file and change directory.

$ ./configure 

$ make

$ sudo make install

$ sudo depmod -a

$ sudo ldconfig

Configuration gpib.conf

The file /etc/gpib.conf is the main configuration file for the GPIB library. For my interface it looks like:

interface {
        minor = 0       /* board index, minor = 0 uses /dev/gpib0, minor = 1 uses /dev/gpib1, etc. */
        board_type = "rwan_usb_gpib"    /* type of interface board being used */
        name = "rwan"   /* name for 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 */

        master = yes    /* interface board is system controller */

The abstact interface board, mostly a GPIB Controller, will usually have the minor number of 0. Then the Linux device name is /dev/gpib0.

The name is a comfort issue, which allows to search for the board with a handy name, e.g in the test program ibtest.

Test with new interface driver

The already installed driver can now be loaded, until a udev rule is setup for USB hotplug.

$ sudo modprobe rwab_usb_gpib

$ lsmod | grep rwan
rwan_usb_gpib          18498  0 
gpib_common            33177  1 rwan_usb_gpib

# Now test it (with modified ibutil.c, see at Troubleshooting):
$ sudo ibtest
Do you wish to open a (d)evice or an interface (b)oard?
        (you probably want to open a device): b
enter name of interface board (or device) you wish to open: rwan
trying to open board named 'rwan'
handle: pad 0 sad -96 board 1
handle: retval -1
libgpib: IBOPENDEV ioctl failed
libgpib: ibfind failed to get descriptor
failed to open board

$ sudo ibtest
Do you wish to open a (d)evice or an interface (b)oard?
        (you probably want to open a device): d
enter primary gpib address for device you wish to open [0-30]: 7
trying to open pad = 7 on /dev/gpib0 ...
handle: pad 7 sad -96 board 0
handle: retval -1
libgpib: IBOPENDEV ioctl failed
libgpib: error in is_cic()!
ibdev error

ibsta = 0x8000  < ERR >
iberr= 0
EDVR 0: OS error

ibcnt = 19

From /var/log/kernel.log you can see the start:

13:52:41 usb 2-3: FTDI USB Serial Device converter now attached to ttyUSB0
17:01:00 Linux-GPIB 3.2.19 Driver
17:32:42 show_signal_msg: 39 callbacks suppressed

19:11:05 gpib: registered rwan_usb_gpib interface
19:11:05 rwan_usb_gpib:usb_gpib_init_module - done

18:10:18 rsyslogd-2039: Could not open output pipe '/dev/xconsole' [try ]

Use of xconsole

In order to use the debug messages from the driver with fprintf (KERN_ALERT you have to do:

$ sudo apt-get install xconsole

$ xconsole

But program xconsole is no longer supported from Unbuntu. Instead use for test:

$ sudo logger -p kern.alert -t Test "alert"
Nov  9 19:11:26 rudi-VB Test: alert

# read continuing the log:
$ tail -f /var/log/syslog

Test of the circuit

In order to test the basic function of the program and the interface, you need a terminal program. May I suggest PUTTY for Win32 and CoolTerm for Mac OS X.

PUTTY Parameters, Session:
  Connection Type: serial
  Serial line: COMx (x = USB Serial Emulation Nummer, z.B. 6)
  Speed: 38400

Keyboard input (blind, no Echo): "I", strg"J" (upper case I, Control+J = LineFeed)

GPIB/USB converter rwan V1.2

Set local echo ON
Text from the clipboard is inserted into the terminal window via the middle mouse key.

Firmware Comands

The commands can be sent manually in a terminal to the GPIB-USB converter. All commands must be terminated with Linefeed (Ctrl + J).

Extensions to GPIB_USB.c

To be able to operate my HP Logic Analyzer HP1631D in a useful manner with this interface a few commands were added:

The extended files are here for download: GPIB_USB_nano.ino , GPIB_functions.ino and header file GPIB_nano.h.

Application Program for Logic Analyzer

/!\ 2016-08-21 Software update - you can find an actual software version here. The renewed program was made compatible for Python 2 and 3, and tested on Linux Ubuntu 16.04-32, Mac OS X 10.11.6 El Capitan, and Windows 7-64. Now it can be used as an example program also for other GPIB instruments.

For comfortable using the HP Logic Analyzer HP1631D, I have written a Python command line program It actually runs under MAC OS X, but should be easily ported to Win32 or Linux. If you run the programm without parameter you get get a help message. The GPIB Address of the device is coded to 4. The following commands are build in, as Command Line Parameter:

If you want to run a different GPIB device so you have to adjust the program accordingly. Since Python is a multi-platform interpreter programming language, an adoption should not be so difficult.

Test with Python

I will use a HP Logic Analyser 1652B for test:

import Gpib
a = Gpib.Gpib('rwan')

Screen Shots

For screen shots please have a look at GPIBtoUSB2#Screen_Shots.


# edit file util/

# 2013-11-08 Rudolf Reuter
# restore xconsole device descriptors
# call with: sudo ./
# test with: ls /dev/xconsole

service rsyslog stop

# make device descriptor
mknod -m 640 /dev/xconsole c 1 3

# change owner
chown syslog:adm /dev/xconsole

service rsyslog start

# give execute rights
$ chmod ug+x

# create device descriptor
$ sudo ./

# edit file in util/

# restore gpib device descriptors
# call with: sudo ./
# test with: ls /dev/gp*

for i in `seq 0 15`;
        mknod -m u=rw,g=rw,o= /dev/gpib${i} c 160 ${i} || exit 1;
        chown root:gpib /dev/gpib${i};

# give execute rights
$ chmod ug+x

# create device descriptors gpib0 ... gpib15
$ sudo ./
$ sudo ls -ls /dev/gpib0
0 crw-rw---- 1 root gpib 160,  0 Nov  8 17:45 /dev/gpib0

# edit lib/ibutil.c, function open_gpib_handle()
# add print statements:

# after: open_cmd.is_board = conf->is_interface;
    fprintf( stderr, "handle: pad %d sad %d board %d\n", open_cmd.pad, open_cmd.sad, open_cmd.is_board);

# after: retval = ioctl( board->fileno, IBOPENDEV, &open_cmd );
    fprintf( stderr, "handle: retval %d\n", retval);

$ udevadm monitor --environment
UDEV  [21066.566555] add      /devices/pci0000:00/0000:00:1f.4/usb2/2-3/2-3:1.0 (usb)

UDEV  [21066.567972] add      /devices/pci0000:00/0000:00:1f.4/usb2/2-3/2-3:1.0/ttyUSB0 (usb-serial)

UDEV  [21066.645399] add      /devices/pci0000:00/0000:00:1f.4/usb2/2-3/2-3:1.0/ttyUSB0/tty/ttyUSB0 (tty)
DEVLINKS=/dev/serial/by-id/usb-FTDI_FT232R_USB_UART_A900FYDY-if00-port0 /dev/serial/by-path/pci-0000:00:1f.4-usb-0:3:1.0-port0
ID_VENDOR_FROM_DATABASE=Future Technology Devices International, Ltd

Nov 10 19:38:08 rudi-VB-SL kernel: [ 1289.675596] Linux-GPIB 3.2.19 Driver
Nov 10 19:38:08 rudi-VB-SL kernel: [ 1289.694440] gpib: registered lpvo_usb_gpib interface
Nov 10 19:38:08 rudi-VB-SL kernel: [ 1289.694504] lpvo_usb_gpib:usb_gpib_init_module - done
Nov 10 19:54:00 rudi-VB-SL kernel: [ 2241.723856] lpvo_usb_gpib:usb_gpib_attach configuring lpvo_usb_gpib#0 as ttyUSB0
Nov 10 19:54:00 rudi-VB-SL kernel: [ 2241.757821] lpvo_usb_gpib:usb_gpib_attach - found f5fbe780 0
Nov 10 19:54:00 rudi-VB-SL kernel: [ 2241.757906] kernel tried to execute NX-protected page - exploit attempt? (uid: 0)
Nov 10 19:54:00 rudi-VB-SL kernel: [ 2241.757908] BUG: unable to handle kernel paging request at f6691964
Nov 10 19:54:00 rudi-VB-SL kernel: [ 2241.757911] IP: [<f6691964>] 0xf6691963
Nov 10 19:54:00 rudi-VB-SL kernel: [ 2241.757921] *pdpt = 00000000019fc001 *pde = 80000000366001e3 
Nov 10 19:54:00 rudi-VB-SL kernel: [ 2241.757924] Oops: 0011 [#1] SMP 



List of pages in this category:

-- RudolfReuter 2013-11-07 18:02:17

Go back to CategoryLogicAnalyzer or StartSeite ; KontaktEmail (ContactEmail)

Linux-GPIBInfo (last edited 2016-08-22 04:57:38 by RudolfReuter)