NI產品與技術 討論區

取消
顯示結果 
搜尋替代 
您的意思是: 

LabWindows/CVI can not append usb pipe path?

Dear All,
I have a small problem in Labwindows CVI. I'm developing a system and need to use USB.
When I trying to copy the device path from SP_INTERFACE_DEVICE_DETAIL_DATA (Null terminated string). Why I couldn't use strcpy(pDeviceDetail->DevicePath0) or  strlen(pDeviceDetail->DevicePath) function?
( Error message >> "missing terminating null in string argument") , The problem didn't exist in VC++,   Why ?
 
Thanks.
ccchen 
0 積分
1 條訊息(共 5 條)
5,435 檢視
Hello ccchen,
 
     Have you ever try to add an null terminatior? You could try
     to insert one to see if it works. If possible, could you show
     some part of your code so we can have more detail to look
     into your problem? Thanks for your help.
 
     Best Regards,
     Alexander Chen,
     Applications Engineer, National Instruments Taiwan
0 積分
2 條訊息(共 5 條)
5,425 檢視

Hi Alexander,

   1. I have try to add "null" , but no use.

   2. Here is my test software , please help me to solve this issue. Thanks.

(ps , If possible, can we disscuss this issue in th tel?)

BR//

ccchen

int get_usb_device()
{   
    SP_INTERFACE_DEVICE_DATA                   interfaceDev;
    SP_INTERFACE_DEVICE_DETAIL_DATA    *pDeviceDetail;
    DWORD dwSize,dwSizeA;
    //
    GUID guid = { 0x652a5694 ,0x8a69, 0x42b9, { 0x98, 0x2f, 0x8c, 0x65, 0xd8, 0x06, 0xeb, 0x85 } };  // = GUID
    HDEVINFO hDev; 
    int pathlen;
    char *devName = "\n"; 
     // 
     hDev = SetupDiGetClassDevs ( &guid, NULL, NULL, DIGCF_PRESENT|DIGCF_DEVICEINTERFACE );   
     //
     interfaceDev.cbSize = sizeof(interfaceDev);   // interfaceDev.cbSize = 28   
     if(!SetupDiEnumDeviceInterfaces  (hDev, NULL, &guid, 0, &interfaceDev))//interfaceDev=0x652a5694,0x8a69,0x42b9, 0x98,0x2f,0x8c,0x65,0xd8, 0x06, 0xeb, 0x85
               return 1;   
     // 
     if( SetupDiGetDeviceInterfaceDetail ( hDev, &interfaceDev, NULL, 0, &dwSize, NULL))  // dwSize = 83
              return 1;
     // 
     pDeviceDetail                =       ( SP_DEVICE_INTERFACE_DETAIL_DATA *)malloc(dwSize+5);         
     pDeviceDetail->cbSize = sizeof( SP_INTERFACE_DEVICE_DETAIL_DATA);
     //
     if(pDeviceDetail == NULL)
     {     SetupDiDestroyDeviceInfoList(hDev);
            return 1;
     }
     dwSizeA = dwSize;
     if(!SetupDiGetDeviceInterfaceDetail ( hDev, &interfaceDev, pDeviceDetail, dwSizeA, &dwSize, NULL))
         return 1;         //  "pDeviceDetail" data in memory are : 05 00 00 00 5c 5c 3f 5c 75 73 62 23 76 69 64 5f 30 34 ........ 
                                                                                  //         ASCII  =              \   \   ?   \    u   s   b   #   v   i     d  _   0   4  .....
    //  
    pathlen = strlen (pDeviceDetail->DevicePath);  //  >> Fail here !! ( Error message >> "missing terminating null in string argument") 
    strcat (pDeviceDetail->DevicePath, "\\");           //  >> Fail here !! ( Error message >> "missing terminating null in string argument")   
    strcpy  ( devName,pDeviceDetail->DevicePath) ; 
  
     printf( "Attempting to open %s\n", devName );  
   return 0;
}

 

 

0 積分
3 條訊息(共 5 條)
5,411 檢視
Hello ccchen,
 
   Thanks for your kindly supplying the source code. Sorry that I am not familiar with
   USB programming, so I can only try to compile your code but I don't know how to
   build a complete application. Currently I can compile without error. Do you encounter
   such error under compile process? Or in the build process? If possible, could you please
   provide a complete CVI project so that we can try to debug in our side?
 
   Also, are you using CVI 3.1 or later? If you are using previous version, you may encounter
   such problem. The following link describe such error.
 
   If you like to contact us via phone, you can call 02-2377222-3 for technial support.
  
  Best Regards,
  Alexander Chen
  AE NITW
0 積分
4 條訊息(共 5 條)
5,387 檢視

Hi Alexander,

Thank you for your feedback & support. I have already solved this issue last night. Thanks again.

( My CVI version is v7.11) 

BR//

ccchen

0 積分
5 條訊息(共 5 條)
5,381 檢視