[otci] fix command issue after factoryreset (#6670)

This commit is contained in:
Simon Lin
2021-06-25 12:18:14 +08:00
committed by GitHub
parent d360c4b601
commit 98d9b455cc
2 changed files with 8 additions and 9 deletions
+8 -1
View File
@@ -95,7 +95,10 @@ class OtCliCommandRunner(OTCommandHandler):
def execute_command(self, cmd, timeout=10) -> List[str]:
self.__otcli.writeline(cmd)
if cmd in {'reset', 'factoryreset'}:
if cmd in ('reset', 'factoryreset'):
self.wait(3)
self.__otcli.writeline('extaddr')
self.wait(1)
return []
if self.__expect_command_echoback:
@@ -210,6 +213,10 @@ class OtbrSshCommandRunner(OTCommandHandler):
raise CommandError(cmd, [err])
output = [l.rstrip('\r\n') for l in cmd_out.readlines()]
if cmd in ('reset', 'factoryreset'):
self.wait(3)
return output
def close(self):
-8
View File
@@ -29,7 +29,6 @@
import ipaddress
import logging
import re
import time
from collections import Counter
from typing import List, Collection, Union, Tuple, Optional, Dict, Pattern, Any
@@ -105,7 +104,6 @@ class OTCI(object):
self.__logger and self.__logger.info('%s', line)
if cmd in ('reset', 'factoryreset'):
self.__wait_reset()
return output
if output[-1] == 'Done':
@@ -2335,12 +2333,6 @@ class OTCI(object):
s = s.replace(char, '\\%s' % char)
return s
def __wait_reset(self):
# reset would restart the otbr-agent executable. It's risky to send commands after reset too quickly because
# it might cause ot-ctl to quit abnormally.
# So we sleep for a while after reset.
time.sleep(3)
def __txt_to_hex(self, txt: Dict[str, Union[str, bytes, bool]]) -> str:
txt_bin = b''
for k, v in txt.items():