Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

C2A内のpacket標準としてCCSDS Space Packet を実装する.そして,Common Packet を抽象化する. #217

Merged
merged 19 commits into from
Jan 31, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Applications/divided_cmd_utility.c
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ DCU_ACK DCU_register_next(CMD_CODE cmd_code, const uint8_t* param, uint16_t len)

ret = CCP_form_rtc(&DCU_packet_, cmd_code, param, len);
if (ret != CCP_UTIL_ACK_OK) return DCU_ACK_ERR;
if (PH_analyze_packet(&DCU_packet_) != PH_REGISTERED) // FIXME: CTCP, SpacePacket 整理で直す
if (PH_analyze_cmd_packet(&DCU_packet_) != PH_REGISTERED)
{
return DCU_ACK_ERR;
}
Expand Down
12 changes: 12 additions & 0 deletions Applications/memory_dump.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ static void MEM_init_(void);

static uint8_t MEM_get_next_adu_counter_(void);

// FIXME: CTCP 大改修が終わったら直す
// https://github.com/ut-issl/c2a-core/pull/217
#if 0
static CCP_EXEC_STS MEM_dump_region_(uint8_t category,
uint8_t num_dumps);

Expand All @@ -35,6 +38,7 @@ static void MEM_setup_header_(TCP* packet,

static void MEM_send_packet_(const CommonTlmPacket* packet,
uint8_t num_dumps);
#endif

AppInfo MEM_create_app(void)
{
Expand Down Expand Up @@ -84,6 +88,9 @@ CCP_EXEC_STS Cmd_MEM_SET_REGION(const CommonCmdPacket* packet)
return CCP_EXEC_SUCCESS;
}

// FIXME: CTCP 大改修が終わったら直す
// https://github.com/ut-issl/c2a-core/pull/217
#if 0
CCP_EXEC_STS Cmd_MEM_DUMP_REGION_SEQ(const CommonCmdPacket* packet)
{
const uint8_t* param = CCP_get_param_head(packet);
Expand Down Expand Up @@ -188,6 +195,7 @@ CCP_EXEC_STS Cmd_MEM_DUMP_SINGLE(const CommonCmdPacket* packet)

return CCP_EXEC_SUCCESS;
}
#endif

CCP_EXEC_STS Cmd_MEM_LOAD(const CommonCmdPacket* packet)
{
Expand Down Expand Up @@ -266,6 +274,9 @@ static uint8_t MEM_get_next_adu_counter_(void)
return ++adu_counter_;
}

// FIXME: CTCP 大改修が終わったら直す
// https://github.com/ut-issl/c2a-core/pull/217
#if 0
static CCP_EXEC_STS MEM_dump_region_(uint8_t category,
uint8_t num_dumps)
{
Expand Down Expand Up @@ -406,5 +417,6 @@ static void MEM_send_packet_(const CommonTlmPacket* packet,
PH_analyze_packet(packet); // FIXME: CTCP, SpacePacket 整理で直す
}
}
#endif

#pragma section
4 changes: 4 additions & 0 deletions Applications/memory_dump.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ AppInfo MEM_create_app(void);
// 自分の解釈をコメントとして追加
CCP_EXEC_STS Cmd_MEM_SET_REGION(const CommonCmdPacket* packet);

// FIXME: CTCP 大改修が終わったら直す
// https://github.com/ut-issl/c2a-core/pull/217
#if 0
CCP_EXEC_STS Cmd_MEM_DUMP_REGION_SEQ(const CommonCmdPacket* packet);
// 1パケットに入り切らない場合は,最初のADU分割された最初のパケットのみダンプ
// もう一度送ると,その次のパケットがダンプ
Expand All @@ -45,6 +48,7 @@ CCP_EXEC_STS Cmd_MEM_DUMP_REGION_RND(const CommonCmdPacket* packet);
CCP_EXEC_STS Cmd_MEM_DUMP_SINGLE(const CommonCmdPacket* packet);
// アドレスを指定して,ダンプ?
// Cmd_MEM_SET_REGION は無視?
#endif

CCP_EXEC_STS Cmd_MEM_LOAD(const CommonCmdPacket* packet);
// MEMにアップリンクして書き込み
Expand Down
4 changes: 2 additions & 2 deletions Applications/telemetry_manager.c
Original file line number Diff line number Diff line change
Expand Up @@ -567,7 +567,7 @@ CCP_EXEC_STS Cmd_TLM_MGR_START_TLM(const CommonCmdPacket* packet)

// master bc 展開
CCP_form_block_deploy_cmd(&TLM_MGR_packet_, TL_ID_DEPLOY_TLM, master_bc_id);
PH_analyze_packet(&TLM_MGR_packet_); // FIXME: CTCP, SpacePacket 整理で直す
PH_analyze_cmd_packet(&TLM_MGR_packet_);

return CCP_EXEC_SUCCESS;
}
Expand Down Expand Up @@ -614,7 +614,7 @@ CCP_EXEC_STS Cmd_TLM_MGR_CLEAR_TLM_TL(const CommonCmdPacket* packet)

param[0] = TL_ID_DEPLOY_TLM;
CCP_form_rtc(&TLM_MGR_packet_, Cmd_CODE_TLCD_CLEAR_ALL_TIMELINE, param, 1);
PH_analyze_packet(&TLM_MGR_packet_); // FIXME: CTCP, SpacePacket 整理で直す
PH_analyze_cmd_packet(&TLM_MGR_packet_);

return CCP_EXEC_SUCCESS;
}
Expand Down
4 changes: 3 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@ set(C2A_SRCS
TlmCmd/packet_list.c
TlmCmd/telemetry_frame.c
TlmCmd/telemetry_generator.c
TlmCmd/Ccsds/TCPacket.c
TlmCmd/Ccsds/cmd_space_packet.c
TlmCmd/Ccsds/space_packet.c
TlmCmd/Ccsds/tlm_space_packet.c
)

if(BUILD_C2A_AS_CXX)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,9 @@ static void DI_GS_mst_packet_handler_(void)
// 本当なら max(今の FIFO の空き, 残り時間で実行可能な数) とかしたい
for (i = 0; i < CCSDS_FIFO_SIZE; ++i)
{
T2M_ACK ack = T2M_form_m_pdu(&DI_GS_ms_tlm_packet_handler_.tc_packet_to_m_pdu, &PH_ms_tlm_list, &DI_GS_ms_tlm_packet_handler_.vcdu.m_pdu);
T2M_ACK ack = T2M_form_m_pdu(&DI_GS_ms_tlm_packet_handler_.tc_packet_to_m_pdu,
&PH_ms_tlm_list,
&DI_GS_ms_tlm_packet_handler_.vcdu.m_pdu);
if (ack != T2M_SUCCESS) return;

// Realtime VCDU カウンタの設定
Expand Down Expand Up @@ -111,7 +113,9 @@ static void DI_GS_rpt_packet_handler_(void)
// 本当なら max(今の FIFO の空き, 残り時間で実行可能な数) とかしたい
for (i = 0; i < CCSDS_FIFO_SIZE; ++i)
{
T2M_ACK ack = T2M_form_m_pdu(&DI_GS_rp_tlm_packet_handler_.tc_packet_to_m_pdu, &PH_rp_tlm_list, &DI_GS_rp_tlm_packet_handler_.vcdu.m_pdu);
T2M_ACK ack = T2M_form_m_pdu(&DI_GS_rp_tlm_packet_handler_.tc_packet_to_m_pdu,
&PH_rp_tlm_list,
&DI_GS_rp_tlm_packet_handler_.vcdu.m_pdu);
if (ack != T2M_SUCCESS) return;

// Replay VCDU カウンタの設定
Expand Down
14 changes: 10 additions & 4 deletions Examples/minimum_user_for_s2e/src/src_user/Drivers/Com/gs.c
Original file line number Diff line number Diff line change
Expand Up @@ -213,19 +213,25 @@ static DS_ERR_CODE GS_analyze_rec_data_(DS_StreamConfig* p_stream_config, void*
const uint8_t* gs_rx_data = DSSC_get_rx_frame(p_stream_config);
const TCF* tc_frame = (const TCF*)gs_rx_data; // 非自明なcast
GS_Driver* gs_driver = (GS_Driver*)p_driver;
int driver_index;
GS_PORT_TYPE driver_index;

// アドレス計算で CCSDS か UART か判別
if ((uint32_t)p_stream_config < (uint32_t)&gs_driver->driver_uart) driver_index = GS_PORT_TYPE_CCSDS;
else driver_index = GS_PORT_TYPE_UART;
if ((uint32_t)p_stream_config < (uint32_t)&gs_driver->driver_uart)
{
driver_index = GS_PORT_TYPE_CCSDS;
}
else
{
driver_index = GS_PORT_TYPE_UART;
}

gs_driver->info[driver_index].tc_frame_validate_status = GS_validate_tc_frame(tc_frame);
if (gs_driver->info[driver_index].tc_frame_validate_status != GS_VALIDATE_ERR_OK)
{
return DS_ERR_CODE_ERR;
}

gs_driver->info[driver_index].cmd_ack = PH_analyze_packet(&tc_frame->tcs.tcp); // 受信コマンドパケット解析
gs_driver->info[driver_index].cmd_ack = PH_analyze_cmd_packet(&tc_frame->tcs.tcp); // 受信コマンドパケット解析

return DS_ERR_CODE_OK;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
static GS_VALIDATE_ERR GS_check_tcf_header_(const TCF* tc_frame);
static GS_VALIDATE_ERR GS_check_tcf_contents_(const TCF* tc_frame);
static GS_VALIDATE_ERR GS_check_tcs_headers_(const TCS* tc_segment);
static GS_VALIDATE_ERR GS_check_tcp_headers_(const TCP* tc_packet);
static GS_VALIDATE_ERR GS_check_cmd_space_packet_headers_(const CmdSpacePacket* csp);
static GS_VALIDATE_ERR GS_check_fecw_(const uint8_t* data, size_t len);

static GS_VALIDATE_ERR GS_check_ad_cmd_(const TCF* tc_frame);
Expand Down Expand Up @@ -77,26 +77,14 @@ static GS_VALIDATE_ERR GS_check_tcf_contents_(const TCF* tc_frame)
{
GS_VALIDATE_ERR ack;

// TCSegment Headerの固定値部分が妥当か確認する
// TCSegment Header の固定値部分が妥当か確認する
ack = GS_check_tcs_headers_(&tc_frame->tcs);
if (ack != GS_VALIDATE_ERR_OK) return ack;

// TCPacektのヘッダのうちTLM/CMD共通部分が妥当か確認する
ack = GS_check_tcp_headers_(&tc_frame->tcs.tcp);
// CmdSpacePacket のヘッダのうち共通部分が妥当か確認する
ack = GS_check_cmd_space_packet_headers_(&tc_frame->tcs.tcp);
if (ack != GS_VALIDATE_ERR_OK) return ack;

// TCPacketのPackte TypeがCommandかどうか確認する
if (TCP_get_type(&tc_frame->tcs.tcp) != TCP_TYPE_CMD)
{
return GS_VALIDATE_ERR_TCP_TYPE_IS_NOT_CMD;
}

// TCPacketのSequence Flagが単パケットか確認する
if (TCP_get_seq_flag(&tc_frame->tcs.tcp) != TCP_SEQ_SINGLE)
{
return GS_VALIDATE_ERR_TCP_SEQ_IS_NOT_SINGLE;
}

return GS_VALIDATE_ERR_OK;
}

Expand All @@ -115,25 +103,37 @@ static GS_VALIDATE_ERR GS_check_tcs_headers_(const TCS* tc_segment)
return GS_VALIDATE_ERR_OK;
}

static GS_VALIDATE_ERR GS_check_tcp_headers_(const TCP* tc_packet)
static GS_VALIDATE_ERR GS_check_cmd_space_packet_headers_(const CmdSpacePacket* csp)
{
APID apid;
// FIXME: 他の部分のチェックも入れる

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)
if (CSP_get_ver(csp) != SP_VER_1) return GS_VALIDATE_ERR_TCP_VER;
if (CSP_get_2nd_hdr_flag(csp) != SP_2ND_HDR_FLAG_PRESENT)
{
// ここではSecondary Headerが必須。
return GS_VALIDATE_ERR_TCP_2ND_HDR_FLAG;
}

apid = TCP_get_apid(tc_packet);
if (CSP_get_type(csp) != SP_TYPE_CMD)
{
return GS_VALIDATE_ERR_TCP_TYPE_IS_NOT_CMD;
}

apid = CSP_get_apid(csp);
if ( !( apid == APID_MOBC_CMD
|| apid == APID_AOBC_CMD
|| apid == APID_TOBC_CMD ) )
{
return GS_VALIDATE_ERR_APID;
}

// Sequence Flag が単パケットか確認する
if (CSP_get_seq_flag(csp) != SP_SEQ_FLAG_SINGLE)
{
return GS_VALIDATE_ERR_TCP_SEQ_IS_NOT_SINGLE;
}

return GS_VALIDATE_ERR_OK;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ typedef enum
GS_VALIDATE_ERR_FARM1_SAME_NUMBER,
GS_VALIDATE_ERR_INVALID_BC_CMD
} GS_VALIDATE_ERR;
// FIXME: TCP → SpacePacket 大工事後に TCP を直す

/**
* @struct GS_ValidateInfo
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@
#undef SIZE_OF_EL_CLOG_COUNTER_T


#define EL_TLOG_TLM_PAGE_SIZE (36)
#define EL_TLOG_TLM_PAGE_SIZE (32)
#define EL_TLOG_TLM_PAGE_MAX_HIGH (4)
#define EL_TLOG_TLM_PAGE_MAX_MIDDLE (4)
#define EL_TLOG_TLM_PAGE_MAX_LOW (4)
#define EL_CLOG_TLM_PAGE_SIZE (22)
#define EL_CLOG_TLM_PAGE_SIZE (20)
#define EL_CLOG_TLM_PAGE_MAX_HIGH (4)
#define EL_CLOG_TLM_PAGE_MAX_MIDDLE (4)
#define EL_CLOG_TLM_PAGE_MAX_LOW (4)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,26 +6,21 @@
#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_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
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/**
* @file
* @brief CmdSpacePacket のユーザー設定
*/
#ifndef CMD_SPACE_PACKET_PARAMS_H_
#define CMD_SPACE_PACKET_PARAMS_H_

#undef CSP_2ND_HDR_VER_TO_USE

#define CSP_2ND_HDR_VER_TO_USE (CSP_2ND_HDR_VER_1)

#endif
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/**
* @file
* @brief SpacePacketの パケット型に関するユーザー設定
*/
#ifndef SPACE_PACKET_TYPEDEF_PARAMS_H_
#define SPACE_PACKET_TYPEDEF_PARAMS_H_

#undef TSP_MAX_LEN
#undef CSP_MAX_LEN

#define TSP_MAX_LEN (432)
#define CSP_MAX_LEN (128)

#endif

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/**
* @file
* @brief TlmSpacePacket のユーザー設定
*/
#ifndef TLM_SPACE_PACKET_PARAMS_H_
#define TLM_SPACE_PACKET_PARAMS_H_

#undef TSP_2ND_HDR_VER_TO_USE

#define TSP_2ND_HDR_VER_TO_USE (TSP_2ND_HDR_VER_1)

#endif
Loading