Skip to content

Commit

Permalink
add definition of AOS TF
Browse files Browse the repository at this point in the history
  • Loading branch information
meltingrabbit committed Nov 8, 2023
1 parent 635ba1a commit 3bf5f1e
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 9 deletions.
12 changes: 7 additions & 5 deletions examples/mobc/src/src_user/tlm_cmd/ccsds/aos_transfer_frame.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
#pragma section REPRO
/**
* @file
* @brief CCSDS で規定される AOS Transfer Frame の実装
* @note 詳細は aos_transfer_frame.h を参照
*/
#include "aos_transfer_frame.h"

#include <string.h> // for memcpy
Expand Down Expand Up @@ -66,7 +71,6 @@ AOSTF_VER AOSTF_get_ver(const AosTransferFrame* aostf)
{
case AOSTF_VER_2:
return ver;

default:
return AOSTF_VER_UNKNOWN;
}
Expand Down Expand Up @@ -96,7 +100,6 @@ AOSTF_SCID AOSTF_get_scdi(const AosTransferFrame* aostf)
{
case AOSTF_SCID_SAMPLE_SATELLITE:
return (AOSTF_SCID)scid;

default:
return AOSTF_SCID_UNKNOWN;
}
Expand Down Expand Up @@ -124,10 +127,9 @@ AOSTF_VCID AOSTF_get_vcid(const AosTransferFrame* aostf)
switch (vcid)
{
case AOSTF_VCID_REALTIME: // FALLTHROUGH
case AOSTF_VCID_REPLAY: // FALLTHROUGH
case AOSTF_VCID_FILL: // FALLTHROUGH
case AOSTF_VCID_REPLAY: // FALLTHROUGH
case AOSTF_VCID_FILL: // FALLTHROUGH
return vcid;

default:
return AOSTF_VCID_UNKNOWN;
}
Expand Down
47 changes: 43 additions & 4 deletions examples/mobc/src/src_user/tlm_cmd/ccsds/aos_transfer_frame.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,42 @@
/**
* @file
* @brief CCSDS で規定される AOS Transfer Frame の実装
* @note packet 構造
* |---------+-------+-------+--------------------------|
* | Pos | Pos | Size | Name |
* | [octet] | [bit] | [bit] | |
* |---------+-------+-------+--------------------------|
* | === Primary Header ================================|
* |---------+-------+-------+--------------------------|
* | 0 | 0 | 2 | Version Number |
* | 0 | 2 | 8 | Spacecraft ID |
* | 1 | 2 | 6 | Virtual Channel ID |
* | 2 | 0 | 24 | Virtual Channel |
* | | | | Frame Count |
* | 5 | 0 | 1 | Replay Flag |
* | 5 | 1 | 1 | VC Frame Count |
* | | | | Usage Flag |
* | 5 | 2 | 2 | Reserved Spare |
* | 5 | 4 | 4 | VC Frame Count Cycle |
* |---------+-------+-------+--------------------------|
* | === User Data Field ===============================|
* |---------+-------+-------+--------------------------|
* | 6 | 0 | * | M_PDU など |
* |---------+-------+-------+--------------------------|
* | === Trailer =======================================|
* |---------+-------+-------+--------------------------|
* | N - 4 | 0 | 32 | CLCW |
* |---------+-------+-------+--------------------------|
*
* Primary Header:
* Version Number と Spacecraft ID をまとめて Master Channel ID と呼ぶ
* 以下をまとめて Signaling Field と呼ぶ
* Frame Header Error Control がある Option もある
* Transfer Frame Insert Zone:
* Primary Header の後に Transfer Frame Insert Zone がある Option もある
* Trailer:
* ここでの定義以外にさまざまな Option がある
*/
#ifndef AOS_TRANSFER_FRAME_H_
#define AOS_TRANSFER_FRAME_H_

Expand All @@ -11,7 +50,7 @@
typedef struct
{
uint8_t header[AOSTF_HEADER_SIZE];
M_PDU m_pdu;
M_PDU m_pdu;
uint8_t trailer[AOSTF_TRAILER_SIZE];
} AosTransferFrame;

Expand All @@ -30,15 +69,15 @@ typedef enum
typedef enum
{
AOSTF_VCID_REALTIME = 0x01, // 000001b: Realtime Transfer Frame
AOSTF_VCID_REPLAY = 0x02, // 000010b: Stored Transfer Frame
AOSTF_VCID_FILL = 0x3f, // 111111b: Fill Transfer Frame
AOSTF_VCID_REPLAY = 0x02, // 000010b: Stored Transfer Frame
AOSTF_VCID_FILL = 0x3f, // 111111b: Fill Transfer Frame
AOSTF_VCID_UNKNOWN
} AOSTF_VCID;

typedef enum
{
AOSTF_REPLAY_FALSE = 0, // 0b: Realtime Transfer Frame
AOSTF_REPLAY_TRUE = 1 // 1b: Replay Transfer Frame
AOSTF_REPLAY_TRUE = 1 // 1b: Replay Transfer Frame
} AOSTF_REPLAY_FLAG;

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

0 comments on commit 3bf5f1e

Please sign in to comment.