diff options
Diffstat (limited to 'iphone.c')
| -rw-r--r-- | iphone.c | 24 |
1 files changed, 11 insertions, 13 deletions
| @@ -474,28 +474,28 @@ int send_to_phone(iphone_device_t phone, char *data, int datalen) | |||
| 474 | #endif | 474 | #endif |
| 475 | do { | 475 | do { |
| 476 | if (retrycount > 3) { | 476 | if (retrycount > 3) { |
| 477 | fprintf(stderr, "EPIC FAIL! aborting on retry count overload.\n"); | 477 | log_debug_msg("EPIC FAIL! aborting on retry count overload.\n"); |
| 478 | return -1; | 478 | return -1; |
| 479 | } | 479 | } |
| 480 | 480 | ||
| 481 | bytes = usb_bulk_write(phone->device, BULKOUT, data, datalen, timeout); | 481 | bytes = usb_bulk_write(phone->device, BULKOUT, data, datalen, timeout); |
| 482 | if (bytes == -ETIMEDOUT) { | 482 | if (bytes == -ETIMEDOUT) { |
| 483 | // timed out waiting for write. | 483 | // timed out waiting for write. |
| 484 | fprintf(stderr, "usb_bulk_write timeout error.\n"); | 484 | log_debug_msg("usb_bulk_write timeout error.\n"); |
| 485 | return bytes; | 485 | return bytes; |
| 486 | } | 486 | } |
| 487 | else if (bytes < 0) { | 487 | else if (bytes < 0) { |
| 488 | fprintf(stderr, "usb_bulk_write failed with error. err:%d (%s)(%s)\n", bytes, usb_strerror(), strerror(-bytes)); | 488 | log_debug_msg("usb_bulk_write failed with error. err:%d (%s)(%s)\n", bytes, usb_strerror(), strerror(-bytes)); |
| 489 | return -1; | 489 | return -1; |
| 490 | } | 490 | } |
| 491 | else if (bytes == 0) { | 491 | else if (bytes == 0) { |
| 492 | fprintf(stderr, "usb_bulk_write sent nothing. retrying.\n"); | 492 | log_debug_msg("usb_bulk_write sent nothing. retrying.\n"); |
| 493 | timeout = timeout * 4; | 493 | timeout = timeout * 4; |
| 494 | retrycount++; | 494 | retrycount++; |
| 495 | continue; | 495 | continue; |
| 496 | } | 496 | } |
| 497 | else if (bytes < datalen) { | 497 | else if (bytes < datalen) { |
| 498 | fprintf(stderr, "usb_bulk_write failed to send full dataload. %d of %d\n", bytes, datalen); | 498 | log_debug_msg("usb_bulk_write failed to send full dataload. %d of %d\n", bytes, datalen); |
| 499 | timeout = timeout * 4; | 499 | timeout = timeout * 4; |
| 500 | retrycount++; | 500 | retrycount++; |
| 501 | data += bytes; | 501 | data += bytes; |
| @@ -946,20 +946,20 @@ uint32_t append_receive_buffer(iphone_umux_client_t client, char* packet) | |||
| 946 | switch(data[0]) { | 946 | switch(data[0]) { |
| 947 | case 0: | 947 | case 0: |
| 948 | // this is not an error, it's just a status message. | 948 | // this is not an error, it's just a status message. |
| 949 | fprintf(stdout, "received status message: %s\n", e_msg); | 949 | log_debug_msg("received status message: %s\n", e_msg); |
| 950 | datalen = 0; | 950 | datalen = 0; |
| 951 | break; | 951 | break; |
| 952 | case 1: | 952 | case 1: |
| 953 | fprintf(stderr, "received error message: %s\n", e_msg); | 953 | log_debug_msg("received error message: %s\n", e_msg); |
| 954 | datalen = 0; | 954 | datalen = 0; |
| 955 | break; | 955 | break; |
| 956 | default: | 956 | default: |
| 957 | fprintf(stderr, "received unknown message (type 0x%02x): %s\n", data[0], e_msg); | 957 | log_debug_msg("received unknown message (type 0x%02x): %s\n", data[0], e_msg); |
| 958 | //datalen = 0; // <-- we let this commented out for testing | 958 | //datalen = 0; // <-- we let this commented out for testing |
| 959 | break; | 959 | break; |
| 960 | } | 960 | } |
| 961 | } else { | 961 | } else { |
| 962 | fprintf(stderr, "peer sent connection reset. setting error: %d\n", client->error); | 962 | log_debug_msg("peer sent connection reset. setting error: %d\n", client->error); |
| 963 | } | 963 | } |
| 964 | } | 964 | } |
| 965 | 965 | ||
| @@ -1056,10 +1056,8 @@ iphone_umux_client_t find_client(usbmux_tcp_header* recv_header) | |||
| 1056 | */ | 1056 | */ |
| 1057 | int iphone_mux_pullbulk(iphone_device_t phone) | 1057 | int iphone_mux_pullbulk(iphone_device_t phone) |
| 1058 | { | 1058 | { |
| 1059 | if (!phone) { | 1059 | if (!phone) |
| 1060 | fprintf(stderr, "iphone_mux_pullbulk: invalid argument\n"); | ||
| 1061 | return -EINVAL; | 1060 | return -EINVAL; |
| 1062 | } | ||
| 1063 | 1061 | ||
| 1064 | int res = 0; | 1062 | int res = 0; |
| 1065 | static const int DEFAULT_CAPACITY = 128*1024; | 1063 | static const int DEFAULT_CAPACITY = 128*1024; |
| @@ -1142,7 +1140,7 @@ int iphone_mux_pullbulk(iphone_device_t phone) | |||
| 1142 | // if there are no leftovers, we just leave the datastructure as is, | 1140 | // if there are no leftovers, we just leave the datastructure as is, |
| 1143 | // and re-use the block next time. | 1141 | // and re-use the block next time. |
| 1144 | if (phone->usbReceive.leftover > 0 && cursor != phone->usbReceive.buffer) { | 1142 | if (phone->usbReceive.leftover > 0 && cursor != phone->usbReceive.buffer) { |
| 1145 | fprintf(stderr, "%s: we got a leftover, so handle it\n", __func__); | 1143 | log_debug_msg("%s: we got a leftover, so handle it\n", __func__); |
| 1146 | char* newbuff = malloc(DEFAULT_CAPACITY); | 1144 | char* newbuff = malloc(DEFAULT_CAPACITY); |
| 1147 | memcpy(newbuff, cursor, phone->usbReceive.leftover); | 1145 | memcpy(newbuff, cursor, phone->usbReceive.leftover); |
| 1148 | free(phone->usbReceive.buffer); | 1146 | free(phone->usbReceive.buffer); |
