I still have the ReadFile hang. I have tried to narrow down my error for days now, but no luck. Maybe someone can see some fundemental error in my work.
I have verified on the bus that I am actually seeing 2 bytes of data. The Host is sending an ACK in response.
The report descriptor declares 2 bytes (16 x 1bit) for the input report.
The Get_Report is working via HIDD_GetInputReport
My WriteFile is working.
I have used CreateFile for Synchronous access.
I use the InputReportByteLength member of the Attributes structure to set the report size (3 in my case).
I have set the polling rate to 1ms to make sure there is no chance of a delay in filling the buffer, and the bus analyser sees a packet every ms as expected.
I could try to use asynchronous access, but that would just mean my program wouldn't hang, but if I would still never see a report if they are being dropped by the driver.
db 0x06, 0x00, 0xFF ;USAGE_PAGE (Vendor Defined Page 1)
db 0x09, 0x01 ;USAGE (I/O Device)
db 0xA1, 0x01 ;COLLECTION (Physical)
db 0x19, 0x01 ; Usage_Minimum (Button 1)
db 0x29, 0x08 ; Usage_Maximum (Button 8)
db 0x15, 0x00 ; Logical_Minimum (0)
db 0x25, 0x01 ; Logical_Maximum (1)
db 0x75, 0x01 ; Report_Size (1)- 1 bit report size
db 0x95, 0x10 ; Report_Count (16) - 16 x 1 bit reports (2 bytes in total)
db 0x81, 0x02 ; Input (Data,Var,Abs)
db 0x19, 0x01 ; Usage_Minimum (Led 1)
db 0x29, 0x08 ; Usage_Maximum (Led 8)
db 0x95, 0x08 ; Report Size (8) - 8 x 1 bit reports (1 byte in total)
db 0x91, 0x02 ; Output (Data,Var,Abs)
db 0xC0 ;END_COLLECTION
CreateFile() - the Handle returned works for the WriteFile, HIDD_GetInputReport and HIDD_SetOutputReport
m_DeviceHandle = CreateFile(pDeviceInterfaceDetailData->DevicePath,
GENERIC_READ | GENERIC_WRITE,
FILE_SHARE_READ | FILE_SHARE_WRITE ,
Call to the member function and initial buffer declarations
CHIDDevice a(0x4242,0x0001, 0x0100);
BYTE* pInbuf = new BYTE[a.GetDevCaps().InputReportByteLength];
a.GetData(pInbuf, 0, true);
Member Function Getdata() that calls ReadFile()
int CHIDDevice::GetData(BYTE* pBuffer, BYTE rptID, bool Interrupt)
DWORD BytesRead = 0;
if (!pBuffer) return CHIDDeviceError_BufferError;
pBuffer = rptID;
if (!m_DeviceHandle) return CHIDDeviceError_NoDevice;
I am at a loss.