]> git.mxchange.org Git - flightgear.git/blobdiff - src/Network/generic.cxx
#591: night-time rendering issues, avoid negative color values
[flightgear.git] / src / Network / generic.cxx
index 1ed607a39dad08e8869e96c6d5f56e9dfb86322e..8a3aa440f5861a50f7a57b531087e837c130efc1 100644 (file)
@@ -55,7 +55,7 @@ FGGeneric::FGGeneric(vector<string> tokens) : exitOnError(false)
     }
 
     if (configToken >= tokens.size()) {
-       SG_LOG(SG_GENERAL, SG_ALERT,
+       SG_LOG(SG_NETWORK, SG_ALERT,
               "Not enough tokens passed for generic protocol");
        return;
     }
@@ -64,8 +64,8 @@ FGGeneric::FGGeneric(vector<string> tokens) : exitOnError(false)
     file_name = config+".xml";
     direction = tokens[2];
 
-    if (direction != "in" && direction != "out") {
-        SG_LOG(SG_GENERAL, SG_ALERT, "Unsuported protocol direction: "
+    if (direction != "in" && direction != "out" && direction != "bi") {
+        SG_LOG(SG_NETWORK, SG_ALERT, "Unsuported protocol direction: "
                << direction);
     }
 
@@ -433,7 +433,9 @@ bool FGGeneric::open() {
 
     set_enabled( true );
 
-    if ( get_direction() == SG_IO_OUT && ! preamble.empty() ) {
+    if ( ((get_direction() == SG_IO_OUT )||
+          (get_direction() == SG_IO_BI))
+          && ! preamble.empty() ) {
         if ( ! io->write( preamble.c_str(), preamble.size() ) ) {
             SG_LOG( SG_IO, SG_WARN, "Error writing preamble." );
             return false;
@@ -448,13 +450,17 @@ bool FGGeneric::open() {
 bool FGGeneric::process() {
     SGIOChannel *io = get_io_channel();
 
-    if ( get_direction() == SG_IO_OUT ) {
+    if ( (get_direction() == SG_IO_OUT) ||
+         (get_direction() == SG_IO_BI) ) {
         gen_message();
         if ( ! io->write( buf, length ) ) {
             SG_LOG( SG_IO, SG_WARN, "Error writing data." );
             goto error_out;
         }
-    } else if ( get_direction() == SG_IO_IN ) {
+    }
+
+    if (( get_direction() == SG_IO_IN ) ||
+        (get_direction() == SG_IO_BI) ) {
         if ( io->get_type() == sgFileType ) {
             if (!binary_mode) {
                 length = io->readline( buf, FG_MAX_MSG_SIZE );
@@ -511,7 +517,9 @@ error_out:
 bool FGGeneric::close() {
     SGIOChannel *io = get_io_channel();
 
-    if ( get_direction() == SG_IO_OUT && ! postamble.empty() ) {
+    if ( ((get_direction() == SG_IO_OUT)||
+          (get_direction() == SG_IO_BI))
+          && ! postamble.empty() ) {
         if ( ! io->write( postamble.c_str(), postamble.size() ) ) {
             SG_LOG( SG_IO, SG_ALERT, "Error writing postamble." );
             return false;
@@ -535,15 +543,15 @@ FGGeneric::reinit()
     path.append("Protocol");
     path.append(file_name.c_str());
 
-    SG_LOG(SG_GENERAL, SG_INFO, "Reading communication protocol from "
+    SG_LOG(SG_NETWORK, SG_INFO, "Reading communication protocol from "
                                 << path.str());
 
     SGPropertyNode root;
     try {
         readProperties(path.str(), &root);
-    } catch (const sg_exception &) {
-        SG_LOG(SG_GENERAL, SG_ALERT,
-         "Unable to load the protocol configuration file");
+    } catch (const sg_exception & ex) {
+        SG_LOG(SG_NETWORK, SG_ALERT,
+         "Unable to load the protocol configuration file: " << ex.getFormattedMessage() );
          return;
     }