diff --git a/README.md b/README.md index cbeacd9..8be5078 100644 --- a/README.md +++ b/README.md @@ -52,6 +52,7 @@ In the following table "I" means the sensor is internal to the USB stick and Product | Id | Firmware | Temp | Hum | Notes -----------|-----------|-----------------|------|-----|--------------- TEMPer | 0c45:7401 | TEMPerF1.4 | I | | Metal +TEMPer | 413d:2107 | TEMPerGold_V3.1 | I | | Metal TEMPerHUM | 413d:2107 | TEMPerX_V3.1 | I | I | White plastic TEMPer2 | 413d:2107 | TEMPerX_V3.3 | I,E | | White plastic TEMPer1F | 413d:2107 | TEMPerX_V3.3 | E | | White plastic diff --git a/temper.py b/temper.py index 8b799bf..74c2183 100755 --- a/temper.py +++ b/temper.py @@ -29,7 +29,6 @@ import select import struct import sys -import time # Non-standard modules try: @@ -38,6 +37,7 @@ print('Cannot import "serial". Please sudo apt-get install python3-serial') sys.exit(1) + class USBList(object): '''Get a list of all of the USB devices on a system, along with their associated hidraw or serial (tty) devices. @@ -182,6 +182,11 @@ def _read_hidraw(self, device): self._parse_bytes('internal temperature', 2, 256.0, bytes, info) return info + if info['firmware'][:15] == 'TEMPerGold_V3.1': + info['firmware'] = info['firmware'][:15] + self._parse_bytes('internal temperature', 2, 100.0, bytes, info) + return info + if info['firmware'][:12] in [ 'TEMPerX_V3.1', 'TEMPerX_V3.3' ]: info['firmware'] = info['firmware'][:12] self._parse_bytes('internal temperature', 2, 100.0, bytes, info) @@ -190,8 +195,10 @@ def _read_hidraw(self, device): self._parse_bytes('external humidity', 12, 100.0, bytes, info) return info - return { 'error' : 'Unknown firmware %s: %s' % (info['firmware'], - binascii.hexlify(bytes)) } + info['error'] = 'Unknown firmware %s: %s' % (info['firmware'], + binascii.hexlify(bytes)) + return info + def _read_serial(self, device): '''Using the Linux serial device, send the special commands and receive the @@ -404,6 +411,7 @@ def main(self): self.print(results, args.json) return 0 + if __name__ == "__main__": temper = Temper() sys.exit(temper.main())