1

I have National Instruments USB<->GPIB bridge. It is an USB board that need special procedure to became usable. I have linux_gpib package installed that provide two kernel modules: gpib_common and ni_usb_gpib. Besides, the gpib_config tool mast be executed before I can talk to any instrument on the GPIB bus. The trick is that board needs about 2 seconds after it was plugged into USB for internal initialization before gpib_config command will take effect. So, I have the following 99-gpib.rules udev rule that does the job perfect:

SUBSYSTEM=="usb", ACTION=="add", ATTR{idVendor}=="3923", ATTR{idProduct}=="709b", RUN+="/bin/sh -c '/usr/bin/sleep 2; /usr/sbin/gpib_config --minor 0'"

KERNEL=="gpib[0-9]*", MODE="0660", GROUP="gpib"

The problem is it only work if I plug the board when host system is up and running. When I reboot with the dongle plugged in I can see both kernel modules loaded, but the board is unusable, meaning that gpib_config tool wasn't executed. If I run it by hand it work perfectly.

Since reboot scenario is more real, then plugging it while the system is running, I need the correct way to make udev do this on boot. Sure, I can write some init script that will check if the board is plugged and kernel modules are loaded and run the tool during loading process, but this is udev job cause it something to deal with hardware, I think. Any ideas?

3
  • I am just listing out the possibilities here, gpib_config needs root privileges. – Thushi Nov 4 '16 at 8:35
  • Put these commands in a shell script and move it to /usr/local/bin. Provide executable permission and update the path in your udev rule – Thushi Nov 4 '16 at 8:41
  • Well, after some feather investigation I found, that RUN is executed before actual module loading. So, at the point gpib_config is executed, no modules and no actual devices are available. – e-pirate Nov 4 '16 at 20:01
1

The problem is in udev that executes RUN stuff before corresponding modules loading, therefore gpib_config fails to configure board. Workaround is to load modules before udev startup on system boot. Not a real solution, I think.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.