signal11 / hidapi

A Simple library for communicating with USB and Bluetooth HID devices on Linux, Mac, and Windows.
http://www.signal11.us/oss/hidapi/
Other
2.46k stars 901 forks source link

Open/reopen device win 10 #389

Closed MrHazee closed 6 years ago

MrHazee commented 6 years ago

Hi there! First, thanks for this beautiful api. Great!!

But I have a couple of problems I just cant work out.

First, If I connect to my device (both physically and software-wise) and then unplug the USB cable, I get tons of messeges to the Console. In my native language Swedish, it looks like this: "Enheten ?r inte ansluten." "Enheten ?r inte ansluten." "Enheten ?r inte ansluten." ...times infinity..

... which translates to "The device is not connected". I´ve attached a hidDeviceDetached-listener but despite that I get about 50 error messages before i can stop it. It lies in the JNA so I have my hand tied up. Any suggestions how I can solv this matter?

Second, I think I´ve read all the post about open a device, close a device, and the open it again. But I cant get it right. No matter what, i get "Device has not been opened" the second time I try to open it. Right now it feels like an impossible task.. I would like to release the handle, like resetting the application, but only the hid-part of it. I havent changed FILE_SHARE_READ | FILE_SHARE_WRITE yet, is that inside the .dll?? I´ve tried both t not make new instances of hidServices and to make new when I re-connect.. When Im hit my disconnect buttom I´ve tried this; hidDevice.close. hidServices.shutdown HidApi.Exit But nothing seems to work... Hope anyone can help me on this, ripping my hair of here.. Thanks! /Rasmus

MrHazee commented 6 years ago

Commented on the wrong API !!! =) But feel free if you have any suggensstions.