diff --git a/README.md b/README.md index ed36416..0e65162 100644 --- a/README.md +++ b/README.md @@ -35,3 +35,6 @@ dc=True peak_max=False peak_min=False ``` + +# Source +https://github.com/tobiasfalk/UIN-T-USB-Reader diff --git a/readDMM.py b/readDMM.py index 7609921..ddeff2e 100644 --- a/readDMM.py +++ b/readDMM.py @@ -1,15 +1,18 @@ import logging +from enum import Enum + from ut61eplus import UT61EPLUS +from ut61eplus import SERIAL_NUMBERS log = logging.getLogger(__name__) logging.basicConfig(level=logging.DEBUG) -dmm = UT61EPLUS() +dmm = UT61EPLUS(serial = str(SERIAL_NUMBERS.A)) log.info('name=%s', dmm.getName()) dmm.sendCommand('lamp') m = dmm.takeMeasurement() log.info('measurent=%s', m) - +dmm.listDevices() diff --git a/ut61eplus/__init__.py b/ut61eplus/__init__.py index 3c357f6..0de4bc9 100644 --- a/ut61eplus/__init__.py +++ b/ut61eplus/__init__.py @@ -1 +1,2 @@ -from .ut61eplus import UT61EPLUS \ No newline at end of file +from .ut61eplus import UT61EPLUS +from .ut61eplus import SERIAL_NUMBERS \ No newline at end of file diff --git a/ut61eplus/ut61eplus.py b/ut61eplus/ut61eplus.py index 0f4ccf7..dc190ce 100644 --- a/ut61eplus/ut61eplus.py +++ b/ut61eplus/ut61eplus.py @@ -35,7 +35,10 @@ 8d . => sum over all - LSB """ - +class SERIAL_NUMBERS: + A = '006C2895' + B = '006C3EE8' + C = '006C2FB6' class Measurement: @@ -308,9 +311,14 @@ class UT61EPLUS: 'not_peak': 78, } - def __init__(self): + def __init__(self, serial = None): """open device""" - self.dev = hid.Device(vid=self.CP2110_VID, pid=self.CP2110_PID) + if not serial == None: + print(serial) + print(type(serial)) + self.dev = hid.Device(vid=self.CP2110_VID, pid=self.CP2110_PID, serial = serial) + else: + self.dev = hid.Device(vid=self.CP2110_VID, pid=self.CP2110_PID) #self.dev.nonblocking = 1 self._send_feature_report([0x41, 0x01]) # enable uart self._send_feature_report([0x50, 0x00, 0x00, 0x25, 0x80, 0x00, 0x00, 0x03, 0x00, 0x00]) # 9600 8N1 - from USB trace @@ -398,6 +406,15 @@ def sendCommand(self, cmd)->None: self._write(seq) # pylint: disable=unused-variable unknown = self._readResponse() + + def listDevices(self): + for device_dict in hid.enumerate(): + keys = list(device_dict.keys()) + keys.sort() + if device_dict['vendor_id'] == self.CP2110_VID: + for key in keys: + print("%s : %s" % (key, device_dict[key])) + print() def _test(self): self._write(self._SEQUENCE_GET_NAME)