Jump to content
The simFlight Network Forums

FSUIPC offset control throttle


Recommended Posts

hello everyone

 

I have question about control throttle on cessna(default plane) by c#.net.when i control throttle to 100%( value = 16384) the Prop level will be come to 0. i don't know why.did you have any idea for this.

 

ENG1_Throttle_lever = 088C

ENG1_Prop_lever = 088E

 

my code

 

private Offset<int> ENG1 = new Offset<int>(0x088C);  // Basic integer read and write example

 

......

 

 private void button1_Click(object sender, EventArgs e)
        {
          
            this.ENG1.Value = 16384;

        }

 

Thank you.

 

Link to comment
Share on other sites

hello everyone

 

I have question about control throttle on cessna(default plane) by c#.net.when i control throttle to 100%( value = 16384) the Prop level will be come to 0. i don't know why.did you have any idea for this.

 

ENG1_Throttle_lever = 088C

ENG1_Prop_lever = 088E

 

my code

 

private Offset<int> ENG1 = new Offset<int>(0x088C);  // Basic integer read and write example

 

......

 

 private void button1_Click(object sender, EventArgs e)

        {

          

            this.ENG1.Value = 16384;

        }

 

Thank you.

 

Those offsets are 16-bit (short) signed integers, not 32-bit "int"s! You are writing 32 bits, so overwriting 088C to 088F, which obviously includes 088E-F, the prop.

 

ALWAYS take note of the sizes and types of the data.

 

Pete

Link to comment
Share on other sites

Hello Pete Dowson

 

Thank you for your reply.in my understood  value of Sint 16 bit is 0-16383 and Sint 32 bit is 0-32767. and i change value to 16383 but everything same.

i don't understand why value 16383 overwriting to next register because i use only  this.ENG1.Value = 16383;

 

Sorry, but you misunderstand completely!

 

First off the range of a signed short integer (16 bit) is -32768 to +32767. The range of a normal 32-bit integer is -2147483648 to +2147483647.

 

The problem is that you are writing 4 bytes (=32 bits) to a value which is only 2 bytes (16-bits) long. Therefore you are writing the upper 16-bits of your value to the address of the Prop Pitch value! It wouldn't matter what number you wrote to the throttle, you are also writing to the prop pitch!!!

 

You need to understand data types and their lengths! I don't know the programming language you are using but I think you should refer to is documentation or manual and learn a bit more about data types.

 

Regards

Pete

Link to comment
Share on other sites

Since this offset is only 2 bytes long you should declare the offset as a shot integer like this:

private Offset<short> ENG1 = new Offset<short>(0x088C);

The value you write in the offset doesn't determine its size in bytes. A 0 stored in an 'int' is still 4 bytes long.

 

Declaring the correct variable type for each offset is very important. My UserGuide.pdf (located in the 'Docs' folder of the FSUIPCClient DLL Zip file) has a table on page 7 explaining what C# types to use given the size of the offset.

 

Paul

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • 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.