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

on board subnet time の設定のバグを修正 #599

Merged
merged 4 commits into from
May 31, 2023
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
9 changes: 9 additions & 0 deletions Drivers/Protocol/common_tlm_cmd_packet_for_driver_super.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,15 @@ DS_ERR_CODE CTP_get_ctp_from_dssc(const DS_StreamConfig* p_stream_config, Common
memcpy(&received_packet->packet, EB90_FRAME_get_packet_head_from_dssc(p_stream_config), (size_t)packet_len);
if (CTP_get_packet_len(received_packet) != packet_len) return DS_ERR_CODE_ERR;
if (!CTP_is_valid_packet(received_packet)) return DS_ERR_CODE_ERR;

// On-Board Subnetwork Time を設定
if (CTP_get_on_board_subnet_time(received_packet) == 0xffffffff)
{
// FIXME: TG_forward_tlm_ ではなくてここでいいか検討
// 可能な限り正確な時間をいれるには,受信直後のここでいれるべき(←→網羅性)
tarotene marked this conversation as resolved.
Show resolved Hide resolved
// MOBC - 2nd OBC - 3rd OBC というとき, 2nd OBC でも 0xffffffff ができるようにしている
CTP_set_on_board_subnet_time(received_packet);
}
return DS_ERR_CODE_OK;
}

Expand Down
17 changes: 17 additions & 0 deletions Examples/2nd_obc_user/src/src_user/TlmCmd/common_tlm_packet.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,30 @@ void CTP_set_apid(CommonTlmPacket* packet, APID apid)
TSP_set_apid(packet, apid);
}

double CTP_get_global_time(const CommonTlmPacket* packet)
{
return TSP_get_global_time(packet);
}

void CTP_set_global_time(CommonTlmPacket* packet)
{
// 何を設定するかはユーザー定義
// TMGR_get_curret_unixtime() で現在の unixtime を入れたり, gps 時刻 を入れたり, など
TSP_set_global_time(packet, 0.0);
}

uint32_t CTP_get_on_board_subnet_time(const CommonTlmPacket* packet)
{
return TSP_get_on_board_subnet_time(packet);
}

void CTP_set_on_board_subnet_time(CommonTlmPacket* packet)
{
// 何を設定するかはユーザー定義
// MOBC では主に TI を,2nd OBC では主に 0xffffffff を
TSP_set_on_board_subnet_time(packet, 0xffffffff);
}

ctp_dest_flags_t CTP_get_dest_flags(const CommonTlmPacket* packet)
{
return TSP_get_dest_flags(packet);
Expand Down
1 change: 0 additions & 1 deletion Examples/2nd_obc_user/sync_with_minimum_user.bat
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ call :sync_file ".\src\src_user\TlmCmd\block_command_user_settings.c" "..\minimu
call :sync_file ".\src\src_user\TlmCmd\block_command_user_settings.h" "..\minimum_user\src\src_user\TlmCmd\block_command_user_settings.h"
call :sync_file ".\src\src_user\TlmCmd\common_cmd_packet.c" "..\minimum_user\src\src_user\TlmCmd\common_cmd_packet.c"
call :sync_file ".\src\src_user\TlmCmd\common_tlm_cmd_packet.c" "..\minimum_user\src\src_user\TlmCmd\common_tlm_cmd_packet.c"
call :sync_file ".\src\src_user\TlmCmd\common_tlm_packet.c" "..\minimum_user\src\src_user\TlmCmd\common_tlm_packet.c"

call :sync_file ".\src\src_user\Test\utils\wings_utils.py" "..\minimum_user\src\src_user\Test\utils\wings_utils.py"
call :sync_file ".\src\src_user\Test\pytest.ini" "..\minimum_user\src\src_user\Test\pytest.ini"
Expand Down
18 changes: 18 additions & 0 deletions Examples/minimum_user/src/src_user/TlmCmd/common_tlm_packet.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
*/
#include <src_core/TlmCmd/common_tlm_packet.h>
#include <src_core/TlmCmd/Ccsds/tlm_space_packet.h>
#include <src_core/System/TimeManager/time_manager.h>
#include <string.h>


Expand All @@ -27,13 +28,30 @@ void CTP_set_apid(CommonTlmPacket* packet, APID apid)
TSP_set_apid(packet, apid);
}

double CTP_get_global_time(const CommonTlmPacket* packet)
{
return TSP_get_global_time(packet);
}

void CTP_set_global_time(CommonTlmPacket* packet)
{
// 何を設定するかはユーザー定義
// TMGR_get_curret_unixtime() で現在の unixtime を入れたり, gps 時刻 を入れたり, など
TSP_set_global_time(packet, 0.0);
}

uint32_t CTP_get_on_board_subnet_time(const CommonTlmPacket* packet)
{
return TSP_get_on_board_subnet_time(packet);
}

void CTP_set_on_board_subnet_time(CommonTlmPacket* packet)
{
// 何を設定するかはユーザー定義
// MOBC では主に TI を,2nd OBC では主に 0xffffffff を
TSP_set_on_board_subnet_time(packet, (uint32_t)TMGR_get_master_total_cycle());
}

ctp_dest_flags_t CTP_get_dest_flags(const CommonTlmPacket* packet)
{
return TSP_get_dest_flags(packet);
Expand Down
26 changes: 25 additions & 1 deletion TlmCmd/common_tlm_packet.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,37 @@ APID CTP_get_apid(const CommonTlmPacket* packet);
void CTP_set_apid(CommonTlmPacket* packet, APID apid);

/**
* @brief 現在の global_time を設定
* @brief Global Time を取得
* @note 何が設定されているかは user 定義
* @param packet: CTP
* @return Global Time
*/
double CTP_get_global_time(const CommonTlmPacket* packet);

/**
* @brief 現在の Global Time を設定
* @note 何を設定するかは user 定義
* @param[in,out] packet: CTP
* @return void
*/
void CTP_set_global_time(CommonTlmPacket* packet);

/**
* @brief On-Board Subnetwork Time を取得
* @note 何が設定されているかは user 定義
* @param packet: CTP
* @return On-Board Subnetwork Time
*/
uint32_t CTP_get_on_board_subnet_time(const CommonTlmPacket* packet);

/**
* @brief 現在の On-Board Subnetwork Time を設定
* @note 何を設定するかは user 定義
* @param[in,out] packet: CTP
* @return void
*/
void CTP_set_on_board_subnet_time(CommonTlmPacket* packet);

/**
* @brief CTP_DEST_FLAG の & を取った flags を取得
* @param packet: CTP
Expand Down
8 changes: 5 additions & 3 deletions TlmCmd/telemetry_generator.c
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ static CCP_CmdRet TG_generate_tlm_(TLM_CODE tlm_id,
TSP_set_tlm_id(&TG_ctp_, tlm_id);
// FIXME: 他の時刻も入れる
CTP_set_global_time(&TG_ctp_);
TSP_set_on_board_subnet_time(&TG_ctp_, (uint32_t)(TMGR_get_master_total_cycle())); // FIXME: 暫定
CTP_set_on_board_subnet_time(&TG_ctp_);
TSP_set_dest_flags(&TG_ctp_, dest_flags);
TSP_set_dest_info(&TG_ctp_, dest_info);

Expand Down Expand Up @@ -302,9 +302,11 @@ static CCP_CmdRet TG_forward_tlm_(APID apid,
// {
// CTP_set_global_time(&TG_ctp_);
// }
if (TSP_get_on_board_subnet_time(&TG_ctp_) == 0xffffffff)
if (CTP_get_on_board_subnet_time(&TG_ctp_) == 0xffffffff)
{
TSP_set_on_board_subnet_time(&TG_ctp_, (uint32_t)(TMGR_get_master_total_cycle())); // FIXME: 暫定
// FIXME: 本当は Driver で受信時に上書きするべき? 一応 CTP_get_ctp_from_dssc でも対応
// MOBC - 2nd OBC - 3rd OBC というとき, 2nd OBC でも 0xffffffff ができるようにしている
CTP_set_on_board_subnet_time(&TG_ctp_);
}

TSP_set_dest_flags(&TG_ctp_, dest_flags);
Expand Down