Skip to content

Commit

Permalink
Merge pull request #35 from ut-issl/feature/del_Cmd_from_cmd_db
Browse files Browse the repository at this point in the history
Cmd DB に "Cmd_" がない DB への対応
  • Loading branch information
meltingrabbit authored Apr 9, 2023
2 parents 34046f4 + e0da8f6 commit fcb75bb
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 8 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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",
# 出力ファイルのエンコーディング
Expand All @@ -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/",
Expand All @@ -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/",
Expand Down
23 changes: 15 additions & 8 deletions my_mod/cmd_def.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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)):
Expand Down Expand Up @@ -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]
Expand Down Expand Up @@ -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 = (
Expand All @@ -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 += """
Expand Down
3 changes: 3 additions & 0 deletions settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand Down

0 comments on commit fcb75bb

Please sign in to comment.