diff --git a/helpers/frontpanel.cpp b/helpers/frontpanel.cpp index 34461c3f..38ae36f6 100644 --- a/helpers/frontpanel.cpp +++ b/helpers/frontpanel.cpp @@ -143,75 +143,91 @@ namespace WPEFramework if (!s_instance) s_instance = new CFrontPanel; #ifdef USE_DS - try + unsigned int retryCount = 1; + do { - LOGINFO("Front panel init"); - fpIndicators = device::FrontPanelConfig::getInstance().getIndicators(); - - for (uint i = 0; i < fpIndicators.size(); i++) + try { - std::string IndicatorNameIarm = fpIndicators.at(i).getName(); - - auto it = std::find(m_lights.begin(), m_lights.end(), IndicatorNameIarm); - if (m_lights.end() == it) + LOGINFO("TRACE:: Front panel init at %d", retryCount); + LOGINFO("Front panel init"); + fpIndicators = device::FrontPanelConfig::getInstance().getIndicators(); + LOGINFO(" so continue with other initialization \r\n"); + for (uint i = 0; i < fpIndicators.size(); i++) { - m_lights.push_back(IndicatorNameIarm); + LOGINFO("TRACE:: Before getName for %d at %d", i, retryCount); + std::string IndicatorNameIarm = fpIndicators.at(i).getName(); + LOGINFO("TRACE:: After getName[%s] for %d at %d", IndicatorNameIarm.c_str(), i, retryCount); + + auto it = std::find(m_lights.begin(), m_lights.end(), IndicatorNameIarm); + if (m_lights.end() == it) + { + m_lights.push_back(IndicatorNameIarm); + } } - } + LOGINFO("TRACE:: Front panel init done with %d lights at %d", (int)m_lights.size(), retryCount); -#if defined(HAS_API_POWERSTATE) - { - Core::hresult res = Core::ERROR_GENERAL; - PowerState pwrStateCur = WPEFramework::Exchange::IPowerManager::POWER_STATE_UNKNOWN; - PowerState pwrStatePrev = WPEFramework::Exchange::IPowerManager::POWER_STATE_UNKNOWN; - ASSERT (_powerManagerPlugin); - if (_powerManagerPlugin) { - res = _powerManagerPlugin->GetPowerState(pwrStateCur, pwrStatePrev); - if (Core::ERROR_NONE == res) + #if defined(HAS_API_POWERSTATE) + { + Core::hresult res = Core::ERROR_GENERAL; + PowerState pwrStateCur = WPEFramework::Exchange::IPowerManager::POWER_STATE_UNKNOWN; + PowerState pwrStatePrev = WPEFramework::Exchange::IPowerManager::POWER_STATE_UNKNOWN; + ASSERT (_powerManagerPlugin); + if (_powerManagerPlugin) { + LOGINFO("TRACE:: Before GetPowerState at %d", retryCount); + res = _powerManagerPlugin->GetPowerState(pwrStateCur, pwrStatePrev); + if (Core::ERROR_NONE == res) + { + if (pwrStateCur == WPEFramework::Exchange::IPowerManager::POWER_STATE_ON) + powerStatus = true; + } + LOGINFO("TRACE:: After GetPowerState at %d", retryCount); + LOGINFO("pwrStateCur[%d] pwrStatePrev[%d] powerStatus[%d]", pwrStateCur, pwrStatePrev, powerStatus); + } + } + #endif + #ifdef CLOCK_BRIGHTNESS_ENABLED + clockBrightness = device::FrontPanelTextDisplay::getInstance("Text").getTextBrightness(); + device::FrontPanelTextDisplay::getInstance("Text").setTextBrightness(clockBrightness); + #endif + LOGINFO("TRACE:: Before getBrightness at %d", retryCount); + globalLedBrightness = device::FrontPanelIndicator::getInstance("Power").getBrightness(); + LOGINFO("TRACE:: After getBrightness at %d", retryCount); + LOGINFO("Power light brightness, %d, power status %d", globalLedBrightness, powerStatus); + + profileType = searchRdkProfile(); + if (TV != profileType) + { + for (uint i = 0; i < fpIndicators.size(); i++) { - if (pwrStateCur == WPEFramework::Exchange::IPowerManager::POWER_STATE_ON) - powerStatus = true; + LOGWARN("Initializing light %s", fpIndicators.at(i).getName().c_str()); + if (powerStatus) + device::FrontPanelIndicator::getInstance(fpIndicators.at(i).getName()).setBrightness(globalLedBrightness, false); + device::FrontPanelIndicator::getInstance(fpIndicators.at(i).getName()).setState(false); } - LOGINFO("pwrStateCur[%d] pwrStatePrev[%d] powerStatus[%d]", pwrStateCur, pwrStatePrev, powerStatus); } - } -#endif -#ifdef CLOCK_BRIGHTNESS_ENABLED - clockBrightness = device::FrontPanelTextDisplay::getInstance("Text").getTextBrightness(); - device::FrontPanelTextDisplay::getInstance("Text").setTextBrightness(clockBrightness); -#endif - globalLedBrightness = device::FrontPanelIndicator::getInstance("Power").getBrightness(); - LOGINFO("Power light brightness, %d, power status %d", globalLedBrightness, powerStatus); + else + { + LOGWARN("Power LED Initializing is not set since we continue with bootloader patern"); + } - profileType = searchRdkProfile(); - if (TV != profileType) - { - for (uint i = 0; i < fpIndicators.size(); i++) - { - LOGWARN("Initializing light %s", fpIndicators.at(i).getName().c_str()); - if (powerStatus) - device::FrontPanelIndicator::getInstance(fpIndicators.at(i).getName()).setBrightness(globalLedBrightness, false); - - device::FrontPanelIndicator::getInstance(fpIndicators.at(i).getName()).setState(false); - } - } - else - { - LOGWARN("Power LED Initializing is not set since we continue with bootloader patern"); - } - - if (powerStatus) - device::FrontPanelIndicator::getInstance("Power").setState(true); + LOGINFO("TRACE:: Before setState at %d", retryCount); + if (powerStatus) + device::FrontPanelIndicator::getInstance("Power").setState(true); + LOGINFO("TRACE:: After setState at %d", retryCount); + initDone=1; + } + catch (...) + { + LOGERR("Exception Caught during [CFrontPanel::instance]\r\n"); + LOGINFO("TRACE:: Retry will happen in 2s"); + //usleep(50000); // Sleep for 50ms before retrying + sleep(2); // Sleep for 50ms before retrying + } } - catch (...) - { - LOGERR("Exception Caught during [CFrontPanel::instance]\r\n"); - } - initDone=1; + while((retryCount++ <= 20) && (initDone == 0) ); #endif } - return s_instance; }