Jump to content
The simFlight Network Forums

Paul Henty

Members
  • Posts

    1,646
  • Joined

  • Days Won

    74

Posts posted by Paul Henty

  1. Hi John,

    I can't see anything wrong with your code. 

    Quote

    I also put a watch on offset 7F00 as U32 in FSUIPC, but it seems to not be receiving anything.

    Have you tried just writing a basic offset - e.g. declare a standard int offset for 7F00 and just write 1 and 0 to it and see if it has any effect?  Should activate the first button on stick 64.

    If you're using FSUIPC7, the offsets list I have says this offset has not been tested/has unknown status.

    I can't check it here but maybe @John Dowsoncould have a quick look at this offset in FSUIPC7 and confirm if it's working or not.

    Paul

  2. SetValue() can be used on any writable offset which is most of them listed in the FSUIPC Offsets Status pdf. These offsets mainly map to K Variables internally. 

    Events (Also known as controls) can be sent using FSUIPCConnection.SendControlToFS().

    The PMDG SDK uses different methods for reading and controlling the aircraft. Using FSUIPC, reading is done with the special offset area. Controlling the aircraft is done by sending controls (events). 

    There are helper Enums built into my DLL for PMDG aircraft (e.g. PMDG_737_NGX_Control). The values of these can be passed to FSUIPCConnection.SendControlToFS().

    You also need to send a parameter value with the control. This can be a direct value (e.g. 0 or 1 for simple off/on switches) or a mouse button code to simulate a mouse click. See the PMDG .h file for details of the mouse codes.

    Paul  

    • Like 1
  3. Hi,

    There are a few mistakes:

    1. You're not calling Process():

    This is the main problem. Process() tells my DLL to get the latest values from FSUIPC. Without that nothing is ever read.

    Offset myOffset = new Offset(address, variableLength);
    FSUIPCConnection.Process();

     

    2. Your first switch statement doesn't contain an entry for 'bool' so the variableLength will be 0.

     

    3. You're trying to convert to float but asking for an Int64...

    valueFloat = Convert.ToInt64(...);

    should be:

    valueFloat = Convert.ToSingle(...);

     

    4. 'bool' and 'char' are not supported by my DLL as they have no equivalents in FSUIPC.

    Bools in FSUIPC are stored as integers of any size with a value of 0 or 1. For the PMDG offsets they are usually a 'byte' type (Length 1) with the value 0 or 1.

    You'll need something like this:

    case "Bool":
          byte valueByte = myOffset.GetValue<byte>();
          valueFloat = Convert.ToSingle(valueByte);
          valueBool = (valueByte > 0);  
          break;

     

    5. For Char you should use 'string' if you're trying to get back text from the char[] arrays: Of course these is no way to convert these to float:

    case "Char":
         string valueString = myOffset.GetValue<string>();
         break;

    The size of the offset should be set to the number of characters in the PMDG documentation: e.g. for AIR_DisplayLandAlt - char[6] :

    Offset AIR_DisplayLandAlt = new Offset(0x6572, 6);

     

    6. It's best not to keep opening and closing the connection if possible. Open it when your application starts and close it before it unloads.

     

    7. When you create new temporary offsets it's important to dispose of them. If you don't they stay active and take up space in the FSUIPC data table. Eventually your app will crash because the table will be full.

    Call the myOffset.Disconnect() method when you're finished with it. This will remove it from the FSUIPC table and allow the .NET garbage collector to dispose of it.

     

    With those changes you should be able to read proper values.

    Paul

  4. There are a number of ways to get the data from the CDU, depending on what level of detail you want. Here are the options:

                cdu0 = new PMDG_NGX_CDU_Screen(0x5400);
                cdu0.RefreshData();
    
                // Entire screen
                this.txtCDU.Text = cdu0.ToString("\r\n");
    
                // Individual Rows:
                string row3Text = cdu0.Rows[2].ToString(); // Rows are 0 based. Third row has index 2
    
                // Individual Cells:
                // e.g. Character in Row 3 (Index 2), First Character (Index 0):
                char R3C1Char = cdu0.Rows[2].Cells[0].Symbol;
                // Same but as a string:
                string R3C1String = cdu0.Rows[2].Cells[0].ToString();
    
                // Get cell colour:
                PMDG_NGX_CDU_COLOR R3C1Colour = cdu0.Rows[2].Cells[0].Color;
    
                // Get cell Flag:
                PMDG_NGX_CDU_FLAG R3C1Flags = cdu0.Rows[2].Cells[0].Flags;
                // Flags values can be combined (e.g. Small and Reversed). To check if a certain bit is set use the HasFlag method:
                bool cellIsReversed = R3C1Flags.HasFlag(PMDG_NGX_CDU_FLAG.REVERSE);

    Paul

  5. Hi Peter,

    The problem is going to be specific to your user's scenery (e.g. third party airports etc). Maybe one of the airports has a strange character in the name, or a missing runway number or something.

    The easiest way to solve this is if I could get the MakeRunways output files from the user's computer. I could then run the load() here and see what's causing the problem. I'll be able to put a check or workaround in my code to stop it crashing.

    I'll need:

    Runways.xml
    F5.csv
    R5.csv
    G5.csv
    Helipads.csv
    T5.csv

    If your user is not willing to send these to you then I'll come up with another plan.

    Paul

    • Thanks 1
  6. Hi Cliff,

    The FSUIPC protocol is based on the Win32 API, specifically sending messages between processes using the windows message pump. So the FSUIPC part is tied exclusively to the Windows operating system. It can't work on the Pi.

    For non-windows operating systems, one option is to use my WebSocketServer which allows reads and writes to offsets over a standard TCP WebSocket connection. The server runs on the Flight Sim PC and the data is exchanged using JSON format. Details are here:

    http://fsuipcwebsockets.paulhenty.com/

    You can use any tech that can can use WebSockets and JSON.

    If you're using .NET on the Pi there is a .NET library to make this process much easier called "FSUIPCWebSocketClientDLL" (also on NuGet). This library is very cross platform and targets .NET Standard 2 as well as more specific frameworks like .NET6 and Mono. It sets up and handles the websocket for you and does the conversion to/from JSON.

    The website above also includes details of this client DLL and has example code in C# and VB.NET and Javascript (for those using it from webbrowsers).

    An alternative would be to create your own client/server protocol to send messages to/from the Pi.

    There's no way to talk to FSUIPC directly on the Pi, you have to have some kind of bridge.

    Paul

  7. Hi Everyone,

    Version 3.2.24-beta is now on Nuget.

    This has a single, combined PMDG_737_NGX_Offsets class which automatically maps the offsets to the correct address depending on the simulator being used. Thanks to Andy B. for the idea. 

    In theory you should be able to use existing PMDG code with no changes and have it work with any simulator.

    Except: In order to determine the simulator being used, the class now needs an open connection when it's created. If you are currently calling "new PMDG_737_NGX_Offsets()" before your connection is open, you need to delay it until after the connection is open.

    The PMDG_737_MSFS_Offsets class has been deleted.

    There are a couple of offsets that have had their type corrected (e.g. vertical speed is now signed instead of unsigned).

    Also if anyone is using specific WideClient class instances, you now pass the class instance to the constructor and not to RefreshData().

    Paul

    • Like 1
  8. Yes, that's a great idea. I've had a look and it's possible to do a combined class. I didn't realise the offsets names were almost identical.

    The new MSFS class will be scrapped and I'll extend the old NGX class to include any new MSFS offsets. When you instantiate the class it will look at the flight sim you are connected to and create the offsets with the correct addresses.

    I'll have a new beta out later today.

    Paul

  9. Yes, I'll fix it. The documentation says this is a byte array instead of a character array so that's why it's wrong.

    I'll have a new beta version out soon. I'll be getting rid of the new MSFS version of the 737 offsets class and amending the original 'NGX' to intelligently switch to the MSFS offsets when connected to MSFS. The offsets names will be the same, you'll just have to change the class name where you instantiate it.

    Paul

  10. A new version of my DLL is now on NuGet (3.2.23-beta). You will need to tick the [show pre-release] box in the NuGet package manager to see this version.

    The current PMDG_737_NGX_Controls enum has been updated with the new controls for the MSFS 737s.

    There is also a new class called PMDG_737_MFSF_Offsets for the MSFS versions of the PMDG 737s.

    This works like the previous offset helpers. Details in this post if you're unfamiliar:

    Paul

  11. New version is now on NuGet (3.2.23-beta). You will need to tick the [show pre-release] box in the NuGet package manager to see this version.

    The current PMDG_737_NGX_Controls enum has been updated with the new controls for the MSFS 737s.

    The offsets for the MSFS version are very different to previous versions, so there is a new class called PMDG_737_MFSF_Offsets that contains the new offsets.

    This works like the previous offset helpers. Details in this post for anyone unfamiliar:

    Paul

     

  12. Thanks for the document. 

    I've just looked at the WebSocketServer - There's no need for a new version. It just needs the WAPID dll replacing with the new 0.9.1 version, but it looks like you've already done that in the latest installer. So everything looks okay.

    Paul

  13. 1 minute ago, John Dowson said:

    I have just released 7.3.12 which contains a fix for using custom controls - available from the usual places.
    Note that FSUIPC7, the WASM and the WAPI have also all been updated to VS2022 and the latest platform toolset. If you are using the WAPI then please update your application.

    @Paul HentyWill the websocketserver need an update for this?

    Yes, I'll get a new version to you by the end of today.

    Is the latest version of the PMDG Offsets list the MSFS 737 in this post?

    Paul

  14. 6 hours ago, Jason Fayre said:

    Paul, any idea when you might get the updated offset block into the .net library for the PMDG for MSFS?

    I planned to release a version later today to fix a small bug in the MSFSVariableServices. Now we have some clarity with the new PMDG SDK I'll also add the new Offsets and a new controls Enum (if they've changed - I haven't looked yet).

    Paul

  15. Hi Jason,

    The rotor brake method is described in this guide I wrote. It's aimed at people programming keys and joysticks but you will get the idea.

     

    Since the parameter is used to send the command you can only send mouse click actions. I can't see any way of sending values along with the command.

    However, I would caution against jumping into this immediately and rewriting your app until PMDG give a clear statement on which method is supposed to be used. The SDK document and .h file are using the same custom events method as P3D (which doesn't seem to work). During development they've been using the rotor brake method, which apparently does still work. 

    It would be very strange for an established and serious company to release an SDK that it complete nonsense, but I suppose it's possible. I would wait to see if there is any clarity, or you might find you have to change your code again. I'm certainly not integrating any of this into my DLL until I know what's going on.

    Paul

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