-
Notifications
You must be signed in to change notification settings - Fork 69
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Missing HID InputReports #53
Comments
Hi, looking at the code I'm wondering if the ReadFile actually sometimes (in your case) returns true indicating that the read has completed in which case perhaps the GetOverlapped call should not be made ... I don't have time right now to investigate (and I don't have hardware that would cause this problem) but you might want to try to follow that thought. If you look at my PureJavaComm here you see that the control flow of the code is subtly different and does not do GetOverlapped if ReadFile returns true. |
I've tested, and the readfile sometime complete synchronously and fill Overlapped and byteread, but the getOverlappedResults give the same answer. The problem happens independently of Readfile synchronous or not (il fact it only happend for a async call) when I get successively getoverlappedResult. It is as if the overlapped was re-written asynchronously, like a shared memory. for application that abuse HID philosophy to exchange data it is tragic. My first hope is to detect block changing when GetOverlappedResult or not, and if a new block is overwritten, call back against, else continue with ReadFile. The snippet of purejavacomm will help me. |
I could make it work, but only by
Here is the patch, but there is tons of printf to remove: |
I was afraid the time inside the listener would make me lose some HID reports, but no... here is my trace:
I don't understand why the inputreport is updated instantly with the second report, but then that the third report wait patiently to be readFile and getOverlappedResult. note that the first report is read after a IO pending then getOverlappedResult, not after a synchronous ReadFile. I don't understand what is happening... Maybe we should ask to Windows programmers... I am not one of them. |
Hi, thanks for the patch but the raw file or pull request is much more usable. Patches don't fit well my workflow. |
Here it is, I've added comments and commented traces. It's crazy, I've just removed the print, and now the bug reappears (probably a timing problem). What corrected the bug was just a 1ms sleep in the loop, after the listener callback. I'll look on monday. anyway here is my situation. ( HidDevice.java.txt with the sleep 1ms I'll look if the solution is not to have a bigger buffer with many reports |
I've tested using bigger buffers (8 times the 64bytes of usual blocks), but there is no change (byteread is always 64+1). I've tested flooding the ledger, and finally the Thread.sleep(); sloud be >11ms ... I decided 20ms and it works. I've heard that depending on USB2 or 3, fast or not, minimum delay for reports is 1ms or 10ms... not sure it is related... here is the version that works now |
Hi,
I've succeeded in exchanging with a HId device (a Ledger nano S).
It worked well, but now on some long sequence of inputreport (3 reports), I miss on report.
all is in purejavahidapi.windows.HidDevice.runReadOnBackground()
I've investigated and I've discovered that the missing report is obtained if,
after the ReadFile()
and the GetOverlappedResult()
I do agains a GetOverlappedResult() which obtaine a different report, the 2nd block.
but if I read again, I always obtain the same second block.
If I do a ReadFile() (with or without a ResetEvent() ), I miss the 2nd report.
I've tried to set an event following this idea
https://groups.google.com/d/msg/comp.os.ms-windows.programmer.win32/YmmR3AP4iXU/dro42wfM5ZcJ
m_InputReportOverlapped.hEvent = CreateEvent(null, true, false, null);
but nothing change
if I do many GetOverlappedResult() even resetting the m_InputReportLength[0]=0;,
each time it says "m_InputReportLength=65" and read the same 2nd report...
with or without ResetEvent(m_InputReportOverlapped.hEvent), nothing change...
I don't know Win32 API, except few page on MSDN about the cited functions...
Do you have an idea... If it works, I will post the patch...
Too bad it was nearly working. I'm not far...
Best regards
The text was updated successfully, but these errors were encountered: