1

I am using linux-gpib package and Keithley's KUSB-488A (gpib-usb converter) on my Ubuntu 14.04 LTS. It is installed properly and I can successfully command my devices using ibtest utility. But before that, everytime I disconnect and reconnect the device I need to run gpib_config --minor 0 inorder to initiate the drivers.

I wanted it to run automatically everytime a connection is made without having to run explicitly. So, a udev rule is what I thought of and wrote the following:

KERNEL=="gpib[0-9]*", ENV{DEVPATH}=="/devices/virtual/gpib_common/gpib0", RUN+="/usr/sbin/gpib_config --minor 0"

based on what I got from:

udevadm info /dev/gpib0

P: /devices/virtual/gpib_common/gpib0
N: gpib0
E: DEVNAME=/dev/gpib0
E: DEVPATH=/devices/virtual/gpib_common/gpib0
E: MAJOR=160
E: MINOR=0
E: SUBSYSTEM=gpib_common

But this didn't help me when I restarted the udev rules. What I have observed, if I reboot the pc itself then on first connection I am able to run ibtest without explicit execution of gpib_config.

Please help me where I am lacking?

1 Answers1

0

I believe you got /dev/gpib0 on the first time after reboot, the next reconnection is on /dev/gpib1 and each time you reconnect it get incremented like in USB storage.

On your first connection, you got:

E: DEVNAME=/dev/gpib0
E: DEVPATH=/devices/virtual/gpib_common/gpib0

On second one, I expect:

E: DEVNAME=/dev/gpib1
E: DEVPATH=/devices/virtual/gpib_common/gpib1

So that rule never run on any reconnection, As ENV{DEVPATH} in the rule fixed at 0. Another point, in your case DEVNAME & DEVPATH are very related (if I can't say: they are the same), so ENV{DEVPATH} does not add any thing to the rule. Try: ls -l /dev/gpib*, you should find a symlink:

/dev/gpibX -> /sys/devices/virtual/gpib_common/gpibX

So keep you rules simple:

KERNEL=="gpib[0-9]*", RUN+="/usr/sbin/gpib_config --minor 0"

BTW, this rule is run multiple times, at least it is run twice (2): On device connection & on device disconnection. I'm not familiar with hardware, if you need it that command only when device get connected add ACTION to the rule:

ACTION=="add", KERNEL=="gpib[0-9]*", RUN+="/usr/sbin/gpib_config --minor 0"
user.dz
  • 49,176