Skip to content

Commit 2000489

Browse files
committed
resource/udev: use filter_match for HIDRelay
This makes it easier to add more VID/PID pairs later. Signed-off-by: Jan Luebbe <[email protected]>
1 parent 16db15a commit 2000489

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

labgrid/resource/udev.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -671,10 +671,14 @@ class HIDRelay(USBResource):
671671
index = attr.ib(default=1, validator=attr.validators.instance_of(int))
672672
invert = attr.ib(default=False, validator=attr.validators.instance_of(bool))
673673

674-
def __attrs_post_init__(self):
675-
self.match['ID_VENDOR_ID'] = '16c0'
676-
self.match['ID_MODEL_ID'] = '05df'
677-
super().__attrs_post_init__()
674+
def filter_match(self, device):
675+
match = (device.properties.get('ID_VENDOR_ID'), device.properties.get('ID_MODEL_ID'))
676+
677+
if match not in [("16c0", "05df"), # dcttech USBRelay2
678+
]:
679+
return False
680+
681+
return super().filter_match(device)
678682

679683
@target_factory.reg_resource
680684
@attr.s(eq=False)

0 commit comments

Comments
 (0)