Jump to content
The simFlight Network Forums

Recommended Posts

Posted

Hello

 

I am trying to write latitude to offset 0x0560 but I am having problems.

 

I am doing:

fsuipc_wrapper.WriteData(0x0560, 8, ByteBuffer.allocate(8).putLong(Double.doubleToLongBits((3.0/90.0)*(10001750.0*65536.0*65536.0))).array()); //Latitude is 3º (I want to set my aircraft at 3º), hardcoded for the moment

The operation

(3.0/90.0)*(10001750.0*65536.0*65536.0)

returns 1.4319063050922668E15 wich is the correct value to send to FS. (I think)

 

But the data received by FS is -4.2718529980465152E16 (getting the latitude after the data sent with the following:)

double d = (double)getLong(0x0560); //The class is extending FSUIPC

Does anybody see my problem?

 

Thanks.

Why is this?

Posted

Hello

 

I am trying to write latitude to offset 0x0560 but I am having problems.

 

I am doing:

fsuipc_wrapper.WriteData(0x0560, 8, ByteBuffer.allocate(8).putLong(Double.doubleToLongBits((3.0/90.0)*(10001750.0*65536.0*65536.0))).array()); //Latitude is 3º (I want to set my aircraft at 3º), hardcoded for the moment

The operation

(3.0/90.0)*(10001750.0*65536.0*65536.0)

returns 1.4319063050922668E15 wich is the correct value to send to FS. (I think)

 

But the data received by FS is -4.2718529980465152E16 (getting the latitude after the data sent with the following:)

double d = (double)getLong(0x0560); //The class is extending FSUIPC

Does anybody see my problem?

 

I don't know the language you are using, so I can't comment on that or whether you are using the correct variable types, but I would just ask why you are multiplying by 3.0. Since the FS units are designed so that the max possible value (90.0 or -90.0) just fits exactly into the 64 bits, I would have thought that multiplying it by 3 would make it too big to fit.

 

Did you think of trying the assorted logging facilities in FSUIPC to check your work. That's why they are there.

 

Regards

Pete

Posted

Hello

 

Can you please explain where I am multiplying by 3.0? I think I am dividing 3.0 by 90, and then that result is multiplied by the constants 10001750.0 and 65536.0 wich I don´t know where they come from. I think I am never multiplying it.

 

Thanks for help.

Posted

Hello

 

Can you please explain where I am multiplying by 3.0? I think I am dividing 3.0 by 90, and then that result is multiplied by the constants 10001750.0 and 65536.0 wich I don´t know where they come from. I think I am never multiplying it.

 

Thanks for help.

 

Er, it is pretty abvious, I would have thought, that

 

(3.0/90.0)*(10001750.0*65536.0*65536.0)

 

is 3 times bigger than:

 

(1.0/90.0)*(10001750.0*65536.0*65536.0)

 

which would give the correct conversion value. If that's not "multiplying by 3" then your understanding of multiplication is not the same as mine!

 

Writing your sum in a different way, it is identical to:

 

(3.0*10001750.0*65536.0*65536.0)/90.0

 

which may let you see how you are, for some reason, multiplying by 3!

 

Where do you get that 3.0 from? It doesn't appear in any documentation for the offset you are dealing with, so why is it there?

 

Did you not yet bother to check your work using the logging, or the Monitor facilities, in FSUIPC?

 

Pete

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.