From a081d007e8a4e67940ee3e6bb622b5955b6addd6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Revol?= Date: Mon, 22 Jan 2007 16:08:31 +0000 Subject: [PATCH] the info.cpp sample from usbkit-99-03-23.tgz git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@19902 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/bin/usb_dev_info.cpp | 82 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 82 insertions(+) create mode 100644 src/bin/usb_dev_info.cpp diff --git a/src/bin/usb_dev_info.cpp b/src/bin/usb_dev_info.cpp new file mode 100644 index 0000000000..6bb0424567 --- /dev/null +++ b/src/bin/usb_dev_info.cpp @@ -0,0 +1,82 @@ + +#include +#include + +void DumpInterface(const USBInterface *ifc) +{ + int i; + const USBEndpoint *ept; + if(!ifc) return; + printf(" Class .............. %d\n",ifc->Class()); + printf(" Subclass ........... %d\n",ifc->Subclass()); + printf(" Protocol ........... %d\n",ifc->Protocol()); + for(i=0;iCountEndpoints();i++){ + if(ept = ifc->EndpointAt(i)){ + printf(" [Endpoint %d]\n",i); + printf(" MaxPacketSize .... %d\n",ept->MaxPacketSize()); + printf(" Interval ......... %d\n",ept->Interval()); + if(ept->IsBulk()){ + printf(" Type ............. Bulk\n"); + } + if(ept->IsIsochronous()){ + printf(" Type ............. Isochronous\n"); + } + if(ept->IsInterrupt()){ + printf(" Type ............. Interrupt\n"); + } + if(ept->IsInput()){ + printf(" Direction ........ Input\n"); + } else { + printf(" Direction ........ Output\n"); + } + } + } +} + +void DumpConfiguration(const USBConfiguration *conf) +{ + int i; + if(!conf) return; + for(i=0;iCountInterfaces();i++){ + printf(" [Interface %d]\n",i); + DumpInterface(conf->InterfaceAt(i)); + } +} + +void DumpInfo(USBDevice &dev) +{ + int i; + + printf("[Device]\n"); + printf("Class .................. %d\n",dev.Class()); + printf("Subclass ............... %d\n",dev.Subclass()); + printf("Protocol ............... %d\n",dev.Protocol()); + printf("Vendor ID .............. 0x%04x\n",dev.VendorID()); + printf("Product ID ............. 0x%04x\n",dev.ProductID()); + printf("Version ................ 0x%04x\n",dev.Version()); + printf("Manufacturer String .... \"%s\"\n",dev.ManufacturerString()); + printf("Product String ......... \"%s\"\n",dev.ProductString()); + printf("Serial Number .......... \"%s\"\n",dev.SerialNumberString()); + + for(i=0;i\n"); + return 1; + } +}