From d7b074cf10317a22ff3c77e11a69a99e6adca72d Mon Sep 17 00:00:00 2001 From: chutaro <35984595+chutaro@users.noreply.github.com> Date: Sat, 16 Dec 2023 13:25:50 +0900 Subject: [PATCH 1/2] add bc raw copy func --- TlmCmd/block_command_table.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/TlmCmd/block_command_table.c b/TlmCmd/block_command_table.c index a0623112a..61920d872 100644 --- a/TlmCmd/block_command_table.c +++ b/TlmCmd/block_command_table.c @@ -269,6 +269,24 @@ BCT_ACK BCT_copy_bct(const bct_id_t dst_block, const bct_id_t src_block) return BCT_SUCCESS; } +BCT_ACK BCT_copy_bct_from_bytes(const bct_id_t bc_id, uint8_t* data) +{ + BCT_Table temp; + + if (bc_id >= BCT_MAX_BLOCKS) return BCT_INVALID_BLOCK_NO; + if (BCE_is_active(bc_id)) return BCT_INVALID_BLOCK_NO; + + // byte 列をいったん BCT_Table の形にして、最低限 cmd 数の確認をする + memcpy(&temp, data, sizeof(BCT_Table)); + if (temp.length == 0 || temp.length > BCT_MAX_CMD_NUM) return BCT_INVALID_CMD_NO; + + // BCT にコピー + memcpy(block_command_table_.blocks[bc_id], &temp, sizeof(BCT_Table)); + BCE_clear_block(bc_id); + + return BCT_SUCCESS; +} + CMD_CODE BCT_get_id(const bct_id_t block, const uint8_t cmd) { BCT_Pos pos; From 1c990205aefe3ddba731b022a26861e6d9057188 Mon Sep 17 00:00:00 2001 From: chutaro <35984595+chutaro@users.noreply.github.com> Date: Mon, 18 Dec 2023 00:58:53 +0900 Subject: [PATCH 2/2] add declaration --- TlmCmd/block_command_table.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/TlmCmd/block_command_table.h b/TlmCmd/block_command_table.h index 2f532ebd7..c71738b0e 100644 --- a/TlmCmd/block_command_table.h +++ b/TlmCmd/block_command_table.h @@ -235,6 +235,14 @@ BCT_ACK BCT_overwrite_cmd(const BCT_Pos* pos, const CommonCmdPacket* packet); */ BCT_ACK BCT_copy_bct(const bct_id_t dst_block, const bct_id_t src_block); +/** + * @brief byte 列から BC を復元し BCT に挿入する + * @param[in] bc_id コピー先の bct_id + * @param[in] data コピー元の byte 列へのポインタ + * @return BCT_ACK + */ +BCT_ACK BCT_copy_bct_from_bytes(const bct_id_t bc_id, uint8_t* data); + // 以下3つは BCT に登録されている Cmd からその内容を取り出すgetter /** * @brief BCT 内の Cmd の CMD_CODE の getter