Impossible to use usbtmc library due inssuficient perrmissions

1,421 views
Skip to first unread message

Nesakysiu Nebūtina

unread,
Nov 20, 2017, 6:44:03 AM11/20/17
to python-ivi
Hi.
I have Rigol DS1102E oscilloscope and I try to control it using python-usbtmc. I have set up al appropriate udev rules and I CAN get device name using echo, cat commands. If I try to use python-usbtmc, i always get  usb.core.USBError: [Errno 13] Access denied (insufficient permissions) error.

Full stack:

>>> import usbtmc
>>> instr =  usbtmc.Instrument(0x1ab1,0x0588)
>>> print(instr.ask("*IDN?"))
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.5/dist-packages/usbtmc/usbtmc.py", line 629, in ask
    self.write(message, encoding)
  File "/usr/local/lib/python3.5/dist-packages/usbtmc/usbtmc.py", line 609, in write
    self.write_raw(str(message).encode(encoding))
  File "/usr/local/lib/python3.5/dist-packages/usbtmc/usbtmc.py", line 475, in write_raw
    self.open()
  File "/usr/local/lib/python3.5/dist-packages/usbtmc/usbtmc.py", line 310, in open
    self.device.set_configuration(self.cfg)
  File "/usr/lib/python3/dist-packages/usb/core.py", line 869, in set_configuration
    self._ctx.managed_set_configuration(self, configuration)
  File "/usr/lib/python3/dist-packages/usb/core.py", line 102, in wrapper
    return f(self, *args, **kwargs)
  File "/usr/lib/python3/dist-packages/usb/core.py", line 147, in managed_set_configuration
    self.managed_open()
  File "/usr/lib/python3/dist-packages/usb/core.py", line 102, in wrapper
    return f(self, *args, **kwargs)
  File "/usr/lib/python3/dist-packages/usb/core.py", line 120, in managed_open
    self.handle = self.backend.open_device(self.dev)
  File "/usr/lib/python3/dist-packages/usb/backend/libusb1.py", line 786, in open_device
    return _DeviceHandle(dev)
  File "/usr/lib/python3/dist-packages/usb/backend/libusb1.py", line 643, in __init__
    _check(_lib.libusb_open(self.devid, byref(self.handle)))
  File "/usr/lib/python3/dist-packages/usb/backend/libusb1.py", line 595, in _check
    raise USBError(_strerror(ret), ret, _libusb_errno[ret])
usb.core.USBError: [Errno 13] Access denied (insufficient permissions)


How can I solve this problem:

My udev rules, related to the USBTMC devices:

cat /etc/udev/rules.d/99-usbtmc.rules
# Siglent SGD 2042X
SUBSYSTEMS==”usb”, ACTION==”add”, ATTRS{idVendor}==”f4ec″, ATTRS{idProduct}==”ee38″, GROUP=”usbtmc”, MODE=”0666″
# USBTMC instruments
# Rigol DS1100 – ID 1ab1:0588 Rigol Technologies DS1000 SERIES
SUBSYSTEMS==”usb”, ACTION==”add”, ATTRS{idVendor}==”1ab1″, ATTRS{idProduct}==”0588″, GROUP=”usbtmc”, MODE=”0666″
# Kernel devices
KERNEL=="usbtmc/*",       MODE="0666", GROUP="usbtmc"
KERNEL=="usbtmc[0-9]*", MODE="0666", GROUP="usbtmc"


rmax7

unread,
Nov 21, 2017, 2:29:45 AM11/21/17
to python-ivi
Coupe of checks:

Did you try running your script with sudo permissions, to see if you are then able to access the USB port?

In the readme file in repo, it suggests using MODE="0660" in udev rules. Did you try that?

Nesakysiu Nebūtina

unread,
Nov 21, 2017, 7:12:35 AM11/21/17
to python-ivi
It works if sudo. Yes, I did try to use 0660 mode.

rmax7

unread,
Nov 21, 2017, 9:18:55 PM11/21/17
to python-ivi
In the udev rules, you put the device in usbtmc group. That's good, now "you" need to be in that group as well.

Check if your user has access to that group, by typing the following in terminal:

groups <username>

If usbtmc does not show there, then add yourself to that group by doing:

sudo usermod -a -G usbtmc <username>

Let us know if this worked!

Nesakysiu Nebūtina

unread,
Nov 22, 2017, 4:36:04 AM11/22/17
to python-ivi
My groups are these:
adm dialout cdrom sudo dip plugdev lpadmin sambashare usbtmc

As you can see,
I am on usbtmc group already.

IT DOES NOT WORK.

mp...@mst.edu

unread,
Apr 27, 2018, 4:51:49 PM4/27/18
to python-ivi
hi there,
Have you been able to solve the problem. i am having the same issue you had.

Thanks
Message has been deleted

Vince Patron

unread,
Apr 27, 2018, 5:52:10 PM4/27/18
to python-ivi
Hi all, I remember battling this issue last year and got it working nicely controlling a Keithley 2461 sourcemeter. 

I'm looking at my udev rules and I am giving control of that device to the group "plugdev" not "usbtmc" per the documentation. In Debian, plugdev seems to be the group that controls USB storage and other USB devices. Here's the line in my file:

SUBSYSTEM=="usb", ATTR{idVendor}=="05e6", ATTR{idProduct}=="2461", GROUP="plugdev"

And this file I called "11-keithley-2461-usb.rules" in directory /etc/udev/rules.d/

Change the USB Vendor ID and Product ID to your device, and name the file something relevant to your device, but use same naming rules (nn-somename.rules)

This is actually a Raspberry Pi (running Rasbian Jessie Lite) controlling my instrument.

-Vince

Bogdan Sikach

unread,
Mar 19, 2021, 4:32:35 AM3/19/21
to python-ivi
Your solution works like a charm (Lubuntu 18.04).
Reply all
Reply to author
Forward
0 new messages