Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
74 changes: 50 additions & 24 deletions doc/configuration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,13 @@ This allows identification through hot-plugging or rebooting.

USBSerialPort:
match:
'ID_SERIAL_SHORT': 'P-00-00682'
ID_SERIAL_SHORT: P-00-00682
speed: 115200

The example would search for a USB serial converter with the key
`ID_SERIAL_SHORT` and the value `P-00-00682` and use it with a baud rate
of 115200.
The `ID_SERIAL_SHORT` property is set by the usb_id builtin helper program.

- match (str): key and value for a udev match, see `udev Matching`_
- speed (int, default=115200): baud rate of the serial port
Expand Down Expand Up @@ -430,7 +431,7 @@ A USBMassStorage resource describes a USB memory stick or similar device.

USBMassStorage:
match:
'ID_PATH': 'pci-0000:06:00.0-usb-0:1.3.2:1.0-scsi-0:0:0:3'
ID_PATH: pci-0000:06:00.0-usb-0:1.3.2:1.0-scsi-0:0:0:3

- match (str): key and value for a udev match, see `udev Matching`_

Expand Down Expand Up @@ -473,7 +474,7 @@ An IMXUSBLoader resource describes a USB device in the imx loader state.

IMXUSBLoader:
match:
'ID_PATH': 'pci-0000:06:00.0-usb-0:1.3.2:1.0'
ID_PATH: pci-0000:06:00.0-usb-0:1.3.2:1.0

- match (str): key and value for a udev match, see `udev Matching`_

Expand All @@ -489,7 +490,7 @@ An MXSUSBLoader resource describes a USB device in the mxs loader state.

MXSUSBLoader:
match:
'ID_PATH': 'pci-0000:06:00.0-usb-0:1.3.2:1.0'
ID_PATH: pci-0000:06:00.0-usb-0:1.3.2:1.0

- match (str): key and value for a udev match, see `udev Matching`_

Expand All @@ -505,7 +506,7 @@ An RKUSBLoader resource describes a USB device in the rockchip loader state.

RKUSBLoader:
match:
'sys_name': '1-3'
sys_name: '1-3'

- match (str): key and value for a udev match, see `udev Matching`_

Expand All @@ -532,7 +533,7 @@ An AndroidFastboot resource describes a USB device in the fastboot state.

AndroidFastboot:
match:
'ID_PATH': 'pci-0000:06:00.0-usb-0:1.3.2:1.0'
ID_PATH: pci-0000:06:00.0-usb-0:1.3.2:1.0

- match (str): key and value for a udev match, see `udev Matching`_

Expand All @@ -548,7 +549,7 @@ Ethernet or WiFi)

USBNetworkInterface:
match:
'ID_PATH': 'pci-0000:06:00.0-usb-0:1.3.2:1.0'
ID_PATH: pci-0000:06:00.0-usb-0:1.3.2:1.0

- match (str): key and value for a udev match, see `udev Matching`_

Expand All @@ -565,7 +566,7 @@ An AlteraUSBBlaster resource describes an Altera USB blaster.

AlteraUSBBlaster:
match:
'ID_PATH': 'pci-0000:06:00.0-usb-0:1.3.2:1.0'
ID_PATH: pci-0000:06:00.0-usb-0:1.3.2:1.0

- match (dict): key and value for a udev match, see `udev Matching`_

Expand All @@ -582,7 +583,7 @@ FT2232H).

USBDebugger:
match:
ID_PATH: 'pci-0000:00:10.0-usb-0:1.4'
ID_PATH: pci-0000:00:10.0-usb-0:1.4

- match (dict): key and value for a udev match, see `udev Matching`_

Expand Down Expand Up @@ -613,7 +614,7 @@ A SigrokUSBDevice resource describes a sigrok USB device.
driver: fx2lafw
channel: "D0=CLK,D1=DATA"
match:
'ID_PATH': 'pci-0000:06:00.0-usb-0:1.3.2:1.0'
ID_PATH: pci-0000:06:00.0-usb-0:1.3.2:1.0

- driver (str): name of the sigrok driver to use
- channel (str): optional, channel mapping as described in the sigrok-cli man page
Expand All @@ -633,7 +634,7 @@ host which is exported over the network. The SigrokDriver will access it via SSH
driver: fx2lafw
channel: "D0=CLK,D1=DATA"
match:
'ID_PATH': 'pci-0000:06:00.0-usb-0:1.3.2:1.0'
ID_PATH: pci-0000:06:00.0-usb-0:1.3.2:1.0
host: remote.example.computer

- driver (str): name of the sigrok driver to use
Expand Down Expand Up @@ -672,7 +673,7 @@ device.

USBSDMuxDevice:
match:
'@ID_PATH': 'pci-0000:00:14.0-usb-0:1.2'
'@ID_PATH': pci-0000:00:14.0-usb-0:1.2

- match (str): key and value for a udev match, see `udev Matching`_

Expand All @@ -693,7 +694,7 @@ A :any:`LXAUSBMux` resource describes a Linux Automation GmbH USB-Mux device.

LXAUSBMux:
match:
'@ID_PATH': 'pci-0000:00:14.0-usb-0:1.2'
'@ID_PATH': pci-0000:00:14.0-usb-0:1.2

- match (str): key and value for a udev match, see `udev Matching`_

Expand All @@ -716,7 +717,7 @@ device.

USBSDWireDevice:
match:
'@ID_PATH': 'pci-0000:00:14.0-usb-0:1.2'
'@ID_PATH': pci-0000:00:14.0-usb-0:1.2

- match (str): key and value for a udev match, see `udev Matching`_

Expand All @@ -739,7 +740,7 @@ Video4Linux2 kernel driver.

USBVideo:
match:
'@ID_PATH': 'pci-0000:00:14.0-usb-0:1.2'
'@ID_PATH': pci-0000:00:14.0-usb-0:1.2

- match (str): key and value for a udev match, see `udev Matching`_

Expand Down Expand Up @@ -801,7 +802,7 @@ The low-level communication is handled by the ``usbtmc`` kernel driver.

USBTMC:
match:
'@ID_PATH': 'pci-0000:00:14.0-usb-0:1.2'
'@ID_PATH': pci-0000:00:14.0-usb-0:1.2

- match (str): key and value for a udev match, see `udev Matching`_

Expand Down Expand Up @@ -863,7 +864,7 @@ running a flashing program with `FlashScriptDriver`_.

USBFlashableDevice:
match:
SUBSYSTEM: 'usb'
SUBSYSTEM: usb
ID_SERIAL: '1234'

- match (str): key and value pairs for a udev match, see `udev Matching`_
Expand Down Expand Up @@ -919,7 +920,7 @@ A :any:`HTTPVideoStream` resource describes a IP video stream over HTTP or HTTPS
.. code-block:: yaml

HTTPVideoStream:
url: 'http://192.168.110.11/0.ts'
url: http://192.168.110.11/0.ts

- url (str): URI of the IP video stream

Expand Down Expand Up @@ -1008,7 +1009,7 @@ created through interaction with that daemon.
.. code-block:: yaml

DockerDaemon:
docker_daemon_url: 'unix://var/run/docker.sock'
docker_daemon_url: unix://var/run/docker.sock

The example describes a docker daemon accessible via the
'/var/run/docker.sock' unix socket. When used by a `DockerDriver`, the
Expand Down Expand Up @@ -1098,7 +1099,7 @@ don't use a parent match.

AndroidFastboot:
match:
'sys_name': '1-1.2.3'
sys_name: '1-1.2.3'

Matching a Specific UART in a Dual-Port Adapter
+++++++++++++++++++++++++++++++++++++++++++++++
Expand Down Expand Up @@ -1150,7 +1151,7 @@ We use the ``ID_USB_INTERFACE_NUM`` to distinguish between the two ports:
USBSerialPort:
match:
'@sys_name': '3-10.2.2.2'
'ID_USB_INTERFACE_NUM': '01'
ID_USB_INTERFACE_NUM: '01'

Matching a USB UART by Serial Number
++++++++++++++++++++++++++++++++++++
Expand All @@ -1164,14 +1165,39 @@ changes or a board has been moved between host systems.

USBSerialPort:
match:
'ID_SERIAL_SHORT': 'P-00-00679'
ID_SERIAL_SHORT: P-00-03564

To check if your device has a serial number, you can use ``udevadm info``:

.. code-block:: bash

$ udevadm info /dev/ttyUSB5 | grep SERIAL_SHORT
E: ID_SERIAL_SHORT=P-00-00679
E: ID_SERIAL_SHORT=P-00-03564

In the background, the additional properties are provided by the builtin ``usb_id``
udev helper::

$ udevadm test-builtin usb_id /sys/class/tty/ttyUSB0
Load module index
Parsed configuration file /lib/systemd/network/99-default.link
Parsed configuration file /lib/systemd/network/73-usb-net-by-mac.link
Created link configuration context.
ID_VENDOR=Silicon_Labs
ID_VENDOR_ENC=Silicon\x20Labs
ID_VENDOR_ID=10c4
ID_MODEL=CP2102_USB_to_UART_Bridge_Controller
ID_MODEL_ENC=CP2102\x20USB\x20to\x20UART\x20Bridge\x20Controller
ID_MODEL_ID=ea60
ID_REVISION=0100
ID_SERIAL=Silicon_Labs_CP2102_USB_to_UART_Bridge_Controller_P-00-03564
ID_SERIAL_SHORT=P-00-03564
ID_TYPE=generic
ID_BUS=usb
ID_USB_INTERFACES=:ff0000:
ID_USB_INTERFACE_NUM=00
ID_USB_DRIVER=cp210x
Unload module index
Unloaded link configuration context.

Drivers
-------
Expand Down Expand Up @@ -1217,7 +1243,7 @@ Implements:
ShellDriver:
prompt: 'root@\w+:[^ ]+ '
login_prompt: ' login: '
username: 'root'
username: root

Arguments:
- prompt (regex): shell prompt to match after logging in
Expand Down
2 changes: 1 addition & 1 deletion doc/getting_started.rst
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ Additional groups and resources can be added:
location: example-location
USBSerialPort:
match:
'ID_SERIAL_SHORT': 'P-00-00682'
ID_SERIAL_SHORT: P-00-00682
speed: 115200
NetworkPowerPort:
model: netio
Expand Down
15 changes: 8 additions & 7 deletions labgrid/resource/udev.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,17 +85,18 @@ def suggest_match(self, device):
if self.device.properties.get('ID_REVISION'):
meta['revision'] = self.device.properties.get('ID_REVISION')

if self.match.get('SUBSYSTEM', None) == 'usb':
path = self._get_usb_device().properties.get('ID_PATH')
if path:
suggestions.append({'ID_PATH': path})
serial = self._get_usb_device().properties.get('ID_SERIAL_SHORT')
if serial:
suggestions.append({'ID_SERIAL_SHORT': serial})
path = self.device.properties.get('ID_PATH')
if path:
suggestions.append({'ID_PATH': path})
elif self.match.get('@SUBSYSTEM', None) == 'usb':
path = self._get_usb_device().properties.get('ID_PATH')
if path:
suggestions.append({'@ID_PATH': path})

serial = self.device.properties.get('ID_SERIAL_SHORT')
if serial:
suggestions.append({'ID_SERIAL_SHORT': serial})
elif self.match.get('@SUBSYSTEM', None) == 'usb':
serial = self._get_usb_device().properties.get('ID_SERIAL_SHORT')
if serial:
suggestions.append({'@ID_SERIAL_SHORT': serial})
Expand Down
19 changes: 17 additions & 2 deletions man/labgrid-suggest.1
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,30 @@ enable debug mode
.SH EXAMPLES
.sp
For a device that has an \fBID_SERIAL_SHORT\fP key with a unique ID embedded
in the USB\-serial converter, the resource match configuration is:
in the USB\-serial converter, \fBlabgrid\-suggest\fP shows two alternatives:
.INDENT 0.0
.INDENT 3.5
.sp
.nf
.ft C
=== added device ===
USBSerialPort for /devices/pci0000:00/0000:00:01.3/0000:02:00.0/usb1/1\-3/1\-3.1/1\-3.1:1.0/ttyUSB0/tty/ttyUSB0
=== device properties ===
device node: /dev/ttyUSB0
udev tags: , systemd
vendor: Silicon_Labs
vendor (DB): Advanced Micro Devices, Inc. [AMD]
model: CP2102_USB_to_UART_Bridge_Controller
revision: 0100
=== suggested matches ===
USBSerialPort:
match:
\(aq@ID_SERIAL_SHORT\(aq: \(aqP\-00\-00682\(aq
ID_PATH: pci\-0000:02:00.0\-usb\-0:3.1:1.0
\-\-\-
USBSerialPort:
match:
ID_SERIAL_SHORT: P\-00\-03564
\-\-\-
.ft P
.fi
.UNINDENT
Expand Down
20 changes: 17 additions & 3 deletions man/labgrid-suggest.rst
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,28 @@ EXAMPLES
--------

For a device that has an ``ID_SERIAL_SHORT`` key with a unique ID embedded
in the USB-serial converter, the resource match configuration is:
in the USB-serial converter, ``labgrid-suggest`` shows two alternatives:

.. code-block:: yaml
=== added device ===
USBSerialPort for /devices/pci0000:00/0000:00:01.3/0000:02:00.0/usb1/1-3/1-3.1/1-3.1:1.0/ttyUSB0/tty/ttyUSB0
=== device properties ===
device node: /dev/ttyUSB0
udev tags: , systemd
vendor: Silicon_Labs
vendor (DB): Advanced Micro Devices, Inc. [AMD]
model: CP2102_USB_to_UART_Bridge_Controller
revision: 0100
=== suggested matches ===
USBSerialPort:
match:
'@ID_SERIAL_SHORT': 'P-00-00682'
ID_PATH: pci-0000:02:00.0-usb-0:3.1:1.0
---
USBSerialPort:
match:
ID_SERIAL_SHORT: P-00-03564
---
SEE ALSO
--------
Expand Down