From ceb7cbf5fde0ff26a35d442135d01e52b0ef0771 Mon Sep 17 00:00:00 2001 From: Aaron Wisner Date: Mon, 23 Jul 2018 15:40:58 -0500 Subject: Add derived UsbTransport class with USB reset method For testing there needs to be a way to simulate unplugging and replugging a device. This change adds support for a USB reset method that does this. Also add timeouts, so USB reads/writes don't block forever on an unresponsive device. Test: glinux, fastboot tool still works Test: Reset confirmed working via wireshark Linux URB captures Change-Id: I7213a2395d4ef1c0238810e4929ab966e78c8b55 --- fastboot/usb_windows.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'fastboot/usb_windows.cpp') diff --git a/fastboot/usb_windows.cpp b/fastboot/usb_windows.cpp index 0e5fba125..8c60a7173 100644 --- a/fastboot/usb_windows.cpp +++ b/fastboot/usb_windows.cpp @@ -66,7 +66,7 @@ struct usb_handle { std::string interface_name; }; -class WindowsUsbTransport : public Transport { +class WindowsUsbTransport : public UsbTransport { public: WindowsUsbTransport(std::unique_ptr handle) : handle_(std::move(handle)) {} ~WindowsUsbTransport() override = default; @@ -74,6 +74,7 @@ class WindowsUsbTransport : public Transport { ssize_t Read(void* data, size_t len) override; ssize_t Write(const void* data, size_t len) override; int Close() override; + int Reset() override; private: std::unique_ptr handle_; @@ -261,6 +262,12 @@ int WindowsUsbTransport::Close() { return 0; } +int WindowsUsbTransport::Reset() { + DBG("usb_reset currently unsupported\n\n"); + // TODO, this is a bit complicated since it is using ADB + return -1; +} + int recognized_device(usb_handle* handle, ifc_match_func callback) { struct usb_ifc_info info; USB_DEVICE_DESCRIPTOR device_desc; @@ -366,8 +373,7 @@ static std::unique_ptr find_usb_device(ifc_match_func callback) { return handle; } -Transport* usb_open(ifc_match_func callback) -{ +UsbTransport* usb_open(ifc_match_func callback, uint32_t) { std::unique_ptr handle = find_usb_device(callback); return handle ? new WindowsUsbTransport(std::move(handle)) : nullptr; } -- cgit v1.2.3