From: Lars Op den Kamp Date: Tue, 24 Apr 2012 22:52:10 +0000 (+0200) Subject: cec: show the build date for firmwares that have this command X-Git-Tag: upstream/2.2.0~1^2~29^2^2~44 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=b2f56d355ff33088445ad8a7f159c1d51d4d48dd;p=deb_libcec.git cec: show the build date for firmwares that have this command --- diff --git a/include/cectypes.h b/include/cectypes.h index 6f7375b..d43121b 100644 --- a/include/cectypes.h +++ b/include/cectypes.h @@ -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, diff --git a/src/lib/CECProcessor.cpp b/src/lib/CECProcessor.cpp index 9f0274b..3467d10 100644 --- a/src/lib/CECProcessor.cpp +++ b/src/lib/CECProcessor.cpp @@ -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) diff --git a/src/lib/adapter/AdapterCommunication.h b/src/lib/adapter/AdapterCommunication.h index cbbc7ff..db0fbe6 100644 --- a/src/lib/adapter/AdapterCommunication.h +++ b/src/lib/adapter/AdapterCommunication.h @@ -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. */ diff --git a/src/lib/adapter/USBCECAdapterCommands.cpp b/src/lib/adapter/USBCECAdapterCommands.cpp index c34713c..326abe1 100644 --- a/src/lib/adapter/USBCECAdapterCommands.cpp +++ b/src/lib/adapter/USBCECAdapterCommands.cpp @@ -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"); diff --git a/src/lib/adapter/USBCECAdapterCommands.h b/src/lib/adapter/USBCECAdapterCommands.h index b88651e..389aa5f 100644 --- a/src/lib/adapter/USBCECAdapterCommands.h +++ b/src/lib/adapter/USBCECAdapterCommands.h @@ -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 */ }; } diff --git a/src/lib/adapter/USBCECAdapterCommunication.cpp b/src/lib/adapter/USBCECAdapterCommunication.cpp index 828ea24..f2b5cd6 100644 --- a/src/lib/adapter/USBCECAdapterCommunication.cpp +++ b/src/lib/adapter/USBCECAdapterCommunication.cpp @@ -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; diff --git a/src/lib/adapter/USBCECAdapterCommunication.h b/src/lib/adapter/USBCECAdapterCommunication.h index 4c4cb43..b44a3ec 100644 --- a/src/lib/adapter/USBCECAdapterCommunication.h +++ b/src/lib/adapter/USBCECAdapterCommunication.h @@ -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); diff --git a/src/lib/adapter/USBCECAdapterMessage.cpp b/src/lib/adapter/USBCECAdapterMessage.cpp index 8b9569d..aef61b2 100644 --- a/src/lib/adapter/USBCECAdapterMessage.cpp +++ b/src/lib/adapter/USBCECAdapterMessage.cpp @@ -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";