1// -*- C++;indent-tabs-mode: t; tab-width: 4; c-basic-offset: 4; -*- 2/* 3 * descriptor_test.cpp 4 * 5 * Test suite program for C++ bindings 6 */ 7 8#include <iostream> 9#include <iomanip> 10#include "usbpp.h" 11 12using namespace std; 13 14int main(void) 15{ 16 17 USB::Busses buslist; 18 19 cout << "bus/device idVendor/idProduct" << endl; 20 21 // buslist.init(); 22 23 USB::Bus *bus; 24 list<USB::Bus *>::const_iterator biter; 25 USB::Device *device; 26 list<USB::Device *>::const_iterator diter; 27 int i, j, k, l; 28 29 for (biter = buslist.begin(); biter != buslist.end(); biter++) { 30 bus = *biter; 31 32 for (diter = bus->begin(); diter != bus->end(); diter++) { 33 device = *diter; 34 35 cout << bus->directoryName() << "/" 36 << device->fileName() << " " 37 << ios::uppercase << hex << setw(4) << setfill('0') 38 << device->idVendor() << "/" 39 << ios::uppercase << hex << setw(4) << setfill('0') 40 << device->idProduct() << endl; 41 if (device->Vendor() != "") { 42 cout << "- Manufacturer : " << device->Vendor() << endl; 43 } else { 44 cout << "- Unable to fetch manufacturer string" << endl; 45 } 46 if (device->Product() != "") { 47 cout << "- Product : " << device->Product() << endl; 48 } else { 49 cout << "- Unable to fetch product string" << endl; 50 } 51 if (device->SerialNumber() != "") { 52 cout << "- Serial Number: " << device->SerialNumber() << endl; 53 } 54 55 USB::Configuration *this_Configuration; 56 this_Configuration = device->firstConfiguration(); 57 for (i=0; i < device->numConfigurations(); i++) { 58 this_Configuration->dumpDescriptor(); 59 USB::Interface *this_Interface; 60 this_Interface = this_Configuration->firstInterface(); 61 for (j=0; j < this_Configuration->numInterfaces(); j++) { 62 USB::AltSetting *this_AltSetting; 63 this_AltSetting = this_Interface->firstAltSetting(); 64 for (k=0; k < this_Interface->numAltSettings(); k++) { 65 this_AltSetting->dumpDescriptor(); 66 USB::Endpoint *this_Endpoint; 67 this_Endpoint = this_AltSetting->firstEndpoint(); 68 for (l=0; l < this_AltSetting->numEndpoints(); l++) { 69 this_Endpoint->dumpDescriptor(); 70 this_Endpoint = this_AltSetting->nextEndpoint(); 71 } 72 this_AltSetting = this_Interface->nextAltSetting(); 73 } 74 this_Interface = this_Configuration->nextInterface(); 75 } 76 this_Configuration = device->nextConfiguration(); 77 } 78 } 79 } 80 81 return 0; 82} 83