Home › Forums › C Programming › USB programming
- This topic has 0 replies, 1 voice, and was last updated 17 years, 1 month ago by bill.
Viewing 0 reply threads
- AuthorPosts
- November 20, 2007 at 12:25 am #2036billParticipant
The purpose of this program is to establish communincation b/n the USB device. Here in the program the bolded if loop is failing and the in the debug condition im getting this result
InterfaceClassGuid {CCCCCCCC-CCCC-CCCC-CCCC-CCCCCCCCCCCC} as this is failing here
and the program returns from this if loop
The following is the way i have tried123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051DEFINE_GUID(USBIODS_GUID,0x1f537664, 0x37a9, 0x48c1, 0x96, 0xe7, 0x1a, 0x8a, 0x18, 0x48, 0x41, 0xfd);<br />// {1F537664-37A9-48c1-96E7-1A8A184841FD}<br /><br />HDEVINFO hInfo = SetupDiGetClassDevs((struct _GUID *)&USBIODS_GUID, NULL, NULL, DIGCF_PRESENT | DIGCF_INTERFACEDEVICE);<br /><br />int i;<br />char *Devices[10]; // an array of cstrings<br />char name[150];<br />for ( i=0; ; ++i)<br />{<br />SP_INTERFACE_DEVICE_DATA Interface_Info;<br /><br />Interface_Info.cbSize = sizeof(Interface_Info);<br />// Enumerate device<br /><br /><br />if (!SetupDiEnumInterfaceDevice(hInfo, NULL, (LPGUID)<br />&USBIODS_GUID,i, &Interface_Info))<br />{<br />SetupDiDestroyDeviceInfoList(hInfo);<br />return(i);<br />}<br /><br />DWORD needed; // get the required lenght<br />SetupDiGetInterfaceDeviceDetail(hInfo, &Interface_Info,<br />NULL, 0, &needed, NULL);<br /><br />PSP_INTERFACE_DEVICE_DETAIL_DATA detail = (PSP_INTERFACE_DEVICE_DETAIL_DATA) malloc(needed);<br />if (!detail)<br />{<br />SetupDiDestroyDeviceInfoList(hInfo);<br />return(i);<br />}<br /><br />detail->cbSize =<br />sizeof(SP_INTERFACE_DEVICE_DETAIL_DATA);<br />if (!SetupDiGetInterfaceDeviceDetail(hInfo,&Interface_Info,detail, needed,NULL, NULL))<br />{<br />free((PVOID) detail);<br />SetupDiDestroyDeviceInfoList(hInfo);<br />return(i);<br />}<br />strncpy(name, detail->DevicePath, sizeof(name));<br />free((PVOID) detail);<br />strcpy(Devices,name); // keep a copy of each device name<br />printf("%s", name);<br />}<br />HANDLE hUsbDevice = CreateFile(name, GENERIC_READ |GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, NULL);<br />}<br /><br />This is the way i have used, kindly suggest any changes to be done for the same as the
123if (!SetupDiEnumInterfaceDevice(hInfo, NULL, (LPGUID)<br />&USBIODS_GUID,i, &Interface_Info))<br />is failing and entering the if condition in the code
- AuthorPosts
Viewing 0 reply threads
- The forum ‘C Programming’ is closed to new topics and replies.