Changeset 60522 in vbox for trunk/src/VBox/ValidationKit/utils/usb
- Timestamp:
- Apr 15, 2016 2:34:35 PM (9 years ago)
- svn:sync-xref-src-repo-rev:
- 106643
- Location:
- trunk/src/VBox/ValidationKit/utils/usb
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/ValidationKit/utils/usb/UsbTest.cpp
r58930 r60522 30 30 * Header Files * 31 31 *********************************************************************************************************************************/ 32 #include <iprt/dir.h> 32 33 #include <iprt/err.h> 34 #include <iprt/file.h> 33 35 #include <iprt/getopt.h> 34 36 #include <iprt/path.h> … … 38 40 #include <iprt/string.h> 39 41 #include <iprt/test.h> 40 #include <iprt/file.h>41 42 42 43 #include <unistd.h> … … 273 274 * Assumption is that the path looks like /dev/bus/usb/%3d/%3d. 274 275 */ 275 uint8_t uBus = 1; 276 bool fBusExists = false; 277 char aszDevPath[64]; 278 279 RT_ZERO(aszDevPath); 280 281 do 276 char *pszDevPath = NULL; 277 278 PRTDIR pDirUsb = NULL; 279 int rc = RTDirOpen(&pDirUsb, "/dev/bus/usb"); 280 if (RT_SUCCESS(rc)) 282 281 { 283 RTStrPrintf(aszDevPath, sizeof(aszDevPath), "/dev/bus/usb/%03d", uBus); 284 285 fBusExists = RTPathExists(aszDevPath); 286 287 if (fBusExists) 282 do 288 283 { 289 /* Check every device. */ 290 bool fDevExists = false; 291 uint8_t uDev = 1; 292 293 do 284 RTDIRENTRY DirUsbBus; 285 rc = RTDirRead(pDirUsb, &DirUsbBus, NULL); 286 if (RT_SUCCESS(rc)) 294 287 { 295 RTStrPrintf(aszDevPath, sizeof(aszDevPath), "/dev/bus/usb/%03d/%03d", uBus, uDev); 296 297 fDevExists = RTPathExists(aszDevPath); 298 299 if (fDevExists) 288 char aszPath[RTPATH_MAX + 1]; 289 RTStrPrintf(&aszPath[0], RT_ELEMENTS(aszPath), "/dev/bus/usb/%s", DirUsbBus.szName); 290 291 PRTDIR pDirUsbBus = NULL; 292 rc = RTDirOpen(&pDirUsbBus, &aszPath[0]); 293 if (RT_SUCCESS(rc)) 300 294 { 301 RTFILE hFileDev; 302 int rc = RTFileOpen(&hFileDev, aszDevPath, RTFILE_O_OPEN | RTFILE_O_READ | RTFILE_O_DENY_NONE); 303 if (RT_SUCCESS(rc)) 295 do 304 296 { 305 USBDEVDESC DevDesc; 306 307 rc = RTFileRead(hFileDev, &DevDesc, sizeof(DevDesc), NULL); 308 RTFileClose(hFileDev); 309 310 if ( RT_SUCCESS(rc) 311 && DevDesc.idVendor == 0x0525 312 && DevDesc.idProduct == 0xa4a0) 313 return RTStrDup(aszDevPath); 314 } 297 RTDIRENTRY DirUsbDev; 298 rc = RTDirRead(pDirUsbBus, &DirUsbDev, NULL); 299 if (RT_SUCCESS(rc)) 300 { 301 char aszPathDev[RTPATH_MAX + 1]; 302 RTStrPrintf(&aszPathDev[0], RT_ELEMENTS(aszPathDev), "/dev/bus/usb/%s/%s", 303 DirUsbBus.szName, DirUsbDev.szName); 304 305 RTFILE hFileDev; 306 rc = RTFileOpen(&hFileDev, aszPathDev, RTFILE_O_OPEN | RTFILE_O_READ | RTFILE_O_DENY_NONE); 307 if (RT_SUCCESS(rc)) 308 { 309 USBDEVDESC DevDesc; 310 311 rc = RTFileRead(hFileDev, &DevDesc, sizeof(DevDesc), NULL); 312 RTFileClose(hFileDev); 313 314 if ( RT_SUCCESS(rc) 315 && DevDesc.idVendor == 0x0525 316 && DevDesc.idProduct == 0xa4a0) 317 pszDevPath = RTStrDup(aszPathDev); 318 } 319 320 rc = VINF_SUCCESS; 321 } 322 else if (rc != VERR_NO_MORE_FILES) 323 rc = VINF_SUCCESS; 324 325 } while ( RT_SUCCESS(rc) 326 && !pszDevPath); 327 328 rc = VINF_SUCCESS; 329 RTDirClose(pDirUsbBus); 315 330 } 316 317 uDev++; 318 } while (fDevExists); 319 } 320 321 uBus++; 322 } while (fBusExists); 323 324 return NULL; 331 } 332 else if (rc != VERR_NO_MORE_FILES) 333 rc = VINF_SUCCESS; 334 } while ( RT_SUCCESS(rc) 335 && !pszDevPath); 336 337 RTDirClose(pDirUsb); 338 } 339 340 return pszDevPath; 325 341 } 326 342 -
trunk/src/VBox/ValidationKit/utils/usb/UsbTestService.cpp
r60517 r60522 832 832 rc = utsDoGadgetCreate(pClient, pPktHdr); 833 833 else if (utsIsSameOpcode(pPktHdr, UTSPKT_OPCODE_GADGET_DESTROY)) 834 rc = utsDoGadget Create(pClient, pPktHdr);834 rc = utsDoGadgetDestroy(pClient, pPktHdr); 835 835 else if (utsIsSameOpcode(pPktHdr, UTSPKT_OPCODE_GADGET_CONNECT)) 836 836 rc = utsDoGadgetConnect(pClient, pPktHdr); -
trunk/src/VBox/ValidationKit/utils/usb/UsbTestServiceGadgetClassTest.cpp
r60517 r60522 32 32 #include <iprt/string.h> 33 33 #include <iprt/symlink.h> 34 #include <iprt/thread.h> 34 35 #include <iprt/types.h> 35 36 … … 359 360 if (RT_SUCCESS(rc)) 360 361 rc = RTLinuxSysFsWriteStrFile(pClass->pszUdc, 0, NULL, "%s/UDC", pClass->pszGadgetPath); 362 if (RT_SUCCESS(rc)) 363 RTThreadSleep(500); /* Fudge: Sleep a bit to give the device a chance to appear on the host so binding succeeds. */ 361 364 } 362 365 } … … 406 409 static DECLCALLBACK(int) utsGadgetClassTestConnect(PUTSGADGETCLASSINT pClass) 407 410 { 408 return RTLinuxSysFsWriteStrFile("connect", 0, NULL, "/sys/class/udc/%s/soft_connect", pClass->pszUdc); 411 int rc = RTLinuxSysFsWriteStrFile("connect", 0, NULL, "/sys/class/udc/%s/soft_connect", pClass->pszUdc); 412 if (RT_SUCCESS(rc)) 413 RTThreadSleep(500); /* Fudge: Sleep a bit to give the device a chance to appear on the host so binding succeeds. */ 414 415 return rc; 409 416 } 410 417 -
trunk/src/VBox/ValidationKit/utils/usb/UsbTestServicePlatform-linux.cpp
r60518 r60522 178 178 g_paDummyHcd[idxHcdCur].uBusId = uBusId; 179 179 g_paDummyHcd[idxHcdCur].fAvailable = true; 180 idxHcdCur++; 180 181 } 181 182 } … … 300 301 pszIdx++; 301 302 uint32_t idxHcd = 0; 302 rc = RTStrToUInt32Ex(psz Udc, NULL, 10, &idxHcd);303 rc = RTStrToUInt32Ex(pszIdx, NULL, 10, &idxHcd); 303 304 if (RT_SUCCESS(rc)) 304 305 {
Note:
See TracChangeset
for help on using the changeset viewer.