Jump to content
The simFlight Network Forums

Recommended Posts

Posted (edited)

Dear Mr Dowson and dear FS community, my name is Zlatko ( friends call me Jack ).
Few months ago i bought  FSUIPC 3.999z9b registration
in order to be able to use Lua scripts and brush up an
old but trustworthy FS9 flightsim platform . I know how 
ridiculous it sounds, if today i ask you to provide tech support for such an old  
product . But the reason for me to communicate my problem here is in hope 
that the issues i experienced are already known
to the FS community and there is a work-around. Maybe i am just missing something obvious.

 Here is the problem itself- when i write Lua scripts, some of the offsets tend to work flowlessly 
but others crash the flight sim if they are used. Here is an example code with two offsets-one working and 
one crashing if used from Lua:

dev = com.open("COM3",115200,0)
  
   while 1 do

     vsOne = ipc.readSD("02C8")   -- CRASH'es FS9
     vsTwo = ipc.readSD("030C")   -- This one works well
     vsOne = (vsOne*60*3.28084)/256
     vsTwo = (vsTwo*60*3.28084)/256
 
       if (vsOne > 5000) then vsOne = 5000
       elseif (vsOne < -5000) then vsOne = -5000
       end

     sentence = string.format ("vert%04d", vsOne)

     com.write (dev, sentence)
     --ipc.log(sentence)
     ipc.display(sentence)
   
   ipc.sleep(20)
   end

Error Code when FS crash occur:

Problem Event Name:    APPCRASH
  Application Name:    fs9.exe
  Application Version:    9.0.0.30612
  Application Timestamp:    00534d69
  Fault Module Name:    FSUIPC.DLL
  Fault Module Version:    3.9.9.9
  Fault Module Timestamp:    56995c3b
  Exception Code:    c0000005
  Exception Offset:    0002c224
  OS Version:    6.3.9600.2.0.0.256.48
  Locale ID:    1026

I've already tryed all the problem solving routines i could thing of - there is only
one copy of FSUIPC within Modules Folder,  the OS is Windows 8.1, and FS9 is installed
on drive D   ( far enough from  'Program Files' ) . FS9 is started as Administrator.
 Exception Code c0000005  claims the problem is access violation, and i disabled
OS DEP ( data execution prevention) entirely, but problem still exists. Processor (intel core i3) is at
50 % and memory - at 20% busy when FS9 runs. There are no other add -ons instaled - just FS9 + FSUIPC 3.999z9b
registered.  
 The only thing (if my observation is right) to extend  clear period before crashes 
is keeping ipc sleep interval at maximum 
(when possible)  within the Lua script and simplifiyng the script itself up to only two or three rows of code.
 

 

 

Edited by Zlatko
Posted
1 hour ago, Zlatko said:

vsOne = ipc.readSD("02C8") -- CRASH'es FS9

To eliminate the Lua end, ry using FSInterrograte to read offsets directly? I think 036C, 0B18, 0BCC, 0BE8,  11BE use the same methods -- as far as I recall it's a request to the PANEL of the aircraft. Are you using an add-on aircraft of a default. If a default then I would suspect some corruption in your FS9 installation, maybe in FSUIPC3 itself.

Even if it is an FSUIPC3 bug,I'm sorry, but I'm afraid I'm well beyond any ability to find it and even less fix it. 02C8 is the current vertical speed and I'm sure many programs for FS9 must be reading it quite happily. The Lua support code to read offsts is no different fom one offset to another -- as I said, they are, by then, all simply numbers in memory, bo action is carried out. So it must the the part of FS which FSUIPC is calling.

[LATER]
Did some more research with some archives. Those variables depend on a "container" for the aircraft, where the latter is identified by an ID. The same data is read not only for the user aircraft (for those offsets) but also for all the AI traffic. So my TrafficLook program will be requesting the same values, albeit not from the same offsets. Another test, to check, in any case.

Pete

 

Posted (edited)

 

"To eliminate the Lua end, ry using FSInterrograte to read offsets directly?"   

 

This is the strangest part of the problem - FS9 and FSUIPC3.9 with all offsets work great on my system, when accessed  from FSInterrogate,  third party add-ons and interface programs, when they are talking to FSUIPC directly.  They could work happily for hours and days as you mentioned it.  It is the Lua part  - when i call one part of the offsets from a Lua script, they work great. When i attempt to read others,  Lua functionality  works for some time ( minutes, one hour or maibe more),  and i can see numbers being exported on the com port or logged within FSUIPC log file.  And then without a warning - bang - the OS is closing Flightsim and FSUIPC and reporting exception code:  c0000005  .

 Or maybe i am doing something wrong within Lua scripting . Am i over-driving the ipc. module by letting it to sleep for only 20 milliseconds?  ( in the lua script above) . The crash  seems to reappear faster when the script is more complex - like using  if ... end constructs ,  string formating , etc... And as i said - it happens only with reading some offsets and never happen when i read  others.  

 

 

Edited by Zlatko
Posted
48 minutes ago, Zlatko said:

This is the strangest part of the problem - FS9 and FSUIPC3.9 with all offsets work great on my system, when accessed  from FSInterrogate,  third party add-ons and interface programs, when they are talking to FSUIPC directly.  They could work happily for hours and days as you mentioned it.  It is the Lua part  - when i call one part of the offsets from a Lua script, they work great. When i attempt to read others,  Lua functionality  works for some time ( minutes, one hour or maibe more),  and i can see numbers being exported on the com port or logged within FSUIPC log file.  And then without a warning - bang - the OS is closing Flightsim and FSUIPC and reporting exception code:  c0000005 

Ah, so something in the mean time is corrupting something. I wish you'd told me it wasn't consistent in the first place.  It would have saved be delving into archives on another PC. You said

Quote

 

some of the offsets tend to work flowlessly 
but others crash the flight sim if they are used. Here is an example code with two offsets-one working and 
one crashing if used from Lua:

 

and that almost explicitly says "others crash ... if they are used".

Never mind. 

48 minutes ago, Zlatko said:

Or maybe i am doing something wrong within Lua scripting

Not if it works some of the time.

48 minutes ago, Zlatko said:

Am i over-driving the ipc. module by letting it to sleep for only 20 milliseconds?  ( in the lua script above) . The crash  seems to reappear faster when the script is more complex - like using  if ... end constructs ,  string formating , etc... And as i said - it happens only with reading some offsets and never happen when i read  others.  

I suppose it could be a timing glitch, catching FS9 when it isn't able to respond to the request for a Container pointer for the panel. You're not changing aircraft whilst this is going on I hope?

The only way to tell if it is timing would be to slow it down. 

You could try using FSInterrogate for a similar batch of offsets and having that repeat fast, too, just to see.

Otherwise, it it isn't an FS9 timing problem -- FSUIPC asking for something not possible at that time, or maybe asking for it before the previous response is provided, then it definitely seems like some corruption is occurring, but, i'm sorry, there's no way I can track it down.  Do you have FSX? If you can reproduce it with your Lua plug-in on FSXthen it must be related t the Lua interpreter and I can maybe get an idea of what it is, even if i can't fix it on FS9.

Pete

 

Posted (edited)

Ahh.,  now i can clearly see how i misled you  in the beginning - first with the title and second - with my initial post - Sorry about that.   Today  i selected a batch of  offsets that seem to be involved in the Lua Problem ( 02C8 , 3BE7 , 0B71 , 0B6E , 0366 ) and
i ran a test - FSInterrogate reading them pretty fast  in a loop directly from FSUIPC3. I left the test to run
for good two hours or more and there was no FS9 crash or any other problem whatsoever.  Now the finger is pointing back to the Lua part.  But that is all right - i don't fixate  my self to what i can't do with Lua for the moment. I am pretty happy with that part i can do.   
  Regards
 Zlatko 

 

Edited by Zlatko
Posted
22 hours ago, Zlatko said:

Now the finger is pointing back to the Lua part.

If you have a small Lua plug-in which gives the problem, and which I can run here with P3D, then maybe I can work out why. The Lua interpreter coding is very similar -- identical for the most part.

Pete

 

Posted

That one below is crashing FS9 almost instantly after the start:

vsOneOld = 2001
   dev = com.open("COM3",115200,0)
   
    while 1 do

      vsOne = ipc.readSD("02C8")   
      vsiFail = ipc.readUB("3BE7")
     
      vsOne = (vsOne*60*3.28084)/256
     
       if ( vsiFail == 1 ) then vsOne = 0
       elseif (vsOne > 2000) then vsOne = 2000
       elseif (vsOne < -2000) then vsOne = -2000
       end
       vsOne = vsOne + 2000

       if (vsOne ~= vsOneOld)  then 
            sen = string.format ("vs%04d", vsOne)
            com.write (dev, sen)
            --ipc.log(sen)
            ipc.display(sen)
        vsOneOld = vsOne
        end
   
   ipc.sleep(20)

I hope , that i am not causing too much trouble  😞 The airplane i am using is the default Cessna172 .

PS- I checked just now , it happens also with the rest of the default airplanes selected

 

 

Posted
1 hour ago, Zlatko said:

That one below is crashing FS9 almost instantly after the start:

Okay. I need to know first whether it still crashes if you comment out the com stuff (com.open abd com-write lines). Otherwuse I would need to find some way of making one of my COM ports valid.

Also, I assume there's and 'end' at the end?

Pete

 

Posted

  Somehow missed that 'end' when copy -pasted the code here.  I actually already did the test with eliminating the com port, but just to be sure that i am not missing something, i commented those parts again  

--dev = com.open("COM3",115200,0)

and 

--com.write (dev, sen)

and it crashed again. Then i commented all 

            --dev = com.open("COM3",115200,0)
            --com.write (dev, sen)
            --ipc.log(sen)
            --ipc.display(sen)

but crashed again. And then i did the opposite  test - re-enabled the com port, but exchanged  02C8 offset with another one extracting vertical speed data  030C ( i know that one works ), also commented 3BE7  

      vsOne = ipc.readSD("030C")   
      --vsiFail = ipc.readUB("3BE7")
and inadvertent FS9 crashes stopped. Both 02C8 and 3BE7 , when used within Lua  plug-in  (in pair or on their own) are making the problem to re-appear   . And there are some more like them. The problem is really really strange one .  The 'clear time' before FS9 crashes is getting much shorter, when more of those are placed and called  within the same lua plug-in,  compared to occasions when only one sensitive offset is used. 

 

Posted
On 9/20/2018 at 9:14 AM, Pete Dowson said:

I'll try the original here, on P3D, without the COM stuff, probably later today. 

Well it runs and runs and runs on P3D and FSX. I am pretty sure it isn't specifically a Lua interpreter bug. I think it is some glitch.  And it must be very timing related.  It could also be something to do with the fact that the Lua plug-in is running in a separate thread asynchronously from the offset reading part which has to be in the in FS9 thread in order to call correctly the internals.

Sorry, I've really got no more ideas.  BUT I think you should be using events rather than a tight loop. It looks like you only need those values when they change. the rest of the time your plug-in need not do anything. For example, converting your code over to using events:

By all means try that. If it still doesn't work, why not use 0x30C instead, which you did mark as "ok".

dev = com.open("COM3",115200,0)
vsOne = 0
vsTwo = 0
  
function checkvals(off, val)
    
	if off == 0x028C then
		vsOne = (val*60*3.28084)/256
 	else if off == 0x030C then
		vsTwo = (val*60*3.28084)/256
 	end
	
	if vsOne > 5000 then vsOne = 5000
	elseif vsOne < -5000 then vsOne = -5000
	end

	sentence = string.format ("vert%04d", vsOne)

	com.write (dev, sentence)
	--ipc.log(sentence)
	ipc.display(sentence)
   
end

event.offset(0x02C8, "SD", "checkvals")
event.offset(0x030C, "SD", "checkvals")

By all means try that. If it still doesn't work, why not use 0x30C instead, which you did mark as "ok".

Sorry not to be able to solve the original problem.

Have you ever thought of moving on a bit? FSX, FSX-SE, even P3D?

Pete

 

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.