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

Pre Release (v3.6.0-beta.0): TLM生成関数の返り値を int から TF_ACK にするなど #288

Merged
merged 11 commits into from
Mar 12, 2022
Merged
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
meltingrabbit marked this conversation as resolved.
Show resolved Hide resolved
import pytest
meltingrabbit marked this conversation as resolved.
Show resolved Hide resolved

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