braiden/python-ant-downloader

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

jat255 opened this issue ยท 9 comments

Hi braiden,

I recently updated to 12.04 x64 and am attempting to reinstall this package. Everything goes fine when I install ez_setup and then python-ant-downloader via pip.

Now, regardless of whether I install the package with or without the "--user" option in pip, I receive the following error when I run ant-downloader:

josh@josh-ThinkPad:~/.local/bin$ ant-downloader 
Traceback (most recent call last):
  File "/home/josh/.local/bin/ant-downloader", line 8, in <module>
    load_entry_point('python-ant-downloader==12.03.21', 'console_scripts', 'ant-downloader')()
  File "/home/josh/.local/lib/python2.7/site-packages/antd/main.py", line 73, in downloader
    host = antd.cfg.create_antfs_host()
  File "/home/josh/.local/lib/python2.7/site-packages/antd/cfg.py", line 112, in create_antfs_host
    host = antfs.Host(create_ant_session(), keys)
  File "/home/josh/.local/lib/python2.7/site-packages/antd/cfg.py", line 99, in create_ant_session
    session = ant.Session(create_ant_core())
  File "/home/josh/.local/lib/python2.7/site-packages/antd/cfg.py", line 95, in create_ant_core
    return ant.Core(create_hardware())
  File "/home/josh/.local/lib/python2.7/site-packages/antd/cfg.py", line 91, in create_hardware
    return hw.UsbHardware(id_vendor, id_product, bulk_endpoint)
  File "/home/josh/.local/lib/python2.7/site-packages/antd/hw.py", line 48, in __init__
    dev.set_configuration()
  File "build/bdist.linux-x86_64/egg/usb/core.py", line 547, in set_configuration
  File "build/bdist.linux-x86_64/egg/usb/core.py", line 91, in managed_set_configuration
  File "build/bdist.linux-x86_64/egg/usb/core.py", line 70, in managed_open
  File "build/bdist.linux-x86_64/egg/usb/backend/libusb10.py", line 494, in open_device
  File "build/bdist.linux-x86_64/egg/usb/backend/libusb10.py", line 403, in _check
usb.core.USBError: [Errno 13] Access denied (insufficient permissions)

I can run the program as root, but obviously this is something I would rather not do. The problem seems to be more localized to libusb1.0, but if you had any ideas, I would really appreciate it. Thanks!

Hi,

You need to setup a udev rule so non-root user can access the device:

Create text file /etc/udev/rules.d/99-garmin.rules with contents:

SUBSYSTEM=="usb", ATTR{idVendor}=="0fcf", ATTR{idProduct}=="1008", MODE="666"

restart udev and reconnect the usb device. if you're running an older version of udev the rule format is slightly different.

SUBSYSTEM=="usb", SYSFS{idVendor}=="0fcf", SYSFS{idProduct}=="1008", MODE="666"

So you can try this if the first one doesn't work.

Regards

Right, of course. The installation had done this already. All I had to do was restart udev with sudo udevadm trigger

Thanks for the help!

Hey I am getting usb.core.USBError: [Errno 13] Access denied (insufficient permissions) for sending a control transfer dev.ctrl_transfer(0x21,0x09,0x0200,0x0000,0x0001) from OS X.. Can someone help me..

Possible a user permissions issue. I believe in Debian-type OS's (Debian, Ubuntu, etc...) you have to be a member of the 'plugdev' group. There may be some analog to that for OS X. Sorry, not an Apple guy.

HankB commented

Anything else to look at for this issue? I'm running Mint 17.2, contents of the udev rule:

hbarta@myrtle ~ $ cat /etc/udev/rules.d/99-garmin.rules
UBSYSTEM=="usb", ATTR{idVendor}=="0fcf", ATTR{idProduct}=="1008", MODE="666"

and I'm a member of plugdev and dialout groups. Permissions on the tty

hbarta@myrtle ~ $ ls -l /dev/ttyUSB0
crw-rw---- 1 root dialout 188, 0 Aug 15 09:00 /dev/ttyUSB0

Still get

raise USBError(_strerror(ret), ret, _libusb_errno[ret])

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

It works if I run it using sudo but I'm not real fond of doing that.

Thanks!

Edit: I found a fix in this thread that involved adding a udev rule:
SUBSYSTEM=="usb", MODE="0666", GROUP="usbusers"
(I didn't have that group so I just used "dialout") That solved the permissions issue.
Other thread is at https://code.google.com/p/pyalienfx/issues/detail?id=3

If your ant stick is showing as dev/ttyUSB0 then, you'll want to use the
serial interface, and the udev rules aren't applicable.

usermod -G dialout -a $USER

To ensure your id can access /dev/ttyUSB0. You might have to logout/login
for group to be added.

And make sure ~/antd/antd.cfg has serial_device = /dev/ttyUSB0 (which I
think is default).

On Sat, Aug 15, 2015 at 10:10 AM, HankB notifications@github.com wrote:

Anything else to look at for this issue? I'm running Mint 17.2, contents
of the udev rule:

hbarta@myrtle ~ $ cat /etc/udev/rules.d/99-garmin.rules
UBSYSTEM=="usb", ATTR{idVendor}=="0fcf", ATTR{idProduct}=="1008",
MODE="666"

and I'm a member of plugdev and dialout groups. Permissions on the tty

hbarta@myrtle ~ $ ls -l /dev/ttyUSB0
crw-rw---- 1 root dialout 188, 0 Aug 15 09:00 /dev/ttyUSB0

Still get

raise USBError(_strerror(ret), ret, _libusb_errno[ret])

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

It works if I run it using sudo but I'm not real fond of doing that.

Thanks!

โ€”
Reply to this email directly or view it on GitHub
#30 (comment)
.

HankB commented

Thank you for the reply and many thanks for ant-downloader.

During the most recent installation I noticed that it includes code to automatically upload to connect.garmin.com. I populated the fields but get a login error (as if the password was not correct.) I suspect that the interface at Garmin has changed. Do you think that there is any hope that I could sort that out? (I've got decades of development experience including C/C++, Perl and Java for the most part but am a real noob when it comes to Python.)

Thanks,
hank

You are correct, Garmin changed something and I haven't had time to look at
it.

All the login and upload logic is in connect.py. Basically I watchef the
form submission in chrome network tab and try to do exactly http post in
this file.

I upgraded to an newer watch that uploads over WiFi so I'm not doing a good
job keeping this working.
On Aug 15, 2015 11:07 AM, "HankB" notifications@github.com wrote:

Thank you for the reply and many thanks for ant-downloader.

During the most recent installation I noticed that it includes code to
automatically upload to connect.garmin.com. I populated the fields but
get a login error (as if the password was not correct.) I suspect that the
interface at Garmin has changed. Do you think that there is any hope that I
could sort that out? (I've got decades of development experience including
C/C++, Perl and Java for the most part but am a real noob when it comes to
Python.)

Thanks,
hank

โ€”
Reply to this email directly or view it on GitHub
#30 (comment)
.

Hello,

For Mac OS, try to unload the AppleUSBFtdi kext:

sudo kextunload -bundle-id com.apple.driver.AppleUSBFTDI

You can reload it with:

sudo kextload -bundle-id com.apple.driver.AppleUSBFTDI

Source:
http://pylibftdi.readthedocs.io/en/0.16.0/troubleshooting.html

Tested on macOS Sierra v10.12.6