Skip to content

Commit

Permalink
Fixed loadibec to work with iOS 4.1
Browse files Browse the repository at this point in the history
  • Loading branch information
bluerise committed Oct 13, 2010
1 parent e7f23d5 commit 55c8076
Showing 1 changed file with 4 additions and 27 deletions.
31 changes: 4 additions & 27 deletions tools/client/linux/loadibec.c
Expand Up @@ -102,41 +102,18 @@ int send_file(struct libusb_device_handle *handle, const char* filename) {
last = 0x800;
}

libusb_control_transfer(handle, 0x41, 0, 0, 0, 0, 0, 1000);

int i = 0;
char response[6];
for(i = 0; i < packets; i++) {
int size = i + 1 < packets ? 0x800 : last;
int bytes = 0;

if(!libusb_control_transfer(handle, 0x21, 1, i, 0, &buffer[i * 0x800], size, 1000)) {
if(libusb_bulk_transfer(handle, 4, &buffer[i * 0x800], size, &bytes, 1000)) {
printf("send_file: error sending packet.\n");
return -1;
}

if(libusb_control_transfer(handle, 0xA1, 3, 0, 0, response, 6, 1000) != 6) {
printf("send_file: error receiving status.\n");
return -1;

} else {
if(response[4] != 5) {
printf("send_file: invalid status.\n");
return -1;
}
}

}

libusb_control_transfer(handle, 0x21, 1, i, 0, buffer, 0, 1000);
for(i = 6; i <= 8; i++) {
if(libusb_control_transfer(handle, 0xA1, 3, 0, 0, response, 6, 1000) != 6) {
printf("send_file: error receiving status.\n");
return -1;

} else {
if(response[4] != i && response[4] != i-2) {
printf("send_file: invalid status.\n");
return -1;
}
}
}

free(buffer);
Expand Down

0 comments on commit 55c8076

Please sign in to comment.