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
  • 48,105
  • 1
    The linux-gpib driver always tries to open /dev/gpib0 port only. Next when I tried

    udevadm monitor --environment --udev

    I could see the actual characteristics of gpib-usb converter and then I changed my udev rule to:

    SUBSYSTEM=="usb", ENV{ID_SERIAL}=="3923_725c_01123B73", RUN+="/bin/sh -c '/usr/sbin/gpib_config --minor 0'"

    It started to detect the device as I wanted it to but sometimes I found this not working when I reboot pc.

    – Ashish Sharma Dec 04 '15 at 04:39
  • @AshishSharma , Do you mean (1) it doesn't work sometimes when machine rebooted with the device connected, to fix it you unplug & plug it again? Or (2) It doesn't matter if it was connected while reboot. Another thing, what's the name & path of the rules file you had used? – user.dz Dec 04 '15 at 10:51
  • 1
    Yes, I would select option (1) with an addition that it happens every time I reboot the pc with device connected. Once I disconnect and then re-connect the device, the rule picks it up and it works fine. My rule name is my-gpib-dev.rules and it is the same I commented earlier. – Ashish Sharma Dec 05 '15 at 12:11
  • @AshishSharma , it seems to me same case http://askubuntu.com/q/445735/26246 , the event comes while root file system is still in (ro) read-only mode , could you try both solutions there and vote up the one that works for you. – user.dz Dec 05 '15 at 13:22