mirror of https://github.com/ARMmbed/mbed-os.git
Tests: USB: Use libusb0 backend on Windows
libusb0 supports all features used for testing. A newer version (libusb1) does not have a complete implementation for Windows.pull/11458/head
parent
8f1bf43335
commit
db2995052f
|
@ -38,6 +38,14 @@ from usb.util import (DESC_TYPE_DEVICE, DESC_TYPE_CONFIG, DESC_TYPE_STRING,
|
||||||
|
|
||||||
import struct
|
import struct
|
||||||
|
|
||||||
|
if sys.platform.startswith('win'):
|
||||||
|
# Use libusb0 on Windows. libusb1 implementation for Windows
|
||||||
|
# does not support all features necessary for testing.
|
||||||
|
import usb.backend.libusb0
|
||||||
|
USB_BACKEND = usb.backend.libusb0.get_backend()
|
||||||
|
else:
|
||||||
|
# Use a default backend on other platforms.
|
||||||
|
USB_BACKEND = None
|
||||||
|
|
||||||
def get_interface(dev, interface, alternate=0):
|
def get_interface(dev, interface, alternate=0):
|
||||||
intf = None
|
intf = None
|
||||||
|
@ -314,11 +322,10 @@ class PyusbBasicTest(BaseHostTest):
|
||||||
def find_device(self, serial_number):
|
def find_device(self, serial_number):
|
||||||
# to make it more reliable, 20 retries in 2[s]
|
# to make it more reliable, 20 retries in 2[s]
|
||||||
for _ in range(20):
|
for _ in range(20):
|
||||||
dev = usb.core.find(custom_match=TestMatch(serial_number))
|
dev = usb.core.find(custom_match=TestMatch(serial_number), backend=USB_BACKEND)
|
||||||
if dev is not None:
|
if dev is not None:
|
||||||
break
|
break
|
||||||
time.sleep(0.1)
|
time.sleep(0.1)
|
||||||
|
|
||||||
if dev is None:
|
if dev is None:
|
||||||
self.log("Device not found")
|
self.log("Device not found")
|
||||||
self.send_kv("failed", "0")
|
self.send_kv("failed", "0")
|
||||||
|
|
Loading…
Reference in New Issue