Skip to content

Commit

Permalink
Merge pull request #214 from arkedge/feature/move_ccsds_to_core
Browse files Browse the repository at this point in the history
MOBC 用 CCSDS のコード(主にデータリンク層)を core に移植する
  • Loading branch information
meltingrabbit authored Dec 3, 2023
2 parents c179702 + 78e9d78 commit 941f294
Show file tree
Hide file tree
Showing 24 changed files with 119 additions and 17 deletions.
25 changes: 25 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 する
Expand All @@ -30,6 +34,27 @@
- `#include <src_core/tlm_cmd/ccsds/space_packet_typedef.h>` -> `#include <src_core/tlm_cmd/ccsds/space_packet_protocol/space_packet_typedef.h>`
- `#include <src_core/tlm_cmd/ccsds/tlm_space_packet.h>` -> `#include <src_core/tlm_cmd/ccsds/space_packet_protocol/tlm_space_packet.h>`
- `#include <src_core/tlm_cmd/ccsds/cmd_space_packet.h>` -> `#include <src_core/tlm_cmd/ccsds/space_packet_protocol/cmd_space_packet.h>`
- [#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)

Expand Down
15 changes: 15 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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})
Expand Down Expand Up @@ -99,4 +104,14 @@ if(C2A_USE_ALL_CORE_LIB)
target_sources(${PROJECT_NAME} PUBLIC $<TARGET_OBJECTS:C2A_CORE_LIB>)
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 $<TARGET_OBJECTS:C2A_CORE_CCSDS_AOS_SPACE_DATA_LINK_PROTOCOL>)
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 $<TARGET_OBJECTS:C2A_CORE_CCSDS_TC_SPACE_DATA_LINK_PROTOCOL>)
endif()

include(common.cmake)
1 change: 1 addition & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
24 changes: 24 additions & 0 deletions docs/core/ccsds.md
Original file line number Diff line number Diff line change
@@ -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: で設定すること.
4 changes: 4 additions & 0 deletions examples/mobc/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
#include <stdint.h>

#include "../../component_driver/com/gs.h"
#include "../../tlm_cmd/ccsds/tcp_to_m_pdu.h"
#include "../../tlm_cmd/ccsds/aos_transfer_frame.h"
#include <src_core/tlm_cmd/ccsds/aos_space_data_link_protocol/tcp_to_m_pdu.h>
#include <src_core/tlm_cmd/ccsds/aos_space_data_link_protocol/aos_transfer_frame.h>
#include <src_core/system/application_manager/app_info.h>

/**
Expand Down
2 changes: 1 addition & 1 deletion examples/mobc/src/src_user/component_driver/com/gs.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#include <stdint.h>

#include "../../hal/ccsds_user.h"
#include "../../tlm_cmd/ccsds/tc_transfer_frame.h"
#include <src_core/tlm_cmd/ccsds/tc_space_data_link_protocol/tc_transfer_frame.h>
#include <src_core/component_driver/driver_super.h>
#include <src_core/tlm_cmd/packet_handler.h>
#include <src_core/tlm_cmd/ccsds/space_packet_protocol/space_packet_typedef.h>
Expand Down
2 changes: 1 addition & 1 deletion examples/mobc/src/src_user/component_driver/com/gs.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#include <src_core/hal/uart.h>
#include <src_core/hal/ccsds.h>
#include "../../hal/ccsds_user.h"
#include "../../tlm_cmd/ccsds/aos_transfer_frame.h"
#include <src_core/tlm_cmd/ccsds/aos_space_data_link_protocol/aos_transfer_frame.h>
#include "gs_validate.h"

#define GS_RX_HEADER_NUM (3)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*/

#include "gs_validate.h"
#include "../../tlm_cmd/ccsds/tc_segment.h"
#include <src_core/tlm_cmd/ccsds/tc_space_data_link_protocol/tc_segment.h>
#include <src_core/tlm_cmd/ccsds/space_packet_protocol/space_packet_typedef.h>

#define GS_RECEIVE_WINDOW (256)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

#include <stdint.h>

#include "../../tlm_cmd/ccsds/tc_transfer_frame.h"
#include <src_core/tlm_cmd/ccsds/tc_space_data_link_protocol/tc_transfer_frame.h>

/**
* @enum GS_VALIDATE_ERR
Expand Down
5 changes: 0 additions & 5 deletions examples/mobc/src/src_user/tlm_cmd/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
7 changes: 6 additions & 1 deletion examples/subobc/check_coding_rule.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,12 @@
"CommonCmdPacket",
"SpacePacket",
"TlmSpacePacket",
"CmdSpacePacket"
"CmdSpacePacket",
"AosTransferFrame",
"MultiplexingProtocolDataUnit",
"TcpToMPdu",
"TcSegment",
"TcTransferFrame"
],
"comment_additional_type" : [
"FIXME: TCP はもう存在しないはずなので,どこかで消す",
Expand Down
17 changes: 17 additions & 0 deletions tlm_cmd/ccsds/aos_space_data_link_protocol/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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)
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

#include "tcp_to_m_pdu.h"
// FIXME: CTP ではなく TSP を使ってしまっている.できれば抽象化するべき
#include <src_core/tlm_cmd/ccsds/space_packet_protocol/tlm_space_packet.h>
#include "../space_packet_protocol/tlm_space_packet.h"

void T2M_initialize(TcpToMPdu* tcp_to_m_pdu)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@

#include <stddef.h> // for size_t

#include <src_core/tlm_cmd/packet_list.h>
#include "multiplexing_protocol_data_unit.h"
#include <src_core/system/time_manager/time_manager.h>
#include "../../packet_list.h"
#include "../../../system/time_manager/time_manager.h"

/**
* @enum T2M_ACK
Expand Down
16 changes: 16 additions & 0 deletions tlm_cmd/ccsds/tc_space_data_link_protocol/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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)
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
#define TC_SEGMENT_H_

#include <stdint.h>
#include <src_core/tlm_cmd/ccsds/space_packet_protocol/cmd_space_packet.h>
#include "../space_packet_protocol/cmd_space_packet.h"
#include <src_user/settings/tlm_cmd/ccsds/space_packet_typedef_params.h>

#define TCS_HEADER_SIZE (1)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#include "tc_transfer_frame.h"

#include <string.h>
#include <src_core/library/crc.h>
#include "../../../library/crc.h"

TCTF_VER TCTF_get_ver(const TcTransferFrame* tctf)
{
Expand Down

0 comments on commit 941f294

Please sign in to comment.