-
Notifications
You must be signed in to change notification settings - Fork 174
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
driver/powerdriver: ykushpower: board_name support
When 6425df9 switched from pykush to ykushcmd, support for the YKUSH 3 and YKUSH XS was lost. Restore support for those boards by passing the board_name argument to ykushcmd. The board_name is determined by the USB Product ID. Added tests for YKUSHPowerPort and YKUSHPowerPort. Signed-off-by: Paul Vittorino <[email protected]>
- Loading branch information
1 parent
c4a0867
commit 411a818
Showing
4 changed files
with
110 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,56 @@ | ||
import attr | ||
|
||
from ..factory import target_factory | ||
from .common import NetworkResource, Resource | ||
from .remote import RemoteUSBResource | ||
from .udev import USBResource | ||
|
||
|
||
@target_factory.reg_resource | ||
@attr.s(eq=False) | ||
class YKUSHPowerPort(Resource): | ||
class YKUSHPowerPort(USBResource): | ||
"""This resource describes a YEPKIT YKUSH switchable USB hub. | ||
Args: | ||
serial (str): serial of the YKUSH device | ||
index (int): port index""" | ||
serial = attr.ib(validator=attr.validators.instance_of(str)) | ||
index = attr.ib(validator=attr.validators.instance_of(int), | ||
serial = attr.ib(default=None, validator=attr.validators.instance_of(str)) | ||
index = attr.ib(default=None, validator=attr.validators.instance_of(int), | ||
converter=int) | ||
|
||
def filter_match(self, device): | ||
if device.properties.get('ID_VENDOR_ID') != "04d8": | ||
return False | ||
|
||
# https://www.yepkit.com/uploads/documents/41cce_YKUSHXS_ProductManual_v0.0.1.pdf | ||
# Vendor ID (VID): 0x04D8 | ||
# Product ID (PID): 0xF0CD | ||
|
||
# https://www.yepkit.com/uploads/documents/e9f11_YKUSH_ProductManual_v1.1.1.pdf | ||
# Vendor ID (VID): 0x04D8 | ||
# Product ID (PID): 0xF2F7 | ||
|
||
# "The board USB control device can be accessed by the USB host using | ||
# the Vendor ID (VID) and Product ID (PID), which is 0x04D8 and | ||
# 0xF11B respectively" | ||
# https://www.yepkit.com/uploads/documents/9f39a_ykush3-datasheet.pdf | ||
|
||
if device.properties.get('ID_MODEL_ID') not in ["f0cd", "f11b", "f2f7"]: | ||
return False | ||
|
||
if device.properties.get('ID_SERIAL_SHORT') != self.serial: | ||
return False | ||
|
||
return super().filter_match(device) | ||
|
||
|
||
@target_factory.reg_resource | ||
@attr.s(eq=False) | ||
class NetworkYKUSHPowerPort(NetworkResource): | ||
class NetworkYKUSHPowerPort(RemoteUSBResource): | ||
""""This resource describes a remote YEPKIT YKUSH switchable USB hub. | ||
Args: | ||
serial (str): serial of the YKUSH device | ||
index (int): port index""" | ||
serial = attr.ib(validator=attr.validators.instance_of(str)) | ||
index = attr.ib(validator=attr.validators.instance_of(int), | ||
serial = attr.ib(default=None, validator=attr.validators.instance_of(str)) | ||
index = attr.ib(default=None, validator=attr.validators.instance_of(int), | ||
converter=int) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters