CCSDS
ccsds_transferframe.h
Go to the documentation of this file.
1
11#ifndef _CCSDS_TRANSFERFRAME_H_
12#define _CCSDS_TRANSFERFRAME_H_
13
14
15
16/****************************************************************/
17/* Transferframes according to */
18/* */
19/* - CCSDS 131.0-B-3, - TM Synchronization and Channel Coding */
20/* https://public.ccsds.org/Pubs/131x0b3e1.pdf */
21/* - CCSDS 132.0-B-2, - TM Space Data Link Protocol */
22/* https://public.ccsds.org/Pubs/132x0b2.pdf */
23/* - CCSDS 231.0-B-3, - TC Synchronization and Channel Coding */
24/* https://public.ccsds.org/Pubs/231x0b3.pdf */
25/* - CCSDS 232.0-B-3, - TC Space Data Link Protocol */
26/* https://public.ccsds.org/Pubs/232x0b3.pdf */
27/* */
28/****************************************************************/
29
30#include "configCCSDS.h"
31
32
33#ifdef configTF_USE_OCF
34#define TF_USE_FECF configTF_USE_FECF
35#else
36#define TF_USE_FECF 1
37#endif
38
39
40
41
42#define TF_SYNC_SIZE 4
43
44namespace CCSDS
45{
46
57 {
58 protected:
59 const static uint8_t SyncSize = TF_SYNC_SIZE;
60 const static uint8_t FecfSize = 2;
61 const static bool UseFECF = (TF_USE_FECF)?true:false; // Frame error control field (CRC)
62
63 uint16_t mu16_Index;
64 uint16_t mu16_FrameLength;
65 bool mb_Sync;
66 uint16_t mu16_SyncErrorCount;
67 uint16_t mu16_ChecksumErrorCount;
68 uint16_t mu16_OverflowErrorCount;
69
70 public:
71 void setSync(void);
72 int32_t process(const uint8_t *pu8_Data, const uint16_t u16_DataSize);
73 uint16_t getSyncErrorCount(void);
74 uint16_t getChecksumErrorCount(void);
75 uint16_t getOverflowErrorCount(void);
76 void clearErrorCounters(void);
77
78 public:
79 Transferframe(void);
80 bool _checkCRC(void);
81 static uint16_t calcCRC(const uint8_t *pu8_Buffer, const uint16_t u16_BufferSize);
82
83 private:
84 virtual uint16_t _getMaxTfSize(void) = 0;
85 virtual uint8_t *_getTfBufferAddr(void) = 0;
86 virtual uint16_t _getPrimaryHeaderSize(void) = 0;
87 virtual void _getFrameLength(void) = 0;
88 virtual int32_t _processFrame(void) = 0;
89 };
90
91
92}
93
94#endif // _CCSDS_TRANSFERFRAME_H_
95
96
Base Class for handling Transfer Frames as described in CCSDS 131.0-B-3, CCSDS 132....
Definition: ccsds_transferframe.h:57
void setSync(void)
Sets the sync flag for the transfer frame processing.
Definition: ccsds_transferframe.cpp:69
Transferframe(void)
Construct a new Transferframe object.
Definition: ccsds_transferframe.cpp:49
uint16_t getChecksumErrorCount(void)
Returns the number of checksum errors.
Definition: ccsds_transferframe.cpp:203
uint16_t getSyncErrorCount(void)
Returns the number of sync errors.
Definition: ccsds_transferframe.cpp:189
int32_t process(const uint8_t *pu8_Data, const uint16_t u16_DataSize)
The given data stream is parsed for Transfer Frames.
Definition: ccsds_transferframe.cpp:95
void clearErrorCounters(void)
Clears all error counters (Sync Error, Overflow Error and Checksum Error)
Definition: ccsds_transferframe.cpp:230
uint16_t getOverflowErrorCount(void)
Returns the number of overflow errors.
Definition: ccsds_transferframe.cpp:221