]> git.mxchange.org Git - simgear.git/blobdiff - Serial/serial.cxx
FreeBSD support.
[simgear.git] / Serial / serial.cxx
index 0106e242c458e79a7b439fcd71eb2e88ef6992ae..18173b43eace7a6b352162419f6b949d621fa0c7 100644 (file)
@@ -50,22 +50,47 @@ 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 required port parameters 
+    if ( tcgetattr( fd, &config ) != 0 ) {
+       FG_LOG( FG_SERIAL, FG_ALERT, "Unable to poll port settings" );
+       return false;
+    }
+
+    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" );
+       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 +136,6 @@ bool fgSERIAL::set_baud(int baud) {
        return false;
     }
 
-    cout << "successfully set baud to " << baud << endl;
-
     return true;
 }
 
@@ -157,6 +180,12 @@ int fgSERIAL::write_port(const string& value) {
 
 
 // $Log$
+// 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 ...
+//
 // Revision 1.1  1998/11/16 13:53:02  curt
 // Initial revision.
 //