Skip to content

Commit

Permalink
resolve cross-ref
Browse files Browse the repository at this point in the history
  • Loading branch information
meltingrabbit committed Jan 27, 2022
1 parent a82d13a commit 2a90f68
Show file tree
Hide file tree
Showing 15 changed files with 80 additions and 43 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,26 +6,21 @@
#ifndef APID_DEFINE_H_
#define APID_DEFINE_H_

#undef TCP_MAX_LEN

#define TCP_MAX_LEN (432u)

/**
* @enum APID
* @brief Application Process ID
* @note 11bit
*/
typedef enum
{
APID_MOBC_CMD = 0x210, // 01000010000b:
APID_AOBC_CMD = 0x211, // 01000010001b:
APID_TOBC_CMD = 0x212, // 01000010010b:
APID_TCAL_TLM = 0x410, // 10000010000b: APID for TIME CARIBLATION TLM
APID_MIS_TLM = 0x510, // 10100010000b: APID for MIS TLM
APID_DUMP_TLM = 0x710, // 11100010000b: APID for DUMP TLM
APID_FILL_PKT = 0x7ff, // 11111111111b: APID for FILL PACKET
APID_MOBC_CMD = 0x210, //!< 01000010000b:
APID_AOBC_CMD = 0x211, //!< 01000010001b:
APID_TOBC_CMD = 0x212, //!< 01000010010b:
APID_TCAL_TLM = 0x410, //!< 10000010000b: APID for TIME CARIBLATION TLM
APID_MIS_TLM = 0x510, //!< 10100010000b: APID for MIS TLM
APID_DUMP_TLM = 0x710, //!< 11100010000b: APID for DUMP TLM
APID_FILL_PKT = 0x7ff, //!< 11111111111b: APID for FILL PACKET
APID_UNKNOWN
} APID;


#endif
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,8 @@
#ifndef CMD_SPACE_PACKET_PARAMS_H_
#define CMD_SPACE_PACKET_PARAMS_H_

#undef CSP_MAX_LEN
#undef CSP_2ND_HDR_VER_TO_USE

#define CSP_MAX_LEN (128)
#define CSP_2ND_HDR_VER_TO_USE (CSP_2ND_HDR_VER_1)

#endif
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/**
* @file
* @brief CmdSpacePacket のユーザー設定
*/
#ifndef SPACE_PACKET_LEN_PARAMS_H_
#define SPACE_PACKET_LEN_PARAMS_H_

#undef TSP_MAX_LEN
#undef CSP_MAX_LEN

#define TSP_MAX_LEN (432)
#define CSP_MAX_LEN (128)

#endif
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,8 @@
#ifndef TLM_SPACE_PACKET_PARAMS_H_
#define TLM_SPACE_PACKET_PARAMS_H_

#undef TSP_MAX_LEN
#undef TSP_2ND_HDR_VER_TO_USE

#define TSP_MAX_LEN (432)
#define TSP_2ND_HDR_VER_TO_USE (TSP_2ND_HDR_VER_1)

#endif
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#ifndef COMMON_CMD_PACKET_DEFINE_H_
#define COMMON_CMD_PACKET_DEFINE_H_

#include <src_core/TlmCmd/Ccsds/cmd_space_packet.h>
#include <src_core/TlmCmd/Ccsds/space_packet_typedef.h>

// CommonCmdPacket として CmdSpacePacket をつかう
typedef CmdSpacePacket CommonCmdPacket;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#ifndef COMMON_TLM_CMD_PACKET_DEFINE_H_
#define COMMON_TLM_CMD_PACKET_DEFINE_H_

#include <src_core/TlmCmd/Ccsds/space_packet.h>
#include <src_core/TlmCmd/Ccsds/space_packet_typedef.h>

// CommonTlmCmdPacket として SpacePacket をつかう
typedef SpacePacket CommonTlmCmdPacket;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#ifndef COMMON_TLM_PACKET_DEFINE_H_
#define COMMON_TLM_PACKET_DEFINE_H_

#include <src_core/TlmCmd/Ccsds/tlm_space_packet.h>
#include <src_core/TlmCmd/Ccsds/space_packet_typedef.h>

// CommonTlmPacket として TlmSpacePacket をつかう
typedef TlmSpacePacket CommonTlmPacket;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ int CTP_is_valid_packet(const CommonTlmPacket* packet)

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

void CTP_set_dest_flags(CommonTlmPacket* packet, CTP_DEST_FLAG flags)
Expand Down
13 changes: 7 additions & 6 deletions TlmCmd/Ccsds/cmd_space_packet.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,17 +52,18 @@ typedef enum
} CSP_2ND_HDR_VER;


#define CSP_MAX_LEN (128) //!< CmdSpacePacket の最大パケット長.値は適当においている
#define CSP_SND_HDR_LEN (9) //!< Secondary Header 長
#define CSP_2ND_HDR_VER_TO_USE (CSP_2ND_HDR_VER_1) //!< 使う Sec. HDR Ver

// CSP_MAX_LEN, CSP_2ND_HDR_VER_TO_USE を再定義
#include <src_user/Settings/TlmCmd/Ccsds/cmd_space_packet_params.h>

// TODO: 上に持ってきて,コンパイルが通らないことを確認する!!!!!!!!!!!!!!!!!!
// space_packet.h と相互 include になってしまっているので,最後のここで include する
// 相互参照問題があるので,この順番で include
#include <src_user/Library/stdint.h>
#include "space_packet_len.h"
#include "space_packet_typedef.h"
#include "space_packet.h"
#include <src_core/TlmCmd/common_cmd_packet.h>
#include "../common_cmd_packet.h"

#if CSP_MAX_LEN <= SP_PRM_HDR_LEN
#error CSP_MAX_LEN is too small
Expand All @@ -86,10 +87,10 @@ typedef enum
* @note C ではテンプレートが使えないため,別で定義する
* https://github.com/ut-issl/c2a-core/issues/204
*/
typedef struct
struct CmdSpacePacket
{
uint8_t packet[CSP_MAX_LEN];
} CmdSpacePacket;
};


// ******************************
Expand Down
2 changes: 1 addition & 1 deletion TlmCmd/Ccsds/space_packet.c
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ uint16_t SP_get_packet_len(const SpacePacket* sp)
void SP_set_packet_len(SpacePacket* sp, uint16_t len)
{
if (len <= SP_PRM_HDR_LEN) return;
SP_set_packet_data_len(sp, (uint16_t)(len - SP_PRM_HDR_LEN))
SP_set_packet_data_len(sp, (uint16_t)(len - SP_PRM_HDR_LEN));
}


Expand Down
16 changes: 6 additions & 10 deletions TlmCmd/Ccsds/space_packet.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,10 @@
#ifndef SPACE_PACKET_H_
#define SPACE_PACKET_H_

#include "tlm_space_packet.h"
#include "cmd_space_packet.h"

#if TSP_MAX_LEN > CSP_MAX_LEN
#define SP_MAX_LEN TSP_MAX_LEN
#else
#define SP_MAX_LEN CSP_MAX_LEN
#endif
#include <src_user/Library/stdint.h>
#include "space_packet_len.h"
#include "space_packet_typedef.h"
#include "../common_tlm_cmd_packet.h"

#define SP_PRM_HDR_LEN (6) //!< Packet Primary Header 長

Expand Down Expand Up @@ -99,10 +95,10 @@ typedef enum
* @struct SpacePacket
* @brief Space Packet
*/
typedef struct
struct SpacePacket
{
uint8_t packet[SP_MAX_LEN];
} SpacePacket;
};

/**
* @struct SP_ParamExtractionInfo
Expand Down
21 changes: 21 additions & 0 deletions TlmCmd/Ccsds/space_packet_len.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/**
* @file
* @brief CCSDS で規定される Space Packet のパケット長情報のヘッダ
* @note space_packet.h と tlm_space_packet.h, cmd_space_packet.h の相互 include 回避のため,分離した
*/
#ifndef SPACE_PACKET_LEN_H_
#define SPACE_PACKET_LEN_H_

#define TSP_MAX_LEN (432) //!< TlmSpacePacket の最大パケット長.VCDU 分割しないならこれが最大値
#define CSP_MAX_LEN (128) //!< CmdSpacePacket の最大パケット長.値は適当においている

// TSP_MAX_LEN, CSP_MAX_LEN を再定義
#include <src_user/Settings/TlmCmd/Ccsds/space_packet_len_params.h>

#if TSP_MAX_LEN > CSP_MAX_LEN
#define SP_MAX_LEN TSP_MAX_LEN
#else
#define SP_MAX_LEN CSP_MAX_LEN
#endif

#endif
12 changes: 12 additions & 0 deletions TlmCmd/Ccsds/space_packet_typedef.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/**
* @file
* @brief SpacePacket 類 と CommonTlmCmdPacket 類が相互参照するのを回避するためのヘッダ
*/
#ifndef SPACE_PACKET_TYPEDEF_H_
#define SPACE_PACKET_TYPEDEF_H_

typedef struct SpacePacket SpacePacket;
typedef struct TlmSpacePacket TlmSpacePacket;
typedef struct CmdSpacePacket CmdSpacePacket;

#endif
13 changes: 7 additions & 6 deletions TlmCmd/Ccsds/tlm_space_packet.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,17 +65,18 @@ typedef enum
} TSP_2ND_HDR_VER;


#define TSP_MAX_LEN (432) //!< TlmSpacePacket の最大パケット長.VCDU 分割しないならこれが最大値
#define TSP_SND_HDR_LEN (20) //!< Secondary Header 長
#define TSP_2ND_HDR_VER_TO_USE (TSP_2ND_HDR_VER_1) //!< 使う Sec. HDR Ver

// TSP_MAX_LEN, TSP_2ND_HDR_VER_TO_USE を再定義
#include <src_user/Settings/TlmCmd/Ccsds/tlm_space_packet_params.h>

// TODO: 上に持ってきて,コンパイルが通らないことを確認する!!!!!!!!!!!!!!!!!!
// space_packet.h と相互 include になってしまっているので,最後のここで include する
// 相互参照問題があるので,この順番で include
#include <src_user/Library/stdint.h>
#include "space_packet_len.h"
#include "space_packet_typedef.h"
#include "space_packet.h"
#include <src_core/TlmCmd/common_tlm_packet.h>
#include "../common_tlm_packet.h"

#if TSP_MAX_LEN <= SP_PRM_HDR_LEN
#error TSP_MAX_LEN is too small
Expand All @@ -88,10 +89,10 @@ typedef enum
* @note C ではテンプレートが使えないため,別で定義する
* https://github.com/ut-issl/c2a-core/issues/204
*/
typedef struct
struct TlmSpacePacket
{
uint8_t packet[TSP_MAX_LEN];
} TlmSpacePacket;
};


// ******************************
Expand Down
1 change: 1 addition & 0 deletions TlmCmd/common_tlm_cmd_packet.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#ifndef COMMON_TLM_CMD_PACKET_H_
#define COMMON_TLM_CMD_PACKET_H_

#include <src_user/Library/stdint.h>
// ここで, CTCP_MAX_LEN, CommonTlmCmdPacket として使うパケット型を指定する
#include <src_user/Settings/TlmCmd/common_tlm_cmd_packet_define.h>
#include <src_user/Settings/TlmCmd/common_tlm_cmd_packet_params.h>
Expand Down

0 comments on commit 2a90f68

Please sign in to comment.