From bafb51a67ae7764c6af138bf03603fecb0fae339 Mon Sep 17 00:00:00 2001 From: "Redzynia, MateuszX" Date: Mon, 25 Sep 2023 11:08:02 +0200 Subject: [PATCH] ykushcmd: Add string support to ykushcmd command By default ykushcmd command supports option to [on, off, cycle] whole ykush yepkit. > ykushcmd -u a # 'a' stands for all ports > ykushcmd -d a # 'a' stands for all ports In current build only int is supported for port number, changing it to string allows to control power on all ports with one command instead of 3 if there are 3 ports. Signed-off-by: Redzynia, MateuszX [bst: adjusted docs accordingly] Signed-off-by: Bastian Krause --- doc/configuration.rst | 5 +++-- labgrid/resource/ykushpowerport.py | 12 ++++++------ 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/doc/configuration.rst b/doc/configuration.rst index f7c40605f..4faf746d9 100644 --- a/doc/configuration.rst +++ b/doc/configuration.rst @@ -303,7 +303,7 @@ hub. YKUSHPowerPort: serial: 'YK12345' - index: 1 + index: '1' The example describes port 1 on the YKUSH USB hub with the serial ``YK12345``. @@ -311,7 +311,8 @@ Use ``ykushcmd -l`` to get your serial number. Arguments: - serial (str): serial number of the YKUSH hub - - index (int): number of the port to switch + - index (str): number of the port to switch, use ``a`` to control the whole hub as one logical + port Used by: - `YKUSHPowerDriver`_ diff --git a/labgrid/resource/ykushpowerport.py b/labgrid/resource/ykushpowerport.py index b7a967816..be3b9c04f 100644 --- a/labgrid/resource/ykushpowerport.py +++ b/labgrid/resource/ykushpowerport.py @@ -11,10 +11,10 @@ class YKUSHPowerPort(Resource): Args: serial (str): serial of the YKUSH device - index (int): port index""" + index (str): port index""" serial = attr.ib(validator=attr.validators.instance_of(str)) - index = attr.ib(validator=attr.validators.instance_of(int), - converter=int) + index = attr.ib(validator=attr.validators.instance_of(str), + converter=str) @target_factory.reg_resource @attr.s(eq=False) @@ -23,7 +23,7 @@ class NetworkYKUSHPowerPort(NetworkResource): Args: serial (str): serial of the YKUSH device - index (int): port index""" + index (str): port index""" serial = attr.ib(validator=attr.validators.instance_of(str)) - index = attr.ib(validator=attr.validators.instance_of(int), - converter=int) + index = attr.ib(validator=attr.validators.instance_of(str), + converter=str)