N
Hallo ich bin seit einiger Zeit drüber eine eigene USB-Firmware für
einen AT90USB162 zu schreiben.
Nach dem ich jetzt endlich das Gerät richtig in Windows als HID-Tastatur
erkannt habe wollte ich nun die ersten Kommunikationsversuche mit dem
Host starten. Dafür wollte ich mir eine kleine C Application schreiben und dabei bin ich auf den Thread hier gestoßen. Die Erkennung des Gerätes klappt soweit auch gut.
Soweit so gut:
Das Problem ist wenn ich HidP_GetCaps aufrufe stürtzt mein Programm
jedesmal mit dem Fehler hidparse.sys konnte nicht gefunden werden.
Jetzt ist die Datei aber im richtigen verzeichniss und auch vorhanden.
Die richtigen Bibiliotheken müsste ich auch eingebunden haben sonst
könnte ich es ja nicht compelieren.
Jemand eine idee an was das liegen könnte
hier mal der C-Code
#include <windows.h>
#include <stdio.h>
#include <stdlib.h>
#include <ddk/hidsdi.h>
#include <ddk/hidpi.h>
#include <ddk/hidusage.h>
#include <setupapi.h>
int main()
{
PSP_DEVICE_INTERFACE_DETAIL_DATA pspdidd;
SP_DEVICE_INTERFACE_DATA spdid;
SP_DEVINFO_DATA spdd;
HDEVINFO hDevInfo;
DWORD dwIndex, dwSize, dwType;
TCHAR szProperty[256];
GUID guid;
HANDLE DeviceHandle;
HIDD_ATTRIBUTES Attributes;
PHIDP_PREPARSED_DATA PreparsedData;
HIDP_CAPS Capabilities;
ZeroMemory(&spdid, sizeof(spdid));
spdid.cbSize = sizeof(spdid);
HidD_GetHidGuid(&guid);
hDevInfo = SetupDiGetClassDevs(&guid,NULL,NULL,DIGCF_DEVICEINTERFACE | DIGCF_PRESENT);
if(hDevInfo == INVALID_HANDLE_VALUE)
{
printf("SetupDiGetClassDevs failed, Error %u\n", GetLastError());
return(FALSE);
}
for(dwIndex = 0; (SetupDiEnumDeviceInterfaces(hDevInfo,NULL,&guid,dwIndex,&spdid)); dwIndex++)
{
printf("Geraete-Index: %u\n", dwIndex);
dwSize = 0;
SetupDiGetDeviceInterfaceDetail(hDevInfo,&spdid,NULL,0,&dwSize,NULL);
if(dwSize)
{
if(NULL == (pspdidd = (PSP_DEVICE_INTERFACE_DETAIL_DATA)HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,dwSize)))
continue;
pspdidd->cbSize = sizeof(*pspdidd);
ZeroMemory((PVOID)&spdd, sizeof(spdd));
spdd.cbSize = sizeof(spdd);
if(SetupDiGetDeviceInterfaceDetail(hDevInfo,&spdid,pspdidd,dwSize,&dwSize,&spdd))
{
printf("Name fuer CreateFile(): %s\n", pspdidd->DevicePath);
if(SetupDiGetDeviceRegistryProperty(hDevInfo,&spdd,SPDRP_FRIENDLYNAME,&dwType,(PBYTE)szProperty,sizeof(szProperty),NULL))
{
if(dwType == REG_SZ)
printf("FriendlyName: %s\n", szProperty);
}
if(SetupDiGetDeviceRegistryProperty(hDevInfo,&spdd,SPDRP_DEVICEDESC,&dwType,(PBYTE)szProperty,sizeof(szProperty),NULL))
{
if(dwType == REG_SZ)
printf("DeviceDescription: %s\n\n", szProperty);
}
}
HeapFree(GetProcessHeap(), 0, pspdidd);
}
if((strstr(pspdidd->DevicePath, "hid#vid_03eb&pid_201c#6&1cdb5d6c&0&0000#{4d1e55b2-f16f-11cf-88cb-001111000030}")) != NULL)
break;
}
SetupDiDestroyDeviceInfoList(hDevInfo);
DeviceHandle = CreateFile(pspdidd->DevicePath,GENERIC_READ,FILE_SHARE_READ,(LPSECURITY_ATTRIBUTES)NULL,OPEN_EXISTING,0,NULL);
HidD_GetAttributes(DeviceHandle,&Attributes);
// printf("\nVendorID : %X",Attributes.VendorID);
// printf("\nProductID: %X",Attributes.ProductID);
// printf("\nVersion : %X",Attributes.VersionNumber);
HidD_GetPreparsedData(DeviceHandle,&PreparsedData);
HidP_GetCaps(PreparsedData,&Capabilities);
return(0);
}
gruß