Jump to content
The simFlight Network Forums

Recommended Posts

Posted

MOVED FROM FAQ SUBFORUM

 

Sir,

I am the chief I.T.Dept. of a VA on Vatsim, and we have flight tracker program to track the flights of pilots coded on Delphi. We preferred to read standart offsets and these offsets are evaluated according to company procedures. A pilot needs to open the main exit (offset 3367) to start boarding. Well some of our pilots reported that they can not use our recorder (flight tracker) because FsLabs' new airbus's doors are not sensed by the recorder. We mailed their support guys and we received the Lvars of the doors.

Now, my question is, is it possible to read the Lvars values out of the aircraft within our recorder program? If it is, how? If it is not, well, I never used LUA before, how can I type a code which will set 3367 as "1" when Lvar (door) is "1", Or 3367 as "0" when Lvar (door) is "0" ?

 

Hope I am clear enough :)

  • 3 weeks later...
Posted

Hi,

didn't you just check the FSUIPC4 Offsets Status.pdf, the very first one I would look into when searching for an Offset?

There you will simple find this by searching for Lvar:

0D70 40 Macros and Lua requests
...
L:Var read and write requests
First write the offset address to which the resulting value (an 8-
byte double or FLT64) will be written (for a Read) or the value
to be written can be found (for a Write). This MUST be one of
the user offsets, i.e. in the range 0x66C0 to 0x66F8.
Then write to 0D70 the name of the LVar, preceded by just one :
(colon) character for a read or :: (two colons) for a write, and
terminated by a zero byte.
The reason for the use of user offsets is to avoid corruption when
more than one application is running which reads L:Vars in this
way. It is a matter for the programs, probably with user
cooperation, to avoid clashes. Both 0D6C and 0D70 can be
written together or at least in one Process call, and the result of a
read can be read immediately, even in the same Process call. For
a write the value to be written can be placed in the stated offset
in the same Process call too, provided it is before the writes to
0D6C and 0D70.
If the Lvar does not currently exist the result of a read will be
0.0. There’s no way to detect if a write succeeded other than to
read the L:var afterwards.
If the offset provided is invalid the request is just ignored and
the offset value unchanged.

I think simple enough and your program just checks if the Doors Offset or User Offset is set.

Thomas

Posted (edited)

Mr Richter, thank you very much for your comment, it helps me to see that there is a solution but I am really confused. I mean, I just can't think from this point on, I am just looking at the code to figure out what to do, only to fail. Sir, I think an example will be very helpful at this point.

When I read the FSUIPC4 Offsets Status.pdf , I see that it says..

 

0D70 40 Write here the complete identity string of a Macro control or Lua program control in order to have FSUIPC execute it. For a Macro, the string should begin with up to 16 characters giving the .MCRO file name (just the name part, not the type), and then, separated by a ‗:‘ character, the macro name within that file—again, up to 16 characters. Spaces either side of the ‗:‘ are optional. For a Lua program operation, the actual Lua control should be provided, followed (with one space or ‗:‘ separator) by the Lua program name (without the .Lua suffix). The valid Lua controls are: Lua, LuaDebug, LuaKill, LuaSet, LuaClear, LuaToggle Note that a parameter should always be written first for the Set, Clear and Toggle controls as this specifies the flag to be changed (0–31). A parameter is never used with ―Lua Kill‖. If a parameter is to be supplied, it should first be written to offset 0D6C, above. Otherwise whatever was last written there will be supplied.

 

But as I said, I am totally confused about what to do by your comment and by the comment above. I can not connect them with each other.

 

This is how I get the offset values on my delphi code :

 

I create a thread first

then define a boolean variable for door state

 

  public

    DoorsOpen      : boolean;

..

 

and inside the thread execute procedure I define another variable for door offset..

procedure TTVThread.Execute;
var
  tDoors:byte;

  res:dword;

 

Now its time to get the offset value..

    FSUIPC_Read($3367, 1, @tDoors,     res);

 

then I process it in another procedure, turn it into a boolean express..

    DoorsOpen:=tDoors<>0;

 

Now my DoorsOpen variable is..true or false. Can you please give me an example about how to evaluate an LVar from this point on? The name of the LVar is lets say "ACDoor1"..

 

I will appreciate if you can. Thank you sir..

 

Edited by buick552
Posted
Hi,
as it says you provide in offset 0x0D6C (4 byte Int) the address (offset) you want to get your value from the L:var and then write into offset 0x0D70 the string of the L:var with zero termination.
 
I.e. using Offset 0x66C0 (8 byte length, double or FLT64)
Write to Offset 0x0D6C (4 byte Int) the value (hex) 0x66C0
Write to Offset 0x0D70 and onwards (max 40 byte) the ASCII values of "ACDoor1" with NULL termination, 65, 67, 68, 111, 111, 114, 49, 0
 
Now process FSUIPC, do not process before both Offsets have been written.
 
Now you should be able to read the value in Offset 0x66C6 (8 byte length as double or FLT64).
If the L:var is correct you should get the correct value

Thomas

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.