-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #111 from arkedge/feature/import-c2a-tlm-cmd-code-…
…generator Import c2a-tlm-cmd-code-generator
- Loading branch information
Showing
15 changed files
with
1,484 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
[flake8] | ||
max-line-length = 100 | ||
ignore = | ||
# black と競合するので | ||
E203, | ||
E501, | ||
W503, | ||
W504 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# OSX | ||
.DS_Store | ||
.AppleDouble | ||
.LSOverride | ||
Icon | ||
|
||
# Thumbnails | ||
._* | ||
|
||
# Files that might appear on external disk | ||
.Spotlight-V100 | ||
.Trashes | ||
|
||
# others | ||
*.pyc | ||
gstos_files/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
# coding: UTF-8 | ||
""" | ||
python 3.7以上を要求 | ||
""" | ||
|
||
import json | ||
import sys | ||
|
||
import my_mod.load_db | ||
import my_mod.cmd_def | ||
import my_mod.tlm_def | ||
import my_mod.tlm_buffer | ||
|
||
|
||
# import pprint | ||
# import os.path | ||
# import msvcrt # Enter不要な入力用 | ||
# import subprocess | ||
|
||
|
||
# 環境変数 | ||
DEBUG = 0 | ||
# 0 : Release | ||
# 1 : all | ||
SETTING_FILE_PATH = "settings.json" | ||
|
||
|
||
def main(): | ||
with open(SETTING_FILE_PATH, mode="r") as fh: | ||
settings = json.load(fh) | ||
# print(settings["path_to_src"]); | ||
|
||
cmd_db = my_mod.load_db.LoadCmdDb(settings) | ||
tlm_db = my_mod.load_db.LoadTlmDb(settings) | ||
# pprint.pprint(cmd_db) | ||
# pprint.pprint(tlm_db) | ||
# print(tlm_db) | ||
|
||
my_mod.cmd_def.GenerateCmdDef(settings, cmd_db["sgc"]) | ||
my_mod.cmd_def.GenerateBctDef(settings, cmd_db["bct"]) | ||
my_mod.tlm_def.GenerateTlmDef(settings, tlm_db["tlm"]) | ||
|
||
if settings["is_main_obc"]: | ||
my_mod.cmd_def.GenerateOtherObcCmdDef(settings, cmd_db["other_obc"]) | ||
my_mod.tlm_def.GenerateOtherObcTlmDef(settings, tlm_db["other_obc"]) | ||
my_mod.tlm_buffer.GenerateTlmBuffer(settings, tlm_db["other_obc"]) | ||
|
||
print("Completed!") | ||
sys.exit(0) | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
# c2a-tlm-cmd-code-generator | ||
[TlmCmd DB](https://github.com/ut-issl/tlm-cmd-db)からC2Aのコードを生成するためのスクリプト | ||
|
||
以下が自動生成される. | ||
- command_definitions.c | ||
- command_definitions.h | ||
- telemetry_definitions.c | ||
- telemetry_definitions.h | ||
- block_command_definitions.h | ||
|
||
## 実行 | ||
``` | ||
$ python GenerateC2ACode.py | ||
``` | ||
|
||
## 設定 | ||
`settings.json` にて記述する. | ||
|
||
`is_main_obc` は,MOBC(地上局と通信するOBC.2nd OBCのtlm/cmdを取りまとめる)かそれ以外のOBC(2nd OBC.MOBCと通信するOBC)かを制御する. | ||
`1` とした場合,MOBCを意図したコードが生成され,加えて以下が生成される. | ||
- 2nd_obc_command_definitions.h | ||
- 2nd_obc_telemetry_definitions.h | ||
- 2nd_obc_telemetry_buffer.c | ||
- 2nd_obc_telemetry_buffer.h | ||
- 2nd_obc_telemetry_data_definitions.h | ||
|
||
``` | ||
{ | ||
# `src_core`, `src_user` のあるディレクトリへのパス | ||
"path_to_src" : "../../c2a/src/", | ||
# テレコマ DB のあるディレクトリへのパス | ||
"path_to_db" : "../../c2a/database/", | ||
# TlmCmdDBのファイル名の接頭辞 | ||
"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", | ||
# 出力ファイルのエンコーディング | ||
"output_file_encoding" : "utf-8", | ||
# MOBCか?(他のOBCのtlm/cmdを取りまとめるか?) 0/1 | ||
# 2nd OBCのコードを生成するときなどは 0 にする | ||
# 0 の場合,以後のパラメタは無効 | ||
"is_main_obc" : 1, | ||
"other_obc_data" : [ | ||
{ | ||
# OBC名 | ||
"name" : "AOBC", | ||
# コードを生成するか? | ||
"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) | ||
"path_to_db" : "../../c2a_sample_aobc/database/", | ||
# MOBC で保持するテレメの TLM ID の最大値(=テレメ種類数) | ||
"max_tlm_num" : 256, | ||
"driver_path" : "Aocs/", | ||
"driver_type" : "AOBC_Driver", | ||
"driver_name" : "aobc", | ||
"code_when_tlm_not_found" : "aobc_driver->info.comm.rx_err_code = AOBC_RX_ERR_CODE_TLM_NOT_FOUND;" | ||
}, | ||
{ | ||
# OBC名 | ||
"name" : "TOBC", | ||
# コードを生成するか? | ||
"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) | ||
"path_to_db" : ""../../c2a_sample_tobc/database/", | ||
# MOBC で保持するテレメの TLM ID の最大値(=テレメ種類数) | ||
"max_tlm_num" : 256, | ||
"driver_path" : "Thermal/", | ||
"driver_type" : "TOBC_Driver", | ||
"driver_name" : "tobc", | ||
"code_when_tlm_not_found" : "tobc_driver->info.comm.rx_err_code = TOBC_RX_ERR_CODE_TLM_NOT_FOUND;" | ||
} | ||
] | ||
} | ||
``` | ||
|
||
## 開発方針 | ||
- `main`: リリース版 | ||
- `feature/*` : 開発ブランチ | ||
|
||
というブランチを用いる. | ||
|
||
[C2A Core](https://github.com/ut-issl/c2a-core) との互換性などは,[Releases](https://github.com/ut-issl/c2a-tlm-cmd-code-generator/releases) を参照すること([詳細](https://github.com/ut-issl/c2a-core/tree/develop/Docs/.General/release.md)) | ||
|
||
## 要求 | ||
- python 3.7 以上 | ||
- 必要ライブラリは `./requirements.txt` に記載. | ||
- なお,現在は標準ライブラリのみしか使っていない | ||
- 以下で一括インストール可能 | ||
``` | ||
$ pip install -r requirements.txt | ||
``` | ||
|
||
## その他 | ||
- MOBCと2nd OBCのC2A間通信の例は (TBA). |
Oops, something went wrong.