1
0
Fork 0

- Filter the fuel switch position to allow it to slowly transition through

null space without killing the engine (hardware specific problem.)
- NMEA output: I'm slightly confused but it appears that a real GPS outputs
  traditional unix line endings on it's gps strings, we were outputing DOS
  CR/LF which was causing some confusion.  This changes the line ending
  convention to match that of a real gps.
- Calculate true ground track and speed for NMEA.
This commit is contained in:
curt 2004-03-14 23:04:32 +00:00
parent 5c0ae1c6f6
commit d77e8c75a1
2 changed files with 40 additions and 21 deletions

View file

@ -1309,10 +1309,10 @@ bool FGATC610x::do_radio_switches() {
// roll over // roll over
if ( digit_tuner[i] < last_digit_tuner[i] ) { if ( digit_tuner[i] < last_digit_tuner[i] ) {
// going up // going up
diff = 15 - last_digit_tuner[i] + digit_tuner[i]; diff = 16 - last_digit_tuner[i] + digit_tuner[i];
} else { } else {
// going down // going down
diff = digit_tuner[i] - 15 - last_digit_tuner[i]; diff = digit_tuner[i] - 16 - last_digit_tuner[i];
} }
} }
digit[i] += diff; digit[i] += diff;
@ -1863,11 +1863,20 @@ bool FGATC610x::do_switches() {
fuel = 0; fuel = 0;
} }
static int fuel1, fuel2, fuel3; const int max_fuel = 60;
fuel3 = fuel2; static int fuel_list[max_fuel];
fuel2 = fuel1; int i;
fuel1 = fuel; for ( i = max_fuel - 1; i >= 0; --i ) {
if ( fuel1 == fuel2 && fuel2 == fuel3 ) { fuel_list[i+1] = fuel_list[i];
}
fuel_list[0] = fuel;
bool all_same = true;
for ( i = 0; i < max_fuel - 1; ++i ) {
if ( fuel_list[i] != fuel_list[i+1] ) {
all_same = false;
}
}
if ( all_same ) {
fgSetBool( "/controls/fuel/tank[0]/fuel_selector", (fuel & 0x01) > 0 ); fgSetBool( "/controls/fuel/tank[0]/fuel_selector", (fuel & 0x01) > 0 );
fgSetBool( "/controls/fuel/tank[1]/fuel_selector", (fuel & 0x02) > 0 ); fgSetBool( "/controls/fuel/tank[1]/fuel_selector", (fuel & 0x02) > 0 );
} }

View file

@ -88,7 +88,7 @@ bool FGNMEA::gen_message() {
} }
deg = (int)(latd); deg = (int)(latd);
min = (latd - (double)deg) * 60.0; min = (latd - (double)deg) * 60.0;
sprintf( gga_lat, "%02d%06.3f,%c", abs(deg), min, dir); sprintf( gga_lat, "%02d%07.4f,%c", abs(deg), min, dir);
sprintf( rmc_lat, "%02d%07.4f,%c", abs(deg), min, dir); sprintf( rmc_lat, "%02d%07.4f,%c", abs(deg), min, dir);
char gga_lon[20], rmc_lon[20]; char gga_lon[20], rmc_lon[20];
@ -101,18 +101,27 @@ bool FGNMEA::gen_message() {
} }
deg = (int)(lond); deg = (int)(lond);
min = (lond - (double)deg) * 60.0; min = (lond - (double)deg) * 60.0;
sprintf( gga_lon, "%03d%06.3f,%c", abs(deg), min, dir); sprintf( gga_lon, "%03d%07.4f,%c", abs(deg), min, dir);
sprintf( rmc_lon, "%03d%07.4f,%c", abs(deg), min, dir); sprintf( rmc_lon, "%03d%07.4f,%c", abs(deg), min, dir);
double vn = fgGetDouble( "/velocities/speed-north-fps" );
double ve = fgGetDouble( "/velocities/speed-east-fps" );
double fps = sqrt( vn*vn + ve*ve );
double mps = fps * SG_FEET_TO_METER;
double kts = mps * SG_METER_TO_NM * 3600;
char speed[10]; char speed[10];
sprintf( speed, "%05.1f", cur_fdm_state->get_V_equiv_kts() ); sprintf( speed, "%.1f", kts );
double hdg_true = atan2( ve, vn ) * SGD_RADIANS_TO_DEGREES;
if ( hdg_true < 0 ) {
hdg_true += 360.0;
}
char heading[10]; char heading[10];
sprintf( heading, "%05.1f", cur_fdm_state->get_Psi() * SGD_RADIANS_TO_DEGREES ); sprintf( heading, "%.1f", hdg_true );
char altitude_m[10]; char altitude_m[10];
sprintf( altitude_m, "%02d", sprintf( altitude_m, "%.1f",
(int)(cur_fdm_state->get_Altitude() * SG_FEET_TO_METER) ); cur_fdm_state->get_Altitude() * SG_FEET_TO_METER );
char date[10]; char date[10];
int year = t->getGmt()->tm_year; int year = t->getGmt()->tm_year;
@ -128,14 +137,15 @@ bool FGNMEA::gen_message() {
} else { } else {
dir = 'E'; dir = 'E';
} }
sprintf( magvar, "%05.1f,%c", magdeg, dir ); sprintf( magvar, "%.1f,%c", magdeg, dir );
// $GPRMC,HHMMSS,A,DDMM.MMMM,N,DDDMM.MMMM,W,XXX.X,XXX.X,DDMMYY,XXX.X,E*XX // $GPRMC,HHMMSS,A,DDMM.MMMM,N,DDDMM.MMMM,W,XXX.X,XXX.X,DDMMYY,XXX.X,E,A*XX
sprintf( rmc, "GPRMC,%s,A,%s,%s,%s,%s,%s,%s", sprintf( rmc, "GPRMC,%s,A,%s,%s,%s,%s,%s,%s,A",
utc, rmc_lat, rmc_lon, speed, heading, date, magvar ); utc, rmc_lat, rmc_lon, speed, heading, date, magvar );
sprintf( rmc_sum, "%02X", calc_nmea_cksum(rmc) ); sprintf( rmc_sum, "%02X", calc_nmea_cksum(rmc) );
sprintf( gga, "GPGGA,%s,%s,%s,1,08,0.9,%s,M, , ", // $GPGGA,HHMMSS,DDMM.MMMM,N,DDDMM.MMMM,W,1,NN,H.H,AAAA.A,M,GG.G,M,,*XX
sprintf( gga, "GPGGA,%s,%s,%s,1,08,0.9,%s,M,0.0,M,,",
utc, gga_lat, gga_lon, altitude_m ); utc, gga_lat, gga_lon, altitude_m );
sprintf( gga_sum, "%02X", calc_nmea_cksum(gga) ); sprintf( gga_sum, "%02X", calc_nmea_cksum(gga) );
sprintf( gsa, "%s", sprintf( gsa, "%s",
@ -152,20 +162,20 @@ bool FGNMEA::gen_message() {
nmea_sentence += rmc; nmea_sentence += rmc;
nmea_sentence += "*"; nmea_sentence += "*";
nmea_sentence += rmc_sum; nmea_sentence += rmc_sum;
nmea_sentence += "\r\n"; nmea_sentence += "\n";
// GGA sentence // GGA sentence
nmea_sentence += "$"; nmea_sentence += "$";
nmea_sentence += gga; nmea_sentence += gga;
nmea_sentence += "*"; nmea_sentence += "*";
nmea_sentence += gga_sum; nmea_sentence += gga_sum;
nmea_sentence += "\r\n"; nmea_sentence += "\n";
// GSA sentence (totally faked) // GSA sentence (totally faked)
nmea_sentence += gsa; nmea_sentence += gsa;
nmea_sentence += "\r\n"; nmea_sentence += "\n";
// cout << nmea_sentence; // cout << nmea_sentence;
length = nmea_sentence.length(); length = nmea_sentence.length();
strncpy( buf, nmea_sentence.c_str(), length ); strncpy( buf, nmea_sentence.c_str(), length );