cec: show the build date for firmwares that have this command
authorLars Op den Kamp <lars@opdenkamp.eu>
Tue, 24 Apr 2012 22:52:10 +0000 (00:52 +0200)
committerLars Op den Kamp <lars@opdenkamp.eu>
Tue, 24 Apr 2012 23:03:48 +0000 (01:03 +0200)
include/cectypes.h
src/lib/CECProcessor.cpp
src/lib/adapter/AdapterCommunication.h
src/lib/adapter/USBCECAdapterCommands.cpp
src/lib/adapter/USBCECAdapterCommands.h
src/lib/adapter/USBCECAdapterCommunication.cpp
src/lib/adapter/USBCECAdapterCommunication.h
src/lib/adapter/USBCECAdapterMessage.cpp

index 6f7375b3fc5ecf9bfed6442e14ad7d7a672f2478..d43121bea3a7542a0180bf2d934585e31b7140a2 100644 (file)
@@ -602,7 +602,7 @@ typedef enum cec_adapter_messagecode
   MSGCODE_TRANSMIT_FAILED_TIMEOUT_LINE,
   MSGCODE_FIRMWARE_VERSION,
   MSGCODE_START_BOOTLOADER,
-  MSGCODE_SET_POWERSTATE,
+  MSGCODE_GET_BUILDDATE,
   MSGCODE_SET_CONTROLLED,
   MSGCODE_GET_AUTO_ENABLED,
   MSGCODE_SET_AUTO_ENABLED,
index 9f0274b491c1a29768d6b240757346cda4575e04..3467d10a765326eca30ab6ca8f65717a3d8dc793 100644 (file)
@@ -188,7 +188,14 @@ bool CCECProcessor::OpenConnection(const char *strPort, uint16_t iBaudRate, uint
   if (bReturn)
   {
     m_configuration.iFirmwareVersion = m_communication->GetFirmwareVersion();
+    uint32_t iBuildDate = m_communication->GetFirmwareBuildDate();
     CLibCEC::AddLog(CEC_LOG_NOTICE, "connected to the CEC adapter. firmware version = %d, client version = %s", m_configuration.iFirmwareVersion, ToString((cec_client_version)m_configuration.clientVersion));
+    if (iBuildDate > 0)
+    {
+      time_t buildTime = (time_t)iBuildDate;
+      CLibCEC::AddLog(CEC_LOG_NOTICE, "Firmware build date: %s", asctime(localtime(&buildTime)));
+    }
+
   }
 
   if (m_configuration.bGetSettingsFromROM == 1)
index cbbc7ff89ed3dc43cbc349769712a76c8a3ded32..db0fbe6cc4e72f1cc3c4a915ddd3a37e111ee50e 100644 (file)
@@ -138,6 +138,11 @@ namespace CEC
      */
     virtual uint16_t GetFirmwareVersion(void) = 0;
 
+    /*!
+     * @return The build date in seconds since epoch, or 0 when no (valid) reply was received.
+     */
+    virtual uint32_t GetFirmwareBuildDate(void) = 0;
+
     /*!
      * @return True when the control mode has been set, false otherwise.
      */
index c34713c9c7bb1518e737f76bd9eee2236abc5e75..326abe17c07ff7c9081179a7b802739f91ac77ff 100644 (file)
@@ -43,7 +43,8 @@ CUSBCECAdapterCommands::CUSBCECAdapterCommands(CUSBCECAdapterCommunication *comm
     m_bSettingAutoEnabled(false),
     m_settingCecVersion(CEC_VERSION_UNKNOWN),
     m_iSettingLAMask(0),
-    m_bNeedsWrite(false)
+    m_bNeedsWrite(false),
+    m_iBuildDate(0)
 {
   m_persistedConfiguration.Clear();
 }
@@ -120,6 +121,16 @@ bool CUSBCECAdapterCommands::RequestSettingCECVersion(void)
   return false;
 }
 
+uint32_t CUSBCECAdapterCommands::RequestBuildDate(void)
+{
+  CLibCEC::AddLog(CEC_LOG_DEBUG, "requesting firmware build date");
+
+  cec_datapacket response = RequestSetting(MSGCODE_GET_BUILDDATE);
+  if (response.size == 4)
+    return (uint32_t)response[0] << 24 | (uint32_t)response[1] << 16 | (uint32_t)response[2] << 8 | (uint32_t)response[3];
+  return 0;
+}
+
 bool CUSBCECAdapterCommands::RequestSettingDefaultLogicalAddress(void)
 {
   CLibCEC::AddLog(CEC_LOG_DEBUG, "requesting default logical address setting");
index b88651e11619dfe5456074d43010f04853ceaf19..389aa5f680a74a44d19ccf125491f0f45a9b5ffd 100644 (file)
@@ -100,6 +100,12 @@ namespace CEC
      */
     bool SetControlledMode(bool controlled);
 
+    /*!
+     * @brief Request the firmware build date from the device.
+     * @return The build date in seconds since epoch, or 0 when no (valid) reply was received.
+     */
+    uint32_t RequestBuildDate(void);
+
   private:
     /*!
      * @brief Reads all settings from the eeprom.
@@ -218,5 +224,6 @@ namespace CEC
     uint16_t                     m_iSettingLAMask;         /**< the value of the LA mask setting */
     bool                         m_bNeedsWrite;            /**< true when we sent changed settings to the adapter that have not been persisted */
     libcec_configuration         m_persistedConfiguration; /**< the configuration that is persisted in the eeprom */
+    uint32_t                     m_iBuildDate;             /**< the build date of the firmware */
   };
 }
index 828ea24cac2aaecb4bf5a40e85df6b52691243b5..f2b5cd6a252555322f1f22e3b4eefd4e09836de9 100644 (file)
@@ -472,6 +472,11 @@ uint16_t CUSBCECAdapterCommunication::GetFirmwareVersion(void)
   return m_commands->GetFirmwareVersion();
 }
 
+uint32_t CUSBCECAdapterCommunication::GetFirmwareBuildDate(void)
+{
+  return m_commands->RequestBuildDate();
+}
+
 bool CUSBCECAdapterCommunication::PersistConfiguration(libcec_configuration *configuration)
 {
   return m_port->IsOpen() ? m_commands->PersistConfiguration(configuration) : false;
index 4c4cb43fd3ec5bc1e394c198c4d07ee6d48ccb71..b44a3ec9adb5300c9575d2aee1ce7c86bf2da2e7 100644 (file)
@@ -76,6 +76,7 @@ namespace CEC
     bool SetAckMask(uint16_t iMask);
     bool PingAdapter(void);
     uint16_t GetFirmwareVersion(void);
+    uint32_t GetFirmwareBuildDate(void);
     bool PersistConfiguration(libcec_configuration *configuration);
     bool GetConfiguration(libcec_configuration *configuration);
     CStdString GetPortName(void);
index 8b9569da0f3e06afdf284cb17d22939e9d119c36..aef61b2b924f0652129de7b7688f6a62f404d393 100644 (file)
@@ -187,8 +187,8 @@ const char *CCECAdapterMessage::ToString(cec_adapter_messagecode msgCode)
     return "FRAME_EOM";
   case MSGCODE_FRAME_ACK:
     return "FRAME_ACK";
-  case MSGCODE_SET_POWERSTATE:
-    return "SET_POWERSTATE";
+  case MSGCODE_GET_BUILDDATE:
+    return "GET_BUILDDATE";
   case MSGCODE_SET_CONTROLLED:
     return "SET_CONTROLLED";
   case MSGCODE_GET_AUTO_ENABLED:
@@ -221,6 +221,8 @@ const char *CCECAdapterMessage::ToString(cec_adapter_messagecode msgCode)
     return "SET_OSD_NAME";
   case MSGCODE_WRITE_EEPROM:
     return "WRITE_EEPROM";
+  default:
+    break;
   }
 
   return "unknown";