F´ Flight Software - C/C++ Documentation NASA-v1.6.0
A framework for building embedded system applications to NASA flight quality standards.
Loading...
Searching...
No Matches
FileUplink.hpp
Go to the documentation of this file.
1// ======================================================================
2// \title FileUplink.hpp
3// \author bocchino
4// \brief hpp file for FileUplink component implementation class
5//
6// \copyright
7// Copyright 2009-2016, by the California Institute of Technology.
8// ALL RIGHTS RESERVED. United States Government Sponsorship
9// acknowledged.
10//
11// ======================================================================
12
13#ifndef Svc_FileUplink_HPP
14#define Svc_FileUplink_HPP
15
16#include <Svc/FileUplink/FileUplinkComponentAc.hpp>
18#include <Os/File.hpp>
19
20namespace Svc {
21
22 class FileUplink :
23 public FileUplinkComponentBase
24 {
25
26 PRIVATE:
27
28 // ----------------------------------------------------------------------
29 // Types
30 // ----------------------------------------------------------------------
31
33 typedef enum { START, DATA } ReceiveMode;
34
36 class File {
37
38 public:
39
41 U32 size;
42
45
47 Os::File osFile;
48
49 PRIVATE:
50
52 ::CFDP::Checksum checksum;
53
54 public:
55
58 const Fw::FilePacket::StartPacket& startPacket
59 );
60
62 Os::File::Status write(
63 const U8 *const data,
64 const U32 byteOffset,
65 const U32 length
66 );
67
69 void getChecksum(::CFDP::Checksum& checksum) {
70 checksum = this->checksum;
71 }
72
73 };
74
76 class FilesReceived {
77
78 public:
79
81 FilesReceived(FileUplink *const fileUplink) :
82 n(0), fileUplink(fileUplink)
83 { }
84
85 public:
86
88 void fileReceived() {
89 ++this->n;
90 this->fileUplink->tlmWrite_FilesReceived(n);
91 }
92
93 PRIVATE:
94
96 U32 n;
97
99 FileUplink *const fileUplink;
100
101 };
102
104 class PacketsReceived {
105
106 public:
107
109 PacketsReceived(FileUplink *const fileUplink) :
110 n(0), fileUplink(fileUplink)
111 { }
112
113 public:
114
116 void packetReceived() {
117 ++this->n;
118 this->fileUplink->tlmWrite_PacketsReceived(n);
119 }
120
121 PRIVATE:
122
124 U32 n;
125
127 FileUplink *const fileUplink;
128
129 };
130
132 class Warnings {
133
134 public:
135
137 Warnings(FileUplink *const fileUplink) :
138 n(0), fileUplink(fileUplink)
139 { }
140
141 public:
142
144 void invalidReceiveMode(const Fw::FilePacket::Type packetType);
145
147 void fileOpen(Fw::LogStringArg& fileName);
148
150 void packetOutOfBounds(
151 const U32 sequenceIndex,
152 Fw::LogStringArg& fileName
153 );
154
156 void packetOutOfOrder(
157 const U32 sequenceIndex,
158 const U32 lastSequenceIndex
159 );
160
162 void fileWrite(Fw::LogStringArg& fileName);
163
165 void badChecksum(
166 const U32 computed,
167 const U32 read
168 );
169
170 PRIVATE:
171
173 void warning() {
174 ++this->n;
175 this->fileUplink->tlmWrite_Warnings(n);
176 }
177
178 PRIVATE:
179
181 U32 n;
182
184 FileUplink *const fileUplink;
185
186 };
187
188 public:
189
190 // ----------------------------------------------------------------------
191 // Construction, initialization, and destruction
192 // ----------------------------------------------------------------------
193
197 const char *const name
198 );
199
202 void init(
203 const NATIVE_INT_TYPE queueDepth,
204 const NATIVE_INT_TYPE instance
205 );
206
209 ~FileUplink();
210
211 PRIVATE:
212
213 // ----------------------------------------------------------------------
214 // Handler implementations for user-defined typed input ports
215 // ----------------------------------------------------------------------
216
219 void bufferSendIn_handler(
220 const NATIVE_INT_TYPE portNum,
221 Fw::Buffer& buffer
222 );
223
226 void pingIn_handler(
227 const NATIVE_INT_TYPE portNum,
228 U32 key
229 );
230
231
232 PRIVATE:
233
234 // ----------------------------------------------------------------------
235 // Private helper functions
236 // ----------------------------------------------------------------------
237
239 void handleStartPacket(const Fw::FilePacket::StartPacket& startPacket);
240
242 void handleDataPacket(const Fw::FilePacket::DataPacket& dataPacket);
243
245 void handleEndPacket(const Fw::FilePacket::EndPacket& endPacket);
246
248 void handleCancelPacket();
249
251 void checkSequenceIndex(const U32 sequenceIndex);
252
254 void compareChecksums(const Fw::FilePacket::EndPacket& endPacket);
255
257 void goToStartMode();
258
260 void goToDataMode();
261
262 PRIVATE:
263
264 // ----------------------------------------------------------------------
265 // Member variables
266 // ----------------------------------------------------------------------
267
269 ReceiveMode receiveMode;
270
272 U32 lastSequenceIndex;
273
275 File file;
276
278 FilesReceived filesReceived;
279
281 PacketsReceived packetsReceived;
282
284 Warnings warnings;
285
286 };
287
288}
289
290#endif
PlatformIntType NATIVE_INT_TYPE
Definition BasicTypes.h:51
uint8_t U8
8-bit unsigned integer
Definition BasicTypes.h:26
Class representing a CFDP checksum.
Definition Checksum.hpp:23
The type of a data packet.
The type of an end packet.
The type of a start packet.
Type
Packet type.