]> git.mxchange.org Git - flightgear.git/commitdiff
Updates ...
authorcurt <curt>
Thu, 19 Nov 1998 03:35:43 +0000 (03:35 +0000)
committercurt <curt>
Thu, 19 Nov 1998 03:35:43 +0000 (03:35 +0000)
Serial/serial.cxx
Serial/testserial.cxx

index 0106e242c458e79a7b439fcd71eb2e88ef6992ae..9c9106b59d74031c07a6e93144bee0b825956813 100644 (file)
@@ -50,22 +50,37 @@ fgSERIAL::~fgSERIAL() {
 }
 
 bool fgSERIAL::open_port(const string& device) {
+    struct termios config;
+
     if ( (fd = open(device.c_str(), O_RDWR | O_NONBLOCK)) == -1 ) {
        FG_LOG( FG_SERIAL, FG_ALERT, "Cannot open " << device
                << " for serial I/O" );
        return false;
     } else {
        dev_open = true;
-       return true;
     }
+
+    // set software flow control 
+    if ( tcgetattr( fd, &config ) != 0 ) {
+       FG_LOG( FG_SERIAL, FG_ALERT, "Unable to poll port settings" );
+       return false;
+    }
+
+    config.c_iflag |= IXON;
+    config.c_iflag |= IXOFF;
+
+    if ( tcsetattr( fd, TCSANOW, &config ) != 0 ) {
+       FG_LOG( FG_SERIAL, FG_ALERT, "Unable to update port settings" );
+       return false;
+    }
+
+    return true;
 }
 
 bool fgSERIAL::set_baud(int baud) {
     struct termios config;
     speed_t speed;
 
-    cout << "attempting to set baud rate to: " << baud << endl;
-
     if ( tcgetattr( fd, &config ) != 0 ) {
        FG_LOG( FG_SERIAL, FG_ALERT, "Unable to poll port settings" );
        return false;
@@ -111,8 +126,6 @@ bool fgSERIAL::set_baud(int baud) {
        return false;
     }
 
-    cout << "successfully set baud to " << baud << endl;
-
     return true;
 }
 
@@ -157,6 +170,9 @@ int fgSERIAL::write_port(const string& value) {
 
 
 // $Log$
+// Revision 1.2  1998/11/19 03:35:43  curt
+// Updates ...
+//
 // Revision 1.1  1998/11/16 13:53:02  curt
 // Initial revision.
 //
index b563ac76ab1ad473151342ea52b420d84c5dd10f..c582c13c316dc916c230ccdc31bf0ca537bd202d 100644 (file)
@@ -1,10 +1,23 @@
 #include <string>
 
+#include <Debug/logstream.hxx>
+
 #include "serial.hxx"
 
 main () {
-    fgSERIAL port( "/dev/ttyS1", 4800);
+    fgSERIAL port;
     string value;
+    bool result;
+
+    fglog().setLogLevels( FG_ALL, FG_INFO );
+
+    cout << "start of main" << endl;
+
+    result = port.open_port("/dev/ttyS1");
+    cout << "opened port, result = " << result << endl;
+
+    result = port.set_baud(4800);
+    cout << "set baud, result = " << result << endl;
 
     port.write_port("ATDT 626-9800\n");