[thci] update pollperiod command to accept ms resolution configuration (#3361)

This commit is contained in:
Jing
2018-12-27 15:39:46 -08:00
committed by Jonathan Hui
parent 7dc645a856
commit eca3e81fd3
3 changed files with 19 additions and 9 deletions
+2 -2
View File
@@ -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 \<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
+3 -2
View File
@@ -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<uint32_t>(value * 1000)); // s->ms
VerifyOrExit(value >= OPENTHREAD_CONFIG_MINIMUM_POLL_PERIOD, error = OT_ERROR_PARSE);
otLinkSetPollPeriod(mInstance, static_cast<uint32_t>(value));
}
exit:
+14 -5
View File
@@ -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: