]> git.mxchange.org Git - flightgear.git/blobdiff - src/FDM/ExternalPipe/ExternalPipe.cxx
Harald JOHNSEN:
[flightgear.git] / src / FDM / ExternalPipe / ExternalPipe.cxx
index a94525448ac30bec378035050ab5d4a6df25671b..614084bef57d968deae2f6fa1f967eb81f35e616 100644 (file)
@@ -145,13 +145,15 @@ static int write_binary( char cmd_type, FILE *pd, char *cmd, int len ) {
     memcpy( buf + 3, cmd, len );
 
     if ( cmd_type == '1' ) {
-        cout << "writing '";
-        for ( int i = 0; i < len + 3; ++i ) {
+        cout << "writing ";
+        cout << (int)hi << " ";
+        cout << (int)lo << " '";
+        for ( int i = 2; i < len + 3; ++i ) {
             cout << buf[i];
         }
         cout << "' (" << cmd << ")" << endl;
     } else if ( cmd_type == '2' ) {
-        cout << "writing controls packet" << endl;
+        // cout << "writing controls packet" << endl;
     } else {
         cout << "writing unknown command?" << endl;
     }
@@ -230,7 +232,7 @@ void FGExternalPipe::init_binary() {
     double lon = fgGetDouble( "/sim/presets/longitude-deg" );
     double lat = fgGetDouble( "/sim/presets/latitude-deg" );
     double alt = fgGetDouble( "/sim/presets/altitude-ft" );
-    double ground = fgGetDouble( "/environment/ground-elevation-m" );
+    double ground = get_Runway_altitude_m();
     double heading = fgGetDouble("/sim/presets/heading-deg");
     double speed = fgGetDouble( "/sim/presets/airspeed-kt" );
     double weight = fgGetDouble( "/sim/aircraft-weight-lbs" );
@@ -293,7 +295,7 @@ void FGExternalPipe::init_property() {
     double lon = fgGetDouble( "/sim/presets/longitude-deg" );
     double lat = fgGetDouble( "/sim/presets/latitude-deg" );
     double alt = fgGetDouble( "/sim/presets/altitude-ft" );
-    double ground = fgGetDouble( "/environment/ground-elevation-m" );
+    double ground = get_Runway_altitude_m();
     double heading = fgGetDouble("/sim/presets/heading-deg");
     double speed = fgGetDouble( "/sim/presets/airspeed-kt" );
     double weight = fgGetDouble( "/sim/aircraft-weight-lbs" );
@@ -401,23 +403,23 @@ void FGExternalPipe::update_binary( double dt ) {
     // cout << "iterations = " << iterations << endl;
     ptr += sizeof(int);
     memcpy( ptr, (char *)(&ctrls), length );
-    cout << "writing control structure, size = "
-         << length + sizeof(int) << endl;
+    // cout << "writing control structure, size = "
+    //      << length + sizeof(int) << endl;
 
     result = write_binary( '2', pd1, buf, length + sizeof(int) );
     fflush( pd1 );
 
     // Read fdm values
     length = sizeof(fdm);
-    cout << "about to read fdm data from remote fdm." << endl;
+    // cout << "about to read fdm data from remote fdm." << endl;
     result = fread( (char *)(& fdm), length, 1, pd2 );
-    if ( result != length ) {
+    if ( result != 1 ) {
         SG_LOG( SG_IO, SG_ALERT, "Read error from named pipe: "
-                << fifo_name_2 );
+                << fifo_name_2 << " expected 1 item, but got " << result );
     } else {
-        cout << "  read successful." << endl;
+        // cout << "  read successful." << endl;
+        FGNetFDM2Props( &fdm, false );
     }
-    FGNetFDM2Props( &fdm, false );
 #endif
 }
 
@@ -431,7 +433,7 @@ static void process_set_command( const string_list &tokens ) {
         cur_fdm_state->_updateGeodeticPosition( lat_rad, lon_rad,
                                                 alt_m * SG_METER_TO_FEET );
 
-        double agl_m = alt_m - globals->get_scenery()->get_cur_elev();
+        double agl_m = alt_m - cur_fdm_state->get_Runway_altitude_m();
         cur_fdm_state->_set_Altitude_AGL( agl_m * SG_METER_TO_FEET );
     } else if ( tokens[1] == "euler_angles" ) {
         double phi_rad   = atof( tokens[2].c_str() );