Skip to content

Commit

Permalink
start hunt for HM310T
Browse files Browse the repository at this point in the history
  • Loading branch information
Rodriguez committed Nov 9, 2023
1 parent dae126c commit 5a81016
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 70 deletions.
62 changes: 0 additions & 62 deletions platform/panduza_platform/core/platform.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,60 +222,6 @@ async def handle_worker_panic(self, name, status):

# ---



# ###########################################################################
# ###########################################################################

# def parse_args(self):
# """
# """
# # Manage arguments
# parser = argparse.ArgumentParser(description='Manage Panduza Platform')
# parser.add_argument('-t', '--tree', help='path to the panduza tree (*.json)', metavar="FILE")
# parser.add_argument('-l', '--log', dest='enable_logs', action='store_true', help='start the logs')
# args = parser.parse_args()

# # Check if logs are enabled
# if not args.enable_logs and self.force_log != True:
# self.log.remove()

# # Check tree filepath value
# self.dtree_filepath = args.tree








# def load_interface(self, bench_name, device, interface_config):
# """Load a new interface
# """
# instance = self.driver_factory.produce_interface(bench_name, device, interface_config)
# self.interfaces.append(instance)
# device.register_interface(instance)


# # ---

# def get_interface_instance(self, bench, device, name):
# """Find the interface corresponding the given parameters

# Return the found interface obj, None if not found
# """
# # Go through all interfaces and search for a match
# for itf in self.interfaces:
# same_bench = (itf.bench_name == bench)
# same_device = (itf.device_name == device)
# same_name = (itf.name == name)
# if same_bench and same_device and same_name:
# return itf
# return None



# =============================================================================
# PRIVATE FUNCTIONS

Expand Down Expand Up @@ -367,14 +313,6 @@ async def __load_tree_task(self):
# Load config
await self.load_config_content_task(new_dtree)









# ---

def __stop(self):
Expand Down
28 changes: 23 additions & 5 deletions platform/panduza_platform/devices/hanmatek/hm310t/dev_hm310t.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import asyncio

from core.platform_device import PlatformDevice

USBID_VENDOR="1a86"
Expand All @@ -7,6 +9,10 @@
from .itf_hanmatek_hm310t_bpc import InterfaceHanmatekHm310tBpc
from .itf_hanmatek_hm310t_ammeter import InterfaceHanmatekHM310tAmmeter

from connectors.udev_tty import HuntUsbDevs
from connectors.modbus_client_serial import ConnectorModbusClientSerial


class DeviceHanmatekHm310t(PlatformDevice):
"""Power Supply From Hanmatek
"""
Expand All @@ -32,12 +38,24 @@ def _PZA_DEV_config(self):
async def _PZA_DEV_hunt(self):
"""
"""
# print( HuntUsbDevs('0416', '5011', 'tty') )

# connector = await SerialTty.Get(serial_port_name='/dev/ttyACM0')
# status = await connector.write_and_read_until("*IDN?", time_lock_s=0.5)

# print(">>> ", status)
matches = HuntUsbDevs(USBID_VENDOR, USBID_MODEL, 'tty')
for match in matches:
print('------', match)
devname = match.get('DEVNAME', None)
if devname:
try:
self.log.info(devname)
connector = await ConnectorModbusClientSerial.Get(
serial_port_name=devname,
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
except asyncio.exceptions.TimeoutError:
print("tiemout")

return []

Expand Down
6 changes: 3 additions & 3 deletions platform/panduza_platform/devices/korad/ka3005/dev_ka3005.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@ async def _PZA_DEV_hunt(self):
"""
print( HuntUsbDevs('0416', '5011', 'tty') )

connector = await SerialTty.Get(serial_port_name='/dev/ttyACM0')
status = await connector.write_and_read_until("*IDN?", time_lock_s=0.5)
# connector = await SerialTty.Get(serial_port_name='/dev/ttyACM0')
# status = await connector.write_and_read_until("*IDN?", time_lock_s=0.5)

print(">>> ", status)
# print(">>> ", status)

return []

Expand Down

0 comments on commit 5a81016

Please sign in to comment.