Jump to content
The simFlight Network Forums

PMDG String Lvars


Detlef_747

Recommended Posts

Hello,

we have been in contact on Lvars some time ago. I have worked with the PMDG offsets more recently. I find, that I can generate Lvars that represent a float number just fine. But string Lvars don't work. So I did a work arround in the lua script attached.

For example

event.offset(0x64bc, "STR", 13, "ChangeMeterTopLine")
calls the function ChangeMeterTopLine just fine. But I cannot write the string into an Lvar at once, so I interpret the string in the FSUIPC lua script and write to a couple of numerical (float) Lvars instead.

Did I miss something with string Lvars? I only found ipc.createLvar(). Are there other functions I could use?

Thank you

Detlef

 

 

PmdgOk.lua

Link to comment
Share on other sites

All lvars are handled internally as 8 byte doubles, so the maximum string length of an lvar is always 8 characters.
I am not going to go through your lua file, but please see the example script I have attached. This creates an lvar, and sets a timer to update this to a different string value every second. There is an event set to pick up the lvar change, and then write the lvar value to an offset. The event on this offset then picks up the new string value for the lvar and just logs it.

John

stringTest.lua

Link to comment
Share on other sites

I think you also need to add data to offsets respecting the offset boundaries for the types you are adding. What this means is the words (e.g. UW, SW) should be added on 2-byte boundaries, dwords (e.g. SD, UD) on 4-nyte boundaries, etc. I am not 100% sure on this without checking the code, but probably a good idea to allocate your offsets with this in mind.

John

Link to comment
Share on other sites

8 hours ago, John Dowson said:

All lvars are handled internally as 8 byte doubles, so the maximum string length of an lvar is always 8 characters.

John,

thank you for your fast reply. Ok, 8 characters max.  That means the 13 character offsets for example

64BC 13 char[13] ELEC_MeterDisplayTop[13]

from the PMDG offset won't work as one piece at leasts. As I said, I found a way arround it. Interpreting the string in the FSUIPC .lua script and write to separate Lvars.

 

8 hours ago, John Dowson said:

please see the example script I have attached. This creates an lvar, and sets a timer to update this to a different string value every second. There is an event set to pick up the lvar change, and then write the lvar value to an offset. The event on this offset then picks up the new string value for the lvar and just logs it.

Thank you for providing the example script. I understand how the script should work but it does not assign a value other than 0 (approx 1.3e-307) to the Lvar. Or I am doing something wrong (which is often..). The counter value is not assigned to the Lvar. This is from the log file:

79860 LUA.3: Lvar updated: 1.1232813414918e-307, type=number
   279875 LUA.3: Lvar value: myvar14
   279938 LUA.3: Offset updated: myvar14
   280907 LUA.3: Lvar updated: 1.1789081879545e-307, type=number

 

Link to comment
Share on other sites

8 hours ago, John Dowson said:

I think you also need to add data to offsets respecting the offset boundaries for the types you are adding. What this means is the words (e.g. UW, SW) should be added on 2-byte boundaries, dwords (e.g. SD, UD) on 4-nyte boundaries, etc. I am not 100% sure on this without checking the code, but probably a good idea to allocate your offsets with this in mind.

John

Hi again,

I know what alignment on words, dword and so on is. But I do not understand, how I should add data to offsets. The PMDG offsets do work as you provide them in the file Offset Mapping for PMDG 737-700.pdf. 

Thank you again,

Detlef

Link to comment
Share on other sites

15 hours ago, Detlef_747 said:

but it does not assign a value other than 0 (approx 1.3e-307) to the Lvar. Or I am doing something wrong (which is often..). The counter value is not assigned to the Lvar. This is from the log file:

79860 LUA.3: Lvar updated: 1.1232813414918e-307, type=number
   279875 LUA.3: Lvar value: myvar14
   279938 LUA.3: Offset updated: myvar14
   280907 LUA.3: Lvar updated: 1.1789081879545e-307, type=number

No - the counter value is appended to the string 'myvar' and the result written to the lvar. The lvar change is then picked-up (in event.Lvar handling function) and written to an offset (as a string - note that you cannot use the value passed to the handling function as that is a number, you have to read the lvar value to get the string), and this offset update then triggers the event.offset handling function and the offset, which holds the lvar value as a string, is then logged.
This is just an example to show you how to handle string lvars, and how to add them to an offset as a string.

15 hours ago, Detlef_747 said:

But I do not understand, how I should add data to offsets.

Bur that is not what your script is doing. Your script is creating and setting lvars based upon the values held in some PMDG-specific offsets.
The example I provided shows you how to add data/lvars to offsets in lua - see the lvarUpdated function, which reads the value of an lvar and adds it to an offset.
You can also use the lvars-to-offsets functionality provided by editing the FSUIPC7..ini file (see the Advanced User guide).

But I don't really understand what you are trying to achieve... as you have the PMDG data on the offsets, why fo you want to use this to create lvars? And what data do you want to write to offsets? And what has this got to do with this topic, which I thought was about using lvars that were strings.

John

Later: if your issue is that the value received in the event.offset handling function (for strings) is a number and not a string, then you have to read the offset as a string in the handling function, and not use the value provided by the function, as this will always be a number. I will clarify this in the documentation - as well as the same for event.lvar when the lvar value is a string, and I will mention the 8 character limit for lvar string handling,
 

Edited by John Dowson
Later added
Link to comment
Share on other sites

6 hours ago, John Dowson said:

But I don't really understand what you are trying to achieve... as you have the PMDG data on the offsets, why fo you want to use this to create lvars? And what data do you want to write to offsets? And what has this got to do with this topic, which I thought was about using lvars that were strings.

John,

thank you for your explanations. They are helpful for me. I think I have to stay with my solution. I don't want to write data to offsets, just read them and write the contents into Lvars. 

I use Siminnovations Airmanager to create instruments on a touchscreen. That software cannot access offsets in FSUIPC. Rather it waits for changes on MSFS simulator variables such as Lvars and then uses the information from the Lvar to control the instruments on the touchscreen. For example:

Offset 64C9 13 char[13] ELEC_MeterDisplayBottom[13] has the information for the bottom line of this instrument:

image.png.3608731e6ca6ee7e6e94db137db47f1b.png

I generate the output you see here from the Lvars I read from FSUIPC via the interface provided from Sim Innovations.

However, it only seems to work with numerical type Lvars. I was not able to see contents from String Lvars generated in FSUIPC, even though I tried to read them as strings. I can live with that now because FSUIPC allows me to generate multiple Lvars (type float) so that I spread the information from the offset on three separate Lvars.

I am not sure I made myself more understandable. I just wanted to understand if and how string Lvars work. If I read the Lvar L:ipcpmdg_DC_Voltmeter generated with stringTest.lua inside the Siminnovations Airmanager, I get the numerical representation for example 9.0251229459308e-308 if I read it as number, and I get "" (an empty string) if I read it as string. That seems to be not an FSUIPC problem but someting in the Siminnovations interface.

I currently experiment some more, just had a complete CTD of MSFS and it won't restart now. I need to restart my computer now...

Detlef

 

 

 

 

 

Link to comment
Share on other sites

30 minutes ago, Detlef_747 said:

I generate the output you see here from the Lvars I read from FSUIPC via the interface provided from Sim Innovations.

I do that, because I don't know PMDG variables I can directly use for some instruments of the B737. For almost all instruments I see the Lvar directly in the XML behaviour file provided with the aircraft. But for some not. And here I do use your offsets from the file Offset Mapping for PMDG 737-700.pdf. That has helped me a lot. The "SDK" which just seems to be a PMDG_NG3_SDK.h file is of no help for me right now.

Detlef

 

Link to comment
Share on other sites

  • 2 weeks later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use. Guidelines Privacy Policy We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.