Jump to content
The simFlight Network Forums

wrong alternator value


whQQps

Recommended Posts

Hello.
I'm trying to make a simple switchbox program with Csharp using FSUIPC Client dll. offset declarations as below.
         private Offset<int> alternatoroffset = new Offset<int>("alternator", 0x3101);
         private Offset<int> masterbatteryoffset = new Offset<int>("masterbattery", 0x3102);
         private Offset<int> avionpwrofset = new Offset<int>("avionicspower", 0x3103);

For control, I assigned the offset values to the labels as below.
          lblalter.Text = this.alternatoroffset.Value.ToString();
          lblavion.Text = this.avionpwrofset.Value.ToString();
          lblmastbat .Text= this.masterbateryoffset.Value.ToString();

When avionics is off, the alternator offset value is 256 and 257. When avionics is on, the alternator offset is 65792 and 65793. I expect it to be 1 and 0. can you help me what is my mistake?

Edited by whQQps
Link to comment
Share on other sites

Hi,

All of these offsets are only 1 byte in length. This can be seen from the FSUIPC Offsets document: e,g,0x3101

image.thumb.png.8aa931ee79e7277ca48f7cc566a0083e.png

By declaring these offsets with type <int> you are reading 4 bytes instead of 1. For offset 0x3101 you are also reading 3102, 3103 and 3104 into one variable.

You must declare these offsets to be an integer of length 1. The C# type for this is either byte (unsigned: + values only) or sbyte (signed: + and - values).

Since the possible values for these offsets are only 0 and 1, just use <byte> like this:

         private Offset<byte> alternatoroffset = new Offset<byte>("alternator", 0x3101);
         private Offset<byte> masterbatteryoffset = new Offset<byte>("masterbattery", 0x3102);
         private Offset<byte> avionpwrofset = new Offset<byte>("avionicspower", 0x3103);

For more information on which C# type to use with different size offsets, please see the "Offset Types Chart" in the downloads section of the website:

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

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.