-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #263 from arkedge/feature/ccp-dump-tlm
CDIS や BCT に保存された CCP をダンプする App を追加
- Loading branch information
Showing
21 changed files
with
1,654 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,149 @@ | ||
#pragma section REPRO | ||
/** | ||
* @file | ||
* @brief TL や CDIS などの PacketList や BCT の CCP をダンプする (GS から内容を確認できるようにする) ための App | ||
*/ | ||
#include "ccp_dump.h" | ||
#include <stddef.h> | ||
#include <string.h> | ||
#include "../tlm_cmd/command_dispatcher_manager.h" | ||
#include "../system/time_manager/time_manager.h" | ||
|
||
/** | ||
* @brief App 初期化関数 | ||
* @param void | ||
* @return RESULT | ||
*/ | ||
static RESULT CCP_DUMP_init_(void); | ||
|
||
static RESULT CCP_DUMP_cdis_(const CommandDispatcher* cdis); | ||
static RESULT CCP_DUMP_bct_(void); | ||
|
||
|
||
static CcpDump ccp_dump_; | ||
const CcpDump* const ccp_dump = &ccp_dump_; | ||
|
||
|
||
AppInfo CCP_DUMP_create_app(void) | ||
{ | ||
return AI_create_app_info("ccpdump", CCP_DUMP_init_, NULL); | ||
} | ||
|
||
|
||
static RESULT CCP_DUMP_init_(void) | ||
{ | ||
memset(&ccp_dump_, 0x00, sizeof(CcpDump)); | ||
|
||
// 初回はなにもダンプしてないので | ||
ccp_dump_.dump.status = CCP_DUMP_STATUS_NOT_FOUND; | ||
return RESULT_OK; | ||
} | ||
|
||
|
||
CCP_CmdRet Cmd_CCP_DUMP_CDIS(const CommonCmdPacket* packet) | ||
{ | ||
CCP_DUMP_CdisDump* cdis_dump = &ccp_dump_.info.cdis; | ||
const CommandDispatcher* cdis; | ||
cdis_dump->cdis_idx = CCP_get_param_from_packet(packet, 0, uint8_t); | ||
cdis_dump->queue_idx = CCP_get_param_from_packet(packet, 1, uint16_t); | ||
|
||
cdis = CDIS_MGR_get_cdis(cdis_dump->cdis_idx); | ||
|
||
ccp_dump_.dump.target = CCP_DUMP_TARGET_CDIS; | ||
|
||
if (cdis == NULL) | ||
{ | ||
ccp_dump_.dump.status = CCP_DUMP_STATUS_NOT_FOUND; | ||
return CCP_make_cmd_ret(CCP_EXEC_ILLEGAL_PARAMETER, 1); | ||
} | ||
if (PL_count_active_nodes(cdis->pl) <= cdis_dump->queue_idx) | ||
{ | ||
ccp_dump_.dump.status = CCP_DUMP_STATUS_NOT_FOUND; | ||
return CCP_make_cmd_ret(CCP_EXEC_ILLEGAL_PARAMETER, 2); | ||
} | ||
|
||
if (CCP_DUMP_cdis_(cdis) == RESULT_OK) | ||
{ | ||
ccp_dump_.dump.status = CCP_DUMP_STATUS_OK; | ||
ccp_dump_.dump.dump_time = TMGR_get_master_clock(); | ||
return CCP_make_cmd_ret_without_err_code(CCP_EXEC_SUCCESS); | ||
} | ||
else | ||
{ | ||
ccp_dump_.dump.status = CCP_DUMP_STATUS_NOT_FOUND; | ||
return CCP_make_cmd_ret(CCP_EXEC_ILLEGAL_PARAMETER, 3); | ||
} | ||
} | ||
|
||
|
||
static RESULT CCP_DUMP_cdis_(const CommandDispatcher* cdis) | ||
{ | ||
const CCP_DUMP_CdisDump* cdis_dump = &ccp_dump_.info.cdis; | ||
const PacketList* pl = cdis->pl; | ||
const PL_Node* node = PL_get_head(pl); | ||
const CommonCmdPacket* ccp; | ||
uint16_t i; | ||
|
||
for (i = 0; i < cdis_dump->queue_idx; ++i) | ||
{ | ||
node = PL_get_next(node); | ||
} | ||
if (node == NULL) | ||
{ | ||
return RESULT_ERR; | ||
} | ||
|
||
ccp = (const CommonCmdPacket*)PL_get_packet(node); | ||
|
||
// CCP_copy_packet はパケット長しかコピーしない.ここではダンプなので,末端の不定もふくめてコピーする | ||
memcpy(ccp_dump_.dump.ccp.packet, ccp->packet, CSP_MAX_LEN); | ||
return RESULT_OK; | ||
} | ||
|
||
|
||
CCP_CmdRet Cmd_CCP_DUMP_BCT(const CommonCmdPacket* packet) | ||
{ | ||
CCP_DUMP_BctDump* bct_dump = &ccp_dump_.info.bct; | ||
bct_dump->pos.block = (bct_id_t)CCP_get_param_from_packet(packet, 0, uint16_t); | ||
bct_dump->pos.cmd = CCP_get_param_from_packet(packet, 1, uint8_t); | ||
|
||
ccp_dump_.dump.target = CCP_DUMP_TARGET_BCT; | ||
|
||
if (BCT_check_position(&bct_dump->pos) != BCT_SUCCESS) | ||
{ | ||
ccp_dump_.dump.status = CCP_DUMP_STATUS_NOT_FOUND; | ||
return CCP_make_cmd_ret(CCP_EXEC_ILLEGAL_PARAMETER, 1); | ||
} | ||
|
||
if (CCP_DUMP_bct_() == RESULT_OK) | ||
{ | ||
ccp_dump_.dump.status = CCP_DUMP_STATUS_OK; | ||
ccp_dump_.dump.dump_time = TMGR_get_master_clock(); | ||
return CCP_make_cmd_ret_without_err_code(CCP_EXEC_SUCCESS); | ||
} | ||
else | ||
{ | ||
ccp_dump_.dump.status = CCP_DUMP_STATUS_NOT_FOUND; | ||
return CCP_make_cmd_ret(CCP_EXEC_ILLEGAL_PARAMETER, 2); | ||
} | ||
} | ||
|
||
|
||
static RESULT CCP_DUMP_bct_(void) | ||
{ | ||
CCP_DUMP_BctDump* bct_dump = &ccp_dump_.info.bct; | ||
|
||
// BCT は CCP 長さが短いので,末尾を 0 埋めしておく | ||
memset(&ccp_dump_.dump.ccp, 0x00, sizeof(CommonCmdPacket)); | ||
|
||
if (BCT_load_cmd(&bct_dump->pos, &ccp_dump_.dump.ccp) == BCT_SUCCESS) | ||
{ | ||
return RESULT_OK; | ||
} | ||
else | ||
{ | ||
return RESULT_ERR; | ||
} | ||
} | ||
|
||
#pragma section |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
/** | ||
* @file | ||
* @brief CDIS などの PacketList や BCT の CCP をダンプする (GS から内容を確認できるようにする) ための App | ||
*/ | ||
#ifndef CCP_DUMP_H_ | ||
#define CCP_DUMP_H_ | ||
|
||
#include "../system/application_manager/app_info.h" | ||
#include "../tlm_cmd/common_cmd_packet.h" | ||
#include "../tlm_cmd/block_command_table.h" | ||
#include "../system/time_manager/obc_time.h" | ||
|
||
/** | ||
* @enum CCP_DUMP_TARGET | ||
* @note uint8_t を想定 | ||
* @brief ダンプした CCP のダンプ元 | ||
*/ | ||
typedef enum | ||
{ | ||
CCP_DUMP_TARGET_CDIS, //!< CDIS | ||
CCP_DUMP_TARGET_BCT //!< BCT | ||
} CCP_DUMP_TARGET; | ||
|
||
/** | ||
* @enum CCP_DUMP_STATUS | ||
* @note uint8_t を想定 | ||
* @brief ダンプ結果 | ||
*/ | ||
typedef enum | ||
{ | ||
CCP_DUMP_STATUS_OK, //!< ダンプ成功 | ||
CCP_DUMP_STATUS_NOT_FOUND //!< CCP が存在せず | ||
} CCP_DUMP_STATUS; | ||
|
||
/** | ||
* @struct CCP_DUMP_CdisDump | ||
* @brief CDIS のダンプ | ||
*/ | ||
typedef struct | ||
{ | ||
uint8_t cdis_idx; //!< CommandDispatcher.idx | ||
uint16_t queue_idx; //!< CDIS の queue の何番目の CCP か | ||
} CCP_DUMP_CdisDump; | ||
|
||
/** | ||
* @struct CCP_DUMP_BctDump | ||
* @brief BCT のダンプ | ||
*/ | ||
typedef struct | ||
{ | ||
BCT_Pos pos; //!< ダンプする BCT の位置 | ||
} CCP_DUMP_BctDump; | ||
|
||
/** | ||
* @struct CcpDump | ||
* @brief CcpDump の AppInfo 構造体 | ||
*/ | ||
typedef struct | ||
{ | ||
struct | ||
{ | ||
CCP_DUMP_CdisDump cdis; | ||
CCP_DUMP_BctDump bct; | ||
} info; //!< ダンブ情報(ダンプするパラメタ) | ||
struct | ||
{ | ||
CommonCmdPacket ccp; //!< ダンプした CCP | ||
CCP_DUMP_TARGET target; //!< ダンプ元 | ||
CCP_DUMP_STATUS status; //!< ダンプ結果 | ||
ObcTime dump_time; //!< ダンプした時刻 | ||
} dump; | ||
} CcpDump; | ||
|
||
extern const CcpDump* const ccp_dump; | ||
|
||
AppInfo CCP_DUMP_create_app(void); | ||
|
||
CCP_CmdRet Cmd_CCP_DUMP_CDIS(const CommonCmdPacket* packet); | ||
CCP_CmdRet Cmd_CCP_DUMP_BCT(const CommonCmdPacket* packet); | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.