Jump to content
The simFlight Network Forums

FSUIPC crashes


Recommended Posts

Hi,

 

basically I want to sync throttles in a twin-engine setup so that I can change between individial throttles and throttle1 controlling the power input for both engines on a button press.

 

I know that FSUIPC provides the possibility to define a keyboard shortcut for exactly this problem. However, I do not use a reverse zone on my throttles, so when the throttles are moved individually, everything is fine and pulling back the throttles all the way will result in idle, but when switching to single-throttle control via the FSUIPC functionality the throttles move through the whole range, including reverse. That is not what I want, and I didn't find anything to change this behavior. Maybe someone has a good idea here.

 

So, what I came up with are the following two LUA scripts, assigned to the respective throttle axes:

 

throttle1 LUA:

 

-- read if sync is requested or not

sync = ipc.readUB(0x66C0)

if (sync == 0xFF) then

-- sync requested. Copy throttle1 value to throttle control: AXIS_THROTTLE_SET

  ipc.control(65765, ipcPARAM)

else

-- default behavior: forward to throttle1 control: AXIS_THROTTLE1_SET

  ipc.control(66420, ipcPARAM)

end

 

 

throttle2 LUA:

 

-- read if sync is requested or not

sync = ipc.readUB(0x66C0)

if (sync == 0) then

-- no sync: just forward to throttle2 control: AXIS_THROTTLE2_SET

  ipc.control(66423, ipcPARAM)

end

-- do nothing if sync is requested

 

A controller button is assigned to toggle the offset at 0x66C0 with xFF

 

The whole thing appears to work nicely and does what I want, but I occasionally get nasty crashes of FSX when toggling to single-throttle and moving the axes:

 

Faulting application name: fsx.exe, version: 10.0.61472.0, time stamp: 0x475e17d3

Faulting module name: FSUIPC4.dll, version: 4.9.0.9, time stamp: 0x51dd33be

Exception code: 0xc0000005

Fault offset: 0x00061476

Faulting process id: 0x21cc

Faulting application start time: 0x01ce8651cfedf981

Faulting application path: C:\FS\FSX\fsx.exe

Faulting module path: C:\FS\FSX\Modules\FSUIPC4.dll

Report Id: 7a0a7f53-f245-11e2-ac4f-f46d040055e1

 

When taking away the LUAs from the axis and just running the usual axis assignments (either "send direct to FSUIPC" or 

"send to FS as normal axis"), I don't get any crashes.

 

My system is Windows 7 professional SP1 with all up-to-date patches, FSX SP2.

 

Any idea? What's wrong with my scripting?

 

Thanks 

 

Dave
Link to comment
Share on other sites

basically I want to sync throttles in a twin-engine setup so that I can change between individial throttles and throttle1 controlling the power input for both engines on a button press.
I know that FSUIPC provides the possibility to define a keyboard shortcut for exactly this problem.

 

Not a "keyboard shortcut". FSUIPC supplies additional controls which can be assigned to button or key just like any other control.

 

However, I do not use a reverse zone on my throttles, so when the throttles are moved individually, everything is fine and pulling back the throttles all the way will result in idle, but when switching to single-throttle control via the FSUIPC functionality the throttles move through the whole range, including reverse.

 

 

 

That's not the throttle sync control, then. I'm afraid you'll need to be more specific.  If you've selected "no reverse zone" then that's what you get, it doesn't suddently change to a setup with a reverse zone just because it is syncing. That would make no sense whatsoever.

 

The whole thing appears to work nicely and does what I want

 

Hmm. It appears to be almost a Lua version of exactly what the throttle sync control does in FSUIPC, except that you are using both the generic AND the separate throttle controls, which isn't a terribly good idea.  Best to send the same value to Throttle 1 and 2 instead, as FSUIPC would do for you. If you don't do this your calibration, which is separate for generic and separate axes, would need very careful settings to avoid a sudden difference when you switch.

 

I am not sure without cross-checking in the code, but I've a feeling that the FSUIPC sync balances to a value between the two axes, though it may do as you are doing and merely copy throttle 1 axis. Are you not moving the throttle 2 axis at all when you operate this option? Why and when are you using it anyway?

 

...but I occasionally get nasty crashes of FSX when toggling to single-throttle and moving the axes:
 
Hmm. That's odd. I see no reason for that. Perhaps you could please tell me EXACTLY how you've assigned to these Lua modules? I'd need also to know whether you are still using both throttle levers or only one when you switch, and whether there's observable jitter on your axes which could be causing the Lua modules to be continuously loaded, compiled, executed and killed. Maybe you've reduced the Delta in the assignments?
 
The crash information is useful, and I'll get on to that in the morning. About to have dinner...
 
Regards
Pete
Link to comment
Share on other sites

Hi Pete,

 

thanks for your swift reply. Enjoy dinner now :smile:

 

So, I'll try and be more specific:

 

As for the first part:

 

I first had two axes assigned:

Throttle1: "send direct to FSUIPC Calibration", assigned as "Throttle1"

Throttle2: "send direct to FSUIPC Calibration", assigned as "Throttle2".

 

Calibration is done in "3 of 11: Separate Throttles per engine", and "No reverse Zone" is ticked.

 

Under the "Hot Keys" tab, I assigned a keyboard shortcut for "Multiple throttle synchronization", say Ctrl-W.

 

Now, when moving the assigned throttles without having pressed Ctrl-W, everything is fine. When pressing Ctrl-W, the throttle 1 axis will indeed move both throttles in sync, but travelling through the range *including" reverse. So, pulling the throttle all the way back will not be idle as with the separate throttles, but full reverse.

(The specific addon is the RealAir Turbine Duke, btw, but it also behaves like that in other addons).

 

 

Second (LUA) part:

 

I did already try and copy the value from throttle1 to throttle2 without using the generic throttle control, but it proved equally unreliable.

I wouldn't mind a sudden slight change when switching, but it should not crash.

 

Concerning the LUA assignment of the axes:

In FSUIPC, on the "Axis Assignment" tab, I used "Rescan" and moved the respective control to get the appropriate axis, under "Type of action required" I chose "Send to FS as normal axis" and in the dropdown I selected "Lua TH1" for the Throttle1 axis and "Lua TH2" for the Throttle2 axis (the LUA files were named TH1.lua and TH2.lua respectively).

 

When operating in "sync" mode, I do use both throttle controls. I know it is not necessary, but I want to maintain the feeling of dual-engine controls, hence the "dead" throttle2 control is used along with the throttle1 control.

 

There is some jitter in the throttle controls, but It doesn't occur excessive to me.

 

As for the Delta in the assignments, I didn't (knowingly) do anything there. Delta says 256.

 

In case you need more information, I'm standing by.

Regards

 

Dave

Link to comment
Share on other sites

Under the "Hot Keys" tab, I assigned a keyboard shortcut for "Multiple throttle synchronization", say Ctrl-W.

Now, when moving the assigned throttles without having pressed Ctrl-W, everything is fine. When pressing Ctrl-W, the throttle 1 axis will indeed move both throttles in sync, but travelling through the range *including" reverse. So, pulling the throttle all the way back will not be idle as with the separate throttles, but full reverse.

 

Okay. I've verified this. it is a bug! A VERY long-standing bug that no one has reported before. Had you reported it before venturing into other solutions I would have tried to fix it immediately, and will do so now. Unfortunately it may take me a few days as I have other commitments this week. But watch for updates maybe before, or over, the weekend.

 

I'm looking at the crash report now.

 

Pete

Link to comment
Share on other sites

Okay. I've verified this. it is a bug! A VERY long-standing bug that no one has reported before. Had you reported it before venturing into other solutions I would have tried to fix it immediately, and will do so now. Unfortunately it may take me a few days as I have other commitments this week. But watch for updates maybe before, or over, the weekend.

 

I'm looking at the crash report now.

 

Pete

 

Ok. Thanks a lot. Looking forward to an updated fsuipc.dll :-)

If I understand you correctly, fixing the multiple throttle sync will make my LUA scripting obsolete.

 

That would still leave me with the question why the LUA version crashes.

 

Regards

Dave

Link to comment
Share on other sites

Ok. Thanks a lot. Looking forward to an updated fsuipc.dll :smile:

 

Decided to stay up late last night and get it out of the way. Too hot here in daytime in any case! Try 4.909a for me please, from this link:

 

FSUIPC 4.909a only

 

This is a pre-release -- I probably won't be making a formal release till next week. I need to apply the changes to FSUIPC3 as well, and test that.

 

If I understand you correctly, fixing the multiple throttle sync will make my LUA scripting obsolete.

 

Yes, if you change back to using the Throttle Sync hotkey -- or the new more efficient Throttlesync on, Throttlesync off, or Throttlesync toggle controls I've now added (the ones I thought I'd implemented ages ago -- and in fact had done so but stupidly omitted them from the list which makes them appear in the drop-down assignments list!)

 

That would still leave me with the question why the LUA version crashes.

 

I located exactly where it was happening, but not exactly why. It's all to do with overlapping continuous executions of the same Lua files. Each time the axis changes the Lua text file is loaded, compiled and executed. If this happens frequently enough and the execution process is slow enough, FSUIPC has to forcibly kill the thread so it can be re-executed. Not nice. There are precautions taken in many places to make sure this doesn't lead to "dangling pointers" (non-zero pointers to objects which no longer exist), but I think you might have hit upon one case not adequately covered. I tried doing exactly the same as you here, using your very Lua files, and no ending of switching back and forthwith the Sync and waggling the throttle axes would induce a crash, so it is very timing dependent. But in any case I've tried to make it more bullet-proof.

 

With that in mind, could you please thoroughly test 4.909a with your current setting before changing back to the way it should be, and see if you can induce the crash. or not. Thanks.

 

BTW it was because of this sort of problem, and the inefficiencies or repeatedly loading and compiling plug-ins, that I introduced the Event system. The better event-driven way of implementing your plug-ins would be to have a function doing the processing, and an event.param to call it. You'd then assign the axes to "Luavalue THR1" and "Luavalue THR2", which instigates the events and thereby executes the function which is held permanently in memory and simply suspended awaiting such events. (You'd need to get the plug-ins pre-loaded then, either via ipcReady.lua calls or entries in an [Auto] section in the INI).

 

I didn't want you to make such changes before I tackled the crash problem, though.

 

No rush for the test results -- by the weekend would be fine, thanks.

 

Regards

Pete

Link to comment
Share on other sites

Thanks for the update. I'll try my best to get some results by the weekend. Work currently keeps me busy and away from simming.

 

That event mechanism sounds good. I remember reading about events in the documentation but I've never paid any closer attention to them so far.

I may have an incentive to do so now, since I'm thinking about making a sync functionality for prop and mixture controls as well.

 

Regards

Dave

Link to comment
Share on other sites

Hi

 

Maybe I have a similar problem with the version 4.90.

 

I have FSX with acc pack, Win 7/64, Aerosoft Airbus A320, CH Products Thorttle Quandrant.

Radomly I got CTD when moving the throttles configured with FSIUPC. I tryed to rescan and recalibrate the throttles but sometimes something wrong happes that causes FSX to crash. The only thing that I have ist the description (in german) of the Application Error:

 

Name der fehlerhaften Anwendung: fsx.exe, Version: 10.0.61637.0, Zeitstempel: 0x46fadb14
Name des fehlerhaften Moduls: FSUIPC4.DLL, Version: 4.9.0.0, Zeitstempel: 0x51862b2f
Ausnahmecode: 0xc0000005
Fehleroffset: 0x00060ade
ID des fehlerhaften Prozesses: 0x47c
Startzeit der fehlerhaften Anwendung: 0x01ce87cab8237ac3
Pfad der fehlerhaften Anwendung: C:\Program Files (x86)\Microsoft Games\Microsoft Flight Simulator X\fsx.exe
Pfad des fehlerhaften Moduls: C:\Program Files (x86)\Microsoft Games\Microsoft Flight Simulator X\Modules\FSUIPC4.DLL
Berichtskennung: 7e1574d7-f3c1-11e2-8a35-14dae94331e0
 
Link to comment
Share on other sites

Maybe I have a similar problem with the version 4.90.

 

 

So, did you try 4.909a? If not why not, if you are using similar Lua plug-ins for your throttles?

 

Radomly I got CTD when moving the throttles configured with FSIUPC. I tryed to rescan and recalibrate the throttles but sometimes something wrong happes that causes FSX to crash. The only thing that I have ist the description (in german) of the Application Error:

 

 
I'm afraid that information is not useful as we have moved on and the offsets do not relate. You need to always test with the latest. Try 4.909a.
 

 

 

That seems to be a long thread with lots of suggestions and solutions. Does it list the Lua plug-ins being used anywhere? I don't have time to read it all at present.

 

Regards

Pete

Link to comment
Share on other sites

I may have an incentive to do so now, since I'm thinking about making a sync functionality for prop and mixture controls as well.

 

The existing FSUIPC Throttles Sync facilities can be applied to those too, automatically. It's an option on the Miscellaneous options tab.

 

Regards

Pete

Link to comment
Share on other sites

The existing FSUIPC Throttles Sync facilities can be applied to those too, automatically. It's an option on the Miscellaneous options tab.

 

Regards

Pete

 

Very good. Then no coding required from my side at all.

You make me a happy man :-)

Link to comment
Share on other sites

Hi Pete,

 

I've started trying 4.909a tonight. I even added more lua files in the same way to sync props and mixture axes in order to increase the probability of a crash. 

So far I could yank the axis controls any way I want with no crash. Let's see how this is going after some more stress testing.

 

I also had a quick look into the controls section and found the Throttlesync toggle/on/off assignments. However, I didn't find anything for mixtures and props.

Is that in yet?

 

Regards

Dave

Link to comment
Share on other sites

Hi Pete,

 

I got a crash again. Version 4.909a, although it says 4.909 in the crash log:

 

Faulting application name: fsx.exe, version: 10.0.61472.0, time stamp: 0x475e17d3
Faulting module name: FSUIPC4.dll, version: 4.9.0.9, time stamp: 0x51ee3e7d
Exception code: 0xc0000005
Fault offset: 0x000615ef
Faulting process id: 0xee8
Faulting application start time: 0x01ce8972bfeb5a07
Faulting application path: C:\FS\FSX\fsx.exe
Faulting module path: C:\FS\FSX\Modules\FSUIPC4.dll
Report Id: 90703c92-f566-11e2-906a-f46d040055e1
 
Happened when moving throttles, then pressing button to activate sync on my lua scripts, then moving throttles again.
 
Regards
Dave
Link to comment
Share on other sites

Hi Pete,

 

I've started trying 4.909a tonight. I even added more lua files in the same way to sync props and mixture axes in order to increase the probability of a crash. 

So far I could yank the axis controls any way I want with no crash. Let's see how this is going after some more stress testing.

 

I also had a quick look into the controls section and found the Throttlesync toggle/on/off assignments. However, I didn't find anything for mixtures and props.

Is that in yet?

 

Regards

Dave

nevermind. I found it.

Link to comment
Share on other sites

 

Hi Pete,

 

I got a crash again. Version 4.909a, although it says 4.909 in the crash log:

 

Faulting application name: fsx.exe, version: 10.0.61472.0, time stamp: 0x475e17d3
Faulting module name: FSUIPC4.dll, version: 4.9.0.9, time stamp: 0x51ee3e7d
Exception code: 0xc0000005
Fault offset: 0x000615ef
Faulting process id: 0xee8
Faulting application start time: 0x01ce8972bfeb5a07
Faulting application path: C:\FS\FSX\fsx.exe
Faulting module path: C:\FS\FSX\Modules\FSUIPC4.dll
Report Id: 90703c92-f566-11e2-906a-f46d040055e1
 
Happened when moving throttles, then pressing button to activate sync on my lua scripts, then moving throttles again.
 
Regards
Dave

 

 

Drat. I thought I might have nailed it. I wish I could reproduce it here. I'll have another look in the next few days.

 

Pete

Link to comment
Share on other sites

I got a crash again. Version 4.909a, although it says 4.909 in the crash log:

 

Working a bit in the dark here, without being able to reproduce it, but I suspected it might be related to the thread execution terminating naturally at the same time as it is being killed for the next try. I think there's a small chance of an overlap there where some things are already closed. I've added more critical sections to try to lock those out from each other. It's a bit of a trial and error process with your system being my only way of testing. Sorry, but could you see if you can make FSUIPC4909b crash, using the same Luas?

 

Thanks!

 

Pete

Link to comment
Share on other sites

Working a bit in the dark here, without being able to reproduce it, but I suspected it might be related to the thread execution terminating naturally at the same time as it is being killed for the next try. I think there's a small chance of an overlap there where some things are already closed. I've added more critical sections to try to lock those out from each other. It's a bit of a trial and error process with your system being my only way of testing. Sorry, but could you see if you can make FSUIPC4909b crash, using the same Luas?

 

Thanks!

 

Pete

 

I'll try the new version this weekend.

 

Regards

Dave

Link to comment
Share on other sites

Hi Pete,

OK, I haven't had any crashes with the 4.909b version this weekend.

The controls respond a little jerky now which probably is due to the fact that you put in some more critical sections for thread sync. Sometimes, the system seems to "think" for a split second before the throttles react to new input from the controllers. However, like I said, no crashes.

 

Regards

 

Dave

Link to comment
Share on other sites

The controls respond a little jerky now which probably is due to the fact that you put in some more critical sections for thread sync. Sometimes, the system seems to "think" for a split second before the throttles react to new input from the controllers. However, like I said, no crashes.

 

Hmm. So I hit the correct spot.  But I don't like it being jerky. Of course, the best solution is to use the Event method instead, as already explained. But I'll have a think about how to alleviate the timing problems with the "kill/restart" method.

 

Thanks for the testing. If I do thing of anything to improve it would you still test it for me, please?

 

Pete

Link to comment
Share on other sites

Hi Pete,

 

I discovered another thing in connection with FSUIPC's own throttle sync, not the lua stuff:

 

When assigning a controller axis to be the reverser axis (FSUIPC -> axis assignment, move axis and choose "send direct to FSUIPC calibration", then "reverser"), this controller axis works ok as long as the throttle sync is not active, i. e. when properly calibrated, the controller axis will move from throttles idle to full reverse.

 

However, then throttle sync is active, the reverser axis just behaves like a normal throttle axis, i. e. it moves all throttles from max power to idle.

 

Can you observe that behavior too?

 

Regards

Dave

Link to comment
Share on other sites

Hmm. So I hit the correct spot.  But I don't like it being jerky. Of course, the best solution is to use the Event method instead, as already explained. But I'll have a think about how to alleviate the timing problems with the "kill/restart" method.

 

Thanks for the testing. If I do thing of anything to improve it would you still test it for me, please?

 

Pete

sure. Please also have a look at my post #21.

 

Thanks

 

Dave

Link to comment
Share on other sites

When assigning a controller axis to be the reverser axis (FSUIPC -> axis assignment, move axis and choose "send direct to FSUIPC calibration", then "reverser"), this controller axis works ok as long as the throttle sync is not active, i. e. when properly calibrated, the controller axis will move from throttles idle to full reverse.

 

However, then throttle sync is active, the reverser axis just behaves like a normal throttle axis, i. e. it moves all throttles from max power to idle.

 

Can you observe that behavior too?

 

Hmm. Strange. I'll check. Tomorrow, though.

 

Pete

Link to comment
Share on other sites

Hmm. Strange. I'll check. Tomorrow, though.

 

Okay. Verified the problem, that reverser axes operate like normal throttles instead when "throttlesync" is engaged.

 

It turned out to be an almost impossible problem to resolve fully. The reverser axis implementation is really a sort of "front end" on the normal throttle actions, converting the calibrated value into a negative throttle value before using the normal throttle facilities. So it all becomes totally indistinguishable. Without a complete redesign of the whole axis assignment and calibration system -- which I am simply not going to risk at this stage -- the only safe way is to automatically disable "throttlesync" when a reverser axis is used.

 

I think this will be okay. I'll document it so folks know. If you need to use throttle sync again after landing and using reverse you'll just need to enable it again.

 

I'm looking now at ways of making the kill/restart sequence for Lua plug-ins smoother. I don't guarantee to resolve this -- but there again the better solution for such needs is to use the event system in any case. Still, I have some ideas which I'll try. I'll let you know when there's a version 4.909c to test for me.

 

Regards

Pete

Link to comment
Share on other sites

I'm looking now at ways of making the kill/restart sequence for Lua plug-ins smoother

 

I've given up on this. There looked to be a way, and I part implemented it and tested it, but it is far too complicated and involves other changes all over the place, so I'm classifying it as "too risky" and "not worth it", especially considering there are other solutions.

 

One thing you could try, to see if it's a little less jerky, is reduce the rerun delay. Here's the section of the FSUIPC advanced user's guide which describes this:

 

LuaRerunDeley=66: This parameter sets the time, in milliseconds, which is imposed between re-runs of the same Lua

plug-in. It is a safety precaution against repetitive execution causing an FS crash by stack overflow. For plug-ins which

take more than that amount of time to load and execute this effectively restricts the repeat rate from dials to 15 times per

second. The rate from buttons or keypresses being held down was already restricted as for those the repeat is not effective

until the current plug-in execution finishes.

 

 

I suspect though that since the execution time of those little Lua plug-ins will be much much less than 66 mSecs in any case, this will actually not have any affect.

 

I'll upload 4.909c soon with the reverser fix.

 

Pete

 

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.