From a212bbb313e89662c93dceea6080899c7b58973b Mon Sep 17 00:00:00 2001 From: cacke-r Date: Tue, 15 Feb 2022 20:56:36 +0100 Subject: [PATCH] Chamtool: Add Autothreshold command Signed-off-by: cacke-r --- Software/ChamTool/Chameleon/Device.py | 6 +++++- Software/ChamTool/chamtool.py | 13 +++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/Software/ChamTool/Chameleon/Device.py b/Software/ChamTool/Chameleon/Device.py index f65ed4ec..e050db8c 100644 --- a/Software/ChamTool/Chameleon/Device.py +++ b/Software/ChamTool/Chameleon/Device.py @@ -28,6 +28,7 @@ class Device: COMMAND_RED_LED = "LEDRED" COMMAND_THRESHOLD = "THRESHOLD" COMMAND_AUTOCALIBRATE = "AUTOCALIBRATE" + COMMAND_AUTOTHRESHOLD = "AUTOTHRESHOLD" COMMAND_UPGRADE = "upgrade" STATUS_CODE_OK = 100 @@ -280,7 +281,10 @@ def cmdThreshold(self, value): def cmdAutoCalibrate(self): return self.returnCmd(self.COMMAND_AUTOCALIBRATE) - + + def cmdAutoThreshold(self, newLogMode): + return self.getSetCmd(self.COMMAND_AUTOTHRESHOLD, newLogMode) + 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 a3f27e86..95bae741 100755 --- a/Software/ChamTool/chamtool.py +++ b/Software/ChamTool/chamtool.py @@ -188,6 +188,17 @@ def cmdAutoCalibrate(chameleon, arg): else: return "Command failed - No Parameter expected ! {}".format(arg) + +def cmdAutoThreshold(chameleon, arg): + result = chameleon.cmdAutoThreshold(arg) + + if (arg is None): + return "Autothreshold is: {}".format(result['response']) + else: + if (result['statusCode'] in chameleon.STATUS_CODES_SUCCESS): + return "Autothreshold is now {}".format(arg) + else: + return "Setting Autothreshold failed: {}".format(arg, result['statusText']) def cmdUpgrade(chameleon, arg): if(chameleon.cmdUpgrade() == 0): @@ -236,6 +247,7 @@ def main(): 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("-at", "--autothreshold", dest="auto_thres", action=CmdListAction, metavar="0/1", nargs='?', help="DIS-/ENABLES Autothreshold for SniffIso15693 Codec") cmdArgGroup.add_argument("-ug", "--upgrade", dest="upgrade", action=CmdListAction, nargs=0, help="set the micro Controller to upgrade mode") args = argParser.parse_args() @@ -271,6 +283,7 @@ def main(): "rled" : cmdRedLED, "threshold" : cmdThreshold, "auto_calib": cmdAutoCalibrate, + "auto_thres": cmdAutoThreshold, "upgrade" : cmdUpgrade, }