Advanced Settings Panel
[pierogi] / protocols / rcaprotocol.cpp
index bd96c7c..593bb7f 100644 (file)
@@ -10,7 +10,7 @@ extern QMutex commandIFMutex;
 
 // I've found no official data on the RCA protocol yet, but from available
 // notes and guesswork I'm using the following:
-// A "zero" is encoded with a 500 usec pulse, 500 usec space.
+// A "zero" is encoded with a 500 usec pulse, 1000 usec space.
 // A "one" is encoded with a 500 usec pulse, and 2000 usec space.
 // The header is a 4000 usec pulse, 4000 usec space.
 // Commands end with a trailing 500 usec pulse.
@@ -28,7 +28,7 @@ RCAProtocol::RCAProtocol(
   unsigned int index)
   : SpaceProtocol(
       guiObject, index,
-      500, 500,
+      500, 1000,
       500, 2000,
       4000, 4000,
       500,
@@ -62,8 +62,11 @@ void RCAProtocol::startSendingCommand(
     // Do we even have this key defined?
     if (i == keycodes.end())
     {
-      std::string s = "Tried to send a non-existent command.\n";
-      throw PIRException(s);
+      QMutexLocker cifLocker(&commandIFMutex);
+      commandInFlight = false;
+      return;
+//      std::string s = "Tried to send a non-existent command.\n";
+//      throw PIRException(s);
     }
 
     // construct the device:
@@ -87,23 +90,26 @@ void RCAProtocol::startSendingCommand(
         // Check whether we've been asked to stop:
         if (checkRepeatFlag())
         {
+          break;
+/*
           QMutexLocker cifLocker(&commandIFMutex);
           commandInFlight = false;
           return;
+*/
         }
       }
 
       ++repeatCount;
     }
+
+    QMutexLocker cifLocker(&commandIFMutex);
+    commandInFlight = false;
   }
   catch (PIRException e)
   {
     // inform the gui:
     emit commandFailed(e.getError().c_str());
   }
-
-  QMutexLocker cifLocker(&commandIFMutex);
-  commandInFlight = false;
 }