Jump to content
The simFlight Network Forums
Sign in to follow this  
mvanbrus

Lua problems.

Recommended Posts

Hello Pete,

 

I assigned Lua Log Lvars to button 10 and LuaKillAll on button 11. The Lua display windows pops up when  pressing button 10 and disappears when pressing button 11. Everything seems normal. If I press button 10 again Lua display opens up again but now the Simulator stop responding and I get a CTD. This happens with P3Dv2.1, P3Dv1.4 and FSX all on the same machine running Winpro8.1 and Fsuipcv4929c. I tried it on my laptop running Winpro8.1, P3Dv1.4 and Fsuipcv4929c with the same result. No Lua Log Lvars log gets created in the modules directory.

 

I tried another Lua plugin called "display vals" which does display values and stops normaly when pressing button 11. If I start it again with button 10 it works fine until I press button 11 to kill it. Then everything freezes and I get a CTD. Again this happens on my computer and also my laptop. Ran it with Admin rights and anti-virus turned off. No luck.

Any thoughts?

 

Martin

 

 

 

 

Share this post


Link to post
Share on other sites

I assigned Lua Log Lvars to button 10 and LuaKillAll on button 11. The Lua display windows pops up when  pressing button 10 and disappears when pressing button 11. Everything seems normal. If I press button 10 again Lua display opens up again but now the Simulator stop responding and I get a CTD. 

 

It is definitely not a good idea to "Kill" plug-ins if you can possibly avoid it. Depending on what that plug-in is doing it can cause hangs and crashes. I've attempted to eliminate them all, but I can only do so for the ones I can actually see or get details of -- with a CTD you should have all the details, the module name and the offset. So I can look at that.

 

But it still remains problematic. In order to allow the plug-in so much freedom over what they do there is a lot of time spent not IN the Lua interpreter itself, where a termination request can be quickly detected and acted upon, and in order to Kill the thread a forceful "kill thread" call to Windows is used. If this occurs in a critical place elsewhere, outside of the Interpreter, it can have unwanted consequences.

 

As I said, I've tried to interlock all of the places where this is the case but it is a never-ending task. I'll look at yours when I have the details, but i don't guarantee anything. I suggest that you modify the Lua plug-in to instead terminate itself on a flag being set, or, better using the event system.

 

No Lua Log Lvars log gets created in the modules directory.

 

 

Did you set the option for a separate log?

 

Pete

Share this post


Link to post
Share on other sites

FYI, I use the FSUIPC4 command "List Local Panel Variables". This will dump those into the current

FSUIPC4.log file.

 

Then I select the "new log" function from the menu. That will leave the FSUIPC4.log.1 in your

modules directory and you can then go in and remove all the non-Lvar stuff.

 

I use a 'find and replace' to strip out the leading space and the time stamp, leaving just the L:vars.

 

This method doesn't use Lua and I just un-map the button I assigned the "List all...." command to.

 

    Paul

Share this post


Link to post
Share on other sites

Peter,

 

The plugins are working and it does behave weird after you start them when you killed them before. So I won't do that again. Need help with this script.

 

 

function MCP(offset, value)

  if value == 1 then

     ext.run("C:\Prosim\ProSimMCP\ProsimMCP.exe")     -- does not work.??

  else

     ext.close("ProSimMCP")                                              -- does not work.??

  end

end

event.offset("5034"), "UB", "MCP") -- Offset "5034" is assigned by Prosim AC gate. Which works.

 

What am I doing wrong with ext.run and ext.close?

 

Martin

Share this post


Link to post
Share on other sites

The plugins are working and it does behave weird after you start them when you killed them before

 

Well there shouldn't be any difference as long as you aren't using any global values. Didn't you manage to get the Module name and address for the CTD you were getting, so i could look and see if I could nail that one?

     ext.run("C:\Prosim\ProSimMCP\ProsimMCP.exe")     -- does not work.??

Strings in Lua, same as in many other languages, use the '\' character as an escape, to allow non-graphics to be included, like "\r" for return, To include a real '\' you need two of them for each, i.e. \\.

     ext.close("ProSimMCP")                                              -- does not work.??

As documented, ext.close needs the handle returned by the ext.run function, not the program name . Please do check the documentation if you get an error as the explanation is often there.

event.offset("5034"), "UB", "MCP") -- Offset "5034" is assigned by Prosim AC gate. Which works.

You've got two many ')' characters there -- the first is not wanted.

 

Pete

Share this post


Link to post
Share on other sites

Hi Peter,

 

I have attached 4 files.

1) Windows event file. Showing system hang. Had to close it with Task Manager.

2) FSUIPC log. MCP.Lua does not work. Sorry I read the manual but just don't have enough programming skills to write those 2 lines ext.run and ext.close correctly. If I replace the 2 lines ext.run and ext.close lines with forexample with ipc.writeUB("029C",1) and ipc.writeUB("029C",0) then the pitot tupe heat on/off works fine. So the script works. Can you please show me the correct writing of those lines?

3)Log Lvars. is your plugin(I have not altered it) This hangs FSX or Prepar3d on a Winpro81 computer after a restart of the plugin in the sim.

4)MCP.lua.

 

 

I want to say a BIG thank you for the "Button Screen Facilities" Some problems with ALT and ESCAPE but will test it thoroughly before reporting problems.

 

Martin

 

F.zip

Share this post


Link to post
Share on other sites

1) Windows event file. Showing system hang. Had to close it with Task Manager.

 

I was expecting details of the CTD you reported. That report is not for a CTD of any kind, but a hang in Prepar3D.exe. I'm afraid there's no useful information for me. A CTD would be a proper crash -- a hang is not decipherable without using tools at the actual time.

 

2) FSUIPC log. MCP.Lua does not work. Sorry I read the manual but just don't have enough programming skills to write those 2 lines ext.run and ext.close correctly. If I replace the 2 lines ext.run and ext.close lines with forexample with ipc.writeUB("029C",1) and ipc.writeUB("029C",0) then the pitot tupe heat on/off works fine. So the script works. Can you please show me the correct writing of those lines?

 

In this line:

 

x=ext.run(c:\\Prosim\\ProSimMCP\\ProsimMCP.exe) 
 
you've correctly changed the single '\' characters to '\\', but inexplicably have removed the " at either end of the string which are needed to denote the string! Why?  All you needed to do was double the '\' characters as I explained! Why change things which were correct and as per documentation?

 

There's nothing wrong with the ext.close. Obviously it won't work till you get the ext.run correct!

 

It really isn't complicated. you just need to be more careful. Programming is like that -- computers are stupid, they can only process things you tell them precisely and correctly.

 

 

3)Log Lvars. is your plugin(I have not altered it) This hangs FSX or Prepar3d on a Winpro81 computer after a restart of the plugin in the sim.

 

I'll try it here, but this is a well used plug-in which has always worked perfectly in FSX so i'm concerned it is specific to the LVars in your particular aircraft. Is it an add-on, and if so, which?

 

Oh, and how did you restart it and why?

 

Pete

Share this post


Link to post
Share on other sites

3)Log Lvars. is your plugin(I have not altered it) This hangs FSX or Prepar3d on a Winpro81 computer after a restart of the plugin in the sim.

 

I've now managed to reproduce the hang which can occur when restarting this, and other Lua plug-ins which use the display facility. It appears to be a problem occurring deep within FS when an existing display is being updated whilst being created or destroyed. I'm working on interlocks in the calls being made, to try to prevent this, but I don't know if it is solvable at present. I know that if i change FSUIPC to never close the display there is no problem at all, you can kill and restart Luas as much as you like. However, it does obviously need to be closed when there's no further need -- so maybe that will be the answer but it makes it more complicated keeping track of it as a separate resource.

 

I will see what I can do but do not hold your breath! ;-)

 

Pete

Share this post


Link to post
Share on other sites

I will see what I can do but do not hold your breath! ;-)

 

Okay. It took a lot of delving. Simple interlocking did not help at all. But after a lot of hacking into Windows.DLL assembler code and finding where the windows handle is stored in the structures (via a pointer to a pointer to a pointer!), I think I've cracked it.

 

Please download FSUIPC4.929h.zip and try it with any Lua plug in displaying a window.. I've been testing it on both FSX Acceleration and P3D v2.2 Beta and have not made it hang yet.

 

Regards

Pete

Share this post


Link to post
Share on other sites

Hi Pete,

 

1) Lua display plug-in's are running fine now in both FSX and P3D. Great job. Send me some of your computer wisdom. :razz:

2) The ext.run and ext.close plug-in works! Had attached the wrong file. You would still have yelled because the reason the plug-in did not work was that I had typed ext-close which made the whole plug-in not work. That's why I had tried to run ext.run without the quotes. My bad. :oops:

 

Martin

Share this post


Link to post
Share on other sites

2) The ext.run and ext.close plug-in works! Had attached the wrong file. You would still have yelled because the reason the plug-in did not work was that I had typed ext-close which made the whole plug-in not work. That's why I had tried to run ext.run without the quotes. My bad. :oops:

 

When there's a syntax error in a plug-in you will get an error message in the FSUIPC log pointing to the line in error. That's where to look whenever something doesn't work as you'd hoped. I always test with FS (temporarily) in windowed mode and the FSUIPC log console window open to the side so I can see what's happening in real time.

 

Regards

Pete

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • 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.