chrieger Posted July 31, 2005 Report Posted July 31, 2005 I found some here in the Forum, but am really not happy with the result. Here is what I found: Public Function Ground_Altitude() As Single ' meters Altitude MSL of ground under plane. Dim x As Long Dim y As Single Dim dwResult As Long Call FSUIPC_Read(&H7D4, 4, VarPtr(x), dwResult) Call FSUIPC_Process(dwResult) y = x If y > 32767 Then y = y - 65534 Ground_Altitude = y * 3.28083989501312 Label4.Caption = Ground_Altitude End Function But I will get not the same rsult as the FS9 will show me? Can somebody help? CHristoph
jd Posted July 31, 2005 Report Posted July 31, 2005 here's my code. what aren't you happy with? how much difference is there? Public Function Ground_Altitude() As Single ' meters Altitude MSL of ground under plane. Dim x As Long Dim Y As Single Dim dwResult As Long Call FSUIPC_Read(&HB4C, 2, VarPtr(x), dwResult) Call FSUIPC_Process(dwResult) Y = x If Y > 32767 Then Y = Y - 65534 Ground_Altitude = Mtof(Y) End Function
Pete Dowson Posted July 31, 2005 Report Posted July 31, 2005 Public Function Ground_Altitude() As Single ' meters Altitude MSL of ground under plane.Dim x As Long Dim y As Single Dim dwResult As Long Call FSUIPC_Read(&H7D4, 4, VarPtr(x), dwResult) Er7D4 certainly isn't "Ground Altitude", it is the altitude set in the autopilot. Please refer to the Programmer's Guide in the SDK. Furthermore: If y > 32767 Then y = y - 65534Ground_Altitude = y * 3.28083989501312 What is that about? You are reading a 32 bit value which, as it states in the document, is 65536 x the number of metres (entered into the A/P). Comparing it with 32767 doesn't do much (32768 = half a metre). And multiplying it by 3.2 .. etc doesn't give you feet unless you also divide by 65536. Regards, Pete
chrieger Posted July 31, 2005 Author Report Posted July 31, 2005 OK, I did try it: Call FSUIPC_Read(&HB4C, 2, VarPtr(x), dwResult) Call FSUIPC_Process(dwResult) I really do not get the correct height like I see in FS window (STrg + z) Peter I also tried to read directly the value for x, but it also does not read correct. I am reading Heading LAT and LON without any trouble, but the height seem not like I want.. Thanks Christoph
Pete Dowson Posted July 31, 2005 Report Posted July 31, 2005 OK, I did try it:Call FSUIPC_Read(&HB4C, 2, VarPtr(x), dwResult) Call FSUIPC_Process(dwResult) I really do not get the correct height like I see in FS window (STrg + z) The FS window Shift+Z does NOT show the GROUND altitude, it shows the AIRCRAFT altitude -- of course these will almost never be the same! Not only that but you are reading a 2 bytes value into a 32-bit (4-byte) variable, I think (forgive me if I'm wrong -- I don't know VB). You need to zero that beforehand to avoid getting rubbish. I am reading Heading LAT and LON without any trouble, but the height seem not like I want.. Hmm. Please think about things a bit longer and decide whether what "height" it is you want (aircraft, ground, VOR, NDB, Eiffel Tower? ;=)), then go find the correct offset and conversion in the documentation. Please also use FSInterrogate to investigate these things. It is provided for a reason. Regards, Pete
chrieger Posted July 31, 2005 Author Report Posted July 31, 2005 I need this height displayed in FS. But I also can not get the results with this: 0020 4 Ground altitude in Metres x 256. (see also offset 0B4C)
Pete Dowson Posted July 31, 2005 Report Posted July 31, 2005 I need this height displayed in FS.But I also can not get the results with this: 0020 4 Ground altitude in Metres x 256. (see also offset 0B4C) Yes, but that also is the GROUND altitude, NOT the height of the aircraft. The ground altitude is NOT displayed in FS!!! You seem very confused as to what you actually want to read! When you have decided, THEN look it up in the documentation, please. AND please please PLEASE use FSInterrogate to actually look at all these things, live, and see how they read and convert there. It is supplied as a tool explicitly to help you sort these things out for yourself! Regards, Pete
chrieger Posted August 1, 2005 Author Report Posted August 1, 2005 Thanks for your help, maybe it is a problem in writing and thinking in english. Sorry for my confusing questions, but I already stopped my programmings in this....
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now