readfile()和GetOverlappedResult()返回lpNumberOfBytesTransferred lenght问题。 [英] readfile() and GetOverlappedResult() return lpNumberOfBytesTransferred lenght problem.
问题描述
我有一个问题
我宣布了一个USB HID设备,HID报告如下:
使用页面(供应商定义1)06 00 FF
使用(供应商定义2)09 02
集合(应用)A1 01
逻辑最小值(0)15 00
逻辑最大值(255)26 FF 00
报表大小(8)75 08
报告ID( 1)85 01
报告数量(7)95 07
用法(供应商定义2)09 02
输入(数据,Var, Abs,NWrp,Lin,Pref,NNul,Bit)81 02
用法(供应商定义2)09 02
输出(数据,Var,Abs,NWrp,Lin ,Pref,NNul,NVol,Bit)91 02
报告ID(2)85 02
报告数(63)95 3F
用法(供应商定义2)09 02
输入(数据,Var,Abs,NWrp,Lin,Pref,NNul,Bit)81 02
用法(供应商定义2) )09 02
输出(数据,Var,Abs,NWrp,Lin,Pref,NNul,NVol,Bit)91 02
En d Collection C0
USB HID设备成功向PC发送8字节数据。 (01 35 00 00 00 00 00 00)
HidP_GetCaps(pPreData,& cap)get cap.InputReportByteLength = 64
部分源代码:
I have a question
I declared a USB HID DEVICE, HID report as follows:
Usage Page (Vendor-Defined 1) 06 00 FF
Usage (Vendor-Defined 2) 09 02
Collection (Application) A1 01
Logical Minimum (0) 15 00
Logical Maximum (255) 26 FF 00
Report Size (8) 75 08
Report ID (1) 85 01
Report Count (7) 95 07
Usage (Vendor-Defined 2) 09 02
Input (Data,Var,Abs,NWrp,Lin,Pref,NNul,Bit) 81 02
Usage (Vendor-Defined 2) 09 02
Output (Data,Var,Abs,NWrp,Lin,Pref,NNul,NVol,Bit) 91 02
Report ID (2) 85 02
Report Count (63) 95 3F
Usage (Vendor-Defined 2) 09 02
Input (Data,Var,Abs,NWrp,Lin,Pref,NNul,Bit) 81 02
Usage (Vendor-Defined 2) 09 02
Output (Data,Var,Abs,NWrp,Lin,Pref,NNul,NVol,Bit) 91 02
End Collection C0
USB HID device success send 8 bytes data to pc. (01 35 00 00 00 00 00 00)
HidP_GetCaps(pPreData, &cap) get cap.InputReportByteLength = 64
Part of the source code:
{
memset(ReadReportBuffer, 0, sizeof(ReadReportBuffer));
ReadFile(m_hReadHandle,
ReadReportBuffer,
64,
NULL,
&ReadOverlapped);
}
dObject = WaitForMultipleObjects(2, hArray, FALSE, INFINITE);
if (dObject == WAIT_OBJECT_0)
{
if (!MyDevFound)//Device extract also set the event
{
continue;
}
GetOverlappedResult(m_hReadHandle,
&ReadOverlapped,
&nBytesRead,
TRUE);//you can also set the last parameter False
if (nBytesRead != 0)
{
m_strTemp = ReadReportBuffer;
m_strLog.Format(_T("Read the Report Data Length is %d.(%02d:%02d:%02d)"),
nBytesRead, sysTime.wHour, sysTime.wMinute, sysTime.wSecond);
m_strLog += m_strTemp;
Display_Info::SendEvent(m_strLog);
//Display Receive Data
pDlg->DisplayDataHex(ReadReportBuffer, nBytesRead);
}
为什么nBytesRead值= 64?
why nBytesRead value = 64?
推荐答案
为什么不应该呢?您要求64个字节,它读取64个字节......
Why shouldn't it? You asked for 64 bytes and it read 64 bytes...
这篇关于readfile()和GetOverlappedResult()返回lpNumberOfBytesTransferred lenght问题。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!