]> git.mxchange.org Git - flightgear.git/blobdiff - src/FDM/ExternalPipe/ExternalPipe.cxx
Merge branch 'maint' into next
[flightgear.git] / src / FDM / ExternalPipe / ExternalPipe.cxx
index 4cd13bc81a9f13c0a0dd7a3b40295406f8df06f4..8f33df584c36c0b719a94b7b8bd333aa9c519a00 100644 (file)
@@ -16,7 +16,7 @@
 //
 // You should have received a copy of the GNU General Public License
 // along with this program; if not, write to the Free Software
-// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 //
 // $Id$
 
@@ -32,6 +32,7 @@
 #endif
 
 #include <stdio.h>              // FILE*, fopen(), fread(), fwrite(), et. al.
+#include <iostream>             // for cout, endl
 
 #include <simgear/debug/logstream.hxx>
 #include <simgear/io/lowlevel.hxx> // endian tests
@@ -44,6 +45,8 @@
 
 #include "ExternalPipe.hxx"
 
+using std::cout;
+using std::endl;
 
 static const int MAX_BUF = 32768;
 
@@ -145,13 +148,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 +235,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 +298,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 +406,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 != 1 ) {
         SG_LOG( SG_IO, SG_ALERT, "Read error from named pipe: "
                 << 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
 }
 
@@ -520,6 +525,7 @@ void FGExternalPipe::update_property( double dt ) {
             cout << "Error reading data" << endl;
         } else {
             // cout << "  read " << strlen(cmd) << " bytes" << endl;
+            // cout << cmd << endl;
         }
 
         // chop trailing newline
@@ -538,7 +544,7 @@ void FGExternalPipe::update_property( double dt ) {
                 // node doesn't exist so create with requested type
                 node = fgGetNode( tokens[1].c_str(), true );
                 if ( tokens[2] == "bool" ) {
-                    node->setBoolValue(true);
+                    node->setBoolValue(false);
                 } else if ( tokens[2] == "int" ) {
                     node->setIntValue(0);
                 } else if ( tokens[2] == "double" ) {