[libusb] Dump out mfg/product/serial strings, if present.
This commit is contained in:
parent
a5f9ea4676
commit
4381022200
|
@ -25,7 +25,7 @@
|
|||
*
|
||||
*/
|
||||
|
||||
#define VERSION "0.23"
|
||||
#define VERSION "0.24"
|
||||
|
||||
#if (__BYTE_ORDER == __LITTLE_ENDIAN)
|
||||
#define le32_to_cpu(__x) __x
|
||||
|
@ -130,7 +130,7 @@ struct printer_data printers[P_END] = {
|
|||
// .paper_code_offset = -1,
|
||||
},
|
||||
{ .type = P_CP_XXX,
|
||||
.model = "SELPHY CP Series (Except CP790/CP900)",
|
||||
.model = "SELPHY CP Series (!CP790/CP900)",
|
||||
.init_length = 12,
|
||||
.foot_length = 0,
|
||||
.init_readback = { 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, -1, 0x00, 0x00, 0x00, 0x00, 0x00 },
|
||||
|
@ -242,7 +242,7 @@ static int parse_printjob(uint8_t *buffer, int *bw_mode, int *plane_len)
|
|||
printer_type = P_CP_XXX;
|
||||
// XXX the P_CP900 is identical, but has extra
|
||||
// data at the very end of the file. No way to detect
|
||||
// from a streamed source.
|
||||
// from a streamed source!
|
||||
} else {
|
||||
printer_type = P_ES1;
|
||||
*bw_mode = (buffer[2] == 0x20);
|
||||
|
|
|
@ -123,6 +123,7 @@ int main (int argc, char **argv)
|
|||
struct libusb_device **list;
|
||||
struct libusb_device_handle *dev;
|
||||
struct libusb_config_descriptor *config;
|
||||
struct libusb_device_descriptor desc;
|
||||
|
||||
uint8_t endp_up = 0;
|
||||
uint8_t endp_down = 0;
|
||||
|
@ -191,8 +192,6 @@ int main (int argc, char **argv)
|
|||
num = libusb_get_device_list(ctx, &list);
|
||||
|
||||
for (i = 0 ; i < num ; i++) {
|
||||
struct libusb_device_descriptor desc;
|
||||
|
||||
libusb_get_device_descriptor(list[i], &desc);
|
||||
|
||||
if (desc.idVendor != USB_VID_CANON)
|
||||
|
@ -264,13 +263,30 @@ int main (int argc, char **argv)
|
|||
|
||||
found2:
|
||||
|
||||
fprintf(stderr, "Found a %s printer\r\n", printers[printer_type].model);
|
||||
|
||||
ret = libusb_open(list[i], &dev);
|
||||
if (ret) {
|
||||
fprintf(stderr, "Could not open device (Need to be root?) (%d)\r\n", ret);
|
||||
goto done_close;
|
||||
}
|
||||
|
||||
/* Query detailed info */
|
||||
fprintf(stderr, "Found a %s printer\r\n", printers[printer_type].model);
|
||||
fprintf(stderr, "Vid: %04x\nPid: %04x\n", desc.idVendor, desc.idProduct);
|
||||
if (desc.iManufacturer || desc.iProduct || desc.iSerialNumber) {
|
||||
unsigned char buf[128];
|
||||
if (desc.iManufacturer) {
|
||||
ret = libusb_get_string_descriptor_ascii(dev, desc.iManufacturer, buf, 128);
|
||||
fprintf(stderr, "Mfg: %s\n", buf);
|
||||
}
|
||||
if (desc.iProduct) {
|
||||
ret = libusb_get_string_descriptor_ascii(dev, desc.iProduct, buf, 128);
|
||||
fprintf(stderr, "Prod: %s\n", buf);
|
||||
}
|
||||
if (desc.iSerialNumber) {
|
||||
ret = libusb_get_string_descriptor_ascii(dev, desc.iSerialNumber, buf, 128);
|
||||
fprintf(stderr, "SerNo: %s\n", buf);
|
||||
}
|
||||
}
|
||||
|
||||
claimed = libusb_kernel_driver_active(dev, iface);
|
||||
if (claimed) {
|
||||
|
@ -281,6 +297,8 @@ found2:
|
|||
}
|
||||
}
|
||||
|
||||
goto done_close;
|
||||
|
||||
ret = libusb_claim_interface(dev, iface);
|
||||
if (ret) {
|
||||
fprintf(stderr, "Could not claim printer interface (%d)\r\n", ret);
|
||||
|
@ -415,10 +433,10 @@ top:
|
|||
done_claimed:
|
||||
libusb_release_interface(dev, iface);
|
||||
|
||||
done_close:
|
||||
if (claimed)
|
||||
libusb_attach_kernel_driver(dev, iface);
|
||||
|
||||
done_close:
|
||||
libusb_close(dev);
|
||||
|
||||
done:
|
||||
|
|
Loading…
Reference in a new issue