Jump to content
The simFlight Network Forums

Recommended Posts

Posted

Hi,
Is it possible to read one L:var value with offset 0x0D70 without macro files?
I just want to read the value of one L:var and did not intend to create a macro file or use LUA just for this purpose.
I'm using C#
Thank you for the help. :)
Framac

 

Posted

Hi,

in case you found the Offset in Offset list you will have seen as well in its description 'L:Var read and write requests' and how to do it? That will answer your question already and how to do.

Thomas

Posted

Hi Thomas
Thank you for your answer.

I try but I'm doing something wrong.

The L:Var is an int :  VC_GSLD_CP_EFIS_ND_Mode_Knob
I have the two offets
        public static Offset<string> offset_sendlvar = new Offset<string>(0x0d70, 40, true);
        public static Offset<int> offset_readlvar = new Offset<int>(0x66c0, true);

        offset_sendlvar.Value = "0x666c0:VC_GSLD_CP_EFIS_ND_Mode_Knob";
        FSUIPCConnection.Process();

        int  test= offset_readlvar.Value;

But this always return 0
 

What I'm doing wrong? Can you help me?
Thank you

Framac

Posted

Hi,

in case you want to read, why do you set then offset_readvar to write only status? In case it is set to write only there is no other value that you set it to in the first or any other modified place and so it returns only that value.

Thomas

Posted

Yes, you are right, but even in R / W mode I can not get the value of LVar.
I do not know if this is the right way to write the value to the offset 0x0D70
        offset_sendlvar.Value = "0x366c0:LVAR_Name";

This is my code right now and only return zero. :(
         ...
        public static Offset<string> offset_sendlvar = new Offset<string>(0x0d70, 40);
        public static Offset<int> offset_readlvar = new Offset<int>(0x66c0);
       ...
        offset_sendlvar.Value = "0x366c0:VC_GSLD_CP_EFIS_ND_Mode_Knob";
        FSUIPCConnection.Process();
        ...
        int  test= offset_readlvar.Value;

I am not asking you to do the work for me but I think a little help with a more detailed answer would be useful not only for me but also for future users who have this problem.
Sometimes the problem is in front of our eyes and we can not see it.
Some of us are not professional developers and any small answer is a big help.  :)

Thank you for your help
.

Framac

Posted

Here is the relevant documentation:

Quote

L:Vars can now be read and written through offsets as well as with Lua plug-in functions. This re-uses the offsets provided for
executing macros and Lua plug-ins, as follows:


0D6C 4 bytes Write here the offset to which the resulting value (an 8-byte double or FLT64) will be written,
or the value to be written can be found.
This MUST be one of the user offsets, i.e. in the range 0x66C0 to 0x66F8.


0D70 40 bytes Write here the name of the LVar, preceded by just one : (colon) for a read or :: (two colons) for a
write,
and terminated by a zero byte.

So you need to also declare another offset (before 0D70) of type int for 0x0D6C. In there you need to write the offset you'll be using to receive, along with the type code. In this case 0x366C0. (int at 66C0). Write this as a number obviously, not as a string.

Then in 0D70 you just write the LVar name preceded by a single colon (meaning read):
 

offset_sendlvar.Value = ":VC_GSLD_CP_EFIS_ND_Mode_Knob";

After processing, 0x66C0 will now contain the value.

Paul

 

  • 1 year later...
Posted
Quote

are you also able to write a LVar ?

Yes. If you are using the latest version of my DLL (3.1.5 or above) you can now use:

FSUIPCConnection.ReadLVar(Name)

and

FSUIPCConnection.WriteLVar(Name, NewValue)

Paul

Posted

Hello,

that was fast 🙂

But what DLL did you mean ?

Matthias

 

Ps.: it seams not, because FSUIPCConnection.ReadLvar is not available.

Where can i find that dll please?

Posted
Quote

But what DLL did you mean ?

My .NET library for talking to FSUIPC from .NET languages. That's what this subforum is for.

Details about the DLL are here:

http://fsuipc.paulhenty.com

If you're not using a .NET language then let me know and I'll give you the steps you need for talking directly to FSUIPC.

Paul

Posted

Hello,

view Days ago i chnged from SharpDevelop to VS2017.

That is my first NugetPackage i installed. Hope i did all right, but for the Moment i get no error when i try to compile the Programm with 

FSUIPCConnection.WriteLVar(Name, NewValue)

No i will try to see if it works.

Thanks for the moment, i will come back 🙂

Matthias

Posted

One Question...what kind of DLL is that ?

I tried it with the actual officiell Schiratti SDK and here it did not work.

Can i have it as a DLL File , so that i can add it as Reference to my Project too ?

thanks

Posted

It's just a standard .NET class library dll.

If you installed it via NuGet then it has been automatically added as a reference. Check the references for your project and you'll see it. The actual dll file will be copied to your build folder (debug/release) as normal.

I think the official SDK has a very old version of the dll (maybe 2.0). A lot of new stuff went into 3.0 including the LVar read/write.

I moved to NuGet as it's much easier to publish new versions and keep everyone alerted to new builds.

Paul

Posted

Hello,

 

yes, i found it, sorry.

As i wrote it is the first time i use a nuget package.

Thans for all, it works

 

Maybe i will convert most of my project to simconnect and only use the write LVar funktion from your dll 

Matthias

Posted

Hello again,

 

i have a new/another Problem.

I have to send "TAB+1" to Prepar3D to open my Doors.

I found you thread: 

but it dosent work for TAB+1

i tried it with                  controlParameter.Value = (int)Keys.Tab + (49);

Also Prepar3D does not become the Focus and also i can not send STRG with

controlParameter.Value = (int)Keys.RControlKey + (49);

but with 

controlParameter.Value = 512 + 49;

it works ???

I just wonder why it works with 512 and not with Keys.RControlKey ???

Can you please help here a bit ?7

Thanks

Matthias

 

Posted

Hi Matthias,

There is now a function in the DLL to send key presses to the sim. Sending Tab+1 would be this:

FSUIPCConnection.SendKeyToFS(Keys.D1, SendModifierKeys.Tab);

This also takes care of setting focus to the sim first.

If you want to return focus to your own application, include a reference to this form as the last parameter. For example if the code is part of the form class:

FSUIPCConnection.SendKeyToFS(Keys.D1, SendModifierKeys.Tab, this);
Quote

I just wonder why it works with 512 and not with Keys.RControlKey ???

The modifiers in the .net "Keys" enum are not the same as the modifier codes used by FSUIPC. I had to make my own enum for the DLL (SendModifierKeys).

For future questions, please make a new thread in my sub forum.

Kind Regards,

Paul

Posted

Thanks Matthias,

Yes, FS must have the focus. That's just how Windows works.

The DLL handles this for you though and can give the focus back to your form if you need to.

Paul

Posted

Hello,

thats so fast 🙂

Hmmm...no, i need that FS becomes the Focus before the Key is send 🙂

But i remember there was a DLL import and setforegroundwindow function for that.

Ahh, one thing ... if i call FSUIPCConnection.... is there maybe any funktion in your dll to ceck if FSUIPC is available ( FS running ) or did your dll check that ?

Matthias

Posted
Quote

Hmmm...no, i need that FS becomes the Focus before the Key is send

Yes that's what the DLL does. It first gives focus to the flight sim. Then it sends the key you requested.

It will then restore the focus to your own application window. But only if you ask it to (third parameter).

Quote

if i call FSUIPCConnection.... is there maybe any funktion in your dll to ceck if FSUIPC is available ( FS running ) or did your dll check that ?

When you call FSUIPCConnection.Open() it will thrown an exception if a flight sim or WideClient.exe is not running. You should catch these exceptions to know that FS is not running.

When you call other functions that talk to FSUIPC e.g. Process() or SendKeyToFS(), these will also throw exceptions if the connection has been lost.

You can examine the FSUIPC Application Templates to see the recommended way to handle the connection management.

http://fsuipc.paulhenty.com/#downloads

Paul

Posted

Hello again,

a very litle problem.

I try to send FSUIPCConnection.SendKeyToFS(Keys.F12, SendModifierKeys.Control);

to Prepar3D v4.4 to open the GSX Menu, but P3D becomes the Focus, but the Key is not send or something.

When i put a Sleep before the FSUIPCConnect command and click on the Prepar3D window to activate it, then it works.

Have you any ideas ?

Matthias

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.