Skip to content
View in the app

A better way to browse. Learn more.

The AVSIM Community

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

GPS Variables - again!

Featured Replies

  • Commercial Member

According to Bill's comprehensive mini-tutorial on flightsim.com, this should return the cruising altitude from the current flightplan:-PCSTRINGZ CruiseAlt;execute_calculator_code("(C:fs9gps:FlightPlanCruisingAltitude,string)",NULL,NULL,&CruiseAlt);All I get is a zero in CruiseAlt instead of (in this case) 22000 feet. Now, what I hope was a comprehensive search through the forum didn't turn up any help, so what I have I done wrong...?-Dai

Hi,In fs9, xml,%((@c:FlightPlanCruisingAltitude,feet))%!d!gives the cruising altitude of the loaded flightplan.(just tested)Even when you edit an existing flightplan with notepad and assign different altitudes for different segments, this code gives the changed cruising altitudes for that segments. Jan

Jan

 

 

 

"Beatus ille qui procul negotiis..."

  • Author
  • Commercial Member
I just noticed you were trying to get a string returned... did you try a float value?
I did.... the compiler (VS2003) complained and said it wanted to see a pczstring.[edit] Must have had finger trouble at some point because execute_calculator_code("(C:fs9gps:FlightPlanCruisingAltitude,feet)",&data,NULL,NULL);compiled okay this time but 'data' still returned zero.@Jan: I'm absolutely C-code only, I'm afraid. The truth is I actually don't have time to learn XML.-Dai
  • Moderator

Well, there's only one type left to try!How about:

SINT32 data=0;execute_calculator_code("(C:fs9gps:FlightPlanCruisingAltitude,feet)",NULL,&data,NULL);

I think Jan was simply pointing out that the XML equivalent does return a valid value...I note the !d! format and suspect that it may in fact be a SINT32 value.

Fr. Bill    

AOPA Member: 07141481 AARP Member: 3209010556


     Avsim Board of Directors | Avsim Forums Moderator
  • Commercial Member
Well, there's only one type left to try!How about:
SINT32 data=0;execute_calculator_code("(C:fs9gps:FlightPlanCruisingAltitude,feet)",NULL,&data,NULL);

I think Jan was simply pointing out that the XML equivalent does return a valid value...I note the !d! format and suspect that it may in fact be a SINT32 value.

I just tried that myself with no joy:
SINT32 cruise_altitude = NULLexecute_calculator_code("(C:fs9gps:FlightPlanCruisingAltitude,feet)",NULL,&cruise_altitude,NULL);And displayed in GDI:swprintf(arrE, L"%01d", (int) cruise_altitude );

Has anyone here ever successfully tested Exec Calc Code in a C gauge to access any GPS data?

  • Author
  • Commercial Member

I failed with SINT32 as well.All of the GPS variables under SDK Help | Core Utilities Kit | Variables | Simulation Variables | Aircraft Avionics Data work when called from execute_calculator_code but it wasn't until recently I had any reason to try the Panels and Gauges SDK | GPS Variables listing. I don't seem to be having a great deal of luck there - it's not an immediate problem but it's going to be one sooner or later.-Dai

If nothing has worked for you "C" guys yet maybe try to use the older style A: GPS vars - execute_calculator_code(A:Gps Wp Next Alt, feet) -or- (A:Gps Wp Prev Alt, feet) -or- (A:Gps Target Altitude, feet)After testing, they still do work in XML.But i believe as Jan and Ed have mentioned, the GPS ignores the flightplan altitude unless the flight plan is modified to include the waypoint altitudes.Just an idea.Roman

20AUG21_Avsim_Sig.png?dl=1  FS RTWR   SHRS F-111   JoinFS   Little Navmap 
 

 

It takes a few more lines of code, but you can read the entire flight plan, including cruise and segment alts, by initializing the gps panel variable (ref. SDK.Flightmap.cpp, gps_info.h in the SDK). It should save some processor cycles too.#define GPS_PANEL_VARIABLE_NAME "FS2002 GPS DATA" // variable for reading GPS infoMODULE_VAR var;initialize_var_by_name (&var, GPS_PANEL_VARIABLE_NAME);gpsinfo = (GPS_INFO*)var.var_ptr;For my purposes, I've observed that the segment alts I've saved in the flightplan are overwritten by the cruise alt when the GPS reads it. Is there a way to retrive the original segment alts through the GPS? Jan mentioned he can read them in FS9 via the "c:FlightPlanCruisingAltitude,feet" var, I wonder if that has changed for FSX or am I missing something?

  • Author
  • Commercial Member

Some threads back (of course I can't find which thread - I've just tried to look for it!! :( ) Ed was kind enough to explain why gps_info.h is not a good idea. It seems that (IIRC) for example, if you reset a flight you're quite likely to get a NULL_POINTER exception as FS loses sight of the gps information. Secondlly, there is something else wrong with the main FS code that prevents it from correctly reading sections of the gps_info file. Lastly (and I am sure about the number here) it restricts you to an absolute maximum of 32 waypoints. [Edit] Found the thread:- here-Dai

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.