def get_pos_param(mavfile, option): inv_dic = {v: k for k, v in dic.items()} param_names = ['GPS_TYPE','GPS_NAVFILTER', 'GPS_MIN_DGPS', 'GPS_SBAS_MODE', 'AHRS_EKF_USE', 'AHRS_GPS_USE', 'EKF_GPS_TYPE','MAG_ENABLE'] ret_str = ''; for param_name in param_names: param_id = int(inv_dic[param_name]) name, value, data = receive_msg(mavfile, 'PARAM_VALUE', True, param_id = param_id) if param_name == 'GPS_MIN_DGPS': if value[1] == 100.0: int_value = 'C' elif value[1] == 50.0: int_value = 'L' else: pass else: int_value = int(value[1]) ret_str += str(int_value) if param_name == 'GPS_SBAS_MODE': ret_str += '_' print('-'*(len(max(param_names, key=len))+1)+'\n' + value[0] + ' '*(len(max(param_names,key=len))-len(param_name)+1) + ': ' + str(value[1])) return ret_str
def get_param(mavfile): while not command.end_entered(): option = raw_input('Choose an option (1. parameter by ID, 2. parameter by name, 3. all GPS parameters): ') if option == 'end': sys.exit() else: try: option = int(option) except: print('Input has to be an integer from the option list') pass if option == 1: param_id = int(raw_input('Type in ID: ')) name, value, data = receive_msg(mavfile, 'PARAM_VALUE', True, param_id = param_id) print('----------\n' + value[0] + ': ' + str(value[1]) + '\n' + '----------') elif option == 2 or option == '': param_name = raw_input('Type in parameter name: ') inv_dic = {v: k for k, v in dic.items()} if '_' not in param_name: param_name_splitted = param_name.split() param_name = '' for word in param_name_splitted: param_name += word.upper()+'_' param_name = param_name[:-1] #removing the last _ from the string print('Changed input to: ' + param_name) else: pass param_id = int(inv_dic[param_name]) name, value, data = receive_msg(mavfile, 'PARAM_VALUE', True, param_id = param_id) print('----------\n' + value[0] + ': ' + str(value[1]) + '\n' + '----------') elif option == 3: get_pos_param(mavfile, 'print') else: print('Option not defined')