Ejemplo n.º 1
0
def perform_config(dev, args):
    module_config = DEVICE[args.device_type]['config'][args.module]
    module_id = module_config['id']
    device_options = module_config['options']

    config_name = args.option
    value_type = device_options[config_name].type
    recipient = get_device_pid(args.device_type)

    if args.value is None:
        success, val = fetch_config(dev, recipient, config_name,
                                    device_options, module_id)
        if success:
            print('Fetched {}: {}'.format(config_name, val))
        else:
            print('Failed to fetch {}'.format(config_name))
    else:
        try:
            config_value = value_type(args.value)
        except ValueError:
            print('Invalid type for {}. Expected {}'.format(
                config_name, value_type))
            return
        success = change_config(dev, recipient, config_name, config_value,
                                device_options, module_id)

        if success:
            print('{} set to {}'.format(config_name, config_value))
        else:
            print('Failed to set {}'.format(config_name))
Ejemplo n.º 2
0
 def setcpi(self, value):
     config_name = 'cpi'
     module_config = DEVICE[self.type]['config']['sensor']
     options = module_config['options']
     module_id = module_config['id']
     recipient = self.pid
     dev = self.dev
     config_value = int(value)
     success = change_config(dev, recipient, config_name, config_value,
                             options, module_id)
     return success
Ejemplo n.º 3
0
def perform_config(dev, args):
    module_config = DEVICE[args.device_type]['config'][args.module]
    module_id = module_config['id']
    device_options = module_config['options']

    config_name = args.option
    recipient = get_device_pid(args.device_type)

    if args.value is None:
        success, val = fetch_config(dev, recipient, config_name,
                                    device_options, module_id)
        if success:
            print('Fetched {}: {}'.format(config_name, val))
        else:
            print('Failed to fetch {}'.format(config_name))
    else:
        config_value = int(args.value)
        success = change_config(dev, recipient, config_name, config_value,
                                device_options, module_id)

        if success:
            print('{} set to {}'.format(config_name, config_value))
        else:
            print('Failed to set {}'.format(config_name))