2013-10-23 56 views
2

得到HID USB設備報告在我的Delphi應用程序,我使用TJvHidDevice寫和讀報告從USB設備。爲什麼我不能用GetInputReport

設備信息波紋管

Bus Type:  USB 
Device Type:  Human Interface Device 
Power Drawn:  100 milliamps @ 5.0 volts 
Endpoint 0:  Type=CTL Class=03 SubClass=00 Protocol=00 MaxPacket=8 
Endpoint 1 OUT: Type=INT Class=03 SubClass=00 Protocol=00 MaxPacket=40 
Endpoint 2 IN: Type=INT Class=03 SubClass=00 Protocol=00 MaxPacket=40 
Hardware ID:  USB\Vid_0483&Pid_5750&Rev_0200 
Data Read:  572 bytes 
Data Written: 384 bytes 
Utilization:  100% 

它有三個端點,它會出來把報告與端點2當我發送報告。 我的代碼是

報告結構

TReport = packed record 
    ReportID: byte; 
    Data: array[0..64] of byte; 
end; 

退房設備

procedure TfrmMain.HidDevsDeviceChange(Sender: TObject); 
begin 
    if HidDevs.CheckOutByID(FHidDev, USB_VID, USB_PID) then 
    begin 
     FHidDev.NumInputBuffers := 65; 
     FHidDev.NumOverlappedBuffers := 65; 
     FUsbDevice.Device := FHidDev; 
     FHidDev.OnData:=OnRead; 
    end; 
end; 

OnRead Enent

procedure TfrmMain.OnRead(HidDev: TJvHidDevice; ReportID: Byte; const Data: Pointer; Size: Word); 
var I: Integer; 
    Str: string; 
begin 
    Str := Format('RD %.2x ', [ReportID]); 
    for I := 0 to Size - 1 do 
     Str := Str + Format('%.2x ', [Cardinal(PChar(Data)[I])]); 
    AddLog('Received: '); 
    SetLogColor(clPurple); 
    AddLog(Str, False); 
end; 

我可以

if not FDevice.SetOutputReport(FBuffer, FDevice.Caps.OutputReportByteLength) then 

寫報告,但是,經過SetOutputReport沒有happens.If我用GetInputReport,而不是OnRead,會出現一個錯誤:31,如果使用READFILE,則應用程序將掛斷。 爲什麼,我該怎麼辦?

+1

如果添加適當的語言標籤(在這種情況下,'delphi')時,你的問題是特定於語言這是有幫助的。 –

+0

thanks.but誰能幫助我? –

回答

0

的問題已經解決。這是,發送到申請報告的大小是不正確的,它是小於InputReportByteLength 65,因此應用程序將不會收到任何東西。