Giter VIP home page Giter VIP logo

temper-python's Introduction

This is a rewrite of a userspace USB driver for TEMPer devices presenting a USB ID like this: 0c45:7401 Microdia My device came from M-Ware ID7747 and also reports itself as 'RDing TEMPerV1.2'.

Also provides a passpersist-module for NetSNMP (as found in the snmpd packages of Debian and Ubuntu) to present the temperature of 1-3 USB devices via SNMP.

Reported working devices

USB ID Name Reported Notes
0c45:7401 Microdia RDing TEMPerV1.2 First supported device
0c45:7401 Microdia TEMPer Temperature Sensor RDing TEMPer2_M12_V1.3 Two sensor device
0c45:7401 Microdia RDing TEMPer1F_V1.3 Single external sensor, but better precision is possible by using "sensor 2"
0c45:7401 Microdia RDing TEMPerV1.4
0c45:7402 Microdia TEMPerHUM Temperature & Humidity Sensor RDing TEMPer1F_H1_V1.4 Single sensor which reports both temperature and relative-humidity

Requirements

Basically, libusb bindings for python (PyUSB) and snmp-passpersist from PyPI.

Under Debian/Ubuntu, treat yourself to some package goodness:

sudo apt-get install python-usb python-setuptools snmpd # The latter is only necessary for SNMP-usage.
sudo easy_install snmp-passpersist

Installation and usage

To install using pip, run

pip install temperusb

To install from source, clone the repository, cd into its top-level directory, and run

sudo python setup.py install

you should end up with two scripts conveniently installed:

/usr/local/bin/temper-poll
/usr/local/bin/temper-snmp

If your system does not provide access as a normal user to the USB device, you need to run them as root. See "USB device permissions" section for more on this.

temper-poll accepts -p option now, which adds the USB bus and port information each device is plugged on.

without -p option

$ temper-poll
Found 1 devices
Device #0: 22.5°C 72.5°F

with -p option

$ temper-poll -p
Found 1 devices
Device #0 (bus 1 - port 1.3): 22.4°C 72.3°F

Which tells you there is a USB hub plugged (internally or externally) on the port 1 of the bus 1 of the host, and your TEMPer device is on the port 3 of that hub.

Tell kernel to leave TEMPer alone

Regarding errors:

  • usb.core.USBError: [Errno 16] Resource busy
  • Unknown error

By default, the Linux kernel claims (e.g. opens/uses) the TEMPer device as a keyboard (HID device). When that happens, this script is not able to set the configuration and communicate with it.

You will see one of those two errors when running sudo temper-poll. Your dmesg log will show something similar to this:

usb 1-1.3: usbfs: interface 0 claimed by usbhid while 'temper-poll' sets config #1

To prevent this, add this to the kernel command line:

usbhid.quirks=0x0c45:0x7401:0x4

On Raspbian, this will be /boot/cmdline.txt. Reboot after saving and retry. Hat tip to and more information from AndiDog here.

Serving via SNMP

Using NetSNMP, you can use temper/snmp.py as a pass_persist module. You can choose one of two OIDs to be emulated: APC's typical internal/battery temperature (.1.3.6.1.4.1.318.1.1.1.2.2.2.0) or Cisco's typical temperature OIDs (.1.3.6.1.4.1.9.9.13.1.3.1.3.1 - 3.3).

Note that you should not activate both modes at the same time. The reason for this limitation is that the script will keep running for each pass_persist entry and they will interfere with each other when updating the temperature. This typically leads to syslog entries like this:

temper-python: Exception while updating data: could not release intf 1: Invalid argument

USB device permissions

At least on Debian Wheezy, the default USB device node has permissions to only allow access for root. In the same case, snmpd is running as the user snmpd. Bam. No access. You might find a corresponding note in syslog.

To solve that, the file 99-tempsensor.rules is a udev rule that allows access to the specific USB devices (with matching VID/PID) by anyone. Install like this:

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

Then restart.

To check for success, find the bus and device IDs of the devices like this:

pi@raspi-temper1 ~ $ lsusb | grep "0c45:7401"
Bus 001 Device 004: ID 0c45:7401 Microdia 
Bus 001 Device 005: ID 0c45:7401 Microdia 

pi@raspi-temper1 ~ $ ls -l /dev/usb*
crw------- 1 root root 189, 0 Jan  1  1970 /dev/usbdev1.1
crw------- 1 root root 189, 1 Jan  1  1970 /dev/usbdev1.2
crw------- 1 root root 189, 2 Jan  1  1970 /dev/usbdev1.3
crw-rw-rwT 1 root root 189, 3 Jan  1  1970 /dev/usbdev1.4
crw-rw-rwT 1 root root 189, 4 Jan  1  1970 /dev/usbdev1.5
pi@raspi-temper1 ~ $ 

Note that /dev/usbdev1.4 and /dev/usbdev1.5 have permissions for read/write for anyone, including snmp. This will work for the passpersist-module running along with snmpd.

What to add to snmpd.conf

To emulate an APC Battery/Internal temperature value, add something like this to snmpd.conf. The highest of all measured temperatures in degrees Celsius as an integer is reported.

pass_persist    .1.3.6.1.4.1.318.1.1.1.2.2.2 /usr/local/bin/temper-snmp

Alternatively, emulate a Cisco device's temperature information with the following. The first three detected devices will be reported as ..13.1.3.1.3.1, ..3.2 and ..3.3 . The value is the temperature in degree Celsius as an integer.

pass_persist    .1.3.6.1.4.1.9.9.13.1.3 /usr/local/bin/temper-snmp

Add --testmode to the line (as an option to snmp.py to enable a mode where APC reports 99°C and Cisco OIDs report 97, 98 and 99°C respectively. No actual devices need to be installed but libusb and its Python bindings are still required.

The path /usr/local/bin/ is correct if the installation using python setup.py install did install the scripts there. If you prefer not to install them, find and use the temper/snmp.py file.

Troubleshooting NetSNMP-interaction

The error reporting of NetSNMP is underwhelming to say the least. Expect every error to fail silently without a chance to find the source.

snmp.py reports some simple information to syslog with an ident string of temper-python and a facility of LOG_DAEMON. So this should give you the available debug information:

sudo tail -f /var/log/syslog | grep temper-python

Try stopping the snmpd daemon and starting it with logging to the console:

sudo service snmpd stop
sudo snmpd -f

It will not start the passpersist-process for snmp.py immediately but on the first request for the activated OIDs. This also means that the first snmpget you try may fail like this:

iso.3.6.1.4.1.9.9.13.1.3.1.3.2 = No Such Instance currently exists at this OID

To test the reporting, try this (twice if it first reports No Such Instance):

snmpget -c public -v 2c localhost .1.3.6.1.4.1.9.9.13.1.3.1.3.1 # Cisco #1
snmpget -c public -v 2c localhost .1.3.6.1.4.1.9.9.13.1.3.1.3.2 # Cisco #2
snmpget -c public -v 2c localhost .1.3.6.1.4.1.9.9.13.1.3.1.3.3 # Cisco #3
snmpget -c public -v 2c localhost .1.3.6.1.4.1.318.1.1.1.2.2.2.0 # APC

When NetSNMP starts the instance (upon first snmpget), you should see something like this in syslog:

Jan  6 16:01:51 raspi-temper1 temper-python: Found 2 thermometer devices.
Jan  6 16:01:51 raspi-temper1 temper-python: Initial temperature of device #0: 22.2 degree celsius
Jan  6 16:01:51 raspi-temper1 temper-python: Initial temperature of device #1: 10.9 degree celsius

If you don't even see this, maybe the script has a problem and quits with an exception. Try running it manually and mimik a passpersist-request (-> means you should enter the rest of the line):

-> sudo temper/snmp.py 
-> PING
<- PONG
-> get
-> .1.3.6.1.4.1.318.1.1.1.2.2.2.0
<- .1.3.6.1.4.1.318.1.1.1.2.2.2.0
<- INTEGER
<- 22.25

If you have a problem with the USB side and want to test SNMP, run the script with --testmode.

Using MQTT

While temper-python does not directly support MQTT, it is fairly straightforeward to push the temperature values collected to a MQTT broker periodically, so they may be integrated in for example Home-Assistant.

In the below example we will show how to push data to a Mosquitto MQTT broker using a small bash script and a CRON job. The setup was tested with temper-python installed on a RaspberryPi running Rasbian Buster and a Mosquitto MQTT broker installed as part of Home-Assistant.

In this example we will publish one specific temperature value for one specific device, for example the temperatue in Celcius for device 0 To test this, type on your console:

$ /usr/local/bin/temper-poll -c -s 0
1.9

As you can see because of the "-c" option, temper-poll will present a single temperature value in degrees Celcius. To get degrees Farenheit, use option "-f" The "-s 0" option makes sure temper-poll only looks at Device #0

We now need to install the Mosquitto client on the device where you installed temper-python. This will provide the mosquitto_pub client which we will use to push towards the MQTT broker

 sudo apt-get install mosquitto-clients

To start pushing a value to your MQTT broker, you also need to know the MQTT server IP adress and optionally a username and password. A mosquitto_pub command looks something like this:

 /usr/bin/mosquitto_pub -h MQTT_IP -m "Some message" -t MQTT_TOPIC -u MQTT_USERNAME -P MQTT_PASSWORD

If you need more paramaters, have a look at the output of

 mosquitto_pub --help

If needed, use the "-d" option for mosquitto_pub, which will print debug output about the connection. A successful connection debug print should look like:

 pi@raspberrypi:~ $ /usr/bin/mosquitto_pub -h 10.0.0.* -m "foobar" -t home-assistant/temper_schuur/temperature -u ****** -P ****** -d
 Client mosqpub|2107-raspberryp sending CONNECT
 Client mosqpub|2107-raspberryp received CONNACK (0)
 Client mosqpub|2107-raspberryp sending PUBLISH (d0, q0, r0, m1, 'home-assistant/temper_schuur/temperature', ... (0 bytes))
 Client mosqpub|2107-raspberryp sending DISCONNECT

We will now combine the two using a small bash script called "temper-push-mqtt". First create the script, then make it executable.

 sudo touch /usr/local/bin/temper-push-mqtt
 sudo chmod a+x /usr/local/bin/temper-push-mqtt
 sudo nano /usr/local/bin/temper-push-mqtt

The script should contain:

 #! /bin/bash
 T=$(/usr/local/bin/temper-poll -c -s 0)
 /usr/bin/mosquitto_pub -h MQTT_IP -m "${T}" -t MQTT_TOPIC -u MQTT_USER -P MQTT_PASSWORD

If you need other parameters for temper-poll, replace them here. Also replace all MQTT_* values with proper values for you local setup. If you are using Home-Assistant you should add a sensor to you setup by defining it in configuration.yaml:

 sensor:
   - platform: mqtt
     name: "Temperatuur Schuur"
     state_topic: "home-assistant/temper_schuur/temperature"
     unit_of_measurement: "°C"

Make sure the state_topic value matches the MQTT_TOPIC value in the temper-push-mqtt script

Finally, to make sure we get periodic data, we create a cron job to run the script every 5 minutes

 sudo crontab -e 

To start a new crontab, which should contain

 */5 * * * *  /usr/local/bin/temper-push-mqtt  > /var/log/cron_temper-push-mqtt.log 2>&1

The above cronjob will run the temper-push-mqtt script every 5 minutes and will log any issues to a logfile /var/log/cron_temper-push-mqtt.log

Note on multiple device usage

The devices I have seen do not have any way to identify them. The serial number is 0. There is no way (and this driver does not make any attempt) to present a persistent ordering among the USB devices. The effective order is the one that libusb presents. That seems to be based on the enumeration order of the devices.

That in turn seems to be based primarily on the physical ordering in the root hub -> hub port hierarchy on bootup. But if you unplug and replug the device (or it gets detached due to a glitch and is redetected) then the order of the devices may be changed.

If that happens, your temperature readings will change and you cannot say which device belongs to what OID if you are using SNMP.

Long story short: Only use the device order if the USB bus is stable and you reboot after any plugging on the device. Even then, you are not safe. Sorry.

Note by GM3D

Since calibration parameters must be set per each device, we need some way to identify them physically. As mentioned above, the serial number for all TEMPer devices is zero, so there is no true way to tell which is which programmatically. The USB device number does not work either since it changes every time you reboot the machine or plug/unplug the device. The way that possibly can work is identifying them by the combination of the bus number and the USB port (possibly a chain of ports, if you have hubs in between), which is what I am doing for now.

This information is basically the same with what you can get with lsusb -t and is based on the information in the sysfs directory /sys/bus/usb/devices (see below). So far I am assuming this scheme is persistent enough for regular use cases, but even the bus number may change in some cases like - for example - if your machine is a tablet like machine and you hotplug it to a keyboard dock with a USB root hub in it. In such case you will need to re-run lsusb and adjust the bus-port numbers in the configuration file accordingly. At the moment I have no clue about SNMP OID persistence.

Calibration parameters

You can have parameters in the configuration file /etc/temper.conf for each of your TEMPer device to calibrate its value with simple linear formula. If there is not this file on your machine it's fine, calibration is just skipped. The same if the program can't find a matching line with the actual device on the system.

Format of calibration lines in /etc/temper.conf is:

n-m(.m)* : scale = a, offset = b

where n is the USB bus number and m is (possibly a chain of) the USB port(s) which your TEMPer device is plugged on. a and b are some floating values decided by experiment, we will come back to this later, first let me describe how n and m can be decided for your device.

You will need to use lsusb command in usbutils package to decide n and m. Use lsusb with and without -t option.

For example, assume the following outputs;

$ lsusb
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 001 Device 016: ID 0c45:7401 Microdia 
Bus 001 Device 015: ID 1a40:0101 TERMINUS TECHNOLOGY INC. USB-2.0 4-Port HUB
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

$ lsusb -t
/:  Bus 02.Port 1: Dev 1, Class=root_hub, Driver=orion-ehci/1p, 480M
/:  Bus 01.Port 1: Dev 1, Class=root_hub, Driver=orion-ehci/1p, 480M
    |__ Port 4: Dev 15, If 0, Class=hub, Driver=hub/4p, 12M
        |__ Port 3: Dev 16, If 0, Class=HID, Driver=usbhid, 1.5M
        |__ Port 3: Dev 16, If 1, Class=HID, Driver=usbhid, 1.5M

First output tells you your TEMPer device (0c45:7401 Microdia) is on the bus 1 and has (just currently, it may change time to time, even if you don't move it around) device ID = 16.

Now look at the second output. Looking at this tree, your TEMPer device (Dev 16) on the bus 01 is connected to your pc through two ports, port 4 and port 3. Don't worry about two devices having the same Dev ID = 16, they both belong to a single TEMPer device (it uses two USB interfaces by default, which is normal).

So in this example, n = 1 and m = 4.3; thus the config file should be like

1-4.3: scale = a, offset = b

with a and b replaced with the actual values which you will need to measure and calculate for your own TEMPer device. These values are used in the formula

y = a * x + b

where

  • y: calibrated temperature (in Celsius),
  • x: raw temperature read from your TEMPer device (in Celsius).

You will need to find appropriate values for a and b for your TEMPer device by doing some experiment and basic math. Either comparing it with another thermometer which you can rely on or measuring two temperatures which you already know ... like iced water and boiling water, but make sure in the latter case that you seal your TEMPer device firmly in a plastic bag or something, since it is NOT waterproof!

To find out bus and port numbers, you can also try running temper-poll with -p option, which will contain information in the form (bus 1 - port 4.3) in the above example. This might be actually easier than looking at the lsusb outputs, as long as it works.

Origins

The USB interaction pattern is extracted from here as seen on Google+.

Compatibility with Python versions

This should work on Python 3.7 and above. It was tested with Python 3.7, 3.8, 3.9, 3.10, 3.11, 3.12.

Authors

  • Original rewrite by Philipp Adelt [email protected]
  • Additional work by Brian Cline
  • Calibration code by Joji Monma (@GM3D on Github)
  • Munin plugin by Alexander Schier (@allo- on Github)
  • PyPI package work and rewrite to libusb1 by James Stewart (@amorphic on Github)
  • Reduced kernel messages, support multiple sensors, and support TEMPer1F_V1.3 by Philip Jay (@ps-jay on Github)
  • Python 3 compatibility and rewrite of cli.py to use argparse by Will Furnass (@willfurnass on Github)
  • TEMPerV1.4 support by Christian von Roques (@roques on Github)
  • Pytest and architecture improvement by Dave Thompson (@davet2001 on Github).

temper-python's People

Contributors

allo- avatar amorphic avatar bit avatar briancline avatar creativethings avatar davet2001 avatar dertak avatar dhellmann avatar endolith avatar eric-s-raymond avatar foundbobby avatar gm3d avatar moonpyk avatar nikdoof avatar padelt avatar ps-jay avatar roques avatar rtaft avatar saimonn avatar sielicki avatar smeek avatar tamcore avatar u1f35c avatar warper avatar willfurnass avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

temper-python's Issues

Temperature gets "stuck" or skips values

So I've had this for years and it's always had this problem, but your "Reported working devices" includes this VID/PID? So maybe there's a bug that's been fixed that you know about?

Here are the USB descriptors:

Bus 002 Device 002: ID 0c45:7401 Microdia TEMPer Temperature Sensor
Device Descriptor:
  bLength                18
  bDescriptorType         1
  bcdUSB               2.00
  bDeviceClass            0 (Defined at Interface level)
  bDeviceSubClass         0 
  bDeviceProtocol         0 
  bMaxPacketSize0         8
  idVendor           0x0c45 Microdia
  idProduct          0x7401 TEMPer Temperature Sensor
  bcdDevice            0.01
  iManufacturer           1 
  iProduct                2 
  iSerial                 0 
  bNumConfigurations      1
  Configuration Descriptor:
    bLength                 9
    bDescriptorType         2
    wTotalLength           59
    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.10
          bCountryCode            0 Not supported
          bNumDescriptors         1
          bDescriptorType        34 Report
          wDescriptorLength      65
         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              10
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        1
      bAlternateSetting       0
      bNumEndpoints           1
      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      41
         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

and here is the log from several years:

obviously not correct

As you can see, it goes up and down with the seasons, but avoids certain temperature ranges and gets "stuck" at certain temperatures. If I do diff(unique(data)), though, it seems like it actually has 0.0625 °C resolution across the entire range:

it does actually reach all values though

It just strongly prefers certain temperatures over others. I don't know if this is a bug in the hardware, firmware, or software that reads it, but I'm posting here in case you know. It's been logging using cba5bf4 since that date. If you know this has nothing to do with your software, feel free to close it.

Temperature is never below -1.8 C

dmesg output: [ 2.225797] usb 1-1.5: Product: TEMPer2_M12_V1.3

Command I use:

$ raspberrypi  ~/g/temper-python> temper-poll -s 1                                                                                                                                                    
Found 1 devices
Device #0: -1.8°C 28.7°F

Result in Finland currently:

image

During the daytime, temperature is correctly reported. But at night when it gets freezing, values never go below -1.8C. In reality, it gets colder than that.

My temper device should work up to -40C. Could it be that something changes at -1.8C regarding how the value is read? I'm also wondering if my device is faulty but that doesn't feel likely as day temperatures are very accurate.

Trying to run on Centos 6.4 gives the following error

Found 1 devices
Traceback (most recent call last):
File "/usr/bin/temper-poll", line 9, in
load_entry_point('temperusb==1.2.1', 'console_scripts', 'temper-poll')()
File "/usr/lib/python2.6/site-packages/temperusb-1.2.1-py2.6.egg/temperusb/cli .py", line 33, in main
'temperature_c': dev.get_temperature(),
File "/usr/lib/python2.6/site-packages/temperusb-1.2.1-py2.6.egg/temperusb/tem per.py", line 150, in get_temperature
self._interrupt_read()
File "/usr/lib/python2.6/site-packages/temperusb-1.2.1-py2.6.egg/temperusb/tem per.py", line 194, in _interrupt_read
data = self._device.read(ENDPOINT, REQ_INT_LEN, interface=INTERFACE, timeout =TIMEOUT)
TypeError: read() got an unexpected keyword argument 'interface'

I am running on Centos 6.4 32bit with pyusb 1.0b2
The device is reported as Bus 002 Device 010: ID 0c45:7401 Microdia by lsusb

Python 3.x support?

A few things that need to be handled differently in Python 3.x:

  • temper.py features long hex literals like 0x0c45L. Python 3 does not have longs (not needed as ints are arbitrary precision).
  • do COMMANDS need to be byte strings?
  • the part of TemperDevice.get_temperature that interprets device responses may need to change
  • ranges are generator expressions so in some cases need to be explicitly converted to lists
  • possibly other things

temper-poll crashes with broken pipe now and then

No handlers could be found for logger "temperusb.temper"
Found 1 devices
Traceback (most recent call last):
File "/usr/local/bin/temper-poll", line 9, in
load_entry_point('temperusb==1.2.1', 'console_scripts', 'temper-poll')()
File "/usr/local/lib/python2.7/dist-packages/temperusb-1.2.1-py2.7.egg/temperusb/cli.py", line 50, in main
'temperature_c': dev.get_temperature(),
File "/usr/local/lib/python2.7/dist-packages/temperusb-1.2.1-py2.7.egg/temperusb/temper.py", line 151, in get_temperature
self._control_transfer(COMMANDS['ini1'])
File "/usr/local/lib/python2.7/dist-packages/temperusb-1.2.1-py2.7.egg/temperusb/temper.py", line 188, in _control_transfer
wValue=0x0200, wIndex=0x01, data_or_wLength=data, timeout=TIMEOUT)
File "/usr/local/lib/python2.7/dist-packages/pyusb-1.0.0b2-py2.7.egg/usb/core.py", line 971, in ctrl_transfer
self.__get_timeout(timeout))
File "/usr/local/lib/python2.7/dist-packages/pyusb-1.0.0b2-py2.7.egg/usb/backend/libusb0.py", line 528, in ctrl_transfer
timeout
File "/usr/local/lib/python2.7/dist-packages/pyusb-1.0.0b2-py2.7.egg/usb/backend/libusb0.py", line 380, in _check
raise USBError(errmsg, ret)
usb.core.USBError: [Errno None] error sending control message: Broken pipe

fixed the line 10 error as in #80 but resulting exe does not work yet

It used to run under previsou OSX but not now under high sierra
Any idea what I am missing?
A dependency I guess!!

temper-poll -p
Traceback (most recent call last):
  File "/opt/miniconda2/bin/temper-poll", line 11, in <module>
    load_entry_point('temperusb==1.5.3', 'console_scripts', 'temper-poll')()
  File "/opt/biotools/temper-python/temperusb/cli.py", line 38, in main
    th = TemperHandler()
  File "/opt/biotools/temper-python/temperusb/temper.py", line 420, in __init__
    usb.core.find(find_all=True, idVendor=vid, idProduct=pid)]
  File "build/bdist.macosx-10.6-x86_64/egg/usb/core.py", line 1263, in find
usb.core.NoBackendError: No backend available

Temper-poll timeouts then stops getting data

Hi,
Thanks for this software :-)
I'm trying to make it work, but I keep getting this output after running the command for some time, once every 30 second. After an hour or so it starts crashing with this message:

ERROR:temperusb.temper:[Errno 110] Operation timed out
Traceback (most recent call last):
  File "/usr/bin/temper-poll", line 9, in <module>
    load_entry_point('temperusb==1.5.2', 'console_scripts', 'temper-poll')()
  File "/usr/lib/python2.6/site-packages/temperusb-1.5.2-py2.6.egg/temperusb/cli.py", line 53, in main
    readings.append(dev.get_temperatures(sensors=sensors))
  File "/usr/lib/python2.6/site-packages/temperusb-1.5.2-py2.6.egg/temperusb/temper.py", line 300, in get_temperatures
    data = self.get_data()
  File "/usr/lib/python2.6/site-packages/temperusb-1.5.2-py2.6.egg/temperusb/temper.py", line 250, in get_data
    return self.get_data(True)
  File "/usr/lib/python2.6/site-packages/temperusb-1.5.2-py2.6.egg/temperusb/temper.py", line 230, in get_data
    self._interrupt_read()
  File "/usr/lib/python2.6/site-packages/temperusb-1.5.2-py2.6.egg/temperusb/temper.py", line 334, in _interrupt_read
    data = self._device.read(ENDPOINT, REQ_INT_LEN, timeout=TIMEOUT)
  File "/usr/lib/python2.6/site-packages/pyusb-1.0.0-py2.6.egg/usb/core.py", line 988, in read
    self.__get_timeout(timeout))
  File "/usr/lib/python2.6/site-packages/pyusb-1.0.0-py2.6.egg/usb/backend/libusb1.py", line 851, in intr_read
    timeout)
  File "/usr/lib/python2.6/site-packages/pyusb-1.0.0-py2.6.egg/usb/backend/libusb1.py", line 936, in __read
    _check(retval)
  File "/usr/lib/python2.6/site-packages/pyusb-1.0.0-py2.6.egg/usb/backend/libusb1.py", line 595, in _check
    raise USBError(_strerror(ret), ret, _libusb_errno[ret])
usb.core.USBError: [Errno 110] Operation timed out

Once this happens, it happens all the time.

I get this on /var/log/messages (or dmesg):

Mar 13 14:19:16 master kernel: usb 4-2: reset low speed USB device number 66 using ohci_hcd
Mar 13 14:19:16 master kernel: usb 4-2: usbfs: process 61958 (temper-poll) did not claim interface 1 before use
Mar 13 14:19:16 master kernel: usb 4-2: reset low speed USB device number 66 using ohci_hcd

The last line repeats itself after each execution of the command.

This is the device information (lsusb -v)

Bus 004 Device 066: ID 0c45:7401 Microdia 
Device Descriptor:
  bLength                18
  bDescriptorType         1
  bcdUSB               2.00
  bDeviceClass            0 (Defined at Interface level)
  bDeviceSubClass         0 
  bDeviceProtocol         0 
  bMaxPacketSize0         8
  idVendor           0x0c45 Microdia
  idProduct          0x7401 
  bcdDevice            0.01
  iManufacturer           1 RDing
  iProduct                2 TEMPerV1.4
  iSerial                 0 
  bNumConfigurations      1
  Configuration Descriptor:
    bLength                 9
    bDescriptorType         2
    wTotalLength           59
    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.10
          bCountryCode            0 Not supported
          bNumDescriptors         1
          bDescriptorType        34 Report
          wDescriptorLength      65
          Report Descriptor: (length is 65)
            Item(Global): Usage Page, data= [ 0x01 ] 1
                            Generic Desktop Controls
            Item(Local ): Usage, data= [ 0x06 ] 6
                            Keyboard
            Item(Main  ): Collection, data= [ 0x01 ] 1
                            Application
            Item(Global): Report ID, data= [ 0x01 ] 1
            Item(Global): Usage Page, data= [ 0x07 ] 7
                            Keyboard
            Item(Local ): Usage Minimum, data= [ 0xe0 ] 224
                            Control Left
            Item(Local ): Usage Maximum, data= [ 0xe7 ] 231
                            GUI Right
            Item(Global): Logical Minimum, data= [ 0x00 ] 0
            Item(Global): Logical Maximum, data= [ 0x01 ] 1
            Item(Global): Report Size, data= [ 0x01 ] 1
            Item(Global): Report Count, data= [ 0x08 ] 8
            Item(Main  ): Input, data= [ 0x02 ] 2
                            Data Variable Absolute No_Wrap Linear
                            Preferred_State No_Null_Position Non_Volatile Bitfield
            Item(Global): Report Count, data= [ 0x01 ] 1
            Item(Global): Report Size, data= [ 0x08 ] 8
            Item(Main  ): Input, data= [ 0x01 ] 1
                            Constant Array Absolute No_Wrap Linear
                            Preferred_State No_Null_Position Non_Volatile Bitfield
            Item(Global): Report Count, data= [ 0x03 ] 3
            Item(Global): Report Size, data= [ 0x01 ] 1
            Item(Global): Usage Page, data= [ 0x08 ] 8
                            LEDs
            Item(Local ): Usage Minimum, data= [ 0x01 ] 1
                            NumLock
            Item(Local ): Usage Maximum, data= [ 0x03 ] 3
                            Scroll Lock
            Item(Main  ): Output, data= [ 0x02 ] 2
                            Data Variable Absolute No_Wrap Linear
                            Preferred_State No_Null_Position Non_Volatile Bitfield
            Item(Global): Report Count, data= [ 0x05 ] 5
            Item(Global): Report Size, data= [ 0x01 ] 1
            Item(Main  ): Output, data= [ 0x01 ] 1
                            Constant Array Absolute No_Wrap Linear
                            Preferred_State No_Null_Position Non_Volatile Bitfield
            Item(Global): Report Count, data= [ 0x05 ] 5
            Item(Global): Report Size, data= [ 0x08 ] 8
            Item(Global): Logical Minimum, data= [ 0x00 ] 0
            Item(Global): Logical Maximum, data= [ 0xff ] 255
            Item(Global): Usage Page, data= [ 0x07 ] 7
                            Keyboard
            Item(Local ): Usage Minimum, data= [ 0x00 ] 0
                            No Event
            Item(Local ): Usage Maximum, data= [ 0xff ] 255
                            (null)
            Item(Main  ): Input, data= [ 0x00 ] 0
                            Data Array Absolute No_Wrap Linear
                            Preferred_State No_Null_Position Non_Volatile Bitfield
            Item(Main  ): End Collection, data=none
      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              10
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        1
      bAlternateSetting       0
      bNumEndpoints           1
      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      41
          Report Descriptor: (length is 41)
            Item(Global): Usage Page, data= [ 0x00 0xff ] 65280
                            (null)
            Item(Local ): Usage, data= [ 0x01 ] 1
                            (null)
            Item(Main  ): Collection, data= [ 0x01 ] 1
                            Application
            Item(Local ): Usage, data= [ 0x01 ] 1
                            (null)
            Item(Global): Logical Minimum, data= [ 0x00 ] 0
            Item(Global): Logical Maximum, data= [ 0xff 0x00 ] 255
            Item(Global): Report Size, data= [ 0x08 ] 8
            Item(Global): Report Count, data= [ 0x08 ] 8
            Item(Main  ): Input, data= [ 0x02 ] 2
                            Data Variable Absolute No_Wrap Linear
                            Preferred_State No_Null_Position Non_Volatile Bitfield
            Item(Local ): Usage, data= [ 0x01 ] 1
                            (null)
            Item(Global): Report Count, data= [ 0x08 ] 8
            Item(Main  ): Output, data= [ 0x02 ] 2
                            Data Variable Absolute No_Wrap Linear
                            Preferred_State No_Null_Position Non_Volatile Bitfield
            Item(Global): Usage Page, data= [ 0x0c ] 12
                            Consumer
            Item(Local ): Usage, data= [ 0x00 ] 0
                            Unassigned
            Item(Global): Logical Minimum, data= [ 0x80 ] 128
            Item(Global): Logical Maximum, data= [ 0x7f ] 127
            Item(Global): Report Size, data= [ 0x08 ] 8
            Item(Global): Report Count, data= [ 0x08 ] 8
            Item(Main  ): Feature, data= [ 0x02 ] 2
                            Data Variable Absolute No_Wrap Linear
                            Preferred_State No_Null_Position Non_Volatile Bitfield
            Item(Main  ): End Collection, data=none
      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
Device Status:     0x0000
  (Bus Powered)

I'm using RHEL6.

I've read some similar issues, but I think they were marked as solved after changing the code. My temper-poll version is the last one, I just reinstalled it to be sure in included the last updates.

Cheers

Windows failing on is_kernel_driver_active

On Windows the is_kernel_driver_active() function is not implemented in libusb, this is a Linux only feature. To use on Windows the NotImplementedError exception could be caught and ignored. temper.py line ~217:

            try:
                if self._device.is_kernel_driver_active(interface):
                    LOGGER.debug('Detaching kernel driver for interface %d '
                        'of %r on ports %r', interface, self._device, self._ports)
                    self._device.detach_kernel_driver(interface)
            except NotImplementedError:
                pass

trouble installing under OSX 10.10.5

I installed on my mac (Python 2.7.11) what I think are dependencies, the installer added others.
sudo pip install snmp-passpersist
sudo port install libusb-devel

when I run sudo python setup.py install I get

running install
running bdist_egg
running egg_info
writing requirements to temperusb.egg-info/requires.txt
writing temperusb.egg-info/PKG-INFO
writing top-level names to temperusb.egg-info/top_level.txt
writing dependency_links to temperusb.egg-info/dependency_links.txt
writing entry points to temperusb.egg-info/entry_points.txt
reading manifest file 'temperusb.egg-info/SOURCES.txt'
reading manifest template 'MANIFEST.in'
writing manifest file 'temperusb.egg-info/SOURCES.txt'
installing library code to build/bdist.macosx-10.5-x86_64/egg
running install_lib
running build_py
creating build/bdist.macosx-10.5-x86_64/egg
creating build/bdist.macosx-10.5-x86_64/egg/temperusb
copying build/lib/temperusb/__init__.py -> build/bdist.macosx-10.5-x86_64/egg/temperusb
copying build/lib/temperusb/cli.py -> build/bdist.macosx-10.5-x86_64/egg/temperusb
copying build/lib/temperusb/snmp.py -> build/bdist.macosx-10.5-x86_64/egg/temperusb
copying build/lib/temperusb/temper.py -> build/bdist.macosx-10.5-x86_64/egg/temperusb
byte-compiling build/bdist.macosx-10.5-x86_64/egg/temperusb/__init__.py to __init__.pyc
byte-compiling build/bdist.macosx-10.5-x86_64/egg/temperusb/cli.py to cli.pyc
byte-compiling build/bdist.macosx-10.5-x86_64/egg/temperusb/snmp.py to snmp.pyc
byte-compiling build/bdist.macosx-10.5-x86_64/egg/temperusb/temper.py to temper.pyc
creating build/bdist.macosx-10.5-x86_64/egg/EGG-INFO
copying temperusb.egg-info/PKG-INFO -> build/bdist.macosx-10.5-x86_64/egg/EGG-INFO
copying temperusb.egg-info/SOURCES.txt -> build/bdist.macosx-10.5-x86_64/egg/EGG-INFO
copying temperusb.egg-info/dependency_links.txt -> build/bdist.macosx-10.5-x86_64/egg/EGG-INFO
copying temperusb.egg-info/entry_points.txt -> build/bdist.macosx-10.5-x86_64/egg/EGG-INFO
copying temperusb.egg-info/requires.txt -> build/bdist.macosx-10.5-x86_64/egg/EGG-INFO
copying temperusb.egg-info/top_level.txt -> build/bdist.macosx-10.5-x86_64/egg/EGG-INFO
zip_safe flag not set; analyzing archive contents...
creating 'dist/temperusb-1.5.1-py2.7.egg' and adding 'build/bdist.macosx-10.5-x86_64/egg' to it
removing 'build/bdist.macosx-10.5-x86_64/egg' (and everything under it)
Processing temperusb-1.5.1-py2.7.egg
Removing /opt/biotools/miniconda2/lib/python2.7/site-packages/temperusb-1.5.1-py2.7.egg
Copying temperusb-1.5.1-py2.7.egg to /opt/biotools/miniconda2/lib/python2.7/site-packages
temperusb 1.5.1 is already the active version in easy-install.pth
Installing temper-poll script to /opt/biotools/miniconda2/bin
Installing temper-snmp script to /opt/biotools/miniconda2/bin

Installed /opt/biotools/miniconda2/lib/python2.7/site-packages/temperusb-1.5.1-py2.7.egg
Processing dependencies for temperusb==1.5.1
Searching for pyusb==1.0.0
Best match: pyusb 1.0.0
Processing pyusb-1.0.0-py2.7.egg
pyusb 1.0.0 is already the active version in easy-install.pth

Using /opt/biotools/miniconda2/lib/python2.7/site-packages/pyusb-1.0.0-py2.7.egg
Finished processing dependencies for temperusb==1.5.1

but when I try to launch temper-poll I get an error (idem when adding sudo)

Traceback (most recent call last):
  File "/opt/biotools/miniconda2/bin/temper-poll", line 9, in 
    load_entry_point('temperusb==1.5.1', 'console_scripts', 'temper-poll')()
  File "build/bdist.macosx-10.5-x86_64/egg/temperusb/cli.py", line 36, in main
  File "build/bdist.macosx-10.5-x86_64/egg/temperusb/temper.py", line 340, in __init__
  File "build/bdist.macosx-10.5-x86_64/egg/usb/core.py", line 1263, in find
usb.core.NoBackendError: No backend available

the other command temper-snmp also fails similarily

Traceback (most recent call last):
  File "/opt/biotools/miniconda2/bin/temper-snmp", line 9, in 
    load_entry_point('temperusb==1.5.1', 'console_scripts', 'temper-snmp')()
  File "build/bdist.macosx-10.5-x86_64/egg/temperusb/snmp.py", line 90, in main
  File "/opt/biotools/miniconda2/lib/python2.7/site-packages/snmp_passpersist.py", line 364, in start
    self.update()
  File "build/bdist.macosx-10.5-x86_64/egg/temperusb/snmp.py", line 82, in update
  File "build/bdist.macosx-10.5-x86_64/egg/temperusb/snmp.py", line 53, in _reinitialize
AttributeError: Updater instance has no attribute 'devs'

Any idea what I could do to improve this?
Thanks

REM: The USB device is OK as my mac can read from the device using the standalone app (http://ssl-lab.blogspot.be/2012/02/controlling-your-temper-on-mac-os-x.html)

Setup.py is not found

Hi

I installed the package with
sudo apt-get install python-usb

If I try sudo python setup.py install

I get the error: can't open setup.py: [Errno 2] No such file or directory

I have confirmed the package is installed.

Note I am using a Raspberry Pi 2

Any help greatly appreciated.

Thanks, Jerry

AttributeError after broken pipe fail

Calls to get_temperature() continually fail after a broken pipe has occurred, even if the objects are recreated. Added an except clause to temper.py to catch AttributeError and just debug log it.
Have a modified version of temper.py here... do I need to make a pull request?

Adding support for Relative Humidity

I have a TEMPerHUM device (USB ID 0c45:7402, TEMPer1F_H1_V1.4) which I have working nicely with the current code after some small tweaks (pull requests already in).

I'd like to add support for reading the relative humidity, but before embarking on anything wondered what your preference was for adding this?

Currently the code is structured around the fact that you'll only be reading temperature, which means to add it cleanly it might require a sizable re-work.

Having sniffed the USB traffic and compared the values returned against the output of the Windows program, I know the conversion required:
rel_humidity = (((data[offset+2] << 8) + data[offset+3]) * 32) / 1000.0
I have hacked it in locally (immediately after reading the temperature in get_temperatures) to show it works.

Any comments on how you would like this structured / approached?

publish sensor data to MQTT

feature request:

how about publishing the temper read to a MQTT broker?

broker url, username, password, port, topic, and then a json string of the temperature data in F and C.

temperusb fails with newer pyusb

pyusb-1.0.0_beta2 causes a failure on startup:

# python ./temperusb/cli.py 
Found 1 devices
Traceback (most recent call last):
  File "./temperusb/cli.py", line 81, in <module>
    main()
  File "./temperusb/cli.py", line 50, in main
    'temperature_c': dev.get_temperature(),
  File "/root/temper-python/temperusb/temper.py", line 152, in get_temperature
    self._interrupt_read()
  File "/root/temper-python/temperusb/temper.py", line 196, in _interrupt_read
    data = self._device.read(ENDPOINT, REQ_INT_LEN, interface=INTERFACE, timeout=TIMEOUT)
TypeError: read() got an unexpected keyword argument 'interface'

which seems to be fixed by removing the interface argument:

diff --git a/temperusb/temper.py b/temperusb/temper.py
index 06510a3..8d3e146 100644
--- a/temperusb/temper.py
+++ b/temperusb/temper.py
@@ -193,7 +193,7 @@ class TemperDevice(object):
         """
         Read data from device.
         """
-        data = self._device.read(ENDPOINT, REQ_INT_LEN, interface=INTERFACE, timeout=TIMEOUT)
+        data = self._device.read(ENDPOINT, REQ_INT_LEN, timeout=TIMEOUT)
         LOGGER.debug('Read data: {0}'.format(data))
         return data

Retry on timeout

This works for the most part, but I have it set to log the temperature every few minutes, and it occasionally returns an error:

usb.core.USBError: [Errno 110] Operation timed out

Would it make sense to catch this and retry a few times automatically?

Regression: Operation timed out

In my recent PR I updated temperusb for compatibility with the recently-released pyusb 1.0.0b2. This PR was merged and released as part of temperusb 1.2.2.

However after using temperusb 1.2.2 for extended periods I'm noticing occurances of the dreaded: usb.core.USBError: [Errno 110] Operation timed out first reported in #3 and fixed as per #12.

As mentioned in #12, this was somehow related to the underlying usb library being used by pyusb. I'm not sure if pyusb 1.0.0b2 has introduced a regression or if this is a new problem related to the various changes from b1 to b2.

It would be good if a few others could try using temperusb 1.2.2 for an extended period and report their experiences. Something like this:

import temperusb
th = temperusb.TemperHandler()
td = th.get_devices()[0]
while True:
    td.get_temperature()
    sleep 10

If others see IOErrors at least we'll know that the issue is universal.

I'm on holidays for the next 2 weeks so will have only intermittent connectivity. However if we can confirm that this is indeed an issue @padelt I suggest a new release of temperusb (1.2.3) with the changes in #12 reverted and the pyusb version locked to 1.0.0b1 in setup.py:

'pyusb==1.0.0b1'

I'll investigate further and report the issue to the pyusb maintainers if one exists. We can then wait for a fix before upgrading.

Operation timed out

Hi, is this the same issue discussed in https://github.com/padelt/temper-python/issues/73 ?

Found 1 devices
WARNING:temperusb.temper:Encountered [Errno 110] Operation timed out, resetting <DEVICE ID 0c45:7401 on Bus 003 Address 013> and trying again.
ERROR:temperusb.temper:[Errno 110] Operation timed out
Traceback (most recent call last):
File "/usr/local/bin/temper-poll", line 11, in
load_entry_point('temperusb==1.5.3', 'console_scripts', 'temper-poll')()
File "build/bdist.linux-x86_64/egg/temperusb/cli.py", line 55, in main
File "build/bdist.linux-x86_64/egg/temperusb/temper.py", line 322, in get_temperatures
File "build/bdist.linux-x86_64/egg/temperusb/temper.py", line 272, in get_data
File "build/bdist.linux-x86_64/egg/temperusb/temper.py", line 243, in get_data
File "build/bdist.linux-x86_64/egg/temperusb/temper.py", line 402, in _interrupt_read
File "/usr/lib/python2.7/dist-packages/usb/core.py", line 988, in read
self.__get_timeout(timeout))
File "/usr/lib/python2.7/dist-packages/usb/backend/libusb1.py", line 851, in intr_read
timeout)
File "/usr/lib/python2.7/dist-packages/usb/backend/libusb1.py", line 936, in __read
_check(retval)
File "/usr/lib/python2.7/dist-packages/usb/backend/libusb1.py", line 595, in _check
raise USBError(_strerror(ret), ret, _libusb_errno[ret])
usb.core.USBError: [Errno 110] Operation timed out

0c45:7402 and usbfs conflicts

Hi there,

I get the following error message when I am running temper-poll:

WARNING:temperusb.temper:Encountered [Errno 110] Operation timed out, resetting <DEVICE ID 0c45:7402 on Bus 002 Address 004> and trying again.
ERROR:temperusb.temper:[Errno 110] Operation timed out
Traceback (most recent call last):
File "/usr/local/bin/temper-poll", line 9, in
load_entry_point('temperusb==1.5.3', 'console_scripts', 'temper-poll')()
File "build/bdist.linux-x86_64/egg/temperusb/cli.py", line 55, in main
File "build/bdist.linux-x86_64/egg/temperusb/temper.py", line 322, in get_temperatures
File "build/bdist.linux-x86_64/egg/temperusb/temper.py", line 272, in get_data
File "build/bdist.linux-x86_64/egg/temperusb/temper.py", line 243, in get_data
File "build/bdist.linux-x86_64/egg/temperusb/temper.py", line 402, in _interrupt_read
File "build/bdist.linux-x86_64/egg/usb/core.py", line 988, in read
File "build/bdist.linux-x86_64/egg/usb/backend/libusb1.py", line 851, in intr_read
File "build/bdist.linux-x86_64/egg/usb/backend/libusb1.py", line 936, in __read
File "build/bdist.linux-x86_64/egg/usb/backend/libusb1.py", line 595, in _check
usb.core.USBError: [Errno 110] Operation timed out

Even though I have:

  • "usbhid.quirks=0x0c45:0x7402:0x4" added to the /etc/default/grub file
  • Tried to load usbhid with the aforementioned parameters
  • Disabled autofs

kern.log:

usbfs: process 9043 (temper-poll) did not claim interface 1 before use
usb 2-2.3: usbfs: interface 1 claimed by usbfs while 'temper-poll' sets config #1
usb 2-2.3: usbfs: interface 1 claimed by usbfs while 'temper-poll' sets config #1

dmesg:

[ 6388.584030] usb 2-2.3: ep 0x82 - rounding interval to 64 microframes, ep desc says 80 microframes
[ 6388.585296] usb 2-2.3: usbfs: process 9043 (temper-poll) did not claim interface 1 before use
[ 6388.585628] usb 2-2.3: usbfs: interface 1 claimed by usbfs while 'temper-poll' sets config #1
[ 6388.963989] usb 2-2.3: usbfs: interface 1 claimed by usbfs while 'temper-poll' sets config #1
[ 6389.238041] usb 2-2.3: reset low-speed USB device number 4 using xhci_hcd

Ubuntu 16.04 LTS

I have tried "usbreset", it didn't work.

Any idea?

temper.py complains about unexpected parameter 'interface'

In /usr/local/lib/python2.7/dist-packages/temperusb-1.2.1-py2.7.egg/temperusb/temper.py
I commented out the data = self._device.read call and replaced it with a call that does not include the interface param...

[code]
def _interrupt_read(self):
"""
Read data from device.
"""
#data = self._device.read(ENDPOINT, REQ_INT_LEN, interface=INTERFACE, timeout=TIMEOUT)
data = self._device.read(ENDPOINT, REQ_INT_LEN, timeout=TIMEOUT)
LOGGER.debug('Read data: {0}'.format(data))
return data
[/code]

Tags not on github

Hi Philipp,

the tags seem to have disappeared from the Github repo...

Sensors stop responding

Running the latest version of temper-poll with 11 sensors attached on Ubuntu 12.04 LTS. The reset that was added a few versions ago fixed the problem of sensors not reporting, but now after many calls of temper-poll (50-100 calls, 1 call per minute) the sensors will stop responding. No error message, it just hangs on:

@___:~$ sudo temper-poll
[sudo] password for ___:
Found 11 devices

And never comes back. Control-C and Control-\ won't kill it either. This is reproducible, but I can't figure out what's causing it.

Devices not identified

Hello,
the Temper-Python program doesnt find my devices right.
I think the temper.conf file is ignored.

/etc/temper.conf:

1-1.2.4: scale = 2, offset = 5
1-1.5.4: scale = 2, offset = 10

The output of lsusb -t is:

1-1.5.4:1.1: No such file or directory
1-1.2.4:1.1: No such file or directory
/: Bus 01.Port 1: Dev 1, Class=root_hub, Driver=dwc_otg/1p, 480M
|__ Port 1: Dev 2, If 0, Class=hub, Driver=hub/5p, 480M
|__ Port 1: Dev 3, If 0, Class=vend., Driver=smsc95xx, 480M
|__ Port 2: Dev 20, If 0, Class=hub, Driver=hub/4p, 480M
|__ Port 4: Dev 21, If 0, Class=HID, Driver=usbhid, 1.5M
|__ Port 4: Dev 21, If 1, Class=HID, Driver=, 1.5M
|__ Port 5: Dev 4, If 0, Class=hub, Driver=hub/4p, 480M
|__ Port 1: Dev 5, If 0, Class=stor., Driver=usb-storage, 480M
|__ Port 2: Dev 6, If 0, Class=stor., Driver=usb-storage, 480M
|__ Port 4: Dev 18, If 0, Class=HID, Driver=usbhid, 1.5M
|__ Port 4: Dev 18, If 1, Class=HID, Driver=, 1.5M

/etc/temper.conf scale and offset values not loading - workaround

Hi,

First off, I really like the work you have done on this project & it has made using USB temperature devices so much easier. I actually did some research before hand and specifically looked for a device I could use with your code. Everything worked fine for me (following your instructions) apart from setting the scale and offset values so I thought I would highlight the issue I encountered & include my work around to help contribute back to the project.

On my Kubuntu 14.04LTS system I configured the /etc/temper.conf file as per the guide however my scale and offset values were not loaded or taken into account when calculating the temperature. By adding some debug statements to the /temper-python/temperusb/temper.py file I was able to identify that the the self._ports value was actually an integer value being compared to string and the self._ports value needed to be cast as string for the comparison at line 112 in the /temper-python/temperusb/temper.py file to work. I also needed to set the bus and port to be set exactly as per the output from temper-poll -p which was different to the explanation in the guide.

Here is my config and changes to work around the issue I encountered.

$python -V
Python 2.7.6

I'm using a temper device with the following id:
$lsusb
Bus 002 Device 004: ID 0c45:7401 Microdia

$lsusb -t
/: Bus 04.Port 1: Dev 1, Class=root_hub, Driver=xhci_hcd/2p, 5000M
/: Bus 03.Port 1: Dev 1, Class=root_hub, Driver=xhci_hcd/2p, 480M
/: Bus 02.Port 1: Dev 1, Class=root_hub, Driver=ehci-pci/2p, 480M
|__ Port 1: Dev 2, If 0, Class=Hub, Driver=hub/4p, 480M
|__ Port 2: Dev 3, If 0, Class=Mass Storage, Driver=usb-storage, 480M
|__ Port 3: Dev 4, If 0, Class=Human Interface Device, Driver=usbhid, 1.5M
|__ Port 3: Dev 4, If 1, Class=Human Interface Device, Driver=, 1.5M
/: Bus 01.Port 1: Dev 1, Class=root_hub, Driver=ehci-pci/2p, 480M
|__ Port 1: Dev 2, If 0, Class=Hub, Driver=hub/4p, 480M
|__ Port 1: Dev 3, If 0, Class=Human Interface Device, Driver=usbhid, 1.5M
|__ Port 2: Dev 4, If 0, Class=Human Interface Device, Driver=usbhid, 1.5M

$temper-poll -p
Found 1 devices
Device #0 (bus 2 - port 3): 20.5°C 68.9°F

/etc/temper.conf
2-3: scale = 1.0, offset = -4.6

With these settings (as stated above) I was able to read the temperature but the scale and offset values were not being recognised. This was caused by the the self._ports value being passed as an integer when (on my system) it needed to be cast as string for the comparison.

/termperusb/temper.py
line 112
if ports == self._ports:
changed to
if ports == str(self._ports):
fixed the issue.

Here is the function the above line resides in.
def set_calibration_data(self):
"""
Set device calibration data based on settings in /etc/temper.conf.
"""
self._scale = 1.0
self._offset = 0.0
try:
f = open('/etc/temper.conf', 'r')
except IOError:
f = None
if f:
lines = f.read().split('\n')
f.close()
for line in lines:
matches = re.match(CALIB_LINE_STR, line)
if matches:
bus = int(matches.groups()[0])
ports = matches.groups()[1]
scale = float(matches.groups()[2])
offset = float(matches.groups()[3])
if ports == str(self._ports):
self._scale = scale
self._offset = offset

Changing line 112 resolved the issue for me & now the scale and offset values are correctly loaded and taken into account when printing the final temperature values.

Thanks again for the great work.

  • Merric

Unchanged reading on temper-poll

Hi

Thanks for creating this library - I've installed it with one of my RDing Temper USB devices on a Raspberry Pi. All seems OK except that, on polling for the temperature every minute for the past 48 hours, I have noticed that my reading is a constant 16.5C

I have checked with another device and I have also used these devices on Win7 an they show variation. Are there any diagnostics I can turn on to establish more information about the sensor reading? Is it possible that I need to calibrate it?

Thanks

Conversion from bytes steam to temp_c

I wonder if we are over complicating the conversion from byte to str to temperature.

It looks like the first byte data[2] is the integer part of the degree, and the second byte data[3] is the fractional part of the degree - by dividing the value by 256.

In the example spreadsheet you have the stream: 80:04:1a:b0:19:70:2e:33

Therefore:
data[2] is 0x1a which is 26 base 10 decimal
data[3] is 0xb0 which is 176 base 10 decimal

And, data[3] / 256.0 equals 0.6875

The "inner" column in the spreadsheet show the temp as 26,69... Hence I'd suggest:

temp_c = data[2] + (data[3] / 256.0)

However, I don't know how negative values of data[2] might appear in the stream. Signed ints? Twos complement?

The theory fits with a maximum high value of 125 deg. (signed 8-bit ints max at 127)

Raspberry pi

Hi, im testing your code on my raspberry pi and im facing some issues... the 1st one was that the 10th line of the setup, the word "encoding" was causing problems:

raceback (most recent call last): File "setup.py", line 10, in <module> long_description=open('README.md', encoding='utf-8').read(), TypeError: 'encoding' is an invalid keyword argument for this function

I commented that line and was able to install, but when I run the temper-poll command I get this:

Traceback (most recent call last): File "/usr/local/bin/temper-poll", line 9, in <module> load_entry_point('temperusb==1.5.3', 'console_scripts', 'temper-poll')() File "build/bdist.linux-armv7l/egg/temperusb/cli.py", line 38, in main File "build/bdist.linux-armv7l/egg/temperusb/temper.py", line 420, in __init__ File "build/bdist.linux-armv7l/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'.

I went over the permission on the USB dongle and while I found it here:

pi@BA6:/dev $ lsusb | grep "0c45:7401" Bus 001 Device 103: ID 0c45:7401 Microdia

I don't find it here:

pi@BA6:/dev $ ls -l /dev/usb* ls: cannot access /dev/usb*: No such file or directory

I tried to run the commands on sudo but is still not working... any ideas?

Thanks.

temper-poll works once, then times out on subsequent calls

The Python poll application works, but only one time. On subsequent calls, the device is detected but I get a handler error and the poll times out.

rlr@Cube:~$ temper-poll
Found 1 devices
Device #0: 25.4°C 77.7°F
rlr@Cube:~$ temper-poll
Found 1 devices
No handlers could be found for logger "temperusb.temper"
Traceback (most recent call last):
  File "/usr/local/bin/temper-poll", line 9, in <module>
    load_entry_point('temperusb==1.4.0', 'console_scripts', 'temper-poll')()
  File "build/bdist.linux-x86_64/egg/temperusb/cli.py", line 48, in main
  File "build/bdist.linux-x86_64/egg/temperusb/temper.py", line 254, in get_temperatures
  File "build/bdist.linux-x86_64/egg/temperusb/temper.py", line 194, in get_data
  File "build/bdist.linux-x86_64/egg/temperusb/temper.py", line 293, in _interrupt_read
  File "build/bdist.linux-x86_64/egg/usb/core.py", line 988, in read
  File "build/bdist.linux-x86_64/egg/usb/backend/libusb1.py", line 851, in intr_read
  File "build/bdist.linux-x86_64/egg/usb/backend/libusb1.py", line 936, in __read
  File "build/bdist.linux-x86_64/egg/usb/backend/libusb1.py", line 595, in _check
usb.core.USBError: [Errno 110] Operation timed out
rlr@Cube:~$

I can repeat this forever by removing then reinserting my USB sensor.

Not sure where to start breaking this down... can you help?
(Installed in Ubuntu 14.04 x86-64 system, kernel 3.13.0-77-generic.

Thanks!

failing to run on Centos

Hello. I can't find usb-python for Centos, but tried pyusb and pyserial. I installed them and then installed temper-python. Also, I can confirm via dmesg that I'm using the new version of the hardware and it's 1.4.

There were no error messages during install but trying to run generates this:

Traceback (most recent call last):
File "/usr/bin/temper-poll", line 9, in
load_entry_point('temperusb==1.1.2', 'console_scripts', 'temper-poll')()
File "/usr/lib/python2.6/site-packages/temperusb-1.1.2-py2.6.egg/temperusb/cli.py", line 26, in main
th = TemperHandler()
File "/usr/lib/python2.6/site-packages/temperusb-1.1.2-py2.6.egg/temperusb/temper.py", line 159, in init
self._devices.extend([TemperDevice(x, bus) for x in bus.devices if (x.idVendor,x.idProduct) in VIDPIDs])
File "/usr/lib/python2.6/site-packages/temperusb-1.1.2-py2.6.egg/temperusb/temper.py", line 60, in init
self._ports = find_ports(bus, device)
File "/usr/lib/python2.6/site-packages/temperusb-1.1.2-py2.6.egg/temperusb/temper.py", line 37, in find_ports
bus_id = int(bus.dirname)
ValueError: invalid literal for int() with base 10: ''

thanks for any help.
Dave

git pull failing for pyusb dependency

Hi

Following the my issue last week and your update, I have updated one of my other Pi installations using:

git pull

then

python setup.py install

and I'm getting a problem with the pyusb dependency:

`
Installing temper-poll script to /usr/local/bin
Installing temper-snmp script to /usr/local/bin

Installed /usr/local/lib/python2.7/dist-packages/temperusb-1.4.1-py2.7.egg
Processing dependencies for temperusb==1.4.1
Searching for pyusb>=1.0.0rc1
Best match: pyusb 1.0.0rc1
Downloading git+https://github.com/walac/pyusb.git#egg=pyusb-1.0.0rc1
error: Download error for git+https://github.com/walac/pyusb.git: unknown url type: git+https
`

Raspbian compatible?

Hi
I'm using this library for reading USB TEMPer devices plugged into Raspberry Pi (vB1 & 2). Has it been tested on Raspbian? It works but I get some errors using temper-poll -p

Misleading error message when run as non-root

Experimenting with repository head under Ubuntu 16.04 Linux on an Intel machine.

Device can be polled when running as root. When running as non-root, temper-poll dies with the following stack trace:

esr@snark:~/software/temper-python$ temper-poll
Traceback (most recent call last):
File "/usr/local/bin/temper-poll", line 9, in
load_entry_point('temperusb==1.5.1', 'console_scripts', 'temper-poll')()
File "build/bdist.linux-x86_64/egg/temperusb/cli.py", line 36, in main
File "build/bdist.linux-x86_64/egg/temperusb/temper.py", line 340, in init
File "build/bdist.linux-x86_64/egg/temperusb/temper.py", line 89, in init
File "build/bdist.linux-x86_64/egg/temperusb/temper.py", line 140, in lookup_sensor_count
File "build/bdist.linux-x86_64/egg/usb/core.py", line 841, in product
File "build/bdist.linux-x86_64/egg/usb/util.py", line 314, in get_string
ValueError: The device has no langid

The following comment thread suggests a possible solution:

https://github.com/walac/pyusb/issues/139

No module named temper.cli

Hi, I'm trying to use temper-python on following Raspberry Pi system:
Linux raspberrypi 3.10.25+ #622 PREEMPT Fri Jan 3 18:41:00 GMT 2014 armv6l GNU/Linux

I executed the setup instructions successfully but I'm getting following error when trying to run the temper-poll program.

Traceback (most recent call last):
File "/usr/local/bin/temper-poll", line 9, in
load_entry_point('temperusb==1.1.1', 'console_scripts', 'temper-poll')()
File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 337, in load_entry_point
return get_distribution(dist).load_entry_point(group, name)
File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 2279, in load_entry_point
return ep.load()
File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 1989, in load
entry = import(self.module_name, globals(),globals(), ['name'])
ImportError: No module named temper.cli

Thanks for looking into this.
Marek

upowerd spamming syslog when polling device

Is anyone else getting syslog spam when polling your sensor?

Nov 29 19:47:01 daw3 journal[2761]: unhandled action 'bind' on /sys/devices/pci0000:00/0000:00:14.0/usb1/1-2/1-2:1.1
Nov 29 19:47:01 daw3 journal[2761]: unhandled action 'unbind' on /sys/devices/pci0000:00/0000:00:14.0/usb1/1-2/1-2:1.1
Nov 29 19:47:01 daw3 journal[2761]: unhandled action 'bind' on /sys/devices/pci0000:00/0000:00:14.0/usb1/1-2/1-2:1.1
Nov 29 19:47:01 daw3 journal[2761]: unhandled action 'unbind' on /sys/devices/pci0000:00/0000:00:14.0/usb1/1-2/1-2:1.1
Nov 29 19:48:01 daw3 journal[2761]: unhandled action 'bind' on /sys/devices/pci0000:00/0000:00:14.0/usb1/1-2/1-2:1.1
Nov 29 19:48:01 daw3 journal[2761]: unhandled action 'unbind' on /sys/devices/pci0000:00/0000:00:14.0/usb1/1-2/1-2:1.1
Nov 29 19:48:01 daw3 journal[2761]: unhandled action 'bind' on /sys/devices/pci0000:00/0000:00:14.0/usb1/1-2/1-2:1.1
Nov 29 19:48:01 daw3 journal[2761]: unhandled action 'unbind' on /sys/devices/pci0000:00/0000:00:14.0/usb1/1-2/1-2:1.1

From what I can find, it's upowerd reporting uevents in newer kernels per https://bugs.freedesktop.org/show_bug.cgi?id=106019
but I haven't found a means to kill the syslog spam. Using Fedora 28 and kernel 4.19.3-200.fc28.x86_64, upower-0.99.7-3.fc28.x86_64.

Unable to read port and bus number

I'm running this on a Ubuntu Precise machine and am getting tracebacks on reading the port and bus number.

sudo temper-poll -p

Traceback (most recent call last):
  File "/usr/local/bin/temper-poll", line 9, in <module>
    load_entry_point('Temper==1.1.1', 'console_scripts', 'temper-poll')()
  File "/usr/local/lib/python2.7/dist-packages/Temper-1.1.1-py2.7.egg/temper/cli.py", line 26, in main
    th = TemperHandler()
  File "/usr/local/lib/python2.7/dist-packages/Temper-1.1.1-py2.7.egg/temper/temper.py", line 160, in __init__
    self._devices.extend([TemperDevice(x, bus) for x in bus.devices if (x.idVendor,x.idProduct) in VIDPIDs])
  File "/usr/local/lib/python2.7/dist-packages/Temper-1.1.1-py2.7.egg/temper/temper.py", line 61, in __init__
    self._ports = find_ports(bus, device)
  File "/usr/local/lib/python2.7/dist-packages/Temper-1.1.1-py2.7.egg/temper/temper.py", line 38, in find_ports
    bus_id = int(bus.dirname)
ValueError: invalid literal for int() with base 10: ''
Traceback (most recent call last):
  File "/usr/local/bin/temper-poll", line 9, in <module>
    load_entry_point('Temper==1.1.1', 'console_scripts', 'temper-poll')()
  File "/usr/local/lib/python2.7/dist-packages/Temper-1.1.1-py2.7.egg/temper/cli.py", line 37, in main
    'bus': dev.get_bus()
  File "/usr/local/lib/python2.7/dist-packages/Temper-1.1.1-py2.7.egg/temper/temper.py", line 93, in get_bus
    return str(int(self._bus.dirname))
ValueError: invalid literal for int() with base 10: ''

The dirname is an empty string in both cases. The second error was found by simply suppressing the first error.

My virtualenv has the following:

$ pip freeze
-e [email protected]:padelt/temper-python.git@4067a65927c6b4a04063c3834f553263993ab1d4#egg=Temper-dev
argparse==1.2.1
distribute==0.6.24
pyusb==1.0.0b1
wsgiref==0.1.2

USB ID parsing

Old versions of temper-poll supported USB hubs chained together, but I tried the newest version today and it does not. Here is the error output:

Traceback (most recent call last):
File "/usr/local/bin/temper-poll", line 9, in
load_entry_point('temperusb==1.2.0', 'console_scripts', 'temper-poll')()
File "/usr/local/lib/python2.7/dist-packages/temperusb-1.2.0-py2.7.egg/temperusb/cli.py", line 26, in main
th = TemperHandler()
File "/usr/local/lib/python2.7/dist-packages/temperusb-1.2.0-py2.7.egg/temperusb/temper.py", line 207, in init
usb.core.find(find_all=True, idVendor=vid, idProduct=pid)]
File "/usr/local/lib/python2.7/dist-packages/temperusb-1.2.0-py2.7.egg/temperusb/temper.py", line 85, in init
self._ports = find_ports(device)
File "/usr/local/lib/python2.7/dist-packages/temperusb-1.2.0-py2.7.egg/temperusb/temper.py", line 73, in find_ports
return float(matches.groups()[1])
ValueError: invalid literal for float(): 1.3.1


It looks like temper-python tries to convert the device ID to a float. For single devices this is fine: A device plugged into USB port 1 is given the id 1. A device plugged into port 3 on a USB hub plugged into USB port 1 is given the id 1.3. A device plugged into a port 1 on a USB hub plugged into port 3 of the last hub is given the id 1.3.1 that cannot converted to a number.

This becomes a problem on motherboards that use a build-in hub rather than ID each port. In this case, any USB hub is already plugged in as 1.x and the first device on the hub (without intentionally chaining hubs) is already 1.x.x.

3 sensor support

I have a TEMPerNTC II
10K F3950 NTCsensor

I noticed this line in lookup_sensor_count
-- All others are two - if not the case, contribute here: https://github.com/padelt/temper-python/issues

Bus 003 Device 014: ID 0c45:7401 Microdia TEMPer Temperature Sensor

[ 3188.367137] usb 3-10.3: new low-speed USB device number 16 using xhci_hcd
[ 3188.448856] usb 3-10.3: New USB device found, idVendor=0c45, idProduct=7401
[ 3188.448859] usb 3-10.3: New USB device strings: Mfr=1, Product=2, SerialNumber=0
[ 3188.448860] usb 3-10.3: Product: TEMPerNTC1.O
[ 3188.448862] usb 3-10.3: Manufacturer: RDing
[ 3188.452222] input: RDing TEMPerNTC1.O as /devices/pci0000:00/0000:00:14.0/usb3/3-10/3-10.3/3-10.3:1.0/0003:0C45:7401.0008/input/input21

Yes, that really says 1.O as in the letter O.

It has an internal sensor and 2 external sensors. temper-python works fine for the internal and first external, but it won't read the 3rd without some code changes. After adding 'TEMPerNTC1.O' with a count of 3 to temper.py, it works fine with all 3.

Temperature reading near zero read near 255.

I put my TEMPer device in an ice bath. I set the /etc/temper.conf file scale=1.0 and offset=0.0 to uncalibrate it. As it cools in the ice bath, the degrees C readings go as 1.3, 0.8, 0.3, 255.9, 255.6. In other words, when it reaches 0.0 degrees, you have to subtract off 256 (still uncalibrated). These values of course mess with the degrees F as well, which respectively show as 34.4, 33.4, 32.6, 492.7, 492.0 !!

Since the advertise device range is -40 to 120 degrees C, I think you need to have a check in the code, after fetching the data at line 268 of temper.py,

  •                 celsius = data[offset] + data[offset+1] / 256.0
    

something like

  •     if celsius >= 128:
             celsius = celsius - 256
    

Incorrect result when temperature drops below freezing

I'm using a 0c45:7401 Microdia device. temper-poll 1.5.2 works great above freezing, but when the temperature drops below 32F/0C, it returns 498 as the Fahrenheit temperature and 254 as the Centigrade temperature. Am I missing something?

Alan

"usb.USBError: Connection timed out" and "usb.USBError: could not detach kernel driver from interface 1: No data available"

After 4 or 5 successful reads, temper-poll dies like below:

% temper-poll 
Found 1 devices
Traceback (most recent call last):
  File "/usr/local/bin/temper-poll", line 9, in <module>
    load_entry_point('Temper==1.1.1', 'console_scripts', 'temper-poll')()
  File "/usr/local/lib/python2.7/dist-packages/Temper-1.1.1-py2.7.egg/temper/cli.py", line 33, in main
    'temperature_c': dev.get_temperature(),
  File "/usr/local/lib/python2.7/dist-packages/Temper-1.1.1-py2.7.egg/temper/temper.py", line 113, in get_temperature
    self._interrupt_read(self._handle)
  File "/usr/local/lib/python2.7/dist-packages/Temper-1.1.1-py2.7.egg/temper/temper.py", line 151, in _interrupt_read
    return handle.interruptRead(0x82, REQ_INT_LEN)
usb.USBError: Connection timed out

any subsequent invocations then end like this

% temper-poll 
Found 1 devices
Traceback (most recent call last):
  File "/usr/local/bin/temper-poll", line 9, in <module>
    load_entry_point('Temper==1.1.1', 'console_scripts', 'temper-poll')()
  File "/usr/local/lib/python2.7/dist-packages/Temper-1.1.1-py2.7.egg/temper/cli.py", line 33, in main
    'temperature_c': dev.get_temperature(),
  File "/usr/local/lib/python2.7/dist-packages/Temper-1.1.1-py2.7.egg/temper/temper.py", line 113, in get_temperature
    self._interrupt_read(self._handle)
  File "/usr/local/lib/python2.7/dist-packages/Temper-1.1.1-py2.7.egg/temper/temper.py", line 151, in _interrupt_read
    return handle.interruptRead(0x82, REQ_INT_LEN)
usb.USBError: could not detach kernel driver from interface 1: No data available

Unplugging the dongle and or reloading the kernel modules did not solve the problem.

This happens on an up2date debian wheezy installation with this sensor:

% lsusb -vv
Bus 003 Device 005: ID 0c45:7401 Microdia 
Device Descriptor:
  bLength                18
  bDescriptorType         1
  bcdUSB               2.00
  bDeviceClass            0 (Defined at Interface level)
  bDeviceSubClass         0 
  bDeviceProtocol         0 
  bMaxPacketSize0         8
  idVendor           0x0c45 Microdia
  idProduct          0x7401 
  bcdDevice            0.01
  iManufacturer           1 RDing
  iProduct                2 TEMPerV1.0
  iSerial                 0 
  bNumConfigurations      1
[...]

Calibration has type conflict on single-number ports

Hi Joji,

Thank you for implementing the calibration code, as my TEMPer is WAY off.

I'm forwarding my TEMPer to a VM. There, I have a ports 'string' that contains only one number, so in my calibration file, I'm using: 1-1: scale = 1.0, offset = 10.0 (just to try). But it just didn't seem to do anything.

By adding some debugging code, I found out that ports was a string (as it comes from the regex) and self._ports was an int. I changed it as below and now it works:

diff --git a/temperusb/temper.py b/temperusb/temper.py
index 06510a3..3c86756 100644
--- a/temperusb/temper.py
+++ b/temperusb/temper.py
@@ -109,7 +109,7 @@ class TemperDevice(object):
ports = matches.groups()[1]
scale = float(matches.groups()[2])
offset = float(matches.groups()[3])

  •                if ports == self._ports:
    
  •                if str(ports) == str(self._ports):
                     self._scale = scale
                     self._offset = offset
    

Hope this can help to make a great tool even better.

With kind regards,

Diego

syslog full of usbfs logs

Hi,
I have been using temper-poll for a while. I have checked my logs and I realized that I have tree lines on it for each temper-poll call:

[4218339.022465] usb 5-1: usbfs: process 27266 (temper-poll) did not claim interface 0 before use
[4218339.026481] usb 5-1: usbfs: process 27266 (temper-poll) did not claim interface 1 before use
[4218339.324370] usb 5-1: reset low-speed USB device number 2 using uhci_hcd

It is possible to stop this logs? I have tried the usbhid.quirks=0x0c45:0x7401:0x4 in kernel options but it didn't work for me.

Thanks in advance
p.

Import not working

Hi all,

since this change: 5991273, altered: from temperusb.temper import TemperHandler, to: from .temper import TemperHandler

I cannot run cli.py directly:

 $ PYTHONPATH=. python temperusb/cli.py -S 2 -s all -p
Traceback (most recent call last):
  File "temperusb/cli.py", line 5, in <module>
    from .temper import TemperHandler
ValueError: Attempted relative import in non-package

Reverting that import to the original seems to have no functional impact in the python setup.py install && temper-poll type scenario.

@willfurnass what's the driver behind the change? If it's reverted will it break something for you?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.