Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stopped working overnight? Appears rules aren't being applied. #57

Open
fallingin2infinity opened this issue Jun 11, 2021 · 1 comment

Comments

@fallingin2infinity
Copy link

Hello,

I got python-usbtmc working yesterday, and was having a good time connecting to my Keysight Ocilloscope, running IDN queries, etc. All from my Raspberry Pi 3B+. I followed everything in the readme file, except the optional Kernel bit. But this morning, it's not working!

The output from lsusb:

pi@raspberrypi:~ $ lsusb
Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 001 Device 005: ID 04d9:0007 Holtek Semiconductor, Inc. 
Bus 001 Device 004: ID 093a:2510 Pixart Imaging, Inc. Optical Mouse
Bus 001 Device 023: ID 0957:0588 Agilent Technologies, Inc. 
Bus 001 Device 002: ID 2109:3431 VIA Labs, Inc. Hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

My usbtmc.rules file:

# USBTMC instruments

# Agilent DSO1052B
SUBSYSTEM=="usb", ACTION=="add", ATTRS{idVendor}=="0x0957", ATTRS{idProduct}=="0x0588", GROUP="usbtmc", MODE="0660"

My Python3 code:

>>> import usbtmc
>>> inst = usbtmc.Instrument(0x0957, 0x0588)
>>> print(inst.ask("*IDN") 

However, this morning the exact same code is returning:

usb.core.USBError: [Errno 13] Access denied (insufficient permissions)

The Pi was left on overnight, too - so nothing should have restarted, etc. The USB device was disconnected and reconnected in the morning. I didn't change anything, other than I probably re-started Python.

I've gone back through the readme (again, not the optional part) and I'm just not getting anywhere. When plugged in, the device is added to /dev/usbtmc0. Using ls -all, I get:

pi@raspberrypi:/dev $ ls -all | grep usbtmc*
crw-------   1 root root    180, 176 Jun 11 14:13 usbtmc0

Which doesn't look right to me. I've done some udevadm debugging to try and highlight an issue, and I'm seeing this line, which looks wrong, as I'd expect the mode to be picked up from my usbtmc.rules file:

usbtmc0: Handling device node '/dev/usbtmc0', devnum=c180:176, mode=0600, uid=0, gid=0

Does anyone have any thoughts?

@chrisjbillington
Copy link

chrisjbillington commented Jan 17, 2023

I couldn't get this to work using any variation of SUBSYSTEM=="usb" alone. This worked for me:

echo 'KERNEL=="usbtmc*", MODE="0660", GROUP="plugdev"'  | sudo tee -a /etc/udev/rules.d/10-usbtmc.rules
echo 'SUBSYSTEM=="usb", MODE="0660", GROUP="plugdev"'  | sudo tee -a /etc/udev/rules.d/00-usb-permissions.rules
sudo udevadm control --reload-rules
sudo udevadm trigger

And ensuring the user was a member of the "plugdev" group (they are by default on the Ubuntu I'm using).

I believe this grants permission for all usbtmc devices regardless of vendor ID and product ID, that's fine for me - but you might wanna specify them if you want to restrict it to only one devuce. I didn't test if that works.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants