* Compacted some of the code and inlined the DumpRoster implementation into the
class as it's so little code. * No need to allocate the roster on the heap. * Add /dev/bus/usb to the device location to make it more clear. * Add the device location to the non-verbose output as well. * Put the manufacturer and product strings into quotes to make it clearer that those are just strings. Avoids just blank output when a device doesn't provide those strings. * Remove trailing whitespace. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@29187 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
f7de06baf3
commit
576cd2495d
@ -95,67 +95,56 @@ DumpConfiguration(const BUSBConfiguration *configuration)
|
||||
static void
|
||||
DumpInfo(BUSBDevice &device, bool verbose)
|
||||
{
|
||||
if (verbose) {
|
||||
printf("[Device %s]\n", device.Location());
|
||||
printf(" Class .................. 0x%02x\n", device.Class());
|
||||
printf(" Subclass ............... 0x%02x\n", device.Subclass());
|
||||
printf(" Protocol ............... 0x%02x\n", device.Protocol());
|
||||
printf(" Max Endpoint 0 Packet .. %d\n", device.MaxEndpoint0PacketSize());
|
||||
printf(" USB Version ............ 0x%04x\n", device.USBVersion());
|
||||
printf(" Vendor ID .............. 0x%04x\n", device.VendorID());
|
||||
printf(" Product ID ............. 0x%04x\n", device.ProductID());
|
||||
printf(" Product Version ........ 0x%04x\n", device.Version());
|
||||
printf(" Manufacturer String .... \"%s\"\n", device.ManufacturerString());
|
||||
printf(" Product String ......... \"%s\"\n", device.ProductString());
|
||||
printf(" Serial Number .......... \"%s\"\n", device.SerialNumberString());
|
||||
if (!verbose) {
|
||||
printf("%04x:%04x /dev/bus/usb%s \"%s\" \"%s\" ver. %04x\n",
|
||||
device.VendorID(), device.ProductID(), device.Location(),
|
||||
device.ManufacturerString(), device.ProductString(),
|
||||
device.Version());
|
||||
return;
|
||||
}
|
||||
|
||||
for (uint32 i = 0; i < device.CountConfigurations(); i++) {
|
||||
printf(" [Configuration %lu]\n", i);
|
||||
DumpConfiguration(device.ConfigurationAt(i));
|
||||
}
|
||||
} else {
|
||||
printf("%04x:%04x %s %s (version %04x)\n", device.VendorID(), device.ProductID(), device.ManufacturerString(), device.ProductString(), device.Version());
|
||||
printf("[Device /dev/bus/usb%s]\n", device.Location());
|
||||
printf(" Class .................. 0x%02x\n", device.Class());
|
||||
printf(" Subclass ............... 0x%02x\n", device.Subclass());
|
||||
printf(" Protocol ............... 0x%02x\n", device.Protocol());
|
||||
printf(" Max Endpoint 0 Packet .. %d\n", device.MaxEndpoint0PacketSize());
|
||||
printf(" USB Version ............ 0x%04x\n", device.USBVersion());
|
||||
printf(" Vendor ID .............. 0x%04x\n", device.VendorID());
|
||||
printf(" Product ID ............. 0x%04x\n", device.ProductID());
|
||||
printf(" Product Version ........ 0x%04x\n", device.Version());
|
||||
printf(" Manufacturer String .... \"%s\"\n", device.ManufacturerString());
|
||||
printf(" Product String ......... \"%s\"\n", device.ProductString());
|
||||
printf(" Serial Number .......... \"%s\"\n", device.SerialNumberString());
|
||||
|
||||
for (uint32 i = 0; i < device.CountConfigurations(); i++) {
|
||||
printf(" [Configuration %lu]\n", i);
|
||||
DumpConfiguration(device.ConfigurationAt(i));
|
||||
}
|
||||
}
|
||||
|
||||
class DumpRoster : public BUSBRoster
|
||||
{
|
||||
public:
|
||||
DumpRoster(bool verbose);
|
||||
~DumpRoster();
|
||||
|
||||
virtual status_t DeviceAdded(BUSBDevice *device);
|
||||
virtual void DeviceRemoved(BUSBDevice *device);
|
||||
class DumpRoster : public BUSBRoster {
|
||||
public:
|
||||
DumpRoster(bool verbose)
|
||||
: fVerbose(verbose)
|
||||
{
|
||||
}
|
||||
|
||||
private:
|
||||
bool fVerbose;
|
||||
virtual status_t DeviceAdded(BUSBDevice *device)
|
||||
{
|
||||
DumpInfo(*device, fVerbose);
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
virtual void DeviceRemoved(BUSBDevice *device)
|
||||
{
|
||||
}
|
||||
|
||||
private:
|
||||
bool fVerbose;
|
||||
};
|
||||
|
||||
|
||||
DumpRoster::DumpRoster(bool verbose)
|
||||
: BUSBRoster(),
|
||||
fVerbose(verbose)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
DumpRoster::~DumpRoster()
|
||||
{
|
||||
}
|
||||
|
||||
status_t
|
||||
DumpRoster::DeviceAdded(BUSBDevice *device)
|
||||
{
|
||||
DumpInfo(*device, fVerbose);
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
void
|
||||
DumpRoster::DeviceRemoved(BUSBDevice *)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
@ -186,10 +175,9 @@ main(int argc, char *argv[])
|
||||
return 0;
|
||||
}
|
||||
} else {
|
||||
DumpRoster *roster = new DumpRoster(verbose);
|
||||
roster->Start();
|
||||
roster->Stop();
|
||||
delete roster;
|
||||
DumpRoster roster(verbose);
|
||||
roster.Start();
|
||||
roster.Stop();
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
Loading…
Reference in New Issue
Block a user