DrDave- Posted April 13, 2021 Report Share Posted April 13, 2021 Mr. Dowson, I have been a appreciative customer for many years. I am building my 3rd Sim using P3DV4. I have FSUIPC6. This Sim's hardware is interfaced almost entirely with Arduino. I'm sure you can appreciate the reasons. Another product, Air Manager, does a great job interfacing the cards with SimConnect. FSUIPC obviously does a great job with other capabilities, especially axes and addons that use FSUIPC. Not sure where FSUIPC's Lua library structure is located. Understand where Lua modules are located and use of plug-ins. The Air Manager Lua modules are located but lua modules are located in Air Manager's root and reference Arduino pin numbers, SimConnect Variables (including LVars) and logic. Is there anyway with paths and directories in Lua to share function and commands? Or is there a better method to share? One suggested method is to use LVars to communicate. AM command - fsx_variable_write(variable,unit, value). Used in both FSX and P3D. FSUIPC Command - ipc.readLvar("variable"). This would work (e.g. set addon offset in FSUIPC from a push of a button attached to Arduino). If there is a better uncomplicated way for FSUIPC to interface with Arduino, I sure would like to know. Link2FS seems no longer available, MobiFlight has limits and Lua code found thru Google is contradictory and flawed at best. Thanks Link to comment Share on other sites More sharing options...
John Dowson Posted April 13, 2021 Report Share Posted April 13, 2021 6 minutes ago, DrDave- said: Not sure where FSUIPC's Lua library structure is located. Understand where Lua modules are located and use of plug-ins. The lua library (and interpreter) are built into FSUIPC6 - they are not located anywhere. By default, all FSUIPC lua plugins are loaded from the FSUIPC installation folder. You can change this location by adding a LuaPath parameter to the [LuaFiles] section of your FSUIPC6.ini file - see the Advanced User manual for details (P10). 11 minutes ago, DrDave- said: Is there anyway with paths and directories in Lua to share function and commands? Or is there a better method to share? Well, you can try using the same lua plugin folder for both and use the LuaPath ini parameter in FSUIPC. However, I'm not sure this is a good idea. Certainly other lua interpreters will not be able to understand the FSUIPC-specific lua scripts, although you may be able to use non-FSUIPC lua scripts in FSUIPC, but I don't know if this is useful - if a script its not using the FSUIPC lua library, it isn't doing anything to/in/for FSUIPC. Peta (and many other FSUIPC users) interface to Arduino's, so they may have further advice. Link to comment Share on other sites More sharing options...
Pete Dowson Posted April 13, 2021 Report Share Posted April 13, 2021 19 minutes ago, DrDave- said: Not sure where FSUIPC's Lua library structure is located. Understand where Lua modules are located and use of plug-ins. So I don't understand the question. If you mean the Lua interprester built into FSYUPC or WideClient, then that is also where the provided libraries are -- within FSUIPC. 19 minutes ago, DrDave- said: Is there anyway with paths and directories in Lua to share function and commands? Or is there a better method to share? If Air Manager incorporates its own Lua interpreter and library, no. You might be able to convert from one to the other but I really can't see how they can be shared. 19 minutes ago, DrDave- said: One suggested method is to use LVars to communicate. AM command - fsx_variable_write(variable,unit, value). Used in both FSX and P3D. FSUIPC Command - ipc.readLvar("variable"). Ah, you mean sharing data, not sharing code and functions. Yes, you could obviously share any data stored externally to the Lua facilities in things like like LVars (stored in the current sim's data area), or FSUIPC offsets, if Air Manager interfaced at all with FSUIPC, would do. Or failing that a file. 22 minutes ago, DrDave- said: If there is a better uncomplicated way for FSUIPC to interface with Arduino, I sure would like to know I use a simple Lua plug-in using the COM library in FSUIPC's Lua to read and write data to an Arduino. i've never used any other Arduino interfacing software. But my use of Arduino was done some time ago. Currently I only use one with an add-on board to operate the magnets on my 737 starter switches. Pete Link to comment Share on other sites More sharing options...
DrDave- Posted April 13, 2021 Author Report Share Posted April 13, 2021 Please let me know which plugin in you use or could you post it here. I cannot find a plug-in in the provided "Lua Plug-Ins" documentation. I will look as well in the com library if I can find it. As I am using P3DV4.5, FSUIPC is in the Add-ons folder in Documents. Where are your libraries located? You list 10 starting with "ipc" in your "Lua Library Reference". In which folder are they located? Link to comment Share on other sites More sharing options...
John Dowson Posted April 13, 2021 Report Share Posted April 13, 2021 6 minutes ago, DrDave- said: You list 10 starting with "ipc" in your "Lua Library Reference". In which folder are they located? They are lua functions (part of the FSUIPC lua library) built into FSUIPC, not plugins. The plugins are documented in the FSUIPC Lua Plug-Ins.pdf, and are contained in a zip file called Example LUA plugins.zip in your Documents folder. Link to comment Share on other sites More sharing options...
DrDave- Posted April 13, 2021 Author Report Share Posted April 13, 2021 7 minutes ago, John Dowson said: They are lua functions (part of the FSUIPC lua library) built into FSUIPC, not plugins. The plugins are documented in the FSUIPC Lua Plug-Ins.pdf, and are contained in a zip file called Example LUA plugins.zip in your Documents folder. Thanks John, I am well aware of the above. I'm looking for the Com Plug-In your Dad mentioned above for communicating with Arduino. There are many examples in your forum as well as others that communicate with many techniques. I'm just looking for the technique (and code if available) used by the Dawsons. It would be the most efficient and practical. Link to comment Share on other sites More sharing options...
Pete Dowson Posted April 13, 2021 Report Share Posted April 13, 2021 3 hours ago, DrDave- said: I'm looking for the Com Plug-In your Dad mentioned above for communicating with Arduino. There is no "core plug-in". Is your Arduino a COM-port connection? If so just read and write data for it using the COM library. Look it up in the FSUIPC Lua library document. You have to write a corresponding program for your Arduino to. So you just invent your own serial port conversation with it. I know very little indeed about Arduino.s , and an Engineer friend did the work involved in installing the little bit of associated hardware which operates by start switch magnets. And that in turn is handled by ProSim. I suggest you ask in a cockpit building forum, or maybe one for Arduino users. They'd be a lot more help than I. We can help understand anything you ask about the COM library, but mostly it is simply "Open port ... and a write data ... read data loop". Since you write the software for both ends of the wire, it is all completely up to you. Pete Link to comment Share on other sites More sharing options...
DrDave- Posted April 13, 2021 Author Report Share Posted April 13, 2021 Thanks so much. Best to hear it from the expert. As I already have 2 bezels using Pokeys57U (inherited from a friend). I should keep it simple an use LVar exchange. Seems the clearest method for Lua. Link to comment Share on other sites More sharing options...
DrDave- Posted April 15, 2021 Author Report Share Posted April 15, 2021 On 4/13/2021 at 1:55 PM, Pete Dowson said: On 4/13/2021 at 6:36 PM, Pete Dowson said: There is no "core plug-in". Is your Arduino a COM-port connection? If so just read and write data for it using the COM library. Look it up in the FSUIPC Lua library document. You have to write a corresponding program for your Arduino to. So you just invent your own serial port conversation with it. I use a simple Lua plug-in using the COM library in FSUIPC's Lua to read and write data to an Arduino. i've never used any other Arduino interfacing software. But my use of Arduino was done some time ago. Currently I only use one with an add-on board to operate the magnets on my 737 starter switches. Pete I was referring to the Plug-In using the COM library referred to in Mr. Dowson's reply, not a "core plug-in". If the code is available for the "simple Lua plug-in using the COM library", I would appreciate viewing that code. It is not supplied in the "Example LUA plugins" folder. Link to comment Share on other sites More sharing options...
SAC002 Posted April 23, 2021 Report Share Posted April 23, 2021 Hi, i want to use fsuipc with my goflight modules. With the new fsuipc wasm module, i would like fsuipc to be my only addon to interact with my goflight modules and my usb controller boards. I have created a simple lua file to turn on and off landing gear lights with my goflight module. Works great with green and orange colors and blank reading the offsets. But what is the most efficient way to make this a continious loop ? Thanks for your help Daniel Link to comment Share on other sites More sharing options...
John Dowson Posted April 24, 2021 Report Share Posted April 24, 2021 9 hours ago, SAC002 said: But what is the most efficient way to make this a continious loop ? Not 100% sure what you mean, but, depending upon what you want to achieve, lua scripts can be auto-started and wait for 'events' and then act upon them . Events can come from various sources, such as a button press or offsets. So you can set a lua function to be called when one of the gear position offset changes (or the landing light offset). Take a look at the event library documentation in the Lua Library. Link to comment Share on other sites More sharing options...
SAC002 Posted April 24, 2021 Report Share Posted April 24, 2021 ok got it...thanks... one question about offsets and bits...can you pls explain offset 0D0C... basically, i want to turn on a goflight modules LED when landing lights are ON, taxi lights are ON, etc... i don't quite understand the bits 0 to 9...how can I check offset 0D0C and these bits to know which lights are ON or OFF ? You have excellent documentation and I am sure it is explained somewhere but i failed to find something about this... Cheers, Daniel Link to comment Share on other sites More sharing options...
John Dowson Posted April 24, 2021 Report Share Posted April 24, 2021 1 hour ago, SAC002 said: i don't quite understand the bits 0 to 9...how can I check offset 0D0C and these bits to know which lights are ON or OFF ? ODOC is 2 bytes, so you can read the value using the lua ipc.readUW function. You can then get the value of the bit you want to test using the lua logic library. So, to check for landing lights, which is bit 2 (and 2^2=4), do something like n=ipc.readUW(0x0D0C) v=logic.And(n, 0x4) and v will hold 1 if the landing lines are on, 0 otherwise. Link to comment Share on other sites More sharing options...
spokes2112 Posted April 24, 2021 Report Share Posted April 24, 2021 John, Was working on a reply the same time as you were. 1 hour ago, John Dowson said: v=logic.And(n, 0x4) and v will hold 1 if the landing lines are on, 0 otherwise. Wouldn't the value of v be 4 if on? OFC "true" boolean is 0 or not zero, so it would work if checking for 0. v=logic.And(n, 0x4) if v == 4 then -- landing lights are on end - or - v=logic.And(n, 0x4) if v ~= 0 then -- landing lights are on end _____________________________________________________________________________________________________________ Here's another way to look at it.. Refer to this chart: Here is an example if you were to use a loop to check, not recommended at all... An example just to show how you can manipulate the checking of bits. a = ipc.readUW(0x0D0C) -- Landing Light is ON if logic.And(a, 4) == 4 then -- Do something end -- Landing Light is OFF if logic.And(a, 4) == 0 then -- Do something end -- BOTH Strobes & Logo lights are ON ( add up bit values ) if logic.And(a, 272) == 272 then -- Do something end -- BOTH Strobes & Logo lights are OFF ( add up bit values ) if logic.And(a, 272) == 0 then -- Do something end Another example, using a recommended event listener to call a function only if the bit value that is masked has changed. This is so much more efficient. BeaconDetect(offset, value) if value == 2 then -- the bit value -- turn ON led code here else -- turn OFF led code here end end StrobesDetect(offset, value) if value == 16 then -- the bit value -- turn ON led code here else -- turn OFF led code here end end LandingOrTaxiDetect(offset, value) -- this detects the landing OR taxi lights being ON (1 led) if value == 4 or value == 8 then -- turn ON led code here else -- turn OFF led code here end end event.offsetmask(0x0D0C, 2, "UW", "BeaconDetect") -- detect if bit #1 (value = 2) changes event.offsetmask(0x0D0C, 16, "UW", "StrobesDetect") -- detect if bit #4 (value = 16) changes event.offsetmask(0x0D0C, 12, "UW", "LandingOrTaxiDetect") -- detect if bit #2 (value = 4) -or- bit #3 (value = 8) changes Roman Link to comment Share on other sites More sharing options...
SAC002 Posted April 24, 2021 Report Share Posted April 24, 2021 thanks guys...really appreciate...i was using event.Offset for 0D0C but not with the mask..it is a good way to do it...and rgr for checking for 0...i also noticed that the return value was not 1 but 4 with the example above... Link to comment Share on other sites More sharing options...
John Dowson Posted April 24, 2021 Report Share Posted April 24, 2021 1 hour ago, spokes2112 said: Wouldn't the value of v be 4 if on? OFC "true" boolean is 0 or not zero, so it would work if checking for 0. Yes, of course (sorry!)...but really the value doesn't matter when checking a bit, its either 0 (off) or not 0 (~=0), unless you are checking for multiple bits....! The value, of course, will depend on the bit position. Link to comment Share on other sites More sharing options...
SAC002 Posted April 24, 2021 Report Share Posted April 24, 2021 👍 I am learning...get to realize what FSUIPC can do...😀 Link to comment Share on other sites More sharing options...
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