Zoolander64 Posted April 17, 2010 Report Posted April 17, 2010 Greetings All, First time posting, long time user of FSUIPC. Over the years I have found this to be a wonderful tool for FSX and earlier versions. I thank Pete for his wonderful efforts. I have recently started creating lua files to learn something new. I am impressed on what can be done, and want to keep at it. I have created a script that cycles through the various views that have been created by another product called EZdok. It simulates the default FSX "S", "Shift-S","A", Shift-A" keys along with tracking and turning on/off TrackIR and EZdok at the appropriate times. So far I have it working very well, except for one command. I am using ipc.get and ipc.set. ipc.set works perfect, but having a little difficulty with ipc.get. It functions as it should for a few passes, but it will eventually crash FSX. I created, separate from my script, a tiny lua that only has the following commands: while 1 do y=0 x = ipc.get("y") ipc.sleep(200) end Not very useful, but suffice for narrowing down my issue. I set this up to repeat (4=CR(-0,5)0,20,CL1:R,0 ; My Test) when I hold down a button on my joystick. In about 30 seconds FSX crashes. I am using the "R" repeat since I believe I read that the lua will complete before starting the next one and not leave a thread hanging. I am curious as what I am doing wrong with using the command. I would appreciate any help I can get. Thanks in advance. -Todd
Pete Dowson Posted April 17, 2010 Report Posted April 17, 2010 I am using ipc.get and ipc.set. ipc.set works perfect, but having a little difficulty with ipc.get. It functions as it should for a few passes, but it will eventually crash FSX. It isn't specifically ipc.get() which crashes FSX. In your scenario you are creating hundreds of threads, each one running the same Lua program. Eventually this crashes FSX because it cannot create any more threads for its own purposes. Look: I created, separate from my script, a tiny lua that only has the following commands:while 1 do y=0 x = ipc.get("y") ipc.sleep(200) end That's a Lua program which never terminates of its own accord. Not very useful, but suffice for narrowing down my issue. I set this up to repeat (4=CR(-0,5)0,20,CL1:R,0 ; My Test) when I hold down a button on my joystick. And because the never-ending program is "sleeping" most of the time, ignoring any attempt to do anything with it, even though every time FSUIPC tries to delete it and restart it, on one of your repeated button presses, it takes longer for Windows to forcibly terminate it than it does to create the new thread. The end result is ... In about 30 seconds FSX crashes. because of the accumulation of threads sitting in uninterruptible "sleeps" waiting to be terminated. I am using the "R" repeat since I believe I read that the lua will complete before starting the next one and not leave a thread hanging. But your Lua program never completes. Even if it did it is incommunicado most of the time (200 mSecs out of about 201). I am curious as what I am doing wrong with using the command. It is nothing to do with any particular command. I am puzzled as to what you are trying to do. Why would you want to keep reading a global variable in a never-ending loop, and, not only that, keep doing so repeatedly on a button being held? If you'd like to explain what it is you are really trying to do, maybe I can advise you on a sensible way to do it? Never ending Lua loops are okay providing they are just loaded once and left to do their job. To keep calling them over and over seems odd when they are running already and still doing the same thing. What's the point? Regards Pete
Zoolander64 Posted April 17, 2010 Author Report Posted April 17, 2010 Greetings Pete, Thanks for taking the time, and on a weekend, to review my feeble attempt at lua. Okay, what you are saying makes perfect sense, and I kinda expected I was getting into thread issues. What I sent was just a sample, of what I thought narrowed done the issue, but I see now this is not the case. Thanks for your explanation. So, since you asked, let me show what I am really trying to do. Below is my actually code for my ini and lua files. I have EZdok and TrackIR. They do not work well with each other. I am tracking the state of each and want to to turn off one, and turn on the other. I am also simulating the default FSX "A" and "Shift-A" since EZdok does not have a view cycle command. I am using the ipc.get and ipc.set commands to remember the last states of TrackIR, Ezdok, and the current view. Note: I have just learning this programming language, and there may be a completely different and better(read as more efficient) way to do this. This is my first attempt. Any advice would be greatly appreciated. -Todd [Buttons] ButtonRepeat=20,10 0=; Joystick - Mode 1 - Normal Flight 1=CP(-0,5)0,4,CL1:R,1 ; TrackIR enable/disable 2=CP(-0,5)0,19,CL1:R,10 ; VC View 3=CR(-0,5)0,22,CL1:R,5 ; Prev View 4=CR(-0,5)0,20,CL1:R,6 ; Next View 5=CR(-0,5)0,21,CL1:R,8 ; Next Catagory -- **************************************** -- -- My EZdok & FSX View Tracking Script -- version: 1.0 -- -- **************************************** -- Passing Parameters -- 0 = Initialize -- 1 = TrackIR enable/disable -- 2 = EZdok state tracking -- 3 - View Next in current catagory -- 4 = View Prev in current catagory -- 5 = View Next Catagory -- 6 = View Prev Catagory -- **************************************** -- Public Variables iMaxView = {12,21} -- EZdok custom views = 10,11,12 VC views & 20,21 outside view (increment when adding new views) iView = {} -- Saved EZdok custom view states iMaxEZCat = 2 -- 2 EZdok catagories (increment when adding new catagories) iMaxCat = iMaxEZCat + 3 -- 2 EZdok catagories + 3 FSX catagories -- **************************************** -- Public Subroutines -- Toggle between 0 and 1. function toggle (iStatus) if iStatus == 0 then return 1 else return 0 end end -- Change TrackIR state -- 0=disabled, 1=enabled, -1=toggle function TrackIREnable(iNewState) -- Get saved state iCurrentState = ipc.get("TrackIR_enabled") -- Check for no previous initialization and assume enabled state if iCurrentState == nil then ipc.set("TrackIR_enabled",1) return end -- Check for toggle if iNewState == -1 then iNewState = toggle(iCurrentState) end -- Send keystroke ONLY if state changed if iNewState ~= iCurrentState then ipc.keypress(120,8) ipc.set("TrackIR_enabled",iNewState) end end -- Change EZdok state -- 0=disabled, 1=enabled, -1=toggle function EZdokEnable(iNewState) -- Get saved state iCurrentState = ipc.get("EZdok_enabled") -- Check for no previous initialization and assume enabled state if iCurrentState == nil then ipc.set("EZdok_enabled",1) return end -- Check for toggle if iNewState == -1 then iNewState = toggle(iCurrentState) end -- Send keystroke ONLY if state changed if iNewState ~= iCurrentState then ipc.keypress(68,8) ipc.set("EZdok_enabled",iNewState) end end --- Select Aircraft View function ShowView(iNewView) TrackIREnable(0) EZdokEnable(1) -- EZdok VC Forward if iNewView == 10 then ipc.keypress(104,2) -- EZdok VC Left elseif iNewView == 11 then ipc.keypress(103,2) -- EZdok VC Right elseif iNewView == 12 then ipc.keypress(105,2) -- EZdok Outside 1 elseif iNewView == 20 then ipc.keypress(100,2) -- EZdok Outside 2 elseif iNewView == 21 then ipc.keypress(102,2) end end -- **************************************** -- Main -- Get the last catagory index, 1=EZdok VC, 2=Ezdok Outside, 3-5 FSX iCat = ipc.get("LastCat") if iCat == nil then iCat = 1 end -- Get the last EZdok VC view iView[1] = ipc.get("LastView10") if iView[1] == nil then iView[1] = 10 end -- Get the last EZdok outside view iView[2] = ipc.get("LastView20") if iView[2] == nil then iView[2] = 20 end -- 0 = Initialize if ipcPARAM == 0 then --Nothing needed here yet end -- TrackIR, -1 = disable, 1 = enable if ipcPARAM == 1 then TrackIREnable(-1) -- Prev View (EZdok) elseif ipcPARAM == 5 and iCat <= iMaxEZCat then -- Decrement to the previous view. If at first EZdok view, -- wrap back to last view iView[iCat] = iView[iCat] - 1 if iView[iCat] < iCat*10 then iView[iCat] = iMaxView[iCat] end ShowView(iView[iCat]) -- Prev View (FSX) -- "Shift-A", as assigned in FSX elseif ipcPARAM == 5 then -- Just issue the keystroke since we dont need to track FSX views. ipc.keypress(65,1) -- Next View (EZdok) elseif ipcPARAM == 6 and iCat <= iMaxEZCat then -- Increment to the next view. If at last availabe EZdok views -- wrap back to first view iView[iCat] = iView[iCat] + 1 if iView[iCat] > iMaxView[iCat] then iView[iCat] = iCat * 10 end ShowView(iView[iCat]) -- Next View (FSX) -- "A", as assigned in FSX elseif ipcPARAM == 6 then -- Just issue the keystroke since we dont need to track FSX views. ipc.keypress(65,8) -- Prev Catagory (EZdok & FSX) elseif ipcPARAM == 7 then -- Decrement catagory counter iCat = iCat - 1 -- Check to see if counter is 0 -- and leave at first catagory (1=Virtual Cockpit), thus no wrap to last catagory. if iCat < 1 then iCat = 1 -- Check to see if now in range of EZdok catagories, typically 2, the VC and outside views. -- and show the saved view in the previous catagory elseif iCat <= iMaxEZCat then ShowView(iView[iCat]) -- Otherwise user still in FSX catagories, so perform a "View Mode Prev" command else ipc.control(65749) EZdokEnable(0) end -- Next Catagory (EZdok & FSX) elseif ipcPARAM == 8 then -- Increment catagory counter iCat = iCat + 1 -- Check to see if exceeded the maximum number of available catagories -- and leave at max, thus no wrap back to virtual cockpit. if iCat > iMaxCat then iCat = iMaxCat -- Check to see if in range of EZdok catagories, typically 2, the VC and outside views. -- and show the saved view in the next catagory elseif iCat <= iMaxEZCat then ShowView(iView[iCat]) -- Otherwise user now in FSX catagories, so perform a "View Mode Prev" command else EZdokEnable(0) ipc.control(65567) end -- Absolute View Selection elseif ipcPARAM >=10 then -- From the user supplied jump-to-direct-view, -- store new catagory and view to be used later iCat = ipcPARAM/10 iView[iCat] = ipcPARAM ShowView(iView[iCat]) end -- Save off these values to use for next time LUA is executed ipc.set("LastCat",iCat) ipc.set("LastView10",iView[1]) ipc.set("LastView20",iView[2]) -- **************************************** -- End
Pete Dowson Posted April 17, 2010 Report Posted April 17, 2010 Note: I have just learning this programming language, and there may be a completely different and better(read as more efficient) way to do this. This is my first attempt. Any advice would be greatly appreciated. Phew! That's a long and complex program for your "first attempt"! It's rather longer than anything I've ever tried, for a "plug-in". I'm not sure when I'll be able to get through that to understand what you are trying to do, but first I will encompass it in "code" brackets (see the "code" button above when you are editing messages). This enables the program to be within a scrollable AND selectable window. Very useful for anything more than a few lines: -- **************************************** -- -- My EZdok & FSX View Tracking Script -- version: 1.0 -- -- **************************************** -- Passing Parameters -- 0 = Initialize -- 1 = TrackIR enable/disable -- 2 = EZdok state tracking -- 3 - View Next in current catagory -- 4 = View Prev in current catagory -- 5 = View Next Catagory -- 6 = View Prev Catagory -- **************************************** -- Public Variables iMaxView = {12,21} -- EZdok custom views = 10,11,12 VC views & 20,21 outside view (increment when adding new views) iView = {} -- Saved EZdok custom view states iMaxEZCat = 2 -- 2 EZdok catagories (increment when adding new catagories) iMaxCat = iMaxEZCat + 3 -- 2 EZdok catagories + 3 FSX catagories -- **************************************** -- Public Subroutines -- Toggle between 0 and 1. function toggle (iStatus) if iStatus == 0 then return 1 else return 0 end end -- Change TrackIR state -- 0=disabled, 1=enabled, -1=toggle function TrackIREnable(iNewState) -- Get saved state iCurrentState = ipc.get("TrackIR_enabled") -- Check for no previous initialization and assume enabled state if iCurrentState == nil then ipc.set("TrackIR_enabled",1) return end -- Check for toggle if iNewState == -1 then iNewState = toggle(iCurrentState) end -- Send keystroke ONLY if state changed if iNewState ~= iCurrentState then ipc.keypress(120,8) ipc.set("TrackIR_enabled",iNewState) end end -- Change EZdok state -- 0=disabled, 1=enabled, -1=toggle function EZdokEnable(iNewState) -- Get saved state iCurrentState = ipc.get("EZdok_enabled") -- Check for no previous initialization and assume enabled state if iCurrentState == nil then ipc.set("EZdok_enabled",1) return end -- Check for toggle if iNewState == -1 then iNewState = toggle(iCurrentState) end -- Send keystroke ONLY if state changed if iNewState ~= iCurrentState then ipc.keypress(68,8) ipc.set("EZdok_enabled",iNewState) end end --- Select Aircraft View function ShowView(iNewView) TrackIREnable(0) EZdokEnable(1) -- EZdok VC Forward if iNewView == 10 then ipc.keypress(104,2) -- EZdok VC Left elseif iNewView == 11 then ipc.keypress(103,2) -- EZdok VC Right elseif iNewView == 12 then ipc.keypress(105,2) -- EZdok Outside 1 elseif iNewView == 20 then ipc.keypress(100,2) -- EZdok Outside 2 elseif iNewView == 21 then ipc.keypress(102,2) end end -- **************************************** -- Main -- Get the last catagory index, 1=EZdok VC, 2=Ezdok Outside, 3-5 FSX iCat = ipc.get("LastCat") if iCat == nil then iCat = 1 end -- Get the last EZdok VC view iView[1] = ipc.get("LastView10") if iView[1] == nil then iView[1] = 10 end -- Get the last EZdok outside view iView[2] = ipc.get("LastView20") if iView[2] == nil then iView[2] = 20 end -- 0 = Initialize if ipcPARAM == 0 then --Nothing needed here yet end -- TrackIR, -1 = disable, 1 = enable if ipcPARAM == 1 then TrackIREnable(-1) -- Prev View (EZdok) elseif ipcPARAM == 5 and iCat <= iMaxEZCat then -- Decrement to the previous view. If at first EZdok view, -- wrap back to last view iView[iCat] = iView[iCat] - 1 if iView[iCat] < iCat*10 then iView[iCat] = iMaxView[iCat] end ShowView(iView[iCat]) -- Prev View (FSX) -- "Shift-A", as assigned in FSX elseif ipcPARAM == 5 then -- Just issue the keystroke since we dont need to track FSX views. ipc.keypress(65,1) -- Next View (EZdok) elseif ipcPARAM == 6 and iCat <= iMaxEZCat then -- Increment to the next view. If at last availabe EZdok views -- wrap back to first view iView[iCat] = iView[iCat] + 1 if iView[iCat] > iMaxView[iCat] then iView[iCat] = iCat * 10 end ShowView(iView[iCat]) -- Next View (FSX) -- "A", as assigned in FSX elseif ipcPARAM == 6 then -- Just issue the keystroke since we dont need to track FSX views. ipc.keypress(65,8) -- Prev Catagory (EZdok & FSX) elseif ipcPARAM == 7 then -- Decrement catagory counter iCat = iCat - 1 -- Check to see if counter is 0 -- and leave at first catagory (1=Virtual Cockpit), thus no wrap to last catagory. if iCat < 1 then iCat = 1 -- Check to see if now in range of EZdok catagories, typically 2, the VC and outside views. -- and show the saved view in the previous catagory elseif iCat <= iMaxEZCat then ShowView(iView[iCat]) -- Otherwise user still in FSX catagories, so perform a "View Mode Prev" command else ipc.control(65749) EZdokEnable(0) end -- Next Catagory (EZdok & FSX) elseif ipcPARAM == 8 then -- Increment catagory counter iCat = iCat + 1 -- Check to see if exceeded the maximum number of available catagories -- and leave at max, thus no wrap back to virtual cockpit. if iCat > iMaxCat then iCat = iMaxCat -- Check to see if in range of EZdok catagories, typically 2, the VC and outside views. -- and show the saved view in the next catagory elseif iCat <= iMaxEZCat then ShowView(iView[iCat]) -- Otherwise user now in FSX catagories, so perform a "View Mode Prev" command else EZdokEnable(0) ipc.control(65567) end -- Absolute View Selection elseif ipcPARAM >=10 then -- From the user supplied jump-to-direct-view, -- store new catagory and view to be used later iCat = ipcPARAM/10 iView[iCat] = ipcPARAM ShowView(iView[iCat]) end -- Save off these values to use for next time LUA is executed ipc.set("LastCat",iCat) ipc.set("LastView10",iView[1]) ipc.set("LastView20",iView[2]) -- **************************************** -- End So, before I looks at it and think about it, is the only problem that it crashes FS at some stage? Otherwise does it do what you want? And how, out of all that, did you identify, as you thought, the "ipc.get()" function as culprit? What pointed you towards it? One way around the terribly inefficient destruction and creation of threads, and the need to use Globals to communicate from one instigation to the next, it is have a version which is loaded once (by ipcReady.lua, for instance) and tests for Lua Flags being toggled by your buttons (i.e using the LuaToggle control), instead of those buttons instigating new thread executions. You would obviously need to make it a never-ending loop then, but with it running only the once that would be fine. I think it would be much more efficient and safer that way. Even so, even if you do that, I'd first like to know what is going wrong with it as it is so I can possibly take more precautions than I have already taken to avoid the thread stacking problem. Can you please confirm what version number of FSUIPC you are using? Maybe it is one before I fixed the last bug I found in that area? Regards Pete
Zoolander64 Posted April 17, 2010 Author Report Posted April 17, 2010 Greetings Pete, Yes, I probably took on more than I could chew, but it seemed like a nice challenge. It is kinda fun too! I think it is really nifty that you allow such an interface for non-programmer types so we don't have to get into SimConnect and C++. btw: Thanks for the "code" button suggestion. Okay, now on to your questions. So, before I looks at it and think about it, is the only problem that it crashes FS at some stage? Yes, that is correct for the most part. I have a few other items I may want to add. And how, out of all that, did you identify, as you thought, the "ipc.get()" function as culprit? It seemed when I was troubleshooting the issue by eliminated code using If/Then or just commented out segments, anything with a ipc.get seemed to cause the FSX crash. Removing the ipc.get statements resulted in no crashes. Now, with that being said, it could be the ipc.get statement takes a hair longer than intrinsic functions, thus causing a larger delay and leaving threads active? The more I think about it and learning what you have commented on threads, ipc.get may be just fine. Also, I could reproduce the crash much quicker with multiple ipc.get statements back to back. This may all be non-applicable since I am just stressing FSX and threads the wrong way. btw: ipc.set seemed to have no issues in my stress tests. I have also noticed that ipc.log and ipc.display in a tight loop will also causes FSX to crash. This could also be contained to my system since I have not tried my scripts on any other installation of FSX. One way around the terribly inefficient destruction and creation of threads, and the need to use Globals to communicate from one instigation to the next, it is have a version which is loaded once I saw this as an option in your documentation. I actually thought (and thought wrong) that a lua script interrupted as needed would be better. It is nice to see this is not the case, and in my situation a iterative script with conditional statements would be better. Thanks for the suggestion. I'd first like to know what is going wrong with it as it is so I can possibly take more precautions Sure, whatever you think I can offer. Especially, since I get to learn more stuff from the master :) Can you please confirm what version number of FSUIPC you are using? I am using registered version FSIUPC v4.60a (4th March 2010)
Pete Dowson Posted April 17, 2010 Report Posted April 17, 2010 Removing the ipc.get statements resulted in no crashes. Now, with that being said, it could be the ipc.get statement takes a hair longer than intrinsic functions, thus causing a larger delay and leaving threads active? No, I don't think that can be the case. It's actually got a lot less to do than most. Wouldn't it more likely be that, without those, your code was actualy doing something different? Anyway, I'll try to work out what was happening. But it won't be today, and maybe not tomorrow. Guests have just arrived! The more I think about it and learning what you have commented on threads, ipc.get may be just fine. Also, I could reproduce the crash much quicker with multiple ipc.get statements back to back. This may all be non-applicable since I am just stressing FSX and threads the wrong way. btw: ipc.set seemed to have no issues in my stress tests. Hmm. That is weird. I don't understand that -- if it is timing, "set" should take longer! I have also noticed that ipc.log and ipc.display in a tight loop will also causes FSX to crash. That's less surprising. One involves file access and the other calls to complex routines inside FSX which are probably not re-entrant. I'll add to this thread when I've had a further look. Maybe tomorrow, maybe monday. Regards Pete
Zoolander64 Posted April 17, 2010 Author Report Posted April 17, 2010 Greetings Pete, Thanks for the reply. Enjoy your weekend and company. No hurry on the response. As I poke around in lua this weekend, I may learn about this stuff so as to be more helpful to you.
Andydigital Posted April 17, 2010 Report Posted April 17, 2010 I am also simulating the default FSX "A" and "Shift-A" since EZdok does not have a view cycle command. EZdok does now allow you to use the default S and Shift + S commands to move through different view categories and A and Shift + A sub views. Just make sure you have version 1.14 I believe its called and you also have to remove those key definitions from the FS control menus. Hopefully that will make your code a little simpler. Also to work with Track IR and EZdok why don't you just send two commands with one joy button press, you can either do this by using the two options within the FSUIPC GUI i.e. one command (key press) on press of the joy button and the other command (key press) on release of the joy button. You could also edit the FSUIPC ini directly to send two commands (key presses) just on a press of the joy button if you wish.
Zoolander64 Posted April 17, 2010 Author Report Posted April 17, 2010 Greetings Andy, Thanks for responding and the suggestions. EZdok does now allow you to use the default S and Shift + S commands to move through different view categories and A and Shift + A sub views Correct, these are now supported with 1.14, but I am taking it a step farther and want my Ezdok custom views to respond, aka cycle, with the "Shift-A" and "A" instead of cycling the default cockpit and outside airplane views. SideNote: I traded emails with Marniftarr(EZdok) during his initial release, even learned a little Russian, and suggested native view cycling support. It is on the short list, after spot plane replacement and TrackIR support. Until then, I figured I would give it a go with an lua. I also am turning off TrackIR (this requires state tracking since it is a toggle and not a forced on or off) when I switch to ANY other view. I also track EZdok on/off as well. When I am in the EZdok custom views, I re-enable EZdok, but when switching, "S", to a FSX catagory, I disable EZdok. Default FSX has typically 4 view catagories. For the VC and outside plane views I have the script use EZdok, and for the spot and airport I switch back to FSX. So in effect I am bagging the default FSX views for VC and outside airplane. So far it all works seamless with this script. Next, I have to figure out how to take it to multiple planes without having multiple lua's. With these custom views, I can, for example, have a view for the the A2A B17 that looks at the starter panel, then when I hold down a button, snaps to outside to see what the engine is doing, and at the same time keeping the A2A checklist on the screen (it disappears at each view change). Also to work with Track IR and EZdok why don't you just send two commands with one joy button press, you can either do this by using the two options within the FSUIPC GUI i.e. one command (key press) on press of the joy button and the other command (key press) on release of the joy button. You could also edit the FSUIPC ini directly to send two commands (key presses) just on a press of the joy button if you wish. The blind toggling of TrackIR and EZdok, did not work (first attempt w/o lua's) since it provided no tracking of it's current state since both the view change and manually triggering are independent. Now with all that said, I am completely open to ideas and sample scripts that make this process easier. I am happy with the script now, but I am sure the process can be reduced.
Pete Dowson Posted April 17, 2010 Report Posted April 17, 2010 I traded emails with Marniftarr(EZdok) during his initial release, even learned a little Russian, and suggested native view cycling support. Did you find out if there's any way to use the same programmed camera views in Slew mode? I programmed my camera view keystrokes onto rocker switches (like a hat) on my PFC yoke, but with ECZA I miss using the same switches for viewing in slew mode too. Regards Pete
Zoolander64 Posted April 18, 2010 Author Report Posted April 18, 2010 Did you find out if there's any way to use the same programmed camera views in Slew mode? Currently, not in the product, that I know of. I can send an email to Marniftarr to see about adding it to the list. Marniftarr is really open to ideas and doing a fantastic job. Very responsive and will end up obsoleting the need for my lua script :) and that is okay. Sidenote: Hmm, with my lua script, I could detect "Y" (SLEW), disable EZdok (Pete, I know you want it enabled), and switch to an outside view. I am in the process of converting over my lua to being event driven with event.flag. No need for ipc.get or ipc.set and this seems like a much better way to go about this. So far so good. I'll have more time to work on it tomorrow.
Pete Dowson Posted April 18, 2010 Report Posted April 18, 2010 I am in the process of converting over my lua to being event driven with event.flag. No need for ipc.get or ipc.set and this seems like a much better way to go about this. So far so good. I'll have more time to work on it tomorrow. Okay. That's good. Meanwhile, I've been thinking about what might have been the problem crashing FSX. I suspect I have a weakness in the Global Variables handling. In order to provide global variables I have a global stack set up in Lua -- effectively another thread permanently suspended except when asked to access the variables it stacks. I'm wondering if that's not as well protected against multiple re-entries as the normal Lua threads. I suppose it could affect "ipc.get" more than "ipc.set" simply because the latter doesn't need the calling thread to be help pending a result. Anyway, even though you shouldn't need it sorting now, I'll get onto it tomorrow. I don't like faults and weaknesses if I can fix 'em! ;-) Regards Pete
Pete Dowson Posted April 18, 2010 Report Posted April 18, 2010 I couldn't resist looking into the ipc.get() problem todayI used this: while 1 do y=0 x = ipc.get("y") ipc.sleep(200) end You said this was "not very useful", though it may also indicate a small misunderstanding. There is no point in the "y=0" part, because the Global variable "y" is not the same as that local variable y. If you wanted the ipc.get to actually return a value other than nil you'd have to use ipc.set() before the loop, to set "y". Anyway, the problem of the crash was nothing to do with starting and stopping threads. That loop alone, just started once and allowed to continue, would crash eventually. My "ipc.get" function retrieves the global value (even "nil") to the global thread's stack, then transfers it to the calling thread's stack, but it didn't pop it off the global stack. Result -- eventually a stack full crash on that global thread. How long that takes is related to the space taken up by the variable. For "nil" it takes more iterations than for a long string, for example. I've fixed it here, ready for the next FSUIPC release. Thanks for finding this bug! Regards Pete
Zoolander64 Posted April 18, 2010 Author Report Posted April 18, 2010 Greetings Pete, As I am working more and more with LUA files, and seeing your post, I am s-l-o-w-l-y getting it and writing better code (I hope). I am almost done with the event.flag method and this seems much cleaner and not a single crash so far. I am glad that I was able to help out a little, even if only indirectly, to make FSUIPC a stronger offering. I have sent your request to Marneftarr. I'll let you know his thoughts on it. Take care Pete, and stay out of that volcanic ash cloud! I went through three of those from being in Alaska for 30 years. Brutal on anything mechanical.
Pete Dowson Posted April 18, 2010 Report Posted April 18, 2010 Take care Pete, and stay out of that volcanic ash cloud! I went through three of those from being in Alaska for 30 years. Brutal on anything mechanical. Yes. It is very annoying. On Wednesday this week I am expecting an Engineer over from Sacramento to fix some long-standing faults on my PFC 737NG cockpit and to update the overhead panel with a fully populated and indicated version. if this blasted cloud doesn't shift before then it's all going to get cancelled. I've no idea when we can re-schedule. It's taken months to sort this trip out! :-( Regards Pete
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now