Jump to content
The simFlight Network Forums

periodic trouble triggering macro from offset


Recommended Posts

Hello,

I'm working on interfacing the A2A Bonanza aircraft to my Talking Flight Monitor accessibility software. 

I'm having some odd issues when trying to set l:vars. Whenever I try to do anything with the 0x0d70 offset, the command just doesn't seem to register occasionally.

It doesn't matter if I use 0d6c and 0d70 to send a setting to an l:var directly, or if I use 0x0d70 to attempt to trigger a macro that toggles an l:var. 

Often, the command will go through fine. However, if I attempt the command several times in a row, several of them won't be sent to the sim.

If I define a macro, then assign a key to it in the sim, it works 100% of the time. So, it's something to do with either FSUIPC itself, or the pyuipc python module I'm using.

I know my code is working, since the macro does work most of the time. 

This is Prepar3d 4.5 and FSUIPC 6.0.8.

Does anyone know of anything that could cause writes to offset 0d70 to not be sent to the sim?

 

 

 

Link to comment
Share on other sites

18 hours ago, Jason Fayre said:

I'm having some odd issues when trying to set l:vars. Whenever I try to do anything with the 0x0d70 offset, the command just doesn't seem to register occasionally.

It doesn't matter if I use 0d6c and 0d70 to send a setting to an l:var directly, or if I use 0x0d70 to attempt to trigger a macro that toggles an l:var. 

Often, the command will go through fine. However, if I attempt the command several times in a row, several of them won't be sent to the sim.

If I define a macro, then assign a key to it in the sim, it works 100% of the time. So, it's something to do with either FSUIPC itself, or the pyuipc python module I'm using.

In FSUIPC the code to process the 0D70 method is the same common code used for buttons.  I suspect it might be a timing issue.

To determine if that's the case so the cause can be pinned down, could you use FSUIPC logging. Compare the times via your two methods. 

It has been found by others that changing L:Vars is not something you can do rapidly. I think the code in the Panels part of P3D is non-re-entrant and there's no queuing of requests.  After all, the L:var mechanism was implemented as an internal thing for panel gauge modules.

Try making sure there's a normal key/mouse pressing delay between each request. A good portion of a second I would think.

Pete

 

  • Like 1
Link to comment
Share on other sites

Hi Pete,

How do I enable the specific logging for this? 

Also, it doesn't seem to matter regarding time interval between invocations when using 0d70. I have tried sending commands more than a second apart and it is still dropping commands.

If I define a key in fsuipc to trigger the macro, I can hit the key quite rapidly while in the sim and the switch toggles every time.

Thanks!

 

 

Link to comment
Share on other sites

19 minutes ago, Jason Fayre said:

How do I enable the specific logging for this? 

For 0D70 writes, you'd need to use the Monitor option, with 0D70 as the offset and ASCIIZ as the type.

For the button action just button logging should do.

21 minutes ago, Jason Fayre said:

I have tried sending commands more than a second apart and it is still dropping commands.

If I define a key in fsuipc to trigger the macro, I can hit the key quite rapidly while in the sim and the switch toggles every time.

That makes no sense to me. Definitely do the Monitor logging, and try to stop when you get a failure so we know which log entry it is -- unless to can make your program stop automatically then?

Pete

 

 

Link to comment
Share on other sites

Hi. I logged offset writes and this looks interesting.

Every time the call goes through correctly, the switch gets toggled and my lua script writes the state of the l:var back to 0x66c6. When it fails, the offset write to 0d70 succeeds, but the switch never moves. 

Here's my log. You can see several examples of the attempt. Every time it succeeds, you will see a write to 66c6 right after the 0d70 write.

********* FSUIPC6, Version 6.0.8 (7th May 2020) by Pete & John Dowson *********
Prepar3D.exe version = 4.5.13.32097
Running inside Prepar3D v4
Module base=7FFE32860000
Windows 10 Pro 64 Bit reported as Build 19631, Release ID: 2004 (OS 10.0)
Reading options from "C:\Program Files\Lockheed Martin\Prepar3D v4\Modules\FSUIPC6.ini"
Checking the Registrations now ...
User Name="Jason Fayre"

FSUIPC6 Key is provided
WIDEFS7 not user registered, or expired
      219 System time = 25/05/2020 08:22:21
      219 FLT path = "C:\Users\jfayr\Documents\Prepar3D v4 Files\"
      234 Using DialogMode
      453 FS path = "C:\Program Files\Lockheed Martin\Prepar3D v4\"
      906 ---------------------- Joystick Device Scan -----------------------
      906 -------------------------------------------------------------------
     1453 ### Checking Prepar3D.cfg
     1453     Controllers are set to ON, using RawInput within P3D
     1453 -------------------------------------------------------------------
     1469 LogOptions=80000000 00000005
     1469 -------------------------------------------------------------------
     1484 SimConnect_Open succeeded: waiting to check version okay
     1484 Opened separate AI Traffic client okay
    19859 Running in "Lockheed Martin® Prepar3D® v4", Version: 4.5.13.32097 (SimConnect: 4.5.0.0)
    19859 Initialising SimConnect data requests now
    19859 FSUIPC Menu entry added
    19875 ... Using Prepar3D with Academic License
    19969 C:\Users\jfayr\Documents\Prepar3D v4 Files\bonanza.fxml
    19969 C:\Users\jfayr\Documents\Prepar3D v4 Add-ons\A2A\SimObjects\Airplanes\A2A_Beechcraft_35_Bonanza\bonanza.air
    61375 ### The user object is 'A2A Beechcraft V35B Bonanza N228Q'
    61391 ### Mode is NORMAL
    62297 ### Mode: PAUSE on
    89016 Loading Complete ...
    89063 ### Mode is NORMAL
    91359 Aircraft loaded: running normally now ...
    91453 User Aircraft ID 1 supplied, now being used
    91844 System time = 25/05/2020 08:23:52, Simulator time = 07:56:12 (11:56Z)
    91953 Aircraft="A2A Beechcraft V35B Bonanza N228Q"
    98078 -------------------- Starting everything now ----------------------
    98188 WRITElua 66C0,   1 bytes: 00                                               .
    98203 WRITElua 66C1,   1 bytes: 00                                               .
    98219 WRITElua 66C2,   1 bytes: 00                                               .
    98219 WRITElua 66C3,   1 bytes: 00                                               .
    98234 WRITElua 66C4,   1 bytes: 01                                               .
    98234 WRITElua 66C5,   1 bytes: 00                                               .
    98250 WRITElua 66C6,   1 bytes: 00                                               .
    98250 WRITElua 66C7,   1 bytes: 00                                               .
    98359 WRITElua 66C8,   1 bytes: 00                                               .
    99531 Advanced Weather Interface Enabled
   181484 WRITE0[18856]  330A,   2 bytes: D2 07                                            ..
   227609 WRITE0[18856]  0D70,  40 bytes: 62 6F 6E 61 6E 7A 61 3A 4C 3A 56 65 6E 74 43 61  bonanza:L:VentCa
   227625                           62 69 6E 46 61 6E 53 77 69 74 63 68 00 00 00 00  binFanSwitch....
   227625                           00 00 00 00 00 00 00 00                          ........
   227734 WRITElua 66C6,   1 bytes: 01                                               .
   279297 WRITE0[18856]  0D70,  40 bytes: 62 6F 6E 61 6E 7A 61 3A 4C 3A 56 65 6E 74 43 61  bonanza:L:VentCa
   279297                           62 69 6E 46 61 6E 53 77 69 74 63 68 00 00 00 00  binFanSwitch....
   279313                           00 00 00 00 00 00 00 00                          ........
   355844 WRITE repeated 2 times
   355844 WRITElua 66C6,   1 bytes: 00                                               .
   397828 WRITE0[18856]  0D70,  40 bytes: 62 6F 6E 61 6E 7A 61 3A 4C 3A 56 65 6E 74 43 61  bonanza:L:VentCa
   397828                           62 69 6E 46 61 6E 53 77 69 74 63 68 00 00 00 00  binFanSwitch....
   397828                           00 00 00 00 00 00 00 00                          ........
   398734 WRITElua 66C6,   1 bytes: 01                                               .
   406734 WRITE0[18856]  0D70,  40 bytes: 62 6F 6E 61 6E 7A 61 3A 4C 3A 56 65 6E 74 43 61  bonanza:L:VentCa
   406734                           62 69 6E 46 61 6E 53 77 69 74 63 68 00 00 00 00  binFanSwitch....
   406734                           00 00 00 00 00 00 00 00                          ........
   406906 WRITElua 66C6,   1 bytes: 00                                               .
   411750 WRITE0[18856]  0D70,  40 bytes: 62 6F 6E 61 6E 7A 61 3A 4C 3A 56 65 6E 74 43 61  bonanza:L:VentCa
   411750                           62 69 6E 46 61 6E 53 77 69 74 63 68 00 00 00 00  binFanSwitch....
   411750                           00 00 00 00 00 00 00 00                          ........
   412078 WRITElua 66C6,   1 bytes: 01                                               .
   413641 WRITE0[18856]  0D70,  40 bytes: 62 6F 6E 61 6E 7A 61 3A 4C 3A 56 65 6E 74 43 61  bonanza:L:VentCa
   413641                           62 69 6E 46 61 6E 53 77 69 74 63 68 00 00 00 00  binFanSwitch....
   413656                           00 00 00 00 00 00 00 00                          ........
   414078 WRITElua 66C6,   1 bytes: 00                                               .
   415469 WRITE0[18856]  0D70,  40 bytes: 62 6F 6E 61 6E 7A 61 3A 4C 3A 56 65 6E 74 43 61  bonanza:L:VentCa
   415469                           62 69 6E 46 61 6E 53 77 69 74 63 68 00 00 00 00  binFanSwitch....
   415484                           00 00 00 00 00 00 00 00                          ........
   416109 WRITElua 66C6,   1 bytes: 01                                               .
   417563 WRITE0[18856]  0D70,  40 bytes: 62 6F 6E 61 6E 7A 61 3A 4C 3A 56 65 6E 74 43 61  bonanza:L:VentCa
   417563                           62 69 6E 46 61 6E 53 77 69 74 63 68 00 00 00 00  binFanSwitch....
   417578                           00 00 00 00 00 00 00 00                          ........
   418219 WRITElua 66C6,   1 bytes: 00                                               .
   419625 WRITE0[18856]  0D70,  40 bytes: 62 6F 6E 61 6E 7A 61 3A 4C 3A 56 65 6E 74 43 61  bonanza:L:VentCa
   419625                           62 69 6E 46 61 6E 53 77 69 74 63 68 00 00 00 00  binFanSwitch....
   419625                           00 00 00 00 00 00 00 00                          ........
   420156 WRITElua 66C6,   1 bytes: 01                                               .
   421609 WRITE0[18856]  0D70,  40 bytes: 62 6F 6E 61 6E 7A 61 3A 4C 3A 56 65 6E 74 43 61  bonanza:L:VentCa
   421609                           62 69 6E 46 61 6E 53 77 69 74 63 68 00 00 00 00  binFanSwitch....
   421625                           00 00 00 00 00 00 00 00                          ........
   449734 WRITE repeated 2 times
   449734 WRITElua 66C6,   1 bytes: 00                                               .
   451375 WRITE0[18856]  0D70,  40 bytes: 62 6F 6E 61 6E 7A 61 3A 4C 3A 56 65 6E 74 43 61  bonanza:L:VentCa
   451391                           62 69 6E 46 61 6E 53 77 69 74 63 68 00 00 00 00  binFanSwitch....
   451391                           00 00 00 00 00 00 00 00                          ........
   505875 WRITE repeated 4 times
   505875 WRITElua 66C6,   1 bytes: 01                                               .
   507203 WRITE0[18856]  0D70,  40 bytes: 62 6F 6E 61 6E 7A 61 3A 4C 3A 56 65 6E 74 43 61  bonanza:L:VentCa
   507203                           62 69 6E 46 61 6E 53 77 69 74 63 68 00 00 00 00  binFanSwitch....
   507219                           00 00 00 00 00 00 00 00                          ........
   507844 WRITElua 66C6,   1 bytes: 00                                               .
   511984 WRITE0[18856]  0D70,  40 bytes: 62 6F 6E 61 6E 7A 61 3A 4C 3A 56 65 6E 74 43 61  bonanza:L:VentCa
   511984                           62 69 6E 46 61 6E 53 77 69 74 63 68 00 00 00 00  binFanSwitch....
   511984                           00 00 00 00 00 00 00 00                          ........
   513000 WRITElua 66C6,   1 bytes: 01                                               .
   514828 WRITE0[18856]  0D70,  40 bytes: 62 6F 6E 61 6E 7A 61 3A 4C 3A 56 65 6E 74 43 61  bonanza:L:VentCa
   514828                           62 69 6E 46 61 6E 53 77 69 74 63 68 00 00 00 00  binFanSwitch....
   514828                           00 00 00 00 00 00 00 00                          ........
   515000 WRITElua 66C6,   1 bytes: 00                                               .
   516906 WRITE0[18856]  0D70,  40 bytes: 62 6F 6E 61 6E 7A 61 3A 4C 3A 56 65 6E 74 43 61  bonanza:L:VentCa
   516906                           62 69 6E 46 61 6E 53 77 69 74 63 68 00 00 00 00  binFanSwitch....
   516906                           00 00 00 00 00 00 00 00                          ........
   517094 WRITElua 66C6,   1 bytes: 01                                               .
   518953 WRITE0[18856]  0D70,  40 bytes: 62 6F 6E 61 6E 7A 61 3A 4C 3A 56 65 6E 74 43 61  bonanza:L:VentCa
   518969                           62 69 6E 46 61 6E 53 77 69 74 63 68 00 00 00 00  binFanSwitch....
   518969                           00 00 00 00 00 00 00 00                          ........
   519063 WRITElua 66C6,   1 bytes: 00                                               .
   522875 WRITE0[18856]  0D70,  40 bytes: 62 6F 6E 61 6E 7A 61 3A 4C 3A 56 65 6E 74 43 61  bonanza:L:VentCa
   522875                           62 69 6E 46 61 6E 53 77 69 74 63 68 00 00 00 00  binFanSwitch....
   522875                           00 00 00 00 00 00 00 00                          ........
   523203 WRITElua 66C6,   1 bytes: 01                                               .
   525031 WRITE0[18856]  0D70,  40 bytes: 62 6F 6E 61 6E 7A 61 3A 4C 3A 56 65 6E 74 43 61  bonanza:L:VentCa
   525031                           62 69 6E 46 61 6E 53 77 69 74 63 68 00 00 00 00  binFanSwitch....
   525031                           00 00 00 00 00 00 00 00                          ........
   525234 WRITElua 66C6,   1 bytes: 00                                               .
   527281 WRITE0[18856]  0D70,  40 bytes: 62 6F 6E 61 6E 7A 61 3A 4C 3A 56 65 6E 74 43 61  bonanza:L:VentCa
   527281                           62 69 6E 46 61 6E 53 77 69 74 63 68 00 00 00 00  binFanSwitch....
   527281                           00 00 00 00 00 00 00 00                          ........
   528250 WRITElua 66C6,   1 bytes: 01                                               .
   530656 WRITE0[18856]  0D70,  40 bytes: 62 6F 6E 61 6E 7A 61 3A 4C 3A 56 65 6E 74 43 61  bonanza:L:VentCa
   530656                           62 69 6E 46 61 6E 53 77 69 74 63 68 00 00 00 00  binFanSwitch....
   530672                           00 00 00 00 00 00 00 00                          ........
   531313 WRITElua 66C6,   1 bytes: 00                                               .
   532656 WRITE0[18856]  0D70,  40 bytes: 62 6F 6E 61 6E 7A 61 3A 4C 3A 56 65 6E 74 43 61  bonanza:L:VentCa
   532656                           62 69 6E 46 61 6E 53 77 69 74 63 68 00 00 00 00  binFanSwitch....
   532656                           00 00 00 00 00 00 00 00                          ........
   535391 WRITE repeated 2 times
   535391 WRITElua 66C6,   1 bytes: 01                                               .
   536828 WRITE0[18856]  0D70,  40 bytes: 62 6F 6E 61 6E 7A 61 3A 4C 3A 56 65 6E 74 43 61  bonanza:L:VentCa
   536828                           62 69 6E 46 61 6E 53 77 69 74 63 68 00 00 00 00  binFanSwitch....
   536844                           00 00 00 00 00 00 00 00                          ........
   537438 WRITElua 66C6,   1 bytes: 00                                               .
   538766 WRITE0[18856]  0D70,  40 bytes: 62 6F 6E 61 6E 7A 61 3A 4C 3A 56 65 6E 74 43 61  bonanza:L:VentCa
   538766                           62 69 6E 46 61 6E 53 77 69 74 63 68 00 00 00 00  binFanSwitch....
   538766                           00 00 00 00 00 00 00 00                          ........
   539469 WRITElua 66C6,   1 bytes: 01                                               .
   540969 WRITE0[18856]  0D70,  40 bytes: 62 6F 6E 61 6E 7A 61 3A 4C 3A 56 65 6E 74 43 61  bonanza:L:VentCa
   540969                           62 69 6E 46 61 6E 53 77 69 74 63 68 00 00 00 00  binFanSwitch....
   540984                           00 00 00 00 00 00 00 00                          ........
   558594 Sim stopped: average frame rate for last 467 secs = 19.3 fps
 

Link to comment
Share on other sites

52 minutes ago, Jason Fayre said:

Every time the call goes through correctly, the switch gets toggled and my lua script writes the state of the l:var back to 0x66c6. When it fails, the offset write to 0d70 succeeds, but the switch never moves. 

So it's a Lua script?  I thought from this:

20 hours ago, Jason Fayre said:

So, it's something to do with either FSUIPC itself, or the pyuipc python module I'm using.

that it was a program access rather than a plug-in.

In the Lua script you are evidently detecting the switch change if you then write to 66C6. What happens if on a failure to do this you then repeat the write to Lua?

I really cannot see anything that FSUIPC does which can change whether the switch operates or not.  Now i know you are using a Lua plug-in then it may be related to the different timings when switching threads. Something is different in the way the gauge module detects the change. 

I suspect the only way to work out what is happening would be to debug the gauge concerned, to see what it is receiving and doing about it. But that's a job for the aircraft author.

One thing you could try, just to see if it really is a difference in FSUIPC between the way it works with buttons compared to the Lua plug-in and 0D70 method: instead of writing to 0D70, toggle a virtual button (see offset 29F0 or 3340), then assign that button to the macro which works for you.

Pete

 

 

Link to comment
Share on other sites

Hi,

The Lua script is just monitoring l:vars for changes using the event.LVar system. The writes to 0d70 are coming from my Talking Flight Monitor application. 

The flow goes like this:

* user presses a hotkey in my software to trigger the switch (in this case, the cabin fan switch)

* my software writes to 0d70 to trigger the macro to toggle the switch

* the lua script detects the change in the cabin fan l:var and writes the result back to 66c6. The lua script isn't actually flipping the switch, the macro does that.

I know I should be able to do this all in my software, but I've had strange results with l:vars periodically reading 0 when I read them from my software. This is ok for values I can anticipate, since I can just read the result again. It doesn't work so well for toggles though when the result is just 0 or 1.

I still don't understand why I'm getting better results when defining the key directly in fsuipc to fire the macro.

I'll take a look at the virtual button offsets and see what I can do.

 

Link to comment
Share on other sites

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.