Skip to content
This repository was archived by the owner on Aug 5, 2022. It is now read-only.

Commit 3f408fc

Browse files
tvyaskeerockl
authored andcommitted
watchdog: Dump WARN if WATCHDOG_USEC is not configured.
Let the user know if cUseWatchdog is set but the environment variable WATCHDOG_USEC isn't, leading to the watchdog being unusable. Signed-off-by: Tarun Vyas <[email protected]>
1 parent e30d492 commit 3f408fc

File tree

3 files changed

+18
-9
lines changed

3 files changed

+18
-9
lines changed

private/src/avb_streamhandler/IasAvbStreamHandler.cpp

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -435,7 +435,21 @@ IasAvbProcessingResult IasAvbStreamHandler::init( const std::string& configName,
435435
// TODO: Add a config option to receive user input to disable avb_watchdog at runtime.
436436
// Otherwise, would not be able to start by executing the demo_app normally
437437
// since WATCHDOG_USEC is set by systemctl.
438-
if (mEnvironment->createWatchdog() != eIasAvbProcOK)
438+
result = mEnvironment->createWatchdog();
439+
if (result == eIasAvbProcInvalidParam)
440+
{
441+
uint64_t wd_en = 0;
442+
DLT_LOG_CXX(*mLog, DLT_LOG_WARN, LOG_PREFIX,
443+
"WATCHDOG_USEC is not configured!");
444+
445+
mEnvironment->getConfigValue(IasRegKeys::cUseWatchdog, wd_en);
446+
if (wd_en)
447+
DLT_LOG_CXX(*mLog, DLT_LOG_WARN, LOG_PREFIX,
448+
"Watchdog won't work. Please configure WATCHDOG_USEC.");
449+
450+
result = eIasAvbProcOK;
451+
}
452+
else if (result != eIasAvbProcOK)
439453
{
440454
DLT_LOG_CXX(*mLog, DLT_LOG_ERROR, LOG_PREFIX, " Init of watchdog failed");
441455
result = eIasAvbProcInitializationFailed;

private/src/avb_streamhandler/IasAvbStreamHandlerEnvironment.cpp

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1204,13 +1204,8 @@ IasAvbProcessingResult IasAvbStreamHandlerEnvironment::createWatchdog()
12041204
}
12051205
else
12061206
{
1207-
/*
1208-
* no watchdog configuration found in env 'WATCHDOG_USEC'.
1209-
* Treat this as a normal use case since users might now want to use either systemd or
1210-
* systemd's watchdog feature.
1211-
*/
12121207
mUseWatchdog = false;
1213-
ret = eIasAvbProcOK; // success
1208+
ret = eIasAvbProcInvalidParam;
12141209
}
12151210

12161211
if (mUseWatchdog)
@@ -1261,7 +1256,7 @@ IasAvbProcessingResult IasAvbStreamHandlerEnvironment::createWatchdog()
12611256
}
12621257
}
12631258

1264-
if (eIasAvbProcOK != ret)
1259+
if (eIasAvbProcOK != ret && eIasAvbProcInvalidParam != ret)
12651260
{
12661261
destroyWatchdog();
12671262
}

private/tst/avb_streamhandler/src/IasTestAvbStreamHandlerEnvironment.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -439,7 +439,7 @@ TEST_F(IasTestAvbStreamHandlerEnvironment, create_destroyWatchdog)
439439
{
440440
ASSERT_TRUE(mIasAvbStreamHandlerEnvironment != NULL);
441441

442-
ASSERT_EQ(eIasAvbProcInitializationFailed, mIasAvbStreamHandlerEnvironment->createWatchdog());
442+
ASSERT_EQ(eIasAvbProcInvalidParam, mIasAvbStreamHandlerEnvironment->createWatchdog());
443443

444444
std::string wdEnvVar("WATCHDOG_USEC");
445445
std::string wdTimeoutUSec("100000");

0 commit comments

Comments
 (0)