March 31, 201016 yr 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
March 31, 201016 yr Commercial Member Nothing... near as I can tell... the GPS ignores the cruise altitude setting in a flight plan. ATC pays attention to it, but the GPS apparently doesn't. Ed Wilson Mindstar AviationMy Playland - I69
March 31, 201016 yr Commercial Member I just noticed you were trying to get a string returned... did you try a float value? Ed Wilson Mindstar AviationMy Playland - I69
March 31, 201016 yr 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..."
March 31, 201016 yr 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
March 31, 201016 yr 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
April 1, 201016 yr 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? B. York FS2Crew Web Site / FS2Crew Facebook Page / FS2Crew Discord
April 1, 201016 yr 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
April 1, 201016 yr 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 FS RTWR SHRS F-111 JoinFS Little Navmap
April 1, 201016 yr Author Commercial Member Hi RomanEven after assigning an arbitary height to every waypoint in the flightplan, cruise alt still returns zero. As Ed says, it looks like it's fubar'd from C.-Dai
April 2, 201016 yr 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?
April 3, 201016 yr 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