From 5f8d0ec71c046a39f53e2245e21f98c9f4de94bc Mon Sep 17 00:00:00 2001 From: cacke-r Date: Sun, 30 Jan 2022 21:20:38 +0100 Subject: [PATCH] Add Autocalibrate command to chamtool Signed-off-by: cacke-r --- Software/ChamTool/Chameleon/Device.py | 4 ++++ Software/ChamTool/chamtool.py | 14 ++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/Software/ChamTool/Chameleon/Device.py b/Software/ChamTool/Chameleon/Device.py index 6aae7d57..f65ed4ec 100644 --- a/Software/ChamTool/Chameleon/Device.py +++ b/Software/ChamTool/Chameleon/Device.py @@ -27,6 +27,7 @@ class Device: COMMAND_GREEN_LED = "LEDGREEN" COMMAND_RED_LED = "LEDRED" COMMAND_THRESHOLD = "THRESHOLD" + COMMAND_AUTOCALIBRATE = "AUTOCALIBRATE" COMMAND_UPGRADE = "upgrade" STATUS_CODE_OK = 100 @@ -277,6 +278,9 @@ def cmdThreshold(self, value): else: return self.getSetCmd(self.COMMAND_THRESHOLD, value) + def cmdAutoCalibrate(self): + return self.returnCmd(self.COMMAND_AUTOCALIBRATE) + def cmdUpgrade(self): # Execute command cmdLine = self.COMMAND_UPGRADE + self.LINE_ENDING diff --git a/Software/ChamTool/chamtool.py b/Software/ChamTool/chamtool.py index 8a1203f5..a3f27e86 100755 --- a/Software/ChamTool/chamtool.py +++ b/Software/ChamTool/chamtool.py @@ -177,6 +177,18 @@ def cmdThreshold(chameleon, arg): else: return "Setting threshold failed: {}".format(arg, result['statusText']) +def cmdAutoCalibrate(chameleon, arg): + + if (len(arg) == 0): + result = chameleon.cmdAutoCalibrate() + if (result['statusCode'] in chameleon.STATUS_CODES_SUCCESS): + return "Autocalibration successfully executed {}".format(result['statusText']) + else: + return "Error during autocalibration: {}".format(result['statusText']) + + else: + return "Command failed - No Parameter expected ! {}".format(arg) + def cmdUpgrade(chameleon, arg): if(chameleon.cmdUpgrade() == 0): print ("Device changed into Upgrade Mode") @@ -223,6 +235,7 @@ def main(): cmdArgGroup.add_argument("-gl", "--gled", dest="gled", action=CmdListAction, metavar="FUNCTION", nargs='?', help="retrieve or set the current green led function") cmdArgGroup.add_argument("-rl", "--rled", dest="rled", action=CmdListAction, metavar="FUNCTION", nargs='?', help="retrieve or set the current red led function") cmdArgGroup.add_argument("-th", "--threshold", dest="threshold", action=CmdListAction, nargs='?', help="retrieve or set the threshold") + cmdArgGroup.add_argument("-ac", "--autocalibrate", dest="auto_calib", action=CmdListAction, nargs=0, help="Send AutoCalibration command") cmdArgGroup.add_argument("-ug", "--upgrade", dest="upgrade", action=CmdListAction, nargs=0, help="set the micro Controller to upgrade mode") args = argParser.parse_args() @@ -257,6 +270,7 @@ def main(): "gled" : cmdGreenLED, "rled" : cmdRedLED, "threshold" : cmdThreshold, + "auto_calib": cmdAutoCalibrate, "upgrade" : cmdUpgrade, }