From a9d545c207f346fcf57a6a94ff010d471d733d4e Mon Sep 17 00:00:00 2001 From: "ethan.du" Date: Wed, 17 Jun 2020 18:33:28 +0800 Subject: [PATCH] bugfix fix string parse --- tools/codegen.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tools/codegen.py b/tools/codegen.py index 9e06226..7a7ea7a 100644 --- a/tools/codegen.py +++ b/tools/codegen.py @@ -279,11 +279,10 @@ class input_json_parse: elif self.type_name == "float32" or self.type_name == "float64": input_config += " node_cmd_input_{}_{}.value.{} = atof({});\n".format(self.cmd_id, self.input["Identifier"], "{}_value".format(self.type_name), self.cmd_id + "_" + self.input["Identifier"]) else: - input_config += " node_cmd_input_{}_{}.value.{} = {};\n".format(self.cmd_id, self.input["Identifier"], "{}_value".format(self.type_name), self.cmd_id + "_" + self.input["Identifier"]) input_config += " if(NULL != node_cmd_input_{}_{}.value.{})\n".format(self.cmd_id, self.input["Identifier"], "{}_value".format(self.input["DataType"]["Type"])) input_config += " HAL_Free(node_cmd_input_{}_{}.value.{});\n".format(self.cmd_id, self.input["Identifier"], "{}_value".format(self.input["DataType"]["Type"])) input_config += " node_cmd_input_{}_{}.value.{} = HAL_Malloc(strlen({}) + 1);\n".format(self.cmd_id, self.input["Identifier"], "{}_value".format(self.input["DataType"]["Type"]), self.cmd_id + "_" + self.input["Identifier"]) - input_config += " strncpy(node_cmd_input_{}_{}[{}].value.{}, {}, strlen({}));\n".format(self.cmd_id, self.input["Identifier"], "{}_value".format(self.input["DataType"]["Type"]), self.cmd_id + "_" + self.input["Identifier"], self.cmd_id + "_" + self.input["Identifier"]) + input_config += " strncpy(node_cmd_input_{}_{}.value.{}, {}, strlen({}));\n".format(self.cmd_id, self.input["Identifier"], "{}_value".format(self.input["DataType"]["Type"]), self.cmd_id + "_" + self.input["Identifier"], self.cmd_id + "_" + self.input["Identifier"]) input_config += " node_cmd_input_{}_{}.value.{}[strlen({})] = \'\\0\';\n".format(self.cmd_id, self.input["Identifier"], "{}_value".format(self.input["DataType"]["Type"]), self.cmd_id + "_" + self.input["Identifier"]) input_config += " HAL_Free({});\n".format(self.cmd_id + "_" + self.input["Identifier"]) input_config += " return;\n"