summaryrefslogtreecommitdiffstats
path: root/fastboot/usb_windows.cpp
diff options
context:
space:
mode:
authorJosh Gao <jmgao@google.com>2018-05-31 21:24:14 -0700
committerJosh Gao <jmgao@google.com>2018-06-01 13:05:49 -0700
commitf22e953272592619fca200246ea5737b13baff43 (patch)
treefd37c1906787661faf0d4356e546a9b3787fb0b0 /fastboot/usb_windows.cpp
parent39cab7cd2538b0f31b3672c71195c47ba3b00de9 (diff)
downloadsystem_core-f22e953272592619fca200246ea5737b13baff43.tar.gz
system_core-f22e953272592619fca200246ea5737b13baff43.tar.bz2
system_core-f22e953272592619fca200246ea5737b13baff43.zip
fastboot: fix USB_TRACE, make it better.
Fix some bit-rotten instances of printf("%d", size_t), add more logging for device selection. Test: fastboot.exe devices Change-Id: I4683fab8f88805e1ac88e193a1e84821be8bfa4c
Diffstat (limited to 'fastboot/usb_windows.cpp')
-rw-r--r--fastboot/usb_windows.cpp21
1 files changed, 15 insertions, 6 deletions
diff --git a/fastboot/usb_windows.cpp b/fastboot/usb_windows.cpp
index 3dab5ac17..0e5fba125 100644
--- a/fastboot/usb_windows.cpp
+++ b/fastboot/usb_windows.cpp
@@ -106,6 +106,7 @@ std::unique_ptr<usb_handle> do_usb_open(const wchar_t* interface_name) {
if (nullptr == ret->adb_interface) {
errno = GetLastError();
+ DBG("failed to open interface %S\n", interface_name);
return nullptr;
}
@@ -157,7 +158,7 @@ ssize_t WindowsUsbTransport::Write(const void* data, size_t len) {
unsigned count = 0;
int ret;
- DBG("usb_write %d\n", len);
+ DBG("usb_write %zu\n", len);
if (nullptr != handle_) {
// Perform write
while(len > 0) {
@@ -195,7 +196,7 @@ ssize_t WindowsUsbTransport::Read(void* data, size_t len) {
unsigned long read = 0;
int ret;
- DBG("usb_read %d\n", len);
+ DBG("usb_read %zu\n", len);
if (nullptr != handle_) {
while (1) {
int xfer = (len > MAX_USBFS_BULK_SIZE) ? MAX_USBFS_BULK_SIZE : len;
@@ -269,19 +270,22 @@ int recognized_device(usb_handle* handle, ifc_match_func callback) {
return 0;
// Check vendor and product id first
- if (!AdbGetUsbDeviceDescriptor(handle->adb_interface,
- &device_desc)) {
+ if (!AdbGetUsbDeviceDescriptor(handle->adb_interface, &device_desc)) {
+ DBG("skipping device %x:%x\n", device_desc.idVendor, device_desc.idProduct);
return 0;
}
// Then check interface properties
- if (!AdbGetUsbInterfaceDescriptor(handle->adb_interface,
- &interf_desc)) {
+ if (!AdbGetUsbInterfaceDescriptor(handle->adb_interface, &interf_desc)) {
+ DBG("skipping device %x:%x, failed to find interface\n", device_desc.idVendor,
+ device_desc.idProduct);
return 0;
}
// Must have two endpoints
if (2 != interf_desc.bNumEndpoints) {
+ DBG("skipping device %x:%x, incorrect number of endpoints\n", device_desc.idVendor,
+ device_desc.idProduct);
return 0;
}
@@ -305,9 +309,13 @@ int recognized_device(usb_handle* handle, ifc_match_func callback) {
info.device_path[0] = 0;
if (callback(&info) == 0) {
+ DBG("skipping device %x:%x, not selected by callback\n", device_desc.idVendor,
+ device_desc.idProduct);
return 1;
}
+ DBG("found device %x:%x (%s)\n", device_desc.idVendor, device_desc.idProduct,
+ info.serial_number);
return 0;
}
@@ -338,6 +346,7 @@ static std::unique_ptr<usb_handle> find_usb_device(ifc_match_func callback) {
}
*copy_name = '\0';
+ DBG("attempting to open interface %S\n", next_interface->device_name);
handle = do_usb_open(next_interface->device_name);
if (NULL != handle) {
// Lets see if this interface (device) belongs to us