diff --git a/Applications/anomaly_handler.c b/Applications/anomaly_handler.c index fcee59c85..f04ecb95c 100644 --- a/Applications/anomaly_handler.c +++ b/Applications/anomaly_handler.c @@ -5,7 +5,7 @@ #include #include "../System/TimeManager/time_manager.h" #include "../Library/endian_memcpy.h" -#include "../TlmCmd/common_tlm_cmd_packet_util.h" +#include "../TlmCmd/common_cmd_packet_util.h" #include "timeline_command_dispatcher.h" // #include "../anomaly_group.h" // #include "../../TlmCmd/block_command_definitions.h" diff --git a/Applications/divided_cmd_utility.c b/Applications/divided_cmd_utility.c index 50d94ca84..127c44e78 100644 --- a/Applications/divided_cmd_utility.c +++ b/Applications/divided_cmd_utility.c @@ -13,7 +13,7 @@ */ #include "divided_cmd_utility.h" #include "../TlmCmd/packet_handler.h" -#include "../TlmCmd/common_tlm_cmd_packet_util.h" +#include "../TlmCmd/common_cmd_packet_util.h" #include "../System/TimeManager/time_manager.h" #include "../System/EventManager/event_logger.h" @@ -205,14 +205,14 @@ DCU_STATUS DCU_check_in(CMD_CODE cmd_code, uint16_t* exec_counter) DCU_ACK DCU_register_next(CMD_CODE cmd_code, const uint8_t* param, uint16_t len) { uint8_t idx; - CTCP_UTIL_ACK ret; + CCP_UTIL_ACK ret; DCU_move_to_front_in_log_(cmd_code); idx = divided_cmd_utility_.exec_log_order[0]; divided_cmd_utility_.exec_logs[idx].status = DCU_STATUS_PROGRESS; ret = CCP_form_rtc(&DCU_packet_, cmd_code, param, len); - if (ret != CTCP_UTIL_ACK_OK) return DCU_ACK_ERR; + if (ret != CCP_UTIL_ACK_OK) return DCU_ACK_ERR; if (PH_analyze_packet(&DCU_packet_) != PH_REGISTERED) { return DCU_ACK_ERR; diff --git a/Applications/memory_dump.c b/Applications/memory_dump.c index 9d937477b..644573614 100644 --- a/Applications/memory_dump.c +++ b/Applications/memory_dump.c @@ -375,7 +375,7 @@ static void MEM_setup_header_(TCP* packet, uint8_t* data; // TCPacketヘッダを設定 - TCP_TLM_setup_primary_hdr(packet, TCP_APID_DUMP_TLM, (uint16_t)(data_len + 12)); + TCP_TLM_setup_primary_hdr(packet, APID_DUMP_TLM, (uint16_t)(data_len + 12)); TCP_TLM_set_ti(packet, (uint32_t)( TMGR_get_master_total_cycle() )); TCP_TLM_set_category(packet, category); // パラメータによる指定 TCP_TLM_set_packet_id(packet, (uint8_t)MEM_TLM_ID); diff --git a/Applications/telemetry_manager.c b/Applications/telemetry_manager.c index 342699792..e105ba9e7 100644 --- a/Applications/telemetry_manager.c +++ b/Applications/telemetry_manager.c @@ -317,19 +317,19 @@ static TLM_MGR_ERR_CODE TLM_MGR_register_generate_tlm_(TLM_MGR_RegisterInfo* reg bct_id_t bc_id = telemetry_manager_.bc_info[bc_info_idx].bc_id; uint8_t bc_cmd_pos = register_info->tlm_register_pointer_to_bc_cmd_idx; BCT_Pos bc_register_pos; - CTCP_UTIL_ACK ctcp_util_ack; + CCP_UTIL_ACK ccp_util_ack; BCT_ACK bct_ack; if (bc_cmd_pos >= TLM_MGR_MAX_TLM_NUM_PER_BC) return TLM_MGR_ERR_CODE_CMD_FULL; BCT_make_pos(&bc_register_pos, bc_id, bc_cmd_pos); - ctcp_util_ack = CCP_form_tlc(&TLM_MGR_packet_, - (cycle_t)bc_cmd_pos, - Cmd_CODE_GENERATE_TLM, - param, - CA_get_cmd_param_min_len(Cmd_CODE_GENERATE_TLM)); - if (ctcp_util_ack != CTCP_UTIL_ACK_OK) return TLM_MGR_ERR_CODE_OTHER_ERR; + ccp_util_ack = CCP_form_tlc(&TLM_MGR_packet_, + (cycle_t)bc_cmd_pos, + Cmd_CODE_GENERATE_TLM, + param, + CA_get_cmd_param_min_len(Cmd_CODE_GENERATE_TLM)); + if (ccp_util_ack != CCP_UTIL_ACK_OK) return TLM_MGR_ERR_CODE_OTHER_ERR; // すでに NOP で埋められており,かつ activate 済なので,直接 BCT にコマンドを挿入できる. bct_ack = BCT_overwrite_cmd(&bc_register_pos, &TLM_MGR_packet_); diff --git a/Applications/telemetry_manager.h b/Applications/telemetry_manager.h index 39aa66d91..a660dd3fb 100644 --- a/Applications/telemetry_manager.h +++ b/Applications/telemetry_manager.h @@ -8,7 +8,7 @@ #include "../System/ApplicationManager/app_info.h" #include "../TlmCmd/common_tlm_cmd_packet.h" -#include "../TlmCmd/common_tlm_cmd_packet_util.h" +#include "../TlmCmd/common_cmd_packet_util.h" #include "../TlmCmd/block_command_table.h" diff --git a/CMakeLists.txt b/CMakeLists.txt index fd3c0ddf1..6886cd837 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -29,7 +29,7 @@ set(C2A_SRCS TlmCmd/block_command_executor.c TlmCmd/command_analyze.c TlmCmd/command_dispatcher.c - TlmCmd/common_tlm_cmd_packet_util.c + TlmCmd/common_cmd_packet_util.c TlmCmd/packet_handler.c TlmCmd/packet_list.c TlmCmd/telemetry_frame.c diff --git a/Docs/Core/communication.md b/Docs/Core/communication.md new file mode 100644 index 000000000..f4778acbe --- /dev/null +++ b/Docs/Core/communication.md @@ -0,0 +1,30 @@ +# Communication + +## 概要 +通信関連,ネットワーク関連などをまとめる. + +## C2A 内部を流れるパケットについて +C2A 内部を流れるパケットは以下の 3 つである. +- `CommonTlmCmdPacket` + - CTCP + - テレコマを区別しないパケット + - CCSDS で規定される Space Packet に相当する +- `CommonTlmPacket` + - CTP + - CTCP のうち,テレメトリパケットに限定したもの +- `CommonCmdPacket` + - CCP + - CTCP のうち,コマンドパケットに限定したもの + +これらのパケットは,すべてユーザー定義であるが, C2A 標準を,ここ (TBA) で定義する. +基本的にはこれを用いることを想定している. + +FIXME: 2022/01/24現在 +現在, CTCP 大改修中 (https://github.com/ut-issl/c2a-core/issues/205) であり,現時点では,すべてのパケットの実体は TCP である. +近いうちに整備される予定. + +## C2A 標準 Space Packet 定義 +TBA + +## CCSDS 準拠状況 +TBA diff --git a/Docs/README.md b/Docs/README.md index 51d474aa1..d1b8d280f 100644 --- a/Docs/README.md +++ b/Docs/README.md @@ -35,6 +35,7 @@ C2A に関する説明の棲み分けは,次のようになっています. 1. How to add a application 1. Core Layer 1. Overview + 1. [Communication](./Core/communication.md) 1. [Tips](./Core/tips.md) 1. Driver 1. [Overview](./Driver/overview.md) diff --git a/Examples/minimum_user_for_s2e/src/src_user/Drivers/Com/gs_validate.c b/Examples/minimum_user_for_s2e/src/src_user/Drivers/Com/gs_validate.c index 0ab712637..d21501098 100644 --- a/Examples/minimum_user_for_s2e/src/src_user/Drivers/Com/gs_validate.c +++ b/Examples/minimum_user_for_s2e/src/src_user/Drivers/Com/gs_validate.c @@ -117,7 +117,7 @@ static GS_VALIDATE_ERR GS_check_tcs_headers_(const TCS* tc_segment) static GS_VALIDATE_ERR GS_check_tcp_headers_(const TCP* tc_packet) { - TCP_APID apid; + APID apid; if (TCP_get_ver(tc_packet) != TCP_VER_1) return GS_VALIDATE_ERR_TCP_VER; if (TCP_get_2nd_hdr_flag(tc_packet) != TCP_2ND_HDR_PRESENT) @@ -127,11 +127,11 @@ static GS_VALIDATE_ERR GS_check_tcp_headers_(const TCP* tc_packet) } apid = TCP_get_apid(tc_packet); - if ( !( apid == TCP_APID_MOBC_CMD - || apid == TCP_APID_AOBC_CMD - || apid == TCP_APID_TOBC_CMD ) ) + if ( !( apid == APID_MOBC_CMD + || apid == APID_AOBC_CMD + || apid == APID_TOBC_CMD ) ) { - return GS_VALIDATE_ERR_TCP_APID; + return GS_VALIDATE_ERR_APID; } return GS_VALIDATE_ERR_OK; diff --git a/Examples/minimum_user_for_s2e/src/src_user/Drivers/Com/gs_validate.h b/Examples/minimum_user_for_s2e/src/src_user/Drivers/Com/gs_validate.h index c348ed061..e76a0e172 100644 --- a/Examples/minimum_user_for_s2e/src/src_user/Drivers/Com/gs_validate.h +++ b/Examples/minimum_user_for_s2e/src/src_user/Drivers/Com/gs_validate.h @@ -24,7 +24,7 @@ typedef enum GS_VALIDATE_ERR_TCS_SEQ_FLAG, GS_VALIDATE_ERR_TCP_VER, GS_VALIDATE_ERR_TCP_2ND_HDR_FLAG, - GS_VALIDATE_ERR_TCP_APID, + GS_VALIDATE_ERR_APID, GS_VALIDATE_ERR_TCP_TYPE_IS_NOT_CMD, GS_VALIDATE_ERR_TCP_SEQ_IS_NOT_SINGLE, GS_VALIDATE_ERR_FECW_MISSMATCH, diff --git a/Examples/minimum_user_for_s2e/src/src_user/Settings/Modes/Transitions/SequenceItems.c b/Examples/minimum_user_for_s2e/src/src_user/Settings/Modes/Transitions/SequenceItems.c index eb12563e3..f3ec377d8 100644 --- a/Examples/minimum_user_for_s2e/src/src_user/Settings/Modes/Transitions/SequenceItems.c +++ b/Examples/minimum_user_for_s2e/src/src_user/Settings/Modes/Transitions/SequenceItems.c @@ -3,7 +3,7 @@ #include "../../../TlmCmd/block_command_definitions.h" #include #include -#include +#include #include "../../../Settings/AnomalyLogger/anomaly_group.h" #include "../mode_definitions.h" diff --git a/Examples/minimum_user_for_s2e/src/src_user/Settings/TlmCmd/Ccsds/apid_define.h b/Examples/minimum_user_for_s2e/src/src_user/Settings/TlmCmd/Ccsds/apid_define.h new file mode 100644 index 000000000..bc919ca88 --- /dev/null +++ b/Examples/minimum_user_for_s2e/src/src_user/Settings/TlmCmd/Ccsds/apid_define.h @@ -0,0 +1,31 @@ +/** + * @file + * @brief CCSDS の APID を定義する + * @note common_tlm_cmd_packet.h などから include されることを前提 + */ +#ifndef APID_DEFINE_H_ +#define APID_DEFINE_H_ + +#undef TCP_MAX_LEN + +#define TCP_MAX_LEN (432u) + +/** + * @enum APID + * @brief Application Process ID + * @note 11bit + */ +typedef enum +{ + APID_MOBC_CMD = 0x210, // 01000010000b: + APID_AOBC_CMD = 0x211, // 01000010001b: + APID_TOBC_CMD = 0x212, // 01000010010b: + APID_TCAL_TLM = 0x410, // 10000010000b: APID for TIME CARIBLATION TLM + APID_MIS_TLM = 0x510, // 10100010000b: APID for MIS TLM + APID_DUMP_TLM = 0x710, // 11100010000b: APID for DUMP TLM + APID_FILL_PKT = 0x7ff, // 11111111111b: APID for FILL PACKET + APID_UNKNOWN +} APID; + + +#endif diff --git a/Examples/minimum_user_for_s2e/src/src_user/Settings/TlmCmd/Ccsds/tcpacket_params.h b/Examples/minimum_user_for_s2e/src/src_user/Settings/TlmCmd/Ccsds/tcpacket_params.h index ec03a9b4e..3da6d6004 100644 --- a/Examples/minimum_user_for_s2e/src/src_user/Settings/TlmCmd/Ccsds/tcpacket_params.h +++ b/Examples/minimum_user_for_s2e/src/src_user/Settings/TlmCmd/Ccsds/tcpacket_params.h @@ -10,25 +10,25 @@ #define TCP_MAX_LEN (432u) -// FIXME: #206 を実装する際は,これは params.h ではなく define.h で定義すべき -/** - * @enum TCP_APID - * @brief Application Process ID - * @note GSTOS の蓄積データの拡張子につく数字 - * @note 11bit - * @note CTCP_DEST_ID として typedef する - */ -typedef enum -{ - TCP_APID_MOBC_CMD = 0x210, // 01000010000b: - TCP_APID_AOBC_CMD = 0x211, // 01000010001b: - TCP_APID_TOBC_CMD = 0x212, // 01000010010b: - TCP_APID_TCAL_TLM = 0x410, // 10000010000b: APID for TIME CARIBLATION TLM - TCP_APID_MIS_TLM = 0x510, // 10100010000b: APID for MIS TLM - TCP_APID_DUMP_TLM = 0x710, // 11100010000b: APID for DUMP TLM - TCP_APID_FILL_PKT = 0x7ff, // 11111111111b: APID for FILL PACKET - TCP_APID_UNKNOWN -} TCP_APID; +// // FIXME: #206 を実装する際は,これは params.h ではなく define.h で定義すべき +// /** +// * @enum TCP_APID +// * @brief Application Process ID +// * @note GSTOS の蓄積データの拡張子につく数字 +// * @note 11bit +// * @note CTCP_DEST_ID として typedef する +// */ +// typedef enum +// { +// TCP_APID_MOBC_CMD = 0x210, // 01000010000b: +// TCP_APID_AOBC_CMD = 0x211, // 01000010001b: +// TCP_APID_TOBC_CMD = 0x212, // 01000010010b: +// TCP_APID_TCAL_TLM = 0x410, // 10000010000b: APID for TIME CARIBLATION TLM +// TCP_APID_MIS_TLM = 0x510, // 10100010000b: APID for MIS TLM +// TCP_APID_DUMP_TLM = 0x710, // 11100010000b: APID for DUMP TLM +// TCP_APID_FILL_PKT = 0x7ff, // 11111111111b: APID for FILL PACKET +// TCP_APID_UNKNOWN +// } TCP_APID; /** * @enum TCP_CMD_DEST_TYPE diff --git a/Examples/minimum_user_for_s2e/src/src_user/Settings/TlmCmd/DataBase/TLM_DB/SAMPLE_MOBC_TLM_DB_GS.csv b/Examples/minimum_user_for_s2e/src/src_user/Settings/TlmCmd/DataBase/TLM_DB/SAMPLE_MOBC_TLM_DB_GS.csv index dccb94c10..1c3dfd6bb 100644 --- a/Examples/minimum_user_for_s2e/src/src_user/Settings/TlmCmd/DataBase/TLM_DB/SAMPLE_MOBC_TLM_DB_GS.csv +++ b/Examples/minimum_user_for_s2e/src/src_user/Settings/TlmCmd/DataBase/TLM_DB/SAMPLE_MOBC_TLM_DB_GS.csv @@ -28,7 +28,7 @@ Comment,TLM Entry,Onboard Software Info.,,Extraction Info.,,,,Conversion Info.,, ,CCSDS_AD_REC_STATUS,uint8_t,(uint8_t)gs_driver->info[0].ad_rec_status,PACKET,=F27+INT((G27+H27)/8),=MOD((G27+H27)@@8),=IF(OR(EXACT(C28@@"uint8_t")@@EXACT(C28@@"int8_t"))@@8@@IF(OR(EXACT(C28@@"uint16_t")@@EXACT(C28@@"int16_t"))@@16@@IF(OR(EXACT(C28@@"uint32_t")@@EXACT(C28@@"int32_t")@@EXACT(C28@@"float"))@@32@@IF(EXACT(C28@@"double")@@64)))),STATUS,,,,,,,0=OK:G@@1=ERROR:R,, ,CCSDS_BC_REC_STATUS,uint8_t,(uint8_t)gs_driver->info[0].bc_rec_status,PACKET,=F28+INT((G28+H28)/8),=MOD((G28+H28)@@8),=IF(OR(EXACT(C29@@"uint8_t")@@EXACT(C29@@"int8_t"))@@8@@IF(OR(EXACT(C29@@"uint16_t")@@EXACT(C29@@"int16_t"))@@16@@IF(OR(EXACT(C29@@"uint32_t")@@EXACT(C29@@"int32_t")@@EXACT(C29@@"float"))@@32@@IF(EXACT(C29@@"double")@@64)))),STATUS,,,,,,,0=OK:G@@1=ERROR:R,, ,CCSDS_BD_REC_STATUS,uint8_t,(uint8_t)gs_driver->info[0].bd_rec_status,PACKET,=F29+INT((G29+H29)/8),=MOD((G29+H29)@@8),=IF(OR(EXACT(C30@@"uint8_t")@@EXACT(C30@@"int8_t"))@@8@@IF(OR(EXACT(C30@@"uint16_t")@@EXACT(C30@@"int16_t"))@@16@@IF(OR(EXACT(C30@@"uint32_t")@@EXACT(C30@@"int32_t")@@EXACT(C30@@"float"))@@32@@IF(EXACT(C30@@"double")@@64)))),STATUS,,,,,,,0=OK:G@@1=ERROR:R,, -,CCSDS_TCFRAME_VALIDATE_STATUS,uint8_t,(uint8_t)(gs_driver->info[0].tc_frame_validate_status),PACKET,=F30+INT((G30+H30)/8),=MOD((G30+H30)@@8),=IF(OR(EXACT(C31@@"uint8_t")@@EXACT(C31@@"int8_t"))@@8@@IF(OR(EXACT(C31@@"uint16_t")@@EXACT(C31@@"int16_t"))@@16@@IF(OR(EXACT(C31@@"uint32_t")@@EXACT(C31@@"int32_t")@@EXACT(C31@@"float"))@@32@@IF(EXACT(C31@@"double")@@64)))),STATUS,,,,,,,0=SUCCESS:G@@ 1=TCF_VER:R@@ 2=TCF_SCID:R@@ 3=TCF_VCID:R@@ 4=TCF_TYPE:R@@ 5=LOCKOUT:R@@ 6=TCF_SEQ_FLAG:R@@ 7=TCP_VER:R@@ 8=TCP_2ND_HDR_FLAG:R@@ 9=TCP_APID:R@@ 10=TCP_TYPE_IS_NOT_CMD:R@@ 11=TCP_SEQ_IS_NOTE_SINGLE:R@@ 12=FECW_MISSMATCH:R@@ 13=FARM1_PWA:R@@ 14=FARM1_NWA:R@@ 15=FARM1_LOCKOUT_AREA:R@@ 16=FARM1_SAME_NUMBER:R@@ 17=INVALID_BC_CMD:R,, +,CCSDS_TCFRAME_VALIDATE_STATUS,uint8_t,(uint8_t)(gs_driver->info[0].tc_frame_validate_status),PACKET,=F30+INT((G30+H30)/8),=MOD((G30+H30)@@8),=IF(OR(EXACT(C31@@"uint8_t")@@EXACT(C31@@"int8_t"))@@8@@IF(OR(EXACT(C31@@"uint16_t")@@EXACT(C31@@"int16_t"))@@16@@IF(OR(EXACT(C31@@"uint32_t")@@EXACT(C31@@"int32_t")@@EXACT(C31@@"float"))@@32@@IF(EXACT(C31@@"double")@@64)))),STATUS,,,,,,,0=SUCCESS:G@@ 1=TCF_VER:R@@ 2=TCF_SCID:R@@ 3=TCF_VCID:R@@ 4=TCF_TYPE:R@@ 5=LOCKOUT:R@@ 6=TCF_SEQ_FLAG:R@@ 7=TCP_VER:R@@ 8=TCP_2ND_HDR_FLAG:R@@ 9=APID:R@@ 10=TCP_TYPE_IS_NOT_CMD:R@@ 11=TCP_SEQ_IS_NOTE_SINGLE:R@@ 12=FECW_MISSMATCH:R@@ 13=FARM1_PWA:R@@ 14=FARM1_NWA:R@@ 15=FARM1_LOCKOUT_AREA:R@@ 16=FARM1_SAME_NUMBER:R@@ 17=INVALID_BC_CMD:R,, ,CCSDS_RET_FROM_IF_RX,int32_t,(int32_t)gs_driver->info[0].ret_from_if_rx,PACKET,=F31+INT((G31+H31)/8),=MOD((G31+H31)@@8),=IF(OR(EXACT(C32@@"uint8_t")@@EXACT(C32@@"int8_t"))@@8@@IF(OR(EXACT(C32@@"uint16_t")@@EXACT(C32@@"int16_t"))@@16@@IF(OR(EXACT(C32@@"uint32_t")@@EXACT(C32@@"int32_t")@@EXACT(C32@@"float"))@@32@@IF(EXACT(C32@@"double")@@64)))),NONE,,,,,,,,, ,CCSDS_LAST_REC_TIME,uint32_t,(uint32_t)gs_driver->info[0].last_rec_time,PACKET,=F32+INT((G32+H32)/8),=MOD((G32+H32)@@8),=IF(OR(EXACT(C33@@"uint8_t")@@EXACT(C33@@"int8_t"))@@8@@IF(OR(EXACT(C33@@"uint16_t")@@EXACT(C33@@"int16_t"))@@16@@IF(OR(EXACT(C33@@"uint32_t")@@EXACT(C33@@"int32_t")@@EXACT(C33@@"float"))@@32@@IF(EXACT(C33@@"double")@@64)))),NONE,,,,,,,,, ,CCSDS_CMD_ACK,uint8_t,(uint8_t)gs_driver->info[0].cmd_ack,PACKET,=F33+INT((G33+H33)/8),=MOD((G33+H33)@@8),=IF(OR(EXACT(C34@@"uint8_t")@@EXACT(C34@@"int8_t"))@@8@@IF(OR(EXACT(C34@@"uint16_t")@@EXACT(C34@@"int16_t"))@@16@@IF(OR(EXACT(C34@@"uint32_t")@@EXACT(C34@@"int32_t")@@EXACT(C34@@"float"))@@32@@IF(EXACT(C34@@"double")@@64)))),STATUS,,,,,,,0=SUCCESS:G@@ 1=RT_ACPT:G@@ 2=RT_FWD:G@@ 3=LENGTH:R@@ 4=CRC:R@@ 5=TO_ID:R@@ 6=TC_DISC:R@@ 7=CM_TYPE:R@@ 8=LST_FUL:R@@ 9=TL_ACPT:G@@ 10=TL_PAST:R@@ 11=TL_EXST:R@@ 12=TL_NEXE:R@@ 13=TL_NFND:R@@ 14=BL_ACPT:G@@ 15=BL_BLK#:R@@ 16=BL_CMD#:R@@ 17=BL_ISOR:R@@ 18=BL_INAC:R@@ 19=BL_COMB:R@@ 20=TLM_DST:R@@ 21=UNKNOWN:R,, @@ -41,7 +41,7 @@ Comment,TLM Entry,Onboard Software Info.,,Extraction Info.,,,,Conversion Info.,, ,UART_AD_REC_STATUS,uint8_t,(uint8_t)gs_driver->info[1].ad_rec_status,PACKET,=F40+INT((G40+H40)/8),=MOD((G40+H40)@@8),=IF(OR(EXACT(C41@@"uint8_t")@@EXACT(C41@@"int8_t"))@@8@@IF(OR(EXACT(C41@@"uint16_t")@@EXACT(C41@@"int16_t"))@@16@@IF(OR(EXACT(C41@@"uint32_t")@@EXACT(C41@@"int32_t")@@EXACT(C41@@"float"))@@32@@IF(EXACT(C41@@"double")@@64)))),STATUS,,,,,,,0=OK:G@@1=ERROR:R,, ,UART_BC_REC_STATUS,uint8_t,(uint8_t)gs_driver->info[1].bc_rec_status,PACKET,=F41+INT((G41+H41)/8),=MOD((G41+H41)@@8),=IF(OR(EXACT(C42@@"uint8_t")@@EXACT(C42@@"int8_t"))@@8@@IF(OR(EXACT(C42@@"uint16_t")@@EXACT(C42@@"int16_t"))@@16@@IF(OR(EXACT(C42@@"uint32_t")@@EXACT(C42@@"int32_t")@@EXACT(C42@@"float"))@@32@@IF(EXACT(C42@@"double")@@64)))),STATUS,,,,,,,0=OK:G@@1=ERROR:R,, ,UART_BD_REC_STATUS,uint8_t,(uint8_t)gs_driver->info[1].bd_rec_status,PACKET,=F42+INT((G42+H42)/8),=MOD((G42+H42)@@8),=IF(OR(EXACT(C43@@"uint8_t")@@EXACT(C43@@"int8_t"))@@8@@IF(OR(EXACT(C43@@"uint16_t")@@EXACT(C43@@"int16_t"))@@16@@IF(OR(EXACT(C43@@"uint32_t")@@EXACT(C43@@"int32_t")@@EXACT(C43@@"float"))@@32@@IF(EXACT(C43@@"double")@@64)))),STATUS,,,,,,,0=OK:G@@1=ERROR:R,, -,UART_TCFRAME_VALIDATE_STATUS,uint8_t,(uint8_t)(gs_driver->info[1].tc_frame_validate_status),PACKET,=F43+INT((G43+H43)/8),=MOD((G43+H43)@@8),=IF(OR(EXACT(C44@@"uint8_t")@@EXACT(C44@@"int8_t"))@@8@@IF(OR(EXACT(C44@@"uint16_t")@@EXACT(C44@@"int16_t"))@@16@@IF(OR(EXACT(C44@@"uint32_t")@@EXACT(C44@@"int32_t")@@EXACT(C44@@"float"))@@32@@IF(EXACT(C44@@"double")@@64)))),STATUS,,,,,,,0=SUCCESS:G@@ 1=TCF_VER:R@@ 2=TCF_SCID:R@@ 3=TCF_VCID:R@@ 4=TCF_TYPE:R@@ 5=LOCKOUT:R@@ 6=TCF_SEQ_FLAG:R@@ 7=TCP_VER:R@@ 8=TCP_2ND_HDR_FLAG:R@@ 9=TCP_APID:R@@ 10=TCP_TYPE_IS_NOT_CMD:R@@ 11=TCP_SEQ_IS_NOTE_SINGLE:R@@ 12=FECW_MISSMATCH:R@@ 13=FARM1_PWA:R@@ 14=FARM1_NWA:R@@ 15=FARM1_LOCKOUT_AREA:R@@ 16=FARM1_SAME_NUMBER:R@@ 17=INVALID_BC_CMD:R,, +,UART_TCFRAME_VALIDATE_STATUS,uint8_t,(uint8_t)(gs_driver->info[1].tc_frame_validate_status),PACKET,=F43+INT((G43+H43)/8),=MOD((G43+H43)@@8),=IF(OR(EXACT(C44@@"uint8_t")@@EXACT(C44@@"int8_t"))@@8@@IF(OR(EXACT(C44@@"uint16_t")@@EXACT(C44@@"int16_t"))@@16@@IF(OR(EXACT(C44@@"uint32_t")@@EXACT(C44@@"int32_t")@@EXACT(C44@@"float"))@@32@@IF(EXACT(C44@@"double")@@64)))),STATUS,,,,,,,0=SUCCESS:G@@ 1=TCF_VER:R@@ 2=TCF_SCID:R@@ 3=TCF_VCID:R@@ 4=TCF_TYPE:R@@ 5=LOCKOUT:R@@ 6=TCF_SEQ_FLAG:R@@ 7=TCP_VER:R@@ 8=TCP_2ND_HDR_FLAG:R@@ 9=APID:R@@ 10=TCP_TYPE_IS_NOT_CMD:R@@ 11=TCP_SEQ_IS_NOTE_SINGLE:R@@ 12=FECW_MISSMATCH:R@@ 13=FARM1_PWA:R@@ 14=FARM1_NWA:R@@ 15=FARM1_LOCKOUT_AREA:R@@ 16=FARM1_SAME_NUMBER:R@@ 17=INVALID_BC_CMD:R,, ,UART_RET_FROM_IF_RX,int32_t,(int32_t)gs_driver->info[1].ret_from_if_rx,PACKET,=F44+INT((G44+H44)/8),=MOD((G44+H44)@@8),=IF(OR(EXACT(C45@@"uint8_t")@@EXACT(C45@@"int8_t"))@@8@@IF(OR(EXACT(C45@@"uint16_t")@@EXACT(C45@@"int16_t"))@@16@@IF(OR(EXACT(C45@@"uint32_t")@@EXACT(C45@@"int32_t")@@EXACT(C45@@"float"))@@32@@IF(EXACT(C45@@"double")@@64)))),NONE,,,,,,,,, ,UART_LAST_REC_TIME,uint32_t,(uint32_t)gs_driver->info[1].last_rec_time,PACKET,=F45+INT((G45+H45)/8),=MOD((G45+H45)@@8),=IF(OR(EXACT(C46@@"uint8_t")@@EXACT(C46@@"int8_t"))@@8@@IF(OR(EXACT(C46@@"uint16_t")@@EXACT(C46@@"int16_t"))@@16@@IF(OR(EXACT(C46@@"uint32_t")@@EXACT(C46@@"int32_t")@@EXACT(C46@@"float"))@@32@@IF(EXACT(C46@@"double")@@64)))),NONE,,,,,,,,, ,UART_CMD_ACK,uint8_t,(uint8_t)gs_driver->info[1].cmd_ack,PACKET,=F46+INT((G46+H46)/8),=MOD((G46+H46)@@8),=IF(OR(EXACT(C47@@"uint8_t")@@EXACT(C47@@"int8_t"))@@8@@IF(OR(EXACT(C47@@"uint16_t")@@EXACT(C47@@"int16_t"))@@16@@IF(OR(EXACT(C47@@"uint32_t")@@EXACT(C47@@"int32_t")@@EXACT(C47@@"float"))@@32@@IF(EXACT(C47@@"double")@@64)))),STATUS,,,,,,,0=SUCCESS:G@@ 1=RT_ACPT:G@@ 2=RT_FWD:G@@ 3=LENGTH:R@@ 4=CRC:R@@ 5=TO_ID:R@@ 6=TC_DISC:R@@ 7=CM_TYPE:R@@ 8=LST_FUL:R@@ 9=TL_ACPT:G@@ 10=TL_PAST:R@@ 11=TL_EXST:R@@ 12=TL_NEXE:R@@ 13=TL_NFND:R@@ 14=BL_ACPT:G@@ 15=BL_BLK#:R@@ 16=BL_CMD#:R@@ 17=BL_ISOR:R@@ 18=BL_INAC:R@@ 19=BL_COMB:R@@ 20=TLM_DST:R@@ 21=UNKNOWN:R,, diff --git a/Examples/minimum_user_for_s2e/src/src_user/Settings/TlmCmd/DataBase/TLM_DB/SAMPLE_MOBC_TLM_DB_MOBC.csv b/Examples/minimum_user_for_s2e/src/src_user/Settings/TlmCmd/DataBase/TLM_DB/SAMPLE_MOBC_TLM_DB_MOBC.csv index abd5b75ac..4f7f34559 100644 --- a/Examples/minimum_user_for_s2e/src/src_user/Settings/TlmCmd/DataBase/TLM_DB/SAMPLE_MOBC_TLM_DB_MOBC.csv +++ b/Examples/minimum_user_for_s2e/src/src_user/Settings/TlmCmd/DataBase/TLM_DB/SAMPLE_MOBC_TLM_DB_MOBC.csv @@ -30,7 +30,7 @@ Comment,TLM Entry,Onboard Software Info.,,Extraction Info.,,,,Conversion Info.,, ,TDSP_CMD_LAST_ERR_STS,int32_t,(int32_t)(TDSP_info->tskd.prev_err.sts),PACKET,=F29+INT((G29+H29)/8),=MOD((G29+H29)@@8),=IF(OR(EXACT(C30@@"uint8_t")@@EXACT(C30@@"int8_t"))@@8@@IF(OR(EXACT(C30@@"uint16_t")@@EXACT(C30@@"int16_t"))@@16@@IF(OR(EXACT(C30@@"uint32_t")@@EXACT(C30@@"int32_t")@@EXACT(C30@@"float"))@@32@@IF(EXACT(C30@@"double")@@64)))),STATUS,,,,,,,0=SUC@@ 1=LEN@@ 2=PRM@@ 3=CNT@@ 4=NDF@@ 5=RUT@@ 6=FMT@@ *=ERR,ŐVR}hs, ,GS_RET_FROM_IF_RX,int32_t,(int32_t)gs_driver->latest_info->ret_from_if_rx,PACKET,=F30+INT((G30+H30)/8),=MOD((G30+H30)@@8),=IF(OR(EXACT(C31@@"uint8_t")@@EXACT(C31@@"int8_t"))@@8@@IF(OR(EXACT(C31@@"uint16_t")@@EXACT(C31@@"int16_t"))@@16@@IF(OR(EXACT(C31@@"uint32_t")@@EXACT(C31@@"int32_t")@@EXACT(C31@@"float"))@@32@@IF(EXACT(C31@@"double")@@64)))),NONE,,,,,,,,, ,TCF_LAST_RECV_ACK,uint8_t,(uint8_t)gs_driver->latest_info->rec_status,PACKET,=F31+INT((G31+H31)/8),=MOD((G31+H31)@@8),=IF(OR(EXACT(C32@@"uint8_t")@@EXACT(C32@@"int8_t"))@@8@@IF(OR(EXACT(C32@@"uint16_t")@@EXACT(C32@@"int16_t"))@@16@@IF(OR(EXACT(C32@@"uint32_t")@@EXACT(C32@@"int32_t")@@EXACT(C32@@"float"))@@32@@IF(EXACT(C32@@"double")@@64)))),STATUS,,,,,,,0=SUCCESS:G@@ 1=ERROR:R,TCFrame DS, -,TCF_VALIDATE_STATUS,uint8_t,(uint8_t)gs_driver->latest_info->tc_frame_validate_status,PACKET,=F32+INT((G32+H32)/8),=MOD((G32+H32)@@8),=IF(OR(EXACT(C33@@"uint8_t")@@EXACT(C33@@"int8_t"))@@8@@IF(OR(EXACT(C33@@"uint16_t")@@EXACT(C33@@"int16_t"))@@16@@IF(OR(EXACT(C33@@"uint32_t")@@EXACT(C33@@"int32_t")@@EXACT(C33@@"float"))@@32@@IF(EXACT(C33@@"double")@@64)))),STATUS,,,,,,,0=SUCCESS:G@@ 1=TCF_VER:R@@ 2=TCF_SCID:R@@ 3=TCF_VCID:R@@ 4=TCF_TYPE:R@@ 5=LOCKOUT:R@@ 6=TCF_SEQ_FLAG:R@@ 7=TCP_VER:R@@ 8=TCP_2ND_HDR_FLAG:R@@ 9=TCP_APID:R@@ 10=TCP_TYPE_IS_NOT_CMD:R@@ 11=TCP_SEQ_IS_NOTE_SINGLE:R@@ 12=FECW_MISSMATCH:R@@ 13=FARM1_PWA:R@@ 14=FARM1_NWA:R@@ 15=FARM1_LOCKOUT_AREA:R@@ 16=FARM1_SAME_NUMBER:R@@ 17=INVALID_BC_CMD:R,TCFrame ،, +,TCF_VALIDATE_STATUS,uint8_t,(uint8_t)gs_driver->latest_info->tc_frame_validate_status,PACKET,=F32+INT((G32+H32)/8),=MOD((G32+H32)@@8),=IF(OR(EXACT(C33@@"uint8_t")@@EXACT(C33@@"int8_t"))@@8@@IF(OR(EXACT(C33@@"uint16_t")@@EXACT(C33@@"int16_t"))@@16@@IF(OR(EXACT(C33@@"uint32_t")@@EXACT(C33@@"int32_t")@@EXACT(C33@@"float"))@@32@@IF(EXACT(C33@@"double")@@64)))),STATUS,,,,,,,0=SUCCESS:G@@ 1=TCF_VER:R@@ 2=TCF_SCID:R@@ 3=TCF_VCID:R@@ 4=TCF_TYPE:R@@ 5=LOCKOUT:R@@ 6=TCF_SEQ_FLAG:R@@ 7=TCP_VER:R@@ 8=TCP_2ND_HDR_FLAG:R@@ 9=APID:R@@ 10=TCP_TYPE_IS_NOT_CMD:R@@ 11=TCP_SEQ_IS_NOTE_SINGLE:R@@ 12=FECW_MISSMATCH:R@@ 13=FARM1_PWA:R@@ 14=FARM1_NWA:R@@ 15=FARM1_LOCKOUT_AREA:R@@ 16=FARM1_SAME_NUMBER:R@@ 17=INVALID_BC_CMD:R,TCFrame ،, ,TCF_LAST_RECV_TIME,uint32_t,(uint32_t)gs_driver->latest_info->last_rec_time,PACKET,=F33+INT((G33+H33)/8),=MOD((G33+H33)@@8),=IF(OR(EXACT(C34@@"uint8_t")@@EXACT(C34@@"int8_t"))@@8@@IF(OR(EXACT(C34@@"uint16_t")@@EXACT(C34@@"int16_t"))@@16@@IF(OR(EXACT(C34@@"uint32_t")@@EXACT(C34@@"int32_t")@@EXACT(C34@@"float"))@@32@@IF(EXACT(C34@@"double")@@64)))),NONE,,,,,,,,ŐVTCFrameM, ,TCF_FARM_PW,uint8_t,(uint8_t)gs_validate_info->positive_window_width,PACKET,=F34+INT((G34+H34)/8),=MOD((G34+H34)@@8),=IF(OR(EXACT(C35@@"uint8_t")@@EXACT(C35@@"int8_t"))@@8@@IF(OR(EXACT(C35@@"uint16_t")@@EXACT(C35@@"int16_t"))@@16@@IF(OR(EXACT(C35@@"uint32_t")@@EXACT(C35@@"int32_t")@@EXACT(C35@@"float"))@@32@@IF(EXACT(C35@@"double")@@64)))),NONE,,,,,,,,FARM-1 Positive Window Width, ,TCP_LAST_RECV_ACK,uint8_t,(uint8_t)gs_driver->latest_info->cmd_ack,PACKET,=F35+INT((G35+H35)/8),=MOD((G35+H35)@@8),=IF(OR(EXACT(C36@@"uint8_t")@@EXACT(C36@@"int8_t"))@@8@@IF(OR(EXACT(C36@@"uint16_t")@@EXACT(C36@@"int16_t"))@@16@@IF(OR(EXACT(C36@@"uint32_t")@@EXACT(C36@@"int32_t")@@EXACT(C36@@"float"))@@32@@IF(EXACT(C36@@"double")@@64)))),STATUS,,,,,,,0=SUCCESS:G@@ 1=RT_ACPT:G@@ 2=RT_FWD:G@@ 3=LENGTH:R@@ 4=CRC:R@@ 5=TO_ID:R@@ 6=TC_DISC:R@@ 7=CM_TYPE:R@@ 8=LST_FUL:R@@ 9=TL_ACPT:G@@ 10=TL_PAST:R@@ 11=TL_EXST:R@@ 12=TL_NEXE:R@@ 13=TL_NFND:R@@ 14=BL_ACPT:G@@ 15=BL_BLK#:R@@ 16=BL_CMD#:R@@ 17=BL_ISOR:R@@ 18=BL_INAC:R@@ 19=BL_COMB:R@@ 20=TLM_DST:R@@ 21=UNKNOWN:R,ŐVTCPacketM, diff --git a/Examples/minimum_user_for_s2e/src/src_user/Settings/TlmCmd/DataBase/TLM_DB/calced_data/SAMPLE_MOBC_TLM_DB_GS.csv b/Examples/minimum_user_for_s2e/src/src_user/Settings/TlmCmd/DataBase/TLM_DB/calced_data/SAMPLE_MOBC_TLM_DB_GS.csv index bef94995c..f39372566 100644 --- a/Examples/minimum_user_for_s2e/src/src_user/Settings/TlmCmd/DataBase/TLM_DB/calced_data/SAMPLE_MOBC_TLM_DB_GS.csv +++ b/Examples/minimum_user_for_s2e/src/src_user/Settings/TlmCmd/DataBase/TLM_DB/calced_data/SAMPLE_MOBC_TLM_DB_GS.csv @@ -28,7 +28,7 @@ Comment,TLM Entry,Onboard Software Info.,,Extraction Info.,,,,Conversion Info.,, ,CCSDS_AD_REC_STATUS,uint8_t,(uint8_t)gs_driver->info[0].ad_rec_status,PACKET,23,0,8,STATUS,,,,,,,0=OK:G@@1=ERROR:R,, ,CCSDS_BC_REC_STATUS,uint8_t,(uint8_t)gs_driver->info[0].bc_rec_status,PACKET,24,0,8,STATUS,,,,,,,0=OK:G@@1=ERROR:R,, ,CCSDS_BD_REC_STATUS,uint8_t,(uint8_t)gs_driver->info[0].bd_rec_status,PACKET,25,0,8,STATUS,,,,,,,0=OK:G@@1=ERROR:R,, -,CCSDS_TCFRAME_VALIDATE_STATUS,uint8_t,(uint8_t)(gs_driver->info[0].tc_frame_validate_status),PACKET,26,0,8,STATUS,,,,,,,0=SUCCESS:G@@ 1=TCF_VER:R@@ 2=TCF_SCID:R@@ 3=TCF_VCID:R@@ 4=TCF_TYPE:R@@ 5=LOCKOUT:R@@ 6=TCF_SEQ_FLAG:R@@ 7=TCP_VER:R@@ 8=TCP_2ND_HDR_FLAG:R@@ 9=TCP_APID:R@@ 10=TCP_TYPE_IS_NOT_CMD:R@@ 11=TCP_SEQ_IS_NOTE_SINGLE:R@@ 12=FECW_MISSMATCH:R@@ 13=FARM1_PWA:R@@ 14=FARM1_NWA:R@@ 15=FARM1_LOCKOUT_AREA:R@@ 16=FARM1_SAME_NUMBER:R@@ 17=INVALID_BC_CMD:R,, +,CCSDS_TCFRAME_VALIDATE_STATUS,uint8_t,(uint8_t)(gs_driver->info[0].tc_frame_validate_status),PACKET,26,0,8,STATUS,,,,,,,0=SUCCESS:G@@ 1=TCF_VER:R@@ 2=TCF_SCID:R@@ 3=TCF_VCID:R@@ 4=TCF_TYPE:R@@ 5=LOCKOUT:R@@ 6=TCF_SEQ_FLAG:R@@ 7=TCP_VER:R@@ 8=TCP_2ND_HDR_FLAG:R@@ 9=APID:R@@ 10=TCP_TYPE_IS_NOT_CMD:R@@ 11=TCP_SEQ_IS_NOTE_SINGLE:R@@ 12=FECW_MISSMATCH:R@@ 13=FARM1_PWA:R@@ 14=FARM1_NWA:R@@ 15=FARM1_LOCKOUT_AREA:R@@ 16=FARM1_SAME_NUMBER:R@@ 17=INVALID_BC_CMD:R,, ,CCSDS_RET_FROM_IF_RX,int32_t,(int32_t)gs_driver->info[0].ret_from_if_rx,PACKET,27,0,32,NONE,,,,,,,,, ,CCSDS_LAST_REC_TIME,uint32_t,(uint32_t)gs_driver->info[0].last_rec_time,PACKET,31,0,32,NONE,,,,,,,,, ,CCSDS_CMD_ACK,uint8_t,(uint8_t)gs_driver->info[0].cmd_ack,PACKET,35,0,8,STATUS,,,,,,,0=SUCCESS:G@@ 1=RT_ACPT:G@@ 2=RT_FWD:G@@ 3=LENGTH:R@@ 4=CRC:R@@ 5=TO_ID:R@@ 6=TC_DISC:R@@ 7=CM_TYPE:R@@ 8=LST_FUL:R@@ 9=TL_ACPT:G@@ 10=TL_PAST:R@@ 11=TL_EXST:R@@ 12=TL_NEXE:R@@ 13=TL_NFND:R@@ 14=BL_ACPT:G@@ 15=BL_BLK#:R@@ 16=BL_CMD#:R@@ 17=BL_ISOR:R@@ 18=BL_INAC:R@@ 19=BL_COMB:R@@ 20=TLM_DST:R@@ 21=UNKNOWN:R,, @@ -41,7 +41,7 @@ Comment,TLM Entry,Onboard Software Info.,,Extraction Info.,,,,Conversion Info.,, ,UART_AD_REC_STATUS,uint8_t,(uint8_t)gs_driver->info[1].ad_rec_status,PACKET,48,0,8,STATUS,,,,,,,0=OK:G@@1=ERROR:R,, ,UART_BC_REC_STATUS,uint8_t,(uint8_t)gs_driver->info[1].bc_rec_status,PACKET,49,0,8,STATUS,,,,,,,0=OK:G@@1=ERROR:R,, ,UART_BD_REC_STATUS,uint8_t,(uint8_t)gs_driver->info[1].bd_rec_status,PACKET,50,0,8,STATUS,,,,,,,0=OK:G@@1=ERROR:R,, -,UART_TCFRAME_VALIDATE_STATUS,uint8_t,(uint8_t)(gs_driver->info[1].tc_frame_validate_status),PACKET,51,0,8,STATUS,,,,,,,0=SUCCESS:G@@ 1=TCF_VER:R@@ 2=TCF_SCID:R@@ 3=TCF_VCID:R@@ 4=TCF_TYPE:R@@ 5=LOCKOUT:R@@ 6=TCF_SEQ_FLAG:R@@ 7=TCP_VER:R@@ 8=TCP_2ND_HDR_FLAG:R@@ 9=TCP_APID:R@@ 10=TCP_TYPE_IS_NOT_CMD:R@@ 11=TCP_SEQ_IS_NOTE_SINGLE:R@@ 12=FECW_MISSMATCH:R@@ 13=FARM1_PWA:R@@ 14=FARM1_NWA:R@@ 15=FARM1_LOCKOUT_AREA:R@@ 16=FARM1_SAME_NUMBER:R@@ 17=INVALID_BC_CMD:R,, +,UART_TCFRAME_VALIDATE_STATUS,uint8_t,(uint8_t)(gs_driver->info[1].tc_frame_validate_status),PACKET,51,0,8,STATUS,,,,,,,0=SUCCESS:G@@ 1=TCF_VER:R@@ 2=TCF_SCID:R@@ 3=TCF_VCID:R@@ 4=TCF_TYPE:R@@ 5=LOCKOUT:R@@ 6=TCF_SEQ_FLAG:R@@ 7=TCP_VER:R@@ 8=TCP_2ND_HDR_FLAG:R@@ 9=APID:R@@ 10=TCP_TYPE_IS_NOT_CMD:R@@ 11=TCP_SEQ_IS_NOTE_SINGLE:R@@ 12=FECW_MISSMATCH:R@@ 13=FARM1_PWA:R@@ 14=FARM1_NWA:R@@ 15=FARM1_LOCKOUT_AREA:R@@ 16=FARM1_SAME_NUMBER:R@@ 17=INVALID_BC_CMD:R,, ,UART_RET_FROM_IF_RX,int32_t,(int32_t)gs_driver->info[1].ret_from_if_rx,PACKET,52,0,32,NONE,,,,,,,,, ,UART_LAST_REC_TIME,uint32_t,(uint32_t)gs_driver->info[1].last_rec_time,PACKET,56,0,32,NONE,,,,,,,,, ,UART_CMD_ACK,uint8_t,(uint8_t)gs_driver->info[1].cmd_ack,PACKET,60,0,8,STATUS,,,,,,,0=SUCCESS:G@@ 1=RT_ACPT:G@@ 2=RT_FWD:G@@ 3=LENGTH:R@@ 4=CRC:R@@ 5=TO_ID:R@@ 6=TC_DISC:R@@ 7=CM_TYPE:R@@ 8=LST_FUL:R@@ 9=TL_ACPT:G@@ 10=TL_PAST:R@@ 11=TL_EXST:R@@ 12=TL_NEXE:R@@ 13=TL_NFND:R@@ 14=BL_ACPT:G@@ 15=BL_BLK#:R@@ 16=BL_CMD#:R@@ 17=BL_ISOR:R@@ 18=BL_INAC:R@@ 19=BL_COMB:R@@ 20=TLM_DST:R@@ 21=UNKNOWN:R,, diff --git a/Examples/minimum_user_for_s2e/src/src_user/Settings/TlmCmd/DataBase/TLM_DB/calced_data/SAMPLE_MOBC_TLM_DB_MOBC.csv b/Examples/minimum_user_for_s2e/src/src_user/Settings/TlmCmd/DataBase/TLM_DB/calced_data/SAMPLE_MOBC_TLM_DB_MOBC.csv index 5bcb81e15..62aeed451 100644 --- a/Examples/minimum_user_for_s2e/src/src_user/Settings/TlmCmd/DataBase/TLM_DB/calced_data/SAMPLE_MOBC_TLM_DB_MOBC.csv +++ b/Examples/minimum_user_for_s2e/src/src_user/Settings/TlmCmd/DataBase/TLM_DB/calced_data/SAMPLE_MOBC_TLM_DB_MOBC.csv @@ -30,7 +30,7 @@ Comment,TLM Entry,Onboard Software Info.,,Extraction Info.,,,,Conversion Info.,, ,TDSP_CMD_LAST_ERR_STS,int32_t,(int32_t)(TDSP_info->tskd.prev_err.sts),PACKET,36,0,32,STATUS,,,,,,,0=SUC@@ 1=LEN@@ 2=PRM@@ 3=CNT@@ 4=NDF@@ 5=RUT@@ 6=FMT@@ *=ERR,ŐVR}hs, ,GS_RET_FROM_IF_RX,int32_t,(int32_t)gs_driver->latest_info->ret_from_if_rx,PACKET,40,0,32,NONE,,,,,,,,, ,TCF_LAST_RECV_ACK,uint8_t,(uint8_t)gs_driver->latest_info->rec_status,PACKET,44,0,8,STATUS,,,,,,,0=SUCCESS:G@@ 1=ERROR:R,TCFrame DS, -,TCF_VALIDATE_STATUS,uint8_t,(uint8_t)gs_driver->latest_info->tc_frame_validate_status,PACKET,45,0,8,STATUS,,,,,,,0=SUCCESS:G@@ 1=TCF_VER:R@@ 2=TCF_SCID:R@@ 3=TCF_VCID:R@@ 4=TCF_TYPE:R@@ 5=LOCKOUT:R@@ 6=TCF_SEQ_FLAG:R@@ 7=TCP_VER:R@@ 8=TCP_2ND_HDR_FLAG:R@@ 9=TCP_APID:R@@ 10=TCP_TYPE_IS_NOT_CMD:R@@ 11=TCP_SEQ_IS_NOTE_SINGLE:R@@ 12=FECW_MISSMATCH:R@@ 13=FARM1_PWA:R@@ 14=FARM1_NWA:R@@ 15=FARM1_LOCKOUT_AREA:R@@ 16=FARM1_SAME_NUMBER:R@@ 17=INVALID_BC_CMD:R,TCFrame ،, +,TCF_VALIDATE_STATUS,uint8_t,(uint8_t)gs_driver->latest_info->tc_frame_validate_status,PACKET,45,0,8,STATUS,,,,,,,0=SUCCESS:G@@ 1=TCF_VER:R@@ 2=TCF_SCID:R@@ 3=TCF_VCID:R@@ 4=TCF_TYPE:R@@ 5=LOCKOUT:R@@ 6=TCF_SEQ_FLAG:R@@ 7=TCP_VER:R@@ 8=TCP_2ND_HDR_FLAG:R@@ 9=APID:R@@ 10=TCP_TYPE_IS_NOT_CMD:R@@ 11=TCP_SEQ_IS_NOTE_SINGLE:R@@ 12=FECW_MISSMATCH:R@@ 13=FARM1_PWA:R@@ 14=FARM1_NWA:R@@ 15=FARM1_LOCKOUT_AREA:R@@ 16=FARM1_SAME_NUMBER:R@@ 17=INVALID_BC_CMD:R,TCFrame ،, ,TCF_LAST_RECV_TIME,uint32_t,(uint32_t)gs_driver->latest_info->last_rec_time,PACKET,46,0,32,NONE,,,,,,,,ŐVTCFrameM, ,TCF_FARM_PW,uint8_t,(uint8_t)gs_validate_info->positive_window_width,PACKET,50,0,8,NONE,,,,,,,,FARM-1 Positive Window Width, ,TCP_LAST_RECV_ACK,uint8_t,(uint8_t)gs_driver->latest_info->cmd_ack,PACKET,51,0,8,STATUS,,,,,,,0=SUCCESS:G@@ 1=RT_ACPT:G@@ 2=RT_FWD:G@@ 3=LENGTH:R@@ 4=CRC:R@@ 5=TO_ID:R@@ 6=TC_DISC:R@@ 7=CM_TYPE:R@@ 8=LST_FUL:R@@ 9=TL_ACPT:G@@ 10=TL_PAST:R@@ 11=TL_EXST:R@@ 12=TL_NEXE:R@@ 13=TL_NFND:R@@ 14=BL_ACPT:G@@ 15=BL_BLK#:R@@ 16=BL_CMD#:R@@ 17=BL_ISOR:R@@ 18=BL_INAC:R@@ 19=BL_COMB:R@@ 20=TLM_DST:R@@ 21=UNKNOWN:R,ŐVTCPacketM, diff --git a/Examples/minimum_user_for_s2e/src/src_user/Settings/TlmCmd/common_cmd_packet_define.h b/Examples/minimum_user_for_s2e/src/src_user/Settings/TlmCmd/common_cmd_packet_define.h new file mode 100644 index 000000000..a7720d582 --- /dev/null +++ b/Examples/minimum_user_for_s2e/src/src_user/Settings/TlmCmd/common_cmd_packet_define.h @@ -0,0 +1,20 @@ +/** + * @file + * @brief CCP 型の定義 + */ +#ifndef COMMON_CMD_PACKET_DEFINE_H_ +#define COMMON_CMD_PACKET_DEFINE_H_ + +#include + +// CommonCmdPacket として TCP をつかう +// FIXME: CmdSpacePacket に差し替える +typedef TCP CommonCmdPacket; +// FIXME: 一時的 https://github.com/ut-issl/c2a-core/pull/209 +typedef TCP CTCP; + +// 2021-01-22 追加 +// DEST_TYPE を定義 +typedef TCP_CMD_DEST_TYPE CCP_DEST_TYPE; + +#endif diff --git a/Examples/minimum_user_for_s2e/src/src_user/Settings/TlmCmd/common_tlm_cmd_packet_define.h b/Examples/minimum_user_for_s2e/src/src_user/Settings/TlmCmd/common_tlm_cmd_packet_define.h index f4e815013..bcf379068 100644 --- a/Examples/minimum_user_for_s2e/src/src_user/Settings/TlmCmd/common_tlm_cmd_packet_define.h +++ b/Examples/minimum_user_for_s2e/src/src_user/Settings/TlmCmd/common_tlm_cmd_packet_define.h @@ -1,26 +1,22 @@ /** * @file - * @brief CTCP型の定義 + * @brief CTCP 型の定義 */ #ifndef COMMON_TLM_CMD_PACKET_DEFINE_H_ #define COMMON_TLM_CMD_PACKET_DEFINE_H_ #include +#include "./Ccsds/apid_define.h" -// 使用するパケット構造体をCTCP型として定義する -typedef TCP CTCP; - -// 宛先IDを定義 -typedef TCP_APID CTCP_DEST_ID; - -// 2021-01-22 追加 -// DEST_TYPE を定義 -typedef TCP_CMD_DEST_TYPE CCP_DEST_TYPE; +// CommonTlmCmdPacket として TCP をつかう +// FIXME: SpacePacket に差し替える +typedef TCP CommonTlmCmdPacket; // テレコマパケットの最大長を定義 #define CTCP_MAX_LEN (TCP_MAX_LEN) // 自分宛てCMDを示すDestination IDを定義 -#define CTCP_MY_DST_ID (TCP_APID_MOBC_CMD) +// FIXME: Space Packet が整備されたら直す +#define CTCP_MY_DST_ID (APID_MOBC_CMD) #endif diff --git a/Examples/minimum_user_for_s2e/src/src_user/Settings/TlmCmd/common_tlm_cmd_packet_params.h b/Examples/minimum_user_for_s2e/src/src_user/Settings/TlmCmd/common_tlm_cmd_packet_params.h index c9939c706..0d721f8d4 100644 --- a/Examples/minimum_user_for_s2e/src/src_user/Settings/TlmCmd/common_tlm_cmd_packet_params.h +++ b/Examples/minimum_user_for_s2e/src/src_user/Settings/TlmCmd/common_tlm_cmd_packet_params.h @@ -7,8 +7,5 @@ #include -#undef CTCP_MY_DST_ID - -#define CTCP_MY_DST_ID (TCP_APID_MOBC_CMD) //!< 自分宛てCMDを示すDestination IDを定義 #endif diff --git a/Examples/minimum_user_for_s2e/src/src_user/Settings/TlmCmd/common_tlm_packet_define.h b/Examples/minimum_user_for_s2e/src/src_user/Settings/TlmCmd/common_tlm_packet_define.h new file mode 100644 index 000000000..679582067 --- /dev/null +++ b/Examples/minimum_user_for_s2e/src/src_user/Settings/TlmCmd/common_tlm_packet_define.h @@ -0,0 +1,14 @@ +/** + * @file + * @brief CTP 型の定義 + */ +#ifndef COMMON_TLM_PACKET_DEFINE_H_ +#define COMMON_TLM_PACKET_DEFINE_H_ + +#include + +// CommonTlmPacket として TCP をつかう +// FIXME: TlmSpacePacket に差し替える +typedef TCP CommonTlmPacket; + +#endif diff --git a/Examples/minimum_user_for_s2e/src/src_user/TlmCmd/CMakeLists.txt b/Examples/minimum_user_for_s2e/src/src_user/TlmCmd/CMakeLists.txt index 90616b146..8108476c4 100644 --- a/Examples/minimum_user_for_s2e/src/src_user/TlmCmd/CMakeLists.txt +++ b/Examples/minimum_user_for_s2e/src/src_user/TlmCmd/CMakeLists.txt @@ -6,7 +6,9 @@ set(C2A_SRCS block_command_definitions.c block_command_user_settings.c command_definitions.c + common_cmd_packet.c common_tlm_cmd_packet.c + common_tlm_packet.c telemetry_definitions.c user_packet_handler.c NormalBlockCommandDefinition/nbc_start_hk_tlm.c diff --git a/Examples/minimum_user_for_s2e/src/src_user/TlmCmd/common_cmd_packet.c b/Examples/minimum_user_for_s2e/src/src_user/TlmCmd/common_cmd_packet.c new file mode 100644 index 000000000..931769e05 --- /dev/null +++ b/Examples/minimum_user_for_s2e/src/src_user/TlmCmd/common_cmd_packet.c @@ -0,0 +1,118 @@ +#pragma section REPRO +/** + * @file + * @brief CTP 関連基本関数の定義 + * @note CCP: CommonCmdPacket + */ +#include + + +int CCP_is_valid_packet(const CommonCmdPacket* packet) +{ + if (packet == NULL) return 0; + if ( CCP_get_packet_len(packet) > (uint16_t)sizeof(CommonCmdPacket) ) return 0; + + return 1; +} + +cycle_t CCP_get_ti(const CommonCmdPacket* packet) +{ + return (cycle_t)TCP_CMD_get_ti(packet); +} + +void CCP_set_ti(CommonCmdPacket* packet, cycle_t ti) +{ + TCP_CMD_set_ti(packet, (uint32_t)ti); +} + +APID CCP_get_apid(const CommonCmdPacket* packet) +{ + return TCP_get_apid(packet); +} + +void CCP_set_apid(CommonCmdPacket* packet, APID apid) +{ + TCP_set_apid(packet, apid); +} + +CCP_EXEC_TYPE CCP_get_exec_type(const CommonCmdPacket* packet) +{ + // TCP_CMD_EXEC_TYPEとCCP_EXEC_TYPEの定義は合わせている.(正確には、前者は後者に含まれている.) + TCP_CMD_EXEC_TYPE exec_type = TCP_CMD_get_exec_type(packet); + if (exec_type == TCP_CMD_EXEC_TYPE_UNKNOWN) + { + return CCP_EXEC_TYPE_UNKNOWN; + } + else + { + return (CCP_EXEC_TYPE)exec_type; + } +} + +void CCP_set_exec_type(CommonCmdPacket* packet, CCP_EXEC_TYPE type) +{ + // CCP_EXEC_TYPEのほうがとりうる数値の幅が広いので,アサーション + if ((int)type >= (int)TCP_CMD_EXEC_TYPE_UNKNOWN) + { + TCP_CMD_set_exec_type(packet, TCP_CMD_EXEC_TYPE_UNKNOWN); + } + else + { + TCP_CMD_set_exec_type(packet, (TCP_CMD_EXEC_TYPE)type); + } +} + +// 2021-01-22 追加 +CCP_DEST_TYPE CCP_get_dest_type(const CommonCmdPacket* packet) +{ + return (CCP_DEST_TYPE)TCP_CMD_get_dest_type(packet); +} + +// 2021-01-22 追加 +void CCP_set_dest_type(CommonCmdPacket* packet, CCP_DEST_TYPE type) +{ + TCP_CMD_set_dest_type(packet, (TCP_CMD_DEST_TYPE)type); +} + +CMD_CODE CCP_get_id(const CommonCmdPacket* packet) +{ + return (CMD_CODE)TCP_CMD_get_channel_id(packet); +} + +void CCP_set_id(CommonCmdPacket* packet, CMD_CODE id) +{ + TCP_CMD_set_channel_id(packet, (uint16_t)id); +} + +uint16_t CCP_get_packet_len(const CommonCmdPacket* packet) +{ + return (uint16_t)(TCP_get_packet_len(packet) + TCP_PRM_HDR_LEN); +} + +uint16_t CCP_get_param_len(const CommonCmdPacket* packet) +{ + // ユーザーデータ長からヘッダ長を除いたものがパラメータ長 + return (uint16_t)(TCP_get_packet_len(packet) - TCP_CMD_2ND_HDR_LEN - TCP_CMD_USER_HDR_LEN); +} + +uint16_t CCP_get_max_param_len(void) +{ + return (uint16_t)(TCP_MAX_LEN - TCP_PRM_HDR_LEN - TCP_CMD_2ND_HDR_LEN - TCP_CMD_USER_HDR_LEN); +} + +const uint8_t* CCP_get_param_head(const CommonCmdPacket* packet) +{ + return TCP_CMD_get_param_head(packet); +} + +void CCP_set_param(CommonCmdPacket* packet, const uint8_t* param, uint16_t len) +{ + TCP_CMD_set_param(packet, param, len); +} + +void CCP_set_common_hdr(CommonCmdPacket* packet) +{ + TCP_CMD_set_common_hdr(packet); +} + +#pragma section diff --git a/Examples/minimum_user_for_s2e/src/src_user/TlmCmd/common_tlm_cmd_packet.c b/Examples/minimum_user_for_s2e/src/src_user/TlmCmd/common_tlm_cmd_packet.c index 6c6560700..82ade57d9 100644 --- a/Examples/minimum_user_for_s2e/src/src_user/TlmCmd/common_tlm_cmd_packet.c +++ b/Examples/minimum_user_for_s2e/src/src_user/TlmCmd/common_tlm_cmd_packet.c @@ -1,181 +1,77 @@ #pragma section REPRO /** * @file - * @brief CTCP の定義 - * @note CTCP: common_tlm_cmd_packet - * @note CCP: CommonCmdPacket + * @brief CTCP 関連基本関数の定義 + * @note CTCP: CommonTlmCmdPacket * @note CTP: CommonTlmPacket + * @note CCP: CommonCmdPacket */ - -#include // for memcpy -#include #include -#include -// ******************** -// CTCP getter/setter -// ******************** -CTCP_TC_DSC CTCP_get_tc_dsc(const CTCP* packet) +int CTCP_is_valid_packet(const CommonTlmCmdPacket* packet) +{ + if (packet == NULL) return 0; + if ( CTCP_get_packet_len(packet) > (uint16_t)sizeof(CommonTlmCmdPacket) ) return 0; + + return 1; +} + +CTCP_PACKET_TYPE CTCP_get_packet_type(const CommonTlmCmdPacket* packet) { switch (TCP_get_type(packet)) { case TCP_TYPE_TLM: - return CTCP_TC_DSC_TLM; + return CTCP_PACKET_TYPE_TLM; case TCP_TYPE_CMD: - return CTCP_TC_DSC_CMD; + return CTCP_PACKET_TYPE_CMD; default: - return CTCP_TC_DSC_UNKNOWN; + return CTCP_PACKET_TYPE_UNKNOWN; } } -void CTCP_copy_packet(CTCP* dest, const CTCP* src) +void CTCP_copy_packet(CommonTlmCmdPacket* dest, const CommonTlmCmdPacket* src) { TCP_copy_packet(dest, src); } +// FIXME: Space Packet が整備されたら実装する +// APID CTCP_get_apid(const CommonTlmCmdPacket* packet) +// { +// } -// ******************* -// CCP getter/setter -// ******************* - -cycle_t CCP_get_ti(const CTCP* packet) -{ - return (cycle_t)TCP_CMD_get_ti(packet); -} - -void CCP_set_ti(CTCP* packet, cycle_t ti) -{ - TCP_CMD_set_ti(packet, (uint32_t)ti); -} - -CTCP_DEST_ID CCP_get_dest_id(const CTCP* packet) -{ - return (CTCP_DEST_ID)TCP_get_apid(packet); -} - -void CCP_set_dest_id(CTCP* packet, CTCP_DEST_ID id) -{ - TCP_set_apid(packet, (TCP_APID)id); -} - -CCP_EXEC_TYPE CCP_get_exec_type(const CTCP* packet) -{ - // TCP_CMD_EXEC_TYPEとCCP_EXEC_TYPEの定義は合わせている.(正確には、前者は後者に含まれている.) - TCP_CMD_EXEC_TYPE exec_type = TCP_CMD_get_exec_type(packet); - if (exec_type == TCP_CMD_EXEC_TYPE_UNKNOWN) - { - return CCP_EXEC_TYPE_UNKNOWN; - } - else - { - return (CCP_EXEC_TYPE)exec_type; - } -} - -void CCP_set_exec_type(CTCP* packet, CCP_EXEC_TYPE type) -{ - // CCP_EXEC_TYPEのほうがとりうる数値の幅が広いので,アサーション - if ((int)type >= (int)TCP_CMD_EXEC_TYPE_UNKNOWN) - { - TCP_CMD_set_exec_type(packet, TCP_CMD_EXEC_TYPE_UNKNOWN); - } - else - { - TCP_CMD_set_exec_type(packet, (TCP_CMD_EXEC_TYPE)type); - } -} +// void CTCP_set_apid(CommonTlmCmdPacket* packet, APID apid) +// { +// } -// 2021-01-22 追加 -CCP_DEST_TYPE CCP_get_dest_type(const CTCP* packet) -{ - return (CCP_DEST_TYPE)TCP_CMD_get_dest_type(packet); -} - -// 2021-01-22 追加 -void CCP_set_dest_type(CTCP* packet, CCP_DEST_TYPE type) -{ - TCP_CMD_set_dest_type(packet, (TCP_CMD_DEST_TYPE)type); -} - -CMD_CODE CCP_get_id(const CTCP* packet) -{ - return (CMD_CODE)TCP_CMD_get_channel_id(packet); -} - -void CCP_set_id(CTCP* packet, CMD_CODE id) -{ - TCP_CMD_set_channel_id(packet, (uint16_t)id); -} - -uint16_t CCP_get_packet_len(const CTCP* packet) +uint16_t CTCP_get_packet_len(const CommonTlmCmdPacket* packet) { return (uint16_t)(TCP_get_packet_len(packet) + TCP_PRM_HDR_LEN); } -uint16_t CCP_get_param_len(const CTCP* packet) -{ - // ユーザーデータ長からヘッダ長を除いたものがパラメータ長 - return (uint16_t)(TCP_get_packet_len(packet) - TCP_CMD_2ND_HDR_LEN - TCP_CMD_USER_HDR_LEN); -} - -uint16_t CCP_get_max_param_len(void) -{ - return (uint16_t)(TCP_MAX_LEN - TCP_PRM_HDR_LEN - TCP_CMD_2ND_HDR_LEN - TCP_CMD_USER_HDR_LEN); -} - -const uint8_t* CCP_get_param_head(const CTCP* packet) -{ - return TCP_CMD_get_param_head(packet); -} - -void CCP_set_param(CTCP* packet, const uint8_t* param, uint16_t len) +// FIXME: 以下4関数について, Space Packet が整備されたら, `if len(ctcp) > CCP_MAX_LEN return NULL;` のようなアサーションをいれる! +const CommonTlmPacket* CTCP_convert_to_ctp(const CommonTlmCmdPacket* ctcp) { - TCP_CMD_set_param(packet, param, len); + if (CTCP_get_packet_type(ctcp) != CTCP_PACKET_TYPE_TLM) return NULL; + return (const CommonTlmPacket*)ctcp; } -void CCP_set_common_hdr(CTCP* packet) +const CommonTlmCmdPacket* CTCP_convert_from_ctp(const CommonTlmPacket* ctp) { - TCP_CMD_set_common_hdr(packet); + return (const CommonTlmCmdPacket*)ctp; } -// ******************* -// CTP getter/setter -// ******************* - -CTP_DEST_FLAG CTP_get_dest_flag(const CTCP* packet) +const CommonCmdPacket* CTCP_convert_to_ccp(const CommonTlmCmdPacket* ctcp) { - uint8_t category = TCP_TLM_get_category(packet); - uint8_t mask = 0xe0; // 11100000b - - category &= mask; - category >>= 5; - - if (category == 0) - { - return CTP_DEST_FLAG_RP; - } - else - { - return (CTP_DEST_FLAG)category; - } + if (CTCP_get_packet_type(ctcp) != CTCP_PACKET_TYPE_CMD) return NULL; + return (const CommonCmdPacket*)ctcp; } -void CTP_set_dest_flag(CTCP* packet, CTP_DEST_FLAG flag) +const CommonTlmCmdPacket* CTCP_convert_from_ccp(const CommonCmdPacket* ccp) { - uint8_t category = TCP_TLM_get_category(packet); - uint8_t mask = 0xe0; // 11100000b - - category &= (uint8_t)(~mask); - category |= (uint8_t)(flag << 5); - - TCP_TLM_set_category(packet, category); + return (const CommonTlmCmdPacket*)ccp; } -uint8_t* CTP_get_user_data_head(CTCP* packet) -{ - return TCP_TLM_get_user_data_head(packet); -} #pragma section diff --git a/Examples/minimum_user_for_s2e/src/src_user/TlmCmd/common_tlm_packet.c b/Examples/minimum_user_for_s2e/src/src_user/TlmCmd/common_tlm_packet.c new file mode 100644 index 000000000..6a6ca35e7 --- /dev/null +++ b/Examples/minimum_user_for_s2e/src/src_user/TlmCmd/common_tlm_packet.c @@ -0,0 +1,57 @@ +#pragma section REPRO +/** + * @file + * @brief CTP 関連基本関数の定義 + * @note CTP: CommonTlmPacket + */ +#include + + +int CTP_is_valid_packet(const CommonTlmPacket* packet) +{ + if (packet == NULL) return 0; + if ( CTP_get_packet_len(packet) > (uint16_t)sizeof(CommonTlmPacket) ) return 0; + + return 1; +} + +CTP_DEST_FLAG CTP_get_dest_flag(const CommonTlmPacket* packet) +{ + uint8_t category = TCP_TLM_get_category(packet); + uint8_t mask = 0xe0; // 11100000b + + category &= mask; + category >>= 5; + + if (category == 0) + { + return CTP_DEST_FLAG_RP; + } + else + { + return (CTP_DEST_FLAG)category; + } +} + +void CTP_set_dest_flag(CommonTlmPacket* packet, CTP_DEST_FLAG flag) +{ + uint8_t category = TCP_TLM_get_category(packet); + uint8_t mask = 0xe0; // 11100000b + + category &= (uint8_t)(~mask); + category |= (uint8_t)(flag << 5); + + TCP_TLM_set_category(packet, category); +} + +uint16_t CTP_get_packet_len(const CommonTlmPacket* packet) +{ + return (uint16_t)(TCP_get_packet_len(packet) + TCP_PRM_HDR_LEN); +} + +uint8_t* CTP_get_user_data_head(CommonTlmPacket* packet) +{ + return TCP_TLM_get_user_data_head(packet); +} + +#pragma section diff --git a/Examples/minimum_user_for_s2e/src/src_user/TlmCmd/user_packet_handler.c b/Examples/minimum_user_for_s2e/src/src_user/TlmCmd/user_packet_handler.c index 869932371..3d1b114e9 100644 --- a/Examples/minimum_user_for_s2e/src/src_user/TlmCmd/user_packet_handler.c +++ b/Examples/minimum_user_for_s2e/src/src_user/TlmCmd/user_packet_handler.c @@ -47,12 +47,12 @@ PH_ACK PH_user_analyze_cmd(const CTCP* packet) CCP_EXEC_STS PH_user_cmd_router(const CTCP* packet) { - switch (CCP_get_dest_id(packet)) + switch (CCP_get_apid(packet)) { - case TCP_APID_AOBC_CMD: + case APID_AOBC_CMD: // AOBCに配送 // return DI_AOBC_dispatch_command(packet); - case TCP_APID_TOBC_CMD: + case APID_TOBC_CMD: // TOBCに配送 // return DI_TOBC_dispatch_command(packet); default: diff --git a/Script/CI/check_coding_rule.json b/Script/CI/check_coding_rule.json index c13b1bae0..7577e17fb 100644 --- a/Script/CI/check_coding_rule.json +++ b/Script/CI/check_coding_rule.json @@ -14,9 +14,13 @@ "src_user/TlmCmd/telemetry_definitions.c" ], "additional_type" : [ - "PL_NodeTag" + "PL_NodeTag", + "CommonTlmCmdPacket", + "CommonTlmPacket", + "CommonCmdPacket" ], "comment_additional_type" : [ - "現状, struct PL_NodeTag* next; は型として引っ掛けられない" + "現状, struct PL_NodeTag* next; は型として引っ掛けられない", + "FIXME: CTCP, CTP, CCP については,整理が終わり次第,消して大丈夫になるはず" ] } diff --git a/Script/CI/check_coding_rule.py b/Script/CI/check_coding_rule.py index c8d289f3f..803ae08be 100644 --- a/Script/CI/check_coding_rule.py +++ b/Script/CI/check_coding_rule.py @@ -685,7 +685,7 @@ def check_operator_space_(path: str, code_lines: list) -> int: if match.group(2) == "*" and match.group(3) != "": if match.group(3)[0] == ")": continue - # common_tlm_cmd_packet_util.h の `(*((type*)( \` が引っかからないように + # common_cmd_packet_util.h の `(*((type*)( \` が引っかからないように # print(line) # print(match) # print("#" + match.group(1) + "#") diff --git a/System/EventManager/event_handler.c b/System/EventManager/event_handler.c index 68b43a17a..d2c359be4 100644 --- a/System/EventManager/event_handler.c +++ b/System/EventManager/event_handler.c @@ -7,7 +7,7 @@ #include "event_handler.h" #include #include -#include "../../TlmCmd/common_tlm_cmd_packet_util.h" +#include "../../TlmCmd/common_cmd_packet_util.h" #include "../../Applications/timeline_command_dispatcher.h" #include "../TimeManager/time_manager.h" @@ -598,11 +598,11 @@ static void EH_respond_(EH_RULE_ID rule_id) { EH_Rule* rule = &event_handler_.rule_table.rules[rule_id]; CTCP packet; - CTCP_UTIL_ACK deploy_ack; - CCP_EXEC_STS deploy_cmd_ack; + CCP_UTIL_ACK form_cmd_ack; + CCP_EXEC_STS deploy_cmd_ack; - deploy_ack = CCP_form_block_deploy_cmd(&packet, TL_ID_DEPLOY_BC, rule->settings.deploy_bct_id); - if (deploy_ack != CTCP_UTIL_ACK_OK) + form_cmd_ack = CCP_form_block_deploy_cmd(&packet, TL_ID_DEPLOY_BC, rule->settings.deploy_bct_id); + if (form_cmd_ack != CCP_UTIL_ACK_OK) { // BC 展開 Cmd の生成に失敗 // 正しく組んでいる場合,ここに来るはずはない diff --git a/System/EventManager/event_logger.c b/System/EventManager/event_logger.c index ac9917dac..3aadc86da 100644 --- a/System/EventManager/event_logger.c +++ b/System/EventManager/event_logger.c @@ -13,7 +13,7 @@ #include "../TimeManager/time_manager.h" #include "../WatchdogTimer/watchdog_timer.h" #include -#include "../../TlmCmd/common_tlm_cmd_packet_util.h" +#include "../../TlmCmd/common_cmd_packet_util.h" #ifdef EL_IS_ENABLE_CLOG diff --git a/System/ModeManager/mode_manager.c b/System/ModeManager/mode_manager.c index 30823b318..769b5a261 100644 --- a/System/ModeManager/mode_manager.c +++ b/System/ModeManager/mode_manager.c @@ -12,7 +12,7 @@ #include "../AnomalyLogger/anomaly_logger.h" #include "../EventManager/event_logger.h" #include "../../TlmCmd/block_command_executor.h" -#include "../../TlmCmd/common_tlm_cmd_packet_util.h" +#include "../../TlmCmd/common_cmd_packet_util.h" #include #include "../../TlmCmd/packet_handler.h" #include "../../Applications/timeline_command_dispatcher.h" diff --git a/System/TimeManager/time_manager.c b/System/TimeManager/time_manager.c index 3c1eacf24..ff67624ae 100644 --- a/System/TimeManager/time_manager.c +++ b/System/TimeManager/time_manager.c @@ -6,7 +6,7 @@ #include "time_manager.h" #include #include "../TaskManager/task_dispatcher.h" -#include "../../TlmCmd/common_tlm_cmd_packet_util.h" +#include "../../TlmCmd/common_cmd_packet_util.h" static TimeManager time_manager_; const TimeManager* const time_manager = &time_manager_; diff --git a/TlmCmd/Ccsds/TCPacket.c b/TlmCmd/Ccsds/TCPacket.c index 8c6cc019f..e8423eb8a 100644 --- a/TlmCmd/Ccsds/TCPacket.c +++ b/TlmCmd/Ccsds/TCPacket.c @@ -95,27 +95,27 @@ void TCP_set_2nd_hdr_flag(TCP* tcp, TCP_2ND_HDR_FLAG flag) tcp->packet[TCP_pp_2nd_hdr_flag_.pos] |= (uint8_t)(val & TCP_pp_2nd_hdr_flag_.mask); } -TCP_APID TCP_get_apid(const TCP* tcp) +APID TCP_get_apid(const TCP* tcp) { - TCP_APID apid = (TCP_APID)(tcp->packet[TCP_pp_apid_.pos] & TCP_pp_apid_.mask); - apid = (TCP_APID)(apid << 8); - apid = (TCP_APID)(apid + tcp->packet[TCP_pp_apid_.pos + 1]); + APID apid = (APID)(tcp->packet[TCP_pp_apid_.pos] & TCP_pp_apid_.mask); + apid = (APID)(apid << 8); + apid = (APID)(apid + tcp->packet[TCP_pp_apid_.pos + 1]); switch (apid) { - case TCP_APID_MOBC_CMD: // FALLTHROUGH - case TCP_APID_AOBC_CMD: // FALLTHROUGH - case TCP_APID_TOBC_CMD: // FALLTHROUGH - case TCP_APID_MIS_TLM: // FALLTHROUGH - case TCP_APID_DUMP_TLM: + case APID_MOBC_CMD: // FALLTHROUGH + case APID_AOBC_CMD: // FALLTHROUGH + case APID_TOBC_CMD: // FALLTHROUGH + case APID_MIS_TLM: // FALLTHROUGH + case APID_DUMP_TLM: return apid; default: - return TCP_APID_UNKNOWN; + return APID_UNKNOWN; } } -void TCP_set_apid(TCP* tcp, TCP_APID apid) +void TCP_set_apid(TCP* tcp, APID apid) { uint8_t val = (uint8_t)((apid >> 8) & TCP_pp_apid_.mask); @@ -492,7 +492,7 @@ uint8_t* TCP_TLM_get_user_data_head(TCP* tcp) return &(tcp->packet[TCP_PRM_HDR_LEN + TCP_TLM_2ND_HDR_LEN]); } -void TCP_TLM_setup_primary_hdr(TCP* tcp, TCP_APID apid, uint16_t len) +void TCP_TLM_setup_primary_hdr(TCP* tcp, APID apid, uint16_t len) { TCP_TLM_set_common_hdr(tcp); TCP_set_apid(tcp, apid); @@ -523,7 +523,7 @@ void TCP_TLM_setup_fill_packet(TCP* tcp, uint16_t fill_size) // 穴埋め領域がTC Packet Primary Header長より大きい場合。 // 穴埋め領域にピッタリハマるFill Packetを生成する。 TCP_TLM_setup_primary_hdr(tcp, - TCP_APID_FILL_PKT, + APID_FILL_PKT, (uint16_t)(fill_size - TCP_PRM_HDR_LEN)); } else @@ -532,7 +532,7 @@ void TCP_TLM_setup_fill_packet(TCP* tcp, uint16_t fill_size) // 領域ピッタリのFill Packetの生成は不可能なので、データ長1 // のFill Packetを生成する。 TCP_TLM_setup_primary_hdr(tcp, - TCP_APID_FILL_PKT, + APID_FILL_PKT, 1); } } diff --git a/TlmCmd/Ccsds/TCPacket.h b/TlmCmd/Ccsds/TCPacket.h index 8d9c20ac9..dc7c7c55d 100644 --- a/TlmCmd/Ccsds/TCPacket.h +++ b/TlmCmd/Ccsds/TCPacket.h @@ -12,8 +12,11 @@ #define TCP_CMD_USER_HDR_LEN (8u) // TCP_MAX_LEN を再定義 -// TCP_APID, TCP_CMD_DEST_TYPE を定義する +// TCP_CMD_DEST_TYPE を定義する #include +// ここで APID を定義する +// 詳細は common_tlm_cmd_packet.h を参照 +#include /** @@ -171,9 +174,9 @@ void TCP_set_2nd_hdr_flag(TCP* tcp, TCP_2ND_HDR_FLAG flag); /** * @brief APID を取得 * @param tcp: TCP - * @return TCP_APID + * @return APID */ -TCP_APID TCP_get_apid(const TCP* tcp); +APID TCP_get_apid(const TCP* tcp); /** * @brief APID を設定 @@ -181,7 +184,7 @@ TCP_APID TCP_get_apid(const TCP* tcp); * @param[in] apid: APID * @return void */ -void TCP_set_apid(TCP* tcp, TCP_APID apid); +void TCP_set_apid(TCP* tcp, APID apid); /** * @brief Sequence Flag を取得 @@ -488,11 +491,11 @@ uint8_t* TCP_TLM_get_user_data_head(TCP* packet); /** * @brief Primary Header を構築 * @param[in,out] tcp: TCP - * @param[in] apid: TCP_APID + * @param[in] apid: APID * @param[in] len: Packet Length * @return void */ -void TCP_TLM_setup_primary_hdr(TCP* tcp, TCP_APID apid, uint16_t len); +void TCP_TLM_setup_primary_hdr(TCP* tcp, APID apid, uint16_t len); /** * @brief 共通部分の Header を構築 @@ -509,5 +512,4 @@ void TCP_TLM_set_common_hdr(TCP* tcp); */ void TCP_TLM_setup_fill_packet(TCP* tcp, uint16_t fill_size); - -#endif // TC_PACKET_H_ +#endif diff --git a/TlmCmd/block_command_executor.c b/TlmCmd/block_command_executor.c index 46f8179c0..247205623 100644 --- a/TlmCmd/block_command_executor.c +++ b/TlmCmd/block_command_executor.c @@ -14,7 +14,7 @@ #include "packet_handler.h" #include "../Library/endian_memcpy.h" #include "../System/TimeManager/time_manager.h" -#include "common_tlm_cmd_packet_util.h" +#include "common_cmd_packet_util.h" static CTCP packet_; diff --git a/TlmCmd/block_command_loader.c b/TlmCmd/block_command_loader.c index 774b05afe..1129a23b6 100644 --- a/TlmCmd/block_command_loader.c +++ b/TlmCmd/block_command_loader.c @@ -12,7 +12,7 @@ #include "../Applications/timeline_command_dispatcher.h" #include "block_command_executor.h" #include // for rotate/combine block -#include "common_tlm_cmd_packet_util.h" +#include "common_cmd_packet_util.h" #define BCL_PARAM_MAX_LENGTH BCT_CMD_MAX_LENGTH diff --git a/TlmCmd/block_command_loader.h b/TlmCmd/block_command_loader.h index 30e2443f8..03203e00f 100644 --- a/TlmCmd/block_command_loader.h +++ b/TlmCmd/block_command_loader.h @@ -11,6 +11,7 @@ #include "./block_command_table.h" #include "../Applications/timeline_command_dispatcher.h" #include "../System/TimeManager/obc_time.h" +#include /** @@ -29,7 +30,6 @@ void BCL_load_sl(bct_id_t pos, void (*func)(void)); #endif - // register系列 /** @@ -83,7 +83,6 @@ void BCL_tool_register_deploy(cycle_t ti, bct_id_t bct_id, TL_ID tl_id); void BCL_tool_register_app(cycle_t ti, AR_APP_ID app_id); - // add cmd param系列 /** @@ -140,4 +139,4 @@ void BCL_tool_prepare_param_float(float val); void BCL_tool_prepare_param_double(double val); #endif -#endif // BLOCK_COMMAND_LOADER_H_ +#endif diff --git a/TlmCmd/block_command_table.c b/TlmCmd/block_command_table.c index 6b940b199..305a1e0d4 100644 --- a/TlmCmd/block_command_table.c +++ b/TlmCmd/block_command_table.c @@ -18,7 +18,7 @@ #include "../System/TimeManager/time_manager.h" #include "../Library/endian_memcpy.h" #include "../System/WatchdogTimer/watchdog_timer.h" -#include "common_tlm_cmd_packet_util.h" +#include "common_cmd_packet_util.h" static BlockCommandTable block_command_table_; const BlockCommandTable* const block_command_table = &block_command_table_; diff --git a/TlmCmd/command_analyze.c b/TlmCmd/command_analyze.c index 77837ac20..3680cca57 100644 --- a/TlmCmd/command_analyze.c +++ b/TlmCmd/command_analyze.c @@ -4,7 +4,7 @@ * @brief コマンドの実行・登録,コマンド関連処理 */ #include "command_analyze.h" -#include "common_tlm_cmd_packet_util.h" +#include "common_cmd_packet_util.h" #include #include "../Library/print.h" #include "../System/EventManager/event_logger.h" diff --git a/TlmCmd/common_cmd_packet.h b/TlmCmd/common_cmd_packet.h new file mode 100644 index 000000000..b3930372f --- /dev/null +++ b/TlmCmd/common_cmd_packet.h @@ -0,0 +1,188 @@ +/** + * @file + * @brief CCP 関連基本関数の宣言 + * @note CCP: CommonCmdPacket + */ +#ifndef COMMON_CMD_PACKET_H_ +#define COMMON_CMD_PACKET_H_ + +#include "../System/TimeManager/obc_time.h" +#include +#include + +// ここで APID を定義する +// 詳細は common_tlm_cmd_packet.h を参照 +#include + + +/** + * @enum CCP_EXEC_STS + * @brief コマンド実行結果コード + * @note uint8_t を想定 + */ +typedef enum +{ + CCP_EXEC_SUCCESS = 0, /*!< コマンド実行成功 + なお,コマンドの実行の結果なので,その後の処理が失敗しても,コマンドが実行されていればこれを返す */ + CCP_EXEC_ILLEGAL_LENGTH, //!< コマンド実行時のコマンド引数長エラー + CCP_EXEC_ILLEGAL_PARAMETER, //!< コマンド実行時のパラメタエラー + CCP_EXEC_ILLEGAL_CONTEXT, //!< コマンド実行時のその他のエラー + CCP_EXEC_CMD_NOT_DEFINED, //!< cmdExec で用いる + CCP_EXEC_ROUTING_FAILED, //!< command router で用いる + CCP_EXEC_PACKET_FMT_ERR, //!< packet handler で用いる + CCP_EXEC_UNKNOWN //!< 内部処理用.使わない. +} CCP_EXEC_STS; + +/** + * @enum CCP_EXEC_TYPE + * @brief コマンド実行種別 + * @note 0x0*を想定(上位4bitは他のC2Aを搭載したボード用に転送するために使うため) + * その定義はTCP_DEST_TYPEにある + * @note TCP_CMD_EXEC_TYPE と CCP_EXEC_TYPE の定義は一致 (正確には、前者は後者に含まれている) + * CCP_EXEC_TYPE CCP_get_exec_type(const CTCP* packet) を参照 + * @note GSからのOBC.TLや,C2A内のCCP_form_tlcはすべてTL0扱いになる + */ +typedef enum +{ + CCP_EXEC_TYPE_GS, //!< GS : Ground Station Command + CCP_EXEC_TYPE_TL0, //!< TL : Timeline Command + CCP_EXEC_TYPE_BC, //!< BC : Block Command + CCP_EXEC_TYPE_RT, //!< RT : Realtime Command + CCP_EXEC_TYPE_UTL, //!< UTL: Unixtime Timeline Command + CCP_EXEC_TYPE_TL1, + CCP_EXEC_TYPE_TL2, + CCP_EXEC_TYPE_UNKNOWN +} CCP_EXEC_TYPE; + + +/** + * @brief 有効なパケットかチェックする + * @note NULL チェックも行う + * @note OBC の外から来たパケットな可能性もあるので,このC2Aで扱えるサイズかもチェックする + * @param packet: CCP + * @retval 1: True + * @retval 0: False + */ +int CCP_is_valid_packet(const CommonCmdPacket* packet); + +/** + * @brief TI を取得 + * @param packet: CCP + * @return ti + */ +cycle_t CCP_get_ti(const CommonCmdPacket* packet); + +/** + * @brief TI を設定 + * @param[in,out] packet: CCP + * @param[in] ti: TI + * @return void + */ +void CCP_set_ti(CommonCmdPacket* packet, cycle_t ti); + +/** + * @brief APID を取得 + * @param packet: CCP + * @return APID + */ +APID CCP_get_apid(const CommonCmdPacket* packet); + +/** + * @brief APID を設定 + * @param[in,out] packet: CCP + * @param[in] apid: APID + * @return void + */ +void CCP_set_apid(CommonCmdPacket* packet, APID apid); + +/** + * @brief EXEC_TYPE を取得 + * @param packet: CCP + * @return CCP_EXEC_TYPE + */ +CCP_EXEC_TYPE CCP_get_exec_type(const CommonCmdPacket* packet); + +/** + * @brief EXEC_TYPE を設定 + * @param[in,out] packet: CCP + * @param[in] type: EXEC_TYPE + * @return void + */ +void CCP_set_exec_type(CommonCmdPacket* packet, CCP_EXEC_TYPE type); + +/** + * @brief DEST_TYPE を取得 + * @param packet: CCP + * @return CCP_DEST_TYPE + * @note 2021/01/22に CCP_EXEC_TYPE の上位4bitを拝借する形で追加実装 FIXME: ドキュメント化 + */ +CCP_DEST_TYPE CCP_get_dest_type(const CommonCmdPacket* packet); + +/** + * @brief DEST_TYPE を設定 + * @param[in,out] packet: CCP + * @param[in] type: DEST_TYPE + * @return void + * @note 2021/01/22に CCP_EXEC_TYPE の上位4bitを拝借する形で追加実装 FIXME: ドキュメント化 + */ +void CCP_set_dest_type(CommonCmdPacket* packet, CCP_DEST_TYPE type); + +/** + * @brief CMD ID を取得 + * @param packet: CCP + * @return CMD_CODE + */ +CMD_CODE CCP_get_id(const CommonCmdPacket* packet); + +/** + * @brief CMD ID を設定 + * @param[in,out] packet: CCP + * @param[in] id: CMD_CODE + * @return void + */ +void CCP_set_id(CommonCmdPacket* packet, CMD_CODE id); + +/** + * @brief パケット長を取得 + * @param packet: CCP + * @return packet len + */ +uint16_t CCP_get_packet_len(const CommonCmdPacket* packet); + +/** + * @brief CMD パラメタ長を取得 + * @param packet: CCP + * @return param len + */ +uint16_t CCP_get_param_len(const CommonCmdPacket* packet); + +/** + * @brief CMD パラメタ長の最大値を取得 + * @return max param len + */ +uint16_t CCP_get_max_param_len(void); + +/** + * @brief 先頭のパラメタのポインタを取得 + * @param packet: CCP + * @return *param_head + */ +const uint8_t* CCP_get_param_head(const CommonCmdPacket* packet); + +/** + * @brief パラメタを設定 + * @param[in,out] packet: CCP + * @param[in] param: パラメタ配列のポインタ + * @param[in] len: パラメタ長 + * @return void + */ +void CCP_set_param(CommonCmdPacket* packet, const uint8_t* param, uint16_t len); + +/** + * @brief 共通部分の Header を構築 + * @param[in,out] packet: CCP + * @return void + */ +void CCP_set_common_hdr(CommonCmdPacket* packet); + +#endif diff --git a/TlmCmd/common_tlm_cmd_packet_util.c b/TlmCmd/common_cmd_packet_util.c similarity index 66% rename from TlmCmd/common_tlm_cmd_packet_util.c rename to TlmCmd/common_cmd_packet_util.c index 6fe88cc81..4b82479f0 100644 --- a/TlmCmd/common_tlm_cmd_packet_util.c +++ b/TlmCmd/common_cmd_packet_util.c @@ -1,45 +1,44 @@ #pragma section REPRO /** * @file - * @brief CTCP の汎用Util + * @brief CCP の汎用 Utility */ -#include "common_tlm_cmd_packet_util.h" +#include "common_cmd_packet_util.h" #include "../Applications/timeline_command_dispatcher.h" // for TL_ID_MAX #include "command_analyze.h" #include "block_command_table.h" // for BCT_MAX_BLOCKS -#include // for CMD_CODE #include "../Library/endian_memcpy.h" #include // for NULL #include /** - * @brief NOP cmd の RTC CTCP を作る - * @param[in,out] packet: CTCP + * @brief NOP cmd の RTC CCP を作る + * @param[in,out] packet: CCP * @return void */ -void CCP_form_nop_rtc_(CTCP* packet); +void CCP_form_nop_rtc_(CommonCmdPacket* packet); /** - * @brief CTCP パラメタ開始位置に対する n 番目の引数の offset を計算する + * @brief CCP パラメタ開始位置に対する n 番目の引数の offset を計算する * @param[in] cmd_id: CMD_CODE * @param[in] n: N番目の引数 (0起算) * @param[out] offset: offset - * @return CTCP_UTIL_ACK + * @return CCP_UTIL_ACK */ -CTCP_UTIL_ACK CCP_calc_param_offset_(CMD_CODE cmd_id, uint8_t n, uint16_t* offset); +CCP_UTIL_ACK CCP_calc_param_offset_(CMD_CODE cmd_id, uint8_t n, uint16_t* offset); -void CCP_form_nop_rtc_(CTCP* packet) +void CCP_form_nop_rtc_(CommonCmdPacket* packet) { CCP_form_rtc(packet, Cmd_CODE_NOP, NULL, 0); } -void CCP_form_app_cmd(CTCP* packet, cycle_t ti, AR_APP_ID id) +void CCP_form_app_cmd(CommonCmdPacket* packet, cycle_t ti, AR_APP_ID id) { // FIXME: この4は環境依存なので,依存しないように直す // 適切に直すことで, CCP_form_tlc の返り値をみなくて良くなるはず. - // Cmd_AM_EXECUTE_APP の引数取得部分と同時に直すべきだが,パラメタサイズは CmdDBから取得可能なはず. + // Cmd_AM_EXECUTE_APP の引数取得部分と同時に直すべきだが,パラメタサイズは CmdDB から取得可能なはず. uint8_t param[4]; size_t id_temp = id; endian_memcpy(param, &id_temp, 4); @@ -47,18 +46,18 @@ void CCP_form_app_cmd(CTCP* packet, cycle_t ti, AR_APP_ID id) CCP_form_tlc(packet, ti, Cmd_CODE_AM_EXECUTE_APP, param, 4); } -CTCP_UTIL_ACK CCP_form_rtc(CTCP* packet, CMD_CODE cmd_id, const uint8_t* param, uint16_t len) +CCP_UTIL_ACK CCP_form_rtc(CommonCmdPacket* packet, CMD_CODE cmd_id, const uint8_t* param, uint16_t len) { if (param == NULL && len != 0) { CCP_form_nop_rtc_(packet); - return CTCP_UTIL_ACK_PARAM_ERR; + return CCP_UTIL_ACK_PARAM_ERR; } if (CA_ckeck_cmd_param_len(cmd_id, len) != CA_ACK_OK) { CCP_form_nop_rtc_(packet); - return CTCP_UTIL_ACK_PARAM_ERR; + return CCP_UTIL_ACK_PARAM_ERR; } CCP_set_common_hdr(packet); @@ -68,23 +67,23 @@ CTCP_UTIL_ACK CCP_form_rtc(CTCP* packet, CMD_CODE cmd_id, const uint8_t* param, CCP_set_ti(packet, 0); // RTの場合、TIは0固定。 CCP_set_param(packet, param, len); - return CTCP_UTIL_ACK_OK; + return CCP_UTIL_ACK_OK; } -CTCP_UTIL_ACK CCP_form_tlc(CTCP* packet, cycle_t ti, CMD_CODE cmd_id, const uint8_t* param, uint16_t len) +CCP_UTIL_ACK CCP_form_tlc(CommonCmdPacket* packet, cycle_t ti, CMD_CODE cmd_id, const uint8_t* param, uint16_t len) { if (param == NULL && len != 0) { CCP_form_nop_rtc_(packet); CCP_convert_rtc_to_tlc(packet, ti); - return CTCP_UTIL_ACK_PARAM_ERR; + return CCP_UTIL_ACK_PARAM_ERR; } if (CA_ckeck_cmd_param_len(cmd_id, len) != CA_ACK_OK) { CCP_form_nop_rtc_(packet); CCP_convert_rtc_to_tlc(packet, ti); - return CTCP_UTIL_ACK_PARAM_ERR; + return CCP_UTIL_ACK_PARAM_ERR; } CCP_set_common_hdr(packet); @@ -94,10 +93,10 @@ CTCP_UTIL_ACK CCP_form_tlc(CTCP* packet, cycle_t ti, CMD_CODE cmd_id, const uint CCP_set_ti(packet, ti); CCP_set_param(packet, param, len); - return CTCP_UTIL_ACK_OK; + return CCP_UTIL_ACK_OK; } -CTCP_UTIL_ACK CCP_form_block_deploy_cmd(CTCP* packet, uint8_t tl_no, bct_id_t block_no) +CCP_UTIL_ACK CCP_form_block_deploy_cmd(CommonCmdPacket* packet, uint8_t tl_no, bct_id_t block_no) { uint8_t param[1 + SIZE_OF_BCT_ID_T]; @@ -105,7 +104,7 @@ CTCP_UTIL_ACK CCP_form_block_deploy_cmd(CTCP* packet, uint8_t tl_no, bct_id_t bl { // タイムラインのline番号、ブロックコマンド番号が範囲外の場合異常判定 CCP_form_nop_rtc_(packet); - return CTCP_UTIL_ACK_PARAM_ERR; + return CCP_UTIL_ACK_PARAM_ERR; } param[0] = tl_no; @@ -114,24 +113,24 @@ CTCP_UTIL_ACK CCP_form_block_deploy_cmd(CTCP* packet, uint8_t tl_no, bct_id_t bl return CCP_form_rtc(packet, Cmd_CODE_TLCD_DEPLOY_BLOCK, param, 1 + SIZE_OF_BCT_ID_T); } -void CCP_convert_rtc_to_tlc(CTCP* packet, cycle_t ti) +void CCP_convert_rtc_to_tlc(CommonCmdPacket* packet, cycle_t ti) { CCP_set_exec_type(packet, CCP_EXEC_TYPE_TL0); CCP_set_ti(packet, ti); } -uint8_t* CCP_get_1byte_param_from_packet(const CTCP* packet, uint8_t n) +uint8_t* CCP_get_1byte_param_from_packet(const CommonCmdPacket* packet, uint8_t n) { static uint8_t ret; uint16_t offset = 0; CMD_CODE cmd_id = CCP_get_id(packet); uint8_t param_size = 1; - CTCP_UTIL_ACK ack; + CCP_UTIL_ACK ack; ret = 0; ack = CCP_calc_param_offset_(cmd_id, n, &offset); - if (ack != CTCP_UTIL_ACK_OK) return &ret; + if (ack != CCP_UTIL_ACK_OK) return &ret; if (CA_get_cmd_param_size(cmd_id, n) != param_size) return &ret; @@ -139,18 +138,18 @@ uint8_t* CCP_get_1byte_param_from_packet(const CTCP* packet, uint8_t n) return &ret; } -uint16_t* CCP_get_2byte_param_from_packet(const CTCP* packet, uint8_t n) +uint16_t* CCP_get_2byte_param_from_packet(const CommonCmdPacket* packet, uint8_t n) { static uint16_t ret; uint16_t offset = 0; CMD_CODE cmd_id = CCP_get_id(packet); uint8_t param_size = 2; - CTCP_UTIL_ACK ack; + CCP_UTIL_ACK ack; ret = 0; ack = CCP_calc_param_offset_(cmd_id, n, &offset); - if (ack != CTCP_UTIL_ACK_OK) return &ret; + if (ack != CCP_UTIL_ACK_OK) return &ret; if (CA_get_cmd_param_size(cmd_id, n) != param_size) return &ret; @@ -158,18 +157,18 @@ uint16_t* CCP_get_2byte_param_from_packet(const CTCP* packet, uint8_t n) return &ret; } -uint32_t* CCP_get_4byte_param_from_packet(const CTCP* packet, uint8_t n) +uint32_t* CCP_get_4byte_param_from_packet(const CommonCmdPacket* packet, uint8_t n) { static uint32_t ret; uint16_t offset = 0; CMD_CODE cmd_id = CCP_get_id(packet); uint8_t param_size = 4; - CTCP_UTIL_ACK ack; + CCP_UTIL_ACK ack; ret = 0; ack = CCP_calc_param_offset_(cmd_id, n, &offset); - if (ack != CTCP_UTIL_ACK_OK) return &ret; + if (ack != CCP_UTIL_ACK_OK) return &ret; if (CA_get_cmd_param_size(cmd_id, n) != param_size) return &ret; @@ -177,18 +176,18 @@ uint32_t* CCP_get_4byte_param_from_packet(const CTCP* packet, uint8_t n) return &ret; } -uint64_t* CCP_get_8byte_param_from_packet(const CTCP* packet, uint8_t n) +uint64_t* CCP_get_8byte_param_from_packet(const CommonCmdPacket* packet, uint8_t n) { static uint64_t ret; uint16_t offset = 0; CMD_CODE cmd_id = CCP_get_id(packet); uint8_t param_size = 8; - CTCP_UTIL_ACK ack; + CCP_UTIL_ACK ack; ret = 0; ack = CCP_calc_param_offset_(cmd_id, n, &offset); - if (ack != CTCP_UTIL_ACK_OK) return &ret; + if (ack != CCP_UTIL_ACK_OK) return &ret; if (CA_get_cmd_param_size(cmd_id, n) != param_size) return &ret; @@ -196,17 +195,17 @@ uint64_t* CCP_get_8byte_param_from_packet(const CTCP* packet, uint8_t n) return &ret; } -uint16_t CCP_get_raw_param_from_packet(const CTCP* packet, void* dest, uint16_t max_copy_len) +uint16_t CCP_get_raw_param_from_packet(const CommonCmdPacket* packet, void* dest, uint16_t max_copy_len) { uint16_t offset = 0; CMD_CODE cmd_id = CCP_get_id(packet); - CTCP_UTIL_ACK ack; + CCP_UTIL_ACK ack; int32_t copy_len; if (!CA_has_raw_param(cmd_id)) return 0; ack = CCP_calc_param_offset_(cmd_id, (uint8_t)(CA_get_cmd_param_num(cmd_id) - 1), &offset); - if (ack != CTCP_UTIL_ACK_OK) return 0; + if (ack != CCP_UTIL_ACK_OK) return 0; copy_len = CCP_get_param_len(packet) - offset; if (copy_len < 0) return 0; @@ -219,18 +218,18 @@ uint16_t CCP_get_raw_param_from_packet(const CTCP* packet, void* dest, uint16_t return (uint16_t)copy_len; } -CTCP_UTIL_ACK CCP_calc_param_offset_(CMD_CODE cmd_id, uint8_t n, uint16_t* offset) +CCP_UTIL_ACK CCP_calc_param_offset_(CMD_CODE cmd_id, uint8_t n, uint16_t* offset) { uint8_t i; - if (cmd_id >= CA_MAX_CMDS) return CTCP_UTIL_ACK_PARAM_ERR; - if (CA_get_cmd_param_num(cmd_id) <= n) return CTCP_UTIL_ACK_PARAM_ERR; + if (cmd_id >= CA_MAX_CMDS) return CCP_UTIL_ACK_PARAM_ERR; + if (CA_get_cmd_param_num(cmd_id) <= n) return CCP_UTIL_ACK_PARAM_ERR; *offset = 0; for (i = 0; i < n; ++i) { (*offset) += CA_get_cmd_param_size(cmd_id, i); } - return CTCP_UTIL_ACK_OK; + return CCP_UTIL_ACK_OK; } #pragma section diff --git a/TlmCmd/common_tlm_cmd_packet_util.h b/TlmCmd/common_cmd_packet_util.h similarity index 73% rename from TlmCmd/common_tlm_cmd_packet_util.h rename to TlmCmd/common_cmd_packet_util.h index 89ea58cca..99a591d7b 100644 --- a/TlmCmd/common_tlm_cmd_packet_util.h +++ b/TlmCmd/common_cmd_packet_util.h @@ -1,64 +1,66 @@ /** * @file - * @brief CTCP の汎用Util + * @brief CCP の汎用 Utility */ -#ifndef COMMON_TLM_CMD_PACKET_UTIL_H_ -#define COMMON_TLM_CMD_PACKET_UTIL_H_ +#ifndef COMMON_CMD_PACKET_UTIL_H_ +#define COMMON_CMD_PACKET_UTIL_H_ -#include "common_tlm_cmd_packet.h" +#include "common_cmd_packet.h" +#include "block_command_table.h" +#include /** - * @enum CTCP_UTIL_ACK - * @brief CTCP Utility の汎用返り値 + * @enum CCP_UTIL_ACK + * @brief CCP Utility の汎用返り値 * @note uint8_t を想定 */ typedef enum { - CTCP_UTIL_ACK_OK = 0, //!< 正常終了 - CTCP_UTIL_ACK_PARAM_ERR //!< パラメタエラー -} CTCP_UTIL_ACK; + CCP_UTIL_ACK_OK = 0, //!< 正常終了 + CCP_UTIL_ACK_PARAM_ERR //!< パラメタエラー +} CCP_UTIL_ACK; /** - * @brief App実行コマンドを生成 - * @param[in,out] packet: CTCP + * @brief App 実行コマンドを生成 + * @param[in,out] packet: CCP * @param[in] ti: TI * @param[in] id: AR_APP_ID * @return void */ -void CCP_form_app_cmd(CTCP* packet, cycle_t ti, AR_APP_ID id); +void CCP_form_app_cmd(CommonCmdPacket* packet, cycle_t ti, AR_APP_ID id); /** * @brief Realtime command を生成 * @note 引数が不正なとき, packet は NOP RTC を返す - * @param[in,out] packet: CTCP + * @param[in,out] packet: CCP * @param[in] packet: CMD_CODE - * @param[in] *param: パラメタ + * @param[in] param: パラメタ * @param[in] len: パラメタ長 - * @return CTCP_UTIL_ACK + * @return CCP_UTIL_ACK */ -CTCP_UTIL_ACK CCP_form_rtc(CTCP* packet, CMD_CODE cmd_id, const uint8_t* param, uint16_t len); +CCP_UTIL_ACK CCP_form_rtc(CommonCmdPacket* packet, CMD_CODE cmd_id, const uint8_t* param, uint16_t len); /** * @brief Timeline command を生成 * @note 引数が不正なとき, packet は NOP TLC を返す - * @param[in,out] packet: CTCP + * @param[in,out] packet: CCP * @param[in] ti: TI * @param[in] packet: CMD_CODE - * @param[in] *param: パラメタ + * @param[in] param: パラメタ * @param[in] len: パラメタ長 - * @return CTCP_UTIL_ACK + * @return CCP_UTIL_ACK */ -CTCP_UTIL_ACK CCP_form_tlc(CTCP* packet, cycle_t ti, CMD_CODE cmd_id, const uint8_t* param, uint16_t len); +CCP_UTIL_ACK CCP_form_tlc(CommonCmdPacket* packet, cycle_t ti, CMD_CODE cmd_id, const uint8_t* param, uint16_t len); /** * @brief BC展開 command を生成 * @note 引数が不正なとき, packet は NOP RTC を返す - * @param[in,out] packet: CTCP + * @param[in,out] packet: CCP * @param[in] tl_no: Timeline no * @param[in] block_no: BC ID - * @return CTCP_UTIL_ACK + * @return CCP_UTIL_ACK */ -CTCP_UTIL_ACK CCP_form_block_deploy_cmd(CTCP* packet, uint8_t tl_no, bct_id_t block_no); +CCP_UTIL_ACK CCP_form_block_deploy_cmd(CommonCmdPacket* packet, uint8_t tl_no, bct_id_t block_no); /** * @brief Realtime Command から Timeline Command へ変換 @@ -66,7 +68,7 @@ CTCP_UTIL_ACK CCP_form_block_deploy_cmd(CTCP* packet, uint8_t tl_no, bct_id_t bl * @param[in] ti: TI * @return void */ -void CCP_convert_rtc_to_tlc(CTCP* packet, cycle_t ti); +void CCP_convert_rtc_to_tlc(CommonCmdPacket* packet, cycle_t ti); /** * @brief CCP packet から,サイズが 1 byte のコマンド引数を取得する @@ -76,7 +78,7 @@ void CCP_convert_rtc_to_tlc(CTCP* packet, cycle_t ti); * @param[in] n: N番目の引数 (0起算) * @return パラメタを保持したポインタ(型は意味をもってない) */ -uint8_t* CCP_get_1byte_param_from_packet(const CTCP* packet, uint8_t n); +uint8_t* CCP_get_1byte_param_from_packet(const CommonCmdPacket* packet, uint8_t n); /** * @brief CCP packet から,サイズが 2 byte のコマンド引数を取得する @@ -86,7 +88,7 @@ uint8_t* CCP_get_1byte_param_from_packet(const CTCP* packet, uint8_t n); * @param[in] n: N番目の引数 (0起算) * @return パラメタを保持したポインタ(型は意味をもってない) */ -uint16_t* CCP_get_2byte_param_from_packet(const CTCP* packet, uint8_t n); +uint16_t* CCP_get_2byte_param_from_packet(const CommonCmdPacket* packet, uint8_t n); /** * @brief CCP packet から,サイズが 4 byte のコマンド引数を取得する @@ -96,7 +98,7 @@ uint16_t* CCP_get_2byte_param_from_packet(const CTCP* packet, uint8_t n); * @param[in] n: N番目の引数 (0起算) * @return パラメタを保持したポインタ(型は意味をもってない) */ -uint32_t* CCP_get_4byte_param_from_packet(const CTCP* packet, uint8_t n); +uint32_t* CCP_get_4byte_param_from_packet(const CommonCmdPacket* packet, uint8_t n); /** * @brief CCP packet から,サイズが 8 byte のコマンド引数を取得する @@ -106,7 +108,7 @@ uint32_t* CCP_get_4byte_param_from_packet(const CTCP* packet, uint8_t n); * @param[in] n: N番目の引数 (0起算) * @return パラメタを保持したポインタ(型は意味をもってない) */ -uint64_t* CCP_get_8byte_param_from_packet(const CTCP* packet, uint8_t n); +uint64_t* CCP_get_8byte_param_from_packet(const CommonCmdPacket* packet, uint8_t n); /** * @brief CCP packet から,RAW コマンド引数を取得する @@ -116,7 +118,7 @@ uint64_t* CCP_get_8byte_param_from_packet(const CTCP* packet, uint8_t n); * @param[in] max_copy_len : コピーする最大長. 0 の場合,無制限 * @return コピーした長さ */ -uint16_t CCP_get_raw_param_from_packet(const CTCP* packet, void* dest, uint16_t max_copy_len); +uint16_t CCP_get_raw_param_from_packet(const CommonCmdPacket* packet, void* dest, uint16_t max_copy_len); /** * @def CCP_get_param_from_packet(packet, n, type) diff --git a/TlmCmd/common_tlm_cmd_packet.h b/TlmCmd/common_tlm_cmd_packet.h index 7d14c8243..e8f838575 100644 --- a/TlmCmd/common_tlm_cmd_packet.h +++ b/TlmCmd/common_tlm_cmd_packet.h @@ -1,263 +1,130 @@ /** * @file - * @brief CTCP の宣言 - * @note CTCP: Common Tlm Cmd Packet - * @note CCP: Common Cmd Packet - * @note CTP: Common Tlm Packet + * @brief CTCP 関連基本関数の宣言 + * @note CTCP: CommonTlmCmdPacket + * @note CTP: CommonTlmPacket + * @note CCP: CommonCmdPacket */ #ifndef COMMON_TLM_CMD_PACKET_H_ #define COMMON_TLM_CMD_PACKET_H_ -#include // for size_t -#include "../System/TimeManager/obc_time.h" -#include -#include -#include - #include #include +#include "./common_tlm_packet.h" +#include "./common_cmd_packet.h" -/** - * @enum CCP_EXEC_STS - * @brief コマンド実行結果コード - * @note uint8_t を想定 - */ +// ここで APID を定義する +/* 例 +// FIXME: CCSDS JAXA 標準になおす typedef enum { - CCP_EXEC_SUCCESS = 0, /*!< コマンド実行成功 - なお,コマンドの実行の結果なので,その後の処理が失敗しても,コマンドが実行されていればこれを返す */ - CCP_EXEC_ILLEGAL_LENGTH, //!< コマンド実行時のコマンド引数長エラー - CCP_EXEC_ILLEGAL_PARAMETER, //!< コマンド実行時のパラメタエラー - CCP_EXEC_ILLEGAL_CONTEXT, //!< コマンド実行時のその他のエラー - CCP_EXEC_CMD_NOT_DEFINED, //!< cmdExec で用いる - CCP_EXEC_ROUTING_FAILED, //!< command router で用いる - CCP_EXEC_PACKET_FMT_ERR, //!< packet handler で用いる - CCP_EXEC_UNKNOWN //!< 内部処理用.使わない. -} CCP_EXEC_STS; - - -#include "block_command_table.h" // CTCP, CCP_EXEC_STS の定義よりあとに include + APID_MOBC_CMD = 0x210, // 01000010000b: + APID_AOBC_CMD = 0x211, // 01000010001b: + APID_TCAL_TLM = 0x410, // 10000010000b: APID for TIME CARIBLATION TLM + APID_MIS_TLM = 0x510, // 10100010000b: APID for MIS TLM + APID_DUMP_TLM = 0x710, // 11100010000b: APID for DUMP TLM + APID_FILL_PKT = 0x7ff, // 11111111111b: APID for FILL PACKET + APID_UNKNOWN +} APID; +*/ +#include /** - * @enum CTCP_TC_DSC (Tlm Cmd Discrimination) - * @brief tlm or cmd を規定 + * @enum CTCP_PACKET_TYPE + * @brief tlm (CTP) or cmd (CCP) を規定 * @note uint8_tを想定 */ typedef enum { - CTCP_TC_DSC_CMD, - CTCP_TC_DSC_TLM, - CTCP_TC_DSC_UNKNOWN -} CTCP_TC_DSC; + CTCP_PACKET_TYPE_CMD, + CTCP_PACKET_TYPE_TLM, + CTCP_PACKET_TYPE_UNKNOWN +} CTCP_PACKET_TYPE; -/** - * @enum CCP_EXEC_TYPE - * @brief コマンド実行種別 - * @note 0x0*を想定(上位4bitは他のC2Aを搭載したボード用に転送するために使うため) - * その定義はTCP_DEST_TYPEにある - * @note TCP_CMD_EXEC_TYPE と CCP_EXEC_TYPE の定義は一致 (正確には、前者は後者に含まれている) - * CCP_EXEC_TYPE CCP_get_exec_type(const CTCP* packet) を参照 - * @note GSからのOBC.TLや,C2A内のCCP_form_tlcはすべてTL0扱いになる - */ -typedef enum -{ - CCP_EXEC_TYPE_GS, //!< GS : Ground Station Command - CCP_EXEC_TYPE_TL0, //!< TL : Timeline Command - CCP_EXEC_TYPE_BC, //!< BC : Block Command - CCP_EXEC_TYPE_RT, //!< RT : Realtime Command - CCP_EXEC_TYPE_UTL, //!< UTL: Unixtime Timeline Command - CCP_EXEC_TYPE_TL1, - CCP_EXEC_TYPE_TL2, - CCP_EXEC_TYPE_UNKNOWN -} CCP_EXEC_TYPE; /** - * @enum CTP_DEST_FLAG - * @brief 配送先指定.テレメのキューを指定するフラグ. - * @note 4bitのフラグ.重送できるように,bitごとのフラグとする + * @brief 有効なパケットかチェックする + * @note NULL チェックも行う + * @note OBC の外から来たパケットな可能性もあるので,このC2Aで扱えるサイズかもチェックする + * @param packet: CTCP + * @retval 1: True + * @retval 0: False */ -typedef enum -{ - CTP_DEST_FLAG_HK = 0x01, // 00000001b: Housekeeping Telemetry - CTP_DEST_FLAG_MS = 0x02, // 00000010b: Mission Telemetry - CTP_DEST_FLAG_ST = 0x04, // 00000100b: Stored Telemetry - CTP_DEST_FLAG_RP = 0x08, // 00001000b: Replay Telemetry - CTP_DEST_FLAG_UNKNOWN -} CTP_DEST_FLAG; - - -// ******************** -// CTCP getter/setter -// ******************** +int CTCP_is_valid_packet(const CommonTlmCmdPacket* packet); /** * @brief tlm か cmd かを判断 - * @param packet: CTCP packet - * @return CTCP_TC_DSC - */ -CTCP_TC_DSC CTCP_get_tc_dsc(const CTCP* packet); - -/** - * @brief CTCP をコピー - * @note user実装次第だが,高速化のためすすべてではなく必要最低限しかコピーしない場合もある - * @param[in,out] dest: コピー先 CTCP - * @param[in] src: コピー元 CTCP - * @return void - */ -void CTCP_copy_packet(CTCP* dest, const CTCP* src); - - -// ******************* -// CCP getter/setter -// ******************* - -/** - * @brief TI を取得 - * @param packet: CTCP packet - * @return ti - */ -cycle_t CCP_get_ti(const CTCP* packet); - -/** - * @brief TI を設定 - * @param[in,out] packet: CTCP - * @param[in] ti: TI - * @return void - */ -void CCP_set_ti(CTCP* packet, cycle_t ti); - -/** - * @brief 宛先 (TCPではAPID) を取得 - * @param packet: CTCP packet - * @return CTCP_DEST_ID - */ -CTCP_DEST_ID CCP_get_dest_id(const CTCP* packet); - -/** - * @brief 宛先 (TCPではAPID) を設定 - * @param[in,out] packet: CTCP - * @param[in] id: 宛先 - * @return void + * @param packet: CTCP + * @return CTCP_PACKET_TYPE */ -void CCP_set_dest_id(CTCP* packet, CTCP_DEST_ID id); +CTCP_PACKET_TYPE CTCP_get_packet_type(const CommonTlmCmdPacket* packet); /** - * @brief EXEC_TYPE を取得 - * @param packet: CTCP packet - * @return CCP_EXEC_TYPE - */ -CCP_EXEC_TYPE CCP_get_exec_type(const CTCP* packet); - -/** - * @brief EXEC_TYPE を設定 - * @param[in,out] packet: CTCP - * @param[in] type: EXEC_TYPE - * @return void - */ -void CCP_set_exec_type(CTCP* packet, CCP_EXEC_TYPE type); - -/** - * @brief DEST_TYPE を取得 - * @param packet: CTCP packet - * @return CCP_DEST_TYPE - * @note 2021/01/22に CCP_EXEC_TYPE の上位4bitを拝借する形で追加実装 - */ -CCP_DEST_TYPE CCP_get_dest_type(const CTCP* packet); - -/** - * @brief DEST_TYPE を設定 - * @param[in,out] packet: CTCP - * @param[in] type: DEST_TYPE - * @return void - * @note 2021/01/22に CCP_EXEC_TYPE の上位4bitを拝借する形で追加実装 + * @brief パケット長を取得 + * @param packet: CTCP + * @return packet len */ -void CCP_set_dest_type(CTCP* packet, CCP_DEST_TYPE type); +uint16_t CTCP_get_packet_len(const CommonTlmCmdPacket* packet); /** - * @brief CMD ID を取得 - * @param packet: CTCP packet - * @return CMD_CODE + * @brief APID を取得 + * @param packet: CTCP + * @return APID */ -CMD_CODE CCP_get_id(const CTCP* packet); +APID CTCP_get_apid(const CommonTlmCmdPacket* packet); /** - * @brief CMD ID を設定 + * @brief APID を設定 * @param[in,out] packet: CTCP - * @param[in] id: CMD_CODE + * @param[in] apid: APID * @return void */ -void CCP_set_id(CTCP* packet, CMD_CODE id); +void CTCP_set_apid(CommonTlmCmdPacket* packet, APID apid); /** - * @brief CTCP (CCP) のパケット長を取得 - * @param packet: CTCP packet - * @return packet len - */ -uint16_t CCP_get_packet_len(const CTCP* packet); - -/** - * @brief CMD パラメタ長を取得 - * @param packet: CTCP packet - * @return param len - */ -uint16_t CCP_get_param_len(const CTCP* packet); - -/** - * @brief CMD パラメタ長の最大値を取得 - * @return max param len - */ -uint16_t CCP_get_max_param_len(void); - -/** - * @brief 先頭のパラメタのポインタを取得 - * @param packet: CTCP packet - * @return *param_head - */ -const uint8_t* CCP_get_param_head(const CTCP* packet); - -/** - * @brief パラメタを設定 - * @param[in,out] packet: CTCP - * @param[in] param: パラメタ配列のポインタ - * @param[in] len: パラメタ長 + * @brief CommonTlmCmdPacket をコピー + * @note user実装次第だが,高速化のためすすべてではなく必要最低限しかコピーしない場合もある + * @param[in,out] dest: コピー先 CTCP + * @param[in] src: コピー元 CTCP * @return void */ -void CCP_set_param(CTCP* packet, const uint8_t* param, uint16_t len); +void CTCP_copy_packet(CommonTlmCmdPacket* dest, const CommonTlmCmdPacket* src); /** - * @brief 共通部分の Header を構築 - * @param[in,out] packet: CTCP - * @return void + * @brief CTCP を CTP に変換(キャスト) + * @note NULL が返る可能性があるので,呼び出し元でしっかりアサーションすること! + * @param[in] ctcp: CTCP + * @retval CTP: 変換成功時 + * @retval NULL: エラー時 */ -void CCP_set_common_hdr(CTCP* packet); - - -// ******************* -// CTP getter/setter -// ******************* +const CommonTlmPacket* CTCP_convert_to_ctp(const CommonTlmCmdPacket* ctcp); /** - * @brief CTP_DEST_FLAG を取得 - * @param packet: CTCP packet - * @return CTP_DEST_FLAG + * @brief CTP を CTCP に変換(キャスト) + * @note NULL が返る可能性があるので,呼び出し元でしっかりアサーションすること! + * @param[in] ctcp: CTP + * @retval CTCP: 変換成功時 + * @retval NULL: エラー時 */ -CTP_DEST_FLAG CTP_get_dest_flag(const CTCP* packet); +const CommonTlmCmdPacket* CTCP_convert_from_ctp(const CommonTlmPacket* ctp); /** - * @brief CTP_DEST_FLAG を設定 - * @param[in,out] packet: CTCP - * @param[in] flag: CTP_DEST_FLAG - * @return void + * @brief CTCP を CCP に変換(キャスト) + * @note NULL が返る可能性があるので,呼び出し元でしっかりアサーションすること! + * @param[in] ctcp: CTCP + * @retval CCP: 変換成功時 + * @retval NULL: エラー時 */ -void CTP_set_dest_flag(CTCP* packet, CTP_DEST_FLAG flag); +const CommonCmdPacket* CTCP_convert_to_ccp(const CommonTlmCmdPacket* ctcp); /** - * @brief ADU分割なしの場合のUser Data先頭のポインタを取得 - * @param packet: CTCP packet - * @note TCPの場合,ADU分割なし時のポインタを取得 - * @note この関数で取得したポインタ経由でtlmのデータをセットする事があるため,constをつけていない + * @brief CCP を CTCP に変換(キャスト) + * @note NULL が返る可能性があるので,呼び出し元でしっかりアサーションすること! + * @param[in] ctcp: CCP + * @retval CTCP: 変換成功時 + * @retval NULL: エラー時 */ -uint8_t* CTP_get_user_data_head(CTCP* packet); +const CommonTlmCmdPacket* CTCP_convert_from_ccp(const CommonCmdPacket* ccp); #endif diff --git a/TlmCmd/common_tlm_packet.h b/TlmCmd/common_tlm_packet.h new file mode 100644 index 000000000..f6ea8d229 --- /dev/null +++ b/TlmCmd/common_tlm_packet.h @@ -0,0 +1,73 @@ +/** + * @file + * @brief CTP 関連基本関数の宣言 + * @note CTP: CommonTlmPacket + */ +#ifndef COMMON_TLM_PACKET_H_ +#define COMMON_TLM_PACKET_H_ + +#include + +// ここで APID を定義する +// 詳細は common_tlm_cmd_packet.h を参照 +#include + + +/** + * @enum CTP_DEST_FLAG + * @brief 配送先指定.テレメのキューを指定するフラグ. + * @note 4bitのフラグ.重送できるように,bitごとのフラグとする + */ +typedef enum +{ + CTP_DEST_FLAG_HK = 0x01, // 00000001b: Housekeeping Telemetry + CTP_DEST_FLAG_MS = 0x02, // 00000010b: Mission Telemetry + CTP_DEST_FLAG_ST = 0x04, // 00000100b: Stored Telemetry + CTP_DEST_FLAG_RP = 0x08, // 00001000b: Replay Telemetry + CTP_DEST_FLAG_UNKNOWN +} CTP_DEST_FLAG; + + + +/** + * @brief 有効なパケットかチェックする + * @note NULL チェックも行う + * @note OBC の外から来たパケットな可能性もあるので,このC2Aで扱えるサイズかもチェックする + * @param packet: CTP + * @retval 1: True + * @retval 0: False + */ +int CTP_is_valid_packet(const CommonTlmPacket* packet); + +/** + * @brief CTP_DEST_FLAG を取得 + * @param packet: CTP + * @return CTP_DEST_FLAG + */ +CTP_DEST_FLAG CTP_get_dest_flag(const CommonTlmPacket* packet); + +/** + * @brief CTP_DEST_FLAG を設定 + * @param[in,out] packet: CTP + * @param[in] flag: CTP_DEST_FLAG + * @return void + */ +void CTP_set_dest_flag(CommonTlmPacket* packet, CTP_DEST_FLAG flag); + +/** + * @brief パケット長を取得 + * @param packet: CTP + * @return packet len + */ +uint16_t CTP_get_packet_len(const CommonTlmPacket* packet); + +/** + * @brief ADU 分割なしの場合の User Data 先頭のポインタを取得 + * @param packet: CTP + * @note TCP の場合, ADU 分割なし時のポインタを取得 + * @note FIXME: この関数で取得したポインタ経由で tlm のデータをセットする事があるため, const をつけていない + */ +uint8_t* CTP_get_user_data_head(CommonTlmPacket* packet); + + +#endif diff --git a/TlmCmd/packet_handler.c b/TlmCmd/packet_handler.c index e02f5d15f..21fbba4ad 100644 --- a/TlmCmd/packet_handler.c +++ b/TlmCmd/packet_handler.c @@ -66,12 +66,12 @@ void PH_init(void) // Cmd_GENERATE_TLMとかも. PH_ACK PH_analyze_packet(const CTCP* packet) { - switch (CTCP_get_tc_dsc(packet)) + switch (CTCP_get_packet_type(packet)) { - case CTCP_TC_DSC_CMD: + case CTCP_PACKET_TYPE_CMD: return PH_analyze_cmd_(packet); - case CTCP_TC_DSC_TLM: + case CTCP_PACKET_TYPE_TLM: return PH_analyze_tlm_(packet); default: @@ -166,13 +166,14 @@ static PH_ACK PH_analyze_tlm_(const CTCP* packet) CCP_EXEC_STS PH_dispatch_command(const CTCP* packet) { - if (CTCP_get_tc_dsc(packet) != CTCP_TC_DSC_CMD) + if (CTCP_get_packet_type(packet) != CTCP_PACKET_TYPE_CMD) { // CMD以外のパケットが来たら異常判定。 return CCP_EXEC_PACKET_FMT_ERR; } - if (CCP_get_dest_id(packet) == CTCP_MY_DST_ID) + // FIXME: CTCP, SpacePacket 整理で直す + if (CCP_get_apid(packet) == CTCP_MY_DST_ID) { // 自分宛てのコマンドの場合は対応処理を呼び出し。 return CA_execute_cmd(packet); diff --git a/TlmCmd/telemetry_generator.c b/TlmCmd/telemetry_generator.c index fd3bd6ddb..3fc5ee98b 100644 --- a/TlmCmd/telemetry_generator.c +++ b/TlmCmd/telemetry_generator.c @@ -44,7 +44,7 @@ CCP_EXEC_STS Cmd_GENERATE_TLM(const CTCP* packet) if (len < 0) return CCP_EXEC_ILLEGAL_CONTEXT; // TODO: lenがマイナスの値たちをどうするか? // TCPacketヘッダ設定 - TCP_TLM_setup_primary_hdr(&tcp_, TCP_APID_MIS_TLM, (uint16_t)(len + 7)); + TCP_TLM_setup_primary_hdr(&tcp_, APID_MIS_TLM, (uint16_t)(len + 7)); TCP_TLM_set_ti(&tcp_, (uint32_t)(TMGR_get_master_total_cycle())); TCP_TLM_set_category(&tcp_, category); // パラメータによる指定 TCP_TLM_set_packet_id(&tcp_, id);