]> git.mxchange.org Git - simgear.git/blobdiff - Serial/serial.cxx
Cygnus tools compatibility tweaks.
[simgear.git] / Serial / serial.cxx
index 9c9106b59d74031c07a6e93144bee0b825956813..e866f8f9d91375fe1a2e2b1414a147be767061b3 100644 (file)
@@ -22,6 +22,7 @@
 // (Log is kept at end of this file)
 
 
+#include <errno.h>
 #include <termios.h>
 #include <sys/types.h>
 #include <sys/stat.h>
@@ -60,14 +61,24 @@ bool fgSERIAL::open_port(const string& device) {
        dev_open = true;
     }
 
-    // set software flow control 
+    // set required port parameters 
     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;
+    cfmakeraw( &config );
+
+    // cout << "config.c_iflag = " << config.c_iflag << endl;
+
+    // software flow control on
+    // config.c_iflag |= IXON;
+    // config.c_iflag |= IXOFF;
+
+    // disable hardware flow control
+    // config.c_cflag |= CRTSCTS;
+
+    // cout << "config.c_iflag = " << config.c_iflag << endl;
 
     if ( tcsetattr( fd, TCSANOW, &config ) != 0 ) {
        FG_LOG( FG_SERIAL, FG_ALERT, "Unable to update port settings" );
@@ -79,7 +90,7 @@ bool fgSERIAL::open_port(const string& device) {
 
 bool fgSERIAL::set_baud(int baud) {
     struct termios config;
-    speed_t speed;
+    speed_t speed = B9600;
 
     if ( tcgetattr( fd, &config ) != 0 ) {
        FG_LOG( FG_SERIAL, FG_ALERT, "Unable to poll port settings" );
@@ -104,8 +115,10 @@ bool fgSERIAL::set_baud(int baud) {
        speed = B57600;
     } else if ( baud == 115200 ) {
        speed = B115200;
+#if defined( linux ) || defined( __FreeBSD__ )
     } else if ( baud == 230400 ) {
        speed = B230400;
+#endif
     } else {
        FG_LOG( FG_SERIAL, FG_ALERT, "Unsupported baud rate " << baud );
        return false;
@@ -170,6 +183,12 @@ int fgSERIAL::write_port(const string& value) {
 
 
 // $Log$
+// Revision 1.4  1998/11/23 21:47:00  curt
+// Cygnus tools compatibility tweaks.
+//
+// Revision 1.3  1998/11/19 13:52:54  curt
+// port configuration tweaks & experiments.
+//
 // Revision 1.2  1998/11/19 03:35:43  curt
 // Updates ...
 //