SimConnect + WASM combined project using VS2019

I really appreciate the responses … my flight app (a software co-pilot) can almost fly from take-off to landing now … It Works for the a320 as is and I can add a profile for other planes (customizations) and have several other planes working now … ((the custom L H Vars for each plane change)

my biggest problem is not the programming, but the discovery / uncovering of exactly which sim vars or events to use … sometimes there are 5-10 choices and I end up just trying a couple at a time until I find what works… ((I stopped develop last year because of some unsolveable show stoppers … then I recently updated MSFS and suddenly some of those “broken” fuctions in my code starting working with no changes to my code)
DeadCertainly this helps >> The RPN codes that are on the HubHop site will work on any valid WASM server so you shouldn’t need to change any of your API calls. It’s just all the RPN scripts that you were looking for <<< this is probably what I’m looking for right now …

HBilliet your comments and code were very enlightening (amazingly so) … So I think I’ll look at that all again and see … I only need a very few functions solved to be able to release my app to Pre-beta / proof of concept ((but it will need a new (graphical) user interface added ontop)

about Chat-GPT … Do you have the $20/month subscription for what you mentioned? I spent about 5 years working on AI … started 20 years ago as database query optimization and finally instead of writing the processing (opt) based on my own DB performance knowledge, I wrote it so the “APP” (AI barely) observed the performance results of all the changes in the input (SQL or scripts) and it became able to rewrite queries and tune the database by itself. I then moved to natural language processing to accept descriptions of what data was wanted and the APP could generate the SQL , scripts and db configurations . … I’d like to try Chat-GPT and see what it can do … thanks thanks

<edit added… I just reviewed my code. I have about 200 sim vars and about 100 events working] what I think I need is those L Y H vars … I have programmed everything so far with simconnect vars and events (C#) … I created a WASM module but have only done a couple things with it …sort of hardcoded functions … now reading your threads again, I think WASM can do everything I need , if I just know how to input to it … I tried a few scripts from the HubHob and don’t have them working … i realize they are vender and plane specific

IF anyone would like to collaborate on this or another project (this is my very serious … hobby) I’m open

I don’t think there’s much you can do about that; it really is a case of finding what works and what doesn’t, by trial and error. It’s worth exercising a bit of caution if you do try the data on HubHop. The database is created by hundreds of users in good faith, but there’s no real quality control before code is published unfortunately, so some of what’s there quite possibly won’t do what you’d hope it would. That said, it could provide very good clues as to how to get quickly to the right answer.

1 Like

I’m still using the free version of Chat-GPT, but if I would plan on using it more often, I will pay for it. But if you see what the free version can do, it’s really amazing (I also was skeptical in the beginning, until I used it for the first time). As another (unrelated) example: I used to work with VBA in Excel a lot, but haven’t done so since more than a year - so I forgot some concepts and functions. I needed to add a button in a sheet that saved a file to the download folder of my windows 10 machine. I asked this to Chat-GPT in the same language as I write this now, and it gave me the complete function that I could copy in a module and it worked. And the nice thing is that it is contextual, so you can add additional questions of give directions for some changes such as “this time, I want the file to be saved as text only”, and it simply adapts the code. So I think that Chat-GPT might be a useful additional in finding solutions to MSFS problems.

1 Like

This post of mine might give you some clues.

1 Like

Last night I took a subscription and I’ve spent about 14 hours with Chat GPT in the last 24 hours! It is much more capable than I expected, it’s amazing , I have it editing / commenting on a book I’m writing and looking up references and interpreting them (philosophy) … I’ll try some programming tonight.

UPDATE: I’m a openai subscriber now, have worked with it for over a week. full time (10+ hours a day)
I have written applications in hours that would have taken days … Chat 4 is much deeper and very powerful. I have done research in minutes that would have taken much more time via google. This is really life-changing for me; as an author , teacher and programmer. Very Cool.

Thanks a lot for this link. But I looked at it, and am completely lost. Trust me, it’s not you, but me having no clue on how to interpret this. I still have many missed pieces. You jump from one part to the other and magically come to a command, but I,miss some guidance and steps inbetween.

Is there a way to learn the details? Is this explained somewhere in full detail? Or should I ask Char-GPT?:grinning:

I don’t think there is any easy way to “learn the details”. As you’ve no doubt seen, most of the Asobo avionics stuff is all RPN embedded within XML and makes heavy use of macros spread over a number of files. Just that little exercise I linked to took me several hours to piece together and I nearly gave up more than once, but in the end I just didn’t want to let it beat me :wink:

I do believe that the way Asobo has done it is probably for performance reasons and I guess it works - it still astonishes me that they can get the sort of frame rates they do, but oh boy does it make trying to “decode the code” a nightmare.

Maybe ChatGPT might be the holy grail…

I probably could get some grip on it, but I’m just missing some basics of how to interpret these XML files. The only thing I start to get is that UseTemplate Name = “xyz” links to Template Name = “xyz”. And that in UseTemplate the line DirectTo means that in the template, #SUFFIX# is replaced by “DirectTo”. But where is the syntax explained? Or is this just some standard way of working with XML files (which I’m not familiar with, but then I know it’s something I need to learn).

how do the C# and WASM communicate?

Wasn’t it the goal of my post to explain all this? The SDK includes a library (simconnect.dll) that provides an API that can be used for that. But this thread is explaining that in some more detail.

1 Like

the WASM module looks like part of the simConnect.dll to the C#?

The communication with the WASM module is done through SimConnect. This is done by creating some “shared memory” called “Client Area Data” between SimConnect and WASM. This is kind of “gateway”.

For more details, I suggest you read my post. This topic might be of particular interest for you:

Chapter 8: Communicating with the WASM Module through Client Data Areas

1 Like

so this is how I’m proceeding

// WASM_HABIWrapper.cpp
#include “WASM_HABI.h”

public ref class WASM_HABIWrapper
{
public:
static bool FindLVar(String^ sLVar, LVar^ pLVar)
{
pin_ptr strLVar = PtrToStringChars(sLVar);

    char lvar[MAX_LVAR_NAME_LENGTH];
    for (int i = 0; i < sLVar->Length; i++)
        lvar[i] = (char)strLVar[i];
    lvar[sLVar->Length] = '\0';

    LVar nativeLVar;
    bool result = ::FindLVar(lvar, &nativeLVar);

    pLVar->ID = nativeLVar.ID;
    pLVar->Offset = nativeLVar.Offset;
    pLVar->Name = gcnew String(nativeLVar.Name);
    pLVar->Value = nativeLVar.Value;

    return result;
}

};

and in C#

LVar pLVar = new LVar();
bool result = WASM_HABIWrapper.FindLVar(“yourLVarName”, pLVar);

        if (result)
        {
            Console.WriteLine($"LVar ID: {pLVar.ID}, Offset: {pLVar.Offset}, Name: {pLVar.Name}, Value: {pLVar.Value}");
        }
        else
        {
            Console.WriteLine("LVar not found.");
        }

Remarkable work. LOTS of remarkable work and so generous to share it with the community! Thank you!

I have been reading this thread and Dragonlaird’s (helper).

I’m a long time programmer but short time MSFS coder. I’ve been having fun playing with the sim and TouchPortal and some python addons. I’ve been experimenting with C++ on VS2019 as well. I have modified some of the samples. I can access the “A” variables but not the “C” variables (GPS variables).

All of my other sim coding is done in python. I love python. It’s OO BASIC! With C++, C#, etc. I spend more time typing and casting variables than I spend on the other 90% of the code. In python I have been successful at starting a BG task to access simvars and using TTS, have them spoken. This one really impresses my girlfriend. :slight_smile:

So, I have a question. Does such functionality as is implemented in your project here exist in a python module? If not, do you have any insight on how I would start such a project myself? I’m not interfacing hardware. I simply want to read and write all possible simvars (A, C, L, etc. especially the GPS variables).

“Thank you” hardly seems worthy of the gift you’ve given here, but, well, there it is. :slight_smile:

Thank you!