Jump to content
The simFlight Network Forums

Paul Henty

Members
  • Posts

    1,652
  • Joined

  • Days Won

    74

Posts posted by Paul Henty

  1. Version 1.1.2 is now on the website:

    http://fsuipcwebsockets.paulhenty.com/index.html#home

    I've added two 'wildcard' addresses to the dropdown list. (Note that these are not my invention, they are built into Windows. How they work is down to Windows not me.)

    1. * (Handles requests on all physical IP Addresses. Doesn't seem to work with any host names or the 127.0.0.1 loopback address.)
    2. + (Handles requests on all IP Addresses and host names. This creates a secure URL that needs admin permissions.)

    Paul

    • Like 1
  2. As John pointed out the Socket Server runs with any version of FSUIPC from 3 onwards. The only difference is that the 'vars' command will run in a legacy mode for all versions before 7. This is significantly slower than the way 'vars' are handled with MSFS.

    4 hours ago, cknipe said:

    When using WebSocketServer (latest FSUIPC7), if I bind the application to an IP address other than 127.0.0.1 (localhost) - it requires Windows Admin rights to run?  Surely this doesn't seem correct

    Certain URLs and Ports are secured by Windows. To use them, the account the application is running under needs permission.

    You can achieve this is two ways:

    1. By running the application as Admin.

    2. By giving the required permission to the current user. This is done using the following command: (You can execute this in the command window or in code):

    netsh http add urlacl url=[URL TO REGISTER] user=[DOMAIN]\[USER OR GROUP]

    e.g. my PC here is call PJH. My user name is Paul. If I want to use the URL http://PJH:2048/fsuipc I would need this command:

    netsh http add urlacl url=http://PJH:2048/fsuipc/ user=PJH\Paul

    To run this command you need to be running 'as admin'. But once you've given permissions the socket server will be able to work without admin privileges.

    I will add this information to the website.

     

    4 hours ago, cknipe said:

    PS - would be nice to bind to multiple IPs, or listen on any/all IPs.

    A listener can only bind to a one URL. Binding to multiple IPs would require starting multiple listeners on the server side and handling requests from any of them. I don't want to make such a fundamental change to the application at this point. 

    Listening on all IPs might be possible as it looks like the URL can include wildcard symbols. So something like http://*:2048/fsuipc will listen on all IPs.

    At the moment there's no way of typing this in as you need to choose from the dropdown list. I'll look into change this to allow any URL to be typed in. (If the wildcards work).

    This will not get around the Windows security however. You'll still need to grant permissions to the wildcard URL or be running 'as administrator'. 

    Paul 

     

  3. Your C# code shows Keys.D1. Did you paste the wrong line? The log shows you sent the 2 key...

       867593 FSUIPC Control Action: Ctrl=1070, Param=4658
       867593 SendKeyToFS(00030032=[alt+ctl+2], KEYDOWN) ctr=0

    I'm assuming you are calling 

    FSUIPCConnection.SendKeyToFS(Keys.D2, SendModifierKeys.Control | SendModifierKeys.Alt);

    You can see from the log (in bold above) that my DLL has passed on the correct key code to FSUIPC.

    @John DowsonMight be able to tell you why this key combination is working from the keyboard but not through the IPC interface.

    Paul

  4. Quote

    event.offsetmask(0x281C, 1,"UB","Batteryswitch")

    You're using "UB" which is 1 byte. Offset 0x281C is 4 bytes. So you're only testing the first byte. This will always be 0 because the entire 4-byte offset only stores 0 and 1. The actual bit you want to test is in offset 0x281F.

    You can with target that byte:

    event.offsetmask(0x281F, 1,"UB","Batteryswitch")

    or tell LUA read the full 4 bytes from the original offset with "UD" (unsigned double word)

    event.offsetmask(0x281C, 1,"UD","Batteryswitch")

    You don't really need to test the individual bit as only one bit is ever flipped - the entire offset value can only be 0 or 1.

    So you could also use the plain event.offset function like this and test the entire value (0 or 1):

    event.offset(0x281C,"UD","Batteryswitch")

    Paul

  5. Hi Patrick,

    You can search for a PayloadStation by name using the Find() method:

            private void btnSendData_Click(object sender, RoutedEventArgs e)
            {
                FSUIPCConnection.PayloadServices.RefreshData();
                // Assign the payload stations to our class level variable for easier access
                this.payloadStations = FSUIPCConnection.PayloadServices.PayloadStations;
    
                //Assigning only one Cabin
                // Find PayloadStation by name (NOTE: The matching is case-sensitive)
                FsPayloadStation CabOA = this.payloadStations.Find(ps => ps.Name == "CAB OA");
                if (CabOA != null)
                {
                    // Payload station found
                    double newWeightKGs = 0;
                    if (double.TryParse(txtboxCabOa.Text, out newWeightKGs))
                    {
                        CabOA.WeightKgs = newWeightKGs;
                    }
                }
                FSUIPCConnection.PayloadServices.WriteChanges();
            }

     Paul

     

  6. Hi Patrick,

    There are a few problems I can see. I've marked the corrected code to match the numbered points below:

    1. Before you change any payload/fuel data you need to read the current payload/fuel state.

    2. Your code never assigns the variable 'this.fuelTanks' to anything. It's always null. There's no need to have this variable.

    3. 'tankControl' is specific to my example application. Instead you need to use one of the FSFuelTanks enum values.

    4. You can't use the text in the textbox as a number. It's a string. You need to manually convert (parse) it to a number type (in this case double).

    Here's the corrected code:

            private void btnWrite_Click(object sender, RoutedEventArgs e)
            {
                // Get reference to save typing
                PayloadServices ps = FSUIPCConnection.PayloadServices;
    
                // Get latest values (1)
                ps.RefreshData();
    
                // Get the centre tank (3)
                FsFuelTank centreMainTank = ps.FuelTanks[FSFuelTanks.Centre_Main];
    
                // Convert the text (string) in the textbox to a number (double) (4)
                double newWeightKGs = 0;
                if (double.TryParse(txtboxCenterTank.Text, out newWeightKGs))
                {
                    // Number converted okay
                    // Assign new value to the fuel tank weight
                    centreMainTank.WeightKgs = newWeightKGs;
                }
    
                // Change more fueltanks here....
    
                // Write any changes to the sim
                ps.WriteChanges();
            }

    Paul

  7. Hi Robert,

    The diagram makes things much clearer.

    You could achieve this without using my DLL. If your main application is in C++ and you're using SimConnect there doesn't seem to be any reason to use a .NET DLL.

    You can use SimConnect to get data from MSFS. (Instead of FSUIPC Offsets).

    You can also talk to the FSUIPC WASM Module directly from C++. Check the download on the FSUIPC website called "FSUIPC WASM Module 1.0.2 + WAPI 1.0.2". That includes all the C++ libraries/examples you need.

    http://fsuipc.com

    That would seem much simpler to me. Only one language, one fewer component, no communication layer between C++ and the VB component, and no .NET runtime.

    image.png.7c76baed9bfae1f3fd0f981b3da04726.png

    The WASM will handle the L:Vars (XML Vars) and the SimConnect will handle Events and SimVars.

    Paul 

    • Like 1
  8. Quote

    Now if only I could figure out how to get to those pesky XMLVARs from C++ or VB...

    If you mean local panel variables (or L:Vars) you can use my DLL. For all sims you can use use:

    FSUIPCConnection.ReadLVar()

    For MSFS you can also use the MSFSVariableServices class. This also allows you to set H:Vars as well.

    This is more complicated, but is thousands of times faster than ReadLVar().

    There is an example project dedicated to MSFSVariableServices on the website...

    http://fsuipc.paulhenty.com/#downloads

    Paul

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