Skip to content

Commit

Permalink
fix to be build
Browse files Browse the repository at this point in the history
  • Loading branch information
meltingrabbit committed Jan 28, 2022
1 parent 7eba605 commit 83eaf08
Show file tree
Hide file tree
Showing 33 changed files with 200 additions and 122 deletions.
2 changes: 1 addition & 1 deletion Applications/divided_cmd_utility.c
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ DCU_ACK DCU_register_next(CMD_CODE cmd_code, const uint8_t* param, uint16_t len)

ret = CCP_form_rtc(&DCU_packet_, cmd_code, param, len);
if (ret != CCP_UTIL_ACK_OK) return DCU_ACK_ERR;
if (PH_analyze_packet(&DCU_packet_) != PH_REGISTERED) // FIXME: CTCP, SpacePacket 整理で直す
if (PH_analyze_cmd_packet(&DCU_packet_) != PH_REGISTERED)
{
return DCU_ACK_ERR;
}
Expand Down
12 changes: 12 additions & 0 deletions Applications/memory_dump.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ static void MEM_init_(void);

static uint8_t MEM_get_next_adu_counter_(void);

// FIXME: CTCP 大改修が終わったら直す
// https://github.com/ut-issl/c2a-core/pull/217
#if 0
static CCP_EXEC_STS MEM_dump_region_(uint8_t category,
uint8_t num_dumps);

Expand All @@ -35,6 +38,7 @@ static void MEM_setup_header_(TCP* packet,

static void MEM_send_packet_(const CommonTlmPacket* packet,
uint8_t num_dumps);
#endif

AppInfo MEM_create_app(void)
{
Expand Down Expand Up @@ -84,6 +88,9 @@ CCP_EXEC_STS Cmd_MEM_SET_REGION(const CommonCmdPacket* packet)
return CCP_EXEC_SUCCESS;
}

// FIXME: CTCP 大改修が終わったら直す
// https://github.com/ut-issl/c2a-core/pull/217
#if 0
CCP_EXEC_STS Cmd_MEM_DUMP_REGION_SEQ(const CommonCmdPacket* packet)
{
const uint8_t* param = CCP_get_param_head(packet);
Expand Down Expand Up @@ -188,6 +195,7 @@ CCP_EXEC_STS Cmd_MEM_DUMP_SINGLE(const CommonCmdPacket* packet)

return CCP_EXEC_SUCCESS;
}
#endif

CCP_EXEC_STS Cmd_MEM_LOAD(const CommonCmdPacket* packet)
{
Expand Down Expand Up @@ -266,6 +274,9 @@ static uint8_t MEM_get_next_adu_counter_(void)
return ++adu_counter_;
}

// FIXME: CTCP 大改修が終わったら直す
// https://github.com/ut-issl/c2a-core/pull/217
#if 0
static CCP_EXEC_STS MEM_dump_region_(uint8_t category,
uint8_t num_dumps)
{
Expand Down Expand Up @@ -406,5 +417,6 @@ static void MEM_send_packet_(const CommonTlmPacket* packet,
PH_analyze_packet(packet); // FIXME: CTCP, SpacePacket 整理で直す
}
}
#endif

#pragma section
4 changes: 4 additions & 0 deletions Applications/memory_dump.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ AppInfo MEM_create_app(void);
// 自分の解釈をコメントとして追加
CCP_EXEC_STS Cmd_MEM_SET_REGION(const CommonCmdPacket* packet);

// FIXME: CTCP 大改修が終わったら直す
// https://github.com/ut-issl/c2a-core/pull/217
#if 0
CCP_EXEC_STS Cmd_MEM_DUMP_REGION_SEQ(const CommonCmdPacket* packet);
// 1パケットに入り切らない場合は,最初のADU分割された最初のパケットのみダンプ
// もう一度送ると,その次のパケットがダンプ
Expand All @@ -45,6 +48,7 @@ CCP_EXEC_STS Cmd_MEM_DUMP_REGION_RND(const CommonCmdPacket* packet);
CCP_EXEC_STS Cmd_MEM_DUMP_SINGLE(const CommonCmdPacket* packet);
// アドレスを指定して,ダンプ?
// Cmd_MEM_SET_REGION は無視?
#endif

CCP_EXEC_STS Cmd_MEM_LOAD(const CommonCmdPacket* packet);
// MEMにアップリンクして書き込み
Expand Down
4 changes: 2 additions & 2 deletions Applications/telemetry_manager.c
Original file line number Diff line number Diff line change
Expand Up @@ -567,7 +567,7 @@ CCP_EXEC_STS Cmd_TLM_MGR_START_TLM(const CommonCmdPacket* packet)

// master bc 展開
CCP_form_block_deploy_cmd(&TLM_MGR_packet_, TL_ID_DEPLOY_TLM, master_bc_id);
PH_analyze_packet(&TLM_MGR_packet_); // FIXME: CTCP, SpacePacket 整理で直す
PH_analyze_cmd_packet(&TLM_MGR_packet_);

return CCP_EXEC_SUCCESS;
}
Expand Down Expand Up @@ -614,7 +614,7 @@ CCP_EXEC_STS Cmd_TLM_MGR_CLEAR_TLM_TL(const CommonCmdPacket* packet)

param[0] = TL_ID_DEPLOY_TLM;
CCP_form_rtc(&TLM_MGR_packet_, Cmd_CODE_TLCD_CLEAR_ALL_TIMELINE, param, 1);
PH_analyze_packet(&TLM_MGR_packet_); // FIXME: CTCP, SpacePacket 整理で直す
PH_analyze_cmd_packet(&TLM_MGR_packet_);

return CCP_EXEC_SUCCESS;
}
Expand Down
14 changes: 10 additions & 4 deletions Examples/minimum_user_for_s2e/src/src_user/Drivers/Com/gs.c
Original file line number Diff line number Diff line change
Expand Up @@ -213,19 +213,25 @@ static DS_ERR_CODE GS_analyze_rec_data_(DS_StreamConfig* p_stream_config, void*
const uint8_t* gs_rx_data = DSSC_get_rx_frame(p_stream_config);
const TCF* tc_frame = (const TCF*)gs_rx_data; // 非自明なcast
GS_Driver* gs_driver = (GS_Driver*)p_driver;
int driver_index;
GS_PORT_TYPE driver_index;

// アドレス計算で CCSDS か UART か判別
if ((uint32_t)p_stream_config < (uint32_t)&gs_driver->driver_uart) driver_index = GS_PORT_TYPE_CCSDS;
else driver_index = GS_PORT_TYPE_UART;
if ((uint32_t)p_stream_config < (uint32_t)&gs_driver->driver_uart)
{
driver_index = GS_PORT_TYPE_CCSDS;
}
else
{
driver_index = GS_PORT_TYPE_UART;
}

gs_driver->info[driver_index].tc_frame_validate_status = GS_validate_tc_frame(tc_frame);
if (gs_driver->info[driver_index].tc_frame_validate_status != GS_VALIDATE_ERR_OK)
{
return DS_ERR_CODE_ERR;
}

gs_driver->info[driver_index].cmd_ack = PH_analyze_packet(&tc_frame->tcs.tcp); // 受信コマンドパケット解析
gs_driver->info[driver_index].cmd_ack = PH_analyze_cmd_packet(&tc_frame->tcs.tcp); // 受信コマンドパケット解析

return DS_ERR_CODE_OK;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
static GS_VALIDATE_ERR GS_check_tcf_header_(const TCF* tc_frame);
static GS_VALIDATE_ERR GS_check_tcf_contents_(const TCF* tc_frame);
static GS_VALIDATE_ERR GS_check_tcs_headers_(const TCS* tc_segment);
static GS_VALIDATE_ERR GS_check_tcp_headers_(const TCP* tc_packet);
static GS_VALIDATE_ERR GS_check_cmd_space_packet_headers_(const CmdSpacePacket* csp);
static GS_VALIDATE_ERR GS_check_fecw_(const uint8_t* data, size_t len);

static GS_VALIDATE_ERR GS_check_ad_cmd_(const TCF* tc_frame);
Expand Down Expand Up @@ -77,26 +77,14 @@ static GS_VALIDATE_ERR GS_check_tcf_contents_(const TCF* tc_frame)
{
GS_VALIDATE_ERR ack;

// TCSegment Headerの固定値部分が妥当か確認する
// TCSegment Header の固定値部分が妥当か確認する
ack = GS_check_tcs_headers_(&tc_frame->tcs);
if (ack != GS_VALIDATE_ERR_OK) return ack;

// TCPacektのヘッダのうちTLM/CMD共通部分が妥当か確認する
ack = GS_check_tcp_headers_(&tc_frame->tcs.tcp);
// CmdSpacePacket のヘッダのうち共通部分が妥当か確認する
ack = GS_check_cmd_space_packet_headers_(&tc_frame->tcs.tcp);
if (ack != GS_VALIDATE_ERR_OK) return ack;

// TCPacketのPackte TypeがCommandかどうか確認する
if (TCP_get_type(&tc_frame->tcs.tcp) != TCP_TYPE_CMD)
{
return GS_VALIDATE_ERR_TCP_TYPE_IS_NOT_CMD;
}

// TCPacketのSequence Flagが単パケットか確認する
if (TCP_get_seq_flag(&tc_frame->tcs.tcp) != TCP_SEQ_SINGLE)
{
return GS_VALIDATE_ERR_TCP_SEQ_IS_NOT_SINGLE;
}

return GS_VALIDATE_ERR_OK;
}

Expand All @@ -115,25 +103,37 @@ static GS_VALIDATE_ERR GS_check_tcs_headers_(const TCS* tc_segment)
return GS_VALIDATE_ERR_OK;
}

static GS_VALIDATE_ERR GS_check_tcp_headers_(const TCP* tc_packet)
static GS_VALIDATE_ERR GS_check_cmd_space_packet_headers_(const CmdSpacePacket* csp)
{
APID apid;
// FIXME: 他の部分のチェックも入れる

if (TCP_get_ver(tc_packet) != TCP_VER_1) return GS_VALIDATE_ERR_TCP_VER;
if (TCP_get_2nd_hdr_flag(tc_packet) != TCP_2ND_HDR_PRESENT)
if (CSP_get_ver(csp) != SP_VER_1) return GS_VALIDATE_ERR_TCP_VER;
if (CSP_get_2nd_hdr_flag(csp) != SP_2ND_HDR_FLAG_PRESENT)
{
// ここではSecondary Headerが必須。
return GS_VALIDATE_ERR_TCP_2ND_HDR_FLAG;
}

apid = TCP_get_apid(tc_packet);
if (CSP_get_type(csp) != SP_TYPE_CMD)
{
return GS_VALIDATE_ERR_TCP_TYPE_IS_NOT_CMD;
}

apid = CSP_get_apid(csp);
if ( !( apid == APID_MOBC_CMD
|| apid == APID_AOBC_CMD
|| apid == APID_TOBC_CMD ) )
{
return GS_VALIDATE_ERR_APID;
}

// Sequence Flag が単パケットか確認する
if (CSP_get_seq_flag(csp) != SP_SEQ_FLAG_SINGLE)
{
return GS_VALIDATE_ERR_TCP_SEQ_IS_NOT_SINGLE;
}

return GS_VALIDATE_ERR_OK;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ typedef enum
GS_VALIDATE_ERR_FARM1_SAME_NUMBER,
GS_VALIDATE_ERR_INVALID_BC_CMD
} GS_VALIDATE_ERR;
// FIXME: TCP → SpacePacket 大工事後に TCP を直す

/**
* @struct GS_ValidateInfo
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,16 @@
#include <stddef.h> // for size_t

#include "../../Library/stdint.h"
#include <src_core/TlmCmd/Ccsds/TCPacket.h>
#include <src_core/TlmCmd/Ccsds/cmd_space_packet.h>

// FIXME: TCP から CmdSpacePacket にしたことによる整理をする!!!

#define TCS_HEADER_SIZE (1u)

typedef struct
{
uint8_t header[TCS_HEADER_SIZE];
TCP tcp;
CmdSpacePacket tcp; // FIXME: TCP から CSP に諸々直す!
} TCS;

typedef enum
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@

#include "string.h" // for memcpy

#include <src_core/TlmCmd/Ccsds/TCPacket.h>

static void M_PDU_clear_spare_(M_PDU* m_pdu);

void M_PDU_generate_byte_stream(const M_PDU* m_pdu,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
*/

#include "tcp_to_m_pdu.h"
// FIXME: CTP ではなく TSP を使ってしまっている.できれば抽象化するべき
#include <src_core/TlmCmd/Ccsds/tlm_space_packet.h>

void T2M_initialize(TcpToMPdu* tcp_to_m_pdu)
{
Expand All @@ -26,7 +28,7 @@ T2M_ACK T2M_form_m_pdu(TcpToMPdu* tcp_to_m_pdu, PacketList* pl, M_PDU* m_pdu)
// M_PDUが完成する or TC Packetがなくなるまで実施
while (tcp_to_m_pdu->m_pdu_wp != M_PDU_DATA_SIZE)
{
const TCP* packet;
const TlmSpacePacket* packet;
size_t tcp_len, tcp_left, m_pdu_left, write_len;

if (PL_is_empty(pl))
Expand Down Expand Up @@ -58,19 +60,19 @@ T2M_ACK T2M_form_m_pdu(TcpToMPdu* tcp_to_m_pdu, PacketList* pl, M_PDU* m_pdu)
// この場合、生成されたFill Packetは次M_PDUにまたがる。
// この状態で追加のテレメトリが生成されない場合は、Fill
// Packetのみで構成されたM_PDUが一度送出されることになる。
static TCP fill_; // サイズが大きいため静的確保(スタック保護)
static TlmSpacePacket fill_; // サイズが大きいため静的確保(スタック保護)
size_t fill_size = M_PDU_DATA_SIZE - tcp_to_m_pdu->m_pdu_wp;
TCP_TLM_setup_fill_packet(&fill_, (uint16_t)fill_size);
TSP_setup_fill_packet(&fill_, (uint16_t)fill_size);
PL_push_back(pl, &fill_);
}
}

// Queue先頭のTC Packetを取得
// 有効パケットまたはFillパケットが必ず入っている。
packet = (const TCP*)(PL_get_head(pl)->packet); // FIXME: Space Packet 実装でなおす
packet = (const TlmSpacePacket*)(PL_get_head(pl)->packet); // FIXME: Space Packet 実装でなおす

// 書き込むデータ長を計算
tcp_len = TCP_TLM_get_packet_len(packet);
tcp_len = TSP_get_packet_len(packet);
tcp_left = tcp_len - tcp_to_m_pdu->tcp_rp;
m_pdu_left = M_PDU_DATA_SIZE - tcp_to_m_pdu->m_pdu_wp;
write_len = (tcp_left > m_pdu_left) ? m_pdu_left : tcp_left;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
#ifndef TCP_TO_M_PDU_H_
#define TCP_TO_M_PDU_H_

// FIXME: TCP から TlmSpacePacket に直す!!!

#include <stddef.h> // for size_t

#include <src_core/TlmCmd/packet_list.h>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
* @note CCP: CommonCmdPacket
*/
#include <src_core/TlmCmd/common_cmd_packet.h>
#include <src_core/TlmCmd/Ccsds/cmd_space_packet.h>
#include <string.h>


Expand Down Expand Up @@ -96,4 +97,9 @@ void CCP_set_common_hdr(CommonCmdPacket* packet)
CSP_set_common_hdr(packet);
}

void CCP_copy_packet(CommonCmdPacket* dest, const CommonCmdPacket* src)
{
CSP_copy_packet(dest, src);
}

#pragma section
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
* @note CCP: CommonCmdPacket
*/
#include <src_core/TlmCmd/common_tlm_cmd_packet.h>
#include <src_core/TlmCmd/Ccsds/space_packet.h>
#include <string.h>


int CTCP_is_valid_packet(const CommonTlmCmdPacket* packet)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
* @note CTP: CommonTlmPacket
*/
#include <src_core/TlmCmd/common_tlm_packet.h>
#include <src_core/TlmCmd/Ccsds/tlm_space_packet.h>
#include <string.h>


Expand All @@ -16,12 +17,12 @@ int CTP_is_valid_packet(const CommonTlmPacket* packet)
return 1;
}

CTP_DEST_FLAG CTP_get_dest_flags(const CommonTlmPacket* packet)
ctp_dest_flags_t CTP_get_dest_flags(const CommonTlmPacket* packet)
{
return TSP_get_dest_flgas(packet);
}

void CTP_set_dest_flags(CommonTlmPacket* packet, CTP_DEST_FLAG flags)
void CTP_set_dest_flags(CommonTlmPacket* packet, ctp_dest_flags_t flags)
{
TSP_set_dest_flgas(packet, flags);
}
Expand All @@ -36,4 +37,9 @@ uint8_t* CTP_get_user_data_head(CommonTlmPacket* packet)
return TSP_get_user_data_head(packet);
}

void CTP_copy_packet(CommonTlmPacket* dest, const CommonTlmPacket* src)
{
TSP_copy_packet(dest, src);
}

#pragma section
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ PH_ACK PH_user_analyze_cmd(const CommonCmdPacket* packet)
{
switch (CCP_get_dest_type(packet))
{
case TCP_CMD_DEST_TYPE_TO_AOBC:
case CCP_DEST_TYPE_TO_AOBC:
return (PH_add_aobc_cmd_(packet) == PH_SUCCESS) ? PH_FORWARDED : PH_PL_LIST_FULL;
case TCP_CMD_DEST_TYPE_TO_TOBC:
case CCP_DEST_TYPE_TO_TOBC:
return (PH_add_tobc_cmd_(packet) == PH_SUCCESS) ? PH_FORWARDED : PH_PL_LIST_FULL;
default:
// TCP_CMD_DEST_TYPE_TO_ME
Expand Down
Loading

0 comments on commit 83eaf08

Please sign in to comment.