InertiaSDK

Loading...
Searching...
No Matches
FlashCommands.h
1#pragma once
2
3#include "data/command/InertiaCommand.h"
4
5 namespace inertia
6{
7
9 enum FlashCommands : uint8_t {
10 FlashStatus = 1, // both ProMoveFS & FAT
11 FlashCheck = 2, // ProMoveFS
12 FlashFormat = 3, // both ProMoveFS & FAT
13 FlashGetFirstFile = 4, // ProMoveFS
14 FlashGetNextFile = 5, // ProMoveFS
15 FlashList = 6, // FAT
16 FlashOpen = 7, // FAT
17 FlashClose = 8, // FAT
18 FlashRead = 9, // FAT
19 FlashSeek = 10, // FAT
20 FlashListEx = 11, // FAT
21 FlashCreate = 12, //FAT
22 FlashWrite = 13, // FAT
23 FlashLast
24};
25
26
28 enum FlashStateType {
29 FlashStateOK = 0,
30 FlashStateReadable = 1, // minor version is invalid
31 FlashStateInvalid = 2, // File system invalid, need to reformat
32 FlashUnformatted = 3, // complete memory needs to be formatted and prepared
33 FlashUnsupported = 4 // Unknown memory type, no actions possible
34};
35
36
38 enum FilesystemCode {
39 ProMoveFS = 1,
40 FAT16 = 2,
41 FAT32 = 3,
42 FS_UNKNOWN
43};
44
45
46 struct INERTIA_API FlashFileItem
47{
48 std::wstring filename;
49 uint32_t filesize;
50 uint32_t filePointer;
51 uint32_t createTime;
52 uint32_t accessTime;
53 uint32_t modifyTime;
54 bool hasExtendedInfo;
55
56 FlashFileItem();
57 FlashFileItem(std::wstring const& argString);
58 FlashFileItem(const std::wstring& _filename, const uint32_t _filesize);
59 FlashFileItem(const std::wstring& _filename, const uint32_t _filesize, const uint32_t _filePointer);
60 FlashFileItem(const std::wstring& _filename, const uint32_t _filesize, const uint32_t _createTime, const uint32_t _accessTime, const uint32_t _modifyTime);
61
62 const std::wstring ToString() const;
63
64#ifdef WITH_BOOST_PROGRAM_OPTIONS
65 static const po::options_description GetOptionDescription();
66#endif
67};
68
69
70 struct INERTIA_API FlashCommand
71 : InertiaCommand
72{
73 protected:
74 FlashCommand();
75 FlashCommand(const uint8_t* packet, const unsigned max_size);
76 FlashCommand(std::wstring const& argString);
77
78 public:
79 InertiaCommandGroups GetGroup() const override;
80 static std::wstring GetName(FlashCommands const command);
81
82 static InertiaCommandPtr Parse(const uint8_t* in, unsigned const packetSize);
83 static InertiaCommandPtr Parse(std::wstring const& argString);
84};
85
86
87 struct INERTIA_API FlashStatusRequest
88 : FlashCommand
89{
90 FlashStatusRequest();
91 FlashStatusRequest(const uint8_t* packet, const unsigned max_size);
92 FlashStatusRequest(std::wstring const& argString);
93
94 void GetBytes(std::vector<uint8_t>& out) const override;
95 const std::wstring ToString() const override;
96
97#ifdef WITH_BOOST_PROGRAM_OPTIONS
98 static const po::options_description GetOptionDescription();
99#endif
100
101 uint8_t GetType() const override;
102 bool IsResponse() const override;
103};
104
105
106 struct INERTIA_API FlashStatusResponse
107 : FlashCommand
108{
109 FlashStateType state;
110 uint8_t dataState;
111 uint8_t version;
112 FilesystemCode code;
113 uint8_t hardwareRevision;
114 uint8_t softwareMajorRevision, softwareMinorRevision, softwareHotFix;
115 uint64_t memorySize;
116 uint64_t freeMemorySize;
117 uint32_t nFileSequences;
118 uint8_t reserved1;
119
120 FlashStatusResponse(const uint8_t* packet, const unsigned max_size);
121 FlashStatusResponse(std::wstring const& argString);
122
123 void GetBytes(std::vector<uint8_t>& out) const override;
124 const std::wstring ToString() const override;
125 static const std::wstring FlashStateToString(const FlashStateType state);
126
127#ifdef WITH_BOOST_PROGRAM_OPTIONS
128 static const po::options_description GetOptionDescription();
129#endif
130
131 uint8_t GetType() const override;
132 bool IsResponse() const override;
133};
134
135
136 struct INERTIA_API FlashCheckRequest
137 : FlashCommand
138{
139 FlashCheckRequest();
140 FlashCheckRequest(const uint8_t* packet, const unsigned max_size);
141 FlashCheckRequest(std::wstring const& argString);
142
143 void GetBytes(std::vector<uint8_t>& out) const override;
144 const std::wstring ToString() const override;
145
146#ifdef WITH_BOOST_PROGRAM_OPTIONS
147 static const po::options_description GetOptionDescription();
148#endif
149
150 uint8_t GetType() const override;
151 bool IsResponse() const override;
152};
153
154
155 struct INERTIA_API FlashCheckResponse
156 : FlashCommand
157 , BoolValue
158{
159 FlashCheckResponse(const uint8_t* packet, const unsigned max_size);
160 FlashCheckResponse(std::wstring const& argString);
161
162 void GetBytes(std::vector<uint8_t>& out) const override;
163 const std::wstring ToString() const override;
164
165#ifdef WITH_BOOST_PROGRAM_OPTIONS
166 static const po::options_description GetOptionDescription();
167#endif
168
169 uint8_t GetType() const override;
170 bool IsResponse() const override;
171};
172
173
174 struct INERTIA_API FlashFormatRequest
175 : FlashCommand
176{
177 bool formatData;
178 bool formatConfig;
179 bool formatAsFAT16;
180
181 FlashFormatRequest();
182 FlashFormatRequest(const uint8_t* packet, const unsigned max_size);
183 FlashFormatRequest(std::wstring const& argString);
184
185 void GetBytes(std::vector<uint8_t>& out) const override;
186 const std::wstring ToString() const override;
187
188#ifdef WITH_BOOST_PROGRAM_OPTIONS
189 static const po::options_description GetOptionDescription();
190#endif
191
192 uint8_t GetType() const override;
193 bool IsResponse() const override;
194};
195
196
197 struct INERTIA_API FlashFormatResponse
198 : FlashCommand
199 , BoolValue
200{
201 FlashFormatResponse(const uint8_t* packet, const unsigned max_size);
202 FlashFormatResponse(std::wstring const& argString);
203
204 void GetBytes(std::vector<uint8_t>& out) const override;
205 const std::wstring ToString() const override;
206
207#ifdef WITH_BOOST_PROGRAM_OPTIONS
208 static const po::options_description GetOptionDescription();
209#endif
210
211 uint8_t GetType() const override;
212 bool IsResponse() const override;
213};
214
215
216 struct INERTIA_API FlashGetFirstFileRequest
217 : FlashCommand
218{
219 uint8_t sequenceID;
220
221 FlashGetFirstFileRequest();
222 FlashGetFirstFileRequest(const uint8_t* packet, const unsigned max_size);
223 FlashGetFirstFileRequest(std::wstring const& argString);
224
225 void GetBytes(std::vector<uint8_t>& out) const override;
226 const std::wstring ToString() const override;
227
228#ifdef WITH_BOOST_PROGRAM_OPTIONS
229 static const po::options_description GetOptionDescription();
230#endif
231
232 uint8_t GetType() const override;
233 bool IsResponse() const override;
234};
235
236
237 struct INERTIA_API FlashGetFirstFileResponse
238 : FlashCommand
239{
240 bool result;
241 uint32_t filePointer;
242
243 FlashGetFirstFileResponse(const uint8_t* packet, const unsigned max_size);
244 FlashGetFirstFileResponse(std::wstring const& argString);
245
246 void GetBytes(std::vector<uint8_t>& out) const override;
247 const std::wstring ToString() const override;
248
249#ifdef WITH_BOOST_PROGRAM_OPTIONS
250 static const po::options_description GetOptionDescription();
251#endif
252
253 uint8_t GetType() const override;
254 bool IsResponse() const override;
255};
256
257
258 struct INERTIA_API FlashGetNextFileRequest
259 : FlashCommand
260{
261 uint32_t filePointer;
262 int32_t fileCount;
263
264 FlashGetNextFileRequest();
265 FlashGetNextFileRequest(const uint8_t* packet, const unsigned max_size);
266 FlashGetNextFileRequest(std::wstring const& argString);
267
268 void GetBytes(std::vector<uint8_t>& out) const override;
269 const std::wstring ToString() const override;
270
271#ifdef WITH_BOOST_PROGRAM_OPTIONS
272 static const po::options_description GetOptionDescription();
273#endif
274
275 uint8_t GetType() const override;
276 bool IsResponse() const override;
277};
278
279
280 struct INERTIA_API FlashGetNextFileResponse
281 : FlashCommand
282{
283 bool result;
284 uint8_t fileLength;
285 uint8_t sequenceID;
286 uint8_t displacement;
287 std::vector<uint8_t> rawdata;
288
289 FlashGetNextFileResponse(const uint8_t* packet, const unsigned max_size);
290 FlashGetNextFileResponse(std::wstring const& argString);
291
292 void GetBytes(std::vector<uint8_t>& out) const override;
293 const std::wstring ToString() const override;
294
295#ifdef WITH_BOOST_PROGRAM_OPTIONS
296 static const po::options_description GetOptionDescription();
297#endif
298
299 uint8_t GetType() const override;
300 bool IsResponse() const override;
301};
302
303
304 struct INERTIA_API FlashListRequest
305 : FlashCommand
306{
307 FlashListRequest();
308 FlashListRequest(const uint8_t* packet, const unsigned max_size);
309 FlashListRequest(std::wstring const& argString);
310
311 void GetBytes(std::vector<uint8_t>& out) const override;
312 const std::wstring ToString() const override;
313
314#ifdef WITH_BOOST_PROGRAM_OPTIONS
315 static const po::options_description GetOptionDescription();
316#endif
317
318 uint8_t GetType() const override;
319 bool IsResponse() const override;
320};
321
322
323 struct INERTIA_API FlashListResponse
324 : FlashCommand
325{
326 std::vector<FlashFileItem> flashFiles;
327
328 FlashListResponse(const uint8_t* packet, const unsigned max_size);
329 FlashListResponse(std::wstring const& argString);
330
331 void GetBytes(std::vector<uint8_t>& out) const override;
332 const std::wstring ToString() const override;
333
334#ifdef WITH_BOOST_PROGRAM_OPTIONS
335 static const po::options_description GetOptionDescription();
336#endif
337
338 uint8_t GetType() const override;
339 bool IsResponse() const override;
340};
341
342
343 struct INERTIA_API FlashOpenRequest
344 : FlashCommand
345{
346 std::wstring filename;
347
348 FlashOpenRequest();
349 FlashOpenRequest(const uint8_t* packet, const unsigned max_size);
350 FlashOpenRequest(std::wstring const& argString);
351
352 void GetBytes(std::vector<uint8_t>& out) const override;
353 const std::wstring ToString() const override;
354
355#ifdef WITH_BOOST_PROGRAM_OPTIONS
356 static const po::options_description GetOptionDescription();
357#endif
358
359 uint8_t GetType() const override;
360 bool IsResponse() const override;
361};
362
363
364 struct INERTIA_API FlashOpenResponse
365 : FlashCommand
366 , BoolValue
367{
368 FlashOpenResponse(const uint8_t* packet, const unsigned max_size);
369 FlashOpenResponse(std::wstring const& argString);
370
371 void GetBytes(std::vector<uint8_t>& out) const override;
372 const std::wstring ToString() const override;
373
374#ifdef WITH_BOOST_PROGRAM_OPTIONS
375 static const po::options_description GetOptionDescription();
376#endif
377
378 uint8_t GetType() const override;
379 bool IsResponse() const override;
380};
381
382
383 struct INERTIA_API FlashCloseRequest
384 : FlashCommand
385{
386 FlashCloseRequest();
387 FlashCloseRequest(const uint8_t* packet, const unsigned max_size);
388 FlashCloseRequest(std::wstring const& argString);
389
390 void GetBytes(std::vector<uint8_t>& out) const override;
391 const std::wstring ToString() const override;
392
393#ifdef WITH_BOOST_PROGRAM_OPTIONS
394 static const po::options_description GetOptionDescription();
395#endif
396
397 uint8_t GetType() const override;
398 bool IsResponse() const override;
399};
400
401
402 struct INERTIA_API FlashCloseResponse
403 : FlashCommand
404 , BoolValue
405{
406 FlashCloseResponse(const uint8_t* packet, const unsigned max_size);
407 FlashCloseResponse(std::wstring const& argString);
408
409 void GetBytes(std::vector<uint8_t>& out) const override;
410 const std::wstring ToString() const override;
411
412#ifdef WITH_BOOST_PROGRAM_OPTIONS
413 static const po::options_description GetOptionDescription();
414#endif
415
416 uint8_t GetType() const override;
417 bool IsResponse() const override;
418};
419
420
421 struct INERTIA_API FlashReadRequest
422 : FlashCommand
423{
424 uint32_t readSize;
425
426 FlashReadRequest();
427 FlashReadRequest(const uint8_t* packet, const unsigned max_size);
428 FlashReadRequest(std::wstring const& argString);
429
430 void GetBytes(std::vector<uint8_t>& out) const override;
431 const std::wstring ToString() const override;
432
433#ifdef WITH_BOOST_PROGRAM_OPTIONS
434 static const po::options_description GetOptionDescription();
435#endif
436
437 uint8_t GetType() const override;
438 bool IsResponse() const override;
439};
440
441
442 struct INERTIA_API FlashReadResponse
443 : FlashCommand
444{
445 uint32_t filePointer;
446 std::vector<uint8_t> rawdata;
447
448 FlashReadResponse(const uint8_t* packet, const unsigned max_size);
449 FlashReadResponse(std::wstring const& argString);
450
451 void GetBytes(std::vector<uint8_t>& out) const override;
452 const std::wstring ToString() const override;
453
454#ifdef WITH_BOOST_PROGRAM_OPTIONS
455 static const po::options_description GetOptionDescription();
456#endif
457
458 uint8_t GetType() const override;
459 bool IsResponse() const override;
460};
461
462
463 struct INERTIA_API FlashSeekRequest
464 : FlashCommand
465{
466 uint32_t filePointer;
467
468 FlashSeekRequest();
469 FlashSeekRequest(const uint8_t* packet, const unsigned max_size);
470 FlashSeekRequest(std::wstring const& argString);
471
472 void GetBytes(std::vector<uint8_t>& out) const override;
473 const std::wstring ToString() const override;
474
475#ifdef WITH_BOOST_PROGRAM_OPTIONS
476 static const po::options_description GetOptionDescription();
477#endif
478
479 uint8_t GetType() const override;
480 bool IsResponse() const override;
481};
482
483
484 struct INERTIA_API FlashSeekResponse
485 : FlashCommand
486 , BoolValue
487{
488 FlashSeekResponse(const uint8_t* packet, const unsigned max_size);
489 FlashSeekResponse(std::wstring const& argString);
490
491 void GetBytes(std::vector<uint8_t>& out) const override;
492 const std::wstring ToString() const override;
493
494#ifdef WITH_BOOST_PROGRAM_OPTIONS
495 static const po::options_description GetOptionDescription();
496#endif
497
498 uint8_t GetType() const override;
499 bool IsResponse() const override;
500};
501
502
503 struct INERTIA_API FlashListExRequest
504 : FlashCommand
505{
506 uint32_t fromTime;
507
508 FlashListExRequest();
509 FlashListExRequest(const uint8_t* packet, const unsigned max_size);
510 FlashListExRequest(std::wstring const& argString);
511
512 void GetBytes(std::vector<uint8_t>& out) const override;
513 const std::wstring ToString() const override;
514
515#ifdef WITH_BOOST_PROGRAM_OPTIONS
516 static const po::options_description GetOptionDescription();
517#endif
518
519 uint8_t GetType() const override;
520 bool IsResponse() const override;
521};
522
523
524 struct INERTIA_API FlashListExResponse
525 : FlashCommand
526{
527 uint8_t listExVersion;
528 uint8_t chunkIndex;
529 std::vector<FlashFileItem> flashFiles;
530
531 FlashListExResponse(const uint8_t* packet, const unsigned max_size);
532 FlashListExResponse(std::wstring const& argString);
533
534 void GetBytes(std::vector<uint8_t>& out) const override;
535 const std::wstring ToString() const override;
536
537#ifdef WITH_BOOST_PROGRAM_OPTIONS
538 static const po::options_description GetOptionDescription();
539#endif
540
541 uint8_t GetType() const override;
542 bool IsResponse() const override;
543};
544
545
546 struct INERTIA_API FlashCreateRequest
547 : FlashCommand
548{
549 std::wstring filename;
550
551 FlashCreateRequest();
552 FlashCreateRequest(const uint8_t* packet, const unsigned max_size);
553 FlashCreateRequest(std::wstring const& argString);
554
555 void GetBytes(std::vector<uint8_t>& out) const override;
556 const std::wstring ToString() const override;
557
558#ifdef WITH_BOOST_PROGRAM_OPTIONS
559 static const po::options_description GetOptionDescription();
560#endif
561
562 uint8_t GetType() const override;
563 bool IsResponse() const override;
564};
565
566
567 struct INERTIA_API FlashCreateResponse
568 : FlashCommand
569 , BoolValue
570{
571 FlashCreateResponse(const uint8_t* packet, const unsigned max_size);
572 FlashCreateResponse(std::wstring const& argString);
573
574 void GetBytes(std::vector<uint8_t>& out) const override;
575 const std::wstring ToString() const override;
576
577#ifdef WITH_BOOST_PROGRAM_OPTIONS
578 static const po::options_description GetOptionDescription();
579#endif
580
581 uint8_t GetType() const override;
582 bool IsResponse() const override;
583};
584
585
586 struct INERTIA_API FlashWriteRequest
587 : FlashCommand
588{
589 std::vector<uint8_t> data;
590
591 FlashWriteRequest();
592 FlashWriteRequest(const uint8_t* packet, const unsigned max_size);
593 FlashWriteRequest(std::wstring const& argString);
594
595 void GetBytes(std::vector<uint8_t>& out) const override;
596 const std::wstring ToString() const override;
597
598#ifdef WITH_BOOST_PROGRAM_OPTIONS
599 static const po::options_description GetOptionDescription();
600#endif
601
602 uint8_t GetType() const override;
603 bool IsResponse() const override;
604};
605
606
607 struct INERTIA_API FlashWriteResponse
608 : FlashCommand
609 , BoolValue
610{
611 FlashWriteResponse(const uint8_t* packet, const unsigned max_size);
612 FlashWriteResponse(std::wstring const& argString);
613
614 void GetBytes(std::vector<uint8_t>& out) const override;
615 const std::wstring ToString() const override;
616
617#ifdef WITH_BOOST_PROGRAM_OPTIONS
618 static const po::options_description GetOptionDescription();
619#endif
620
621 uint8_t GetType() const override;
622 bool IsResponse() const override;
623};
624
625}
inertia
Definition FlashCommands.h:6
inertia::FlashStateType
FlashStateType
Definition FlashCommands.h:28
inertia::FlashCommands
FlashCommands
Definition FlashCommands.h:9
inertia::InertiaCommandPtr
std::shared_ptr< InertiaCommand > InertiaCommandPtr
Pointer to an InertiaCommand.
Definition platform.h:52
inertia::InertiaCommandGroups
InertiaCommandGroups
Definition InertiaCommand.h:7
inertia::FilesystemCode
FilesystemCode
Definition FlashCommands.h:38