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 1919import time
2020import threading
2121import uuid
22+ import sys
2223import mbed_host_tests
2324import usb .core
2425from usb .util import (
3132 DESC_TYPE_CONFIG ,
3233 build_request_type )
3334
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+
3444try :
3545 import hid
3646except ImportError :
@@ -232,7 +242,7 @@ def get_usb_dev(usb_id_str):
232242 during test suite setup.
233243 Raises RuntimeError if the device is not found.
234244 """
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 )
236246 if usb_dev is None :
237247 err_msg = 'USB device (SN={}) not found.'
238248 raise RuntimeError (err_msg .format (usb_id_str ))
You can’t perform that action at this time.
0 commit comments