diff options
author | Nikias Bassen | 2009-01-27 21:21:08 -0800 |
---|---|---|
committer | Matt Colyer | 2009-01-27 21:21:08 -0800 |
commit | 325470e5f298ed493dd813256571c154bfb71406 (patch) | |
tree | 3f0d48d302885ee66ac78b24ee21b664cd7b3cb0 /src | |
parent | bced0730e878aefebb53732702d8dd34486697a2 (diff) | |
download | libimobiledevice-325470e5f298ed493dd813256571c154bfb71406.tar.gz libimobiledevice-325470e5f298ed493dd813256571c154bfb71406.tar.bz2 |
Clear extra packets from buffers, in case something went wrong previously.
Signed-off-by: Matt Colyer <matt@colyer.name>
Diffstat (limited to 'src')
-rw-r--r-- | src/iphone.c | 24 |
1 files changed, 18 insertions, 6 deletions
diff --git a/src/iphone.c b/src/iphone.c index 457d919..6eb56f7 100644 --- a/src/iphone.c +++ b/src/iphone.c @@ -38,6 +38,8 @@ static void iphone_config_usb_device(iphone_device_t phone) { int ret; + int bytes; + unsigned char buf[512]; log_debug_msg("setting configuration... "); ret = usb_set_configuration(phone->device, 3); @@ -70,6 +72,14 @@ static void iphone_config_usb_device(iphone_device_t phone) } else { log_debug_msg("done.\n"); } + + do { + bytes = usb_bulk_read(phone->device, BULKIN, (void *) &buf, 512, 800); + if (bytes > 0) { + log_debug_msg("iphone_config_usb_device: initial read returned %d bytes of data.\n", bytes); + log_debug_buffer(buf, bytes); + } + } while (bytes > 0); } /** @@ -219,12 +229,14 @@ iphone_error_t iphone_free_device(iphone_device_t device) int bytes; unsigned char buf[512]; - // read final package - bytes = usb_bulk_read(device->device, BULKIN, (void *) &buf, 512, 1000); - if (bytes > 0) { - log_debug_msg("iphone_free_device: final read returned\n"); - log_debug_buffer(buf, bytes); - } + // read final package(s) + do { + bytes = usb_bulk_read(device->device, BULKIN, (void *) &buf, 512, 800); + if (bytes > 0) { + log_debug_msg("iphone_free_device: final read returned\n"); + log_debug_buffer(buf, bytes); + } + } while (bytes > 0); if (device->buffer) { free(device->buffer); |