X-Git-Url: http://git.maemo.org/git/?a=blobdiff_plain;f=protocols%2Fnecprotocol.cpp;h=ccaca0078dcac08ea43418a06d887b4ae0c8373e;hb=f3809ec697222bd9ad47c725bb72dd7272fd594b;hp=c29e5395d5400409e4658576665889c09893f219;hpb=7c3ee21c56417e0c615d20acb6f057d6394d1b48;p=pierogi diff --git a/protocols/necprotocol.cpp b/protocols/necprotocol.cpp index c29e539..ccaca00 100644 --- a/protocols/necprotocol.cpp +++ b/protocols/necprotocol.cpp @@ -9,13 +9,18 @@ extern bool commandInFlight; extern QMutex commandIFMutex; +// Debugging: +#include + // The official NEC protocol, as I understand it, has the following attributes: // A "zero" is encoded with a 560 usec pulse, 560 usec space. // A "one" is encoded with a 560 usec pulse, and 3*560 (1680) usec space. // The header is a 9000 usec pulse, 4500 usec space. // Commands end with a trailing 560 usec pulse. -// A repeat block is a 9000 usec pulse, 2250 usec space, then trailing pulse. +// A repeat block (if used) is a 9000 usec pulse, 2250 usec space, then +// trailing pulse. // Each command runs for 110000 usec before another can be executed. +// The normal carrier frequency is 38 kHz. NECProtocol::NECProtocol( QObject *guiObject, @@ -34,6 +39,7 @@ NECProtocol::NECProtocol( isExtendedNEC(extNEC), isShortRepeat(srtRep) { + setMinimumRepetitions(1); } @@ -62,8 +68,11 @@ void NECProtocol::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: @@ -96,23 +105,26 @@ void NECProtocol::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; }