阅读:1453回复:4
我的usb通讯怎么老编译不通?(50分)
源代码如下:
GUID hidGUID; HDEVINFO hardwareDeviceInfoSet; SP_DEVICE_INTERFACE_DATA deviceInterfaceData; PSP_INTERFACE_DEVICE_DETAIL_DATA deviceDetail; ULONG requiredSize; HANDLE deviceHandle = INVALID_HANDLE_VALUE; DWORD result; //Get the HID GUID value - used as mask to get list of devices HidD_GetHidGuid (&hidGUID); //Get a list of devices matching the criteria (hid interface, present) hardwareDeviceInfoSet = SetupDiGetClassDevs (&hidGUID, NULL, // Define no enumerator (global) NULL, // Define no (DIGCF_PRESENT | // Only Devices present DIGCF_DEVICEINTERFACE)); // Function class devices. deviceInterfaceData.cbSize = sizeof(SP_DEVICE_INTERFACE_DATA); //Go through the list and get the interface data result = SetupDiEnumDeviceInterfaces (hardwareDeviceInfoSet, NULL, //infoData, &hidGUID, //interfaceClassGuid, deviceIndex, &deviceInterfaceData); /* Failed to get a device - possibly the index is larger than the number of devices */ if (result == FALSE) { SetupDiDestroyDeviceInfoList (hardwareDeviceInfoSet); return INVALID_HANDLE_VALUE; } //Get the details with null values to get the required size of the buffer SetupDiGetDeviceInterfaceDetail (hardwareDeviceInfoSet, &deviceInterfaceData, NULL, //interfaceDetail, 0, //interfaceDetailSize, &requiredSize, 0); //infoData)) //Allocate the buffer deviceDetail = (PSP_INTERFACE_DEVICE_DETAIL_DATA)malloc(requiredSize); deviceDetail->cbSize = sizeof(SP_INTERFACE_DEVICE_DETAIL_DATA); //Fill the buffer with the device details if (!SetupDiGetDeviceInterfaceDetail (hardwareDeviceInfoSet, &deviceInterfaceData, deviceDetail, requiredSize, &requiredSize, NULL)) { SetupDiDestroyDeviceInfoList (hardwareDeviceInfoSet); free (deviceDetail); return INVALID_HANDLE_VALUE; } //Open file on the device deviceHandle = CreateFile (deviceDetail->DevicePath, GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, // no SECURITY_ATTRIBUTES structure OPEN_EXISTING, // No special create flags 0, NULL); // No template file SetupDiDestroyDeviceInfoList (hardwareDeviceInfoSet); free (deviceDetail); return deviceHandle; 1. 其中GUID打印出来是: 4D1E55B2-F16F-11CF-88CB-001111000030 在好几台机器上编译都是这个,这个是GUID吗? 2. SetupDiGetClassDevs 总是返回一个值:0x00143cb8请问这个是 设备句柄吗? 3. 我的result = SetupDiEnumDeviceInterfaces总是返回零,有时候调用N次都是0,怎么回事啊?快头疼死了!请大侠帮帮忙! [编辑 - 7/17/04 by billy2004] |
|
沙发#
发布于:2004-07-18 09:13
你在firmware里写好符合hid的代码没有?上philips的网站,搜搜关于pdiusbd12的资料,下载usbhid的编程源代码看看吧,下载driver和源码要注册的,不管是免费的
[编辑 - 7/18/04 by netscan] |
|
板凳#
发布于:2004-07-17 19:22
快救救我吧!
|
|
地板#
发布于:2004-07-17 17:43
我的USB芯片是philips的pdiusbd12
|
|
地下室#
发布于:2004-07-17 15:44
既然是hid设备,那就不需要知道guid了,你不是用了HidD_GetHidGuid函数了吗?有源码的,找关于hid设备源码好好看看
[编辑 - 7/17/04 by netscan] |
|