cec: renamed WaitForAck() to WaitForTransmitSucceeded(), because it waits for the...
authorLars Op den Kamp <lars@opdenkamp.eu>
Mon, 31 Oct 2011 19:47:19 +0000 (20:47 +0100)
committerLars Op den Kamp <lars@opdenkamp.eu>
Mon, 31 Oct 2011 19:47:19 +0000 (20:47 +0100)
include/cectypes.h
src/lib/CECProcessor.cpp
src/lib/CECProcessor.h
src/lib/devices/CECBusDevice.cpp
src/testclient/main.cpp

index df9af817ef303b8aa3d4c10bc237395b05d4fbdc..afd5b162cbb4bdaf9b5339b99a96a3481d75c6aa 100644 (file)
@@ -642,17 +642,16 @@ typedef struct cec_command
   cec_opcode          opcode;
   cec_datapacket      parameters;
   int8_t              opcode_set;
-  int32_t             ack_timeout;
+  int32_t             transmit_timeout;
 
 #ifdef __cplusplus
   static void format(cec_command &command, cec_logical_address initiator, cec_logical_address destination, cec_opcode opcode)
   {
     command.clear();
-    command.initiator   = initiator;
-    command.destination = destination;
-    command.opcode      = opcode;
-    command.opcode_set  = 1;
-    command.ack_timeout = 1000;
+    command.initiator        = initiator;
+    command.destination      = destination;
+    command.opcode           = opcode;
+    command.opcode_set       = 1;
   }
 
   void push_back(uint8_t data)
@@ -673,13 +672,13 @@ typedef struct cec_command
 
   void clear(void)
   {
-    initiator   = CECDEVICE_UNKNOWN;
-    destination = CECDEVICE_UNKNOWN;
-    ack         = 0;
-    eom         = 0;
-    opcode_set  = 0;
-    opcode      = CEC_OPCODE_FEATURE_ABORT;
-    ack_timeout = 1000;
+    initiator        = CECDEVICE_UNKNOWN;
+    destination      = CECDEVICE_UNKNOWN;
+    ack              = 0;
+    eom              = 0;
+    opcode_set       = 0;
+    opcode           = CEC_OPCODE_FEATURE_ABORT;
+    transmit_timeout = 1000;
     parameters.clear();
   };
 #endif
index 19984f0312c3b33b68eb04a6fc6a79e092001afd..3b6f6f2e1cac5a18b7d810135e3a7d1116921799 100644 (file)
@@ -259,16 +259,13 @@ bool CCECProcessor::Transmit(const cec_command &data)
       }
     }
 
-    if (data.ack_timeout > 0)
+    if (data.transmit_timeout > 0)
     {
-      bool bError(false);
-      if ((bReturn = WaitForAck(&bError, output->size(), data.ack_timeout)) == false)
+      if ((bReturn = WaitForTransmitSucceeded(output->size(), data.transmit_timeout)) == false)
         m_controller->AddLog(CEC_LOG_ERROR, "did not receive ack");
     }
     else
-    {
       bReturn = true;
-    }
   }
 
   return bReturn;
@@ -286,16 +283,16 @@ void CCECProcessor::TransmitAbort(cec_logical_address address, cec_opcode opcode
   Transmit(command);
 }
 
-bool CCECProcessor::WaitForAck(bool *bError, uint8_t iLength, uint32_t iTimeout /* = 1000 */)
+bool CCECProcessor::WaitForTransmitSucceeded(uint8_t iLength, uint32_t iTimeout /* = 1000 */)
 {
-  bool bTransmitSucceeded = false;
+  bool bError(false);
+  bool bTransmitSucceeded(false);
   uint8_t iPacketsLeft(iLength / 4);
-  *bError = false;
 
   int64_t iNow = GetTimeMs();
   int64_t iTargetTime = iNow + (uint64_t) iTimeout;
 
-  while (!bTransmitSucceeded && !*bError && (iTimeout == 0 || iNow < iTargetTime))
+  while (!bTransmitSucceeded && !bError && (iTimeout == 0 || iNow < iTargetTime))
   {
     CCECAdapterMessage msg;
 
@@ -305,7 +302,7 @@ bool CCECProcessor::WaitForAck(bool *bError, uint8_t iLength, uint32_t iTimeout
       continue;
     }
 
-    *bError = msg.is_error();
+    bError = msg.is_error();
     m_controller->AddLog(msg.is_error() ? CEC_LOG_WARNING : CEC_LOG_DEBUG, msg.ToString());
 
     switch(msg.message())
@@ -315,20 +312,20 @@ bool CCECProcessor::WaitForAck(bool *bError, uint8_t iLength, uint32_t iTimeout
       break;
     case MSGCODE_TRANSMIT_SUCCEEDED:
       bTransmitSucceeded = (iPacketsLeft == 0);
-      *bError = !bTransmitSucceeded;
+      bError = !bTransmitSucceeded;
       break;
     default:
       CStdString strLog;
       strLog.Format("received unexpected reply '%1x' instead of ack", msg.message());
       m_controller->AddLog(CEC_LOG_WARNING, strLog);
-      *bError = true;
+      bError = true;
       break;
     }
 
     iNow = GetTimeMs();
   }
 
-  return bTransmitSucceeded && !*bError;
+  return bTransmitSucceeded && !bError;
 }
 
 bool CCECProcessor::ParseMessage(const CCECAdapterMessage &msg)
index 2d5c3127052da5d9dd84cae5ffd5ff6946eab42e..8569949cbf0b3805863421c05f3a45d234568260 100644 (file)
@@ -81,7 +81,7 @@ namespace CEC
 
   private:
       void LogOutput(const cec_command &data);
-      bool WaitForAck(bool *bError, uint8_t iLength, uint32_t iTimeout = 1000);
+      bool WaitForTransmitSucceeded(uint8_t iLength, uint32_t iTimeout = 1000);
       bool ParseMessage(const CCECAdapterMessage &msg);
       void ParseCommand(cec_command &command);
 
index cbd332e088c44fce6bbf63779f0c4d47d4ef3845..7faa5fb6a10252da1b43e2f6284352b91f7e7673 100644 (file)
@@ -212,7 +212,6 @@ void CCECBusDevice::PollVendorId(void)
 
     cec_command command;
     cec_command::format(command, GetMyLogicalAddress(), GetLogicalAddress(), CEC_OPCODE_GIVE_DEVICE_VENDOR_ID);
-    command.ack_timeout = 0;
     m_processor->Transmit(command);
   }
 }
index 33cbd88e2cec3ebec16cf97394061723a40ea14a..d30d982053673bfa341b07688c00973d2f5425a1 100644 (file)
@@ -200,7 +200,7 @@ void show_console_help(void)
   "Available commands:" << endl <<
   endl <<
   "tx {bytes}                transfer bytes over the CEC line." << endl <<
-  "txn {bytes}               transfer bytes and don't wait for an ACK reply." << endl <<
+  "txn {bytes}               transfer bytes but don't wait for transmission ACK." << endl <<
   "[tx 40 00 FF 11 22 33]    sends bytes 0x40 0x00 0xFF 0x11 0x22 0x33" << endl <<
   endl <<
   "on {address}              power on the device with the given logical address." << endl <<
@@ -421,7 +421,7 @@ int main (int argc, char *argv[])
             bytes.push_back(ivalue);
 
           if (command == "txn")
-            bytes.ack_timeout = 0;
+            bytes.transmit_timeout = 0;
 
           parser->Transmit(bytes);
         }