From 5fd7f36c6565c6c6b49c949851b561b139c3621f Mon Sep 17 00:00:00 2001 From: occheung Date: Tue, 6 Oct 2020 15:01:04 +0800 Subject: [PATCH] flash: generate bin thru py --- flash.py | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 flash.py diff --git a/flash.py b/flash.py new file mode 100644 index 0000000..c8fa12f --- /dev/null +++ b/flash.py @@ -0,0 +1,49 @@ +import argparse +import struct + + +def get_argparser(): + parser = argparse.ArgumentParser(description="MQTT-controlled 4-channel DDS signal generator") + + parser.add_argument("cidr", nargs=1, + metavar=("Client_CIDR"), + help="IPv4 Address of Humpback-DDS in CIDR notation") + parser.add_argument("mac_addr", nargs=1, + metavar=("Client_MAC"), + help="MAC Address of Humpback-DDS") + parser.add_argument("broker_ip", nargs=1, + metavar=("Broker_IP"), + help="IP address of MQTT broker") + parser.add_argument("name", nargs=1, + metavar=("Name"), + help="Device name of Humpback-DDS") + + return parser + + +def write_record(f, key, value): + key_size = len(key) + 1 + value_size = len(value) + record_size = key_size + value_size + 4 + f.write(struct.pack("