summaryrefslogtreecommitdiff
path: root/test-cli/test/tests
diff options
context:
space:
mode:
Diffstat (limited to 'test-cli/test/tests')
-rw-r--r--test-cli/test/tests/qplc.py27
1 files changed, 20 insertions, 7 deletions
diff --git a/test-cli/test/tests/qplc.py b/test-cli/test/tests/qplc.py
index 48d600a..28310c6 100644
--- a/test-cli/test/tests/qplc.py
+++ b/test-cli/test/tests/qplc.py
@@ -6,6 +6,8 @@ import sh
import stat
import time
import ping3
+from netifaces import AF_INET
+import netifaces as ni
from test.helpers.md5 import md5_file
from test.helpers.plc import dcpPLC
@@ -34,7 +36,6 @@ class Qplc(unittest.TestCase):
self.__gen_mac = varlist.get('gen_mac', self.__xmlObj.getKeyVal(self.__QPLCName, "gen_mac", "0"))
self.__mtd_device = varlist.get('mtd_device', self.__xmlObj.getKeyVal(self.__QPLCName, "mtd_device", "/dev/mtd0"))
self.__firmware_Path = varlist.get('firmwarepath', self.__xmlObj.getKeyVal(self.__QPLCName, "firmwarepath", "/root/hwtest-files/firmware"))
- self.__plc_test_ip = varlist.get('plc_test_ip', self.__xmlObj.getKeyVal(self.__QPLCName, "plc_test_ip", "10.10.1.254"))
self.__skipflash = varlist.get('skipflash', self.__xmlObj.getKeyVal(self.__QPLCName, "skipflash", "0"))
self.__plc = dcpPLC(self.__factoryTool, self.__mtd_device)
self.__factory_password = varlist.get('factory_password', self.__xmlObj.getKeyVal(self.__QPLCName, "factory_password", "0"))
@@ -82,25 +83,37 @@ class Qplc(unittest.TestCase):
self.fail('BUG: ?????')
logObj.getlogger().info("MAC {}".format(res[0]))
plcMAC = res[0][0]
- time.sleep(12)
+ # wait for PLC to be turned on
+ attemptcounter = 0
+ plcfound = False
+ while attemptcounter < 5 and not plcfound:
+ if self.__plc.discover():
+ plcfound = True
+ else:
+ attemptcounter += 1
+ time.sleep(5)
+ # mandatory wait before configuring the PLC chip
+ time.sleep(2)
self.__plc.set_plc2('SYSTEM.PRODUCTION.SECTOR0_UNLOCK_PASSWORD',
self.__factory_password,
'SYSTEM.PRODUCTION.MAC_ADDR',
'{}'.format(plcMAC),
self.__firmware_password)
- #self.__plc.set_plc('SYSTEM.PRODUCTION.SECTOR0_UNLOCK_PASSWORD', self.__factory_password, self.__firmware_password)
- #plcMAC = res[0][0]
- #self.__plc.set_plc('SYSTEM.PRODUCTION.MAC_ADDR', '{}'.format(plcMAC), self.__firmware_password)
+ # plc reset to save changes
self.__plc.setPLCReset()
time.sleep(int(self.__plc_reset_wait))
+ # calculate the IP of the GPLC0000 board to ping
+ ip_eth01 = ni.ifaddresses('eth0:1')[AF_INET][0]['addr'] # plc_test_ip = 10.10.1.113
+ ip_eth01_splited = ip_eth01.split('.')
+ ip_eth01_splited[3] = str(int(ip_eth01_splited[3]) + 100)
+ plc_test_ip = ".".join(ip_eth01_splited) # plc_test_ip = 10.10.1.213
# ping against the GPLC0000 board
ping3.EXCEPTIONS = True
try:
- ping3.ping(self.__plc_test_ip, timeout=0.1)
+ ping3.ping(plc_test_ip, timeout=0.1)
except:
self.fail('PLC ping timeout')
-
def getresults(self):
return self.__resultlist