webbasan / HotasCtrl

A small command line tool to setup lighting and display on the Saitek/MadCatz X52/X52pro.
MIT License
15 stars 3 forks source link

USB Error 2 - invalid parameter org.usb4java.LibUsbException #1

Open michaelrshannon opened 9 years ago

michaelrshannon commented 9 years ago

Firstly, love what you're going for here - been struggling to find anything online on how to interface with the X52 Pro since the Saitek forums went down.

I had a quick look through the source, but I'm not familiar enough with developing jar packages to be able to easily see what's going wrong here.

After running java -jar HotasCtrl.jar light all on led all on, I get the following response

Set MFD with brightness 128
Error: USB error 2: setBrightness failed: Invalid parameter org.usb4java.LibUsbException: USB error 2: setBrightness failed: Invalid parameter
        at de.mundito.hid.SaitekX52Pro.setBrightness(SaitekX52Pro.java:239)
        at de.mundito.hid.HotasX52Impl.setBrightness(HotasX52Impl.java:75)
        at de.mundito.hid.HotasX52Impl.setBrightness(HotasX52Impl.java:37)
        at de.mundito.hid.SetupLight.setup(SetupLight.java:19)
        at de.mundito.app.HotasCtrl.doIt(HotasCtrl.java:35)
        at de.mundito.app.HotasCtrl.main(HotasCtrl.java:59)

Environment

OS: Windows 8.1 x64 Device: Saitek x52 Pro Driver Version: 7.0.34.109 Software Version (reported from Windows joystick properties): 7.0.27.13


Let me know if I can provide any other info that would help identifying the issue!

webbasan commented 9 years ago

Hmm, interesting - I had tested it only on OS X, but the Windows stuff is also in the JAR, so I hoped it will work...

The exception comes deep from the USB stuff, so I have to check that further. The brightness is controlled by the light parameter, so does it work when you omit it and just set the LEDs? Like:

java -jar HotasCtrl.jar led all on

regards, webbasan.

2015-05-16 14:11 GMT+02:00 Michael Shannon notifications@github.com:

Firstly, love what you're going for here - been struggling to find anything online on how to interface with the X52 Pro since the Saitek forums went down.

I had a quick look through the source, but I'm not familiar enough with developing jar packages to be able to easily see what's going wrong here.

After running java -jar HotasCtrl.jar light all on led all on, I get the following response

Set MFD with brightness 128 Error: USB error 2: setBrightness failed: Invalid parameter org.usb4java.LibUsbException: USB error 2: setBrightness failed: Invalid parameter at de.mundito.hid.SaitekX52Pro.setBrightness(SaitekX52Pro.java:239) at de.mundito.hid.HotasX52Impl.setBrightness(HotasX52Impl.java:75) at de.mundito.hid.HotasX52Impl.setBrightness(HotasX52Impl.java:37) at de.mundito.hid.SetupLight.setup(SetupLight.java:19) at de.mundito.app.HotasCtrl.doIt(HotasCtrl.java:35) at de.mundito.app.HotasCtrl.main(HotasCtrl.java:59)


Environment

OS: Windows 8.1 x64 Device: Saitek x52 Pro Driver Version: 7.0.34.109

Software Version (reported from Windows joystick properties): 7.0.27.13

Let me know if I can provide any other info that would help identifying the issue!

— Reply to this email directly or view it on GitHub https://github.com/webbasan/HotasCtrl/issues/1.

webbasan commented 9 years ago

Another thought: "invalid parameter" could mean that the Windows driver checks and accepts only certain values for the brightness (I discovered some "useful" values through try-and-error on OS X), so you may also try if one of these work:

java -jar HotasCtrl.jar light all dark java -jar HotasCtrl.jar light all half

or try to set lighting for MFD and LEDs individually:

java -jar HotasCtrl.jar light mfd half java -jar HotasCtrl.jar light led half

This also may give hints what exactly is considered "invalid"...

So far for now, I'm now away from the keyboard, but I may be I can look into it later this day.

regards, webbasan

2015-05-16 14:47 GMT+02:00 Horst Weber webbasan@gmail.com:

Hmm, interesting - I had tested it only on OS X, but the Windows stuff is also in the JAR, so I hoped it will work...

The exception comes deep from the USB stuff, so I have to check that further. The brightness is controlled by the light parameter, so does it work when you omit it and just set the LEDs? Like:

java -jar HotasCtrl.jar led all on

regards, webbasan.

2015-05-16 14:11 GMT+02:00 Michael Shannon notifications@github.com:

Firstly, love what you're going for here - been struggling to find anything online on how to interface with the X52 Pro since the Saitek forums went down.

I had a quick look through the source, but I'm not familiar enough with developing jar packages to be able to easily see what's going wrong here.

After running java -jar HotasCtrl.jar light all on led all on, I get the following response

Set MFD with brightness 128 Error: USB error 2: setBrightness failed: Invalid parameter org.usb4java.LibUsbException: USB error 2: setBrightness failed: Invalid parameter at de.mundito.hid.SaitekX52Pro.setBrightness(SaitekX52Pro.java:239) at de.mundito.hid.HotasX52Impl.setBrightness(HotasX52Impl.java:75) at de.mundito.hid.HotasX52Impl.setBrightness(HotasX52Impl.java:37) at de.mundito.hid.SetupLight.setup(SetupLight.java:19) at de.mundito.app.HotasCtrl.doIt(HotasCtrl.java:35) at de.mundito.app.HotasCtrl.main(HotasCtrl.java:59)


Environment

OS: Windows 8.1 x64 Device: Saitek x52 Pro Driver Version: 7.0.34.109

Software Version (reported from Windows joystick properties): 7.0.27.13

Let me know if I can provide any other info that would help identifying the issue!

— Reply to this email directly or view it on GitHub https://github.com/webbasan/HotasCtrl/issues/1.

michaelrshannon commented 9 years ago

Ok, some more errors:

$ java -jar HotasCtrl.jar led all on
Set LED FIRE to color ON
Error: USB error 2: setLED failed: Invalid parameter
org.usb4java.LibUsbException: USB error 2: setLED failed: Invalid parameter
        at de.mundito.hid.SaitekX52Pro.setLED(SaitekX52Pro.java:248)
        at de.mundito.hid.HotasX52Impl.setLedColor(HotasX52Impl.java:81)
        at de.mundito.hid.HotasX52Impl.setLedColor(HotasX52Impl.java:47)
        at de.mundito.hid.SetupLed.setup(SetupLed.java:19)
        at de.mundito.app.HotasCtrl.doIt(HotasCtrl.java:35)
        at de.mundito.app.HotasCtrl.main(HotasCtrl.java:59)
$ java -jar HotasCtrl.jar light all dark
Set MFD with brightness 4
Error: USB error 2: setBrightness failed: Invalid parameter
org.usb4java.LibUsbException: USB error 2: setBrightness failed: Invalid parameter
        at de.mundito.hid.SaitekX52Pro.setBrightness(SaitekX52Pro.java:239)
        at de.mundito.hid.HotasX52Impl.setBrightness(HotasX52Impl.java:75)
        at de.mundito.hid.HotasX52Impl.setBrightness(HotasX52Impl.java:37)
        at de.mundito.hid.SetupLight.setup(SetupLight.java:19)
        at de.mundito.app.HotasCtrl.doIt(HotasCtrl.java:35)
        at de.mundito.app.HotasCtrl.main(HotasCtrl.java:59)

...and so on - all the suggested arguments return the same error - hope that helps!

webbasan commented 9 years ago

I have tried it now myself and seen it... ;-)

Took a while to set it up all in my Bootcamp environment... Looks like the USB4Java library does something different on Windows. At least it seems that it's not a Java7 vs Java8 issue, or related to 32 bit vs. 64 bit - I get this error with every version.

I will try to get it running, but it looks like it will take some time...

Kind regards, webbasan

2015-05-16 20:19 GMT+02:00 Michael Shannon notifications@github.com:

Ok, some more errors:

$ java -jar HotasCtrl.jar led all on Set LED FIRE to color ON Error: USB error 2: setLED failed: Invalid parameter org.usb4java.LibUsbException: USB error 2: setLED failed: Invalid parameter at de.mundito.hid.SaitekX52Pro.setLED(SaitekX52Pro.java:248) at de.mundito.hid.HotasX52Impl.setLedColor(HotasX52Impl.java:81) at de.mundito.hid.HotasX52Impl.setLedColor(HotasX52Impl.java:47) at de.mundito.hid.SetupLed.setup(SetupLed.java:19) at de.mundito.app.HotasCtrl.doIt(HotasCtrl.java:35) at de.mundito.app.HotasCtrl.main(HotasCtrl.java:59)

$ java -jar HotasCtrl.jar light all dark Set MFD with brightness 4 Error: USB error 2: setBrightness failed: Invalid parameter org.usb4java.LibUsbException: USB error 2: setBrightness failed: Invalid parameter at de.mundito.hid.SaitekX52Pro.setBrightness(SaitekX52Pro.java:239) at de.mundito.hid.HotasX52Impl.setBrightness(HotasX52Impl.java:75) at de.mundito.hid.HotasX52Impl.setBrightness(HotasX52Impl.java:37) at de.mundito.hid.SetupLight.setup(SetupLight.java:19) at de.mundito.app.HotasCtrl.doIt(HotasCtrl.java:35) at de.mundito.app.HotasCtrl.main(HotasCtrl.java:59)

...and so on - all the suggested arguments return the same error - hope that helps!

— Reply to this email directly or view it on GitHub https://github.com/webbasan/HotasCtrl/issues/1#issuecomment-102663082.

michaelrshannon commented 9 years ago

Awesome - glad you've been able to reproduce it - let me know if I can do anything else to help on my end!

webbasan commented 9 years ago

Just a little update for this issue:

I've read some of the available documentation which is related to USB4Java and USB handling on Windows. It seems, that it gets rather complicated to handle it - as far as I understand it, Windows requires a special USB driver to get this working. I got lost when I tried to install the package and it failed. Makes me wonder if it could work togther with the Saitek USB driver anyway...

To dig deeper into this issue I have to setup a VM with at least Windows 7 - rebooting into Bootcamp for this gets to troublesome for me. My current Windows VMs are based on XP - and it's said that there were significant changes to the relevant USB API, so they are useless for this issue.

So I have to postpone the work on this issue a bit further. I will get back to it, because I would like to see this application working on Windows also: I hope it will prove to be useful for Star Citizen also... ;-)

rkagerer commented 9 years ago

This may not be helpful, but I get the same issues in Windows. Would love for this to work, as the brightness slider in the default control panel no longer seems to work for me.

erkswede commented 7 years ago

Did you ever get this working under windows? I have the same issue and I'm planning on using this for a X-Plane plugin and it would be great to have it platform independent. Thanks!

rkagerer commented 7 years ago

I don't think so. I can't recall if I worked around, or just gave up.

webbasan commented 7 years ago

Sorry to say so, but I didn't had the time to investigate that further - I would really appreciate some help from somebody who is able to investigate that further or could provide some insight.

It seems to me that this is not an issue with USB4Java in the first place but the underlying usblib. On Windows, it requires some additional support from specific drivers (which you have to install separately - and I had trouble trying that) and I'm not even sure if that's enough: the documentation just mentions HIDevices, but the interesting part would be to send commands to the stick to set up the lights etc., not just reading the button presses like for any other ordinary HID.

So I assume that Saitek provided some driver extension which is out of reach of the more generic approach of usblib and that may be the root cause of the problem.