From f7c9db0acbd2c266d5468e3705850749bfaf9d86 Mon Sep 17 00:00:00 2001 From: Yong Li Date: Tue, 15 Jan 2019 13:45:33 +0800 Subject: 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 --- app/watchdog.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'app') 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 @@ ipmi_ret_t ipmi_app_watchdog_get(ipmi_netfn_t netfn, ipmi_cmd_t cmd, res.timer_use = wd_dont_log; res.timer_action = static_cast(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 @@ ipmi_ret_t ipmi_app_watchdog_get(ipmi_netfn_t netfn, ipmi_cmd_t cmd, // 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; -- cgit v1.2.1