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

[BUG] hid_send_feature_report error on Gentoo Linux #90

Closed
CyberGuerro opened this issue Mar 15, 2024 · 58 comments · Fixed by #94 or #98
Closed

[BUG] hid_send_feature_report error on Gentoo Linux #90

CyberGuerro opened this issue Mar 15, 2024 · 58 comments · Fixed by #94 or #98
Assignees
Labels
bug Something isn't working

Comments

@CyberGuerro
Copy link

Describe the bug
With attached xpanel.ini and Saitek Radio Panel connected to USB, plugin crash and x-plane with it

To Reproduce
Steps to reproduce the behavior like this:

  1. Attach saitek device
  2. Run X-Plane12 and select aircraft (ZIBO 4.01.9)
  3. Start flight
  4. X-Plane crash

Expected behavior
Flight start

** X-Plane log file **
Log.txt

xpanel.ini content:

; Aircraft specific handler for Zibo 737 XPlane aircraft
log_level="DEBUG"
aircraft_acf="b738_4k.acf"

;---------------------- Saitek Radio Panel -------------------------
[device:id="saitek_radio"]
vid="6a3"
pid="d05"

[multi_display:id="RADIO_DISPLAY_ACTIVE_UP"]
line="on_select:SW_UP_COM1,dataref:sim/cockpit/radios/com1_freq_hz"
line="on_select:SW_UP_COM2,dataref:sim/cockpit/radios/com2_freq_hz"
line="on_select:SW_UP_NAV1,dataref:sim/cockpit/radios/nav1_freq_hz"
line="on_select:SW_UP_NAV2,dataref:sim/cockpit/radios/nav2_freq_hz"
line="on_select:SW_UP_ADF,dataref:sim/cockpit/radios/adf1_freq_hz"
line="on_select:SW_UP_IDT,dataref:sim/cockpit/radios/transponder_code"

[multi_display:id="RADIO_DISPLAY_STBY_UP"]
line="on_select:SW_UP_COM1,dataref:sim/cockpit/radios/com1_stdby_freq_hz"
line="on_select:SW_UP_COM2,dataref:sim/cockpit/radios/com2_stdby_freq_hz"
line="on_select:SW_UP_NAV1,dataref:sim/cockpit/radios/nav1_stdby_freq_hz"
line="on_select:SW_UP_NAV2,dataref:sim/cockpit/radios/nav2_stdby_freq_hz"
line="on_select:SW_UP_ADF,dataref:sim/cockpit/radios/adf1_stdby_freq_hz"

[button:id="KNOB_UP_BIG_PLUS"]
on_push="on_select:SW_UP_COM1,dataref:sim/cockpit/radios/com1_stdby_freq_hz:100:0:15000"
on_push="on_select:SW_UP_COM2,dataref:sim/cockpit/radios/com2_stdby_freq_hz:100:0:15000"
on_push="on_select:SW_UP_NAV1,dataref:sim/cockpit/radios/nav1_stdby_freq_hz:100:0:15000"
on_push="on_select:SW_UP_NAV2,dataref:sim/cockpit/radios/nav2_stdby_freq_hz:100:0:15000"
on_push="on_select:SW_UP_ADF,dataref:sim/cockpit/radios/adf1_stdby_freq_hz:100:0:359"
on_push="on_select:SW_UP_IDT,dataref:sim/cockpit/radios/transponder_code:100:0:8888"

[button:id="KNOB_UP_BIG_MINUS"]
on_push="on_select:SW_UP_COM1,dataref:sim/cockpit/radios/com1_stdby_freq_hz:-100:0:16000"
on_push="on_select:SW_UP_COM2,dataref:sim/cockpit/radios/com2_stdby_freq_hz:-100:0:16000"
on_push="on_select:SW_UP_NAV1,dataref:sim/cockpit/radios/nav1_stdby_freq_hz:-100:0:16000"
on_push="on_select:SW_UP_NAV2,dataref:sim/cockpit/radios/nav2_stdby_freq_hz:-100:0:16000"
on_push="on_select:SW_UP_ADF,dataref:sim/cockpit/radios/adf1_stdby_freq_hz:-100:0:359"
on_push="on_select:SW_UP_IDT,dataref:sim/cockpit2/radios/actuators/transponder_code:-100:0:8888"

[button:id="KNOB_UP_SMALL_PLUS"]
on_push="on_select:SW_UP_COM1,dataref:sim/cockpit/radios/com1_stdby_freq_hz:5:0:15000"
on_push="on_select:SW_UP_COM2,dataref:sim/cockpit/radios/com2_stdby_freq_hz:5:0:15000"
on_push="on_select:SW_UP_NAV1,dataref:sim/cockpit/radios/nav1_stdby_freq_hz:1:0:15000"
on_push="on_select:SW_UP_NAV2,dataref:sim/cockpit/radios/nav2_stdby_freq_hz:1:0:15000"
on_push="on_select:SW_UP_ADF,dataref:sim/cockpit/radios/adf1_stdby_freq_hz:1:0:359"
on_push="on_select:SW_UP_IDT,dataref:sim/cockpit/radios/transponder_code:1:0:8888"

[button:id="KNOB_UP_SMALL_MINUS"]
on_push="on_select:SW_UP_COM1,dataref:sim/cockpit/radios/com1_stdby_freq_hz:-5:0:16000"
on_push="on_select:SW_UP_COM2,dataref:sim/cockpit/radios/com2_stdby_freq_hz:-5:0:16000"
on_push="on_select:SW_UP_NAV1,dataref:sim/cockpit/radios/nav1_stdby_freq_hz:-1:0:16000"
on_push="on_select:SW_UP_NAV2,dataref:sim/cockpit/radios/nav2_stdby_freq_hz:-1:0:16000"
on_push="on_select:SW_UP_ADF,dataref:sim/cockpit/radios/adf1_stdby_freq_hz:-1:0:359"
on_push="on_select:SW_UP_IDT,dataref:sim/cockpit2/radios/actuators/transponder_code:-1:0:8888"

[button:id="ACT_STBY_UP"]
on_push="on_select:SW_UP_COM1,commandref:sim/radios/com1_standy_flip:once"
on_push="on_select:SW_UP_COM2,commandref:sim/radios/com2_standy_flip:once"
on_push="on_select:SW_UP_NAV1,commandref:sim/radios/nav1_standy_flip:once"
on_push="on_select:SW_UP_NAV2,commandref:sim/radios/nav2_standy_flip:once"
on_push="on_select:SW_UP_ADF,commandref:sim/radios/adf1_standy_flip:once"



[multi_display:id="RADIO_DISPLAY_ACTIVE_DOWN"]
line="on_select:SW_DOWN_COM1,dataref:sim/cockpit/radios/com1_freq_hz"
line="on_select:SW_DOWN_COM2,dataref:sim/cockpit/radios/com2_freq_hz"
line="on_select:SW_DOWN_NAV1,dataref:sim/cockpit/radios/nav1_freq_hz"
line="on_select:SW_DOWN_NAV2,dataref:sim/cockpit/radios/nav2_freq_hz"
line="on_select:SW_DOWN_ADF,dataref:sim/cockpit/radios/adf1_freq_hz"
line="on_select:SW_DOWN_IDT,dataref:sim/cockpit/radios/transponder_code"

[multi_display:id="RADIO_DISPLAY_STBY_DOWN"]
line="on_select:SW_DOWN_COM1,dataref:sim/cockpit/radios/com1_stdby_freq_hz"
line="on_select:SW_DOWN_COM2,dataref:sim/cockpit/radios/com2_stdby_freq_hz"
line="on_select:SW_DOWN_NAV1,dataref:sim/cockpit/radios/nav1_stdby_freq_hz"
line="on_select:SW_DOWN_NAV2,dataref:sim/cockpit/radios/nav2_stdby_freq_hz"
line="on_select:SW_DOWN_ADF,dataref:sim/cockpit/radios/adf1_stdby_freq_hz"

[button:id="KNOB_DOWN_BIG_PLUS"]
on_push="on_select:SW_DOWN_COM1,dataref:sim/cockpit/radios/com1_stdby_freq_hz:100:0:15000"
on_push="on_select:SW_DOWN_COM2,dataref:sim/cockpit/radios/com2_stdby_freq_hz:100:0:15000"
on_push="on_select:SW_DOWN_NAV1,dataref:sim/cockpit/radios/nav1_stdby_freq_hz:100:0:15000"
on_push="on_select:SW_DOWN_NAV2,dataref:sim/cockpit/radios/nav2_stdby_freq_hz:100:0:15000"
on_push="on_select:SW_DOWN_ADF,dataref:sim/cockpit/radios/adf1_stdby_freq_hz:100:0:359"
on_push="on_select:SW_DOWN_IDT,dataref:sim/cockpit/radios/transponder_code:100:0:8888"

[button:id="KNOB_DOWN_BIG_MINUS"]
on_push="on_select:SW_DOWN_COM1,dataref:sim/cockpit/radios/com1_stdby_freq_hz:-100:0:16000"
on_push="on_select:SW_DOWN_COM2,dataref:sim/cockpit/radios/com2_stdby_freq_hz:-100:0:16000"
on_push="on_select:SW_DOWN_NAV1,dataref:sim/cockpit/radios/nav1_stdby_freq_hz:-100:0:16000"
on_push="on_select:SW_DOWN_NAV2,dataref:sim/cockpit/radios/nav2_stdby_freq_hz:-100:0:16000"
on_push="on_select:SW_DOWN_ADF,dataref:sim/cockpit/radios/adf1_stdby_freq_hz:-100:0:359"
on_push="on_select:SW_DOWN_IDT,dataref:sim/cockpit2/radios/actuators/transponder_code:-100:0:8888"

[button:id="KNOB_DOWN_SMALL_PLUS"]
on_push="on_select:SW_DOWN_COM1,dataref:sim/cockpit/radios/com1_stdby_freq_hz:5:0:15000"
on_push="on_select:SW_DOWN_COM2,dataref:sim/cockpit/radios/com2_stdby_freq_hz:5:0:15000"
on_push="on_select:SW_DOWN_NAV1,dataref:sim/cockpit/radios/nav1_stdby_freq_hz:1:0:15000"
on_push="on_select:SW_DOWN_NAV2,dataref:sim/cockpit/radios/nav2_stdby_freq_hz:1:0:15000"
on_push="on_select:SW_DOWN_ADF,dataref:sim/cockpit/radios/adf1_stdby_freq_hz:1:0:359"
on_push="on_select:SW_DOWN_IDT,dataref:sim/cockpit/radios/transponder_code:1:0:8888"

[button:id="KNOB_DOWN_SMALL_MINUS"]
on_push="on_select:SW_DOWN_COM1,dataref:sim/cockpit/radios/com1_stdby_freq_hz:-5:0:16000"
on_push="on_select:SW_DOWN_COM2,dataref:sim/cockpit/radios/com2_stdby_freq_hz:-5:0:16000"
on_push="on_select:SW_DOWN_NAV1,dataref:sim/cockpit/radios/nav1_stdby_freq_hz:-1:0:16000"
on_push="on_select:SW_DOWN_NAV2,dataref:sim/cockpit/radios/nav2_stdby_freq_hz:-1:0:16000"
on_push="on_select:SW_DOWN_ADF,dataref:sim/cockpit/radios/adf1_stdby_freq_hz:-1:0:359"
on_push="on_select:SW_DOWN_IDT,dataref:sim/cockpit2/radios/actuators/transponder_code:-1:0:8888"

[button:id="ACT_STBY_DOWN"]
on_push="on_select:SW_DOWN_COM1,commandref:sim/radios/com1_standy_flip:once"
on_push="on_select:SW_DOWN_COM2,commandref:sim/radios/com2_standy_flip:once"
on_push="on_select:SW_DOWN_NAV1,commandref:sim/radios/nav1_standy_flip:once"
on_push="on_select:SW_DOWN_NAV2,commandref:sim/radios/nav2_standy_flip:once"
on_push="on_select:SW_DOWN_ADF,commandref:sim/radios/adf1_standy_flip:once"

List of usb devices connected before run X-Plane12

Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 001 Device 002: ID 1462:7d25 Micro Star International MYSTIC LIGHT 
Bus 001 Device 003: ID 05e3:0608 Genesys Logic, Inc. Hub
Bus 001 Device 006: ID 05e3:0608 Genesys Logic, Inc. Hub
Bus 001 Device 009: ID 051d:0002 American Power Conversion Uninterruptible Power Supply
Bus 001 Device 010: ID 058f:6364 Alcor Micro Corp. AU6477 Card Reader Controller
Bus 001 Device 033: ID 043e:9a10 LG Electronics USA, Inc. ASM107x
Bus 001 Device 034: ID 131d:0159 Natural Point 
Bus 001 Device 041: ID 05e3:0610 Genesys Logic, Inc. Hub
Bus 001 Device 042: ID 06a3:0d05 Saitek PLC Pro Flight Radio Panel
Bus 001 Device 043: ID 1a40:0101 Terminus Technology Inc. Hub
Bus 001 Device 044: ID 03f0:e807 HP, Inc HP Webcam HD 4310
Bus 001 Device 045: ID 046d:c52b Logitech, Inc. Unifying Receiver
Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 002 Device 005: ID 05e3:0616 Genesys Logic, Inc. hub

Desktop (please complete the following information):

  • OS: Linux Gentoo
  • X-Plane version 12.09.rc5 (last available)
@CyberGuerro CyberGuerro added the bug Something isn't working label Mar 15, 2024
@norberttak
Copy link
Owner

Thanks for the bug report. I've never seen a crash on that component. I have to investigate it and reproduce in my environment. Try to do this on the weekend.

@CyberGuerro
Copy link
Author

CyberGuerro commented Mar 16, 2024

I think I found a possible cause:
I removed all your libraries to force plugin using my system libraries (hidapi, libusb), only liblua I had to maintain and now plugin start but return me this error:

XPanel [7052] [DEBUG]:add new saitek radio panel device
XPanel [7052] [DEBUG]:UsbHidDevice: call hid_init()
XPanel [13068] [DEBUG]:UsbHidDevice connect successful. vid=1699 pid=3333
XPanel [14070] [ERROR]:error in UsbHidDevice::send_feature_report reason=hid_error is not implemented yet
XPanel [14070] [ERROR]:SaitekRadioPanel connect. error in write_device
XPanel [14070] [DEBUG]:SaitekRadioPanel::start called
XPanel [14070] [DEBUG]:UsbHidDevice::start
XPanel [14070] [INFO]:successful init and start plugin

in my distribution hidapi is 0.13.1 (I tried 0.14 marked unstable but same error)
I suspect that in your sistem (LINUX) you have more recent version and not all dependency libs was included in your installation package, so plugin try to search in my system's libs that apparently are incompatible with yours.

PS.
Now I'm using compiled sources that you send me for bug #87, instead of official release sources (1.8)

@norberttak
Copy link
Owner

I tested your config on windows and it works fine. So I think the issue is around hidapi library versions.
Unfortunately I don't have a Linux machine that can run XPlane (only a laptop to build the sources). Here you can see how the github action pipeline build the Linux binary:

- name: Install dependencies

The pipeline uses Ubuntu 20.04 (Focal) which is pretty old and it uses hidapi 0.9 version according to Ubuntu

On my Windows machine, I use the 0.12.0 version of hidapi lib and it works fine. I don't know whether it is possible to downgrade your hidapi version to this or not.

To solve the issue I have to update the hidapi version to the latest stable version (0.13.1 or 0.14) and do tests with that version on Windows and Linux. I guess the same error ("hid_error is not implemented yet") will raise on Windows as well.

@CyberGuerro
Copy link
Author

CyberGuerro commented Mar 16, 2024

Two little things/questions about pipeline build action:

  1. can you substitute liblua5.3-dev at line 64 with liblua-dev (without version, so it can take last installed version of it)?
  2. can you switch from focal to lunar or newer?

About hidapi on my system I've installed it to make some tests, but normally it isn't installed and the plugin uses its libraries installed in its folder like other plugins which are completely autoconsisten.

If I can help you I give you my time as tester. I tried to build your sources, but I haven't packages for arduino and compilation fails :-( :-(

@norberttak
Copy link
Owner

Regarding pipeline:

  • Github supports only the stable Ubuntu versions as runners, so I updated to the latest stable version 22.04
  • Unfortunately, on Ubuntu the apt repo doesn't have liblua-dev only the libluaX.Y-dev. I updated it to the latest 5.4 version.

You can find the build artifacts here: https://github.com/norberttak/XPanel/actions/runs/8310493658/artifacts/1332243748

I updated the hidapi version to the latest 0.14.0 but I have to test it first on my Windows system. The MR is opened but still work in progress: #91

@CyberGuerro
Copy link
Author

CyberGuerro commented Mar 17, 2024

OK, tried your last ebuild:

  1. Crash plugin if device listted in config isn't found....... ....FIXED (tried with switch config, but without connect device and now plugin show error in ERROR DIALOG and XPLANE doesn't crash anymore)
  2. Radio device error still persist with this error (same config of the my bug opened message):
    XPanel [59844] [ERROR]:error in UsbHidDevice::send_feature_report reason=hid_error is not implemented yet

Attached Log.txt

I found this googling error, I don't know if it can help you to solve...

@norberttak
Copy link
Owner

I created a new build: https://github.com/norberttak/XPanel/actions/runs/8332736662/artifacts/1336532931
It contains the following updates:

  • updated hidapi version to 0.14
  • added some error messages around the hidapi_init() call
  • liblua updated to version 5.4
  • Linux build is based on Ubuntu 22.04

Please test this build with the enclosed libraries.

To be sure I got all the details about your setup:

  1. You have Saitek Switch and Saitek Radio devices. Switch Panel works fine, and the error only raised with the Radio panel, right?
  2. Do you have any other plugin or application that connects to the Radio Panel? Maybe in the scripts of FlyWithLua?
  3. Please run the lsusb -t command to check what driver is loaded for the Saitek Radio panel

@CyberGuerro
Copy link
Author

CyberGuerro commented Mar 18, 2024

Tested: same error attach Log.txt
To your questions:

  1. RIGHT
  2. No other plugins or Lua scripts
  3. this is the command output:
    lsusb
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 001 Device 002: ID 1462:7d25 Micro Star International MYSTIC LIGHT 
Bus 001 Device 003: ID 05e3:0608 Genesys Logic, Inc. Hub
Bus 001 Device 004: ID 05e3:0608 Genesys Logic, Inc. Hub
Bus 001 Device 005: ID 1a40:0101 Terminus Technology Inc. Hub
Bus 001 Device 006: ID 043e:9a10 LG Electronics USA, Inc. ASM107x
Bus 001 Device 007: ID 058f:6364 Alcor Micro Corp. AU6477 Card Reader Controller
Bus 001 Device 008: ID 051d:0002 American Power Conversion Uninterruptible Power Supply
Bus 001 Device 009: ID 03f0:e807 HP, Inc HP Webcam HD 4310
Bus 001 Device 010: ID 131d:0159 Natural Point 
Bus 001 Device 011: ID 046d:c52b Logitech, Inc. Unifying Receiver
Bus 001 Device 012: ID 05e3:0610 Genesys Logic, Inc. Hub
Bus 001 Device 013: ID 06a3:0d05 Saitek PLC Pro Flight Radio Panel
Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 002 Device 002: ID 05e3:0616 Genesys Logic, Inc. hub

lsusb -t

/:  Bus 001.Port 001: Dev 001, Class=root_hub, Driver=xhci_hcd/16p, 480M
    |__ Port 002: Dev 002, If 0, Class=Human Interface Device, Driver=usbhid, 12M
    |__ Port 005: Dev 003, If 0, Class=Hub, Driver=hub/4p, 480M
        |__ Port 002: Dev 005, If 0, Class=Hub, Driver=hub/4p, 12M
            |__ Port 001: Dev 009, If 0, Class=Video, Driver=uvcvideo, 12M
            |__ Port 001: Dev 009, If 1, Class=Video, Driver=uvcvideo, 12M
            |__ Port 001: Dev 009, If 2, Class=Audio, Driver=snd-usb-audio, 12M
            |__ Port 001: Dev 009, If 3, Class=Audio, Driver=snd-usb-audio, 12M
            |__ Port 001: Dev 009, If 4, Class=Human Interface Device, Driver=usbhid, 12M
            |__ Port 004: Dev 011, If 0, Class=Human Interface Device, Driver=usbhid, 12M
            |__ Port 004: Dev 011, If 1, Class=Human Interface Device, Driver=usbhid, 12M
            |__ Port 004: Dev 011, If 2, Class=Human Interface Device, Driver=usbhid, 12M
        |__ Port 003: Dev 006, If 0, Class=Hub, Driver=hub/4p, 480M
            |__ Port 003: Dev 010, If 0, Class=[unknown], Driver=[none], 12M
        |__ Port 004: Dev 008, If 0, Class=Human Interface Device, Driver=usbhid, 1.5M
    |__ Port 008: Dev 012, If 0, Class=Hub, Driver=hub/4p, 480M
        |__ Port 003: Dev 013, If 0, Class=Human Interface Device, Driver=[none], 1.5M
    |__ Port 013: Dev 004, If 0, Class=Hub, Driver=hub/4p, 480M
        |__ Port 001: Dev 007, If 0, Class=Mass Storage, Driver=usb-storage, 480M
        |__ Port 001: Dev 007, If 1, Class=Human Interface Device, Driver=usbhid, 480M
/:  Bus 002.Port 001: Dev 001, Class=root_hub, Driver=xhci_hcd/9p, 20000M/x2
    |__ Port 007: Dev 002, If 0, Class=Hub, Driver=hub/4p, 5000M

Can I suggest you to look Sparker project XSaitekPanels to get some ideas,
In particular hidapi folder : You could try to compile the hidapi library for all 3 OS instead of using compiled libraries (lin & win) or better copy his hidapi into your project
Maybe he uses a different driver (I'm thinking hidraw instead of hidusb)?
You could ask him how is his approach in linux enviironment

@norberttak
Copy link
Owner

I have some small progress.

  1. I can reproduce the issue on my Linux laptop. I created a small test project (attached in the
    hidtest.tar.gz ) You can build it on your system as well. Please note, this is a standalone application using code parts from my plugin. It shall be run without XPlane simulator.

If I change the hidapi backend to hidraw (see the makefile HIDPKG variable), I have some more detailed error messages:

XPanel [54131] [ERROR]:error in UsbHidDevice::send_feature_report reason=ioctl (SFEATURE): Invalid argument

with libusb backend the same error message (not implemented ... ) appears what you found.
I still have to understand what this error message means. It's strange that on Windows this is working properly. I'll search for this.

  1. I also checked the XSaitekpanel's source as you suggested. It's difficult to follow the code, but as far as I see they are doing the same. I'll look into details.

  2. Just a quick question: When you remove every multi_display entity from your config, the button handling is working with the Radio Panel? I mean the rotary encoders. If yes, it means only the write operation (send_fetaure_report) is failing in my code.

@CyberGuerro
Copy link
Author

CyberGuerro commented Mar 19, 2024

  1. I built successfully the sources...
  2. I connected the device
  3. I run the compiled output (hidtest) this is the output:
HID test application
Press 'q' to exit the application
The log is saved into test_log.txt
Segmentation error

attached log file test_log.txt

About your 3rd point I'll try modified config this evening when I'll come back home from work :-) ....stay tuned :-)

@norberttak
Copy link
Owner

based on what you wrote:

In particular [hidapi folder](https://github.com/sparker256/xsaitekpanels/tree/master/src/hidapi) : You could try to compile the hidapi library for all 3 OS instead of using compiled libraries (lin & win) or better copy his hidapi into your project
Maybe he uses a different driver (I'm thinking hidraw instead of hidusb)?

I updated my test application, and it now runs properly. Thanks for the hint. Now I use the hid.c from the latest version of hidapi instead of linking to the system installed libraries. I created a new build of the plugin on my Ubuntu. Unfortunately, I can't test it, so may I ask you to do a quick test with
this package?

@CyberGuerro
Copy link
Author

Now plugin doesn't load due this error:
dlerror:/home/claudio/X-Plane 12/Resources/plugins/XPanel/64/lin.xpl: undefined symbol: hid_exit

About your previouse question:

Just a quick question: When you remove every multi_display entity from your config, the button handling is working with the Radio Panel? I mean the rotary encoders. If yes, it means only the write operation (send_fetaure_report) is failing in my code.

Error persist again whitout any section about multidisplay and buttons like this:

[device:id="saitek_radio"]
vid="6a3"
pid="d05"

@norberttak norberttak linked a pull request Mar 21, 2024 that will close this issue
@CyberGuerro
Copy link
Author

CyberGuerro commented Mar 22, 2024

I found this bug on hidapi repository and I suspect that it could be the reason of this bug. In the discussion someone suggests to use hidraw instead hidusb for Linux platform due a timeout issue

@norberttak
Copy link
Owner

Yes, I know this bug and I modified my build to use hidraw accordingly. It solved the issue with my test application, but unfortunately, the plugin still doesn't work in your environment (undefined symbol: hid_exit):
https://github.com/norberttak/XPanel/actions/runs/8385560897/artifacts/1348881346

I gonna build a PC with Linux & X-Plane to be able to test the plugin on Linux. I try to do my tests tonight and I'll update you on the progress. Hope I can fix this hidapi related issue soon.

@norberttak
Copy link
Owner

I spent two days with a stupid mistake :-( I added the hidapi as a source to my project. It's a strange behavior of CMAKE that it ignores silently the .c file if the project is c++. It doesn't matter I added the hid.c to the source tree explicitly.
Anyhow, I built a new version of the plugin. Meanwhile, I have a Linux PC running Ubuntu 22.04 and XPlane12. The Zibo with your configuration works fine. So I'm pretty confident the issue solved.
Could you please test it on your environment as well?
XPanel_linux.zip

Just for reference, here is the dependencies you have to install:

ldd lin.xpl
        linux-vdso.so.1 (0x00007fff9fba0000)
        libudev.so.1 => /lib/x86_64-linux-gnu/libudev.so.1 (0x00007fc75c6d1000)
        liblua5.4.so.0 => /lib/x86_64-linux-gnu/liblua5.4.so.0 (0x00007fc75c68f000)
        libstdc++.so.6 => /lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007fc75c463000)
        libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007fc75c37c000)
        libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007fc75c35c000)
        libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fc75c133000)
        /lib64/ld-linux-x86-64.so.2 (0x00007fc75c81c000)

If it works fine I will merge it to the main line and will create a new release.
,Norbert

@CyberGuerro
Copy link
Author

I'm sorry, but it doesn't work...... the difference now is the error:

XPanel [28748] [DEBUG]:add new saitek radio panel device
XPanel [28748] [DEBUG]:UsbHidDevice: call hid_init()
XPanel [28748] [DEBUG]:UsbHidDevice: successful hid_init
XPanel [28801] [DEBUG]:UsbHidDevice connect successful. vid=1699 pid=3333
XPanel [34254] [ERROR]:error in UsbHidDevice::send_feature_report reason=ioctl (SFEATURE): Connessione scaduta
XPanel [34254] [ERROR]:SaitekRadioPanel connect. error in write_device
XPanel [34254] [DEBUG]:SaitekRadioPanel::start called
XPanel [34254] [DEBUG]:UsbHidDevice::start

(error is in my language: italian) which means "Connection timed out"
it seems that there is a timeout issue as mentioned in my previous message (hidapi bug)
attached complete Log.txt

@norberttak
Copy link
Owner

The bug you mentioned shouldn't play in my latest version. That bug is about the libusb backend, and my plugin now contains the hid.c with hidraw backend. I modified my plugin to use hiddraw instead of libusb in PR: #94
The send_feature_report() in my plugin is different from in that bug

We could do a few things here:

  1. Please remove all libraries from the XPanel/64 folder. Only the lin.xpl shall be there.
  2. Please be sure the libusb is not installed on your system (at least for a test). It shouldn't be loaded by my plugin, but I'm not aware of the magic of loading the libraries by Linux. The libusb related libraries on my Ubuntu are: libhidapi-libusb0 and libusb-1.0-0
  3. I added an extra setting to the CMAKE. The XSaitek panel uses this. On Ubuntu I didn't need it but may be it could help on Gentoo Linux.
  4. Based on the previous: You may try to compile my code from this branch: 90-bug-plugin-crash-with-saitek-radio-panel Please check the runtime dependency by the ldd command

The latest Ubuntu 22.04 binary build from my branch is here

@CyberGuerro
Copy link
Author

CyberGuerro commented Mar 24, 2024

Your last binary (with libraries inside plugin's folder) give me this ldd output:

ldd lin.xpl
        linux-vdso.so.1 (0x00007ffd8c84e000)
        libudev.so.1 => /mnt/X-Plane_Data/0/Plugins/XPanel/64/./libudev.so.1 (0x00007f6ee659e000)
        liblua5.4.so.0 => /mnt/X-Plane_Data/0/Plugins/XPanel/64/./liblua5.4.so.0 (0x00007f6ee655c000)
        libstdc++.so.6 => /usr/lib/gcc/x86_64-pc-linux-gnu/13/libstdc++.so.6 (0x00007f6ee6200000)
        libm.so.6 => /usr/lib64/libm.so.6 (0x00007f6ee6124000)
        libgcc_s.so.1 => /usr/lib/gcc/x86_64-pc-linux-gnu/13/libgcc_s.so.1 (0x00007f6ee64fe000)
        libc.so.6 => /usr/lib64/libc.so.6 (0x00007f6ee5f46000)
        /lib64/ld-linux-x86-64.so.2 (0x00007f6ee66e2000)

removing all libraries I have this output

ldd lin.xpl
./lin.xpl: /usr/lib64/liblua5.4.so.0: no version information available (required by ./lin.xpl)
        linux-vdso.so.1 (0x00007ffc889a8000)
        libudev.so.1 => /usr/lib64/libudev.so.1 (0x00007f1cf22e7000)
        liblua5.4.so.0 => /usr/lib64/liblua5.4.so.0 (0x00007f1cf22a5000)
        libstdc++.so.6 => /usr/lib/gcc/x86_64-pc-linux-gnu/13/libstdc++.so.6 (0x00007f1cf2000000)
        libm.so.6 => /usr/lib64/libm.so.6 (0x00007f1cf1f24000)
        libgcc_s.so.1 => /usr/lib/gcc/x86_64-pc-linux-gnu/13/libgcc_s.so.1 (0x00007f1cf2280000)
        libc.so.6 => /usr/lib64/libc.so.6 (0x00007f1cf1d46000)
        libcap.so.2 => /usr/lib64/libcap.so.2 (0x00007f1cf2271000)
        /lib64/ld-linux-x86-64.so.2 (0x00007f1cf247c000)

I tried to build your sources as indicated in your point 4, but it doesn't build due an error in your sources:

[ 70%] Building CXX object src/CMakeFiles/xpanel.dir/devices/fip/FIPDevice.cpp.o
[ 74%] Building CXX object src/CMakeFiles/xpanel.dir/devices/fip/FIPPage.cpp.o
In file included from /home/claudio/Desktop/XPanel-90-bug-plugin-crash-with-saitek-radio-panel/src/devices/fip/FIPPage.h:10,
                 from /home/claudio/Desktop/XPanel-90-bug-plugin-crash-with-saitek-radio-panel/src/devices/fip/FIPPage.cpp:6:
/home/claudio/Desktop/XPanel-90-bug-plugin-crash-with-saitek-radio-panel/src/devices/fip/FIPLayer.h:12:9: error: ‘uint8_t’ does not name a type
   12 |         uint8_t r;
      |         ^~~~~~~
/home/claudio/Desktop/XPanel-90-bug-plugin-crash-with-saitek-radio-panel/src/devices/fip/FIPLayer.h:10:1: note: ‘uint8_t’ is defined in header ‘<cstdint>’; did you forget to ‘#include <cstdint>’?
    9 | #include <fstream>
  +++ |+#include <cstdint>
   10 | 

You have to add
#include <cstdint>
in your /src/devices/fip/FIPLayer.h after row
#include <fstream>

After changes I built it, I used it, but same error.
this is the output of ldd:

ldd lin.xpl
        linux-vdso.so.1 (0x00007fffb66c7000)
        libudev.so.1 => /usr/lib64/libudev.so.1 (0x00007f40973f1000)
        liblua5.4.so.0 => /usr/lib64/liblua5.4.so.0 (0x00007f40973af000)
        libstdc++.so.6 => /usr/lib/gcc/x86_64-pc-linux-gnu/13/libstdc++.so.6 (0x00007f4097000000)
        libm.so.6 => /usr/lib64/libm.so.6 (0x00007f40972d3000)
        libgcc_s.so.1 => /usr/lib/gcc/x86_64-pc-linux-gnu/13/libgcc_s.so.1 (0x00007f40972ae000)
        libc.so.6 => /usr/lib64/libc.so.6 (0x00007f4096e22000)
        libcap.so.2 => /usr/lib64/libcap.so.2 (0x00007f409729f000)
        /lib64/ld-linux-x86-64.so.2 (0x00007f4097581000)

One question:
How is the node in /dev of your Linux box when you attach saitek device? I'm asking to myself if could be a permission's issue..... but it's strange because other plugins works with saitek devices.....

@norberttak
Copy link
Owner

norberttak commented Mar 24, 2024

The only thing that is strange in your ldd is the libcap. I'm not a Linux guru so maybe it's not important but that lib is about the user access rights. which may cause some permission issue??? Anyhow I don't know why it is linked to the plugin when you build it.

My device tree looks like this with the 3 Saitek devices I have:

norbi@norbi-linux:~$ ls -la /dev/saitek*
lrwxrwxrwx 1 root root 7 márc  24 20:57 /dev/saitekmultipanel -> hidraw4
lrwxrwxrwx 1 root root 7 márc  24 20:57 /dev/saitekradiopanel -> hidraw1
lrwxrwxrwx 1 root root 7 márc  24 20:57 /dev/saitekswitchpanel -> hidraw9

This the content of my rule file (/etc/udev/rules.d/99-saitek.rules)

KERNEL=="hidraw*", ATTRS{idProduct}=="0d67", ATTRS{idVendor}=="06a3", MODE="0666", SYMLINK+="saitekswitchpanel"
KERNEL=="hidraw*", ATTRS{idProduct}=="0d05", ATTRS{idVendor}=="06a3", MODE="0666", SYMLINK+="saitekradiopanel"
KERNEL=="hidraw*", ATTRS{idProduct}=="0d06", ATTRS{idVendor}=="06a3", MODE="0666", SYMLINK+="saitekmultipanel"
BUS=="usb", ATTRS{idProduct}=="0d05", ATTRS{idVendor}=="06a3", MODE="0666"
BUS=="usb", ATTRS{idProduct}=="0d06", ATTRS{idVendor}=="06a3", MODE="0666"
BUS=="usb", ATTRS{idProduct}=="0d67", ATTRS{idVendor}=="06a3", MODE="0666"

When you say other plugins, you mean XSaitekpanel? If yes I need to double(triple) check the cmake files in that repo. Unfortunately, not all cmake files are in use so it's pretty hard to follow what is live and what is dead code there.

@norberttak
Copy link
Owner

The update for missing #include <fstream> has been merged and this branch has been rebased #96

@CyberGuerro
Copy link
Author

CyberGuerro commented Mar 24, 2024

When you say other plugins, you mean XSaitekpanel? If yes I need to double(triple) check the cmake files in that repo. Unfortunately, not all cmake files are in use so it's pretty hard to follow what is live and what is dead code there.

Yes,
I noticed this:
If first I run X-Plane with your plugin (with error) and then restart X-Plane switching to XSaitekPanel I have to disconnect device and reconnect because XSaitekPanel doesn't recognize it.

If I use ever xsaitepanel every X-Plane start is ok.
Can I suggest you to ask support to Sparker (the author of xSaitekPanels), Hes a Linux developer and very very helpful :-)

These are my udev rules:

KERNEL=="hidraw*", ATTRS{idVendor}=="06a3", ATTRS{idProduct}=="0d67", MODE="0666", SYMLINK+="saitekswitchpanel"
KERNEL=="hidraw*", ATTRS{idVendor}=="06a3", ATTRS{idProduct}=="0d05", MODE="0666", SYMLINK+="saitekradiopanel%n"
KERNEL=="hidraw*", ATTRS{idVendor}=="06a3", ATTRS{idProduct}=="0d06", MODE="0666", SYMLINK+="saitekmultipanel"
KERNEL=="hidraw*", ATTRS{idVendor}=="06a3", ATTRS{idProduct}=="0b4e", MODE="0666", SYMLINK+="saitekbippanel"
KERNEL=="hidraw*", ATTRS{idVendor}=="06a3", ATTRS{idProduct}=="0b4d", MODE="0666", SYMLINK+="saitektpmpanel"
SUBSYSTEM=="usb", ATTRS{idVendor}=="06a3", ATTRS{idProduct}=="0d05", MODE="0666"
SUBSYSTEM=="usb", ATTRS{idVendor}=="06a3", ATTRS{idProduct}=="0d06", MODE="0666"
SUBSYSTEM=="usb", ATTRS{idVendor}=="06a3", ATTRS{idProduct}=="0d67", MODE="0666"
SUBSYSTEM=="usb", ATTRS{idVendor}=="06a3", ATTRS{idProduct}=="0b4e", MODE="0666"
SUBSYSTEM=="usb", ATTRS{idVendor}=="06a3", ATTRS{idProduct}=="0b4d", MODE="0666"

For saitek radio panels I have to enumerate my devices with "%n" suffix

@norberttak
Copy link
Owner

For saitek radio panels I have to enumerate my devices with "%n" suffix
Does it mean you have more than one Radio devices connected?

@CyberGuerro
Copy link
Author

CyberGuerro commented Mar 25, 2024

For saitek radio panels I have to enumerate my devices with "%n" suffix Does it mean you have more than one Radio devices connected?

In this Test phase only 1, but usually I connect 3 Radio panels. I think that when I connect Radio panel device (independent by number of devices), rule create symlink with suffix (but this doesn't give any problem with XSaitekPanels plugin).

What I don't understand is error message "connection timed out"... ...it seems that plugin is able to connect to device, but when it try to write bytes to it, connection is closed/fallen...

During my last test, I tried to remove all plugins, but nothing had changed

@norberttak
Copy link
Owner

there are two differences between my plugin and xsaitek plugin:

  1. they use hid_enumerate and hid_open_path while my plugin simple call hid_open
  2. xsaitek plugin simple ignores the return value of hid_send_feature_report while my plugin stops itself upon an error from that hid function.

I create a test version with the above two updates. If an error happens in hid_send_feature_report you will see the error message but the plugin tries to continue.
lin.zip

It works on my Ubuntu box.

@CyberGuerro
Copy link
Author

I'm afraid, it doesn't work, same error.
Before start xplane I removed all files in XPanel/64 and copied content of your zip (only lin.xpl). Is it right?

Attach Log.txt

@norberttak
Copy link
Owner

Could you please check the flywithlua plugin and its scripts? I see these lines in your last log file:

FlyWithLua Info: HID access initialized.
FlyWithLua Info: FlyWithLua.ini full path 
/home/claudio/X-Plane 12/Resources/plugins/FlyWithLua/Internals/FlyWithLua.ini
FlyWithLua Info: Discovered 8 HID devices.
FlyWithLua Info: Initial assignments successfully saved.

...
FlyWithLua Info: Start loading script file /home/claudio/X-Plane 12/Resources/plugins/FlyWithLua/Scripts/xsaitekpanels-scripts-zibo.lua
FlyWithLua Info: Finished loading script file /home/claudio/X-Plane 12/Resources/plugins/FlyWithLua/Scripts/xsaitekpanels-scripts-zibo.lua

@norberttak norberttak reopened this Mar 29, 2024
@norberttak
Copy link
Owner

norberttak commented Mar 29, 2024

my plugin initialize only those devices that are in the actual xpanel.ini config file (placed in the aircraft folder). I don't load the devices when the XPlane simulator starts, only at that point where you start to load the airplane.

If it is more convenient, I can create a small standalone application to test the HID devices.

@norberttak norberttak changed the title [BUG] Plugin crash with Saitek Radio Panel [BUG] hid_send_feature_report error on Gentoo Linux Mar 29, 2024
@norberttak
Copy link
Owner

norberttak commented Mar 29, 2024

Here is a test application contains the same code parts that the plugin use:
hidtest.tar.gz
The package contains the compiled binary (hidtest) and the source code as well. You can compile it if you wish:

make clean
make
./hidtest

If it works you will see a lot of XPanel [40538] [TRACE]:successful hid_send_feature_report log lines on the console and the radio panel display will display 0..9 numbers periodically changing.
The application logs are also saved into test_log.txt

This is the output on my console when I run this test program:

norbi@norbi-linux:~/src/hidtest$ ./hidtest
HID test application
The log is saved into test_log.txt
XPanel [3153] [DEBUG]:UsbHidDevice: call hid_init()
XPanel [3153] [DEBUG]:UsbHidDevice: successful hid_init
XPanel [3155] [DEBUG]:device opened: vid=1699 pid=3333
XPanel [3155] [DEBUG]:UsbHidDevice::start
XPanel [3155] [TRACE]:UsbHidDevice::thread_func: started for vid=1699 pid=3333
XPanel [3178] [TRACE]:successful hid_send_feature_report
XPanel [3178] [TRACE]:successful device_read
...
XPanel [8080] [TRACE]:successful hid_send_feature_report
XPanel [8080] [TRACE]:successful device_read
XPanel [8080] [DEBUG]:UsbHidDevice thread_func: exit vid=1699 pid=3333
XPanel [8081] [DEBUG]:UsbHidDevice::stop. thread finish ? 1 remaining time=482
XPanel [8081] [DEBUG]:UsbHidDevice::release called for vid=1699 pid=3333
XPanel [8081] [DEBUG]:UsbHidDevice release
XPanel [8081] [DEBUG]:All USB HID devices are closed. call hid_exit()
Application stopped
XPanel [8081] [TRACE]:UsbHidDevice::~UsbHidDevice() vid=1699 pid=3333

One more thing you can test: The hidapitester could be a good tool to see what's on your system

./hidapitester --vidpid 06a3:0d05 --verbose --open --list-detail
see some details about your radio device

./hidapitester --vidpid 06a3:0d05 --open --get-report-descriptor
print out the report descriptor of your device

./hidapitester --vidpid 06a3:0d05 --open --send-feature 3
it will set the first digit of top-left display on the radio dvice to 3

@CyberGuerro
Copy link
Author

CyberGuerro commented Mar 29, 2024

TEST APP WORKS!!!! 👍 👍 👍
Displays show numers :-)
attach
test_log.txt

Tried hidapitester and it works has expected 👍

@norberttak
Copy link
Owner

It's good news 👍
Now, the strange thing is that this test application uses the same code as XPanel uses :-)
Just to be 100% sure the xpanel plugin doesn't work, I recompiled the whole project again. Could you please test this version? Sorry for the many iterations, but this issue is really tricky. Please be sure all other plugins are removed for the test.

If this still doesn't work, then maybe something in your XPlane simulator interferes with my plugin. Do you start any other HID related applications alongside the simulator?

FYI: Here it is the code updates around hid initialization: #97 The enclosed lin.xpl contains these modifications.

@CyberGuerro
Copy link
Author

CyberGuerro commented Mar 29, 2024

Your plugin doesn't want to work......
Removed all plugins and now when I close X-Plane it crash....
attached
Log.txt

What I'm asking to myself is: which is the differences between you plugin and xsaitekpanels in terms of:

  • when they are initialized by X-Plane
  • which are the steps of initialization of two plugins

When you find them you probably find the answer to this mystery....

Unfortunately I'm not C++ developer and I don't understand the code :-( :-( :-(
Can I suggest to ask help to Sparker?

@norberttak
Copy link
Owner

norberttak commented Mar 29, 2024

I'm getting run out the ideas what could be the issue here :-(
Regarding your points in the previous message:

  1. Now I moved the HID initialization to the point where XPlane starts (that's what you asked for display something on the radio panel before airplane loaded). With this I moved the hid initialization to the very beginning of my plugin. XSaitekpanel do the similar.

  2. Otherwise, the initialization steps are identical in the two plugins (hid_enumerate, hid_open_path, hid_set_nonblocking, hid_free_enumeration)

With this version you should see 123 on the top-left display of radio panel before any aircraft loaded. If it works please try to load an aircraft.

@CyberGuerro
Copy link
Author

CyberGuerro commented Mar 29, 2024

Now when I start X-Plane display show this:

[12300   ]   [00-      ]
[ 0000   ]   [0754     ]

Then, when I load Cessna Error windows show known error and the device doesn't work.

Then I close X-Plane without any crash :-)
I found this in the log, before X-plane load aircraft:
XPanel [54533] [INFO]:XPLM_MSG_PLANE_CRASHED or XPLM_MSG_PLANE_UNLOADED message received

attached
Log.txt

@norberttak
Copy link
Owner

and what if you reload the plugin (menu --> Plugins --> XPanel--> reload plugin)

@CyberGuerro
Copy link
Author

and what if you reload the plugin (menu --> Plugins --> XPanel--> reload plugin)
Tried before write my last message... I think you should find "reload" call in the Log.txt attached before.

@norberttak
Copy link
Owner

Sorry, I didn't recognized the reload message in your log files (I had a quick view on my phone only)

I added a hack to my code: it opens the radio devices at the very beginning but it don't close when airplane loaded (the version from yesterday closed and reopened the radio device upon plane loaded)
lin.zip
All you radios shall display 12345 on the top-left display. I hope after an airplane loaded it still works.

@CyberGuerro
Copy link
Author

CyberGuerro commented Mar 30, 2024

Well.... as you said when X-Plane 12 starts all my 3 radio's display show "12345", but when I load aircraft, plugin stop working and shows errors in windows dialog.
attached Log.txt

Can I ask you (if is it possible) to remove/comment all "send_feature_report" call from all your code (it seems that it doesn't work) so we remove annoying message error?

@norberttak
Copy link
Owner

I removed the send_feature_report calls from this version
lin-no-feature-report.zip
Please note the send_feature_report is used to set the display on the radio device so this version wont show you the radio frequencies only the buttons will work.

I also created another version
lin-early-load.zip
This version is initializing the plugin in much earlier than the original. Could you please test this as well?
Please run this command after the aircraft is loaded: lsof /dev/saitekradiopanel1 It will show which processes are attached to the device. On my Ubuntu it shows this while XPlane is running:

norbi@norbi-linux:~/src/XPanel$ lsof /dev/saitekradiopanel1
COMMAND    PID  USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
Main\x20T 4937 norbi  164u   CHR  241,1      0t0  462 /dev/hidraw1
Main\x20T 4937 norbi  265u   CHR  241,1      0t0  462 /dev/hidraw1

@CyberGuerro
Copy link
Author

CyberGuerro commented Mar 30, 2024

plugin with no-feature-report works (buttons and rotaries); I only noticed that when i push lower switch button, X-Plane zooms the view and keyboard doesn't work until I disconnect device.

plugin with early-load doesn't work as usually.
this is the output of command:

lsof /dev/saitekradiopanel7 
COMMAND    PID    USER  FD   TYPE DEVICE SIZE/OFF NODE NAME
Main\x20T 7431 claudio 157u   CHR  236,7      0t0 1382 /dev/hidraw7
Main\x20T 7431 claudio 336u   CHR  236,7      0t0 1382 /dev/hidraw7

PS.
I think that in your country is late and so I'd like to wish you Happy Easter, I don't want you brake your head during the holydays, so I understand if we restart THE FIXING on tuesday...... ...but if you want I'm here to help you as I can :-)

@norberttak
Copy link
Owner

It's very strange. I noticed the same behavior (zoom on lower switch button). But only with the no-feature-report version. xsaitekpanel has a description about how to solve this kind of mouse interference: https://github.com/sparker256/xsaitekpanels/blob/master/docs/Linux_Users_Please_Read.txt That solved my problem.

The identifier in the above description is not up-to-date. You can see the correct names in the output of lsusb command.

I'm in Hungary so, I think we are in the same time zone. I really want to solve this issue, so I'll think more about it during the Easter holiday. Happy Easter to you as well!

@CyberGuerro
Copy link
Author

About the behavior I solved: I have to deactivate device in KDE, infact it identify Radio Devices as mouse device. After deactivated no more interference between keyboard/mouse and saitek :-)

@norberttak
Copy link
Owner

I created another version:

  • pre-opens all devices and keep them open
  • ignores the send_feature_report errors. it will log the error message on DEBUG level and code will continue despite of the error.
    lin-preopen-all-devices.zip

@CyberGuerro
Copy link
Author

Now:
if I connect 1 device (radio), x-plane loads aircraft, but panel is "cold and dark" and no buttons, no display, no knobs, no error window.....
attached Log.txt
If I attach all my 3 radio devices, X-Plane freezes during initial load ("Initialize plugins" phase)
For future I'll test with only one device connected (radio) and then, when it will be ok, I'll test with all 3 devices connected :-)

@norberttak
Copy link
Owner

It's strange that between the device connect and the first send_feature_report error your PC spend more than 5 seconds

XPanel [45982] [DEBUG]:device connect: vid=1699 pid=3333
XPanel [51488] [DEBUG]:error in UsbHidDevice::send_feature_report reason=ioctl (SFEATURE): Connessione scaduta
XPanel [51490] [DEBUG]:SaitekRadioPanel connect. successful

On my PC (which is a much less powerful compared to yours) it is only 5 ms (not seconds but milliseconds)

XPanel [12347] [DEBUG]:device connect: vid=1699 pid=3333
XPanel [12351] [DEBUG]:SaitekRadioPanel connect. successful

What I see is that you have a lot of custom scenaries what are loaded at almost the same time as XPanel plugin loads. Maybe it overloads your PC and the plugin can't get the time to communicate with the USB devices? I know it sounds very strange. I would like to do two tests:

  1. I created a plugin version that delays any USB message handling for 10 seconds after plugin loads. It means that in the first 10 seconds it seems not working so please wait the time before testing the devices.
    lin-delay-10sec.zip
  2. I don't know whether it is possible or not but for a test it would be nice to disable every custom scenaries.

@CyberGuerro
Copy link
Author

Remove all custom sceneries, using your lin-delay-10sec version, tested with only 1 radio device: NOT WORKING, same error.
Atteched
Log.txt

@norberttak
Copy link
Owner

norberttak commented Apr 5, 2024

I did a USB communication capture on my Ubuntu box. I'd like to ask you to do the same tests on your system as well:

  1. install wireshark sudo apt install wireshark
  2. enable usbmon kernel modul: sudo modprobe usbmon
  3. list your USB devices:
norbi@norbi-linux:~$ lsusb
Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 001 Device 007: ID 413c:2110 Dell Computer Corp. Dell Wired Multimedia Keyboard
Bus 001 Device 004: ID 413c:1010 Dell Computer Corp. USB 2.0 Hub [MTT]
Bus 001 Device 003: ID 06a3:a2ae Saitek PLC Pro Flight Instrument Panel
Bus 001 Device 014: ID 06a3:0d67 Saitek PLC Pro Flight Switch Panel
Bus 001 Device 011: ID 044f:b679 ThrustMaster, Inc. T-Rudder
Bus 001 Device 008: ID 06a3:0d06 Saitek PLC Flight Pro Multi Panel
Bus 001 Device 005: ID 06a3:0d05 Saitek PLC Pro Flight Radio Panel
Bus 001 Device 002: ID 2109:2817 VIA Labs, Inc. USB2.0 Hub             
Bus 001 Device 013: ID 0b05:1939 ASUSTek Computer, Inc. AURA LED Controller
Bus 001 Device 009: ID 05e3:0610 Genesys Logic, Inc. Hub
Bus 001 Device 012: ID 06a3:0bac Saitek PLC Pro Flight Yoke
Bus 001 Device 010: ID 0461:4d81 Primax Electronics, Ltd Dell N889 Optical Mouse
Bus 001 Device 015: ID 0b0e:0300 GN Netcom Jabra EVOLVE 20 SE MS
Bus 001 Device 006: ID 06a3:712c Saitek PLC Pro Flight Yoke integrated hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 004 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 003 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
  1. My radio panel is on the USB Bus 001, and it has device ID 005. Note these values.
  2. Start wireshark sudo wireshark and select the USB bus to capture (in my case it was 001 according to the previous point)
  3. Apply this filter in wireshark: usb.dst contains "1.5." || usb.src contains "1.5." here the 1.5 means bus 1 and device 5 (according to lsusb output). Modify the filter according to your bus/device id.
  4. Start packet capturing in wireshark
  5. Start XPlane and load the Cessna 172. Do not touch any button, knob on saitek devices. After about 1 minute stop capturing packets in wireshark.
  6. Stop XPlane simulator

This is the captured USB frames in my system:
Screenshot from 2024-04-05 18-46-54
The SET_REPORT_REQUEST is when my plugin initialize the radio panel. That's the point where you get the timeout error messages.

I'm really curious what traffic is captured on your system. If you have time I'd like to see the same tests with XSaitek panel plugin as well.

Please use the lin-delay-10sec version for your tests.

@CyberGuerro
Copy link
Author

Tests done.
This is my usb lists:

Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 001 Device 002: ID 1462:7d25 Micro Star International MYSTIC LIGHT 
Bus 001 Device 003: ID 05e3:0608 Genesys Logic, Inc. Hub
Bus 001 Device 004: ID 05e3:0608 Genesys Logic, Inc. Hub
Bus 001 Device 005: ID 05e3:0610 Genesys Logic, Inc. Hub
Bus 001 Device 006: ID 1a40:0101 Terminus Technology Inc. Hub
Bus 001 Device 007: ID 058f:6364 Alcor Micro Corp. AU6477 Card Reader Controller
Bus 001 Device 008: ID 043e:9a10 LG Electronics USA, Inc. ASM107x
Bus 001 Device 009: ID 03f0:e807 HP, Inc HP Webcam HD 4310
Bus 001 Device 010: ID 051d:0002 American Power Conversion Uninterruptible Power Supply
Bus 001 Device 011: ID 131d:0159 Natural Point 
Bus 001 Device 012: ID 046d:c52b Logitech, Inc. Unifying Receiver
Bus 001 Device 013: ID 06a3:0d05 Saitek PLC Pro Flight Radio Panel
Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 002 Device 002: ID 05e3:0616 Genesys Logic, Inc. hub

This is my wireshark filter:
usb.dst contains "1.13." || usb.src contains "1.13."
(my device's id is 13 on bus 001)

Attached:
XPanel.zip
Xsaitekpanels.zip

I hope these help you

@norberttak
Copy link
Owner

Thanks for the tests. What I see:

  1. it seems Saitek changed something in the firmware because the HID descriptor in your Radio HW is different what I have. I'm not sure it is important or not.
  2. XSaitek Panel sends the first feature report with the very first byte set to 0. According to Linux kernel source if it is 0 then kernel truncates the report size. That's what I see in comparison with XSaitek panel and my plugin's feature report (my plugin try to send 23 bytes while Xsaitek panel only 22 bytes). The Radio panel response for my 23 byte long message with a
URB status: No such file or directory (-ENOENT) (-2)

It could be the root cause of the issue. I'm not sure but it seems a problem. On the other hand I don't understand how it works both on my Linux and Windows. Anyways, I created a new version where I set the first byte of the feature report strictly to 0. Could you please test this please?

@CyberGuerro
Copy link
Author

GREAT NEWS!!!!
Now it works: no more errors and display, buttons and knobs work.....
.....BUT...
....if I connect only 1 radio it works as expected, but if I connect all my 3 radio devices, all 3 devices's display show same things (Top-Left display of first, second and third devices shows same thing, top-right same thing on all 3 devices and so on) and 3 devices are setted as below:

device 1 upper: COM1
device 1 lower: COM 2
device 2 upper: NAV 1
device 2 lower: NAV 2
device 3 upper: ADF
device 3 lower: XPDR

If I turn device 1 knobs, sometimes display of device 1 change, sometimes display of device 2, sometimes display of device 3. Same thing if I use knobs of device 2 or device 3.

I think that now the plugin have to distinguish the device when there are multiple devices of the same type.

@norberttak
Copy link
Owner

that's great news :-)

let me check what causes the mixing of more than one radio devices. If you don't mind I close this Issue and open a new one for the multi radio issue.

@norberttak
Copy link
Owner

Followup of the multi radio devices bug: #99

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
2 participants