-
-
Notifications
You must be signed in to change notification settings - Fork 120
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
HidDevice.ReadAsync failed on .NET 6 #225
Comments
I've been meaning to do this for quite a while. This is the solution: Usage will be something like this:
|
Any update on this? I get a similar error when trying to use WriteAndReadAsync on .Net 6.0 The parameter is incorrect. at Hid.Net.HidDevice.d__20.MoveNext() in //src/Hid.Net/HidDevice.cs:line 139 |
Same here. First try to write to my HID Device and ran into this error.
Working on a sample project who talks to my HID Device with nuget Package 4.3.0-beta Platform: Windows 10 Actually I'm not able to compile develop branch with my Visual Studio Version (2022) because net45 is not supported anymore |
4.3.0 is more like the stable version. |
Actually I was able to figure out what is the problem on my code. From the TrezorExample.cs
But after changing the writebuffer from 64 to 65 everything was fine and i was able to send the message and to display the answer. I took the size of the writebuffer from TrezorExample.cs Size 65 is stated everywhere as hid report message size = 64 +1 byte for startbyte. |
Hello, I am facing the same issue while writing to the hid device, "An error occurred while attempting to write to the device" | false parameter. Even if i change the byte[] size to 64 or 65, nothing seems to work. I'm using 4.3.0 beta version and i'm using the following code.
|
Describe the issue
IOException occurred when
HidDevice.ReadAsync
on TFM .NET 6Could be related with #224
Your Code
Info
Avoid this issue on .NET 6
Option 1: specify an AppContext switch or an environment variable
https://docs.microsoft.com/en-us/dotnet/core/compatibility/core-libraries/6.0/filestream-position-updates-after-readasync-writeasync-completion#recommended-action
Follow this link for how to do. also i think this related with issue
But this could be effect to app performance..
Option 2: Use Read() than ReadAsync() in WindowsHidHandler.ReadReportAsync
Device.Net/src/Hid.Net/Windows/WindowsHidHandler.cs
Lines 165 to 183 in 5524cda
Option 3: FILE_FLAG_OVERLAPPED 0 in kernel32.CreateFile() on .NET 6
Device.Net/src/Device.Net/Windows/ApiService.cs
Lines 14 to 20 in 5524cda
Same approach as #223
but need to runtime check because preprocessor could not solve
.net6(app) -> .netstandard2.0(user library) -> Hid.Net
.I will make PR soon by option 3
The text was updated successfully, but these errors were encountered: