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

Secondary Header Version を Startup Counter に変更 #652

Open
wants to merge 11 commits into
base: develop
Choose a base branch
from
Open
64 changes: 63 additions & 1 deletion Applications/timeline_command_dispatcher.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@

static TimelineCommandDispatcher timeline_command_dispatcher_;
const TimelineCommandDispatcher* const timeline_command_dispatcher = &timeline_command_dispatcher_;
static BCExecStatus bc_exec_status_;
const BCExecStatus* const bc_exec_status = &bc_exec_status_;
static CommonCmdPacket TLCD_null_packet_;

static void TLCD_gs_init_(void);
Expand Down Expand Up @@ -53,6 +55,15 @@ static void TLCD_gs_init_(void)
timeline_command_dispatcher_.tlm_info_.page_no = 0;
timeline_command_dispatcher_.tlm_info_.updated_at = 0;

bc_exec_status_.last_exec_block_type = TLCD_ID_MAX;
bc_exec_status_.last_exec_block = 0;
bc_exec_status_.last_exec_time = 0;
bc_exec_status_.last_exec_status = CCP_EXEC_SUCCESS;
bc_exec_status_.last_err_block_type = TLCD_ID_MAX;
bc_exec_status_.last_err_block = 0;
bc_exec_status_.last_err_time = 0;
bc_exec_status_.last_err_status = CCP_EXEC_SUCCESS;

memset(&TLCD_null_packet_, 0, sizeof(TLCD_null_packet_));
TLCD_update_tl_list_for_tlm(TLCD_ID_FROM_GS);
}
Expand Down Expand Up @@ -247,35 +258,65 @@ CCP_CmdRet Cmd_TLCD_DEPLOY_BLOCK(const CommonCmdPacket* packet)
{
TLCD_ID id = (TLCD_ID)CCP_get_param_from_packet(packet, 0, uint8_t);
bct_id_t block_no = CCP_get_param_from_packet(packet, 1, bct_id_t);
cycle_t exec_time = TMGR_get_master_total_cycle();
PL_ACK ack;

if (CCP_get_param_len(packet) != (1 + SIZE_OF_BCT_ID_T))
{
// パラメータはTLライン番号(1Byte)とブロック番号。
// 一致しない場合は異常判定。

if (id != TLCD_ID_DEPLOY_TLM)
{
bc_exec_status_.last_err_block_type = id;
bc_exec_status_.last_err_block = block_no;
bc_exec_status_.last_err_time = exec_time;
bc_exec_status_.last_err_status = CCP_EXEC_ILLEGAL_LENGTH;
}
return CCP_make_cmd_ret_without_err_code(CCP_EXEC_ILLEGAL_LENGTH);
}

if (id >= TLCD_ID_MAX)
{
// 指定されたライン番号が存在しない場合は異常判定
if (id != TLCD_ID_DEPLOY_TLM)
{
bc_exec_status_.last_err_block_type = id;
bc_exec_status_.last_err_block = block_no;
bc_exec_status_.last_err_time = exec_time;
bc_exec_status_.last_err_status = CCP_EXEC_ILLEGAL_PARAMETER;
}
return CCP_make_cmd_ret_without_err_code(CCP_EXEC_ILLEGAL_PARAMETER);
}

if (block_no >= BCT_MAX_BLOCKS)
{
// 指定されたブロック番号が存在しない場合は異常判定
if (id != TLCD_ID_DEPLOY_TLM)
{
bc_exec_status_.last_err_block_type = id;
bc_exec_status_.last_err_block = block_no;
bc_exec_status_.last_err_time = exec_time;
bc_exec_status_.last_err_status = CCP_EXEC_ILLEGAL_PARAMETER;
}
return CCP_make_cmd_ret_without_err_code(CCP_EXEC_ILLEGAL_PARAMETER);
}

ack = PL_deploy_block_cmd(&(PH_tl_cmd_list[id]), block_no, TMGR_get_master_total_cycle());
ack = PL_deploy_block_cmd(&(PH_tl_cmd_list[id]), block_no, exec_time);

if (ack == PL_BC_LIST_CLEARED)
{
EL_record_event((EL_GROUP)EL_CORE_GROUP_TLCD_DEPLOY_BLOCK,
(uint32_t)PL_BC_LIST_CLEARED,
EL_ERROR_LEVEL_HIGH,
(uint32_t)( ((0x000000ff & id) << 24) | (0x00ffffff & block_no) ));
if (id != TLCD_ID_DEPLOY_TLM)
{
bc_exec_status_.last_exec_block_type = id;
bc_exec_status_.last_exec_block = block_no;
bc_exec_status_.last_exec_time = exec_time;
bc_exec_status_.last_exec_status = CCP_EXEC_ILLEGAL_CONTEXT;
}
return CCP_make_cmd_ret(CCP_EXEC_ILLEGAL_CONTEXT, (uint32_t)ack);
}
else if (ack != PL_SUCCESS)
Expand All @@ -286,14 +327,35 @@ CCP_CmdRet Cmd_TLCD_DEPLOY_BLOCK(const CommonCmdPacket* packet)
(uint32_t)( ((0x000000ff & id) << 24) | (0x00ffffff & block_no) ));
if (ack == PL_BC_TIME_ADJUSTED)
{
if (id != TLCD_ID_DEPLOY_TLM)
{
bc_exec_status_.last_exec_block_type = id;
bc_exec_status_.last_exec_block = block_no;
bc_exec_status_.last_exec_time = exec_time;
bc_exec_status_.last_exec_status = CCP_EXEC_SUCCESS;
}
return CCP_make_cmd_ret(CCP_EXEC_SUCCESS, (uint32_t)ack);
}
else
{
if (id != TLCD_ID_DEPLOY_TLM)
{
bc_exec_status_.last_err_block_type = id;
bc_exec_status_.last_err_block = block_no;
bc_exec_status_.last_err_time = exec_time;
bc_exec_status_.last_err_status = CCP_EXEC_ILLEGAL_CONTEXT;
}
return CCP_make_cmd_ret(CCP_EXEC_ILLEGAL_CONTEXT, (uint32_t)ack);
}
}

if (id != TLCD_ID_DEPLOY_TLM)
{
bc_exec_status_.last_exec_block_type = id;
bc_exec_status_.last_exec_block = block_no;
bc_exec_status_.last_exec_time = exec_time;
bc_exec_status_.last_exec_status = CCP_EXEC_SUCCESS;
}
return CCP_make_cmd_ret(CCP_EXEC_SUCCESS, (uint32_t)ack);
}

Expand Down
15 changes: 14 additions & 1 deletion Applications/timeline_command_dispatcher.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,21 @@ typedef struct
} tlm_info_;
} TimelineCommandDispatcher;

extern const TimelineCommandDispatcher* const timeline_command_dispatcher;

typedef struct {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 [check_coding_rule] reported by reviewdog 🐶
ALLMAN STYLE IS REQUIRED

TLCD_ID last_exec_block_type;
bct_id_t last_exec_block;
cycle_t last_exec_time;
CCP_EXEC_STS last_exec_status;
TLCD_ID last_err_block_type;
bct_id_t last_err_block;
cycle_t last_err_time;
CCP_EXEC_STS last_err_status;

} BCExecStatus;

extern const TimelineCommandDispatcher* const timeline_command_dispatcher;
extern const BCExecStatus* const bc_exec_status;
/**
* @brief TL0 (GS から登録されるバス用の Timeline) の実行 App を作成する
* @param void
Expand Down
5 changes: 2 additions & 3 deletions TlmCmd/Ccsds/tlm_space_packet.c
Original file line number Diff line number Diff line change
Expand Up @@ -132,10 +132,9 @@ TSP_2ND_HDR_VER TSP_get_2nd_hdr_ver(const TlmSpacePacket* tsp)
}


void TSP_set_2nd_hdr_ver(TlmSpacePacket* tsp, TSP_2ND_HDR_VER ver)
void TSP_set_2nd_hdr_ver(TlmSpacePacket* tsp, uint8_t ver)
{
uint8_t tmp = (uint8_t)ver;
SP_insert_param_to_packet(TSP_CAST_TO_NON_CONST_SP(tsp), &TSP_pei_2nd_hdr_ver_, &tmp);
SP_insert_param_to_packet(TSP_CAST_TO_NON_CONST_SP(tsp), &TSP_pei_2nd_hdr_ver_, &ver);
}


Expand Down
4 changes: 2 additions & 2 deletions TlmCmd/Ccsds/tlm_space_packet.h
Original file line number Diff line number Diff line change
Expand Up @@ -208,10 +208,10 @@ TSP_2ND_HDR_VER TSP_get_2nd_hdr_ver(const TlmSpacePacket* tsp);
/**
* @brief Secondary Header Version No を設定
* @param[in,out] tsp: TlmSpacePacket
* @param[in] id: TSP_2ND_HDR_VER
* @param[in] id: uint8_t
* @return void
*/
void TSP_set_2nd_hdr_ver(TlmSpacePacket* tsp, TSP_2ND_HDR_VER ver);
void TSP_set_2nd_hdr_ver(TlmSpacePacket* tsp, uint8_t ver);

/**
* @brief Board Time を取得
Expand Down
10 changes: 10 additions & 0 deletions TlmCmd/telemetry_frame.c
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,11 @@ void TF_copy_u32(uint8_t* ptr, uint32_t data)
ENDIAN_memcpy(ptr, &data, 4);
}

void TF_copy_u64(uint8_t* ptr, uint64_t data)
{
ENDIAN_memcpy(ptr, &data, 8);
}

void TF_copy_i8(uint8_t* ptr, int8_t data)
{
ptr[0] = (uint8_t)data;
Expand All @@ -89,6 +94,11 @@ void TF_copy_i32(uint8_t* ptr, int32_t data)
ENDIAN_memcpy(ptr, &data, 4);
}

void TF_copy_i64(uint8_t* ptr, int64_t data)
{
ENDIAN_memcpy(ptr, &data, 8);
}

void TF_copy_float(uint8_t* ptr, float data)
{
ENDIAN_memcpy(ptr, &data, sizeof(float));
Expand Down
4 changes: 4 additions & 0 deletions TlmCmd/telemetry_frame.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,12 +90,16 @@ void TF_copy_u16(uint8_t* ptr, uint16_t data);

void TF_copy_u32(uint8_t* ptr, uint32_t data);

void TF_copy_u64(uint8_t* ptr, uint64_t data);

void TF_copy_i8(uint8_t* ptr, int8_t data);

void TF_copy_i16(uint8_t* ptr, int16_t data);

void TF_copy_i32(uint8_t* ptr, int32_t data);

void TF_copy_i64(uint8_t* ptr, int64_t data);

void TF_copy_float(uint8_t* ptr, float data);

void TF_copy_double(uint8_t* ptr, double data);
Expand Down
5 changes: 3 additions & 2 deletions TlmCmd/telemetry_generator.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include <src_user/TlmCmd/user_packet_handler.h>
#include <src_user/Settings/TlmCmd/common_tlm_packet_define.h>
#include "./Ccsds/tlm_space_packet.h" // FIXME: TSP 依存性はNGなので, TCP → SP 大工事終わったら直す
#include <src_user/IfWrapper/mram.h> // FIXME: RTI 依存性はNGなのでいつか直すべき


/**
Expand Down Expand Up @@ -123,7 +124,7 @@ CCP_CmdRet Cmd_GENERATE_TLM(const CommonCmdPacket* packet)
TSP_set_dest_flags(&TG_ctp_, dest_flags);
TSP_set_dest_info(&TG_ctp_, dr_partition); // FIXME: もはや dr partition ですらない
TSP_set_tlm_id(&TG_ctp_, id);
TSP_set_2nd_hdr_ver(&TG_ctp_, TSP_2ND_HDR_VER_1);
TSP_set_2nd_hdr_ver(&TG_ctp_, (uint8_t)(mram->cdh.obc_startup_counter));

// 生成したパケットを指定された回数配送処理へ渡す
while (num_dumps != 0)
Expand Down Expand Up @@ -249,7 +250,7 @@ static CCP_CmdRet TG_generate_tlm_(TLM_CODE tlm_id,
TSP_setup_primary_hdr(&TG_ctp_, CTP_APID_FROM_ME, TG_get_next_seq_count_(), packet_len);

// Secondary Header
TSP_set_2nd_hdr_ver(&TG_ctp_, TSP_2ND_HDR_VER_1);
TSP_set_2nd_hdr_ver(&TG_ctp_, (uint8_t)(mram->cdh.obc_startup_counter));
TSP_set_board_time(&TG_ctp_, (uint32_t)(TMGR_get_master_total_cycle()));
TSP_set_tlm_id(&TG_ctp_, tlm_id);
// FIXME: 他の時刻も入れる
Expand Down
Loading