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

Tlm DB を v3 に更新 #363

Open
wants to merge 5 commits into
base: main
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
2 changes: 1 addition & 1 deletion code-generator/my_mod/cmd_def.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ def GenerateCmdDef(settings, sgc_db):
if j >= param_num and type_list[j] != "":
err_flag = 1
if err_flag:
print("Error: Cmd DB Err at " + name, file=sys.stderr)
print("Error: Cmd DB Err at " + name + ".", file=sys.stderr)
sys.exit(1)

# パラメタ長のカウント
Expand Down
2 changes: 1 addition & 1 deletion code-generator/my_mod/load_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def LoadTlmCSV_(tlm_db_path, db_prefix, tlm_id_range, encoding):
tlm_id = sheet[1][2] # FIXME: テレメIDを取得.マジックナンバーで指定してしまってる.
if not int(tlm_id_range[0], 0) <= int(tlm_id, 0) < int(tlm_id_range[1], 0):
print(
"Error: TLM ID is invalid at " + db_prefix + "_TLM_DB_" + tlm_name + ".csv",
"Error: TLM ID is invalid at " + db_prefix + "_TLM_DB_" + tlm_name + ".csv.",
file=sys.stderr,
)
sys.exit(1)
Expand Down
2 changes: 1 addition & 1 deletion code-generator/my_mod/tlm_buffer.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ def GenerateTlmBuffer(settings, other_obc_dbs):
name_tree = name.lower().split(".")
name_path = "/".join(name_tree)
if SetStructTree_(tlm_struct_tree, name_path, var_type):
print("Error: Tlm DB Struct Parse Err at " + name, file=sys.stderr)
print("Error: Tlm DB Struct Parse Err at " + name + ".", file=sys.stderr)
sys.exit(1)

# pprint.pprint(tlm_struct_tree)
Expand Down
27 changes: 26 additions & 1 deletion code-generator/my_mod/tlm_def.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,18 @@ def GenerateTlmDef(settings, tlm_db):
if pos == "":
continue

# tlm field のバリデーション
if not my_mod.util.ValidateTlmField(name):
print(
"Error: Tlm Field must match `[A-Z_][0-9A-Z_]*` at "
+ name
+ " in "
+ tlm["tlm_name"].upper()
+ ".",
file=sys.stderr,
)
sys.exit(1)

pos = int(pos)
code = code.replace("@@", ",")
func_code += " "
Expand Down Expand Up @@ -89,8 +101,21 @@ def GenerateTlmDef(settings, tlm_db):
elif var_type == "double":
func_code += "TF_copy_double"
max_pos = pos + 8
elif var_type == "raw":
print(
"Error: Var. Type `raw` of "
+ name
+ " is forbidden in Telemetry Generator at "
+ tlm["tlm_name"].upper()
+ ".",
file=sys.stderr,
)
sys.exit(1)
else:
print("Error: Tlm DB Err at " + tlm["tlm_name"].upper(), file=sys.stderr)
print(
"Error: Tlm DB Err at " + name + " in " + tlm["tlm_name"].upper() + ".",
file=sys.stderr,
)
sys.exit(1)
func_code += "(&packet[" + str(pos) + "], " + code + ");\n"

Expand Down
15 changes: 11 additions & 4 deletions code-generator/my_mod/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,16 @@
import subprocess
import sys
import os
import re
import hashlib


def ValidateTlmField(name):
pattern = re.compile(r"[A-Z_][0-9A-Z_]*")
parts = name.split(".")
return all(pattern.fullmatch(part) for part in parts)


def GenerateSettingNote(settings):
note = ""
note += " * @note このコードは自動生成されています!\n"
Expand Down Expand Up @@ -74,7 +81,7 @@ def GetCommitHash_(path):
)
return result.stdout.strip()
except subprocess.CalledProcessError:
print("Warn: failed to get commit hash(" + path + ")", file=sys.stderr)
print("Warn: failed to get commit hash (" + path + ").", file=sys.stderr)
return "unknown"


Expand All @@ -92,7 +99,7 @@ def GetRepo_(path):
try:
subprocess.run(["git", "--version"], capture_output=True, check=True)
except subprocess.CalledProcessError:
print("Warn: failed to execute git command", file=sys.stderr)
print("Warn: failed to execute git command.", file=sys.stderr)
return "unknown/unknown/unknown"

try:
Expand All @@ -102,7 +109,7 @@ def GetRepo_(path):
remote = result.stdout.split("\n")[0] # 最初の remote を取得

if not remote:
print("Warn: failed to get git remote", file=sys.stderr)
print("Warn: failed to get git remote.", file=sys.stderr)
return "unknown/unknown/unknown"

remote_url = subprocess.run(
Expand All @@ -124,7 +131,7 @@ def GetRepo_(path):

return remote_url
except subprocess.CalledProcessError:
print("Warn: failed to execute: git remote", file=sys.stderr)
print("Warn: failed to execute: git remote.", file=sys.stderr)
return "unknown/unknown/unknown"


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
* @note このコードは自動生成されています!
* @note コード生成元 tlm-cmd-db:
* repository: github.com/arkedge/c2a-core.git
* CSV files MD5: 0e38aad788fca6fba1d44684152ac1a2
* db commit hash: e1e6b79acd85523f04266f1c08b7a3b89e5b6e05
* CSV files MD5: 9450db57c0e358a24dae8d48c378585d
* db commit hash: 84d0b4e00bf0a969cd5a2dd8e6f3081c62269b96
* @note コード生成パラメータ:
* name: AOBC
* db_prefix: SAMPLE_AOBC
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
* @note このコードは自動生成されています!
* @note コード生成元 tlm-cmd-db:
* repository: github.com/arkedge/c2a-core.git
* CSV files MD5: 0e38aad788fca6fba1d44684152ac1a2
* db commit hash: e1e6b79acd85523f04266f1c08b7a3b89e5b6e05
* CSV files MD5: 9450db57c0e358a24dae8d48c378585d
* db commit hash: 84d0b4e00bf0a969cd5a2dd8e6f3081c62269b96
* @note コード生成パラメータ:
* name: AOBC
* db_prefix: SAMPLE_AOBC
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
* @note このコードは自動生成されています!
* @note コード生成元 tlm-cmd-db:
* repository: github.com/arkedge/c2a-core.git
* CSV files MD5: 0e38aad788fca6fba1d44684152ac1a2
* db commit hash: e1e6b79acd85523f04266f1c08b7a3b89e5b6e05
* CSV files MD5: 9450db57c0e358a24dae8d48c378585d
* db commit hash: 84d0b4e00bf0a969cd5a2dd8e6f3081c62269b96
* @note コード生成パラメータ:
* name: AOBC
* db_prefix: SAMPLE_AOBC
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
* @note このコードは自動生成されています!
* @note コード生成元 tlm-cmd-db:
* repository: github.com/arkedge/c2a-core.git
* CSV files MD5: 0e38aad788fca6fba1d44684152ac1a2
* db commit hash: e1e6b79acd85523f04266f1c08b7a3b89e5b6e05
* CSV files MD5: 9450db57c0e358a24dae8d48c378585d
* db commit hash: 84d0b4e00bf0a969cd5a2dd8e6f3081c62269b96
* @note コード生成パラメータ:
* name: AOBC
* db_prefix: SAMPLE_AOBC
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
* @note このコードは自動生成されています!
* @note コード生成元 tlm-cmd-db:
* repository: github.com/arkedge/c2a-core.git
* CSV files MD5: 0e38aad788fca6fba1d44684152ac1a2
* db commit hash: e1e6b79acd85523f04266f1c08b7a3b89e5b6e05
* CSV files MD5: 9450db57c0e358a24dae8d48c378585d
* db commit hash: 84d0b4e00bf0a969cd5a2dd8e6f3081c62269b96
* @note コード生成パラメータ:
* name: AOBC
* db_prefix: SAMPLE_AOBC
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* @note このコードは自動生成されています!
* @note コード生成元 tlm-cmd-db:
* repository: github.com/arkedge/c2a-core.git
* CSV files MD5: a6ac3f58e1422615904c43d389e64877
* CSV files MD5: 73c2be94af0baa13f6e06ab0a10a499b
* @note コード生成パラメータ:
* db_prefix: SAMPLE_MOBC
* tlm_id_range: [0x00, 0x100]
Expand Down
2 changes: 1 addition & 1 deletion examples/mobc/src/src_user/tlm_cmd/command_definitions.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* @note このコードは自動生成されています!
* @note コード生成元 tlm-cmd-db:
* repository: github.com/arkedge/c2a-core.git
* CSV files MD5: a6ac3f58e1422615904c43d389e64877
* CSV files MD5: 73c2be94af0baa13f6e06ab0a10a499b
* @note コード生成パラメータ:
* db_prefix: SAMPLE_MOBC
* tlm_id_range: [0x00, 0x100]
Expand Down
2 changes: 1 addition & 1 deletion examples/mobc/src/src_user/tlm_cmd/command_definitions.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* @note このコードは自動生成されています!
* @note コード生成元 tlm-cmd-db:
* repository: github.com/arkedge/c2a-core.git
* CSV files MD5: a6ac3f58e1422615904c43d389e64877
* CSV files MD5: 73c2be94af0baa13f6e06ab0a10a499b
* @note コード生成パラメータ:
* db_prefix: SAMPLE_MOBC
* tlm_id_range: [0x00, 0x100]
Expand Down
2 changes: 1 addition & 1 deletion examples/mobc/src/src_user/tlm_cmd/telemetry_definitions.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* @note このコードは自動生成されています!
* @note コード生成元 tlm-cmd-db:
* repository: github.com/arkedge/c2a-core.git
* CSV files MD5: a6ac3f58e1422615904c43d389e64877
* CSV files MD5: 73c2be94af0baa13f6e06ab0a10a499b
* @note コード生成パラメータ:
* db_prefix: SAMPLE_MOBC
* tlm_id_range: [0x00, 0x100]
Expand Down
2 changes: 1 addition & 1 deletion examples/mobc/src/src_user/tlm_cmd/telemetry_definitions.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* @note このコードは自動生成されています!
* @note コード生成元 tlm-cmd-db:
* repository: github.com/arkedge/c2a-core.git
* CSV files MD5: a6ac3f58e1422615904c43d389e64877
* CSV files MD5: 73c2be94af0baa13f6e06ab0a10a499b
* @note コード生成パラメータ:
* db_prefix: SAMPLE_MOBC
* tlm_id_range: [0x00, 0x100]
Expand Down
Binary file modified examples/mobc/tlm-cmd-db/TLM_DB/SAMPLE_MOBC_TLM_DB.xlsm
Binary file not shown.
Loading
Loading