Merge branch 'master' into release
authorLars Op den Kamp <lars@opdenkamp.eu>
Fri, 27 Jan 2012 12:07:55 +0000 (13:07 +0100)
committerLars Op den Kamp <lars@opdenkamp.eu>
Fri, 27 Jan 2012 12:07:55 +0000 (13:07 +0100)
ChangeLog
debian/changelog
include/cectypes.h
project/libcec.rc
project/testclient.rc
src/CecSharpTester/Properties/AssemblyInfo.cs
src/LibCecSharp/AssemblyInfo.cpp
src/lib/CECProcessor.cpp

index ff67255c18332812eee3727e096efb2dbc31bf8e..49b0e7eebe6e1d8b4232d81fc26c3d67d77b1509 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+libcec (1.4-3) unstable; urgency=low
+
+  * fixed:
+    * try to ping the device and grab the firmware version until the connect
+      timeout runs out. fixes failed reconnect after standby, when the adapter
+      is still being initialised
+
+ -- Pulse-Eight Packaging <packaging@pulse-eight.com>  Thu, 27 Jan 2012 13:05:00 +0100
+
 libcec (1.4-2) unstable; urgency=low
 
    * changed/added:
@@ -6,7 +15,7 @@ libcec (1.4-2) unstable; urgency=low
      * refactored threading/locking - added windows native instead of
        pthread-win32, so we can compile native x64 too
      * check whether the adapter responds when connecting to it and report the
-          firmware version of the adapter after connecting
+       firmware version of the adapter after connecting
      * moved create-installer.cmd to support/
      * completely removed AM_SILENT_RULES
    * interface changes:
index ff67255c18332812eee3727e096efb2dbc31bf8e..49b0e7eebe6e1d8b4232d81fc26c3d67d77b1509 100644 (file)
@@ -1,3 +1,12 @@
+libcec (1.4-3) unstable; urgency=low
+
+  * fixed:
+    * try to ping the device and grab the firmware version until the connect
+      timeout runs out. fixes failed reconnect after standby, when the adapter
+      is still being initialised
+
+ -- Pulse-Eight Packaging <packaging@pulse-eight.com>  Thu, 27 Jan 2012 13:05:00 +0100
+
 libcec (1.4-2) unstable; urgency=low
 
    * changed/added:
@@ -6,7 +15,7 @@ libcec (1.4-2) unstable; urgency=low
      * refactored threading/locking - added windows native instead of
        pthread-win32, so we can compile native x64 too
      * check whether the adapter responds when connecting to it and report the
-          firmware version of the adapter after connecting
+       firmware version of the adapter after connecting
      * moved create-installer.cmd to support/
      * completely removed AM_SILENT_RULES
    * interface changes:
index 5213b3770ab417c5bb434e24d8d8cd10b24ff459..86be2a258e2969fe80e7ff788933e7810a2a8f72 100644 (file)
@@ -76,8 +76,6 @@ namespace CEC {
 #define CEC_DEFAULT_TRANSMIT_TIMEOUT 1000
 #define CEC_DEFAULT_TRANSMIT_WAIT    2000
 #define CEC_DEFAULT_TRANSMIT_RETRIES 1
-#define CEC_PING_ADAPTER_TRIES       5
-#define CEC_FW_VERSION_TRIES         5
 
 #define CEC_MIN_LIB_VERSION          1
 #define CEC_LIB_VERSION_MAJOR        1
index 42544764b66f1125ff03b1cfb925c8793b98651d..b5e6969cb485588c99f670bfe8044afe8df724f6 100644 (file)
Binary files a/project/libcec.rc and b/project/libcec.rc differ
index c6850157ae6c4ac9a9a67f0ef1b6a0682d2421a5..24d3722cc5c2de80fc36d5a6b22846cc5eb44320 100644 (file)
Binary files a/project/testclient.rc and b/project/testclient.rc differ
index eb3e6c106be186dc8251560c273e56b97453cb7d..fb546d460bcaa7ba396094520e64c0cadd1fbeca 100644 (file)
@@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
 // You can specify all the values or you can default the Build and Revision Numbers 
 // by using the '*' as shown below:
 // [assembly: AssemblyVersion("1.0.*")]
-[assembly: AssemblyVersion("1.4.1.0")]
-[assembly: AssemblyFileVersion("1.4.1.0")]
+[assembly: AssemblyVersion("1.4.2.0")]
+[assembly: AssemblyFileVersion("1.4.2.0")]
index 716ad99d438c7dbbd3bc491babff012fd11bdff3..c030509ae28d029e502f290532569988e1fe996b 100644 (file)
@@ -13,7 +13,7 @@ using namespace System::Security::Permissions;
 [assembly:AssemblyTrademarkAttribute("")];
 [assembly:AssemblyCultureAttribute("")];
 
-[assembly:AssemblyVersionAttribute("1.4.1.0")];
+[assembly:AssemblyVersionAttribute("1.4.2.0")];
 
 [assembly:ComVisible(false)];
 [assembly:CLSCompliantAttribute(true)];
index 12cea4f8ecc80186bf141dfd40e49dbf510a9a80..8c808ae8b390cb20e4461e466d20038d9944a1e3 100644 (file)
@@ -145,45 +145,43 @@ bool CCECProcessor::OpenConnection(const char *strPort, uint16_t iBaudRate, uint
     return bReturn;
   }
 
+  uint64_t iNow = GetTimeMs();
+  uint64_t iTarget = iTimeoutMs > 0 ? iNow + iTimeoutMs : iNow + CEC_DEFAULT_TRANSMIT_WAIT;
+
   /* open a new connection */
   if ((bReturn = m_communication->Open(strPort, iBaudRate, iTimeoutMs)) == false)
     CLibCEC::AddLog(CEC_LOG_ERROR, "could not open a connection");
 
   /* try to ping the adapter */
-  int iPingTry(0);
   bool bPingOk(false);
-  while (!bPingOk && iPingTry++ < CEC_PING_ADAPTER_TRIES)
+  unsigned iPingTry(0), iFwVersionTry(0);
+  uint16_t iFirmwareVersion(CEC_FW_VERSION_UNKNOWN);
+  while ((!bPingOk || iFirmwareVersion == CEC_FW_VERSION_UNKNOWN) && iTarget > iNow)
   {
-    if ((bPingOk = m_communication->PingAdapter()) == false)
+    if (!bPingOk)
     {
-      CLibCEC::AddLog(CEC_LOG_ERROR, "the adapter did not respond correctly to a ping (try %d of %d)", iPingTry, CEC_PING_ADAPTER_TRIES);
-      Sleep(500);
+      if ((bPingOk = m_communication->PingAdapter()) == false)
+      {
+        CLibCEC::AddLog(CEC_LOG_ERROR, "the adapter did not respond correctly to a ping (try %d)", ++iPingTry);
+        Sleep(500);
+      }
     }
-  }
 
-  if (bPingOk)
-  {
-    uint16_t iFirmwareVersion(CEC_FW_VERSION_UNKNOWN);
-    int iFwVersionTry(0);
-    bool bFwVersionOk(false);
-    while (!bFwVersionOk && iFwVersionTry++ < CEC_FW_VERSION_TRIES)
+    if (bPingOk)
     {
       if ((iFirmwareVersion = m_communication->GetFirmwareVersion()) == CEC_FW_VERSION_UNKNOWN)
       {
-        CLibCEC::AddLog(CEC_LOG_ERROR, "the adapter did not respond with a correct firmware version (try %d of %d)", iFwVersionTry, CEC_FW_VERSION_TRIES);
+        CLibCEC::AddLog(CEC_LOG_ERROR, "the adapter did not respond with a correct firmware version (try %d)", ++iFwVersionTry);
         Sleep(500);
       }
+      else
+      {
+        CLibCEC::AddLog(CEC_LOG_NOTICE, "CEC Adapter firmware version: %d", iFirmwareVersion);
+        bReturn = true;
+      }
     }
 
-    if (iFirmwareVersion == CEC_FW_VERSION_UNKNOWN)
-    {
-      bReturn = false;
-    }
-    else
-    {
-      bReturn = true;
-      CLibCEC::AddLog(CEC_LOG_NOTICE, "CEC Adapter firmware version: %d", iFirmwareVersion);
-    }
+    iNow = GetTimeMs();
   }
 
   return bReturn;