Skip to content
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

Unable to Open Device (Works with 0.7.0) #107

Open
valleyman86 opened this issue Mar 7, 2013 · 5 comments
Open

Unable to Open Device (Works with 0.7.0) #107

valleyman86 opened this issue Mar 7, 2013 · 5 comments

Comments

@valleyman86
Copy link

I downloaded master and I am using Windows 8 currently. When I try to open a device the handle always returns 0xffff... from CreateFileA. I tried to download 0.7.0 and it seemed to open it properly. So I compared the code and tryed to modify open_device to be the same and that had no effect. It still failed on the newest build.

Any ideas?

@signal11
Copy link
Owner

signal11 commented Mar 8, 2013

Not sure what to say on this one. I don't have Windows 8. Can you do some debugging to find out what exactly the differences are? I'm surprised an old version works that way.

There's more to it than just open_device(), and the logic for that function (the parameters) have changed their logic since then (which is ok, since it's a static internal function).

This particular function has been a major pain, because it's seemed to behave differently with different devices and OS versions, not all of which I can test (because I don't have everyone's hardware).

See what arrangement of the flags seem to work for you, and we'll figure out how to proceed from here.

@valleyman86
Copy link
Author

I tried to figure out the differences but the main issue was that CreateFileA would return an invalid handle. The flags for setting that up are bit different for this call on the newer version. I tried changing these flags to use the same as the older one with the same results. The only thing that makes sense to me that this could happen is if there is some setup code for CreateFileA that is being setup differently.

At first I thought it was my USB hub causing the issue because virtually every USB lib I tried to use for both C or .NET failed to work properly. Then I tried 0.7.0 and it worked great! I was able to send commands to my USB hub and have it respond accordingly.

So can you suggest some other methods (setup prior to CreateFileA) that I can take a look at? I am not really that familiar with this code so it could take me a while to figure this out.

@signal11
Copy link
Owner

I did suggest some things. Try different flags passed to CreateFileA().

You have one version that works and one version that doesn't. It shouldn't be hard to trace hid_open() in a debugger and find out what's different.

Did you try with other HID devices, such as a joystick?

@signal11
Copy link
Owner

signal11 commented Sep 9, 2013

Any update?

@ts80
Copy link

ts80 commented Oct 14, 2013

Hi,

I had the same problem as the thread starter (using Win7). I also compared the open_device() function in hid.c of my working copy (master checked out some days ago) and release 0.7.0.
However, changing the flags worked fine for me. The configuration which is working for me is:

DWORD desired_access = GENERIC_WRITE | GENERIC_READ;
DWORD share_mode = FILE_SHARE_READ | FILE_SHARE_WRITE;

This corresponds to the configuration which is used in the error case of 0.7.0. As I just started using hid_api, I can not really judge these changes. How to proceed here?
If you need some additional info, just let me know...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants