diff --git a/README.md b/README.md index 764c9f5..004c6bc 100644 --- a/README.md +++ b/README.md @@ -33,6 +33,8 @@ $ python GenerateC2ACode.py "db_prefix" : "SAMPLE_MOBC", # TLM ID の定義域 "tlm_id_range" : ["0x00", "0x100"], + # Cmd DB の Name に "Cmd_" の接頭辞が含まれるか?(今後は含まれないのが基本とする) + "is_cmd_prefixed_in_db" : 0, # 入力 Tlm Cmd DB のエンコーディング "input_file_encoding" : "utf-8", # 出力ファイルのエンコーディング @@ -49,6 +51,7 @@ $ python GenerateC2ACode.py "is_enable" : 1, "db_prefix" : "SAMPLE_AOBC", "tlm_id_range" : ["0x90", "0xc0"], + "is_cmd_prefixed_in_db" : 0, "input_file_encoding" : "utf-8", # DBがあるディレクトリへのパス(絶対でも相対でもOK) "db_path" : "../../c2a_sample_aobc/src/src_user/Settings/TlmCmd/DataBase/", @@ -66,6 +69,7 @@ $ python GenerateC2ACode.py "is_enable" : 1, "db_prefix" : "SAMPLE_TOBC", "tlm_id_range" : ["0xc0", "0xf0"], + "is_cmd_prefixed_in_db" : 0, "input_file_encoding" : "utf-8", # DBがあるディレクトリへのパス(絶対でも相対でもOK) "db_path" : ""../../c2a_sample_tobc/src/src_user/Settings/TlmCmd/DataBase/", diff --git a/my_mod/cmd_def.py b/my_mod/cmd_def.py index e3022ab..1782f51 100644 --- a/my_mod/cmd_def.py +++ b/my_mod/cmd_def.py @@ -27,8 +27,7 @@ def GenerateCmdDef(settings, sgc_db): if comment != "": # Comment continue - cmd_name = name - cmd_code = cmd_name.replace("Cmd_", "Cmd_CODE_") + cmd_name, cmd_code = GetCmdNameAndCmdCode_(name, settings["is_cmd_prefixed_in_db"]) # print(cmd_name) # print(cmd_code) body_c += " cmd_table[" + cmd_code + "].cmd_func = " + cmd_name + ";\n" @@ -53,8 +52,7 @@ def GenerateCmdDef(settings, sgc_db): sgc_db[i][13], sgc_db[i][15], ] - cmd_name = name - cmd_code = cmd_name.replace("Cmd_", "Cmd_CODE_") + cmd_name, cmd_code = GetCmdNameAndCmdCode_(name, settings["is_cmd_prefixed_in_db"]) # パラメタ長の整合性チェック for j in range(len(type_list)): @@ -105,8 +103,6 @@ def GenerateBctDef(settings, bct_db): DATA_SART_ROW = 2 body_h = "" - # " cmd_table[Cmd_CODE_NOP].cmd_func = Cmd_NOP;" - # " Cmd_CODE_NOP = 0x0000," for i in range(DATA_SART_ROW, len(bct_db)): comment = bct_db[i][0] name = bct_db[i][1] @@ -161,8 +157,10 @@ def GenerateOtherObcCmdDef(settings, other_obc_dbs): if comment != "": # Comment continue # print(name) - cmd_name = name - cmd_code = cmd_name.replace("Cmd_", name_upper + "_Cmd_CODE_") + _, cmd_code = GetCmdNameAndCmdCode_( + name, settings["other_obc_data"][i]["is_cmd_prefixed_in_db"] + ) + cmd_code = name_upper + "_" + cmd_code body_h += " " + cmd_code + " = " + cmd_id + ",\n" # print(body_h) output_file_path = ( @@ -175,6 +173,15 @@ def GenerateOtherObcCmdDef(settings, other_obc_dbs): OutputOtherObcCmdDefH_(output_file_path, obc_name, body_h, settings) +def GetCmdNameAndCmdCode_(name, is_cmd_prefixed_in_db): + if is_cmd_prefixed_in_db: + cmd_name = name + else: + cmd_name = "Cmd_" + name + cmd_code = cmd_name.replace("Cmd_", "Cmd_CODE_") + return cmd_name, cmd_code + + def OutputCmdDefC_(file_path, body, settings): output = "" output += """ diff --git a/settings.json b/settings.json index 45e3c1c..bd8454d 100644 --- a/settings.json +++ b/settings.json @@ -2,6 +2,7 @@ "c2a_root_dir" : "../../c2a/src/", "db_prefix" : "SAMPLE_MOBC", "tlm_id_range" : ["0x00", "0x100"], + "is_cmd_prefixed_in_db" : 0, "input_file_encoding" : "utf-8", "output_file_encoding" : "utf-8", "is_main_obc" : 1, @@ -11,6 +12,7 @@ "is_enable" : 1, "db_prefix" : "SAMPLE_AOBC", "tlm_id_range" : ["0x90", "0xc0"], + "is_cmd_prefixed_in_db" : 0, "input_file_encoding" : "utf-8", "db_path" : "C:/c2a_sample_aobc/src/src_user/Settings/TlmCmd/DataBase/", "max_tlm_num" : 256, @@ -24,6 +26,7 @@ "is_enable" : 1, "db_prefix" : "SAMPLE_TOBC", "tlm_id_range" : ["0xc0", "0xf0"], + "is_cmd_prefixed_in_db" : 0, "input_file_encoding" : "utf-8", "db_path" : "C:/c2a_sample_tobc/src/src_user/Settings/TlmCmd/DataBase/", "max_tlm_num" : 256,