Skip to content

Commit

Permalink
remote: restore previous client io command behaviour
Browse files Browse the repository at this point in the history
Signed-off-by: Felix Zwettler <[email protected]>
  • Loading branch information
flxzt committed Aug 2, 2024
1 parent 7d8de91 commit 5398ebc
Showing 1 changed file with 28 additions and 55 deletions.
83 changes: 28 additions & 55 deletions labgrid/remote/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -770,63 +770,36 @@ def digital_io(self):
from ..resource import ModbusTCPCoil, OneWirePIO, HttpDigitalOutput
from ..resource.remote import NetworkDeditecRelais8, NetworkSysfsGPIO, NetworkLXAIOBusPIO, NetworkHIDRelay

if action == "get":
drv = None
try:
drv = target.get_driver("DigitalInputProtocol", name=name)
except NoDriverFoundError:
for resource in target.resources:
if isinstance(resource, ModbusTCPCoil):
drv = self._get_driver_or_new(target, "ModbusCoilDriver", name=name)
elif isinstance(resource, OneWirePIO):
drv = self._get_driver_or_new(target, "OneWirePIODriver", name=name)
elif isinstance(resource, HttpDigitalOutput):
drv = self._get_driver_or_new(target, "HttpDigitalOutputDriver", name=name)
elif isinstance(resource, NetworkDeditecRelais8):
drv = self._get_driver_or_new(target, "DeditecRelaisDriver", name=name)
elif isinstance(resource, NetworkSysfsGPIO):
drv = self._get_driver_or_new(target, "GpioDigitalInputDriver", name=name)
elif isinstance(resource, NetworkLXAIOBusPIO):
drv = self._get_driver_or_new(target, "LXAIOBusPIODriver", name=name)
elif isinstance(resource, NetworkHIDRelay):
drv = self._get_driver_or_new(target, "HIDRelayDriver", name=name)
if drv:
break

if not drv:
raise UserError("target has no compatible resource available")
drv = None
try:
drv = target.get_driver("DigitalOutputProtocol", name=name)
except NoDriverFoundError:
for resource in target.resources:
if isinstance(resource, ModbusTCPCoil):
drv = self._get_driver_or_new(target, "ModbusCoilDriver", name=name)
elif isinstance(resource, OneWirePIO):
drv = self._get_driver_or_new(target, "OneWirePIODriver", name=name)
elif isinstance(resource, HttpDigitalOutput):
drv = self._get_driver_or_new(target, "HttpDigitalOutputDriver", name=name)
elif isinstance(resource, NetworkDeditecRelais8):
drv = self._get_driver_or_new(target, "DeditecRelaisDriver", name=name)
elif isinstance(resource, NetworkSysfsGPIO):
drv = self._get_driver_or_new(target, "GpioDigitalOutputDriver", name=name)
elif isinstance(resource, NetworkLXAIOBusPIO):
drv = self._get_driver_or_new(target, "LXAIOBusPIODriver", name=name)
elif isinstance(resource, NetworkHIDRelay):
drv = self._get_driver_or_new(target, "HIDRelayDriver", name=name)
if drv:
break

if not drv:
raise UserError("target has no compatible resource available")
if action == "get":
print(f"digital IO{' ' + name if name else ''} for place {place.name} is {'high' if drv.get() else 'low'}")
else:
drv = None
try:
drv = target.get_driver("DigitalOutputProtocol", name=name)
except NoDriverFoundError:
for resource in target.resources:
if isinstance(resource, ModbusTCPCoil):
drv = self._get_driver_or_new(target, "ModbusCoilDriver", name=name)
elif isinstance(resource, OneWirePIO):
drv = self._get_driver_or_new(target, "OneWirePIODriver", name=name)
elif isinstance(resource, HttpDigitalOutput):
drv = self._get_driver_or_new(target, "HttpDigitalOutputDriver", name=name)
elif isinstance(resource, NetworkDeditecRelais8):
drv = self._get_driver_or_new(target, "DeditecRelaisDriver", name=name)
elif isinstance(resource, NetworkSysfsGPIO):
drv = self._get_driver_or_new(target, "GpioDigitalOutputDriver", name=name)
elif isinstance(resource, NetworkLXAIOBusPIO):
drv = self._get_driver_or_new(target, "LXAIOBusPIODriver", name=name)
elif isinstance(resource, NetworkHIDRelay):
drv = self._get_driver_or_new(target, "HIDRelayDriver", name=name)
if drv:
break

if not drv:
raise UserError("target has no compatible resource available")

if action == "high":
drv.set(True)
elif action == "low":
drv.set(False)
elif action == "high":
drv.set(True)
elif action == "low":
drv.set(False)

async def _console(self, place, target, timeout, *, logfile=None, loop=False, listen_only=False):
name = self.args.name
Expand Down

0 comments on commit 5398ebc

Please sign in to comment.