Does SimConnect work differently in standalone Wasm modules and panel Wasm modules?

I am developing an aircraft that needs to use a Wasm module to (heavily) modify various state of the aircraft, through the simulation variables, while it is flying, to achieve its purpose. I use the Wasm SimConnect API for this.

I first used a standalone Wasm module, and that worked great. I call SimConnect_Open(), a few SimConnect_SubscribeToSystemEvent(), lots of SimConnect_AddToDataDefinition(), one SimConnect_RequestDataOnSimObject(), and then one SimConnect_CallDispatch().

Works as it should, my dispatch callback function gets called whenever any of the simulation variables I have requested data on changes.

But, I then realised that a standalone Wasm module, even if packaged as part of a specific aircraft, actually is loaded and active all the time, regardless of what aircraft the user is currently flying. Which is obviously not what I want.

So I need to turn it into a panel Wasm module instead. OK, just a slight change in the plumbing, use a FOO_gauge_callback() instead of module_init(), and do the initialisation when I get the PANEL_SERVICE_PRE_INSTALL callback. Sounds not like a major change.

But, it doesn’t seem to work;) I don’t get any dispatch callbacks when the simulation variables I have requested data for changes… I do get callbacks for the system events I have requested.

I wonder what I am missing, it must be something simple, as this is basically how any of the “interesting” third-party panel Wasm modules work, right? (Like what the helicopters use.)

1 Like

Unfortunately i dont have an answer for you. But if you dont get an answer here, try the FSdeveloper forum:

Im sure there you will get help fast. :slight_smile:

1 Like

Ah, of course I figured it out myself right after posting this. A trivial problem.

When the code was a standalone module, I was waiting for the SimStart system event before I called SimConnect_RequestDataOnSimObject(). But for a panel module, no SimStart or SimStop events are generated. Which, I guess, makes sense as the panel module is loaded only when the aircraft is flying and the simulation is running.

When I made that logic simpler, it again works as expected. Great. I’ll keep this thread here, anyway, in case it helps somebody else later.

(See GitHub - tml1024/flying-brick: Sample aircraft for MSFS built from scratch )

1 Like