* 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
|
static void
|
||||||
DumpInfo(BUSBDevice &device, bool verbose)
|
DumpInfo(BUSBDevice &device, bool verbose)
|
||||||
{
|
{
|
||||||
if (verbose) {
|
if (!verbose) {
|
||||||
printf("[Device %s]\n", device.Location());
|
printf("%04x:%04x /dev/bus/usb%s \"%s\" \"%s\" ver. %04x\n",
|
||||||
printf(" Class .................. 0x%02x\n", device.Class());
|
device.VendorID(), device.ProductID(), device.Location(),
|
||||||
printf(" Subclass ............... 0x%02x\n", device.Subclass());
|
device.ManufacturerString(), device.ProductString(),
|
||||||
printf(" Protocol ............... 0x%02x\n", device.Protocol());
|
device.Version());
|
||||||
printf(" Max Endpoint 0 Packet .. %d\n", device.MaxEndpoint0PacketSize());
|
return;
|
||||||
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("[Device /dev/bus/usb%s]\n", device.Location());
|
||||||
printf(" Product Version ........ 0x%04x\n", device.Version());
|
printf(" Class .................. 0x%02x\n", device.Class());
|
||||||
printf(" Manufacturer String .... \"%s\"\n", device.ManufacturerString());
|
printf(" Subclass ............... 0x%02x\n", device.Subclass());
|
||||||
printf(" Product String ......... \"%s\"\n", device.ProductString());
|
printf(" Protocol ............... 0x%02x\n", device.Protocol());
|
||||||
printf(" Serial Number .......... \"%s\"\n", device.SerialNumberString());
|
printf(" Max Endpoint 0 Packet .. %d\n", device.MaxEndpoint0PacketSize());
|
||||||
|
printf(" USB Version ............ 0x%04x\n", device.USBVersion());
|
||||||
for (uint32 i = 0; i < device.CountConfigurations(); i++) {
|
printf(" Vendor ID .............. 0x%04x\n", device.VendorID());
|
||||||
printf(" [Configuration %lu]\n", i);
|
printf(" Product ID ............. 0x%04x\n", device.ProductID());
|
||||||
DumpConfiguration(device.ConfigurationAt(i));
|
printf(" Product Version ........ 0x%04x\n", device.Version());
|
||||||
}
|
printf(" Manufacturer String .... \"%s\"\n", device.ManufacturerString());
|
||||||
} else {
|
printf(" Product String ......... \"%s\"\n", device.ProductString());
|
||||||
printf("%04x:%04x %s %s (version %04x)\n", device.VendorID(), device.ProductID(), device.ManufacturerString(), device.ProductString(), device.Version());
|
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
|
|
||||||
{
|
class DumpRoster : public BUSBRoster {
|
||||||
public:
|
public:
|
||||||
DumpRoster(bool verbose);
|
DumpRoster(bool verbose)
|
||||||
~DumpRoster();
|
: fVerbose(verbose)
|
||||||
|
{
|
||||||
virtual status_t DeviceAdded(BUSBDevice *device);
|
}
|
||||||
virtual void DeviceRemoved(BUSBDevice *device);
|
|
||||||
|
virtual status_t DeviceAdded(BUSBDevice *device)
|
||||||
private:
|
{
|
||||||
bool fVerbose;
|
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
|
int
|
||||||
main(int argc, char *argv[])
|
main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
@ -175,7 +164,7 @@ main(int argc, char *argv[])
|
|||||||
devname = argv[i];
|
devname = argv[i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (devname.Length() > 0) {
|
if (devname.Length() > 0) {
|
||||||
BUSBDevice device(devname.String());
|
BUSBDevice device(devname.String());
|
||||||
if (device.InitCheck() < B_OK) {
|
if (device.InitCheck() < B_OK) {
|
||||||
@ -186,11 +175,10 @@ main(int argc, char *argv[])
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
DumpRoster *roster = new DumpRoster(verbose);
|
DumpRoster roster(verbose);
|
||||||
roster->Start();
|
roster.Start();
|
||||||
roster->Stop();
|
roster.Stop();
|
||||||
delete roster;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user