diff --git a/CHANGELOG.md b/CHANGELOG.md index 8db6d652f..3b9edfa16 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,10 @@ ## v4.1.0 (Unreleased) +### Enhancements + +- [#214](https://github.com/arkedge/c2a-core/pull/214): CCSDS の主 MOBC 向け Data Link Layer のコードを Core 管理にする + ### Fixed - [#193](https://github.com/arkedge/c2a-core/pull/193): VCDU を AOS transfer frame に rename する @@ -30,6 +34,27 @@ - `#include ` -> `#include ` - `#include ` -> `#include ` - `#include ` -> `#include ` +- [#214](https://github.com/arkedge/c2a-core/pull/214): 影響範囲は MOBC の CCSDS Data Link Layer の実装 + 1. AOS Space Data Link Protocol の実装を c2a-core のものに切り替える + 1. `src_user/tlm_cmd/ccsds/` 内の既存の実装を消す + - `aos_transfer_frame.{c,h}` + - `multiplexing_protocol_data_unit.{c,h}` + - `tcp_to_m_pdu.{c,h}` + 1. c2a-core の実装を使うように切り替える + - `src_core/ccsds/aos_space_data_link_protocol/` 内のソースファイルをビルド対象に追加する + - CMake の場合, `C2A_USE_CORE_CCSDS_AOS_SPACE_DATA_LINK_PROTOCOL` option を `ON` にするだけでよい (C2A user top の `CMakeLists.txt`) + - `examples/mobc/CMakeLists.txt` を参考にできる. + 1. コンパイルが通らないところを直す.ファイルの場所が変わったことによる include path の修正が想定される. + 1. TC Space Data Link Protocol の実装を c2a-core のものに切り替える + 1. `src_user/tlm_cmd/ccsds/` 内の既存の実装を消す + - `tc_segment.{c,h}` + - `tc_transfer_frame.{c,h}` + 1. c2a-core の実装を使うように切り替える + - `src_core/ccsds/tc_space_data_link_protocol/` 内のソースファイルをビルド対象に追加する + - CMake の場合, `C2A_USE_CORE_CCSDS_TC_SPACE_DATA_LINK_PROTOCOL` option を `ON` にするだけでよい (C2A user top の `CMakeLists.txt`) + - `examples/mobc/CMakeLists.txt` を参考にできる. + 1. コンパイルが通らないところを直す.ファイルの場所が変わったことによる include path の修正が想定される. + ## v4.0.1 (2023-11-09) diff --git a/CMakeLists.txt b/CMakeLists.txt index f0c5ea1c6..95580c75d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -20,6 +20,11 @@ option(C2A_USE_ALL_CORE_APPS "Use C2A-core all Applications" ON) option(C2A_USE_ALL_CORE_TEST_APPS "Use C2A-core all Test Applications" ON) option(C2A_USE_ALL_CORE_LIB "Use C2A-core all library" ON) +## C2A CCSDS select +# See alse; /docs/core/ccsds.md +option(C2A_USE_CORE_CCSDS_AOS_SPACE_DATA_LINK_PROTOCOL "Use C2A-core CCSDS AOS SPACE DATA LINK PROTOCOL implementation" OFF) +option(C2A_USE_CORE_CCSDS_TC_SPACE_DATA_LINK_PROTOCOL "Use C2A-core CCSDS TC SPACE DATA LINK PROTOCOL implementation" OFF) + option(C2A_USE_SIMPLE_LIBC "Use C2A-core hosted simple libc (c2a-core/library/libc) implementation" OFF) set(C2A_CORE_DIR ${CMAKE_CURRENT_SOURCE_DIR}) @@ -99,4 +104,14 @@ if(C2A_USE_ALL_CORE_LIB) target_sources(${PROJECT_NAME} PUBLIC $) endif() +if(C2A_USE_CORE_CCSDS_AOS_SPACE_DATA_LINK_PROTOCOL) + add_subdirectory(tlm_cmd/ccsds/aos_space_data_link_protocol) + target_sources(${PROJECT_NAME} PUBLIC $) +endif() + +if(C2A_USE_CORE_CCSDS_TC_SPACE_DATA_LINK_PROTOCOL) + add_subdirectory(tlm_cmd/ccsds/tc_space_data_link_protocol) + target_sources(${PROJECT_NAME} PUBLIC $) +endif() + include(common.cmake) diff --git a/docs/README.md b/docs/README.md index 777af589c..c624ce479 100644 --- a/docs/README.md +++ b/docs/README.md @@ -37,6 +37,7 @@ C2A に関する説明の棲み分けは,次のようになっています. 1. Core Layer 1. Overview 1. [Communication](./core/communication.md) + 1. [CCSDS](./core/ccsds.md) 1. [Tips](./core/tips.md) 1. Component Driver 1. [Overview](./component_driver/overview.md) diff --git a/docs/core/ccsds.md b/docs/core/ccsds.md new file mode 100644 index 000000000..869f4c506 --- /dev/null +++ b/docs/core/ccsds.md @@ -0,0 +1,24 @@ +# CCSDS + +## 概要 +C2A Core に実装された CCSDS (Consultative Committee for Space Data Systems) によって規定される宇宙データシステムの標準規格 Space Communications Protocols についてまとめる. +CCSDS 技術仕様文書は [ブルーブック(Blue Books):全85文書](https://stage.tksc.jaxa.jp/ccsds/docs/doc_blue.html) を参照すること. + + +## Space Packet Protocol +[`tlm_cmd/ccsds/space_packet_protocol`](/tlm_cmd/ccsds/space_packet_protocol/) に配置される. + +[Core/Communication.md#c2a-標準-space-packet-定義](./communication.md#c2a-標準-space-packet-定義) などを参照のこと. + + +## AOS Space Data Link Protocol / TC Space Data Link Protocol +[`tlm_cmd/ccsds/aos_space_data_link_protocol`](/tlm_cmd/ccsds/aos_space_data_link_protocol/), [`tlm_cmd/ccsds/tc_space_data_link_protocol`](/tlm_cmd/ccsds/tc_space_data_link_protocol/) に配置される. + +基本的には,地上局と通信する無線機 (STX や SRX) に接続される OBC (MOBC など) 向けのコードとなる. + +AOS Space Data Link Protocol や TC Space Data Link Protocol は,様々な設計パラメタがあるが,ここでのコードは,ある特定の設計パラメタにおける実装であることに注意すること. +したがって,現時点では汎用性の低いコードが配置されている. +(今後,適切にリファクタリングする予定.) + +また,本コードをコンパイル対象に加えると,少なくない RAM を static に確保してしまうため,デフォルトではコンパイル対象には含まれない. +コンパイル対象に含める場合は, FIXME: で設定すること. diff --git a/examples/mobc/CMakeLists.txt b/examples/mobc/CMakeLists.txt index 77f97b445..0583bd82d 100644 --- a/examples/mobc/CMakeLists.txt +++ b/examples/mobc/CMakeLists.txt @@ -20,6 +20,10 @@ option(C2A_BUILD_WITH_SILS_MOCKUP "Build C2A with SILS mockup for check undefine option(C2A_BUILD_FOR_SILS "Build C2A for SILS target" ON) +# core に同梱されている CCSDS の実装を使う +set(C2A_USE_CORE_CCSDS_AOS_SPACE_DATA_LINK_PROTOCOL ON) +set(C2A_USE_CORE_CCSDS_TC_SPACE_DATA_LINK_PROTOCOL ON) + if(C2A_BUILD_WITH_SILS_MOCKUP) set(C2A_BUILD_AS_CXX OFF) endif() diff --git a/examples/mobc/src/src_user/applications/component_service/csrv_gs.h b/examples/mobc/src/src_user/applications/component_service/csrv_gs.h index 594e2900a..e23135c1d 100644 --- a/examples/mobc/src/src_user/applications/component_service/csrv_gs.h +++ b/examples/mobc/src/src_user/applications/component_service/csrv_gs.h @@ -8,8 +8,8 @@ #include #include "../../component_driver/com/gs.h" -#include "../../tlm_cmd/ccsds/tcp_to_m_pdu.h" -#include "../../tlm_cmd/ccsds/aos_transfer_frame.h" +#include +#include #include /** diff --git a/examples/mobc/src/src_user/component_driver/com/gs.c b/examples/mobc/src/src_user/component_driver/com/gs.c index f5bac2c06..cd2f600b7 100644 --- a/examples/mobc/src/src_user/component_driver/com/gs.c +++ b/examples/mobc/src/src_user/component_driver/com/gs.c @@ -10,7 +10,7 @@ #include #include "../../hal/ccsds_user.h" -#include "../../tlm_cmd/ccsds/tc_transfer_frame.h" +#include #include #include #include diff --git a/examples/mobc/src/src_user/component_driver/com/gs.h b/examples/mobc/src/src_user/component_driver/com/gs.h index b35a0e2b1..c19d92565 100644 --- a/examples/mobc/src/src_user/component_driver/com/gs.h +++ b/examples/mobc/src/src_user/component_driver/com/gs.h @@ -10,7 +10,7 @@ #include #include #include "../../hal/ccsds_user.h" -#include "../../tlm_cmd/ccsds/aos_transfer_frame.h" +#include #include "gs_validate.h" #define GS_RX_HEADER_NUM (3) diff --git a/examples/mobc/src/src_user/component_driver/com/gs_validate.c b/examples/mobc/src/src_user/component_driver/com/gs_validate.c index 8a3e4201a..b14d4e804 100644 --- a/examples/mobc/src/src_user/component_driver/com/gs_validate.c +++ b/examples/mobc/src/src_user/component_driver/com/gs_validate.c @@ -5,7 +5,7 @@ */ #include "gs_validate.h" -#include "../../tlm_cmd/ccsds/tc_segment.h" +#include #include #define GS_RECEIVE_WINDOW (256) diff --git a/examples/mobc/src/src_user/component_driver/com/gs_validate.h b/examples/mobc/src/src_user/component_driver/com/gs_validate.h index d397bcfb6..2a664fff8 100644 --- a/examples/mobc/src/src_user/component_driver/com/gs_validate.h +++ b/examples/mobc/src/src_user/component_driver/com/gs_validate.h @@ -14,7 +14,7 @@ #include -#include "../../tlm_cmd/ccsds/tc_transfer_frame.h" +#include /** * @enum GS_VALIDATE_ERR diff --git a/examples/mobc/src/src_user/tlm_cmd/CMakeLists.txt b/examples/mobc/src/src_user/tlm_cmd/CMakeLists.txt index 0fbae1a07..cc0d7962a 100644 --- a/examples/mobc/src/src_user/tlm_cmd/CMakeLists.txt +++ b/examples/mobc/src/src_user/tlm_cmd/CMakeLists.txt @@ -14,11 +14,6 @@ set(C2A_SRCS normal_block_command_definition/nbc_start_hk_tlm.c normal_block_command_definition/nbc_respond_eh_for_test.c normal_block_command_definition/nbc_test_bcl.c - ccsds/aos_transfer_frame.c - ccsds/multiplexing_protocol_data_unit.c - ccsds/tc_transfer_frame.c - ccsds/tcp_to_m_pdu.c - ccsds/tc_segment.c ) if(C2A_BUILD_AS_CXX) diff --git a/examples/subobc/check_coding_rule.json b/examples/subobc/check_coding_rule.json index 5c9e1e795..5f191bb54 100644 --- a/examples/subobc/check_coding_rule.json +++ b/examples/subobc/check_coding_rule.json @@ -31,7 +31,12 @@ "CommonCmdPacket", "SpacePacket", "TlmSpacePacket", - "CmdSpacePacket" + "CmdSpacePacket", + "AosTransferFrame", + "MultiplexingProtocolDataUnit", + "TcpToMPdu", + "TcSegment", + "TcTransferFrame" ], "comment_additional_type" : [ "FIXME: TCP はもう存在しないはずなので,どこかで消す", diff --git a/tlm_cmd/ccsds/aos_space_data_link_protocol/CMakeLists.txt b/tlm_cmd/ccsds/aos_space_data_link_protocol/CMakeLists.txt new file mode 100644 index 000000000..a9b512b74 --- /dev/null +++ b/tlm_cmd/ccsds/aos_space_data_link_protocol/CMakeLists.txt @@ -0,0 +1,17 @@ +cmake_minimum_required(VERSION 3.13) + +project(C2A_CORE_CCSDS_AOS_SPACE_DATA_LINK_PROTOCOL) + +set(C2A_SRCS + aos_transfer_frame.c + multiplexing_protocol_data_unit.c + tcp_to_m_pdu.c +) + +if(C2A_BUILD_AS_CXX) + set_source_files_properties(${C2A_SRCS} PROPERTIES LANGUAGE CXX) # C++ +endif() + +add_library(${PROJECT_NAME} OBJECT ${C2A_SRCS}) + +include(${C2A_CORE_DIR}/common.cmake) diff --git a/examples/mobc/src/src_user/tlm_cmd/ccsds/aos_transfer_frame.c b/tlm_cmd/ccsds/aos_space_data_link_protocol/aos_transfer_frame.c similarity index 100% rename from examples/mobc/src/src_user/tlm_cmd/ccsds/aos_transfer_frame.c rename to tlm_cmd/ccsds/aos_space_data_link_protocol/aos_transfer_frame.c diff --git a/examples/mobc/src/src_user/tlm_cmd/ccsds/aos_transfer_frame.h b/tlm_cmd/ccsds/aos_space_data_link_protocol/aos_transfer_frame.h similarity index 100% rename from examples/mobc/src/src_user/tlm_cmd/ccsds/aos_transfer_frame.h rename to tlm_cmd/ccsds/aos_space_data_link_protocol/aos_transfer_frame.h diff --git a/examples/mobc/src/src_user/tlm_cmd/ccsds/multiplexing_protocol_data_unit.c b/tlm_cmd/ccsds/aos_space_data_link_protocol/multiplexing_protocol_data_unit.c similarity index 100% rename from examples/mobc/src/src_user/tlm_cmd/ccsds/multiplexing_protocol_data_unit.c rename to tlm_cmd/ccsds/aos_space_data_link_protocol/multiplexing_protocol_data_unit.c diff --git a/examples/mobc/src/src_user/tlm_cmd/ccsds/multiplexing_protocol_data_unit.h b/tlm_cmd/ccsds/aos_space_data_link_protocol/multiplexing_protocol_data_unit.h similarity index 100% rename from examples/mobc/src/src_user/tlm_cmd/ccsds/multiplexing_protocol_data_unit.h rename to tlm_cmd/ccsds/aos_space_data_link_protocol/multiplexing_protocol_data_unit.h diff --git a/examples/mobc/src/src_user/tlm_cmd/ccsds/tcp_to_m_pdu.c b/tlm_cmd/ccsds/aos_space_data_link_protocol/tcp_to_m_pdu.c similarity index 98% rename from examples/mobc/src/src_user/tlm_cmd/ccsds/tcp_to_m_pdu.c rename to tlm_cmd/ccsds/aos_space_data_link_protocol/tcp_to_m_pdu.c index 92ce180e8..83e7e79e7 100644 --- a/examples/mobc/src/src_user/tlm_cmd/ccsds/tcp_to_m_pdu.c +++ b/tlm_cmd/ccsds/aos_space_data_link_protocol/tcp_to_m_pdu.c @@ -7,7 +7,7 @@ #include "tcp_to_m_pdu.h" // FIXME: CTP ではなく TSP を使ってしまっている.できれば抽象化するべき -#include +#include "../space_packet_protocol/tlm_space_packet.h" void T2M_initialize(TcpToMPdu* tcp_to_m_pdu) { diff --git a/examples/mobc/src/src_user/tlm_cmd/ccsds/tcp_to_m_pdu.h b/tlm_cmd/ccsds/aos_space_data_link_protocol/tcp_to_m_pdu.h similarity index 93% rename from examples/mobc/src/src_user/tlm_cmd/ccsds/tcp_to_m_pdu.h rename to tlm_cmd/ccsds/aos_space_data_link_protocol/tcp_to_m_pdu.h index c0da712de..fc568710d 100644 --- a/examples/mobc/src/src_user/tlm_cmd/ccsds/tcp_to_m_pdu.h +++ b/tlm_cmd/ccsds/aos_space_data_link_protocol/tcp_to_m_pdu.h @@ -10,9 +10,9 @@ #include // for size_t -#include #include "multiplexing_protocol_data_unit.h" -#include +#include "../../packet_list.h" +#include "../../../system/time_manager/time_manager.h" /** * @enum T2M_ACK diff --git a/tlm_cmd/ccsds/tc_space_data_link_protocol/CMakeLists.txt b/tlm_cmd/ccsds/tc_space_data_link_protocol/CMakeLists.txt new file mode 100644 index 000000000..cb6894dcb --- /dev/null +++ b/tlm_cmd/ccsds/tc_space_data_link_protocol/CMakeLists.txt @@ -0,0 +1,16 @@ +cmake_minimum_required(VERSION 3.13) + +project(C2A_CORE_CCSDS_TC_SPACE_DATA_LINK_PROTOCOL) + +set(C2A_SRCS + tc_segment.c + tc_transfer_frame.c +) + +if(C2A_BUILD_AS_CXX) + set_source_files_properties(${C2A_SRCS} PROPERTIES LANGUAGE CXX) # C++ +endif() + +add_library(${PROJECT_NAME} OBJECT ${C2A_SRCS}) + +include(${C2A_CORE_DIR}/common.cmake) diff --git a/examples/mobc/src/src_user/tlm_cmd/ccsds/tc_segment.c b/tlm_cmd/ccsds/tc_space_data_link_protocol/tc_segment.c similarity index 100% rename from examples/mobc/src/src_user/tlm_cmd/ccsds/tc_segment.c rename to tlm_cmd/ccsds/tc_space_data_link_protocol/tc_segment.c diff --git a/examples/mobc/src/src_user/tlm_cmd/ccsds/tc_segment.h b/tlm_cmd/ccsds/tc_space_data_link_protocol/tc_segment.h similarity index 97% rename from examples/mobc/src/src_user/tlm_cmd/ccsds/tc_segment.h rename to tlm_cmd/ccsds/tc_space_data_link_protocol/tc_segment.h index f1861e889..7c57fa6f8 100644 --- a/examples/mobc/src/src_user/tlm_cmd/ccsds/tc_segment.h +++ b/tlm_cmd/ccsds/tc_space_data_link_protocol/tc_segment.h @@ -20,7 +20,7 @@ #define TC_SEGMENT_H_ #include -#include +#include "../space_packet_protocol/cmd_space_packet.h" #include #define TCS_HEADER_SIZE (1) diff --git a/examples/mobc/src/src_user/tlm_cmd/ccsds/tc_transfer_frame.c b/tlm_cmd/ccsds/tc_space_data_link_protocol/tc_transfer_frame.c similarity index 98% rename from examples/mobc/src/src_user/tlm_cmd/ccsds/tc_transfer_frame.c rename to tlm_cmd/ccsds/tc_space_data_link_protocol/tc_transfer_frame.c index 4c90be69b..a4646933c 100644 --- a/examples/mobc/src/src_user/tlm_cmd/ccsds/tc_transfer_frame.c +++ b/tlm_cmd/ccsds/tc_space_data_link_protocol/tc_transfer_frame.c @@ -6,7 +6,7 @@ #include "tc_transfer_frame.h" #include -#include +#include "../../../library/crc.h" TCTF_VER TCTF_get_ver(const TcTransferFrame* tctf) { diff --git a/examples/mobc/src/src_user/tlm_cmd/ccsds/tc_transfer_frame.h b/tlm_cmd/ccsds/tc_space_data_link_protocol/tc_transfer_frame.h similarity index 100% rename from examples/mobc/src/src_user/tlm_cmd/ccsds/tc_transfer_frame.h rename to tlm_cmd/ccsds/tc_space_data_link_protocol/tc_transfer_frame.h