[otci] address small reliability issues (#7372)
This commit addresses several small reliability issues revealed during
testing.
diff --git a/tools/otci/otci/connectors.py b/tools/otci/otci/connectors.py
index 7d8a342..713fbc3 100644
--- a/tools/otci/otci/connectors.py
+++ b/tools/otci/otci/connectors.py
@@ -159,7 +159,7 @@
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
diff --git a/tools/otci/otci/otci.py b/tools/otci/otci/otci.py
index a51a865..ca14133 100644
--- a/tools/otci/otci/otci.py
+++ b/tools/otci/otci/otci.py
@@ -47,7 +47,9 @@
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 @@
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(),