charlie172sierra Posted August 1, 2011 Report Posted August 1, 2011 Hello Mr. Dowson & fellow simmers, I have recently upgraded to the registered version of FSUIPC (version 4.7 I believe) in the hopes of tweaking the FSUIPC data output to the Flight Illusion Simulator Control Program Version 7.0.8. Flight Illusion's gauges require both the FSUIPC and FI software to complete the interface between FSX and FI's gauges. Specifically I have the following problem: The GSA40 Directional Gyro is reporting the true heading instead of the magnetic heading. Flight Illusion's software allows monitoring the received values of both magnetic heading and true heading (among several other flight characteristics.) Furthermore, FI's software can force the gyro to report the compass heading (a.k.a. magnetic heading) but with the following huge drawback: the gryo mimics all of the lags associated with a whiskey compass. What I would like to do, if possible, is configure FSUIPC to send the magnetic heading value in place of the true heading value. That is, Flight Illusion's software thinks it is receiving the true heading from FSUIPC when in fact FSUIPC is sending it the magnetic heading. Is such a programming trick possible? I realize that there would be another work-around. I would simply use the heading encoder to adjust the GSA40 to match the FSX simulated whiskey compass' heading, like what is necessary to do to correct for gyro drift. Alas, I cannot get the encoder to function so I'm unable to do this (I'm waiting to hear back from FI or other simmers in a different posting within Flight Illusion's forum pages in the simFlight website.) So, for now, I have to either endure a gyrocompass with gyro stability always reporting the true heading, or a gyro that reports magnetic heading but exhibits all of the lags of a whiskey compass. I am no expert at computer programming (I have minimal experience with Visual Basic) and am certainly no flight expert (I've only just begun flight school -- best decision in my life!), so I understand that I may be in error in my understanding of the situation. Any advice or comments would be greatly appreciated! Thanks much, David
Pete Dowson Posted August 1, 2011 Report Posted August 1, 2011 What I would like to do, if possible, is configure FSUIPC to send the magnetic heading value in place of the true heading value. That is, Flight Illusion's software thinks it is receiving the true heading from FSUIPC when in fact FSUIPC is sending it the magnetic heading. Is such a programming trick possible? If the Flight Illusion driver is reading the offset for the True heading, that's what it gets. Can the driver be configured to read a different FSUIPC offset instead? If so it would be easy to make a little Lua plug-in which computes the magnetic heading and provides it via a spare user offset. Really, the driver is the place you need to address this problem. Don't the FI authors know this is a bug in their handling? Shouldn't they be asked to correct it? FSUIPC4 does actually provide a "spoofing" facility to make one offset look like another., which might do the job. It would need a rather complicated trick played via a Lua plug-in. But check the driver's facilities first, see if the offsets it reads from are configurable. Regards Pete
charlie172sierra Posted August 1, 2011 Author Report Posted August 1, 2011 Hello Pete, Thanks for the quick reply. I definitely agree that it is a Flight Illusion driver issue and I am hoping that one of their personnel will respond to a posting I put within their customer support forum (which resides within the simFlight forum.) That said, I think their customer support staff probably consists of one person who also does R&D, manufacturing, marketing and accounting...so the response time is often longer than ideal. I will school myself on what a Lua is, tinker with the files associated with Flight Illusion's controller program, and maybe track down the offset parameterization and alter it to read the magnetic heading from FSUIPC's output. I am already sure that it cannot be configured from using the menus within Flight Illusion's control program. I will post here if I find a quick resolution, otherwise I've got some learning to do by perusing the forum before I will be able to comprehend the "spoofing" solution. Thanks again, David
Pete Dowson Posted August 2, 2011 Report Posted August 2, 2011 I will school myself on what a Lua is, tinker with the files associated with Flight Illusion's controller program, and maybe track down the offset parameterization and alter it to read the magnetic heading from FSUIPC's output. I am already sure that it cannot be configured from using the menus within Flight Illusion's control program. I will post here if I find a quick resolution, otherwise I've got some learning to do by perusing the forum before I will be able to comprehend the "spoofing" solution. You won't find the "spoofing" so easily. It isn't specifically a Lua facility, it's a programming facility documented only for FSUIPC4 in the FSUIPC SDK. You'll need to download that in any case, but just to get the details of the offsets which are only documented there. There is an example of this spoofing facility in the Lua plugins examples installed in a ZIP in your FSUIPC documents folder, in the FSX Modules folder. It is called "liar.lua". When that is run it fakes the readouts for a lot of FSX values. An example just for heading would be much simpler. You'd need to read the normal True heading, adjust it for magnetic variation (another offset), then send it back to FSUIPC using the "spoofing" offset, as seen near the end of that liar.lua program. I can help with the details when you get further. Note also that if you do use this method, EVERY program reading the true heading offset from FSUIPC will get the magnetic heading instead. Only the Lua program doing the spoofing can read the original. So before you begin you need to think whether there are any other FSUIPC-interfacing applications you are using which use the heading value. It's okay if they use SimConnect instead, FSUIPC doesn't alter the FS values, only its own offsets. Regards Pete
charlie172sierra Posted August 11, 2011 Author Report Posted August 11, 2011 Hello Pete, I did exactly as you said, using the Liar Lua as a template, and now have the Flight Illusion GSA40 Directional Gyro reporting the magnetic heading and properly possessing the stability of a gyrocompass. Thanks much for your advice! I cut & pasted the code below in case anyone else has this issue (of course, if you see coding glitches or inefficiencies, please comment if you wish.) -- "spoofMH4TH" is a Lua plug-in for FSUIPC4 -- that spoofs magnetic heading as true heading for FSUIPC clients. -- Adapted from Pete Dowson's "Liar" Lua by charlie172sierra -- PROBLEM: -- Flight Illusion's GSA40 Directional Gyro can only indicate true heading with the desirable -- characteristic of gyro stability but with the huge drawback of not indicating magnetic heading, OR -- desirably indicate magnetic heading but with the huge drawback of having all of the lags -- associated with a whiskey compass. -- SOLUTION: -- Use Lua plug-in to read magnetic variation and true heading, compute magnetic heading, and -- spoof magnetic heading as true heading for Flight Illusion's gauges Control Program V 7.0.8 -- (the FSUIPC client.) Flight Illusion's GSA40 Directional Gyro will then indicate magnetic -- heading despite "thinking" that it is still indicating the true heading. -- NOTES: -- This is a work-around for my inability to enable the encoders on the GSA40 Directional Gyro. -- Were the encoders enabled, I'd simply adjust the DG heading to match the whiskey compass -- heading (like compensating for gyro drift.) -- Flight Illusion's Control Program 7.0.8 identifies true heading as "real heading" in the configuration -- window for the GSA40. -- Within FSUIPC (enabled in registered version only), user must define a key press that -- activates "Lua spoofMH4TH". It may also be desirable to define a different -- key press that toggles: "LuaToggle spoofMH4TH". -- ****************** Begin main routine ******************************** -- Loop till flag 0 is set (setting 0 can be done by toggling the Lua off) while ipc.testflag(0) == false do -- ***** read magnetic variation & true heading ***** mv, th = ipc.readStruct( 0x02A0, "1SW", 0x0580, "1UD") -- ***** convert from FS units to aviation units ***** mv = mv * 360 / 65536 th = th * 360 / (65536 * 65536) -- ***** determine magnetic heading ************** mh = th - mv -- ***** convert from aviation units to FS units ***** mh = (mh / 360) * (65536 * 65536) -- ***** spoof magnetic heading as true heading **** ipc.writeStruct(0x0024,"1UW",0x0580,"1UW",4,"1UD",mh) -- Sleep for 50 mSecs so the update gets done roughly 20 times per second ipc.sleep(50) end -- ****************** end main routine ******************************** -- Lua was toggled off -- Now undo the overrides (otherwise they'll take about 12 seconds to die, with frozen values provided!) ipc.writeStruct(0x0024,"1UW",0x0580,"1UW",0) Thanks again - FSUIPC helped me resolve a really annoying 3rd party hardware&software issue! David
Pete Dowson Posted August 11, 2011 Report Posted August 11, 2011 I did exactly as you said, using the Liar Lua as a template, and now have the Flight Illusion GSA40 Directional Gyro reporting the magnetic heading and properly possessing the stability of a gyrocompass. Thanks much for your advice! I cut & pasted the code below in case anyone else has this issue (of course, if you see coding glitches or inefficiencies, please comment if you wish.) Excellent! Do you think you could re-post this with a suitable thread title in the User Contributions subforum? That way it will remain a reference. If it's only here it will eventually scroll away into the distance! Thanks, 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