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
diff --git a/fastboot/usb.h b/fastboot/usb.h
index 5b44468..96eb934 100644
--- a/fastboot/usb.h
+++ b/fastboot/usb.h
@@ -52,6 +52,13 @@
char device_path[256];
};
+class UsbTransport : public Transport {
+ // Resets the underlying transport. Returns 0 on success.
+ // This effectively simulates unplugging and replugging
+ virtual int Reset() = 0;
+};
+
typedef int (*ifc_match_func)(usb_ifc_info *ifc);
-Transport* usb_open(ifc_match_func callback);
+// 0 is non blocking
+UsbTransport* usb_open(ifc_match_func callback, uint32_t timeout_ms = 0);