1 | /* $Id: tstHostHardwareLinux.cpp 14991 2008-12-04 15:17:33Z 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 | #ifdef VBOX_USB_WITH_SYSFS
|
---|
17 | # include "tstUSBLinux.h"
|
---|
18 | #endif
|
---|
19 |
|
---|
20 | #include <HostHardwareLinux.h>
|
---|
21 |
|
---|
22 | #include <VBox/err.h>
|
---|
23 |
|
---|
24 | #include <iprt/initterm.h>
|
---|
25 | #include <iprt/stream.h>
|
---|
26 |
|
---|
27 | #include <iprt/cdefs.h>
|
---|
28 | #include <iprt/types.h>
|
---|
29 |
|
---|
30 | int main()
|
---|
31 | {
|
---|
32 | RTR3Init();
|
---|
33 | #ifdef VBOX_USB_WITH_SYSFS
|
---|
34 | USBProxyServiceLinux service;
|
---|
35 | service.initSysfs();
|
---|
36 | if (RT_FAILURE(service.getLastError()))
|
---|
37 | {
|
---|
38 | RTPrintf("Failed to initialise USBProxyServiceLinux, error %Rrc\n",
|
---|
39 | service.getLastError());
|
---|
40 | return 1;
|
---|
41 | }
|
---|
42 | PUSBDEVICE pChain = service.getDevicesFromSysfs();
|
---|
43 | if (pChain == NULL)
|
---|
44 | RTPrintf("Failed to get any devices from sysfs\n.");
|
---|
45 | else
|
---|
46 | {
|
---|
47 | PUSBDEVICE pNext = pChain;
|
---|
48 | while (pNext != NULL)
|
---|
49 | {
|
---|
50 | RTPrintf("Device: %s (product string)\n", pNext->pszProduct);
|
---|
51 | RTPrintf(" Manufacturer: %s\n", pNext->pszManufacturer);
|
---|
52 | RTPrintf(" Serial number: %s\n", pNext->pszSerialNumber);
|
---|
53 | RTPrintf(" Address: %s\n", pNext->pszAddress);
|
---|
54 | RTPrintf(" Vendor ID: %d\n", pNext->idVendor);
|
---|
55 | RTPrintf(" Product ID: %d\n", pNext->idProduct);
|
---|
56 | RTPrintf(" Revision: %d.%d\n", pNext->bcdDevice >> 8, pNext->bcdDevice & 255);
|
---|
57 | RTPrintf(" USB Version: %d.%d\n", pNext->bcdUSB >> 8, pNext->bcdUSB & 255);
|
---|
58 | RTPrintf(" Device class: %d\n", pNext->bDeviceClass);
|
---|
59 | RTPrintf(" Device subclass: %d\n", pNext->bDeviceSubClass);
|
---|
60 | RTPrintf(" Device protocol: %d\n", pNext->bDeviceProtocol);
|
---|
61 | RTPrintf(" Number of configurations: %d\n", pNext->bNumConfigurations);
|
---|
62 | RTPrintf(" Device state: %s\n",
|
---|
63 | pNext->enmState == USBDEVICESTATE_UNUSED ? "unused"
|
---|
64 | : pNext->enmState == USBDEVICESTATE_USED_BY_HOST_CAPTURABLE ? "used by host"
|
---|
65 | : "unknown"
|
---|
66 | );
|
---|
67 | RTPrintf(" Device speed: %s\n",
|
---|
68 | pNext->enmSpeed == USBDEVICESPEED_LOW ? "low"
|
---|
69 | : pNext->enmSpeed == USBDEVICESPEED_FULL ? "full"
|
---|
70 | : pNext->enmSpeed == USBDEVICESPEED_HIGH ? "high"
|
---|
71 | : "unknown"
|
---|
72 | );
|
---|
73 | RTPrintf(" Serial hash: 0x%llx\n", pNext->u64SerialHash);
|
---|
74 | RTPrintf(" Bus number: %d\n", pNext->bBus);
|
---|
75 | RTPrintf(" Port number: %d\n", pNext->bPort);
|
---|
76 | RTPrintf(" Device number: %d\n", pNext->bDevNum);
|
---|
77 | RTPrintf("\n");
|
---|
78 | pNext = pNext->pNext;
|
---|
79 | }
|
---|
80 | }
|
---|
81 | #endif /* VBOX_USB_WITH_SYSFS */
|
---|
82 | VBoxMainDriveInfo driveInfo;
|
---|
83 | g_testHostHardwareLinux = true;
|
---|
84 | int rc = driveInfo.updateFloppies();
|
---|
85 | if (RT_SUCCESS (rc))
|
---|
86 | rc = driveInfo.updateDVDs();
|
---|
87 | if (RT_FAILURE (rc))
|
---|
88 | {
|
---|
89 | RTPrintf("Failed to update the host drive information, error %Rrc\n",
|
---|
90 | rc);
|
---|
91 | return 1;
|
---|
92 | }
|
---|
93 | RTPrintf ("Listing floppy drives detected:\n");
|
---|
94 | for (VBoxMainDriveInfo::DriveInfoList::const_iterator it = driveInfo.FloppyBegin();
|
---|
95 | it != driveInfo.FloppyEnd(); ++it)
|
---|
96 | {
|
---|
97 | RTPrintf (" device: %s", it->mDevice.c_str());
|
---|
98 | if (!it->mUdi.empty())
|
---|
99 | RTPrintf (", udi: %s", it->mUdi.c_str());
|
---|
100 | if (!it->mDescription.empty())
|
---|
101 | RTPrintf (", description: %s", it->mDescription.c_str());
|
---|
102 | RTPrintf ("\n");
|
---|
103 | }
|
---|
104 | RTPrintf ("Listing DVD drives detected:\n");
|
---|
105 | for (VBoxMainDriveInfo::DriveInfoList::const_iterator it = driveInfo.DVDBegin();
|
---|
106 | it != driveInfo.DVDEnd(); ++it)
|
---|
107 | {
|
---|
108 | RTPrintf (" device: %s", it->mDevice.c_str());
|
---|
109 | if (!it->mUdi.empty())
|
---|
110 | RTPrintf (", udi: %s", it->mUdi.c_str());
|
---|
111 | if (!it->mDescription.empty())
|
---|
112 | RTPrintf (", description: %s", it->mDescription.c_str());
|
---|
113 | RTPrintf ("\n");
|
---|
114 | }
|
---|
115 | return 0;
|
---|
116 | }
|
---|
117 |
|
---|