Skip to content

Commit

Permalink
first version of hm310t hunt
Browse files Browse the repository at this point in the history
  • Loading branch information
Rodriguez committed Nov 9, 2023
1 parent 5a81016 commit d435d1e
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 6 deletions.
4 changes: 3 additions & 1 deletion platform/panduza_platform/core/platform_device_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
24 changes: 19 additions & 5 deletions platform/panduza_platform/devices/hanmatek/hm310t/dev_hm310t.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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")
)
Expand Down

0 comments on commit d435d1e

Please sign in to comment.