Jump to content
The simFlight Network Forums

FSUIPC C# Altitude Problem


Recommended Posts

Hello.

I'm currently using Phenty's C# DLL.

I'm currently designing a website whereby it uploads the flight's statistics (heading, IAS, lat/long, altitude,etc) to my server.

So far, I've got everything working perfectly except from the Altitude.

Here is a snippet of code from the application: (C# CODE)

Offset agl = new Offset(0x0570);
string altitude = agl.Value.ToString();

Here is a snippet of code from the server: (PHP CODE)

$altitude=round(substr(mysql_real_escape_string($_GET['altitude']),0,8));
 $altitude = $altitude * (65536.0 * 65536.0) * 3.28084;

My FS altitude currently shows: 2843FT

My server-side altitude shows: 6.56168FT

Could you please tell me what I'm doing wrong?

If needed, I'll start the IPC logging but I wouldn't assume it is required for this type of 'problem'

Cheers,

Link to comment
Share on other sites

Hi,

The altitude is stored in FSUIPC as an 8-byte integer, not a double so you need to declare the offset as a long:

Offset agl = new Offset(0x0570);

To convert this to a feet you need to divide by (65536.0 * 65536.0) and then multiply by 3.28084 for feet.

So your PHP should probably look more like this:

$altitude=round(substr(mysql_real_escape_string($_GET['altitude']),0,8));
 $altitude = $altitude / (65536.0 * 65536.0) * 3.28084;

See if that works...

Paul

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.