本文介绍了如何获取接口2端点7下的路径以获取接收数据?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我有设备将在接口2端点7下传输数据



但我不知道如何获取接口2端点7的设备路径





我的代码如下所示:



If I have device will transfer data under interface 2 endpoint 7

but I have no idea how to get device path of interface 2 endpoint 7


my code by step as below:

// declared
SP_DEVINFO_DATA devInfoData;
SP_DEVICE_INTERFACE_DATA deviceInterfaceData;
PSP_INTERFACE_DEVICE_DETAIL_DATA detail = NULL;


//step 1:
HDEVINFO handle = SetupDiGetClassDevs(&USB_DEVICE, NULL, NULL, DIGCF_PRESENT | DIGCF_DEVICEINTERFACE); 

devInfoData.cbSize = sizeof(SP_DEVINFO_DATA);
deviceInterfaceData.cbSize = sizeof(SP_DEVICE_INTERFACE_DATA);

//step 2
for(memberIndex = 0; SetupDiEnumDeviceInfo(handle, memberIndex, &devInfoData); memberIndex++)
{
     result = SetupDiEnumDeviceInterfaces(handle, NULL, &USB_DEVICE, memberIndex, &deviceInterfaceData);
     if(result)
     {
         //step 3
         // First we get the required buffer size
         result = SetupDiGetDeviceInterfaceDetail(handle, &deviceInterfaceData, NULL, 0, &requiredSize, NULL);

         ...
         detail = (PSP_INTERFACE_DEVICE_DETAIL_DATA) new BYTE[requiredSize];
         detail->cbSize = sizeof(SP_INTERFACE_DEVICE_DETAIL_DATA);


         //step 4
         result = SetupDiGetDeviceInterfaceDetail(handle, &deviceInterfaceData, detail, requiredSize, NULL, &devInfoData);
         if(!result)
         {
          //Error handle
          continue;
          }


          ...


         //declared
         UINT success;
         char pinBuf[512] = {0}, poutBuf[512] = {0};
         int ReadLen = 512, WriteLen = 512;
         OVERLAPPED ovlp;
         DWORD lpBytesReturnedRead, lpBytesReturnedWrite;

         //this path is my confused point
         //detail->DevicePath is get parent class, but I need get child class path 
         //like under uvc class interface 2 endpoint 7 path

         //my diagram
         <a href="https://db.tt/kdKY28tl">regedit diagram</a>

        // "detail->DevicePath" get the format like this as below:
  // \??\USB#VID_0603&PID_8613#6&293792e1&0&2#{a5dcbf10-6530-11d2-901f-00c04fb951ed}
         HANDLE handleCreateFile = CreateFile(detail->DevicePath,  //<-------point
					GENERIC_WRITE | GENERIC_READ,
					FILE_SHARE_WRITE | FILE_SHARE_READ,
					NULL,
					OPEN_EXISTING,
					FILE_FLAG_OVERLAPPED,
					NULL);
         // how could I get uvc class path under interface 2 endpoint 7
         // this is my confused point ,i have no idea
         // any someone have good idea ,how to get this path or using another method




        //finally
        success = ReadFile(handleCreateFile,
					pinBuf,//&pinBuf,         <----?
					512,
					&lpBytesReturnedRead,   //<----?
					&ovlp                   //<----?
					);
        //the ReadFile where wrong , the success value always return false ??
        // Could any one tell me , how to fill correct Parameters?
        if(!success)
        {
            //do something
        }



     }

推荐答案


这篇关于如何获取接口2端点7下的路径以获取接收数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-17 18:59