# HG changeset patch # User Edouard Tisserant # Date 1725544546 -7200 # Node ID fdbb3c4ebbf6047f79508a4c6b71bc376070d81f # Parent 3779356cca8f882ba60bd8a929105528e909ca71 MQTT: WIP supporting structured types : do not crash when generating C code if using location with no size diff -r 3779356cca8f -r fdbb3c4ebbf6 mqtt/mqtt_client_gen.py --- a/mqtt/mqtt_client_gen.py Fri Aug 30 15:17:03 2024 +0200 +++ b/mqtt/mqtt_client_gen.py Thu Sep 05 15:55:46 2024 +0200 @@ -363,7 +363,6 @@ #define USE_MQTT_5""".format(**config) AuthType = config["AuthType"] - print(config) if AuthType == "x509": for k in ["KeyStore","TrustStore"]: config[k] = '"'+config[k]+'"' if config[k] else "NULL" @@ -382,8 +381,13 @@ for row in self["output"]: Topic, QoS, _Retained, iec_type, iec_number = row Retained = 1 if _Retained=="True" else 0 - C_type, iec_size_prefix = MQTT_IEC_types[iec_type] - c_loc_name = "__Q" + iec_size_prefix + locstr + "_" + str(iec_number) + if iec_type in MQTT_IEC_types: + C_type, iec_size_prefix = MQTT_IEC_types[iec_type] + c_loc_name = "__Q" + iec_size_prefix + locstr + "_" + str(iec_number) + else: + C_type = iec_type.upper(); + c_loc_name = "__Q" + locstr + "_" + str(iec_number) + formatdict["decl"] += """ DECL_VAR({iec_type}, {C_type}, {c_loc_name})""".format(**locals()) @@ -397,8 +401,13 @@ # inputs need to be sorted for bisection search for row in sorted(self["input"]): Topic, QoS, iec_type, iec_number = row - C_type, iec_size_prefix = MQTT_IEC_types[iec_type] - c_loc_name = "__I" + iec_size_prefix + locstr + "_" + str(iec_number) + if iec_type in MQTT_IEC_types: + C_type, iec_size_prefix = MQTT_IEC_types[iec_type] + c_loc_name = "__I" + iec_size_prefix + locstr + "_" + str(iec_number) + else: + C_type = iec_type.upper(); + c_loc_name = "__I" + locstr + "_" + str(iec_number) + formatdict["decl"] += """ DECL_VAR({iec_type}, {C_type}, {c_loc_name})""".format(**locals()) formatdict["topics"] += """