Skip to content

Navigation Menu

Sign in
Sign up

Fix HID read/write issue on Windows - #11

Open
mdiea wants to merge 1 commit into
ljakob:main from
mdiea:main
Open

Fix HID read/write issue on Windows #11
mdiea wants to merge 1 commit into
ljakob:main from
mdiea:main

Conversation

@mdiea

@mdiea mdiea commented Mar 10, 2025

Copy link
Copy Markdown

Dear ljakob,

First of all, thank you for your work on this repo. Your implementation has been extremely useful, and I truly appreciate the effort you've put into it.

While using unit_ut61eplus on Windows 10, I encountered an issue where:

  • The read() function blocks indefinitely, preventing further execution.

After investigating, I found that this behavior is caused by how HIDAPI handles Report IDs on Windows:

  1. Windows expects a Report ID as the first byte. If it's missing, hid_write() pads the buffer to 65 bytes, leading to incorrect return values.
  2. hid_read() is blocking by default in Windows, meaning it waits indefinitely if no data is available.

Proposed Solution:

  • Ensure a Report ID is always present before calling write() on Windows by prepending 0x00 if needed.
  • Enable non-blocking mode for read() to prevent infinite waits, and introduce a timeout to avoid unnecessary delays.

I have implemented and tested these fixes, and they resolve the issue without affecting functionality on Linux.

You will see that I also changed the variables CP2110_VID and CP2110_PID, as this is how my USB is numbered.

Thanks again for your work! 🚀

Best regards,

BaalNetbek reacted with thumbs up emoji
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

1 participant

AltStyle によって変換されたページ (->オリジナル) /