cli,hitl: allow more settings per invokation, expand example
This commit is contained in:
parent
a3511f5223
commit
7329d0f241
|
@ -22,4 +22,6 @@ python3 -m pip install -r requirements.txt
|
|||
ping -c 5 -w 20 stabilizer-hitl
|
||||
|
||||
# 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]}'
|
||||
|
|
15
miniconf.py
15
miniconf.py
|
@ -85,8 +85,7 @@ def main():
|
|||
description='Miniconf command line interface.',
|
||||
formatter_class=argparse.RawDescriptionHelpFormatter,
|
||||
epilog='''Examples:
|
||||
%(prog)s dt/sinara/stabilizer afe/0 '"G10"'
|
||||
%(prog)s dt/sinara/stabilizer iir_ch/0/0 \
|
||||
%(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,
|
||||
|
@ -95,10 +94,8 @@ def main():
|
|||
help='The MQTT broker address')
|
||||
parser.add_argument('prefix', type=str,
|
||||
help='The MQTT topic prefix of the target')
|
||||
parser.add_argument('path', type=str,
|
||||
help='The setting path to configure')
|
||||
parser.add_argument('value', type=str,
|
||||
help='The value of setting in JSON format')
|
||||
parser.add_argument('settings', metavar="KEY=VALUE", nargs='+',
|
||||
help='JSON encoded values for settings path keys.')
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
|
@ -110,8 +107,10 @@ def main():
|
|||
|
||||
async def configure_settings():
|
||||
interface = await Miniconf.create(args.prefix, args.broker)
|
||||
response = await interface.command(args.path, json.loads(args.value))
|
||||
print(response)
|
||||
for kv in args.settings:
|
||||
path, value = kv.split("=", 1)
|
||||
response = await interface.command(path, json.loads(value))
|
||||
print(response)
|
||||
|
||||
loop.run_until_complete(configure_settings())
|
||||
|
||||
|
|
Loading…
Reference in New Issue