The Usb programm

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • yogishgowda
    New Member
    • Nov 2007
    • 4

    The Usb programm

    Hi Debasisdas

    The following is the way i have tried
    DEFINE_GUID(USB IODS_GUID,0x1f5 37664, 0x37a9, 0x48c1, 0x96, 0xe7, 0x1a, 0x8a, 0x18, 0x48, 0x41, 0xfd);
    // {1F537664-37A9-48c1-96E7-1A8A184841FD}



    HDEVINFO hInfo = SetupDiGetClass Devs((struct _GUID *)&USBIODS_GUID , NULL, NULL, DIGCF_PRESENT | DIGCF_INTERFACE DEVICE);

    int i;
    char *Devices[10]; // an array of cstrings
    char name[150];
    for ( i=0; ; ++i)
    {
    SP_INTERFACE_DE VICE_DATA Interface_Info;

    Interface_Info. cbSize = sizeof(Interfac e_Info);
    // Enumerate device


    if (!SetupDiEnumIn terfaceDevice(h Info, NULL, (LPGUID)
    &USBIODS_GUID,i , &Interface_Info ))

    {
    SetupDiDestroyD eviceInfoList(h Info);
    return(i);
    }

    DWORD needed; // get the required lenght
    SetupDiGetInter faceDeviceDetai l(hInfo, &Interface_Info ,
    NULL, 0, &needed, NULL);

    PSP_INTERFACE_D EVICE_DETAIL_DA TA detail = (PSP_INTERFACE_ DEVICE_DETAIL_D ATA) malloc(needed);
    if (!detail)
    {
    SetupDiDestroyD eviceInfoList(h Info);
    return(i);
    }

    detail->cbSize =
    sizeof(SP_INTER FACE_DEVICE_DET AIL_DATA);
    if (!SetupDiGetInt erfaceDeviceDet ail(hInfo,&Inte rface_Info,deta il, needed,NULL, NULL))
    {
    free((PVOID) detail);
    SetupDiDestroyD eviceInfoList(h Info);
    return(i);
    }

    strncpy(name, detail->DevicePath, sizeof(name));
    free((PVOID) detail);
    strcpy(Devices[i],name); // keep a copy of each device name
    printf("%s", name);

    }


    HANDLE hUsbDevice = CreateFile(name , GENERIC_READ |GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, NULL);
    }

    This is the way i have used, kindly suggest any changes to be done for the same as the

    if (!SetupDiEnumIn terfaceDevice(h Info, NULL, (LPGUID)
    &USBIODS_GUID,i , &Interface_Info ))

    is failing and entering the if condition in the code
  • debasisdas
    Recognized Expert Expert
    • Dec 2006
    • 8119

    #2
    The code is OK but what exactly you are trying to do ?
    A brief description of the problem is requested.

    Comment

    • yogishgowda
      New Member
      • Nov 2007
      • 4

      #3
      Originally posted by debasisdas
      The code is OK but what exactly you are trying to do ?
      A brief description of the problem is requested.
      The purpose of this program is to establish communincation b/n the USB device. Here in the program the blocked if loop is failing and the in the debug condition im getting this result
      InterfaceClassG uid {CCCCCCCC-CCCC-CCCC-CCCC-CCCCCCCCCCCC} as this is failing here
      and the program returns from this if loop

      Comment

      • yogishgowda
        New Member
        • Nov 2007
        • 4

        #4
        I hope .. i am missing some initialisation procedure for the devices,
        some more info

        compiler : VC6++
        OS :windows xp

        Comment

        Working...