From d435d1e5e32bb63d900fd6f97813c7aa90c99b50 Mon Sep 17 00:00:00 2001 From: Rodriguez Date: Thu, 9 Nov 2023 14:36:12 +0100 Subject: [PATCH] first version of hm310t hunt --- .../core/platform_device_factory.py | 4 +++- .../devices/hanmatek/hm310t/dev_hm310t.py | 24 +++++++++++++++---- 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/platform/panduza_platform/core/platform_device_factory.py b/platform/panduza_platform/core/platform_device_factory.py index dad320a..bcf0cff 100644 --- a/platform/panduza_platform/core/platform_device_factory.py +++ b/platform/panduza_platform/core/platform_device_factory.py @@ -92,11 +92,13 @@ async def hunt_start(self): async def hunt_next(self): try: d = next(self.__hunt_iter) - self.__log.info(f"{self.__device_templates[d]}") device_builder = self.__device_templates[d]() instances = await device_builder.get_hunted_instances() self.__device_store[d]['instances'] = instances + + # self.__log.info(f">> {self.__device_templates[d]}") + self.__log.info(f">> {self.__device_store[d]}") return True except StopIteration: diff --git a/platform/panduza_platform/devices/hanmatek/hm310t/dev_hm310t.py b/platform/panduza_platform/devices/hanmatek/hm310t/dev_hm310t.py index dfca0b3..5b1a763 100644 --- a/platform/panduza_platform/devices/hanmatek/hm310t/dev_hm310t.py +++ b/platform/panduza_platform/devices/hanmatek/hm310t/dev_hm310t.py @@ -38,10 +38,11 @@ def _PZA_DEV_config(self): async def _PZA_DEV_hunt(self): """ """ + bag = [] matches = HuntUsbDevs(USBID_VENDOR, USBID_MODEL, 'tty') for match in matches: - print('------', match) + # print('------', match) devname = match.get('DEVNAME', None) if devname: try: @@ -51,19 +52,32 @@ async def _PZA_DEV_hunt(self): serial_baudrate=9600 ) regs = await connector.read_holding_registers(address=0x03, size=1, unit=1) - self.log.debug(f"read regs={regs}") - # str_value = int_to_state_string(regs[0]) - # return str_value + # self.log.debug(f"read regs={regs}") + if regs[0] == 3010: + + ma = self._PZA_DEV_config()["manufacturer"] + mo = self._PZA_DEV_config()["model"] + ref = f"{ma}.{mo}" + bag.append({ + "ref": ref, + "settings": { + } + }) + except asyncio.exceptions.TimeoutError: print("tiemout") - return [] + return bag # --- async def _PZA_DEV_mount_interfaces(self): """ """ + + # "usb_vendor": USBID_VENDOR, + # "usb_model": USBID_MODEL + self.mount_interface( InterfaceHanmatekHm310tBpc(name=f":channel_0:_ctrl") )