commit
24215c72a1
@ -22,4 +22,6 @@ python3 -m pip install -r requirements.txt
|
|||||||
ping -c 5 -w 20 stabilizer-hitl
|
ping -c 5 -w 20 stabilizer-hitl
|
||||||
|
|
||||||
# Test the MQTT interface.
|
# Test the MQTT interface.
|
||||||
python3 miniconf.py dt/sinara/stabilizer afe/0 '"G2"'
|
python3 miniconf.py dt/sinara/stabilizer afe/0='"G2"'
|
||||||
|
python3 miniconf.py dt/sinara/stabilizer afe/0='"G1"' iir_ch/0/0=\
|
||||||
|
'{"y_min": -32767, "y_max": 32767, "y_offset": 0, "ba": [1.0, 0, 0, 0, 0]}'
|
||||||
|
18
miniconf.py
18
miniconf.py
@ -83,8 +83,10 @@ class Miniconf:
|
|||||||
def main():
|
def main():
|
||||||
parser = argparse.ArgumentParser(
|
parser = argparse.ArgumentParser(
|
||||||
description='Miniconf command line interface.',
|
description='Miniconf command line interface.',
|
||||||
epilog='''Example:
|
formatter_class=argparse.RawDescriptionHelpFormatter,
|
||||||
%(prog)s -v -b mqtt dt/sinara/stabilizer afe/0 '"G10"'
|
epilog='''Examples:
|
||||||
|
%(prog)s dt/sinara/stabilizer afe/0='"G2"' iir_ch/0/0=\
|
||||||
|
'{"y_min": -32767, "y_max": 32767, "y_offset": 0, "ba": [1.0, 0, 0, 0, 0]}'
|
||||||
''')
|
''')
|
||||||
parser.add_argument('-v', '--verbose', action='count', default=0,
|
parser.add_argument('-v', '--verbose', action='count', default=0,
|
||||||
help='Increase logging verbosity')
|
help='Increase logging verbosity')
|
||||||
@ -92,10 +94,8 @@ def main():
|
|||||||
help='The MQTT broker address')
|
help='The MQTT broker address')
|
||||||
parser.add_argument('prefix', type=str,
|
parser.add_argument('prefix', type=str,
|
||||||
help='The MQTT topic prefix of the target')
|
help='The MQTT topic prefix of the target')
|
||||||
parser.add_argument('path', type=str,
|
parser.add_argument('settings', metavar="KEY=VALUE", nargs='+',
|
||||||
help='The setting path to configure')
|
help='JSON encoded values for settings path keys.')
|
||||||
parser.add_argument('value', type=str,
|
|
||||||
help='The value of setting in JSON format')
|
|
||||||
|
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
@ -107,8 +107,10 @@ def main():
|
|||||||
|
|
||||||
async def configure_settings():
|
async def configure_settings():
|
||||||
interface = await Miniconf.create(args.prefix, args.broker)
|
interface = await Miniconf.create(args.prefix, args.broker)
|
||||||
response = await interface.command(args.path, json.loads(args.value))
|
for kv in args.settings:
|
||||||
print(f"Response: {response}")
|
path, value = kv.split("=", 1)
|
||||||
|
response = await interface.command(path, json.loads(value))
|
||||||
|
print(response)
|
||||||
|
|
||||||
loop.run_until_complete(configure_settings())
|
loop.run_until_complete(configure_settings())
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user