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

GSCD,TLCD,RTCDなどの実行時エラー履歴を残す #268

Merged
merged 6 commits into from
Apr 1, 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
Original file line number Diff line number Diff line change
Expand Up @@ -96,13 +96,7 @@
@pytest.mark.sils
def test_event_logger_init_check():
update_all_tlm()

# ### 初期化
ret = wings.util.send_rt_cmd_and_confirm(
ope, c2a_enum.Cmd_CODE_EL_INIT, (), c2a_enum.Tlm_CODE_HK
)
assert ret == "SUC"

initialize_el()
update_all_tlm()
assert g_count_total == 0
for err_level in range(EL_ERROR_LEVEL_MAX):
Expand Down Expand Up @@ -147,11 +141,7 @@ def test_event_logger_set_params():
@pytest.mark.real
@pytest.mark.sils
def test_event_logger_record_event():
# ### 初期化
ret = wings.util.send_rt_cmd_and_confirm(
ope, c2a_enum.Cmd_CODE_EL_INIT, (), c2a_enum.Tlm_CODE_HK
)

initialize_el()
change_tlog_tlm_page(0, EL_ERROR_LEVEL_HIGH)
change_clog_tlm_page(0, EL_ERROR_LEVEL_HIGH)
update_all_tlm()
Expand Down Expand Up @@ -276,10 +266,7 @@ def test_event_logger_record_event():
@pytest.mark.real
@pytest.mark.sils
def test_event_logger_clear_log():
# ### 初期化
ret = wings.util.send_rt_cmd_and_confirm(
ope, c2a_enum.Cmd_CODE_EL_INIT, (), c2a_enum.Tlm_CODE_HK
)
initialize_el()

local0 = 1
local1 = 5
Expand Down Expand Up @@ -405,10 +392,7 @@ def test_event_logger_clear_log():
@pytest.mark.real
@pytest.mark.sils
def test_event_logger_tlog_overflow():
# ### 初期化
ret = wings.util.send_rt_cmd_and_confirm(
ope, c2a_enum.Cmd_CODE_EL_INIT, (), c2a_enum.Tlm_CODE_HK
)
initialize_el()

# ### 設定コマンドのアサーション確認
change_tlog_tlm_page(0, EL_ERROR_LEVEL_HIGH)
Expand Down Expand Up @@ -630,9 +614,7 @@ def test_event_logger_tlog_overflow():
@pytest.mark.real
@pytest.mark.sils
def test_event_logger_clog_overflow():
# ### 初期化
wings.util.send_rt_cmd_and_confirm(ope, c2a_enum.Cmd_CODE_EL_INIT, (), c2a_enum.Tlm_CODE_HK)

initialize_el()
update_el_tlm()
update_el_clog_tlm()

Expand Down Expand Up @@ -686,10 +668,7 @@ def test_event_logger_clog_overflow():
@pytest.mark.real
@pytest.mark.sils
def test_event_logger_logging_setting():
# ### 初期化
ret = wings.util.send_rt_cmd_and_confirm(
ope, c2a_enum.Cmd_CODE_EL_INIT, (), c2a_enum.Tlm_CODE_HK
)
initialize_el()

# ### 切り替え
ret = wings.util.send_rt_cmd_and_confirm(
Expand Down Expand Up @@ -771,6 +750,22 @@ def test_event_logger_final_check():
assert ret == "SUC"
meltingrabbit marked this conversation as resolved.
Show resolved Hide resolved


def initialize_el():
# ### 初期化
ret = wings.util.send_rt_cmd_and_confirm(
ope, c2a_enum.Cmd_CODE_EL_INIT, (), c2a_enum.Tlm_CODE_HK
)
assert ret == "SUC"
# ### 不正引数のチェックをするtestでEL登録されないように無効化
ret = wings.util.send_rt_cmd_and_confirm(
ope,
c2a_enum.Cmd_CODE_EL_DISABLE_LOGGING,
(c2a_enum.EL_CORE_GROUP_CDIS_EXEC_ERR,),
c2a_enum.Tlm_CODE_HK,
)
assert ret == "SUC"


# 難しいので time はみない
def assert_latest_log(group, local, err_level, note):
update_el_tlm()
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import os
import sys
import time

import isslwings as wings
import pytest

ROOT_PATH = "../../../"
sys.path.append(os.path.dirname(__file__) + "/" + ROOT_PATH + "utils")
import c2a_enum_utils
import wings_utils

c2a_enum = c2a_enum_utils.get_c2a_enum()
ope = wings_utils.get_wings_operation()

# C2Aでのdefine値
AM_TLM_PAGE_MAX = 4


@pytest.mark.sils
@pytest.mark.real
def test_cdis_exec_err():

# === ELの初期化
assert "SUC" == wings.util.send_rt_cmd_and_confirm(
ope, c2a_enum.Cmd_CODE_EL_INIT, (), c2a_enum.Tlm_CODE_HK
)
tlm_EL = wings.util.generate_and_receive_tlm(
ope, c2a_enum.Cmd_CODE_GENERATE_TLM, c2a_enum.Tlm_CODE_EL
)
ti_now = tlm_EL["EL.SH.TI"]

# === 以下の4つを無効パラメタでコマンド登録する
# RT Cmd_CODE_TMGR_UPDATE_UNIXTIME
# RT Cmd_CODE_AM_SET_PAGE_FOR_TLM
# TL Cmd_CODE_TMGR_UPDATE_UNIXTIME
# TL Cmd_CODE_AM_SET_PAGE_FOR_TLM
assert "PRM" == wings.util.send_rt_cmd_and_confirm(
ope, c2a_enum.Cmd_CODE_TMGR_UPDATE_UNIXTIME, (-10, 0, 0), c2a_enum.Tlm_CODE_HK
)
assert "PRM" == wings.util.send_rt_cmd_and_confirm(
ope,
c2a_enum.Cmd_CODE_AM_SET_PAGE_FOR_TLM,
(AM_TLM_PAGE_MAX + 100,),
c2a_enum.Tlm_CODE_HK,
)
wings.util.send_tl_cmd(ope, ti_now + 50, c2a_enum.Cmd_CODE_TMGR_UPDATE_UNIXTIME, (-10, 0, 0))
wings.util.send_tl_cmd(
ope, ti_now + 55, c2a_enum.Cmd_CODE_AM_SET_PAGE_FOR_TLM, (AM_TLM_PAGE_MAX + 100,)
)
time.sleep(2)

# === ELのチェック
tlm_EL = wings.util.generate_and_receive_tlm(
ope, c2a_enum.Cmd_CODE_GENERATE_TLM, c2a_enum.Tlm_CODE_EL
)
# GS_cmd_dispatcher
assert tlm_EL["EL.TLOGS.LOW.EVENTS3.GROUP"] == c2a_enum.EL_CORE_GROUP_CDIS_EXEC_ERR
assert tlm_EL["EL.TLOGS.LOW.EVENTS2.GROUP"] == c2a_enum.EL_CORE_GROUP_CDIS_EXEC_ERR
assert tlm_EL["EL.TLOGS.LOW.EVENTS3.LOCAL"] == tlm_EL["EL.TLOGS.LOW.EVENTS2.LOCAL"]
note = (c2a_enum.Cmd_CODE_TMGR_UPDATE_UNIXTIME << 16) | c2a_enum.CCP_EXEC_ILLEGAL_PARAMETER
assert tlm_EL["EL.TLOGS.LOW.EVENTS3.NOTE"] == note
note = (c2a_enum.Cmd_CODE_AM_SET_PAGE_FOR_TLM << 16) | c2a_enum.CCP_EXEC_ILLEGAL_PARAMETER
assert tlm_EL["EL.TLOGS.LOW.EVENTS2.NOTE"] == note
# TL_cmd_dispatcher
assert tlm_EL["EL.TLOGS.LOW.EVENTS1.GROUP"] == c2a_enum.EL_CORE_GROUP_CDIS_EXEC_ERR
assert tlm_EL["EL.TLOGS.LOW.EVENTS0.GROUP"] == c2a_enum.EL_CORE_GROUP_CDIS_EXEC_ERR
assert tlm_EL["EL.TLOGS.LOW.EVENTS1.LOCAL"] == tlm_EL["EL.TLOGS.LOW.EVENTS0.LOCAL"]
note = (c2a_enum.Cmd_CODE_TMGR_UPDATE_UNIXTIME << 16) | c2a_enum.CCP_EXEC_ILLEGAL_PARAMETER
assert tlm_EL["EL.TLOGS.LOW.EVENTS1.NOTE"] == note
note = (c2a_enum.Cmd_CODE_AM_SET_PAGE_FOR_TLM << 16) | c2a_enum.CCP_EXEC_ILLEGAL_PARAMETER
assert tlm_EL["EL.TLOGS.LOW.EVENTS0.NOTE"] == note
# GSとTLをlocalで区別できているか
assert tlm_EL["EL.TLOGS.LOW.EVENTS1.LOCAL"] != tlm_EL["EL.TLOGS.LOW.EVENTS3.LOCAL"]

# === 最後にもう一度初期化
assert "SUC" == wings.util.send_rt_cmd_and_confirm(
ope, c2a_enum.Cmd_CODE_EL_INIT, (), c2a_enum.Tlm_CODE_HK
)


if __name__ == "__main__":
test_cdis_exec_err()
pass
3 changes: 2 additions & 1 deletion System/EventManager/event_logger.h
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,8 @@ typedef enum
EL_CORE_GROUP_EH_MATCH_RULE, //!< EH_Rule でマッチした(詳細は event_handler.h 参照)
EL_CORE_GROUP_EH_RESPOND_WITH_HIGHER_LEVEL_RULE, //!< EH_Rule でマッチしたが,そのルールで対応せずに,上位のルールで対応させた(詳細は event_handler.h 参照)
EL_CORE_GROUP_COMMAND_ANALYZE,
EL_CORE_GROUP_COMMAND_DISPATCHER,
EL_CORE_GROUP_CDIS_INTERNAL_ERR,
EL_CORE_GROUP_CDIS_EXEC_ERR,
// TODO: Driver Super
#ifdef EL_IS_ENABLE_EL_ERROR_LEVEL
EL_CORE_GROUP_EL_DROP_CLOG1, //!< EL CLogs で古いエラーを上書きするとき (group, err_level を保存)
Expand Down
28 changes: 17 additions & 11 deletions TlmCmd/command_dispatcher.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,16 @@
// 現状 PL が NULL チェックをしてないので,できない

/**
* @enum CIDS_EL_LOCAL_ID
* @enum CDIS_EL_LOCAL_ID
* @brief CDIS 内部の event の local ID
* @note uint8_t
*/
typedef enum
{
CIDS_EL_LOCAL_ID_NULL_PARAM, //!< NULL 引数
CIDS_EL_LOCAL_ID_INVALID_PL, //!< 不正な PL
CIDS_EL_LOCAL_ID_UNKNOWN
} CIDS_EL_LOCAL_ID;
CDIS_EL_LOCAL_ID_NULL_PARAM, //!< NULL 引数
CDIS_EL_LOCAL_ID_INVALID_PL, //!< 不正な PL
CDIS_EL_LOCAL_ID_UNKNOWN
} CDIS_EL_LOCAL_ID;

/**
* @brief CDIS_ExecInfo の初期化
Expand Down Expand Up @@ -54,17 +54,17 @@ CommandDispatcher CDIS_init(PacketList* pl)
if (pl == NULL)
{
// 初期化時エラーは試験時に確認され,打ち上げ後はありえないので,イベント発行のみしかしない
EL_record_event((EL_GROUP)EL_CORE_GROUP_COMMAND_DISPATCHER,
CIDS_EL_LOCAL_ID_NULL_PARAM,
EL_record_event((EL_GROUP)EL_CORE_GROUP_CDIS_INTERNAL_ERR,
CDIS_EL_LOCAL_ID_NULL_PARAM,
EL_ERROR_LEVEL_HIGH,
0);
return cdis;
}
if (PL_get_packet_type(pl) != PL_PACKET_TYPE_CCP)
{
// 初期化時エラーは試験時に確認され,打ち上げ後はありえないので,イベント発行のみしかしない
EL_record_event((EL_GROUP)EL_CORE_GROUP_COMMAND_DISPATCHER,
CIDS_EL_LOCAL_ID_INVALID_PL,
EL_record_event((EL_GROUP)EL_CORE_GROUP_CDIS_INTERNAL_ERR,
CDIS_EL_LOCAL_ID_INVALID_PL,
EL_ERROR_LEVEL_HIGH,
(uint32_t)pl);
return cdis;
Expand All @@ -86,8 +86,7 @@ static void CDIS_clear_exec_info_(CDIS_ExecInfo* exec_info)

void CDIS_dispatch_command(CommandDispatcher* cdis)
{
// パケットコピー用.サイズが大きいため静的変数として宣言
static CommonCmdPacket packet_;
static CommonCmdPacket packet_; // パケットコピー用.サイズが大きいため静的変数として宣言

// 実行有効フラグが無効化されている場合は処理打ち切り
if (cdis->lockout) return;
Expand Down Expand Up @@ -129,6 +128,13 @@ void CDIS_dispatch_command(CommandDispatcher* cdis)

if (cdis->prev.sts != CCP_EXEC_SUCCESS)
{
// 実行時エラー情報をELにも記録. エラー発生場所(GSCD,TLCDなど)はcdisのポインタアドレスで区別
uint32_t note = ((0x0000ffff & cdis->prev.code) << 16) | (0x0000ffff & cdis->prev.sts);
meltingrabbit marked this conversation as resolved.
Show resolved Hide resolved
EL_record_event((EL_GROUP)EL_CORE_GROUP_CDIS_EXEC_ERR,
(uint32_t)cdis,
EL_ERROR_LEVEL_LOW,
note);

// 実行したコマンドが実行異常ステータスを返した場合
// エラー発生カウンタをカウントアップ
++(cdis->error_counter);
Expand Down