CCSDS
|
Base Class for handling Transfer Frames as described in CCSDS 131.0-B-3, CCSDS 132.0-B-2, CCSDS 231.0-B-3 and CCSDS 232.0-B-3. More...
#include <ccsds_transferframe.h>
Public Member Functions | |
void | setSync (void) |
Sets the sync flag for the transfer frame processing. More... | |
int32_t | process (const uint8_t *pu8_Data, const uint16_t u16_DataSize) |
The given data stream is parsed for Transfer Frames. More... | |
uint16_t | getSyncErrorCount (void) |
Returns the number of sync errors. More... | |
uint16_t | getChecksumErrorCount (void) |
Returns the number of checksum errors. More... | |
uint16_t | getOverflowErrorCount (void) |
Returns the number of overflow errors. More... | |
void | clearErrorCounters (void) |
Clears all error counters (Sync Error, Overflow Error and Checksum Error) | |
Transferframe (void) | |
Construct a new Transferframe object. | |
bool | _checkCRC (void) |
Static Public Member Functions | |
static uint16_t | calcCRC (const uint8_t *pu8_Buffer, const uint16_t u16_BufferSize) |
Protected Attributes | |
uint16_t | mu16_Index |
uint16_t | mu16_FrameLength |
bool | mb_Sync |
uint16_t | mu16_SyncErrorCount |
uint16_t | mu16_ChecksumErrorCount |
uint16_t | mu16_OverflowErrorCount |
Static Protected Attributes | |
static const uint8_t | SyncSize = TF_SYNC_SIZE |
static const uint8_t | FecfSize = 2 |
static const bool | UseFECF = (TF_USE_FECF)?true:false |
Base Class for handling Transfer Frames as described in CCSDS 131.0-B-3, CCSDS 132.0-B-2, CCSDS 231.0-B-3 and CCSDS 232.0-B-3.
Transfer Frames are used to ensure a transfer from the ground to the spacecraft and vice versa, corresponding to OSI layer 2.
The transfer frames for uplink and downlink differ, therefore this class is the base for the specific classes TransferframeTc and TransferframeTm.
uint16_t CCSDS::Transferframe::getChecksumErrorCount | ( | void | ) |
Returns the number of checksum errors.
Checksum errors occur if the FECF feature of the protocol is used and the calculated checksum of the transfer frame does not match the received one.
uint16_t CCSDS::Transferframe::getOverflowErrorCount | ( | void | ) |
Returns the number of overflow errors.
Overflow errors occur if the frame length from given in the header information is bigger than the maximum remaining size of the transfer frame data section; A wrong package alignment caused by a synchronization error can also lead to an overflow error.
If the number of overflow errors exceeds 65535, the method returns 65535.
uint16_t CCSDS::Transferframe::getSyncErrorCount | ( | void | ) |
Returns the number of sync errors.
Sync Errors occur if the parsing engine does not find an expected sync code.
If the number of sync errors exceeds 65535, the method returns 65535.
int32_t CCSDS::Transferframe::process | ( | const uint8_t * | pu8_Data, |
const uint16_t | u16_DataSize | ||
) |
The given data stream is parsed for Transfer Frames.
The method can handle continuously incoming data as well as complete data blocks. If a complete Transfer Frame is processed, the corresponding uplink or downlink callback function is called.
Attention: In contrast to Telemetry Transfer Frames, the Telecommand Transfer Frames do not come with a sync code. For enabling the processing, the method setSync() must be called if a start sequence was received by the wrapping protocol (usually a CLTU start sequence).
pu8_Data | The data buffer which is to parse |
u16_DataSize | The size of the data buffer |
0 | If the buffer was parsed |
-1 | If fhe u16_DataSize is 0 or the pu8_Data is NULL |
void CCSDS::Transferframe::setSync | ( | void | ) |
Sets the sync flag for the transfer frame processing.
This method enables the object to parse the data stram for a complete transfer frame. In case of uplink data, this method must be called if the start of a new transfer frame is detected by receiving a CLTU start sequence (Telecommand Transfer Frames do not have the sync code). In case of downlink data, the synchronization can be done automatically by detectiong the start code.