File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -109,12 +109,15 @@ This allows identification through hot-plugging or rebooting.
109109 USBSerialPort :
110110 match :
111111 ID_SERIAL_SHORT : ' P-00-00682'
112+ ID_USB_INTERFACE_NUM : ' 00'
112113 speed : 115200
113114
114- The example would search for a USB serial converter with the key
115- ``ID_SERIAL_SHORT `` and the value ``P-00-00682 `` and use it with a baud rate
116- of ``115200 ``.
117- The ``ID_SERIAL_SHORT `` property is set by the ``usb_id `` builtin helper program.
115+ The example would search for a USB serial converter with a given serial number
116+ (``ID_SERIAL_SHORT `` = ``P-00-00682 ``) and use first interface
117+ (``ID_USB_INTERFACE_NUM `` = ``00 ``) with a baud rate of 115200.
118+
119+ The ``ID_SERIAL_SHORT `` and ``ID_USB_INTERFACE_NUM `` properties are set by the
120+ ``usb_id `` builtin helper program.
118121
119122Arguments:
120123 - match (dict): key and value pairs for a udev match, see `udev Matching `_
Original file line number Diff line number Diff line change @@ -91,12 +91,22 @@ def suggest_match(self, device):
9191 suggestions .append ({'@ID_PATH' : path })
9292
9393 serial = self .device .properties .get ('ID_SERIAL_SHORT' )
94+ interface_num = self .device .properties .get ('ID_USB_INTERFACE_NUM' )
9495 if serial :
95- suggestions .append ({'ID_SERIAL_SHORT' : serial })
96+ if interface_num is not None :
97+ suggestions .append ({'ID_SERIAL_SHORT' : serial ,
98+ 'ID_USB_INTERFACE_NUM' : interface_num })
99+ else :
100+ suggestions .append ({'ID_SERIAL_SHORT' : serial })
96101 elif self .match .get ('@SUBSYSTEM' , None ) == 'usb' :
97102 serial = self ._get_usb_device ().properties .get ('ID_SERIAL_SHORT' )
103+ interface_num = self ._get_usb_device ().properties .get ('ID_USB_INTERFACE_NUM' )
98104 if serial :
99- suggestions .append ({'@ID_SERIAL_SHORT' : serial })
105+ if interface_num is not None :
106+ suggestions .append ({'@ID_SERIAL_SHORT' : serial ,
107+ '@ID_USB_INTERFACE_NUM' : interface_num })
108+ else :
109+ suggestions .append ({'@ID_SERIAL_SHORT' : serial })
100110
101111 return meta , suggestions
102112
You can’t perform that action at this time.
0 commit comments