Skip to content

TEMPer2 not detecting devices #129

Closed

Description

@Stylopidae1793

Hi,

I'm trying to get the Temper2 device to work with this code.

Basically, when I run 'temper-poll', I get an error saying that it found 0 devices. However, the 'txt' button works.

The device model is 1a86:e025.

I'm new to raspberry pis in general, and python specifically, and I didn't see anything which resembled this problem on other github pages.

Activity

  1. davet2001 commented on May 2, 2023

    @davet2001
    Collaborator

    Ok, the device you list is made by QinHeng Electronics and since it is not listed on at least two PID databases, I'm guessing it's either new or obscure.

    Doing a bit of digging, and looking at another implementation, it's possible this is a TEMPer2_V3.7 with two temperature sensors, one internal and one external. Does that sound about right?

    If I create a pull request for this, do you have the capability to clone it and try it?

  2. davet2001 commented on May 2, 2023

    @davet2001
    Collaborator

    @Stylopidae1793 or any other volunteer who has this device: please could you try the above PR to see if it works with your sensor?

  3. Stylopidae1793 commented on May 2, 2023

    @Stylopidae1793
    Author

    Yes! I'd be happy to clone the pull request and try it!

  4. Stylopidae1793 commented on May 3, 2023

    @Stylopidae1793
    Author

    Using the lsusb function, this is indeed produced by QinHeng Electronics and has the external and internal sensor that you described. The model should be V 3.9.

    I cloned the repository above and followed the instructions in the README and unfortunately it still says 'Found 0 devices' when I use the temper-poll command.

  5. davet2001 commented on May 4, 2023

    @davet2001
    Collaborator

    @Stylopidae1793 thanks for this. Please can you paste the output of lsusb -v -d 1a86:e025?

    Then just to confirm that you do have the correct branch, could you also paste the output of git status and python3 -m temperusb.cli -v? Many thanks!

  6. Stylopidae1793 commented on May 5, 2023

    @Stylopidae1793
    Author

    Here's the output you requested:

    lsusb -v -d 1a86:e025
    
    Bus 001 Device 007: ID 1a86:e025 QinHeng Electronics TEMPer2
    Couldn't open device, some information will be missing
    Device Descriptor:
      bLength                18
      bDescriptorType         1
      bcdUSB               1.10
      bDeviceClass            0 
      bDeviceSubClass         0 
      bDeviceProtocol         0 
      bMaxPacketSize0         8
      idVendor           0x1a86 QinHeng Electronics
      idProduct          0xe025 
      bcdDevice            1.00
      iManufacturer           1 PCsensor
      iProduct                2 TEMPer2
      iSerial                 0 
      bNumConfigurations      1
      Configuration Descriptor:
        bLength                 9
        bDescriptorType         2
        wTotalLength       0x0042
        bNumInterfaces          2
        bConfigurationValue     1
        iConfiguration          0 
        bmAttributes         0xa0
          (Bus Powered)
          Remote Wakeup
        MaxPower              100mA
        Interface Descriptor:
          bLength                 9
          bDescriptorType         4
          bInterfaceNumber        0
          bAlternateSetting       0
          bNumEndpoints           1
          bInterfaceClass         3 Human Interface Device
          bInterfaceSubClass      1 Boot Interface Subclass
          bInterfaceProtocol      1 Keyboard
          iInterface              0 
            HID Device Descriptor:
              bLength                 9
              bDescriptorType        33
              bcdHID               1.11
              bCountryCode            0 Not supported
              bNumDescriptors         1
              bDescriptorType        34 Report
              wDescriptorLength      62
             Report Descriptors: 
               ** UNAVAILABLE **
          Endpoint Descriptor:
            bLength                 7
            bDescriptorType         5
            bEndpointAddress     0x81  EP 1 IN
            bmAttributes            3
              Transfer Type            Interrupt
              Synch Type               None
              Usage Type               Data
            wMaxPacketSize     0x0008  1x 8 bytes
            bInterval               1
        Interface Descriptor:
          bLength                 9
          bDescriptorType         4
          bInterfaceNumber        1
          bAlternateSetting       0
          bNumEndpoints           2
          bInterfaceClass         3 Human Interface Device
          bInterfaceSubClass      1 Boot Interface Subclass
          bInterfaceProtocol      2 Mouse
          iInterface              0 
            HID Device Descriptor:
              bLength                 9
              bDescriptorType        33
              bcdHID               1.10
              bCountryCode            0 Not supported
              bNumDescriptors         1
              bDescriptorType        34 Report
              wDescriptorLength      23
             Report Descriptors: 
               ** UNAVAILABLE **
          Endpoint Descriptor:
            bLength                 7
            bDescriptorType         5
            bEndpointAddress     0x82  EP 2 IN
            bmAttributes            3
              Transfer Type            Interrupt
              Synch Type               None
              Usage Type               Data
            wMaxPacketSize     0x0008  1x 8 bytes
            bInterval              10
          Endpoint Descriptor:
            bLength                 7
            bDescriptorType         5
            bEndpointAddress     0x02  EP 2 OUT
            bmAttributes            3
              Transfer Type            Interrupt
              Synch Type               None
              Usage Type               Data
            wMaxPacketSize     0x0008  1x 8 bytes
    
    git status
    On branch temper2_new
    Your branch is up to date with 'origin/temper2_new'.
    
    nothing to commit, working tree clean
    
    python3 -m temperusb.cli -v
    Traceback (most recent call last):
      File "/home/pi/temper-python/temperusb/temper.py", line 99, in __init__
        productname = self._device.product
      File "/usr/local/lib/python3.9/dist-packages/pyusb-1.2.1-py3.9.egg/usb/core.py", line 875, in product
        self._product = util.get_string(self, self.iProduct)
      File "/usr/local/lib/python3.9/dist-packages/pyusb-1.2.1-py3.9.egg/usb/util.py", line 313, in get_string
        raise ValueError("The device has no langid"
    ValueError: The device has no langid (permission issue, no string descriptors supported or device error)
    
    During handling of the above exception, another exception occurred:
    
    Traceback (most recent call last):
      File "/usr/lib/python3.9/runpy.py", line 197, in _run_module_as_main
        return _run_code(code, main_globals, None,
      File "/usr/lib/python3.9/runpy.py", line 87, in _run_code
        exec(code, run_globals)
      File "/home/pi/temper-python/temperusb/cli.py", line 110, in <module>
        main()
      File "/home/pi/temper-python/temperusb/cli.py", line 42, in main
        th = TemperHandler()
      File "/home/pi/temper-python/temperusb/temper.py", line 432, in __init__
        self._devices += [TemperDevice(device) for device in \
      File "/home/pi/temper-python/temperusb/temper.py", line 432, in <listcomp>
        self._devices += [TemperDevice(device) for device in \
      File "/home/pi/temper-python/temperusb/temper.py", line 102, in __init__
        raise usb.core.USBError("Error reading langids from device. "+
    usb.core.USBError: [Errno None] Error reading langids from device. This might be a permission issue. Please check that the device node for your TEMPer devices can be read and written by the user running this code. The temperusb README.md contains hints about how to fix this. Search for 'USB device permissions'.
    
  7. davet2001 commented on May 8, 2023

    @davet2001
    Collaborator

    Thanks @Stylopidae1793! The above error points to a permissions issue (your current user does not have access to the new device).
    Please can you update the file
    /etc/udev/rules.d/99-tempsensor.rules
    to add the last line from here
    https://github.com/davet2001/temper-python/blob/temper2_new/etc/99-tempsensor.rules

    Then please run the below and paste the output to confirm?
    cat /etc/udev/rules.d/99-tempsensor.rules

    Then reboot and retry python3 -m temperusb.cli -v and paste the output. Thanks for persevering!

  8. Stylopidae1793 commented on May 8, 2023

    @Stylopidae1793
    Author

    It doesn't look like the code I added is showing up.

    cat /etc/udev/rules.d/99-tempsensor.rules
    SUBSYSTEMS=="usb", ACTION=="add", ATTRS{idVendor}=="0c45", ATTRS{idProduct}=="7401", MODE="666"
    SUBSYSTEMS=="usb", ACTION=="add", ATTRS{idVendor}=="0c45", ATTRS{idProduct}=="7402", MODE="666"
    
    Traceback (most recent call last):
      File "/home/pi/temper-python/temperusb/temper.py", line 99, in __init__
        productname = self._device.product
      File "/usr/local/lib/python3.9/dist-packages/pyusb-1.2.1-py3.9.egg/usb/core.py", line 875, in product
        self._product = util.get_string(self, self.iProduct)
      File "/usr/local/lib/python3.9/dist-packages/pyusb-1.2.1-py3.9.egg/usb/util.py", line 313, in get_string
        raise ValueError("The device has no langid"
    ValueError: The device has no langid (permission issue, no string descriptors supported or device error)
    
    During handling of the above exception, another exception occurred:
    
    Traceback (most recent call last):
      File "/usr/lib/python3.9/runpy.py", line 197, in _run_module_as_main
        return _run_code(code, main_globals, None,
      File "/usr/lib/python3.9/runpy.py", line 87, in _run_code
        exec(code, run_globals)
      File "/home/pi/temper-python/temperusb/cli.py", line 110, in <module>
        main()
      File "/home/pi/temper-python/temperusb/cli.py", line 42, in main
        th = TemperHandler()
      File "/home/pi/temper-python/temperusb/temper.py", line 432, in __init__
        self._devices += [TemperDevice(device) for device in \
      File "/home/pi/temper-python/temperusb/temper.py", line 432, in <listcomp>
        self._devices += [TemperDevice(device) for device in \
      File "/home/pi/temper-python/temperusb/temper.py", line 102, in __init__
        raise usb.core.USBError("Error reading langids from device. "+
    usb.core.USBError: [Errno None] Error reading langids from device. This might be a permission issue. Please check that the device node for your TEMPer devices can be read and written by the user running this code. The temperusb README.md contains hints about how to fix this. Search for 'USB device permissions'.```
  9. davet2001 commented on May 8, 2023

    @davet2001
    Collaborator

    You definitely need to edit the udev rules file until you see 3 lines in it.

    What happened when you tried to save it?

  10. Stylopidae1793 commented on May 8, 2023

    @Stylopidae1793
    Author

    When I write it directly using the Pi operating system, it saves it without a problem. I can access it and it shows up.

    However, when I nano into /etc/udev/rules.d/99-tempsensor.rules, it says permission denied and the line I added using the direct access method does not show up.

  11. davet2001 commented on May 8, 2023

    @davet2001
    Collaborator

    Try
    sudo echo '"SUBSYSTEMS=="usb", ACTION=="add", ATTRS{idVendor}=="1a86", ATTRS{idProduct}=="e025", MODE="666"' >> /etc/udev/rules.d/99-tempsensor.rules

    Then check it using the same method.

  12. Stylopidae1793 commented on May 9, 2023

    @Stylopidae1793
    Author

    It still says permission denied, unfortunately.

  13. davet2001 commented on May 9, 2023

    @davet2001
    Collaborator

    You need to be able to modify the config.

    Can you try the following in a terminal:

    sudo nano /etc/udev/rules.d/99-tempsensor.rules

    Then add the new line followed by enter

    Then press ctrl-o to write the file?

  14. Stylopidae1793 commented on May 10, 2023

    @Stylopidae1793
    Author

    That worked! The new line of code shows up in the 99-tempsensor.rules file. It doesn't let me copy/paste it in it's entirety, but it's definitely there.

    temper-poll still gives me an error, though:

    Traceback (most recent call last):
      File "/usr/local/lib/python3.9/dist-packages/temperusb-1.6.0-py3.9.egg/temperusb/temper.py", line 99, in __init__
      File "/usr/local/lib/python3.9/dist-packages/pyusb-1.2.1-py3.9.egg/usb/core.py", line 875, in product
        self._product = util.get_string(self, self.iProduct)
      File "/usr/local/lib/python3.9/dist-packages/pyusb-1.2.1-py3.9.egg/usb/util.py", line 313, in get_string
        raise ValueError("The device has no langid"
    ValueError: The device has no langid (permission issue, no string descriptors supported or device error)
    
    During handling of the above exception, another exception occurred:
    
    Traceback (most recent call last):
      File "/usr/local/bin/temper-poll", line 33, in <module>
        sys.exit(load_entry_point('temperusb==1.6.0', 'console_scripts', 'temper-poll')())
      File "/usr/local/lib/python3.9/dist-packages/temperusb-1.6.0-py3.9.egg/temperusb/cli.py", line 42, in main
      File "/usr/local/lib/python3.9/dist-packages/temperusb-1.6.0-py3.9.egg/temperusb/temper.py", line 432, in __init__
      File "/usr/local/lib/python3.9/dist-packages/temperusb-1.6.0-py3.9.egg/temperusb/temper.py", line 432, in <listcomp>
      File "/usr/local/lib/python3.9/dist-packages/temperusb-1.6.0-py3.9.egg/temperusb/temper.py", line 102, in __init__
    usb.core.USBError: [Errno None] Error reading langids from device. This might be a permission issue. Please check that the device node for your TEMPer devices can be read and written by the user running this code. The temperusb README.md contains hints about how to fix this. Search for 'USB device permissions'.
    
  15. davet2001 commented on May 10, 2023

    @davet2001
    Collaborator

    @Stylopidae1793 Did you reboot after editing the file? If not please can you reboot and retry?

  16. davet2001 commented on May 10, 2023

    @davet2001
    Collaborator

    Please can you also paste the output from cat /etc/udev/rules.d/99-tempsensor.rules?

  17. Stylopidae1793 commented on May 11, 2023

    @Stylopidae1793
    Author

    I edited the file, and then rebooted the device. I shut the pi down, then restarted it. I also used sudo reboot.

    Here's the output:

    cat /etc/udev/rules.d/99-tempsensor.rules
    SUBSYSTEMS=="usb", ACTION=="add", ATTRS{idVendor}=="0c45", ATTRS{idProduct}=="7401", MODE="666"
    SUBSYSTEMS=="usb", ACTION=="add", ATTRS{idVendor}=="0c45", ATTRS{idProduct}=="7402", MODE="666"
    SUBSYSTEMS=="usb", ACTION=="add", ATTRS{idVendor}=="1a86", ATTRS{idProduct}=="e025", MODE="666"
    
  18. davet2001 commented on May 11, 2023

    @davet2001
    Collaborator

    Ok, please can you confirm that you still got the error after the reboot?

    If so, please can you try running the script as root, ie sudo python3 -m temperusb.cli -v?

    You may need to install some extra packages via sudo pip. If that happens, I would appreciate if you could resolve those issues yourself via Google before coming back with a question.

    (If you can confirm the library works, I can merge it and resolve your permissions issue outside of this ticket.)

  19. davet2001 commented on Jun 4, 2023

    @davet2001
    Collaborator

    @Stylopidae1793 did you get any success testing this?

  20. Stylopidae1793 commented on Jun 6, 2023

    @Stylopidae1793
    Author

    My apologies for the long delay.

    I did some troubleshooting on my own, and I was finally able to get it working last week. I'm not entirely sure what I did, but eventually it started working.

    I'll close the thread now.

  21. davet2001 commented on Jun 6, 2023

    @davet2001
    Collaborator

    @Stylopidae1793 if the new branch worked, I'll merge it so that everyone can use it.

    Do I understand correctly that the previously non working TEMPer device now works with the code from the branch that I linked above?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions