Jump to content
The simFlight Network Forums

Recommended Posts

Posted

Hello

I am using the KingAir analog from BlackSquare. I am trying to assign the value of two L type variables to a specific address or another variable.

image.png.05f019a5f74f087e1d6d68cca0411111.png

image.png.a7971cabe8349c617480d0747075aec1.png.

It can be noted that both values coincide with what the instrument needles indicate. I then wrote the following codes:

    local circuitConnection = ipc.readLvar("L:var_cabinPressurizationAltitude")
    local valueToWrite = circuitConnection
    ipc.writeUB(0x274A, valueToWrite)

    local circuitConnection = ipc.readLvar("L:var_cabinPressureDifferential")
    local valueToWrite = circuitConnection
    ipc.writeUB(0x2749, valueToWrite)

But the values read from these addresses are very different.

image.png.3f512e1d8664a74a2bf379a554aa230a.png

I have also tried it this way:

ipc.execCalcCode("(L:CABIN_PRESS_DIFF)")
ipc.execCalcCode("(L:CABIN_PRESS_ALT)")

ipc.reloadWASM();

    ipc.execCalcCode("(L:var_cabinPressureDifferential, Number) (>L:CABIN_PRESS_DIFF)")
    ipc.execCalcCode("(L:var_cabinPressurizationAltitude, Number) (>L:CABIN_PRESS_ALT)")

 

Considering that I have assigned an address to these variables within the FSUIPC7.ini

[LvarOffsets]

91=CABIN_PRESS_DIFF=UB2747
92=CABIN_PRESS_ALT=UB2748

And the result has been equally wrong.

image.png.d6dbb51da0b287b8c7a444b3fc30050c.png

If you could please give me some idea of how to get the indicated value to be the one I need to read and write to an address or another variable. Thank you very much.

 

Alejandro Gómez.

 

 

 

Posted
15 hours ago, P-38L said:

It can be noted that both values coincide with what the instrument needles indicate. I then wrote the following codes:

    local circuitConnection = ipc.readLvar("L:var_cabinPressurizationAltitude")
    local valueToWrite = circuitConnection
    ipc.writeUB(0x274A, valueToWrite)

    local circuitConnection = ipc.readLvar("L:var_cabinPressureDifferential")
    local valueToWrite = circuitConnection
    ipc.writeUB(0x2749, valueToWrite)

But the values read from these addresses are very different.

You are writing the values as an unsigned byte (UB). Those lvars contain double values, so use ipc.writeDBL or ipc.writeFLT. And as they are 8 or 4bytes, you need to write them to an offset on an 8-byte or 4-byte boundary, so use, for example, 0x2750 and 0x2758 (last digit must be a 0 or an 8 when. writing as doubles.

15 hours ago, P-38L said:

I have also tried it this way:

ipc.execCalcCode("(L:CABIN_PRESS_DIFF)")
ipc.execCalcCode("(L:CABIN_PRESS_ALT)")

That won't do anything....

15 hours ago, P-38L said:

   ipc.execCalcCode("(L:var_cabinPressureDifferential, Number) (>L:CABIN_PRESS_DIFF)")
    ipc.execCalcCode("(L:var_cabinPressurizationAltitude, Number) (>L:CABIN_PRESS_ALT)")

That will write those lvar values to new lvars (and create them)...why would you want to do this?

15 hours ago, P-38L said:

[LvarOffsets]

91=CABIN_PRESS_DIFF=UB2747
92=CABIN_PRESS_ALT=UB2748

And the result has been equally wrong.

Again, because you are writing them as bytes when they should be doubles (or floats)...

Try:

Quote

[LvarOffsets]

91=L:var_cabinPressureDifferential=0x2750
92=L:var_cabinPressurizationAltitude,=0x2758

or

Quote

[LvarOffsets]

91=L:var_cabinPressureDifferential=F0x2750
92=L:var_cabinPressurizationAltitude,=F0x2754

John

Posted

Dear Mr. Dowson

I tried with the examples you kindly gave me, but I still don't get the number that the simulator shows me. I even tried using SB, UB, SW, UW, SD, UD and F and none of those options give me the answer, it even gives me random numbers including negative numbers that "jump" from positive to negative quickly. After many attempts I came up with this idea:

ipc.execCalcCode("(L:var_cabinPressureDifferential, PSI) 100 * (>L:CABIN_PRESS_DIFF)")

and then I got the exact number; So far so good, 1 out of 2. But I haven't had any luck with the variable:

ipc.execCalcCode("(L:var_cabinPressurizationAltitude) (>L:CABIN_PRESS_ALT)")

I've even written it like this without getting any positive result:

ipc.execCalcCode("(L:var_cabinPressurizationAltitude, FT) (>L:CABIN_PRESS_ALT)")

I don't know if I should use a multiplier or divisor like I did with the "var_cabinPressureDifferential" variable, but I've used all my math resources without any optimal answer. It always jumps like crazy from negative to positive for no apparent reason.

 

Alejandro

Posted
1 hour ago, P-38L said:

I tried with the examples you kindly gave me, but I still don't get the number that the simulator shows me.

If you list the lvars (Add-ons -> WASM -> List Lvars) do you see the lvars with the correct values?

1 hour ago, P-38L said:

I even tried using SB, UB, SW, UW, SD, UD and F and none of those options give me the answer, it even gives me random numbers including negative numbers that "jump" from positive to negative quickly.

I don't know why you would try that... Please use something like:

Quote

[LvarOffsets]
1=L:var_cabinPressureDifferential=0x2750
2=L:var_cabinPressurizationAltitude,=0x2758

and also log offsets (Log -> Offsets...) 0x2750 and 0x2578 both as FLT64. This will then log the values in those offsets to the FSUIPC7.log file. You can show me / attach your FSUIPC7.log and FSUIPC7.ini files

I have added new functionality to log specified lvars (to the log or a separate window) which I will release in a day or two - this may help you see the lvar values, but will basically show the same as adding the lvars to offsets and logging the offsets. I will let you know when available.

 

Posted
If you list the lvars (Add-ons -> WASM -> List Lvars) do you see the lvars with the correct values? 

Yes sir. The same value as shown in the instrument.

image.png.ff022b4af834e2c139a0084c06b99eee.png

image.png.76d9cd06c10a3aa22f76ee03fa1a7fe8.png

And I put it in two memory addresses like this:

92=CABIN_PRESS_ALT=0x2748
93=var_cabinPressurizationAltitude=0x2749

Row 93 contains the original airplane variable. Row 92 contains my own variable, which I wrote like this:

ipc.execCalcCode("1 if{ (L:var_cabinPressurizationAltitude, FT) 1 * 0 < 
if{ 0 100 360 / * } els{ (L:var_cabinPressurizationAltitude, FT) 1 * 45000 > 
  if{ 360 100 360 / * } els{ (L:var_cabinPressurizationAltitude, FT) 
  1 * 0 - 45000 0 - / 360 0 - * 0 + 100 360 / * } } } 10 * (>L:CABIN_PRESS_ALT)")

In both examples the reading of the variable value does not match at all:

image.png.add4f189ed7f7a332aa0cac5848d4c06.png

Here is the copy of the .ini and .log files:

 

FSUIPC7.log

FSUIPC7.ini

Posted
9 hours ago, P-38L said:

And I put it in two memory addresses like this:

92=CABIN_PRESS_ALT=0x2748
93=var_cabinPressurizationAltitude=0x2749

But that can't possibly work, for two reasons:
    1. You are instructing to write 8 bytes to offset address 0x2748. This will therefore use addresses 0x2748 - 0x274F inclusive. The second entry is using 0x2749, which then overwrites the area specified for the first lvar.
    2. You cannot write an 8-byte value to 0x2749 as this is not on an 8-byte boundary. As I mentioned earlier (and as documented), values MUST be boundary aligned. What this means is that the offset address used for 8-byte values must end with a 0 or 8, offset addresses for 4-byte values must end in 0, 4, 8, or C, and offset addresses for 2-byte values must end in 0,2,4,6,8,A,C or E.

Your ini file shows this:

Quote

91=CABIN_PRESS_DIFF=0x2747
92=var_cabinPressurizationAltitude=0x2748

which is incorrect for the reasons given above.

You are also adding many lvars as unsigned bytes (UB), and many of those are not unsigned bytes. An unsigned byte can only hold a value in the range 0-255.

No point looking at your log as
  - you have WAPI TRACE logging activated., Turn this off.
  - you are NOT monitoring/logging the offsets you are using, as advised

Why do you noy just follow the advise I previously gave:

. Please use something like:

  Quote

[LvarOffsets]
91=L:var_cabinPressureDifferential=0x2750
92=L:var_cabinPressurizationAltitude,=0x2758

and also log offsets (Log -> Offsets...) 0x2750 and 0x2578 both as FLT64. This will then log the values in those offsets to the FSUIPC7.log file. You can show me / attach your FSUIPC7.log and FSUIPC7.ini files

?

John

Posted

I also am not sure that you can specify the units for an lvar like this:

(L:var_cabinPressurizationAltitude, FT)

That syntax is for simvars, which have units specified (and documented). I have never seen this used before with lvars....

John

Posted

Dear Mr. John

I finally understood how it should be done. I didn't know about assigning one variable to 0x2750 and the next to 0x2758; I thought I could use normal consecutive numbers. Now knowing that I have finally this:

90=L:var_cabinPressureDifferential=0x2750
91=L:var_cabinPressurizationAltitude=0x2758
92=L:var_cabinClimbRate=0x2760

and then from there, I took them to SIOC at Opencockpits for the analog instruments and they are working perfectly.

I really appreciate your great help and patience.

Alejandro

 
 
 

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.