This delay is meant for multicharacter commands, besides we always guarantee delay by other means - so do the stuff properly.
Signed-off-by: Michal Soltys <[email protected]> --- drivers/apcsmart.c | 17 +++++++++-------- 1 files changed, 9 insertions(+), 8 deletions(-) diff --git a/drivers/apcsmart.c b/drivers/apcsmart.c index 0a6a56b..63b91b5 100644 --- a/drivers/apcsmart.c +++ b/drivers/apcsmart.c @@ -854,13 +854,15 @@ static int sdcmd_S(int dummy) } /* soft hibernate, hack version for CS 350 */ -static int sdcmd_CS(int tval) +static int sdcmd_CS(int status) { + char temp[16]; + upsdebugx(1, "Using CS 350 'force OB' shutdown method"); - if (tval & APC_STAT_OL) { + if (status & APC_STAT_OL) { upsdebugx(1, "On-line - forcing OB temporarily"); ser_send_char(upsfd, 'U'); - usleep(UPSDELAY); + ser_get_line(upsfd, temp, sizeof(temp), ENDCHAR, IGNCHARS, SER_WAIT_SEC, SER_WAIT_USEC); } return sdcmd_S(tval); } @@ -874,7 +876,7 @@ static int sdcmd_ATn(int cnt) { int n = 0, mmax, ret; const char *strval; - char timer[4]; + char temp[16]; mmax = cnt == 2 ? 99 : 999; @@ -885,14 +887,14 @@ static int sdcmd_ATn(int cnt) n = 0; } - snprintf(timer, sizeof(timer), "%.*d", cnt, n); + snprintf(temp, sizeof(temp), "%.*d", cnt, n); ser_flush_in(upsfd, IGNCHARS, nut_debug_level); upsdebugx(1, "Issuing hard hibernate with %d minutes additional wakeup delay", n*6); ser_send_char(upsfd, APC_CMD_GRACEDOWN); usleep(CMDLONGDELAY); - ser_send_pace(upsfd, UPSDELAY, timer); + ser_send_pace(upsfd, UPSDELAY, temp); ret = sdok(); if (ret || cnt == 3) @@ -905,8 +907,7 @@ static int sdcmd_ATn(int cnt) * silent (YMMV); */ ser_send_char(upsfd, APC_CMD_GRACEDOWN); - usleep(UPSDELAY); - ser_flush_in(upsfd, IGNCHARS, nut_debug_level); + ser_get_line(upsfd, temp, sizeof(temp), ENDCHAR, IGNCHARS, SER_WAIT_SEC, SER_WAIT_USEC); return 0; } -- 1.7.2.1 _______________________________________________ Nut-upsdev mailing list [email protected] http://lists.alioth.debian.org/mailman/listinfo/nut-upsdev
