• Which the release of FS2020 we see an explosition of activity on the forun and of course we are very happy to see this. But having all questions about FS2020 in one forum becomes a bit messy. So therefore we would like to ask you all to use the following guidelines when posting your questions:

    • Tag FS2020 specific questions with the MSFS2020 tag.
    • Questions about making 3D assets can be posted in the 3D asset design forum. Either post them in the subforum of the modelling tool you use or in the general forum if they are general.
    • Questions about aircraft design can be posted in the Aircraft design forum
    • Questions about airport design can be posted in the FS2020 airport design forum. Once airport development tools have been updated for FS2020 you can post tool speciifc questions in the subforums of those tools as well of course.
    • Questions about terrain design can be posted in the FS2020 terrain design forum.
    • Questions about SimConnect can be posted in the SimConnect forum.

    Any other question that is not specific to an aspect of development or tool can be posted in the General chat forum.

    By following these guidelines we make sure that the forums remain easy to read for everybody and also that the right people can find your post to answer it.

[Noob] Export (readonly) LVars to the outside without gauge?

Messages
2
Country
germany
Hello FSDeveloper,

I need to read some LVars from an external program. I read the 'C Gauges Tutorial', at least one version worked and I saw the gauge in P3D/FSX. However, I like to build a plane independent approach. Something like fsuipc, a module which is loaded at startup. I wonder if there is already such a solution since I read a lot of threads where people asked the same question. Sadly, I was not able to find there a satisfying answer/full example.
I guess a simple example which just reads one LVAR (execute_calculator_code) would be sufficient. Implementing communication to the outside via IPC or TCP should be easy.

The reason: I'm very new to the FSX/P3D SDK usage. Previously I could extract most of the data I need with SimConnect but it seems that some 3rd-party plane developer (eg Majestic Dash8) doesn't eg. provide RPM data via SimConnect.

I hope this question was not answered already.
I appreciate any tip or pointer to the solution!

Thanks
Olaf
 
Check the Cabin Comfort example in FSX/P3D SDK. Could be useful as a starting point.

Tom
 
I have such a module mostly written. I got bogged down getting a named pipe to provide all the functionality that I was looking for.
I can trim it down to be a module that will load into FSX and retrieve LVars. You can add whichever type of interface you want to retrieve the information from outside FSX.
I'll try to post the source code here in a day or two.

Doug
 
Here is a basic dll file with functions to work with LVars.
You will need a dll.xml entry like this to load it:
Code:
<Launch.Addon>
<Name>lvar interface</Name>
<Disabled>False</Disabled>
<ManualLoad>FALSE</ManualLoad>
<Path>.\modules\lvar_interface.dll</Path>
</Launch.Addon>

Doug
 

Attachments

Hi @ddawson, i've test your dll file and works very well.

I have a question:

There's in gauges.h a way to create or "subcribe" to an event like "6hz" event in simconnect?

I try to avoid de use of multi threading.

Thanks.
 
The Cabin Comfort example Tom referred to does define "Update" methods in a couple of the classes it uses. These should get called at 18Hz. that would, in my opinion, be an overly complex way to get such a result.
Why not use a Windows timer? Straightforward and simple.
You could also use SimConnect, as you suggested. You can use it within a gauge or module.
 
Thanks @ddawson for your reply.
I chose to use SimConnect. I agree with you, the Update methods in the Cabin Comfort example are too complex and I don't need a gauge type interface. So, with SimConnect, I have the possibility to send messages to the FS and maybe some menu to control some options (debug, reset, etc).
I use the 6hz event of SimConnect instead a Windows timer because (i think, i'm not sure yet) this event is more frame-friendly.

Thanks again, regards.
 
Data transfer rates via SimConnect are extremely fast.

Using 6hz as a data update rate is horribly inaccurate.
 
Using 6hz as a data update rate is horribly inaccurate.
@WarpD thanks for your comment.
6hz maybe is inaccurate but i have no problem with that. I use it to send data via serial port to a microchip pic based display. Is working realy fine. On the other hand, I try to do this task using multi-threading, launching a thread in the module_init method of the dll and I can't use the execute_calculator_code function (I only use that to retrive the PCSTRINGZ with the name of the VOR/ILS tuned).
Using the 6hz method, i only use a thread to listen the serial port and send the commands to the FS.
 
Ok... there are far better and more accurate means that have zero frame rate issues... but... (shrug)
 
Hello DDawson. Thank you for files. Do you know why the below code works for FSX but not FS9? Is it possible that FSUIPC v3.999z9 can't do ipc.readLvar? Is there a function way to readLvar, and if so, what is the syntax?

Code:
while 1 do

  FDValue = ipc.readLvar("L:CpitCmdrSetValue")
  ipc.writeDBL(0x66D0,FDValue)
  ipc.sleep(50)

end

With FSX, I found out that FSUIPC v4.84 could not run the code below but 4.975 could because v4.84 did not have the feature of event.Lvar so FSUIPC v3.999z9 certainly did not:

Code:
function writeFDCmdr(varname, value)
    ipc.writeUW(0x66D0, value)
    end

event.Lvar("L:CpitCmdrSetValue",100,"writeFDCmdr")

oops! Well, don't I feel a bit silly. I had forgotten that I had assigned the throttle axis to 66D0. I did this so I could use the throttle axis to control up to 4 engine throttles, either together or separately as well as prop pitch, mixture, cowl flaps, flaps and spoiler. Re-assigned 0x66E0 and life is good again.
 
Last edited:
Back
Top