From eca3e81fd3cb55e96aab5503fe06801d7b0abc60 Mon Sep 17 00:00:00 2001 From: Jing <33887762+FiveDimensions@users.noreply.github.com> Date: Fri, 28 Dec 2018 07:39:46 +0800 Subject: [PATCH] [thci] update `pollperiod` command to accept ms resolution configuration (#3361) --- src/cli/README.md | 4 ++-- src/cli/cli.cpp | 5 +++-- tools/harness-thci/OpenThread.py | 19 ++++++++++++++----- 3 files changed, 19 insertions(+), 9 deletions(-) diff --git a/src/cli/README.md b/src/cli/README.md index 2d7eb570b..013d3cdc7 100644 --- a/src/cli/README.md +++ b/src/cli/README.md @@ -1404,7 +1404,7 @@ Done ### pollperiod -Get the customized data poll period of sleepy end device (seconds). Only for certification test +Get the customized data poll period of sleepy end device (milliseconds). Only for certification test ```bash > pollperiod @@ -1414,7 +1414,7 @@ Done ### pollperiod \ -Set the customized data poll period for sleepy end device (seconds). Only for certification test +Set the customized data poll period for sleepy end device (milliseconds >= 10ms). Only for certification test ```bash > pollperiod 10 diff --git a/src/cli/cli.cpp b/src/cli/cli.cpp index acb2482ea..01ff40998 100644 --- a/src/cli/cli.cpp +++ b/src/cli/cli.cpp @@ -1996,12 +1996,13 @@ void Interpreter::ProcessPollPeriod(int argc, char *argv[]) if (argc == 0) { - mServer->OutputFormat("%d\r\n", (otLinkGetPollPeriod(mInstance) / 1000)); // ms->s + mServer->OutputFormat("%d\r\n", otLinkGetPollPeriod(mInstance)); } else { SuccessOrExit(error = ParseLong(argv[0], value)); - otLinkSetPollPeriod(mInstance, static_cast(value * 1000)); // s->ms + VerifyOrExit(value >= OPENTHREAD_CONFIG_MINIMUM_POLL_PERIOD, error = OT_ERROR_PARSE); + otLinkSetPollPeriod(mInstance, static_cast(value)); } exit: diff --git a/tools/harness-thci/OpenThread.py b/tools/harness-thci/OpenThread.py index 98c180c5f..e17407d06 100644 --- a/tools/harness-thci/OpenThread.py +++ b/tools/harness-thci/OpenThread.py @@ -1301,7 +1301,13 @@ class OpenThread(IThci): def getPollingRate(self): """get data polling rate for sleepy end device""" print '%s call getPollingRate' % self.port - return self.__sendCommand('pollperiod')[0] + sPollingRate = self.__sendCommand('pollperiod')[0] + try: + iPollingRate = int(sPollingRate)/1000 + fPollingRate = round(float(sPollingRate)/1000, 3) + return fPollingRate if fPollingRate > iPollingRate else iPollingRate + except Exception, e: + ModuleHelper.WriteIntoDebugLogger("getPollingRate() Error: " + str(e)) def setPollingRate(self, iPollingRate): """set data polling rate for sleepy end device @@ -1314,9 +1320,11 @@ class OpenThread(IThci): False: fail to set the data polling rate for sleepy end device """ print '%s call setPollingRate' % self.port - print iPollingRate + # convert s to ms + iPollingRate *= 1000 + print int(iPollingRate) try: - cmd = 'pollperiod %s' % str(iPollingRate) + cmd = 'pollperiod %d' % int(iPollingRate) print cmd return self.__sendCommand(cmd)[0] == 'Done' except Exception, e: @@ -1535,9 +1543,10 @@ class OpenThread(IThci): False: fail to set the data poll period for SED """ print '%s call setKeepAliveTimeOut' % self.port - print iTimeOut + iTimeOut *= 1000 + print int(iTimeOut) try: - cmd = 'pollperiod %s' % str(iTimeOut) + cmd = 'pollperiod %d' % int(iTimeOut) print cmd return self.__sendCommand(cmd)[0] == 'Done' except Exception, e: