Get the correct present countdown value when watchdog is stopped
The timeRemaining property in watchdog service will return 0
if the watchdog is not started.
Tested By:
ipmitool raw 0x6 0x24 0x0 0x0 0x0 0x0 0xa 0xb
ipmitool mc watchdog get
Change-Id: I27992f25a0e2c75df398ec5e2702b467365e9a32
Signed-off-by: Yong Li <yong.b.li@linux.intel.com>
diff --git a/app/watchdog.cpp b/app/watchdog.cpp
index abdf8e4..1a5d19c 100644
--- a/app/watchdog.cpp
+++ b/app/watchdog.cpp
@@ -361,9 +361,17 @@
res.timer_use = wd_dont_log;
res.timer_action =
static_cast<uint8_t>(wdActionToIpmiAction(wd_prop.expireAction));
+
+ // Interval and timeRemaining need converted from milli -> deci seconds
+ res.initial_countdown = htole16(wd_prop.interval / 100);
if (wd_prop.enabled)
{
res.timer_use |= wd_running;
+ res.present_countdown = htole16(wd_prop.timeRemaining / 100);
+ }
+ else
+ {
+ res.present_countdown = res.initial_countdown;
}
res.timer_use |=
@@ -372,10 +380,6 @@
// TODO: Do something about having pretimeout support
res.pretimeout = 0;
res.expire_flags = 0;
- // Interval and timeRemaining need converted from milli -> deci seconds
- res.initial_countdown = htole16(wd_prop.interval / 100);
- res.present_countdown = htole16(wd_prop.timeRemaining / 100);
-
memcpy(response, &res, sizeof(res));
*data_len = sizeof(res);
lastCallSuccessful = true;