cec-client: show the firmware build date if it's available in cec-client -l. fixed...
authorLars Op den Kamp <lars@opdenkamp.eu>
Thu, 26 Apr 2012 12:37:07 +0000 (14:37 +0200)
committerLars Op den Kamp <lars@opdenkamp.eu>
Thu, 26 Apr 2012 12:39:31 +0000 (14:39 +0200)
src/lib/CECProcessor.cpp
src/testclient/main.cpp

index 8838df620a187b1d03fbf310503a97a5b8200ac4..1c92bb1ba8b94b6f0bffcd443c618275b4750ed3 100644 (file)
@@ -193,7 +193,7 @@ bool CCECProcessor::OpenConnection(const char *strPort, uint16_t iBaudRate, uint
     m_configuration.iFirmwareBuildDate = m_communication->GetFirmwareBuildDate();
     CStdString strLog;
     strLog.Format("connected to the CEC adapter. libCEC version = %s, client version = %s, firmware version = %d", ToString((cec_server_version)m_configuration.serverVersion), ToString((cec_client_version)m_configuration.clientVersion), m_configuration.iFirmwareVersion);
-    if (m_configuration.iFirmwareBuildDate > 0)
+    if (m_configuration.iFirmwareBuildDate != CEC_DEFAULT_FIRMWARE_BUILD_DATE)
     {
       time_t buildTime = (time_t)m_configuration.iFirmwareBuildDate;
       strLog.AppendFormat(", firmware build date: %s", asctime(gmtime(&buildTime)));
@@ -1772,11 +1772,10 @@ bool CCECProcessor::GetDeviceInformation(const char *strPort, libcec_configurati
   if (!OpenConnection(strPort, CEC_SERIAL_DEFAULT_BAUDRATE, iTimeoutMs, false))
     return false;
 
-  config->iFirmwareVersion = m_communication->GetFirmwareVersion();
-  config->iPhysicalAddress = m_communication->GetPhysicalAddress();
+  config->iFirmwareVersion   = m_communication->GetFirmwareVersion();
+  config->iPhysicalAddress   = m_communication->GetPhysicalAddress();
+  config->iFirmwareBuildDate = m_communication->GetFirmwareBuildDate();
 
-  delete m_communication;
-  m_communication = NULL;
   return true;
 }
 
index 65e99bcd95ee40927c195a491277bc8ca5c56005..2fa510e0bcc15310eaeff0d108c4efeefe6cf479 100644 (file)
@@ -204,14 +204,24 @@ void ListDevices(ICECAdapter *parser)
 
     for (int8_t iDevicePtr = 0; iDevicePtr < iDevicesFound; iDevicePtr++)
     {
-      strDeviceInfo.AppendFormat("device:             %d\ncom port:           %s\n", iDevicePtr + 1, devices[iDevicePtr].comm);
+      strDeviceInfo.AppendFormat("device:              %d\ncom port:            %s\n", iDevicePtr + 1, devices[iDevicePtr].comm);
       libcec_configuration config;
       config.Clear();
 
       if (!parser->GetDeviceInformation(devices[iDevicePtr].comm, &config))
         PrintToStdOut("WARNING: unable to open the device on port %s", devices[iDevicePtr].comm);
       else
-        strDeviceInfo.AppendFormat("firmware version:   %d\n", config.iFirmwareVersion);
+      {
+        strDeviceInfo.AppendFormat("firmware version:    %d\n", config.iFirmwareVersion);
+
+        if (config.iFirmwareBuildDate != CEC_DEFAULT_FIRMWARE_BUILD_DATE)
+        {
+          time_t buildTime = (time_t)config.iFirmwareBuildDate;
+          strDeviceInfo.AppendFormat("firmware build date: %s", asctime(gmtime(&buildTime)));
+          strDeviceInfo = strDeviceInfo.Left((int)strDeviceInfo.length() - 1); // strip \n added by asctime
+          strDeviceInfo.append(" +0000");
+        }
+      }
       strDeviceInfo.append("\n");
     }
     PrintToStdOut(strDeviceInfo.c_str());