1 | /* $Id: tstUSBLinux.cpp 14711 2008-11-27 15:16:52Z vboxsync $ */
|
---|
2 |
|
---|
3 | /** @file
|
---|
4 | *
|
---|
5 | * Test executable for quickly excercising/debugging the hal-based Linux USB
|
---|
6 | * bits.
|
---|
7 | */
|
---|
8 |
|
---|
9 | /*
|
---|
10 | * Copyright (C) 2008 Sun Microsystems, Inc.
|
---|
11 | *
|
---|
12 | * Sun Microsystems, Inc. confidential
|
---|
13 | * All rights reserved
|
---|
14 | */
|
---|
15 |
|
---|
16 | #include "tstUSBLinux.h"
|
---|
17 |
|
---|
18 | #include <VBox/err.h>
|
---|
19 |
|
---|
20 | #include <iprt/initterm.h>
|
---|
21 | #include <iprt/stream.h>
|
---|
22 |
|
---|
23 | #include <iprt/cdefs.h>
|
---|
24 | #include <iprt/types.h>
|
---|
25 |
|
---|
26 | int main()
|
---|
27 | {
|
---|
28 | RTR3Init();
|
---|
29 | USBProxyServiceLinux service;
|
---|
30 | service.initSysfs();
|
---|
31 | if (RT_FAILURE(service.getLastError()))
|
---|
32 | {
|
---|
33 | RTPrintf("Failed to initialise USBProxyServiceLinux, error %Rrc\n",
|
---|
34 | service.getLastError());
|
---|
35 | return 1;
|
---|
36 | }
|
---|
37 | PUSBDEVICE pChain = service.getDevicesFromSysfs();
|
---|
38 | if (pChain == NULL)
|
---|
39 | RTPrintf("Failed to get any devices from sysfs\n.");
|
---|
40 | else
|
---|
41 | {
|
---|
42 | PUSBDEVICE pNext = pChain;
|
---|
43 | while (pNext != NULL)
|
---|
44 | {
|
---|
45 | RTPrintf("Device: %s (product string)\n", pNext->pszProduct);
|
---|
46 | RTPrintf(" Manufacturer: %s\n", pNext->pszManufacturer);
|
---|
47 | RTPrintf(" Serial number: %s\n", pNext->pszSerialNumber);
|
---|
48 | RTPrintf(" Address: %s\n", pNext->pszAddress);
|
---|
49 | RTPrintf(" Vendor ID: %d\n", pNext->idVendor);
|
---|
50 | RTPrintf(" Product ID: %d\n", pNext->idProduct);
|
---|
51 | RTPrintf(" Revision: %d.%d\n", pNext->bcdDevice >> 8, pNext->bcdDevice & 255);
|
---|
52 | RTPrintf(" USB Version: %d.%d\n", pNext->bcdUSB >> 8, pNext->bcdUSB & 255);
|
---|
53 | RTPrintf(" Device class: %d\n", pNext->bDeviceClass);
|
---|
54 | RTPrintf(" Device subclass: %d\n", pNext->bDeviceSubClass);
|
---|
55 | RTPrintf(" Device protocol: %d\n", pNext->bDeviceProtocol);
|
---|
56 | RTPrintf(" Number of configurations: %d\n", pNext->bNumConfigurations);
|
---|
57 | RTPrintf(" Device state: %s\n",
|
---|
58 | pNext->enmState == USBDEVICESTATE_UNUSED ? "unused"
|
---|
59 | : pNext->enmState == USBDEVICESTATE_USED_BY_HOST_CAPTURABLE ? "used by host"
|
---|
60 | : "unknown"
|
---|
61 | );
|
---|
62 | RTPrintf(" Device speed: %s\n",
|
---|
63 | pNext->enmSpeed == USBDEVICESPEED_LOW ? "low"
|
---|
64 | : pNext->enmSpeed == USBDEVICESPEED_FULL ? "full"
|
---|
65 | : pNext->enmSpeed == USBDEVICESPEED_HIGH ? "high"
|
---|
66 | : "unknown"
|
---|
67 | );
|
---|
68 | RTPrintf(" Serial hash: 0x%llx\n", pNext->u64SerialHash);
|
---|
69 | RTPrintf(" Bus number: %d\n", pNext->bBus);
|
---|
70 | RTPrintf(" Port number: %d\n", pNext->bPort);
|
---|
71 | RTPrintf(" Device number: %d\n", pNext->bDevNum);
|
---|
72 | RTPrintf("\n");
|
---|
73 | pNext = pNext->pNext;
|
---|
74 | }
|
---|
75 | }
|
---|
76 | return 0;
|
---|
77 | }
|
---|
78 |
|
---|