Skip to content

Commit

Permalink
Merge pull request #288 from ut-issl/feature/fix_TF_ACK
Browse files Browse the repository at this point in the history
Pre Release (v3.6.0-beta.0): TLM生成関数の返り値を int から TF_ACK にするなど
  • Loading branch information
meltingrabbit authored Mar 12, 2022
2 parents 1c76a31 + db7c470 commit 365e461
Show file tree
Hide file tree
Showing 10 changed files with 503 additions and 420 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -379,21 +379,20 @@ static DS_ERR_CODE AOBC_analyze_tlm_aobc_hk_(const CommonTlmPacket* packet, AOBC
return DS_ERR_CODE_OK;
}

int AOBC_pick_up_tlm_buffer(const AOBC_Driver* aobc_driver, AOBC_TLM_CODE tlm_id, uint8_t* packet, int max_len)
TF_TLM_FUNC_ACK AOBC_pick_up_tlm_buffer(const AOBC_Driver* aobc_driver, AOBC_TLM_CODE tlm_id, uint8_t* packet, uint16_t* len, uint16_t max_len)
{
const CommonTlmPacket* buffered_packet;
uint16_t packet_len;

if (tlm_id >= AOBC_MAX_TLM_NUM) return TF_NOT_DEFINED;
if (aobc_driver->tlm_buffer.tlm[tlm_id].is_null_packet) return TF_NULL_PACKET;
if (tlm_id >= AOBC_MAX_TLM_NUM) return TF_TLM_FUNC_ACK_NOT_DEFINED;
if (aobc_driver->tlm_buffer.tlm[tlm_id].is_null_packet) return TF_TLM_FUNC_ACK_NULL_PACKET;

buffered_packet = &(aobc_driver->tlm_buffer.tlm[tlm_id].packet);
packet_len = CTP_get_packet_len(buffered_packet);
*len = CTP_get_packet_len(buffered_packet);

if (packet_len > max_len) return TF_TOO_SHORT_LEN;
if (*len > max_len) return TF_TLM_FUNC_ACK_TOO_SHORT_LEN;

memcpy(packet, &buffered_packet->packet, (size_t)packet_len);
return packet_len;
memcpy(packet, &buffered_packet->packet, (size_t)(*len));
return TF_TLM_FUNC_ACK_SUCCESS;
}

#pragma section
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ void AOBC_init_tlm_buffer(AOBC_Driver* aobc_driver);

DS_ERR_CODE AOBC_buffer_tlm_packet(DS_StreamConfig* p_stream_config, AOBC_Driver* aobc_driver);

// FIXME: TF_ACK になおす!
int AOBC_pick_up_tlm_buffer(const AOBC_Driver* aobc_driver, AOBC_TLM_CODE tlm_id, uint8_t* packet, int max_len);
TF_TLM_FUNC_ACK AOBC_pick_up_tlm_buffer(const AOBC_Driver* aobc_driver, AOBC_TLM_CODE tlm_id, uint8_t* packet, uint16_t* len, uint16_t max_len);

#endif

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import os
import sys

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()

# コードと整合をとる
TF_TLM_PAGE_SIZE = 64
TF_TLM_PAGE_MAX = 4

# 使われてない tlm id
NO_USED_TLM_ID = 1


@pytest.mark.real
@pytest.mark.sils
def test_telemetry_frame_set_page():
init_tf()

tlm_TF = wings.util.generate_and_receive_tlm(
ope, c2a_enum.Cmd_CODE_GENERATE_TLM, c2a_enum.Tlm_CODE_TF
)
assert tlm_TF["TF.PAGE_NO"] == 0

assert "SUC" == wings.util.send_rt_cmd_and_confirm(
ope, c2a_enum.Cmd_CODE_TF_SET_PAGE_FOR_TLM, (1,), c2a_enum.Tlm_CODE_HK
)
tlm_TF = wings.util.generate_and_receive_tlm(
ope, c2a_enum.Cmd_CODE_GENERATE_TLM, c2a_enum.Tlm_CODE_TF
)
assert tlm_TF["TF.PAGE_NO"] == 1

assert "PRM" == wings.util.send_rt_cmd_and_confirm(
ope, c2a_enum.Cmd_CODE_TF_SET_PAGE_FOR_TLM, (TF_TLM_PAGE_MAX,), c2a_enum.Tlm_CODE_HK
)
tlm_TF = wings.util.generate_and_receive_tlm(
ope, c2a_enum.Cmd_CODE_GENERATE_TLM, c2a_enum.Tlm_CODE_TF
)
assert tlm_TF["TF.PAGE_NO"] == 1


@pytest.mark.real
@pytest.mark.sils
def test_telemetry_frame_tlm_func():
init_tf()

# 登録されている tlm func の確認
tlm_TF = wings.util.generate_and_receive_tlm(
ope, c2a_enum.Cmd_CODE_GENERATE_TLM, c2a_enum.Tlm_CODE_TF
)
assert int(tlm_TF["TF.TLM0"], base=16) != 0 # tlm id = 0 は MOBC tlm が普通はある

# 登録されていない tlm func の確認
page = NO_USED_TLM_ID // TF_TLM_PAGE_SIZE
offset = NO_USED_TLM_ID % TF_TLM_PAGE_SIZE

assert "SUC" == wings.util.send_rt_cmd_and_confirm(
ope, c2a_enum.Cmd_CODE_TF_SET_PAGE_FOR_TLM, (page,), c2a_enum.Tlm_CODE_HK
)
tlm_TF = wings.util.generate_and_receive_tlm(
ope, c2a_enum.Cmd_CODE_GENERATE_TLM, c2a_enum.Tlm_CODE_TF
)

assert tlm_TF["TF.TLM" + str(offset)] == "0x00000000"

# tlm func の登録
func_adr = "0x12345678"
assert "SUC" == wings.util.send_rt_cmd_and_confirm(
ope,
c2a_enum.Cmd_CODE_TF_REGISTER_TLM,
(NO_USED_TLM_ID, int(func_adr, base=16)),
c2a_enum.Tlm_CODE_HK,
)
tlm_TF = wings.util.generate_and_receive_tlm(
ope, c2a_enum.Cmd_CODE_GENERATE_TLM, c2a_enum.Tlm_CODE_TF
)
assert tlm_TF["TF.TLM" + str(offset)] == func_adr

# 不正な登録
# → 第一引数が uint8_t なので,そもそも TF_TLM_PAGE_SIZE * TF_TLM_PAGE_MAX 以上の値を打てない
# assert "PRM" == wings.util.send_rt_cmd_and_confirm(
# ope, c2a_enum.Cmd_CODE_TF_REGISTER_TLM, (TF_TLM_PAGE_SIZE * TF_TLM_PAGE_MAX, int(func_adr, base=16)), c2a_enum.Tlm_CODE_HK
# )


@pytest.mark.real
@pytest.mark.sils
def test_telemetry_frame_final_check():
init_tf()


def init_tf():
assert "SUC" == wings.util.send_rt_cmd_and_confirm(
ope, c2a_enum.Cmd_CODE_TF_INIT, (), c2a_enum.Tlm_CODE_HK
)


if __name__ == "__main__":
pass
Loading

0 comments on commit 365e461

Please sign in to comment.