File tree Expand file tree Collapse file tree 1 file changed +11
-1
lines changed Expand file tree Collapse file tree 1 file changed +11
-1
lines changed Original file line number Diff line number Diff line change 19
19
import time
20
20
import threading
21
21
import uuid
22
+ import sys
22
23
import mbed_host_tests
23
24
import usb .core
24
25
from usb .util import (
31
32
DESC_TYPE_CONFIG ,
32
33
build_request_type )
33
34
35
+ if sys .platform .startswith ('win' ):
36
+ # Use libusb0 on Windows. libusb1 implementation for Windows
37
+ # does not support all features necessary for testing.
38
+ import usb .backend .libusb0
39
+ USB_BACKEND = usb .backend .libusb0 .get_backend ()
40
+ else :
41
+ # Use a default backend on other platforms.
42
+ USB_BACKEND = None
43
+
34
44
try :
35
45
import hid
36
46
except ImportError :
@@ -232,7 +242,7 @@ def get_usb_dev(usb_id_str):
232
242
during test suite setup.
233
243
Raises RuntimeError if the device is not found.
234
244
"""
235
- usb_dev = usb .core .find (custom_match = lambda d : d .serial_number == usb_id_str )
245
+ usb_dev = usb .core .find (custom_match = lambda d : d .serial_number == usb_id_str , backend = USB_BACKEND )
236
246
if usb_dev is None :
237
247
err_msg = 'USB device (SN={}) not found.'
238
248
raise RuntimeError (err_msg .format (usb_id_str ))
You can’t perform that action at this time.
0 commit comments