Linux error - sub_open: SUB Device not found [SOLVED]

All about Sub-20 Multi Interface USB Adapter USB to I2C, SPI, GPIO, RS232, RS485, Ir, LCD

Moderator: serg

Post Reply
rdturner
Posts: 1
Joined: Mon Aug 27, 2012 2:58 pm

Linux error - sub_open: SUB Device not found [SOLVED]

Post by rdturner »

After compiling sub_app under Ubuntu 12.04 and 10.04, I found that if I ran sub_app as a normal user I got the following error: "sub_open: SUB Device not found"
However, if I ran sub_app as root, it worked with no errors.

Obviously, I had a permissions issue, and while there are several ways to address permissions, I chose to add a custom udev rule for the SUB-20.

udev is used in recent Linux kernels to dynamically create device nodes (http://en.wikipedia.org/wiki/Udev). It does this for SUB-20 each time it is plugged in. Obviously the default udev rule limits write permission to the superuser (root).

I wrote a custom udev rule file in /etc/udev/rules.d. The name of the file is arbitrary. I chose: 98-xdimax-SUB-20.rules, so I used "sudo vi /etc/udev/rules.d/98-xdimax-SUB-20.rules" to create the rule. The 98 prefix insures that it is the last executed rule (including the rules in /lib/udev/rules.d), so it will override any defaults.

The file contains one line:

SUBSYSTEM=="usb", ENV{ID_VENDOR_ID}=="04d8", ENV{ID_MODEL}=="SUB-20", GROUP="plugdev",MODE="0660"

[The quoted values should be the same for any SUB-20 board, but I show below how to check your board's values.]

This allows members of the "plugdev" group to write to the SUB-20. You can use any group and/or make the MODE 0664 or 0666.

run " sudo service udev restart" and the next time the board is plugged in the new permissions take effect.

If you make a typo in writing the rule, it will not work. There is a udev utility, udevadm, that will let you test the command before you restart the udev service, as described below:

/* How-To determine device values and test the udev rule */

(1) run "lsusb" to see your SUB-20 usb values. It will be something like:

Bus 001 Device 015: ID 04d8:ffc3 Microchip Technology, Inc.

The Bus # and Device # may be different. In fact the Device # will change each time you unplug and replug the SUB-20

(2) run "udevadm info --query=all --name=/dev/bus/usb/001/015" The last two numbers must match the Bus and Device numbers from the lsusb command in step 1, above.

This will give you list of the device information, including the ID_VENDOR and ID_MODEL values used in the rule

(3) The devadm test command needs the exact path to the SUB-20, which is this first line of the output from step #2 above. The line starts with a P: and then gives the path. On my PC it is: "/devices/pci0000:00/0000:00:1a.0/usb1/1-1/1-1.2" (YMMV)

(4) test the rule with that path:

sudo devadm test --action='SUBSYSTEM=="usb", ENV{ID_VENDOR_ID}=="04d8", ENV{ID_MODEL}=="SUB-20", GROUP="plugdev",MODE="0660"' /devices/pci0000:00/0000:00:1a.0/usb1/1-1/1-1.2

The rule itself is delimited by single quotes so that the double quote values of the rule are read correctly.

Note that this is the correct udevadm syntax for Ubuntu 12.04 but may differ for Linux other distributions.

NB: Thanks to "kevdog" for his post on udev at http://ubuntuforums.org/showthread.php?t=1918512

Post Reply