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

ValueError: The device has no langid #8

Closed
jedie opened this issue Apr 2, 2017 · 5 comments
Closed

ValueError: The device has no langid #8

jedie opened this issue Apr 2, 2017 · 5 comments

Comments

@jedie
Copy link
Contributor

jedie commented Apr 2, 2017

I have a Polar A360, Firmware v1.2.60, HW-Model 00756861.01

Traceback (most recent call last):
  File "__main__.py", line 285, in <module>
    main()
  File "__main__.py", line 278, in main
    cli.cmdloop(__INTRO.format(__version__))
  File "/usr/lib/python2.7/cmd.py", line 142, in cmdloop
    stop = self.onecmd(line)
  File "/usr/lib/python2.7/cmd.py", line 221, in onecmd
    return func(arg)
  File "__main__.py", line 75, in do_list
    info = Device.get_info(dev)
  File "/media/servershare/repos/polar_venv/src/loophole/loophole/polar/__init__.py", line 660, in get_info
    return usb.get_info(usb_device)
  File "/media/servershare/repos/polar_venv/src/loophole/loophole/polar/__init__.py", line 578, in get_info
    return self.usb.get_info(usb_device)
  File "/media/servershare/repos/polar_venv/src/loophole/loophole/polar/__init__.py", line 476, in get_info
    info['manufacturer'] = self.usb.util.get_string(usb_device, usb_device.iManufacturer)
  File "/media/servershare/repos/polar_venv/src/pyusb/usb/util.py", line 314, in get_string
    raise ValueError("The device has no langid")
ValueError: The device has no langid
$ lsusb 
...
Bus 001 Device 004: ID 0da4:0008 Polar Electro Oy Loop
...

the print output of Device.list() entry is:

0 DEVICE ID 0da4:0008 on Bus 001 Address 004 =================
 bLength                :   0x12 (18 bytes)
 bDescriptorType        :    0x1 Device
 bcdUSB                 :  0x200 USB 2.0
 bDeviceClass           :    0x0 Specified at interface
 bDeviceSubClass        :    0x0
 bDeviceProtocol        :    0x0
 bMaxPacketSize0        :   0x40 (64 bytes)
 idVendor               : 0x0da4
 idProduct              : 0x0008
 bcdDevice              :  0x100 Device 1.0
 iManufacturer          :    0x1 Error Accessing String
 iProduct               :    0x2 Error Accessing String
 iSerialNumber          :    0x3 Error Accessing String
 bNumConfigurations     :    0x1
  CONFIGURATION 1: 350 mA ==================================
   bLength              :    0x9 (9 bytes)
   bDescriptorType      :    0x2 Configuration
   wTotalLength         :   0x29 (41 bytes)
   bNumInterfaces       :    0x1
   bConfigurationValue  :    0x1
   iConfiguration       :    0x4 Error Accessing String
   bmAttributes         :   0x80 Bus Powered
   bMaxPower            :   0xaf (350 mA)
    INTERFACE 0: Human Interface Device ====================
     bLength            :    0x9 (9 bytes)
     bDescriptorType    :    0x4 Interface
     bInterfaceNumber   :    0x0
     bAlternateSetting  :    0x0
     bNumEndpoints      :    0x2
     bInterfaceClass    :    0x3 Human Interface Device
     bInterfaceSubClass :    0x0
     bInterfaceProtocol :    0x0
     iInterface         :    0x5 Error Accessing String
      ENDPOINT 0x81: Interrupt IN ==========================
       bLength          :    0x7 (7 bytes)
       bDescriptorType  :    0x5 Endpoint
       bEndpointAddress :   0x81 IN
       bmAttributes     :    0x3 Interrupt
       wMaxPacketSize   :   0x40 (64 bytes)
       bInterval        :    0x1
      ENDPOINT 0x1: Interrupt OUT ==========================
       bLength          :    0x7 (7 bytes)
       bDescriptorType  :    0x5 Endpoint
       bEndpointAddress :    0x1 OUT
       bmAttributes     :    0x3 Interrupt
       wMaxPacketSize   :   0x40 (64 bytes)
       bInterval        :    0x1

virtualenv info:

$ pip freeze
appdirs==1.4.3
packaging==16.8
pkg-resources==0.0.0
protobuf==3.2.0
pyparsing==2.2.0
-e git+https://github.com/walac/pyusb.git@1f66ccd5d252e969b1de9bf91bf24e5c64294b8d#egg=pyusb
six==1.10.0
@jedie
Copy link
Contributor Author

jedie commented Apr 4, 2017

It works as root using sudo...

Related stuff around permissions:
https://github.com/walac/pyusb/issues/139
padelt/temper-python#63

Maybe we can add a message like this:
padelt/temper-python@69034a4

@rsc-dev
Copy link
Owner

rsc-dev commented Apr 4, 2017 via email

@jedie
Copy link
Contributor Author

jedie commented Apr 4, 2017

The output with #9 looks like this:

$ python loophole/__main__.py


 _|                                _|                  _|
 _|    _|_|      _|_|    _|_|_|    _|_|_|      _|_|    _|    _|_|
 _|  _|    _|  _|    _|  _|    _|  _|    _|  _|    _|  _|  _|_|_|_|
 _|  _|    _|  _|    _|  _|    _|  _|    _|  _|    _|  _|  _|
 _|    _|_|      _|_|    _|_|_|    _|    _|    _|_|    _|    _|_|_|
                         _|
                         _|
                                                           ver. 0.5

loophole(no device)>list
Device no: 0
Device info:
DEVICE ID 0da4:0008 on Bus 001 Address 003 =================
 bLength                :   0x12 (18 bytes)
 bDescriptorType        :    0x1 Device
 bcdUSB                 :  0x200 USB 2.0
 bDeviceClass           :    0x0 Specified at interface
 bDeviceSubClass        :    0x0
 bDeviceProtocol        :    0x0
 bMaxPacketSize0        :   0x40 (64 bytes)
 idVendor               : 0x0da4
 idProduct              : 0x0008
 bcdDevice              :  0x100 Device 1.0
 iManufacturer          :    0x1 Error Accessing String
 iProduct               :    0x2 Error Accessing String
 iSerialNumber          :    0x3 Error Accessing String
 bNumConfigurations     :    0x1
  CONFIGURATION 1: 350 mA ==================================
   bLength              :    0x9 (9 bytes)
   bDescriptorType      :    0x2 Configuration
   wTotalLength         :   0x29 (41 bytes)
   bNumInterfaces       :    0x1
   bConfigurationValue  :    0x1
   iConfiguration       :    0x4 Error Accessing String
   bmAttributes         :   0x80 Bus Powered
   bMaxPower            :   0xaf (350 mA)
    INTERFACE 0: Human Interface Device ====================
     bLength            :    0x9 (9 bytes)
     bDescriptorType    :    0x4 Interface
     bInterfaceNumber   :    0x0
     bAlternateSetting  :    0x0
     bNumEndpoints      :    0x2
     bInterfaceClass    :    0x3 Human Interface Device
     bInterfaceSubClass :    0x0
     bInterfaceProtocol :    0x0
     iInterface         :    0x5 Error Accessing String
      ENDPOINT 0x81: Interrupt IN ==========================
       bLength          :    0x7 (7 bytes)
       bDescriptorType  :    0x5 Endpoint
       bEndpointAddress :   0x81 IN
       bmAttributes     :    0x3 Interrupt
       wMaxPacketSize   :   0x40 (64 bytes)
       bInterval        :    0x1
      ENDPOINT 0x1: Interrupt OUT ==========================
       bLength          :    0x7 (7 bytes)
       bDescriptorType  :    0x5 Endpoint
       bEndpointAddress :    0x1 OUT
       bmAttributes     :    0x3 Interrupt
       wMaxPacketSize   :   0x40 (64 bytes)
       bInterval        :    0x1
-------------------------------------------------------------------------------
Traceback (most recent call last):
  File "loophole/__main__.py", line 301, in <module>
    main()
  File "loophole/__main__.py", line 294, in main
    cli.cmdloop(__INTRO.format(__version__))
  File "/usr/lib/python2.7/cmd.py", line 142, in cmdloop
    stop = self.onecmd(line)
  File "/usr/lib/python2.7/cmd.py", line 221, in onecmd
    return func(arg)
  File "loophole/__main__.py", line 88, in do_list
    ) % err
ValueError: Can't get device info. Origin Error: The device has no langid
Maybe this is a permission issue.
Please read section 'permission' in README ;)

@jedie
Copy link
Contributor Author

jedie commented Apr 4, 2017

The interesting question is: How to use the USB device without root!

I found:
http://stackoverflow.com/questions/3738173/why-does-pyusb-libusb-require-root-sudo-permissions-on-linux

so maybe create a udev role?!?
Maybe print in the error message a example udev role?!? This information is available. See the print output from above:

...
DEVICE ID 0da4:0008 on Bus 001 Address 003
...

Don't know to get the IDs directly.

@rsc-dev
Copy link
Owner

rsc-dev commented Apr 4, 2017

Insufficient permissions for USB. Exception handling implemented.
@jedie Thanks!!

@rsc-dev rsc-dev closed this as completed Apr 4, 2017
fernsehkind referenced this issue in fernsehkind/loophole Sep 22, 2019
Fix#8 USB permission problem
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