Jump to content
The simFlight Network Forums

Strange behavior while reading offsets


Recommended Posts

Today I came across a very strange behavior trying to read offsets 09D2 and 0B26 (ICAOmanufacturer and ICAOmodel). I'm not sure if it's caused by the Client DLL or FSUIPC itself.

Somehow... the string seems to keep the previous value and just overwrite it partially:

The code is rather simple: 

  public partial class Form1 : Form
    {
        private Offset<string> ICAOmanufacturer = new Offset<string>("Aircraft", 0x09D2, 16);
        private Offset<string> ICAOModel = new Offset<string>("Aircraft", 0x0B26, 32);
        public Form1()
        {
            InitializeComponent();
        }

        private void Button1_Click(object sender, EventArgs e)
        {
            // Connect to FSUIPC
            try
            {
                if (!FSUIPCConnection.IsOpen)
                {
                    FSUIPCConnection.Open();
                    button1.Enabled = false;
                } else
                {
                    FSUIPCConnection.Close();
                }
            }
            catch
            {
                // NO FSUIPC running
            }
        }

        private void Button2_Click(object sender, EventArgs e)
        {
            try
            {
                FSUIPCConnection.Process("Aircraft");
                tbOutput.AppendText($"Manufacturer: {ICAOmanufacturer.Value}\r\nModel: {ICAOModel.Value}\r\n\r\n");
            } catch(Exception ex)
            {
                tbOutput.Text = $"Exception: {ex.Message}";
            }
        }

        private void Form1_FormClosing(object sender, FormClosingEventArgs e)
        {
            FSUIPCConnection.Close();
        }
    }

Do I oversee something?

Link to comment
Share on other sites

Your code looks fine. These offsets are new for FSUIPC7 so it looks like a problem specific to FSUIPC7. The historic string offsets like 0x3D00 work fine.

Please report this to John Dowson in the MSFS support sub-forum.

https://forum.simflight.com/forum/183-fsuipc7-msfs/

It looks to me like the 0 terminator at the end of the strings isn't being written. It also looks like there are double quotes in the string which shouldn't really be there. 

I guess you could find the end of the string by looking for the second double quote, but that's not really how it's meant to work. There should be a 0 terminator which my DLL will handle for you.

Paul

Link to comment
Share on other sites

Thank you Paul,

first I thought, that I messed up smthg in my code, as I'm working on a bigger project and there are already lots of forms, classes and stuff. I'm a pro at graphics, but not an expert programmer. Still learning new things every day, so I wasn't sure if it's not my fault. That's also the reason why I decided to go with the DLL client and not simconnect. I think it's a big help -> Can't thank you enough for making this possible btw and will definitely donate.
So I'm a bit stuck at the moment, because I gotta identify the loaded aircraft and have a hard time to do that. Tried all the listed offsets

private Offset<string> aircraftProfileName = new Offset<string>("AircraftID", 0x9540, 64);
private Offset<string> AIRfilePathname = new Offset<string>("AircraftID", 0x3C00, 256);
private Offset<string> ICAOdesignator = new Offset<string>("AircraftID", 0x0618, 16);
private Offset<string> ICAOmanufacturer = new Offset<string>("AircraftID", 0x09D2, 16);
private Offset<string> ICAOModel = new Offset<string>("AircraftID", 0x0B26, 32);
private Offset<string> title = new Offset<string>("AircraftID", 0x3D00, 256);

and found out, that the best way to identify the aircraft is 3D00. However, I gotta have a manufacturer and a model too to display it to the user. Unfortunately ASOBO, as well as third party devs don't really care much about keeping a straight line in naming their aircraft. In fact it's a totally mess! Sometimes the manufacturer name is missing completely, sometimes it's replaced by the dev name, sometimes it's at the beginning of the string, sometimes at the end. There's no structure at all in that. So I hoped the new offsets would help a bit to find a solution for that.
Looking for the second double quote sadly doesn't work, as I already came across aircraft, where the second one is missing (for whatever reason). Ok, maybe it's the string length, gotta check that.
Will report that to John.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

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