From 62d798396ed715d391f0acf26b5f801440323270 Mon Sep 17 00:00:00 2001 From: Fabian Pflug Date: Fri, 13 Sep 2024 12:27:12 +0200 Subject: [PATCH] resource: Add generic USB port This is useful, if the DUT is a USB device, where you are not yet sure, what exactly it is. This allows the test to use the wrapper to communicate with the device, even if it is on the network. Might also be useful, if you don't yet have a driver for a USB controlled device and want to test it out before upstreaming it. Signed-off-by: Fabian Pflug --- doc/configuration.rst | 17 +++++++++++++++++ labgrid/remote/exporter.py | 1 + labgrid/resource/__init__.py | 1 + labgrid/resource/remote.py | 9 +++++++++ labgrid/resource/udev.py | 6 ++++++ 5 files changed, 34 insertions(+) diff --git a/doc/configuration.rst b/doc/configuration.rst index f70bf2b66..5b7910f0a 100644 --- a/doc/configuration.rst +++ b/doc/configuration.rst @@ -641,6 +641,23 @@ device available on a remote computer. The NetworkUSBMassStorage can be used in test cases by calling the ``write_files()``, ``write_image()``, and ``get_size()`` functions. +GenericUSBPort +~~~~~~~~~~~~~~ +A :any:`GenericUSBPort` resource describes a generic USB device, that has no +specific driver yet. Useful if your DUT creates its own USB endpoint, that you +want to test. + +.. code-block:: yaml + + GenericUSBPort: + match: + ID_PATH: pci-0000:3c:00.0-usb-0:1.2:1.0 + +NetworkGenericUSBPort +~~~~~~~~~~~~~~~~~~~ +A :any:`NetworkGenericUSBPort` describes a `GenericUSBPort`_ available on a remote +computer. + SigrokDevice ~~~~~~~~~~~~ A :any:`SigrokDevice` resource describes a *Sigrok* device. To select a diff --git a/labgrid/remote/exporter.py b/labgrid/remote/exporter.py index 86a261c92..ebc666bc7 100755 --- a/labgrid/remote/exporter.py +++ b/labgrid/remote/exporter.py @@ -550,6 +550,7 @@ def __attrs_post_init__(self): exports["USBSDWireDevice"] = USBSDWireExport exports["USBDebugger"] = USBGenericExport +exports["GenericUSBPort"] = USBGenericExport exports["USBMassStorage"] = USBGenericExport exports["USBVideo"] = USBGenericExport exports["USBAudioInput"] = USBAudioInputExport diff --git a/labgrid/resource/__init__.py b/labgrid/resource/__init__.py index dd7554dff..a86a952bf 100644 --- a/labgrid/resource/__init__.py +++ b/labgrid/resource/__init__.py @@ -12,6 +12,7 @@ AndroidUSBFastboot, DFUDevice, DeditecRelais8, + GenericUSBPort, HIDRelay, IMXUSBLoader, LXAUSBMux, diff --git a/labgrid/resource/remote.py b/labgrid/resource/remote.py index b8adb2524..aad343833 100644 --- a/labgrid/resource/remote.py +++ b/labgrid/resource/remote.py @@ -294,6 +294,15 @@ def __attrs_post_init__(self): super().__attrs_post_init__() +@target_factory.reg_resource +@attr.s(eq=False) +class NetworkGenericUSBPort(RemoteUSBResource): + """The NetworkGenericUSBPort describes a remotely accessible USB device""" + def __attrs_post_init__(self): + self.timeout = 10.0 + super().__attrs_post_init__() + + @target_factory.reg_resource @attr.s(eq=False) class NetworkUSBDebugger(RemoteUSBResource): diff --git a/labgrid/resource/udev.py b/labgrid/resource/udev.py index 54c6a9fd3..fe1ae2090 100644 --- a/labgrid/resource/udev.py +++ b/labgrid/resource/udev.py @@ -228,6 +228,12 @@ def read_attr(self, attribute): return None +@target_factory.reg_resource +@attr.s(eq=False) +class GenericUSBPort(USBResource): + pass + + @target_factory.reg_resource @attr.s(eq=False) class USBSerialPort(USBResource, SerialPort):