Skip to content

Commit

Permalink
sed AOSTF to AosTransferFrame
Browse files Browse the repository at this point in the history
  • Loading branch information
meltingrabbit committed Nov 8, 2023
1 parent 94c7dc6 commit 635ba1a
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 41 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
typedef struct
{
TcpToMPdu tc_packet_to_m_pdu; //!< PL から取り出した tc_packet を M_PDU に変換する
AOSTF aostf; //!< 送信するAOSTF
AosTransferFrame aostf; //!< 送信するAOSTF
uint32_t aostf_counter; //!< AOSTF counter
} CSRV_GS_TlmPacketHandler;

Expand Down
4 changes: 2 additions & 2 deletions examples/mobc/src/src_user/component_driver/com/gs.c
Original file line number Diff line number Diff line change
Expand Up @@ -254,11 +254,11 @@ static CDS_ERR_CODE GS_analyze_rec_data_(CDS_StreamConfig* p_stream_config, void
return CDS_ERR_CODE_OK;
}

CDS_CMD_ERR_CODE GS_send_aostf(GS_Driver* gs_driver, const AOSTF* aostf)
CDS_CMD_ERR_CODE GS_send_aostf(GS_Driver* gs_driver, const AosTransferFrame* aostf)
{
CDS_ERR_CODE ret_ccsds = CDS_ERR_CODE_OK;
CDS_ERR_CODE ret_uart = CDS_ERR_CODE_OK;
size_t aostf_size = sizeof(AOSTF);
size_t aostf_size = sizeof(AosTransferFrame);

// パディングが無ければ元を GS_tx_frame_ にコピーさせる (444Byte) のコピーが無駄
if (aostf_size == AOSTF_LEN)
Expand Down
2 changes: 1 addition & 1 deletion examples/mobc/src/src_user/component_driver/com/gs.h
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,6 @@ CDS_REC_ERR_CODE GS_rec_tctf(GS_Driver* gs_driver);
* @param[in] aostf: 送信する AOSTF. 場合によってはそのまま DS に渡すので, local変数ではなくstaticな変数を渡すこと
* @return CDS_CMD_ERR_CODE: 送信結果
*/
CDS_CMD_ERR_CODE GS_send_aostf(GS_Driver* gs_driver, const AOSTF* aostf);
CDS_CMD_ERR_CODE GS_send_aostf(GS_Driver* gs_driver, const AosTransferFrame* aostf);

#endif
40 changes: 20 additions & 20 deletions examples/mobc/src/src_user/tlm_cmd/ccsds/aos_transfer_frame.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@

#include <string.h> // for memcpy

static void AOSTF_set_common_hdr_(AOSTF* aostf);
static void AOSTF_clear_spare_(AOSTF* aostf);
static void AOSTF_set_common_hdr_(AosTransferFrame* aostf);
static void AOSTF_clear_spare_(AosTransferFrame* aostf);

void AOSTF_generate_byte_stream(const AOSTF* aostf, uint8_t byte_stream[AOSTF_LEN])
void AOSTF_generate_byte_stream(const AosTransferFrame* aostf, uint8_t byte_stream[AOSTF_LEN])
{
memcpy(byte_stream, aostf->header, AOSTF_HEADER_SIZE);
byte_stream += AOSTF_HEADER_SIZE;
Expand All @@ -17,45 +17,45 @@ void AOSTF_generate_byte_stream(const AOSTF* aostf, uint8_t byte_stream[AOSTF_LE
memcpy(byte_stream, aostf->trailer, AOSTF_TRAILER_SIZE);
}

void AOSTF_setup_fill_aostf(AOSTF* aostf)
void AOSTF_setup_fill_aostf(AosTransferFrame* aostf)
{
AOSTF_set_common_hdr_(aostf);
AOSTF_set_vcid(aostf, AOSTF_VCID_FILL);
M_PDU_setup_idle_m_pdu(&(aostf->m_pdu));
}

void AOSTF_setup_realtime_aostf_hdr(AOSTF* aostf, uint32_t counter)
void AOSTF_setup_realtime_aostf_hdr(AosTransferFrame* aostf, uint32_t counter)
{
AOSTF_set_common_hdr_(aostf);
AOSTF_set_vcid(aostf, AOSTF_VCID_REALTIME);
AOSTF_set_aostf_counter(aostf, counter);
}

void AOSTF_setup_replay_aostf_hdr(AOSTF* aostf, uint32_t counter)
void AOSTF_setup_replay_aostf_hdr(AosTransferFrame* aostf, uint32_t counter)
{
AOSTF_set_common_hdr_(aostf);
AOSTF_set_replay_flag(aostf, AOSTF_REPLAY_TRUE);
AOSTF_set_vcid(aostf, AOSTF_VCID_REPLAY);
AOSTF_set_aostf_counter(aostf, counter);
}

static void AOSTF_set_common_hdr_(AOSTF* aostf)
static void AOSTF_set_common_hdr_(AosTransferFrame* aostf)
{
AOSTF_set_ver(aostf, AOSTF_VER_2);
AOSTF_set_scid(aostf, AOSTF_SCID_SAMPLE_SATELLITE); // FIXME: 仮
AOSTF_set_replay_flag(aostf, AOSTF_REPLAY_FALSE);
AOSTF_clear_spare_(aostf);
}

static void AOSTF_clear_spare_(AOSTF* aostf)
static void AOSTF_clear_spare_(AosTransferFrame* aostf)
{
unsigned int pos = 5;
uint8_t mask = 0x7f; // 01111111b

aostf->header[pos] &= (uint8_t)(~mask);
}

AOSTF_VER AOSTF_get_ver(const AOSTF* aostf)
AOSTF_VER AOSTF_get_ver(const AosTransferFrame* aostf)
{
unsigned int pos = 0;
uint8_t mask = 0xc0; // 11000000b
Expand All @@ -72,7 +72,7 @@ AOSTF_VER AOSTF_get_ver(const AOSTF* aostf)
}
}

void AOSTF_set_ver(AOSTF* aostf, AOSTF_VER ver)
void AOSTF_set_ver(AosTransferFrame* aostf, AOSTF_VER ver)
{
unsigned int pos = 0;
uint8_t mask = 0xc0; // 11000000b
Expand All @@ -82,7 +82,7 @@ void AOSTF_set_ver(AOSTF* aostf, AOSTF_VER ver)
aostf->header[pos] |= val;
}

AOSTF_SCID AOSTF_get_scdi(const AOSTF* aostf)
AOSTF_SCID AOSTF_get_scdi(const AosTransferFrame* aostf)
{
unsigned int pos = 0;
uint8_t mask1 = 0x3f; // 00111111b
Expand All @@ -102,7 +102,7 @@ AOSTF_SCID AOSTF_get_scdi(const AOSTF* aostf)
}
}

void AOSTF_set_scid(AOSTF* aostf, AOSTF_SCID scid)
void AOSTF_set_scid(AosTransferFrame* aostf, AOSTF_SCID scid)
{
unsigned int pos = 0;
uint8_t mask1 = 0x3f; // 00111111b
Expand All @@ -114,7 +114,7 @@ void AOSTF_set_scid(AOSTF* aostf, AOSTF_SCID scid)
aostf->header[pos + 1] |= (uint8_t)((scid << 6) & mask2);
}

AOSTF_VCID AOSTF_get_vcid(const AOSTF* aostf)
AOSTF_VCID AOSTF_get_vcid(const AosTransferFrame* aostf)
{
unsigned int pos = 1;
uint8_t mask = 0x3f; // 00111111b
Expand All @@ -133,7 +133,7 @@ AOSTF_VCID AOSTF_get_vcid(const AOSTF* aostf)
}
}

void AOSTF_set_vcid(AOSTF* aostf, AOSTF_VCID vcid)
void AOSTF_set_vcid(AosTransferFrame* aostf, AOSTF_VCID vcid)
{
unsigned int pos = 1;
uint8_t mask = 0x3f; // 00111111b
Expand All @@ -142,7 +142,7 @@ void AOSTF_set_vcid(AOSTF* aostf, AOSTF_VCID vcid)
aostf->header[pos] |= (uint8_t)(vcid & mask);
}

uint32_t AOSTF_get_aostf_counter(const AOSTF* aostf)
uint32_t AOSTF_get_aostf_counter(const AosTransferFrame* aostf)
{
unsigned int pos = 2;

Expand All @@ -155,7 +155,7 @@ uint32_t AOSTF_get_aostf_counter(const AOSTF* aostf)
return counter;
}

void AOSTF_set_aostf_counter(AOSTF* aostf, uint32_t counter)
void AOSTF_set_aostf_counter(AosTransferFrame* aostf, uint32_t counter)
{
unsigned int pos = 2;

Expand All @@ -164,15 +164,15 @@ void AOSTF_set_aostf_counter(AOSTF* aostf, uint32_t counter)
aostf->header[pos + 2] = (uint8_t)(counter & 0xff);
}

AOSTF_REPLAY_FLAG AOSTF_get_replay_flag(const AOSTF* aostf)
AOSTF_REPLAY_FLAG AOSTF_get_replay_flag(const AosTransferFrame* aostf)
{
unsigned int pos = 5;
uint8_t mask = 0x80; // 10000000b

return (AOSTF_REPLAY_FLAG)((aostf->header[pos] & mask) >> 7);
}

void AOSTF_set_replay_flag(AOSTF* aostf, AOSTF_REPLAY_FLAG flag)
void AOSTF_set_replay_flag(AosTransferFrame* aostf, AOSTF_REPLAY_FLAG flag)
{
unsigned int pos = 5;
uint8_t mask = 0x80; // 10000000b
Expand All @@ -181,7 +181,7 @@ void AOSTF_set_replay_flag(AOSTF* aostf, AOSTF_REPLAY_FLAG flag)
aostf->header[pos] |= (uint8_t)((flag << 7) & mask);
}

uint32_t AOSTF_get_clcw(const AOSTF* aostf)
uint32_t AOSTF_get_clcw(const AosTransferFrame* aostf)
{
unsigned int pos = 0;

Expand All @@ -196,7 +196,7 @@ uint32_t AOSTF_get_clcw(const AOSTF* aostf)
return clcw;
}

void AOSTF_set_clcw(AOSTF* aostf, uint32_t clcw)
void AOSTF_set_clcw(AosTransferFrame* aostf, uint32_t clcw)
{
unsigned int pos = 0;

Expand Down
34 changes: 17 additions & 17 deletions examples/mobc/src/src_user/tlm_cmd/ccsds/aos_transfer_frame.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ typedef struct
uint8_t header[AOSTF_HEADER_SIZE];
M_PDU m_pdu;
uint8_t trailer[AOSTF_TRAILER_SIZE];
} AOSTF;
} AosTransferFrame;

typedef enum
{
Expand Down Expand Up @@ -41,37 +41,37 @@ typedef enum
AOSTF_REPLAY_TRUE = 1 // 1b: Replay Transfer Frame
} AOSTF_REPLAY_FLAG;

void AOSTF_generate_byte_stream(const AOSTF* aostf, uint8_t byte_stream[AOSTF_LEN]);
void AOSTF_generate_byte_stream(const AosTransferFrame* aostf, uint8_t byte_stream[AOSTF_LEN]);

void AOSTF_setup_fill_aostf(AOSTF* aostf);
void AOSTF_setup_fill_aostf(AosTransferFrame* aostf);

void AOSTF_setup_realtime_aostf_hdr(AOSTF* aostf, uint32_t counter);
void AOSTF_setup_realtime_aostf_hdr(AosTransferFrame* aostf, uint32_t counter);

void AOSTF_setup_replay_aostf_hdr(AOSTF* aostf, uint32_t counter);
void AOSTF_setup_replay_aostf_hdr(AosTransferFrame* aostf, uint32_t counter);

AOSTF_VER AOSTF_get_ver(const AOSTF* aostf);
AOSTF_VER AOSTF_get_ver(const AosTransferFrame* aostf);

void AOSTF_set_ver(AOSTF* aostf, AOSTF_VER ver);
void AOSTF_set_ver(AosTransferFrame* aostf, AOSTF_VER ver);

AOSTF_SCID AOSTF_get_scdi(const AOSTF* aostf);
AOSTF_SCID AOSTF_get_scdi(const AosTransferFrame* aostf);

void AOSTF_set_scid(AOSTF* aostf, AOSTF_SCID scid);
void AOSTF_set_scid(AosTransferFrame* aostf, AOSTF_SCID scid);

AOSTF_VCID AOSTF_get_vcid(const AOSTF* aostf);
AOSTF_VCID AOSTF_get_vcid(const AosTransferFrame* aostf);

void AOSTF_set_vcid(AOSTF* aostf, AOSTF_VCID vcid);
void AOSTF_set_vcid(AosTransferFrame* aostf, AOSTF_VCID vcid);

uint32_t AOSTF_get_aostf_counter(const AOSTF* aostf);
uint32_t AOSTF_get_aostf_counter(const AosTransferFrame* aostf);

void AOSTF_set_aostf_counter(AOSTF* aostf, uint32_t counter);
void AOSTF_set_aostf_counter(AosTransferFrame* aostf, uint32_t counter);

AOSTF_REPLAY_FLAG AOSTF_get_replay_flag(const AOSTF* aostf);
AOSTF_REPLAY_FLAG AOSTF_get_replay_flag(const AosTransferFrame* aostf);

void AOSTF_set_replay_flag(AOSTF* aostf, AOSTF_REPLAY_FLAG flag);
void AOSTF_set_replay_flag(AosTransferFrame* aostf, AOSTF_REPLAY_FLAG flag);

uint32_t AOSTF_get_clcw(const AOSTF* aostf);
uint32_t AOSTF_get_clcw(const AosTransferFrame* aostf);

void AOSTF_set_clcw(AOSTF* aostf, uint32_t clcw);
void AOSTF_set_clcw(AosTransferFrame* aostf, uint32_t clcw);

uint32_t AOSTF_calc_next_counter(uint32_t prev);

Expand Down

0 comments on commit 635ba1a

Please sign in to comment.