Aldaviva / PowerMate

🎛 Receive events and control the light on a Griffin PowerMate USB device
https://www.nuget.org/packages/PowerMate/
Apache License 2.0
6 stars 0 forks source link

DeviceException #5

Closed tobster-de closed 5 months ago

tobster-de commented 7 months ago

I wanted to revive my mate and found your project. I'm not sure if I'm doing something wrong here, but just executing the PowerMateVolume project or the unit test for the constructor produces the following:

HidSharp.Exceptions.DeviceIOException: Unable to open HID class device (\\?\hid#vid_077d&pid_0410#7&68a7320&0&0000#{4d1e55b2-f16f-11cf-88cb-001111000030}).
   at HidSharp.Platform.Windows.WinHidStream.Init(String path)
   at HidSharp.Platform.Windows.WinHidDevice.OpenDeviceDirectly(OpenConfiguration openConfig)
   at HidSharp.Device.OpenDeviceAndRestrictAccess(OpenConfiguration openConfig)
   at HidSharp.Device.Open(OpenConfiguration openConfig)
   at HidSharp.Device.Open()
   at HidSharp.HidDevice.Open()
   at HidClient.AbstractHidClient.AttachToDevice()
   at HidClient.AbstractHidClient..ctor(DeviceList deviceList)
   at HidClient.AbstractHidClient..ctor()
   at PowerMate.PowerMateClient..ctor() in C:\dev\Privat\PowerMate\PowerMate\PowerMateClient.cs:line 30
   at Program.<Main>$(String[] args) in C:\dev\Privat\PowerMate\PowerMateVolume\PowerMateVolume.cs:line 10

The device should be there:

image

Do you have any hint, what's going on?

tobster-de commented 7 months ago

image

Aldaviva commented 7 months ago

One thing I noticed is that my PowerMate appears as a "HID-compliant consumer control device" underneath a "USB Input Device" instead of a "HID-compliant mouse." Mine also has a newer revision (0x400 instead of 0x109), although that may not matter.

Is is possible that another program, such as the official Griffin PowerMate software, is also running at the same time and preventing this program from opening the device? I'm not sure if these devices allow concurrent usage.

image

Aldaviva commented 7 months ago

The specific error here is triggered by CreateFileW in kernel32.dll returning -1. Sadly, HidSharp is not calling GetLastError to get more details about why it returned -1, although that may be possible with a breakpoint.

Aldaviva commented 7 months ago

You may also try installing and using the official Griffin PowerMate software just to ensure that your USB and PowerMate hardware are working OK. This requires .NET Framework 2/3/3.5, which you can install using optionalfeatures.exe:

image

Aldaviva commented 5 months ago

Feel free to reopen if there is new information.