diff --git a/src/lvmopstools/devices/ion.py b/src/lvmopstools/devices/ion.py index 3d52973..e5f7d18 100644 --- a/src/lvmopstools/devices/ion.py +++ b/src/lvmopstools/devices/ion.py @@ -11,7 +11,7 @@ import asyncio import warnings -from typing import TypedDict +from typing import TypedDict, cast from drift import Drift from drift.convert import data_to_float32 @@ -61,10 +61,12 @@ async def _read_one_ion_controller(ion_config: dict) -> dict[str, IonPumpDict]: signal_address = camera_config["signal_address"] # on_off_address = camera_config["on_off_address"] - signal = await drift.client.read_input_registers(signal_address, 2) - # onoff = await drift.client.read_input_registers(on_off_address, 1) + signal = await drift.client.read_input_registers(signal_address, count=2) + # onoff = await drift.client.read_input_registers(on_off_address, count=1) - diff_volt = data_to_float32(tuple(signal.registers)) + registers = cast(tuple[int, int], tuple(signal.registers)) + + diff_volt = data_to_float32(registers) pressure = convert_pressure(diff_volt) # onoff_status = bool(onoff.registers[0]) diff --git a/tests/test_devices.py b/tests/test_devices.py index 4e45a1b..46e233d 100644 --- a/tests/test_devices.py +++ b/tests/test_devices.py @@ -88,13 +88,16 @@ async def test_toggle_ion_pump(ion_pump_server): on_off_address = b2_config["on_off_address"] async with drift: - register_z2 = await drift.client.read_holding_registers(on_off_address, 1) + register_z2 = await drift.client.read_holding_registers( + on_off_address, + count=1, + ) assert register_z2.registers[0] == 0 await toggle_ion_pump("b2", True) async with drift: - register_z2 = await drift.client.read_holding_registers(0, 50) + register_z2 = await drift.client.read_holding_registers(0, count=50) assert sum([reg > 0 for reg in register_z2.registers]) == 1 @@ -106,5 +109,5 @@ async def test_toggle_ion_pump_all(ion_pump_server): await toggle_ion_pump(ALL, True) async with drift: - register_z2 = await drift.client.read_holding_registers(0, 50) + register_z2 = await drift.client.read_holding_registers(0, count=50) assert sum([reg > 0 for reg in register_z2.registers]) == 3