Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Split header codegen #44

Open
wants to merge 2 commits into
base: split-c2a-root-dir-ref
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 20 additions & 4 deletions src/my_mod/cmd_def.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,8 @@ def GenerateCmdDef(c2a_root_dir, settings, sgc_db):

DATA_SART_ROW = 3

body_c = ""
# generate header
body_h = ""
# " cmd_table[Cmd_CODE_NOP].cmd_func = Cmd_NOP;"
# " Cmd_CODE_NOP = 0x0000,"
for i in range(DATA_SART_ROW, len(sgc_db)):
comment = sgc_db[i][0]
Expand All @@ -30,9 +29,27 @@ def GenerateCmdDef(c2a_root_dir, settings, sgc_db):
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"
body_h += " " + cmd_code + " = " + cmd_id + ",\n"

OutputCmdDefH_(output_file_path + output_file_name_base + ".h", body_h, settings)

# generate impl
body_c = ""
# " cmd_table[Cmd_CODE_NOP].cmd_func = Cmd_NOP;"
for i in range(DATA_SART_ROW, len(sgc_db)):
comment = sgc_db[i][0]
name = sgc_db[i][1]
cmd_id = sgc_db[i][3]
if comment == "" and name == "": # CommentもNameも空白なら打ち切り
break
if comment != "": # Comment
continue

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"

body_c += "\n"
for i in range(DATA_SART_ROW, len(sgc_db)):
comment = sgc_db[i][0]
Expand Down Expand Up @@ -93,7 +110,6 @@ def GenerateCmdDef(c2a_root_dir, settings, sgc_db):
)

OutputCmdDefC_(output_file_path + output_file_name_base + ".c", body_c, settings)
OutputCmdDefH_(output_file_path + output_file_name_base + ".h", body_h, settings)


def GenerateBctDef(c2a_root_dir, settings, bct_db):
Expand Down
11 changes: 8 additions & 3 deletions src/my_mod/tlm_def.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,15 @@ def GenerateTlmDef(c2a_root_dir, settings, tlm_db):

DATA_START_ROW = 8

body_c = ""
# generate header
body_h = ""
for tlm in tlm_db:
body_h += " Tlm_CODE_" + tlm["tlm_name"].upper() + " = " + tlm["tlm_id"] + ",\n"

OutputTlmDefH_(output_file_path + output_file_name_base + ".h", body_h, settings)

# generate impl
body_c = ""

# "static TF_TLM_FUNC_ACK OBC_(uint8_t* packet, uint16_t* len, uint16_t max_len);"
# " OBC_ID = 0x00,"
Expand All @@ -23,7 +30,6 @@ def GenerateTlmDef(c2a_root_dir, settings, tlm_db):
+ tlm["tlm_name"].upper()
+ "_(uint8_t* packet, uint16_t* len, uint16_t max_len);\n"
)
body_h += " Tlm_CODE_" + tlm["tlm_name"].upper() + " = " + tlm["tlm_id"] + ",\n"

body_c += "\n"
body_c += "void TF_load_tlm_table(TF_TlmInfo tlm_table[TF_MAX_TLMS])\n"
Expand Down Expand Up @@ -115,7 +121,6 @@ def GenerateTlmDef(c2a_root_dir, settings, tlm_db):
body_c += "}\n"

OutputTlmDefC_(output_file_path + output_file_name_base + ".c", body_c, settings)
OutputTlmDefH_(output_file_path + output_file_name_base + ".h", body_h, settings)


def GenerateOtherObcTlmDef(c2a_root_dir, settings, other_obc_dbs):
Expand Down