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

byte 列から BC を復元して BCT に挿入する関数を追加 #648

Open
wants to merge 13 commits into
base: develop
Choose a base branch
from
Open
18 changes: 18 additions & 0 deletions TlmCmd/block_command_table.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
8 changes: 8 additions & 0 deletions TlmCmd/block_command_table.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading