all: Fix enumeration, and fix send_data for larger sizes.
This commit is contained in:
parent
310ae8c241
commit
46aff13042
|
@ -115,7 +115,7 @@ done:
|
|||
}
|
||||
|
||||
static int send_data(struct libusb_device_handle *dev, uint8_t endp,
|
||||
uint8_t *buf, uint16_t len)
|
||||
uint8_t *buf, int len)
|
||||
{
|
||||
int num;
|
||||
|
||||
|
@ -129,6 +129,7 @@ static int send_data(struct libusb_device_handle *dev, uint8_t endp,
|
|||
}
|
||||
len -= num;
|
||||
buf += num;
|
||||
// DEBUG("Sent %d (%d remaining) to 0x%x\n", num, len, endp);
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
@ -144,7 +145,7 @@ static void sigterm_handler(int signum) {
|
|||
static int print_scan_output(struct libusb_device *device,
|
||||
struct libusb_device_descriptor *desc,
|
||||
char *prefix, char *manuf2,
|
||||
int found, int valid,
|
||||
int found, int match, int valid,
|
||||
int scan_only, char *match_serno)
|
||||
{
|
||||
struct libusb_device_handle *dev;
|
||||
|
@ -155,7 +156,8 @@ static int print_scan_output(struct libusb_device *device,
|
|||
|
||||
if (libusb_open(device, &dev)) {
|
||||
ERROR("Could not open device %04x:%04x\n", desc->idVendor, desc->idProduct);
|
||||
return -1;
|
||||
found = -1;
|
||||
goto abort;
|
||||
}
|
||||
|
||||
/* Query detailed info */
|
||||
|
@ -174,7 +176,7 @@ static int print_scan_output(struct libusb_device *device,
|
|||
|
||||
DEBUG("%s%sPID: %04X Product: '%s' Serial: '%s'\n",
|
||||
(!valid) ? "UNRECOGNIZED: " : "",
|
||||
found ? "MATCH: " : "",
|
||||
match ? "MATCH: " : "",
|
||||
desc->idProduct, product, serial);
|
||||
|
||||
if (valid && scan_only) {
|
||||
|
@ -210,5 +212,6 @@ static int print_scan_output(struct libusb_device *device,
|
|||
}
|
||||
|
||||
libusb_close(dev);
|
||||
abort:
|
||||
return found;
|
||||
}
|
||||
|
|
|
@ -116,7 +116,7 @@ static int find_and_enumerate(struct libusb_context *ctx,
|
|||
|
||||
found = print_scan_output((*list)[i], &desc,
|
||||
URI_PREFIX, "Kodak",
|
||||
(found == i), 1,
|
||||
found, (found == i), 1,
|
||||
scan_only, match_serno);
|
||||
}
|
||||
|
||||
|
|
|
@ -98,7 +98,7 @@ static int find_and_enumerate(struct libusb_context *ctx,
|
|||
|
||||
found = print_scan_output((*list)[i], &desc,
|
||||
URI_PREFIX, "Kodak",
|
||||
(found == i), 1,
|
||||
found, (found == i), 1,
|
||||
scan_only, match_serno);
|
||||
}
|
||||
|
||||
|
|
|
@ -446,7 +446,7 @@ static int find_and_enumerate(struct libusb_context *ctx,
|
|||
|
||||
found = print_scan_output((*list)[i], &desc,
|
||||
URI_PREFIX, "Canon",
|
||||
(found == i), valid,
|
||||
found, (found == i), valid,
|
||||
scan_only, match_serno);
|
||||
}
|
||||
|
||||
|
@ -592,6 +592,8 @@ int main (int argc, char **argv)
|
|||
read_data(footer_len, 0, data_fd, footer, buffer, BUF_LEN);
|
||||
close(data_fd); /* We're done */
|
||||
|
||||
DEBUG("Plane len %d\n", plane_len);
|
||||
|
||||
/* Libusb setup */
|
||||
libusb_init(&ctx);
|
||||
found = find_and_enumerate(ctx, &list, use_serno, printer_type, 0);
|
||||
|
|
Loading…
Reference in a new issue