Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
aos_transfer_frame
Browse files Browse the repository at this point in the history
meltingrabbit committed Nov 8, 2023
1 parent a3f8b83 commit 94c7dc6
Showing 4 changed files with 29 additions and 46 deletions.
Original file line number Diff line number Diff line change
@@ -9,7 +9,7 @@

#include "../../component_driver/com/gs.h"
#include "../../tlm_cmd/ccsds/tcp_to_m_pdu.h"
#include "../../tlm_cmd/ccsds/aostf.h"
#include "../../tlm_cmd/ccsds/aos_transfer_frame.h"
#include <src_core/system/application_manager/app_info.h>

/**
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
@@ -10,7 +10,7 @@
#include <src_core/hal/uart.h>
#include <src_core/hal/ccsds.h>
#include "../../hal/ccsds_user.h"
#include "../../tlm_cmd/ccsds/aostf.h"
#include "../../tlm_cmd/ccsds/aos_transfer_frame.h"
#include "gs_validate.h"

#define GS_RX_HEADER_NUM (3)
30 changes: 11 additions & 19 deletions examples/mobc/src/src_user/tlm_cmd/ccsds/aos_transfer_frame.c
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
#pragma section REPRO
#include "aostf.h"
#include "aos_transfer_frame.h"

#include <string.h> // for memcpy

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

void AOSTF_generate_byte_stream(const AOSTF* aostf,
uint8_t byte_stream[AOSTF_LEN])
void AOSTF_generate_byte_stream(const AOSTF* aostf, uint8_t byte_stream[AOSTF_LEN])
{
memcpy(byte_stream, aostf->header, AOSTF_HEADER_SIZE);
byte_stream += AOSTF_HEADER_SIZE;
@@ -25,16 +24,14 @@ void AOSTF_setup_fill_aostf(AOSTF* aostf)
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(AOSTF* 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(AOSTF* aostf, uint32_t counter)
{
AOSTF_set_common_hdr_(aostf);
AOSTF_set_replay_flag(aostf, AOSTF_REPLAY_TRUE);
@@ -75,8 +72,7 @@ AOSTF_VER AOSTF_get_ver(const AOSTF* aostf)
}
}

void AOSTF_set_ver(AOSTF* aostf,
AOSTF_VER ver)
void AOSTF_set_ver(AOSTF* aostf, AOSTF_VER ver)
{
unsigned int pos = 0;
uint8_t mask = 0xc0; // 11000000b
@@ -106,8 +102,7 @@ AOSTF_SCID AOSTF_get_scdi(const AOSTF* aostf)
}
}

void AOSTF_set_scid(AOSTF* aostf,
AOSTF_SCID scid)
void AOSTF_set_scid(AOSTF* aostf, AOSTF_SCID scid)
{
unsigned int pos = 0;
uint8_t mask1 = 0x3f; // 00111111b
@@ -138,8 +133,7 @@ AOSTF_VCID AOSTF_get_vcid(const AOSTF* aostf)
}
}

void AOSTF_set_vcid(AOSTF* aostf,
AOSTF_VCID vcid)
void AOSTF_set_vcid(AOSTF* aostf, AOSTF_VCID vcid)
{
unsigned int pos = 1;
uint8_t mask = 0x3f; // 00111111b
@@ -161,8 +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(AOSTF* aostf, uint32_t counter)
{
unsigned int pos = 2;

@@ -179,8 +172,7 @@ AOSTF_REPLAY_FLAG AOSTF_get_replay_flag(const AOSTF* aostf)
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(AOSTF* aostf, AOSTF_REPLAY_FLAG flag)
{
unsigned int pos = 5;
uint8_t mask = 0x80; // 10000000b
@@ -204,8 +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(AOSTF* aostf, uint32_t clcw)
{
unsigned int pos = 0;

@@ -219,4 +210,5 @@ uint32_t AOSTF_calc_next_counter(uint32_t prev)
{
return (prev + 1) % AOSTF_COUNTER_MAX;
}

#pragma section
41 changes: 16 additions & 25 deletions examples/mobc/src/src_user/tlm_cmd/ccsds/aos_transfer_frame.h
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
#ifndef AOSTF_H_
#define AOSTF_H_
#ifndef AOS_TRANSFER_FRAME_H_
#define AOS_TRANSFER_FRAME_H_

#include "m_pdu.h"

#define AOSTF_HEADER_SIZE (6u)
#define AOSTF_TRAILER_SIZE (4u)
#define AOSTF_LEN (AOSTF_HEADER_SIZE + M_PDU_LEN + AOSTF_TRAILER_SIZE)
#define AOSTF_COUNTER_MAX (0x01000000) // 24bit長
#define AOSTF_HEADER_SIZE (6u)
#define AOSTF_TRAILER_SIZE (4u)
#define AOSTF_LEN (AOSTF_HEADER_SIZE + M_PDU_LEN + AOSTF_TRAILER_SIZE)
#define AOSTF_COUNTER_MAX (0x01000000) // 24bit長

typedef struct
{
@@ -41,47 +41,38 @@ 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 AOSTF* aostf, uint8_t byte_stream[AOSTF_LEN]);

void AOSTF_setup_fill_aostf(AOSTF* aostf);

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

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

AOSTF_VER AOSTF_get_ver(const AOSTF* aostf);

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

AOSTF_SCID AOSTF_get_scdi(const AOSTF* aostf);

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

AOSTF_VCID AOSTF_get_vcid(const AOSTF* aostf);

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

uint32_t AOSTF_get_aostf_counter(const AOSTF* aostf);

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

AOSTF_REPLAY_FLAG AOSTF_get_replay_flag(const AOSTF* aostf);

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

uint32_t AOSTF_get_clcw(const AOSTF* aostf);

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

uint32_t AOSTF_calc_next_counter(uint32_t prev);

#endif // AOSTF_H_
#endif

0 comments on commit 94c7dc6

Please sign in to comment.