USB Device Descriptor

This commit is contained in:
Indy970 2019-02-12 23:35:42 +02:00
parent 4c74f40535
commit 2cca07497c
2 changed files with 28 additions and 4 deletions

View file

@ -147,12 +147,39 @@ int hpusb::is_device(libusb_device * device) {
else {
// log(QString().sprintf("Vendor:Device = %04x:%04x", desc.idVendor, desc.idProduct));
if ((desc.idVendor==USB_VID_HP)&&(desc.idProduct==USB_PID_PRIME3)) {
dumpDevice(device);
return 1;
}
}
return 0;
}
void hpusb::dumpDevice(libusb_device * device) {
QString dump("Device Descriptor\n");
libusb_device_descriptor desc = {0};
int rc=0;
if (device) {
rc = libusb_get_device_descriptor(device, &desc);
dump+=QString().sprintf("bLength: %d\n",(int)desc.bLength);
dump+=QString().sprintf("bDescriptor Type: %d\n",(int)desc.bDescriptorType);
dump+=QString().sprintf("bcdUSB: %d\n",(int)desc.bcdUSB);
dump+=QString().sprintf("bDeviceClass: %d\n",(int)desc.bDeviceClass);
dump+=QString().sprintf("bDeviceSubClass: %d\n",(int)desc.bDeviceSubClass);
dump+=QString().sprintf("bDeviceProtocal: %d\n",(int)desc.bDeviceProtocol);
dump+=QString().sprintf("bMaxPacketSize0: %d\n",(int)desc.bMaxPacketSize0);
dump+=QString().sprintf("idVendor: %X\n",(int)desc.idVendor);
dump+=QString().sprintf("idProduct: %d\n",(int)desc.idProduct);
dump+=QString().sprintf("bcdDevicel: %d\n",(int)desc.bcdDevice);
dump+=QString().sprintf("iManufacture: %i\n",desc.iManufacturer);
dump+=QString().sprintf("iProduct: %i\n",desc.iProduct);
dump+=QString().sprintf("iSerialNumber: %i\n",desc.iSerialNumber);
dump+=QString().sprintf("bNumConfigurations: %d\n",desc.bNumConfigurations);
}
log(dump);
qDebug()<<dump;
}
int hpusb::submit_sync_transfer(hp_Handle * handle, hp_pkt_in * pktin, hp_pkt_out * pktout) {
log("In sync transfer");
@ -439,12 +466,8 @@ int hpusb::load_info(hp_Handle * handle, hp_Information * hpinfo) {
//hpinfo->appver=app;
log(app);
// QByteArray db= QByteArray(reinterpret_cast<const double*>(&pktout.buffer[ind]), pktout.size-ind);
long double num=0;
int i;
ind+=16;

View file

@ -96,6 +96,7 @@ class hpusb
hpusb();
int hp_init();
int is_device(libusb_device *);
void dumpDevice(libusb_device * );
int hp_open(hp_Handle *);
int submit_async_transfer(hp_Handle *, hp_pkt_in *, hp_pkt_out *);
int submit_sync_transfer(hp_Handle *, hp_pkt_in *, hp_pkt_out *);