diff options
author | Manel Caro <mcaro@iseebcn.com> | 2020-07-31 13:58:41 +0200 |
---|---|---|
committer | Manel Caro <mcaro@iseebcn.com> | 2020-07-31 13:58:41 +0200 |
commit | 227d9783fe8327b84ac3b0e032f012ba144816f8 (patch) | |
tree | 47ad5279c7593d6f2db4b7167fe0be9266f74203 /test-cli/test/helpers | |
parent | d46bce422fd03cd57d1ba336361da17d6efb48db (diff) | |
download | board-227d9783fe8327b84ac3b0e032f012ba144816f8.zip board-227d9783fe8327b84ac3b0e032f012ba144816f8.tar.gz board-227d9783fe8327b84ac3b0e032f012ba144816f8.tar.bz2 |
IGEP0048: added plc test
Diffstat (limited to 'test-cli/test/helpers')
-rw-r--r-- | test-cli/test/helpers/plc.py | 26 | ||||
-rw-r--r-- | test-cli/test/helpers/testsrv_db.py | 13 |
2 files changed, 35 insertions, 4 deletions
diff --git a/test-cli/test/helpers/plc.py b/test-cli/test/helpers/plc.py index 3b00934..b1ec382 100644 --- a/test-cli/test/helpers/plc.py +++ b/test-cli/test/helpers/plc.py @@ -1,10 +1,10 @@ import sh from sh import flashcp -from sh import flash_erase +from sh import flash_eraseall from sh import ErrorReturnCode from sh import Command from test.helpers.gpio import gpio - +import time class dcpPLC(object): __nReset = None @@ -33,10 +33,18 @@ class dcpPLC(object): self.__nRest = gpio('75', 'out', '1') self.__nRest = gpio('69', 'out', '1') + def setPLCReset(self): + self.__nRest = gpio('75', 'out', '0') + self.__nRest = gpio('69', 'out', '0') + time.sleep(0.25) + self.__nRest = gpio('69', 'out', '1') + self.__nRest = gpio('75', 'out', '1') + + def SaveFirmware(self, firmare): self.setSaveFirmwareMode() try: - flash_erase(self.__mtd_device) + flash_eraseall(self.__mtd_device) flashcp(firmare, self.__mtd_device) except ErrorReturnCode as Error: return False, "plc flash firmware failed {} ".format(Error.exit_code) @@ -44,11 +52,21 @@ class dcpPLC(object): def set_plc (self, var, value, password): try: - self.__myConfigTool("-o", "SET", "-p", "{}".format(var), '{}'.format(value), "-w", "{}".format(password)) + res = self.__myConfigTool("-o", "SET", "-p", "{}={}".format(var, value), "-w", "{}".format(password)) + print(res) except ErrorReturnCode as Error: return False, "set var failed {} {}".format(var,Error.exit_code) return True, '' + def set_plc2 (self, var1, value1,var2, value2, password): + try: + res = self.__myConfigTool("-o", "SET", "-p", "{}={}".format(var1, value1), "-p", "{}={}".format(var2, value2), "-w", "{}".format(password)) + print(res) + except ErrorReturnCode as Error: + return False, "set var failed {}".format(Error.exit_code) + return True, '' + + def get_plc (self, var, value, password): try: self.__myConfigTool("-o", "GET", "-p", "{}".format(var), '{}'.format(value), "-w", "{}".format(password)) diff --git a/test-cli/test/helpers/testsrv_db.py b/test-cli/test/helpers/testsrv_db.py index c2b2276..556c246 100644 --- a/test-cli/test/helpers/testsrv_db.py +++ b/test-cli/test/helpers/testsrv_db.py @@ -132,6 +132,19 @@ class TestSrv_Database(object): # print(r) return None + + def get_plc_macaddr(self, board_uuid): + sql = "SELECT * FROM isee.f_get_plcmac(\'{}\')".format(board_uuid) + # print('>>>' + sql) + try: + res = self.__sqlObject.db_execute_query(sql) + return res, '' + except Exception as err: + r = find_between(str(err), '#', '#') + print(r) + return None, r + + def get_board_macaddr(self, board_uuid): sql = "SELECT * FROM isee.f_get_board_macaddr('{}')".format(board_uuid) # print('>>>' + sql) |