C2A_Core
space_packet.h
[詳解]
1 
36 #ifndef SPACE_PACKET_H_
37 #define SPACE_PACKET_H_
38 
39 #include <stdint.h>
40 #include "space_packet_typedef.h"
41 #include "../common_tlm_cmd_packet.h"
42 
43 #define SP_PRM_HDR_LEN (6)
44 
45 
51 typedef enum
52 {
53  SP_VER_1 = 0,
56 
63 typedef enum
64 {
66  SP_TYPE_CMD = 1
68 
75 typedef enum
76 {
80 
86 typedef enum
87 {
93 
98 typedef struct
99 {
100  uint16_t pos;
101  uint8_t mask;
102  uint8_t offset;
103  uint8_t byte_len;
105 
106 
107 // ******************************
108 // Primary Header getter/setter
109 // ******************************
110 
116 SP_VER SP_get_ver(const SpacePacket* sp);
117 
124 void SP_set_ver(SpacePacket* sp, SP_VER ver);
125 
131 SP_TYPE SP_get_type(const SpacePacket* sp);
132 
139 void SP_set_type(SpacePacket* sp, SP_TYPE type);
140 
147 
155 
161 APID SP_get_apid(const SpacePacket* sp);
162 
169 void SP_set_apid(SpacePacket* sp, APID apid);
170 
177 
184 void SP_set_seq_flag(SpacePacket* sp, SP_SEQ_FLAG flag);
185 
191 uint16_t SP_get_seq_count(const SpacePacket* sp);
192 
199 void SP_set_seq_count(SpacePacket* sp, uint16_t count);
200 
206 uint16_t SP_get_packet_data_len(const SpacePacket* sp);
207 
216 void SP_set_packet_data_len(SpacePacket* sp, uint16_t len);
217 
218 
219 // ******************
220 // Utility Function
221 // ******************
222 
228 uint16_t SP_get_packet_len(const SpacePacket* sp);
229 
236 void SP_set_packet_len(SpacePacket* sp, uint16_t len);
237 
245 void SP_copy_packet(SpacePacket* dest, const SpacePacket* src);
246 
255  const SP_ParamExtractionInfo* pei,
256  void* dst);
257 
266  const SP_ParamExtractionInfo* pei,
267  const void* src);
268 
269 #endif
APID
Application Process ID
Definition: apid_define.h:17
void SP_set_packet_data_len(SpacePacket *sp, uint16_t len)
Packet Data Length を設定
Definition: space_packet.c:138
SP_2ND_HDR_FLAG SP_get_2nd_hdr_flag(const SpacePacket *sp)
Secondary Header Flag を取得
Definition: space_packet.c:66
uint16_t SP_get_seq_count(const SpacePacket *sp)
Sequence Count を取得
Definition: space_packet.c:113
uint16_t SP_get_packet_len(const SpacePacket *sp)
Packet Length を取得
Definition: space_packet.c:152
void SP_extract_param_from_packet(const SpacePacket *sp, const SP_ParamExtractionInfo *pei, void *dst)
packet に格納された param を取得
Definition: space_packet.c:171
SP_TYPE
Space Packet Type
Definition: space_packet.h:64
@ SP_TYPE_TLM
0b: TELEMETRY
Definition: space_packet.h:65
@ SP_TYPE_CMD
1b: COMMAND
Definition: space_packet.h:66
SP_SEQ_FLAG SP_get_seq_flag(const SpacePacket *sp)
Sequence Flag を取得
Definition: space_packet.c:97
SP_2ND_HDR_FLAG
Space Packet Secandary Header Flag
Definition: space_packet.h:76
@ SP_2ND_HDR_FLAG_PRESENT
1b: Secondary Header Present
Definition: space_packet.h:78
@ SP_2ND_HDR_FLAG_ABSENT
0b: Secondary Header Absent
Definition: space_packet.h:77
void SP_set_ver(SpacePacket *sp, SP_VER ver)
Version No を設定
Definition: space_packet.c:43
SP_SEQ_FLAG
Space Packet Sequence Flag
Definition: space_packet.h:87
@ SP_SEQ_FLAG_CONT
00b: Continuation component of higher data structure
Definition: space_packet.h:88
@ SP_SEQ_FLAG_FIRST
01b: First component of higher data structure
Definition: space_packet.h:89
@ SP_SEQ_FLAG_LAST
10b: Last component of higher data structure
Definition: space_packet.h:90
@ SP_SEQ_FLAG_SINGLE
11b: Standalone packet
Definition: space_packet.h:91
void SP_set_seq_flag(SpacePacket *sp, SP_SEQ_FLAG flag)
Sequence Flag を設定
Definition: space_packet.c:106
void SP_set_seq_count(SpacePacket *sp, uint16_t count)
Sequence Count を設定
Definition: space_packet.c:122
APID SP_get_apid(const SpacePacket *sp)
APID を取得
Definition: space_packet.c:82
void SP_insert_param_to_packet(SpacePacket *sp, const SP_ParamExtractionInfo *pei, const void *src)
packet に param を格納
Definition: space_packet.c:207
void SP_set_2nd_hdr_flag(SpacePacket *sp, SP_2ND_HDR_FLAG flag)
Secondary Header Flag を設定
Definition: space_packet.c:75
SP_VER
Space Packet Version Number
Definition: space_packet.h:52
@ SP_VER_UNKNOWN
Definition: space_packet.h:54
@ SP_VER_1
000b: Version-1
Definition: space_packet.h:53
uint16_t SP_get_packet_data_len(const SpacePacket *sp)
Packet Data Length を取得
Definition: space_packet.c:128
void SP_set_type(SpacePacket *sp, SP_TYPE type)
Packet Type を設定
Definition: space_packet.c:59
void SP_set_packet_len(SpacePacket *sp, uint16_t len)
Packet Length を設定
Definition: space_packet.c:158
SP_VER SP_get_ver(const SpacePacket *sp)
Version No を取得
Definition: space_packet.c:25
void SP_copy_packet(SpacePacket *dest, const SpacePacket *src)
SpacePacket をコピー
Definition: space_packet.c:165
void SP_set_apid(SpacePacket *sp, APID apid)
APID を設定
Definition: space_packet.c:90
SP_TYPE SP_get_type(const SpacePacket *sp)
Packet Type を取得
Definition: space_packet.c:50
SpacePacket 類 と CommonTlmCmdPacket 類が相互参照するのを回避するためのヘッダ
C89 環境用 stdint.h
packet からデータを抜き取るときのパラメタ
Definition: space_packet.h:99
uint16_t pos
位置
Definition: space_packet.h:100
uint8_t mask
1 byte 目にあてるマスク
Definition: space_packet.h:101
uint8_t offset
bit offset (bit が左シフトされて格納されている場合)
Definition: space_packet.h:102
uint8_t byte_len
パケット octet 列の何 byte にわたるか.最大 8 (64bit)
Definition: space_packet.h:103
Space Packet