From f36be3da06a2175f49ed2b987b684fdf66871b58 Mon Sep 17 00:00:00 2001 From: pod2g Date: Tue, 28 Dec 2010 22:56:16 +0100 Subject: MacOSX test: Console reading fixed --- irecovery.c | 5 +++-- libirecovery.c | 15 +++++++++++---- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/irecovery.c b/irecovery.c index 39ac425..3e32395 100644 --- a/irecovery.c +++ b/irecovery.c @@ -277,6 +277,9 @@ int main(int argc, char* argv[]) { } } + if (verbose) irecv_set_debug_level(verbose); + + irecv_init(); irecv_client_t client = NULL; for (i = 0; i <= 5; i++) { debug("Attempting to connect... \n"); @@ -291,8 +294,6 @@ int main(int argc, char* argv[]) { } } - if (verbose) irecv_set_debug_level(verbose); - switch (action) { case kResetDevice: irecv_reset(client); diff --git a/libirecovery.c b/libirecovery.c index f3d6f28..97432b7 100644 --- a/libirecovery.c +++ b/libirecovery.c @@ -359,7 +359,8 @@ irecv_error_t irecv_open(irecv_client_t* pclient) { return error; } - error = irecv_set_interface(client, 0, 0); + // pod2g 2010-12-28: switched to interface 1.1 by default on non DFU modes + error = irecv_set_interface(client, 1, 1); if (error != IRECV_E_SUCCESS) { return error; } @@ -408,7 +409,8 @@ irecv_error_t irecv_set_interface(irecv_client_t client, int interface, int alt_ if (check_context(client) != IRECV_E_SUCCESS) return IRECV_E_NO_DEVICE; #ifndef WIN32 - libusb_release_interface(client->handle, client->interface); + // pod2g 2010-12-28: this crashes iBoot on MacOSX + //libusb_release_interface(client->handle, client->interface); debug("Setting to interface %d:%d\n", interface, alt_interface); if (libusb_claim_interface(client->handle, interface) < 0) { @@ -744,9 +746,10 @@ irecv_error_t irecv_receive(irecv_client_t client) { char buffer[BUFFER_SIZE]; memset(buffer, '\0', BUFFER_SIZE); if (check_context(client) != IRECV_E_SUCCESS) return IRECV_E_NO_DEVICE; - - int bytes = 0; + // pod2g 2010-12-28: switch to interface 0 for console reading then return to interface 1 + irecv_set_interface(client, 0, 0); + int bytes = 0; while (irecv_bulk_transfer(client, 0x81, (unsigned char*) buffer, BUFFER_SIZE, &bytes, 1000) == 0) { if (bytes > 0) { if (client->received_callback != NULL) { @@ -755,12 +758,16 @@ irecv_error_t irecv_receive(irecv_client_t client) { event.data = buffer; event.type = IRECV_RECEIVED; if (client->received_callback(client, &event) != 0) { + irecv_set_interface(client, 1, 1); return IRECV_E_SUCCESS; } } } else break; } + // pod2g 2010-12-28: MacOSX need a reset if read times out + irecv_reset(client); + irecv_set_interface(client, 1, 1); return IRECV_E_SUCCESS; } -- cgit v1.1-32-gdbae