From a97b0c02af6983071aa79f975dbd86c957bd727d Mon Sep 17 00:00:00 2001 From: Jing <33887762+FiveDimensions@users.noreply.github.com> Date: Tue, 2 Oct 2018 14:52:06 +0800 Subject: [PATCH] [thci] wpanctl thci firmeware validation and modify getGUA according to GRL change (#3106) --- tools/harness-thci/OpenThread.py | 5 ++-- tools/harness-thci/OpenThread_WpanCtl.py | 31 ++++++++++++++++++------ 2 files changed, 26 insertions(+), 10 deletions(-) diff --git a/tools/harness-thci/OpenThread.py b/tools/harness-thci/OpenThread.py index fcf36b20d..8b957cb3f 100644 --- a/tools/harness-thci/OpenThread.py +++ b/tools/harness-thci/OpenThread.py @@ -1829,8 +1829,7 @@ class OpenThread(IThci): filterByPrefix: a given expected global IPv6 prefix to be matched Returns: - a global IPv6 address that matches with filterByPrefix - or None if no matched GUA + a global IPv6 address """ print '%s call getGUA' % self.port print filterByPrefix @@ -1847,7 +1846,7 @@ class OpenThread(IThci): if fullIp.startswith(filterByPrefix): return fullIp print 'no global address matched' - return None + return str(globalAddrs[0]) except Exception, e: ModuleHelper.WriteIntoDebugLogger("getGUA() Error: " + str(e)) diff --git a/tools/harness-thci/OpenThread_WpanCtl.py b/tools/harness-thci/OpenThread_WpanCtl.py index 98763a154..e9fd433b2 100644 --- a/tools/harness-thci/OpenThread_WpanCtl.py +++ b/tools/harness-thci/OpenThread_WpanCtl.py @@ -61,6 +61,10 @@ class OpenThread_WpanCtl(IThci): LOWEST_POSSIBLE_PARTATION_ID = 0x1 LINK_QUALITY_CHANGE_TIME = 100 + # Used for reference firmware version control for Test Harness. + # This variable will be updated to match the OpenThread reference firmware officially released. + firmwarePrefix = "OPENTHREAD/" + def __init__(self, **kwargs): """initialize the serial port and default network parameters Args: @@ -259,7 +263,7 @@ class OpenThread_WpanCtl(IThci): return 'Fail' else: retry_times -= 1 - time.sleep(0.1) + time.sleep(0.2) else: retry_times -= 1 time.sleep(1) @@ -607,7 +611,14 @@ class OpenThread_WpanCtl(IThci): Returns: IPv6 address dotted-quad format """ - return strIp6Prefix[0:4] + '::' + prefix1 = strIp6Prefix.rstrip('L') + prefix2 = prefix1.lstrip("0x") + hexPrefix = str(prefix2).ljust(16, '0') + hexIter = iter(hexPrefix) + finalMac = ':'.join(a + b + c + d for a, b, c, d in zip(hexIter, hexIter, hexIter, hexIter)) + prefix = str(finalMac) + strIp6Prefix = prefix[:20] + return strIp6Prefix + ':' def __convertLongToString(self, iValue): """convert a long hex integer to string @@ -781,10 +792,16 @@ class OpenThread_WpanCtl(IThci): print '%s call intialize' % self.port try: # init serial port + self.deviceConnected = False self._connect() self.__sendCommand(WPANCTL_CMD + 'leave') self.__sendCommand(WPANCTL_CMD + 'dataset erase') - self.deviceConnected = True + + if self.firmwarePrefix in self.UIStatusMsg: + self.deviceConnected = True + else: + self.UIStatusMsg = "Firmware Not Matching Expecting " + self.firmwarePrefix + " Now is " + self.UIStatusMsg + ModuleHelper.WriteIntoDebugLogger("Err: OpenThread device Firmware not matching..") except Exception, e: ModuleHelper.WriteIntoDebugLogger('intialize() Error: ' + str(e)) self.deviceConnected = False @@ -1845,8 +1862,7 @@ class OpenThread_WpanCtl(IThci): filterByPrefix: a given expected global IPv6 prefix to be matched Returns: - a global IPv6 address that matches with filterByPrefix - or None if no matched GUA + a global IPv6 address """ print '%s call getGUA' % self.port print filterByPrefix @@ -1860,13 +1876,14 @@ class OpenThread_WpanCtl(IThci): else: for line in globalAddrs: line = self.__padIp6Addr(line) - print line + print "Padded IPv6 Address:" + line if line.startswith(filterByPrefix): return line print 'no global address matched' - return None + return str(globalAddrs[0]) except Exception, e: ModuleHelper.WriteIntoDebugLogger('getGUA() Error: ' + str(e)) + return e def getShortAddress(self): """get Rloc16 short address of Thread device"""