[otci] address small reliability issues (#7372)

This commit addresses several small reliability issues revealed during
testing.
This commit is contained in:
Simon Lin
2022-02-08 21:51:06 -08:00
committed by GitHub
parent b9ee08d87b
commit 4fb966e3eb
2 changed files with 10 additions and 3 deletions
+1 -1
View File
@@ -159,7 +159,7 @@ class OtCliSerial(OtCliHandler):
line = self.__linebuffer + line
self.__linebuffer = b''
return line.decode('utf-8').rstrip('\r\n')
return line.decode('utf-8', errors='ignore').rstrip('\r\n')
return None
+9 -2
View File
@@ -47,7 +47,9 @@ class OTCI(object):
manipulate an OpenThread device.
"""
__exec_command_retry = 0
DEFAULT_EXEC_COMMAND_RETRY = 4 # A command is retried 4 times if failed.
__exec_command_retry = DEFAULT_EXEC_COMMAND_RETRY
def __init__(self, otcmd: OTCommandHandler):
"""
@@ -278,7 +280,12 @@ class OTCI(object):
for line in output[2:]:
fields = line.strip().split('|')
_, J, netname, extpanid, panid, extaddr, ch, dbm, lqi, _ = fields
try:
_, J, netname, extpanid, panid, extaddr, ch, dbm, lqi, _ = fields
except Exception:
logging.warning('ignored output: %r', line)
continue
networks.append({
'joinable': bool(int(J)),
'network_name': netname.strip(),