In my delphi application, i use TJvHidDevice for writing and reading report from a usb device.
The device info bellows
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%
It has three endpoints,and it will out put report with endpoint 2 when i send report to it. My codes are
Report structure
TReport = packed record
ReportID: byte;
Data: array[0..64] of byte;
end;
Check out Device
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;
I can write report by
if not FDevice.SetOutputReport(FBuffer, FDevice.Caps.OutputReportByteLength) then
but , after SetOutputReport nothing happens.If i used GetInputReport instead of OnRead, there will be an error : 31 , if use readFile,the application will hang up. why,and what should i do?
delphi
) when your question is specific to that language. – Ken White