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

xlua: Problem to properly read/evaluate dataref (crash) #22

Open
GladYouAsked opened this issue Nov 16, 2024 · 3 comments
Open

xlua: Problem to properly read/evaluate dataref (crash) #22

GladYouAsked opened this issue Nov 16, 2024 · 3 comments

Comments

@GladYouAsked
Copy link

Hello,

there seems to be an issue with reading/evaluating a specific dataref with xlua.
I assume it could be an issue with xlua, as there is no issue to read this dataref with the DataRefEditor or via a FlyWithLua-Script.
Even it seems to be a strangely behaving dataref, xlua should not crash when just reading such a dataref.
The principle problem in interacting with this dataref has been confirmed by another user.
The xlua-script attached below is reduced to the minimum to demonstrate the problem.

What I try to do:
I want to extract information from a dataref to display it on a StreamDeck+ via X-KeyPad.
I use xlua for this to avoid installation of FlyWithLua or similar.
Aircraft: X-Trident AW109SP
Dataref: aw109/CAS_text (string with variable size)
Location of the lua-script: \X-Plane 12\Aircraft\AW109SP v1.0 for X-Plane 12\plugins\xlua\scripts\XKP.ParseCASDisplay

Description of Problem:
Typically it works. But as soon as I take off and cycle the landing gear and the gear is almost retracted X-Plane crashes. It is reproducible. Obviously s.th. changes with the dataref in this moment.
I see no useable information in the Log.txt (attached), X-Plane just crashes and the log ends without further information.

What I have done so far:

  • I have removed all functionality from the script to identify the problem.
  • It seems that just accessing the data in the dataref (evaluating it or printing it) is enough to crash X-Plane in the described situation (cycling gear). Even just assessing the length of that string (via string.len()) crashes the sim in the situation described above.
  • I tried with the xlua version provided by X-Trident with the AW109SP and also the latest xlua from github. No difference.
  • I have removed all plugins not related to the AW109SP and X-KeyPad.
  • Execute the code with a different cycle time or "after_physics()": No difference.
  • The length of "aw109/CAS_text" differs depending on the number of messages in the queue, see also the attached log-file. Maybe this is the problem (accessing data outside the initially reserved size). Examples:
    ECS ON|FLTA INHBT|LANDING GEAR|LIMITER ON|MAIN UTIL CHRG|
    ECS ON|FLTA INHBT|LIMITER ON|
    ECS ON|FLTA INHBT|LIMITER ON|1 OIL PRES|2 OIL PRES|ROTOR LOW|

Attached:

@JGregory
Copy link
Collaborator

JGregory commented Nov 16, 2024

@GladYouAsked
Your script should reside inside a directory of the same name. ie. \X-Plane 12\Aircraft\AW109SP v1.0 for X-Plane 12\plugins\xlua\scripts\XKP.ParseCASDisplay\XKP.ParseCASDisplay.lua. Not sure if this is related to your crash.

My testing:
Your script... "XKP.ParseCASDisplay.txt" cannot be tested as written. The script is looking for datarefs that have not been created. This "might" not be a problem in your aircraft if the datarefs are created in another plugin and prior to the "find_dataref".

However, if I comment out the "find_dataref" lines and add ...

AW109_CAS_Text_ref  = create_dataref("aw109/CAS_text", "string")
AW109_CAS_count  = create_dataref("aw109/CAS_count", "number")

Then the script will run and I do not get a crash.

Note: "AW109_CAS_count" is never incremented in your test script and therefore the debug print at the bottom of the script is never run.

My guess is there is something else going on when you cycle the gear. The only way for me to test this any further would be to have a copy of the actual aircraft you are running the scripts in.

@GladYouAsked
Copy link
Author

@JGregory
Thanks for the reply!

Your script should reside inside a directory of the same name

It is located in the correct location with the correct name and it is working in principle. The problem is in interacting with that specific dataref (aw109/CAS_text).

The script is looking for datarefs that have not been created.

Maybe my problem description was not clear, sorry:
The datarefs I read via the provided example script are created/managed by the X-Trident AW109SP https://store.x-plane.org/AW-109-SP_p_1891.html
It will for sure not exist in a vanilla X-Plane installation.
If you look into the attached log file you see the debug-output for those datarefs

And I understand if you are not able to debug this as you probably do not own that aircraft. So is there anything I can do for debugging on my side?

I will contact the author of the AW109SP (X-Trident) as well, maybe he has an idea what is going on.
Nevertheless, it will be a grey zone, unless there is a formal guide on how to create/manage/manipulate datarefs. If this is the case, then both sides (content creators and xlua) could be verified against this guideline.

@JGregory
Copy link
Collaborator

@GladYouAsked

And I understand if you are not able to debug this as you probably do not own that aircraft. So is there anything I can do for debugging on my side?

I will contact the author of the AW109SP (X-Trident) as well, maybe he has an idea what is going on. Nevertheless, it will be a grey zone, unless there is a formal guide on how to create/manage/manipulate datarefs. If this is the case, then both sides (content creators and xlua) could be verified against this guideline.

You initially stated that the example script would "demonstrate the problem" but when I run it (with the modifications I mentioned) in a test aircraft I do not get any crash. That makes me feel this is most likely an issue somewhere in the AW109SP and not with XLua. If it were an XLua issue I think we would have had other reports of this by now.

Since I don't know what the plugin for the AW109SP is doing, I can't know why the aircraft is crashing.

I'm not sure what you mean by a "formal guide". We do have a document for XLua that explains the use of custom datarefs....

XLua.pdf

If the issue persists and you can get me a copy of the aircraft I will be happy to do some more testing.

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

2 participants