diff --git a/testing/SYS-DVT/data.json b/testing/SYS-DVT/data.json index f3bfe438b8..24e52306aa 100644 --- a/testing/SYS-DVT/data.json +++ b/testing/SYS-DVT/data.json @@ -1,6 +1,6 @@ { - "modules": { - "bb_sensor": { + "module": { + "bb_current": { "sys_path": "/sys/bb_sensor", "get_vars": { "bb_shunt_voltage": { @@ -17,10 +17,10 @@ "unit": "mW" } }, - "set_vars": "NULL" + "set_vars": null }, - "bb_temperature": { + "bb_temp": { "sys_path": "/sys/bb_temp", "get_vars": { "bb_input_temp": { @@ -37,18 +37,18 @@ }, "set_vars": { "bb_max_temp": { - "max_val": "100", - "min_val": "-15", + "max_val": 125, + "min_val": -25, "unit": "Celcius" }, "bb_max_hyst": { - "max_val": "100", - "min_val": "-15", + "max_val": 125, + "min_val": -25, "unit": "Celcius" } } }, - "Help": "./occmd.py ", + "help": "./occmd.py ", "version": "0.1" } diff --git a/testing/SYS-DVT/occmd.py b/testing/SYS-DVT/occmd.py index beff6275cf..6c5a12bdbd 100644 --- a/testing/SYS-DVT/occmd.py +++ b/testing/SYS-DVT/occmd.py @@ -4,9 +4,41 @@ import json DB_FILE = "data.json" db = ''; +module = '' +operation = '' +param = '' +value = '' -def parse_it(args): - for +def check_args(args): + global module + global operation + global param + global value + + # check for module name + if((len(args) < 2) or (args[1] == 'help')): + return -1 + + for x in db['module']: + if(x == args[1]): + module = x + # Check for get/set + if(len(args) < 3 and (args[2] == 'get' or args[2] == 'set')): + return -1 + else: + operation = args[2] + if(operation == 'set'): + if(len(args) < 5): + return -1 + else: + param = args[3] + value = args[4] + else: # get + if(len(args) < 4): + return -1 + else: + param = args[3] + return 0 def load_database(): @@ -17,8 +49,13 @@ def load_database(): def main(): load_database() - print db - parse_it(sys.argv) + if(check_args(sys.argv)): + print db['module']['help'] + sys.exit(-1) + + # We have a valid request request process it + print "Request valid" + sys.exit(0)