Jump to content
The simFlight Network Forums

dazz

Members
  • Posts

    104
  • Joined

  • Last visited

Posts posted by dazz

  1. Thanks, John. Turns out I had an ipc.exit() somewhere that was responsible for the thread interruption. The range wasn't being entered again before the thread completed running The LuaRerunDelay parameter could be useful for some other application, good to know. I don't think i'll need it this time around. The script is working fine already.

    I really need to re-read the advanced guide again. It's been a while. 
    Muchas gracias de nuevo 😃

  2. I'm super rusty and I don't seem to remember if there's a way to do what I mention in the title. I need my script (it's tied to an axis range) to complete execution, but sometimes it doesn't, I suspect it's because another input is detected for the axis, but I'm not sure because the log doesn't print the lines I have at the beginning of the script after the interruption of the previous execution. Is there a way to get a "lock" or something like that? Thanks

    Using FSX and FSUPIC4 v4.977, I believe it's the latest one 

  3. Hi there, long time no see! Hope you're doing great, Pete. 
    So I'm planning to go back to doing some flight simming after a long hiatus. Got some new gear and I'm in the process of configuring everything in FSUIPC/LINDA.
     

    I have a Lua script to map the flaps, spoilers and gear lever to a single axis using ranges. The idea is to push the lever all the way up/down to retract/deploy the gear, while a smaller input to the lever increments or decrements the flaps. Then I use the global shift utility in LINDA to duplicate that for the spoilers.

    I have a Lua script to take care of all that called lindaDefault.lua, which works well for aircrafts that use default controls for the gear, flaps and spoilers.

    The plan is to then use specific scripts for planes that require some custom logic for some or all the controls. These scripts execute a require('lindaDefault') so that they have access to all the default functions there, and then I can (hopefully) override the functions that are needed to make the script work for that specific plane. For example, the NGX uses different controls for the spoilers, so I would be overrinding those functions while using the default ones for the flaps and gear.

    This is a snippet of lindaDefault.lua, containing one of the functions - spoilersDeploy() - that are meant to be overriden if necessary. 

    [code]

    -------------------------------------------------------------------------------------------------------------------------------
    ----------------------------------------------------- OVERRIDABLE FUNCTIONS ---------------------------------------------------
    -------------------------------------------------------------------------------------------------------------------------------

    function spoilersDeploy() 
        ipc.control(66064) -- Spoilers Deploy
    end

    -------------------------------------------------------------------------------------------------------------------------------
    -------------------------------------------------------------------------------------------------------------------------------
    -------------------------------------------------------------------------------------------------------------------------------

    function AXIS_GEAR_SPOILERS_100() 
        if SHIFT_GLOB == 0 then
            ipc.control(66080) -- Gear down
        else
            spoilersDeploy()
        end
        ipc.set('LEVER_MAXED_OUT', true)
    end

    FUNCTIONS =
    {
      [1] = AXIS_PARKINGBRAKES_SPOILERS_OFF,
      [2] = AXIS_PARKINGBRAKES_SPOILERS_ON_ARM,
      [3] = VOID,
      [4] = AXIS_FLAPS_SPOILERS_DEC,
      [5] = AXIS_FLAPS_SPOILERS_INC,
      [6] = AXIS_GEAR_SPOILERS_0,
      [7] = AXIS_GEAR_SPOILERS_100,
    }

    func = FUNCTIONS[f]

    if (func) then
        func()
    else
        ipc.log('nope, no function here to be called')
    end

    [/code]

    Then I have this lindaNGX.lua that's supposed to override the spoiler functions like this:

    [code]

    require('lindaDefault')

    -------------------------------------------------------------------------------------------------------------------------------
    ----------------------------------------------------- OVERRIDABLE FUNCTIONS ---------------------------------------------------
    -------------------------------------------------------------------------------------------------------------------------------

    function spoilersDeploy() 
        ipc.control(86637, 16384) -- Spoilers Deploy
    end

    function spoilersRetract() 
        ipc.control(86637, -16384) -- Spoilers Retract
    end

    function spoilersArm() 
        ipc.control(86637, -13100) -- Spoilers Arm
    end

    function spoilersDisarm() 
        spoilersRetract()
    end

    -------------------------------------------------------------------------------------------------------------------------------
    -------------------------------------------------------------------------------------------------------------------------------
    -------------------------------------------------------------------------------------------------------------------------------

    [/code]

     

    This is not working. The functions in lindaDefault.lua are the ones being called.
    Any ideas, please? Thanks in advance.

  4. Thanks, Dario.

     

    Note, however, that's for a Lua plug-in program. For a simple assignment to a switch you'd select <custom control> and enter 69749 for the control number and that other number for the parameter.

     

    Incidentally, that second number makes more sense as 0x20000000 in Lua, or just x20000000 as the parameter entry. It's a single digit in a 32-bit binary value.

     

    Pete

     

    Yeah, silly me. I haven't fired up my sim in ages and since all my assignments are in Lua - Linda, I just opened my NGX script and searched for "taxi" without even thinking.

    That parameter probably came from flipping switches in the cockpit while tracing control changes.

     

    Thanks for the clarifications

  5. Dear Pete,

     

    Hope you had a Merry Christmas, and a Happy New Year.

     

    My name is Ronald Jackson.

    I'm going to start working on a Homemade cockpit. But before I did that, I installed one toggle switch to my computer to see how everything would work, and it seems to work just fine. When I try to compliment it to my fsx fsuipc with a pmdg ngx product it seems not to work since I'm not able to understand how the offsets work. I've read the manuals many times, but can't get to understand them. Searched for help over the internet hoping to find solutions but nothing. I see you have helped many folks, so I thought you might be the right person to come to. I've created an account on this just to get in touch with you, hoping you have the time and the courage to help me understand my problem and my frustration. 

    All I need to know is how to get the taxi lights to work using the toggle switch on/off "737 pmdg product". 

    Just help me in trying to understand just the lights part, how the offsets for the lights work, and how I can make the lights work with the switch toggle I've installed using FSUIPC.

     

    P.D

    If any question, email me on my personal email-

    rjackson1995@aol.com

     

    Thanks

     

    Looking forwards in hearing from you.

     

    Sincerely,

    Ronnie

     

    try this Ron:

     

    ipc.control(69749, 536870912)

  6. Ok, here is the reply from Ryan:

    When you say "every other load" do you mean loading the aircraft over itself without shutting the sim down and restarting it first? If so, that's a big no no with most complex addons - there's bugs in FSX that cause all the data to corrupt if you do that...

    That makes since,so maybe we have to live with it. I can, with just another reload :).

    Regards,

    Johan

    Does that apply to loading, I don't know, the 900, then another NGX variant like the 800WL or 700 or whatever?

  7. Thank you so much for adding these offsets! Out of curiosity, is there an offset guaranteed to be non-zero if the NGX is loaded? I'm looking for a shortcut to detect the presence of the aircraft outside of the AIR file name.

    Cheers!

    Luke

    I use the path of the AIR file.


    function loadFunct()
    acPath = ipc.readSTR(0x3C00, 256)

    if (string.find(acPath, "00NGX") == null) then
    ...
    end
    end

    event.sim(FLIGHTLOAD, "loadFunct")
    [/CODE]

  8. Thanks. I'll revise the PDF. I need also to point out that it only appears to work on the first loading of the PMDG airecraft -- see previous message here. Some can get it working again on every alternate load, but here you'd need to reload FSX to change aircraft and have the Client data supplied still! :sad:

    [LATER]

    Okay, the document is revised in the packaged 4.82.. I'll post it separately too so folks may notice.

    Pete

    Damn it! , it's also happening to me and I thought it was something in my code. I can force to restart my dll in the middle of a flight, but if I load a different flight it stops working

  9. Here's the log in the event viewer with version 4.812f

    Exception code: 0xc0000005

    Fault offset: 0x0004f590

    Faulting process id: 0x1bbc

    Faulting application start time: 0x01cd119264c5fc9a

    Faulting application path: C:\Program Files (x86)\Microsoft Games\Microsoft Flight Simulator X\fsx.exe

    Faulting module path: C:\Program Files (x86)\Microsoft Games\Microsoft Flight Simulator X\Modules\FSUIPC4.dll

    And I tried the event.terminate thing (this is the script I use to start & restart the dll, calling it from ipcReady with ipc.runlua, so that it runs in it's own thread):


    require "ngxSDK2Lua"
    function restartNGXSDK2Lua()
    acName = ipc.readSTR(0x3D00, 100)
    if (string.find(acName, "NGX") == null) then
    return
    end

    resp = ngxSDK2Lua.start();

    if (resp ~= nil) then
    ipc.log(resp)
    end
    end
    function kill()
    ipc.log("Killing ngxSDK2Lua ...............")
    resp = ngxSDK2Lua.kill();

    if (resp ~= nil) then
    ipc.log(resp)
    end
    end
    event.offset(0x3D00, "STR" , "restartNGXSDK2Lua")
    event.terminate("kill")

    [/CODE]

    ...but I don't see the "Killing ngxSDK2Lua ..............." trace printed in the log, not sure it's working

  10. It isn't easy. In fact it is almost impossible unless I can trap the error in FSUIPC or get a full stack trace.

    The information you posted would be very useful IF you were using the exact same version of FSUIPC as me, because I could then find exactly where in the code the FSUIPC crash was. To that end please reproduce it using FSUIPC4812f

    On this one:

    If your DLL is creating another thread then you need to have it terminating itself when the main Lua thread terminates. To do this try using

    event.terminate

    which should allow you to call some function in your DLL to close down.

    Regards

    Pete

    Ok, I'll try that version of FSUIPC.

    It's a very rare occurrence really so it doesn't worry me much. I need to keep restarting the dll over and over again to trigger the error, so it's not that big of a deal I think.

    As for the event.terminate part, I'll try that, but I'm not creating a new thread in the dll in the end. It was crashing like mad when I tried it and couldn't figure out why, but will see if event.terminate helps

    Thanks for the suggestions

  11. Pete maybe you can give me some guidelines on how to proceed to debug this:

    When I restart the dll in the middle of a flight, I can do it in two ways:

    1.- Call the Lua script that starts the dll. It calls a function in the dll that starts the SimConnect communication. When I do that the previous instance seems to vanish on it's own, and the new one starts just fine. Problem is that after a number of restarts I get a CTD in FSUIPC4.dll (different fault offsets, here's two examples):

    Exception code: 0xc0000005

    Fault offset: 0x0004afc2

    Faulting process id: 0x1944

    Faulting application start time: 0x01cd118cc82d9b4b

    Faulting application path: C:\Program Files (x86)\Microsoft Games\Microsoft Flight Simulator X\fsx.exe

    Faulting module path: C:\Program Files (x86)\Microsoft Games\Microsoft Flight Simulator X\Modules\FSUIPC4.dll

    Exception code: 0xc0000005

    Fault offset: 0x0004dbaa

    Faulting process id: 0x1ab4

    Faulting application start time: 0x01cd118f381ebe6b

    Faulting application path: C:\Program Files (x86)\Microsoft Games\Microsoft Flight Simulator X\fsx.exe

    Faulting module path: C:\Program Files (x86)\Microsoft Games\Microsoft Flight Simulator X\Modules\FSUIPC4.dll

    2.- If I do a Lua KillAll I get an instant CTD in ntdll.dll:

    Exception code: 0xc0000029

    Fault offset: 0x000907b6

    Faulting process id: 0xc84

    Faulting application start time: 0x01cd118ba3ba321e

    Faulting application path: C:\Program Files (x86)\Microsoft Games\Microsoft Flight Simulator X\fsx.exe

    Faulting module path: C:\Windows\SysWOW64\ntdll.dll

    what tools can I use to figure out where the problem is please?

  12. Also note that I am still hopeful that FSUIPC4 can provide direct offset mapping for all the PMDG 737NGX data. The facility is already programmed. I am only waiting for PMDG's okay, because of the worrying EULA.

    There's a note in my Readme warning about that, and advising to check your forums here for possible news before doing anything with my dll.

    I still think this could end up being a useful Lua script installer, even if it doesn't use my dll at all.

  13. Damn, it's true!, it's not what I said. I'm trying with a release version of the dll with some traces in the log and the loop is running in the new thread. It's doing some weird things but it's running for sure and the creator thread is back to running the Lua script that launched the dll.

    The module runs but every now and then, randomly, a call to Lua fails (this is the FSUIPC log, where I print what comes from the dll. Every log line is a switch/knob I clicked):


    IRS_DisplaySelector: 1
    IRS_SysDisplay_R: 0
    IRS_DisplaySelector: 2
    IRS_DisplaySelector: 3
    IRS_DisplaySelector: 4
    IRS_DisplaySelector: 3
    IRS_DisplaySelector: 2
    IRS_DisplaySelector: 1
    [E] *** LUA Error: ...ht Simulator X\modules\linda/system/handlers-mcp.lua:168: attempt to perform arithmetic on a nil value
    IRS_DisplaySelector: 0
    IRS_DisplaySelector: 1
    IRS_DisplaySelector: 2
    IRS_DisplaySelector: 1
    IRS_DisplaySelector: 2
    [E] *** LUA Error: (null)
    IRS_DisplaySelector: 1
    IRS_DisplaySelector: 2
    [E] *** LUA Error: attempt to call a number value
    [/CODE]

    ...and finally crashes:

    Unhandled exception at 0x773015ee in fsx.exe: 0xC0000005: Access violation reading location 0x56085da3.

    I'll see what I can do.

    By the way, I'm doing this thing modular, so one will only need to drop a script in a folder and the dll will do the rest, and if you add a supported panel in the future, you just add the script (or run the installer again) and off you go.

    I plan on including some module(s) with the installer ready to use, maybe some GoFlight & Opencockpits panels

  14. It doesn't even get to the loop. The child dies because the parent dies (the function above returns). When the function


    extern "C" __declspec(dllexport) int luaopen_ngxSDK2Lua(lua_State *L)
    [/CODE]

    exits, the thread that created the child that runs the SimConnect part (startThread above) dies, and with it dies the "startThread" child.

    So the timeline would be like...

    Lua: require "ngxSDK2Lua"

    dll: extern "C" __declspec(dllexport) int luaopen_ngxSDK2Lua(lua_State *L)

    dll: spawns the "initCommunication" thread that should start the SimConnect part

    dll: the function luaopen_ngxSDK2Lua exits, execution back to Lua. Parent thread dies

    dll: child thread dies at some point while configuring SimConnect because the parent just died, FSX crashes to desktop.

    I would need some sort of Linux "fork" like function maybe? not sure, but I've reverted back to the old version with an init Lua script that I'll start with ipc.runlua so that the SimConnect stuff runs on it's own thread.

  15. One question please. I'm trying to spawn a thread to run the communication with the NGX


    void startThread() {
    initCommunication();
    }
    extern "C" __declspec(dllexport) int luaopen_ngxSDK2Lua(lua_State *L){
    // register Lua functions
    static const luaL_Reg functs [] = {
    {"registerOffsetMap", cpp_registerOffsetMap},
    {"registerLuaFile", cpp_registerLuaFile},
    ...
    {NULL,NULL}
    };
    luaL_register(L,"ngxSDK2Lua", functs);
    LuaGlobal = L;
    if (active) {
    return 0;
    }
    // run installed modules
    ...
    boost::thread thrd(startThread);
    thrd.detach();
    return 0;
    }
    [/CODE]

    this runs the first time I do a require "ngxSDK2Lua" in Lua. The idea is that control returns to the Lua script while the dll does it's stuff, but as soon as the the function returns, the child thread that starts the SimConnect communication dies.

    Until now I was starting the module using an independent Lua thread with ipc.runlua, but this would be better. Is it even possible please?

  16. I have no idea what's going on. All of a sudden I don't get any PMDG events detected in the dispatch method.

    I haven't changed anything in the Simconnect initialization and RequestClientData part.

    I get an event dwID 15, then a 2 and nothing else. Have commented out everything except for what's in the example provided by PMDG and still no go.

    I know it's not too much info, but maybe it rings a bell... or maybe I could upload the VS project

    So frustrating cause it's finished

    I'm sure I'm missing something stupid somewhere

  17. Pete, this is almost ready, but I'm geting random crashes if I run FSUIPC_Process(&dwResult); right after writing an offset:

    FSUIPC_Write(dwOffset, 1, pSrce, &dwResult);

    FSUIPC_Process(&dwResult);

    If I process the read/writes once after the entire dispatch loop is done, it works fine (probably a better way to go about it anyway)

    Not sure how to debug this

  18. I'm doing something I think should address the offset "issues", being those

    1.- I had no way to set offsets in the dll

    2.- setting offsets from lua via ipc lib is too slow. 500 iterations take some 20 seconds, so this module would be colmpletely useless for devices that listen to offsets that are being updated from Lua

    So I implemented a way to register items to be stored in any offset.

    An example:


    ngxSDK2Lua.registerOffset("IRS_DisplaySelector", 0x6CCC, "writeUB")
    [/CODE]

    this would instruct the dll to store any new data in the item "IRS_SysDisplay_R" to the offset 0x6CCC as an unsigned byte. Or..

    [CODE]
    ngxSDK2Lua.registerOffset("IRS_SysDisplay_R", 0x6DCC, "setbitsUB", 1) -- last param is the mask for setbitsUB
    [/CODE]

    to assign the IRS_SysDisplay_R boolean to the first bit (least significant) of the offset 0x6DCC

    I'll be using a hash map (I think it has direct access to the members) to speed things up

    [CODE]
    static std::hash_map<std::string, OffsetCall> offsetMappings;
    [/CODE]

    to retrieve a struct for each mapped item

    [CODE]
    struct OffsetCall
    {
    void (*offsetFunction)(DWORD dwOffset, void* valueOrMask);
    DWORD dwOffset;
    DWORD mask;
    };
    [/CODE]

    then call the offsetFunction with the new value of the item (or the mask for functions like setbitsXX or clearbitsXX)

    should be pretty fast me thinks, and it's 100% configurable

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