taken over datalinklayer form upstream

This commit is contained in:
Robin Müller 2020-08-28 17:40:53 +02:00
parent 5ce954672b
commit d2ef2b2be4
22 changed files with 1629 additions and 1629 deletions

View File

@ -1,62 +1,62 @@
/** /**
* @file BCFrame.h * @file BCFrame.h
* @brief This file defines the BCFrame class. * @brief This file defines the BCFrame class.
* @date 24.04.2013 * @date 24.04.2013
* @author baetz * @author baetz
*/ */
#ifndef BCFRAME_H_ #ifndef BCFRAME_H_
#define BCFRAME_H_ #define BCFRAME_H_
#include "../datalinklayer/CCSDSReturnValuesIF.h" #include "CCSDSReturnValuesIF.h"
/** /**
* Small helper class to identify a BcFrame. * Small helper class to identify a BcFrame.
* @ingroup ccsds_handling * @ingroup ccsds_handling
*/ */
class BcFrame: public CCSDSReturnValuesIF { class BcFrame: public CCSDSReturnValuesIF {
private: private:
static const uint8_t UNLOCK_COMMAND = 0b00000000;//! Identifier for a certain BC Command. static const uint8_t UNLOCK_COMMAND = 0b00000000;//! Identifier for a certain BC Command.
static const uint8_t SET_V_R_1 = 0b10000010;//! Identifier for a certain BC Command. static const uint8_t SET_V_R_1 = 0b10000010;//! Identifier for a certain BC Command.
static const uint8_t SET_V_R_2 = 0b00000000;//! Identifier for a certain BC Command. static const uint8_t SET_V_R_2 = 0b00000000;//! Identifier for a certain BC Command.
public: public:
uint8_t byte1; //!< First content byte uint8_t byte1; //!< First content byte
uint8_t byte2; //!< Second content byte uint8_t byte2; //!< Second content byte
uint8_t vR; //!< vR byte uint8_t vR; //!< vR byte
/** /**
* Simple default constructor. * Simple default constructor.
*/ */
BcFrame() : BcFrame() :
byte1(0), byte2(0), vR(0) { byte1(0), byte2(0), vR(0) {
} }
/** /**
* Main and only useful method of the class. * Main and only useful method of the class.
* With the buffer and size information passed, the class passes the content * With the buffer and size information passed, the class passes the content
* and checks if it is one of the two valid BC Command Frames. * and checks if it is one of the two valid BC Command Frames.
* @param inBuffer Content of the frame to check, * @param inBuffer Content of the frame to check,
* @param inSize Size of the data to check. * @param inSize Size of the data to check.
* @return - #BC_ILLEGAL_COMMAND if it is no command. * @return - #BC_ILLEGAL_COMMAND if it is no command.
* - #BC_IS_UNLOCK_COMMAND if it is an unlock command. * - #BC_IS_UNLOCK_COMMAND if it is an unlock command.
* - #BC_IS_SET_VR_COMMAND if it is such. * - #BC_IS_SET_VR_COMMAND if it is such.
*/ */
ReturnValue_t initialize(const uint8_t* inBuffer, uint16_t inSize) { ReturnValue_t initialize(const uint8_t* inBuffer, uint16_t inSize) {
ReturnValue_t returnValue = BC_ILLEGAL_COMMAND; ReturnValue_t returnValue = BC_ILLEGAL_COMMAND;
if (inSize == 1) { if (inSize == 1) {
byte1 = inBuffer[0]; byte1 = inBuffer[0];
if (byte1 == UNLOCK_COMMAND) { if (byte1 == UNLOCK_COMMAND) {
returnValue = BC_IS_UNLOCK_COMMAND; returnValue = BC_IS_UNLOCK_COMMAND;
} }
} else if (inSize == 3) { } else if (inSize == 3) {
byte1 = inBuffer[0]; byte1 = inBuffer[0];
byte2 = inBuffer[1]; byte2 = inBuffer[1];
vR = inBuffer[2]; vR = inBuffer[2];
if (byte1 == SET_V_R_1 && byte2 == SET_V_R_2) { if (byte1 == SET_V_R_1 && byte2 == SET_V_R_2) {
returnValue = BC_IS_SET_VR_COMMAND; returnValue = BC_IS_SET_VR_COMMAND;
} }
} }
return returnValue; return returnValue;
} }
}; };
#endif /* BCFRAME_H_ */ #endif /* BCFRAME_H_ */

View File

@ -1,56 +1,56 @@
/** /**
* @file CCSDSReturnValuesIF.h * @file CCSDSReturnValuesIF.h
* @brief This file defines the CCSDSReturnValuesIF class. * @brief This file defines the CCSDSReturnValuesIF class.
* @date 24.04.2013 * @date 24.04.2013
* @author baetz * @author baetz
*/ */
#ifndef CCSDSRETURNVALUESIF_H_ #ifndef CCSDSRETURNVALUESIF_H_
#define CCSDSRETURNVALUESIF_H_ #define CCSDSRETURNVALUESIF_H_
#include "../returnvalues/HasReturnvaluesIF.h" #include "../returnvalues/HasReturnvaluesIF.h"
/** /**
* This is a helper class to collect special return values that come up during CCSDS Handling. * This is a helper class to collect special return values that come up during CCSDS Handling.
* @ingroup ccsds_handling * @ingroup ccsds_handling
*/ */
class CCSDSReturnValuesIF: public HasReturnvaluesIF { class CCSDSReturnValuesIF: public HasReturnvaluesIF {
public: public:
static const uint8_t INTERFACE_ID = CLASS_ID::CCSDS_HANDLER_IF; //!< Basic ID of the interface. static const uint8_t INTERFACE_ID = CLASS_ID::CCSDS_HANDLER_IF; //!< Basic ID of the interface.
static const ReturnValue_t BC_IS_SET_VR_COMMAND = MAKE_RETURN_CODE( 0x01 ); //!< A value to describe a BC frame. static const ReturnValue_t BC_IS_SET_VR_COMMAND = MAKE_RETURN_CODE( 0x01 ); //!< A value to describe a BC frame.
static const ReturnValue_t BC_IS_UNLOCK_COMMAND = MAKE_RETURN_CODE( 0x02 ); //!< A value to describe a BC frame. static const ReturnValue_t BC_IS_UNLOCK_COMMAND = MAKE_RETURN_CODE( 0x02 ); //!< A value to describe a BC frame.
static const ReturnValue_t BC_ILLEGAL_COMMAND = MAKE_RETURN_CODE( 0xB0 );//!< A value to describe an illegal BC frame. static const ReturnValue_t BC_ILLEGAL_COMMAND = MAKE_RETURN_CODE( 0xB0 );//!< A value to describe an illegal BC frame.
static const ReturnValue_t BOARD_READING_NOT_FINISHED = MAKE_RETURN_CODE( 0xB1 ); //! The CCSDS Board is not yet finished reading, it requires another cycle. static const ReturnValue_t BOARD_READING_NOT_FINISHED = MAKE_RETURN_CODE( 0xB1 ); //! The CCSDS Board is not yet finished reading, it requires another cycle.
static const ReturnValue_t NS_POSITIVE_W = MAKE_RETURN_CODE( 0xF0 );//!< NS is in the positive window static const ReturnValue_t NS_POSITIVE_W = MAKE_RETURN_CODE( 0xF0 );//!< NS is in the positive window
static const ReturnValue_t NS_NEGATIVE_W = MAKE_RETURN_CODE( 0xF1 );//!< NS is in the negative window static const ReturnValue_t NS_NEGATIVE_W = MAKE_RETURN_CODE( 0xF1 );//!< NS is in the negative window
static const ReturnValue_t NS_LOCKOUT = MAKE_RETURN_CODE( 0xF2 ); //!< NS is in lockout state static const ReturnValue_t NS_LOCKOUT = MAKE_RETURN_CODE( 0xF2 ); //!< NS is in lockout state
static const ReturnValue_t FARM_IN_LOCKOUT = MAKE_RETURN_CODE( 0xF3 );//!< FARM-1 is currently in lockout state static const ReturnValue_t FARM_IN_LOCKOUT = MAKE_RETURN_CODE( 0xF3 );//!< FARM-1 is currently in lockout state
static const ReturnValue_t FARM_IN_WAIT = MAKE_RETURN_CODE( 0xF4 ); //!< FARM-1 is currently in wait state static const ReturnValue_t FARM_IN_WAIT = MAKE_RETURN_CODE( 0xF4 ); //!< FARM-1 is currently in wait state
static const ReturnValue_t WRONG_SYMBOL = MAKE_RETURN_CODE( 0xE0 ); //!< An error code in the FrameFinder. static const ReturnValue_t WRONG_SYMBOL = MAKE_RETURN_CODE( 0xE0 ); //!< An error code in the FrameFinder.
static const ReturnValue_t DOUBLE_START = MAKE_RETURN_CODE( 0xE1 ); //!< An error code in the FrameFinder. static const ReturnValue_t DOUBLE_START = MAKE_RETURN_CODE( 0xE1 ); //!< An error code in the FrameFinder.
static const ReturnValue_t START_SYMBOL_MISSED = MAKE_RETURN_CODE( 0xE2 );//!< An error code in the FrameFinder. static const ReturnValue_t START_SYMBOL_MISSED = MAKE_RETURN_CODE( 0xE2 );//!< An error code in the FrameFinder.
static const ReturnValue_t END_WITHOUT_START = MAKE_RETURN_CODE( 0xE3 );//!< An error code in the FrameFinder. static const ReturnValue_t END_WITHOUT_START = MAKE_RETURN_CODE( 0xE3 );//!< An error code in the FrameFinder.
static const ReturnValue_t TOO_LARGE = MAKE_RETURN_CODE( 0xE4 );//!< An error code for a frame. static const ReturnValue_t TOO_LARGE = MAKE_RETURN_CODE( 0xE4 );//!< An error code for a frame.
static const ReturnValue_t TOO_SHORT = MAKE_RETURN_CODE( 0xE5 );//!< An error code for a frame. static const ReturnValue_t TOO_SHORT = MAKE_RETURN_CODE( 0xE5 );//!< An error code for a frame.
static const ReturnValue_t WRONG_TF_VERSION = MAKE_RETURN_CODE( 0xE6 ); //!< An error code for a frame. static const ReturnValue_t WRONG_TF_VERSION = MAKE_RETURN_CODE( 0xE6 ); //!< An error code for a frame.
static const ReturnValue_t WRONG_SPACECRAFT_ID = MAKE_RETURN_CODE( 0xE7 );//!< An error code for a frame. static const ReturnValue_t WRONG_SPACECRAFT_ID = MAKE_RETURN_CODE( 0xE7 );//!< An error code for a frame.
static const ReturnValue_t NO_VALID_FRAME_TYPE = MAKE_RETURN_CODE( 0xE8 );//!< An error code for a frame. static const ReturnValue_t NO_VALID_FRAME_TYPE = MAKE_RETURN_CODE( 0xE8 );//!< An error code for a frame.
static const ReturnValue_t CRC_FAILED = MAKE_RETURN_CODE( 0xE9 );//!< An error code for a frame. static const ReturnValue_t CRC_FAILED = MAKE_RETURN_CODE( 0xE9 );//!< An error code for a frame.
static const ReturnValue_t VC_NOT_FOUND = MAKE_RETURN_CODE( 0xEA ); //!< An error code for a frame. static const ReturnValue_t VC_NOT_FOUND = MAKE_RETURN_CODE( 0xEA ); //!< An error code for a frame.
static const ReturnValue_t FORWARDING_FAILED = MAKE_RETURN_CODE( 0xEB );//!< An error code for a frame. static const ReturnValue_t FORWARDING_FAILED = MAKE_RETURN_CODE( 0xEB );//!< An error code for a frame.
static const ReturnValue_t CONTENT_TOO_LARGE = MAKE_RETURN_CODE( 0xEC );//!< An error code for a frame. static const ReturnValue_t CONTENT_TOO_LARGE = MAKE_RETURN_CODE( 0xEC );//!< An error code for a frame.
static const ReturnValue_t RESIDUAL_DATA = MAKE_RETURN_CODE( 0xED );//!< An error code for a frame. static const ReturnValue_t RESIDUAL_DATA = MAKE_RETURN_CODE( 0xED );//!< An error code for a frame.
static const ReturnValue_t DATA_CORRUPTED = MAKE_RETURN_CODE( 0xEE );//!< An error code for a frame. static const ReturnValue_t DATA_CORRUPTED = MAKE_RETURN_CODE( 0xEE );//!< An error code for a frame.
static const ReturnValue_t ILLEGAL_SEGMENTATION_FLAG = MAKE_RETURN_CODE( 0xEF );//!< An error code for a frame. static const ReturnValue_t ILLEGAL_SEGMENTATION_FLAG = MAKE_RETURN_CODE( 0xEF );//!< An error code for a frame.
static const ReturnValue_t ILLEGAL_FLAG_COMBINATION = MAKE_RETURN_CODE( 0xD0 ); //!< An error code for a frame. static const ReturnValue_t ILLEGAL_FLAG_COMBINATION = MAKE_RETURN_CODE( 0xD0 ); //!< An error code for a frame.
static const ReturnValue_t SHORTER_THAN_HEADER = MAKE_RETURN_CODE( 0xD1 ); //!< An error code for a frame. static const ReturnValue_t SHORTER_THAN_HEADER = MAKE_RETURN_CODE( 0xD1 ); //!< An error code for a frame.
static const ReturnValue_t TOO_SHORT_BLOCKED_PACKET = MAKE_RETURN_CODE( 0xD2 ); //!< An error code for a frame. static const ReturnValue_t TOO_SHORT_BLOCKED_PACKET = MAKE_RETURN_CODE( 0xD2 ); //!< An error code for a frame.
static const ReturnValue_t TOO_SHORT_MAP_EXTRACTION = MAKE_RETURN_CODE( 0xD3 ); //!< An error code for a frame. static const ReturnValue_t TOO_SHORT_MAP_EXTRACTION = MAKE_RETURN_CODE( 0xD3 ); //!< An error code for a frame.
virtual ~CCSDSReturnValuesIF() { virtual ~CCSDSReturnValuesIF() {
} //!< Empty virtual destructor } //!< Empty virtual destructor
}; };
#endif /* CCSDSRETURNVALUESIF_H_ */ #endif /* CCSDSRETURNVALUESIF_H_ */

View File

@ -1,63 +1,63 @@
/** /**
* @file Clcw.cpp * @file Clcw.cpp
* @brief This file defines the Clcw class. * @brief This file defines the Clcw class.
* @date 17.04.2013 * @date 17.04.2013
* @author baetz * @author baetz
*/ */
#include "../datalinklayer/Clcw.h" #include "Clcw.h"
#include "../serviceinterface/ServiceInterfaceStream.h" #include "../serviceinterface/ServiceInterfaceStream.h"
Clcw::Clcw() { Clcw::Clcw() {
content.raw = 0; content.raw = 0;
content.status = STATUS_FIELD_DEFAULT; content.status = STATUS_FIELD_DEFAULT;
} }
Clcw::~Clcw() { Clcw::~Clcw() {
} }
void Clcw::setVirtualChannel(uint8_t setChannel) { void Clcw::setVirtualChannel(uint8_t setChannel) {
content.virtualChannelIdSpare = ((setChannel & 0x3F) << 2); content.virtualChannelIdSpare = ((setChannel & 0x3F) << 2);
} }
void Clcw::setLockoutFlag(bool lockout) { void Clcw::setLockoutFlag(bool lockout) {
content.flags = (content.flags & LOCKOUT_FLAG_MASK) | (lockout << LOCKOUT_FLAG_POSITION); content.flags = (content.flags & LOCKOUT_FLAG_MASK) | (lockout << LOCKOUT_FLAG_POSITION);
} }
void Clcw::setWaitFlag(bool waitFlag) { void Clcw::setWaitFlag(bool waitFlag) {
content.flags = (content.flags & WAIT_FLAG_MASK) | (waitFlag << WAIT_FLAG_POSITION); content.flags = (content.flags & WAIT_FLAG_MASK) | (waitFlag << WAIT_FLAG_POSITION);
} }
void Clcw::setRetransmitFlag(bool retransmitFlag) { void Clcw::setRetransmitFlag(bool retransmitFlag) {
content.flags = (content.flags & RETRANSMIT_FLAG_MASK) | (retransmitFlag << RETRANSMIT_FLAG_POSITION); content.flags = (content.flags & RETRANSMIT_FLAG_MASK) | (retransmitFlag << RETRANSMIT_FLAG_POSITION);
} }
void Clcw::setFarmBCount(uint8_t count) { void Clcw::setFarmBCount(uint8_t count) {
content.flags = (content.flags & FARM_B_COUNT_MASK) | ((count & 0x03) << 1); content.flags = (content.flags & FARM_B_COUNT_MASK) | ((count & 0x03) << 1);
} }
void Clcw::setReceiverFrameSequenceNumber(uint8_t vR) { void Clcw::setReceiverFrameSequenceNumber(uint8_t vR) {
content.vRValue = vR; content.vRValue = vR;
} }
uint32_t Clcw::getAsWhole() { uint32_t Clcw::getAsWhole() {
return content.raw; return content.raw;
} }
void Clcw::setRFAvailable(bool rfAvailable) { void Clcw::setRFAvailable(bool rfAvailable) {
content.flags = (content.flags & NO_RF_AVIALABLE_MASK) | (!rfAvailable << NO_RF_AVIALABLE_POSITION); content.flags = (content.flags & NO_RF_AVIALABLE_MASK) | (!rfAvailable << NO_RF_AVIALABLE_POSITION);
} }
void Clcw::setBitLock(bool bitLock) { void Clcw::setBitLock(bool bitLock) {
content.flags = (content.flags & NO_BIT_LOCK_MASK) | (!bitLock << NO_BIT_LOCK_POSITION); content.flags = (content.flags & NO_BIT_LOCK_MASK) | (!bitLock << NO_BIT_LOCK_POSITION);
} }
void Clcw::print() { void Clcw::print() {
sif::debug << "Clcw::print: Clcw is: " << std::hex << getAsWhole() << std::dec << std::endl; sif::debug << "Clcw::print: Clcw is: " << std::hex << getAsWhole() << std::dec << std::endl;
} }
void Clcw::setWhole(uint32_t rawClcw) { void Clcw::setWhole(uint32_t rawClcw) {
content.raw = rawClcw; content.raw = rawClcw;
} }

View File

@ -1,66 +1,66 @@
/** /**
* @file Clcw.h * @file Clcw.h
* @brief This file defines the Clcw class. * @brief This file defines the Clcw class.
* @date 17.04.2013 * @date 17.04.2013
* @author baetz * @author baetz
*/ */
#ifndef CLCW_H_ #ifndef CLCW_H_
#define CLCW_H_ #define CLCW_H_
#include "../datalinklayer/ClcwIF.h" #include "ClcwIF.h"
/** /**
* Small helper method to handle the Clcw values. * Small helper method to handle the Clcw values.
* It has a content struct that manages the register and can be set externally. * It has a content struct that manages the register and can be set externally.
* @ingroup ccsds_handling * @ingroup ccsds_handling
*/ */
class Clcw : public ClcwIF { class Clcw : public ClcwIF {
private: private:
static const uint8_t STATUS_FIELD_DEFAULT = 0b00000001; //!< Default for the status field. static const uint8_t STATUS_FIELD_DEFAULT = 0b00000001; //!< Default for the status field.
static const uint8_t NO_RF_AVIALABLE_POSITION = 7; //!< Position of a flag in the register (starting with 0). static const uint8_t NO_RF_AVIALABLE_POSITION = 7; //!< Position of a flag in the register (starting with 0).
static const uint8_t NO_BIT_LOCK_POSITION = 6; //!< Position of a flag in the register (starting with 0). static const uint8_t NO_BIT_LOCK_POSITION = 6; //!< Position of a flag in the register (starting with 0).
static const uint8_t LOCKOUT_FLAG_POSITION = 5; //!< Position of a flag in the register (starting with 0). static const uint8_t LOCKOUT_FLAG_POSITION = 5; //!< Position of a flag in the register (starting with 0).
static const uint8_t WAIT_FLAG_POSITION = 4; //!< Position of a flag in the register (starting with 0). static const uint8_t WAIT_FLAG_POSITION = 4; //!< Position of a flag in the register (starting with 0).
static const uint8_t RETRANSMIT_FLAG_POSITION = 3; //!< Position of a flag in the register (starting with 0). static const uint8_t RETRANSMIT_FLAG_POSITION = 3; //!< Position of a flag in the register (starting with 0).
static const uint8_t NO_RF_AVIALABLE_MASK = 0xFF xor (1 << NO_RF_AVIALABLE_POSITION); //!< Mask for a flag in the register. static const uint8_t NO_RF_AVIALABLE_MASK = 0xFF xor (1 << NO_RF_AVIALABLE_POSITION); //!< Mask for a flag in the register.
static const uint8_t NO_BIT_LOCK_MASK = 0xFF xor (1 << NO_BIT_LOCK_POSITION); //!< Mask for a flag in the register. static const uint8_t NO_BIT_LOCK_MASK = 0xFF xor (1 << NO_BIT_LOCK_POSITION); //!< Mask for a flag in the register.
static const uint8_t LOCKOUT_FLAG_MASK = 0xFF xor (1 << LOCKOUT_FLAG_POSITION); //!< Mask for a flag in the register. static const uint8_t LOCKOUT_FLAG_MASK = 0xFF xor (1 << LOCKOUT_FLAG_POSITION); //!< Mask for a flag in the register.
static const uint8_t WAIT_FLAG_MASK = 0xFF xor (1 << WAIT_FLAG_POSITION); //!< Mask for a flag in the register. static const uint8_t WAIT_FLAG_MASK = 0xFF xor (1 << WAIT_FLAG_POSITION); //!< Mask for a flag in the register.
static const uint8_t RETRANSMIT_FLAG_MASK = 0xFF xor (1 << RETRANSMIT_FLAG_POSITION); //!< Mask for a flag in the register. static const uint8_t RETRANSMIT_FLAG_MASK = 0xFF xor (1 << RETRANSMIT_FLAG_POSITION); //!< Mask for a flag in the register.
static const uint8_t FARM_B_COUNT_MASK = 0b11111001; //!< Mask for a counter in the register. static const uint8_t FARM_B_COUNT_MASK = 0b11111001; //!< Mask for a counter in the register.
/** /**
* This is the data structure of the CLCW register. * This is the data structure of the CLCW register.
*/ */
union clcwContent { union clcwContent {
uint32_t raw; uint32_t raw;
struct { struct {
uint8_t status; uint8_t status;
uint8_t virtualChannelIdSpare; uint8_t virtualChannelIdSpare;
uint8_t flags; uint8_t flags;
uint8_t vRValue; uint8_t vRValue;
}; };
}; };
clcwContent content; //!< Represents the content of the register. clcwContent content; //!< Represents the content of the register.
public: public:
/** /**
* The constructor sets everything to default values. * The constructor sets everything to default values.
*/ */
Clcw(); Clcw();
/** /**
* Nothing happens in the destructor. * Nothing happens in the destructor.
*/ */
~Clcw(); ~Clcw();
void setVirtualChannel( uint8_t setChannel ); void setVirtualChannel( uint8_t setChannel );
void setLockoutFlag( bool lockout ); void setLockoutFlag( bool lockout );
void setWaitFlag( bool waitFlag ); void setWaitFlag( bool waitFlag );
void setRetransmitFlag( bool retransmitFlag ); void setRetransmitFlag( bool retransmitFlag );
void setFarmBCount( uint8_t count ); void setFarmBCount( uint8_t count );
void setReceiverFrameSequenceNumber( uint8_t vR ); void setReceiverFrameSequenceNumber( uint8_t vR );
void setRFAvailable( bool rfAvailable ); void setRFAvailable( bool rfAvailable );
void setBitLock( bool bitLock ); void setBitLock( bool bitLock );
uint32_t getAsWhole(); uint32_t getAsWhole();
void setWhole( uint32_t rawClcw ); void setWhole( uint32_t rawClcw );
void print(); void print();
}; };
#endif /* CLCW_H_ */ #endif /* CLCW_H_ */

View File

@ -1,139 +1,139 @@
#include "../datalinklayer/DataLinkLayer.h" #include "DataLinkLayer.h"
#include "../globalfunctions/CRC.h" #include "../globalfunctions/CRC.h"
#include "../serviceinterface/ServiceInterfaceStream.h" #include "../serviceinterface/ServiceInterfaceStream.h"
DataLinkLayer::DataLinkLayer(uint8_t* set_frame_buffer, ClcwIF* setClcw, DataLinkLayer::DataLinkLayer(uint8_t* set_frame_buffer, ClcwIF* setClcw,
uint8_t set_start_sequence_length, uint16_t set_scid) : uint8_t set_start_sequence_length, uint16_t set_scid) :
spacecraftId(set_scid), frameBuffer(set_frame_buffer), clcw(setClcw), receivedDataLength(0), currentFrame( spacecraftId(set_scid), frameBuffer(set_frame_buffer), clcw(setClcw), receivedDataLength(0), currentFrame(
NULL), startSequenceLength(set_start_sequence_length) { NULL), startSequenceLength(set_start_sequence_length) {
//Nothing to do except from setting the values above. //Nothing to do except from setting the values above.
} }
DataLinkLayer::~DataLinkLayer() { DataLinkLayer::~DataLinkLayer() {
} }
ReturnValue_t DataLinkLayer::frameDelimitingAndFillRemoval() { ReturnValue_t DataLinkLayer::frameDelimitingAndFillRemoval() {
if ((receivedDataLength - startSequenceLength) < FRAME_PRIMARY_HEADER_LENGTH) { if ((receivedDataLength - startSequenceLength) < FRAME_PRIMARY_HEADER_LENGTH) {
return SHORTER_THAN_HEADER; return SHORTER_THAN_HEADER;
} }
//Removing start sequence. //Removing start sequence.
//SHOULDDO: Not implemented here. //SHOULDDO: Not implemented here.
while ( *frameBuffer == START_SEQUENCE_PATTERN ) { while ( *frameBuffer == START_SEQUENCE_PATTERN ) {
frameBuffer++; frameBuffer++;
} }
TcTransferFrame frame_candidate(frameBuffer); TcTransferFrame frame_candidate(frameBuffer);
this->currentFrame = frame_candidate; //should work with shallow copy. this->currentFrame = frame_candidate; //should work with shallow copy.
return RETURN_OK; return RETURN_OK;
} }
ReturnValue_t DataLinkLayer::frameValidationCheck() { ReturnValue_t DataLinkLayer::frameValidationCheck() {
//Check TF_version number //Check TF_version number
if (this->currentFrame.getVersionNumber() != FRAME_VERSION_NUMBER_DEFAULT) { if (this->currentFrame.getVersionNumber() != FRAME_VERSION_NUMBER_DEFAULT) {
return WRONG_TF_VERSION; return WRONG_TF_VERSION;
} }
//Check SpaceCraft ID //Check SpaceCraft ID
if (this->currentFrame.getSpacecraftId() != this->spacecraftId) { if (this->currentFrame.getSpacecraftId() != this->spacecraftId) {
return WRONG_SPACECRAFT_ID; return WRONG_SPACECRAFT_ID;
} }
//Check other header limitations: //Check other header limitations:
if (!this->currentFrame.bypassFlagSet() && this->currentFrame.controlCommandFlagSet()) { if (!this->currentFrame.bypassFlagSet() && this->currentFrame.controlCommandFlagSet()) {
return NO_VALID_FRAME_TYPE; return NO_VALID_FRAME_TYPE;
} }
//- Spares are zero //- Spares are zero
if (!this->currentFrame.spareIsZero()) { if (!this->currentFrame.spareIsZero()) {
return NO_VALID_FRAME_TYPE; return NO_VALID_FRAME_TYPE;
} }
//Compare detected frame length with the one in the header //Compare detected frame length with the one in the header
uint16_t length = currentFrame.getFullSize(); uint16_t length = currentFrame.getFullSize();
if (length > receivedDataLength) { if (length > receivedDataLength) {
//Frame is too long or just right //Frame is too long or just right
// error << "frameValidationCheck: Too short."; // error << "frameValidationCheck: Too short.";
// currentFrame.print(); // currentFrame.print();
return TOO_SHORT; return TOO_SHORT;
} }
if (USE_CRC) { if (USE_CRC) {
return this->frameCheckCRC(); return this->frameCheckCRC();
} }
return RETURN_OK; return RETURN_OK;
} }
ReturnValue_t DataLinkLayer::frameCheckCRC() { ReturnValue_t DataLinkLayer::frameCheckCRC() {
uint16_t checkValue = CRC::crc16ccitt(this->currentFrame.getFullFrame(), uint16_t checkValue = CRC::crc16ccitt(this->currentFrame.getFullFrame(),
this->currentFrame.getFullSize()); this->currentFrame.getFullSize());
if (checkValue == 0) { if (checkValue == 0) {
return RETURN_OK; return RETURN_OK;
} else { } else {
return CRC_FAILED; return CRC_FAILED;
} }
} }
ReturnValue_t DataLinkLayer::allFramesReception() { ReturnValue_t DataLinkLayer::allFramesReception() {
ReturnValue_t status = this->frameDelimitingAndFillRemoval(); ReturnValue_t status = this->frameDelimitingAndFillRemoval();
if (status != RETURN_OK) { if (status != RETURN_OK) {
return status; return status;
} }
return this->frameValidationCheck(); return this->frameValidationCheck();
} }
ReturnValue_t DataLinkLayer::masterChannelDemultiplexing() { ReturnValue_t DataLinkLayer::masterChannelDemultiplexing() {
//Nothing to do at present. Ideally, there would be a map of MCID's identifying which MC to use. //Nothing to do at present. Ideally, there would be a map of MCID's identifying which MC to use.
return virtualChannelDemultiplexing(); return virtualChannelDemultiplexing();
} }
ReturnValue_t DataLinkLayer::virtualChannelDemultiplexing() { ReturnValue_t DataLinkLayer::virtualChannelDemultiplexing() {
uint8_t vcId = currentFrame.getVirtualChannelId(); uint8_t vcId = currentFrame.getVirtualChannelId();
virtualChannelIterator iter = virtualChannels.find(vcId); virtualChannelIterator iter = virtualChannels.find(vcId);
if (iter == virtualChannels.end()) { if (iter == virtualChannels.end()) {
//Do not report because passive board will get this error all the time. //Do not report because passive board will get this error all the time.
return RETURN_OK; return RETURN_OK;
} else { } else {
return (iter->second)->frameAcceptanceAndReportingMechanism(&currentFrame, clcw); return (iter->second)->frameAcceptanceAndReportingMechanism(&currentFrame, clcw);
} }
} }
ReturnValue_t DataLinkLayer::processFrame(uint16_t length) { ReturnValue_t DataLinkLayer::processFrame(uint16_t length) {
receivedDataLength = length; receivedDataLength = length;
ReturnValue_t status = allFramesReception(); ReturnValue_t status = allFramesReception();
if (status != RETURN_OK) { if (status != RETURN_OK) {
sif::error << "DataLinkLayer::processFrame: frame reception failed. " sif::error << "DataLinkLayer::processFrame: frame reception failed. "
"Error code: " << std::hex << status << std::dec << std::endl; "Error code: " << std::hex << status << std::dec << std::endl;
// currentFrame.print(); // currentFrame.print();
return status; return status;
} else { } else {
return masterChannelDemultiplexing(); return masterChannelDemultiplexing();
} }
} }
ReturnValue_t DataLinkLayer::addVirtualChannel(uint8_t virtualChannelId, ReturnValue_t DataLinkLayer::addVirtualChannel(uint8_t virtualChannelId,
VirtualChannelReceptionIF* object) { VirtualChannelReceptionIF* object) {
std::pair<virtualChannelIterator, bool> returnValue = virtualChannels.insert( std::pair<virtualChannelIterator, bool> returnValue = virtualChannels.insert(
std::pair<uint8_t, VirtualChannelReceptionIF*>(virtualChannelId, object)); std::pair<uint8_t, VirtualChannelReceptionIF*>(virtualChannelId, object));
if (returnValue.second == true) { if (returnValue.second == true) {
return RETURN_OK; return RETURN_OK;
} else { } else {
return RETURN_FAILED; return RETURN_FAILED;
} }
} }
ReturnValue_t DataLinkLayer::initialize() { ReturnValue_t DataLinkLayer::initialize() {
ReturnValue_t returnValue = RETURN_FAILED; ReturnValue_t returnValue = RETURN_FAILED;
//Set Virtual Channel ID to first virtual channel instance in this DataLinkLayer instance to avoid faulty information (e.g. 0) in the VCID. //Set Virtual Channel ID to first virtual channel instance in this DataLinkLayer instance to avoid faulty information (e.g. 0) in the VCID.
if ( virtualChannels.begin() != virtualChannels.end() ) { if ( virtualChannels.begin() != virtualChannels.end() ) {
clcw->setVirtualChannel( virtualChannels.begin()->second->getChannelId() ); clcw->setVirtualChannel( virtualChannels.begin()->second->getChannelId() );
} else { } else {
sif::error << "DataLinkLayer::initialize: No VC assigned to this DLL instance! " << std::endl; sif::error << "DataLinkLayer::initialize: No VC assigned to this DLL instance! " << std::endl;
return RETURN_FAILED; return RETURN_FAILED;
} }
for (virtualChannelIterator iterator = virtualChannels.begin(); for (virtualChannelIterator iterator = virtualChannels.begin();
iterator != virtualChannels.end(); iterator++) { iterator != virtualChannels.end(); iterator++) {
returnValue = iterator->second->initialize(); returnValue = iterator->second->initialize();
if (returnValue != RETURN_OK) if (returnValue != RETURN_OK)
break; break;
} }
return returnValue; return returnValue;
} }

View File

@ -1,112 +1,112 @@
#ifndef DATALINKLAYER_H_ #ifndef DATALINKLAYER_H_
#define DATALINKLAYER_H_ #define DATALINKLAYER_H_
#include "../datalinklayer/CCSDSReturnValuesIF.h" #include "CCSDSReturnValuesIF.h"
#include "../datalinklayer/ClcwIF.h" #include "ClcwIF.h"
#include "../datalinklayer/TcTransferFrame.h" #include "TcTransferFrame.h"
#include "../datalinklayer/VirtualChannelReceptionIF.h" #include "VirtualChannelReceptionIF.h"
#include "../events/Event.h" #include "../events/Event.h"
#include <map> #include <map>
class VirtualChannelReception; class VirtualChannelReception;
/** /**
* A complete representation of the CCSDS Data Link Layer. * A complete representation of the CCSDS Data Link Layer.
* The operations of this layer are defined in the CCSDS TC Space Data Link Protocol * The operations of this layer are defined in the CCSDS TC Space Data Link Protocol
* document. It is configured to handle a VC Demultiplexing function. All reception * document. It is configured to handle a VC Demultiplexing function. All reception
* steps are performed. * steps are performed.
*/ */
class DataLinkLayer : public CCSDSReturnValuesIF { class DataLinkLayer : public CCSDSReturnValuesIF {
public: public:
static const uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::SYSTEM_1; static const uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::SYSTEM_1;
static const Event RF_AVAILABLE = MAKE_EVENT(0, SEVERITY::INFO); //!< A RF available signal was detected. P1: raw RFA state, P2: 0 static const Event RF_AVAILABLE = MAKE_EVENT(0, SEVERITY::INFO); //!< A RF available signal was detected. P1: raw RFA state, P2: 0
static const Event RF_LOST = MAKE_EVENT(1, SEVERITY::INFO); //!< A previously found RF available signal was lost. P1: raw RFA state, P2: 0 static const Event RF_LOST = MAKE_EVENT(1, SEVERITY::INFO); //!< A previously found RF available signal was lost. P1: raw RFA state, P2: 0
static const Event BIT_LOCK = MAKE_EVENT(2, SEVERITY::INFO); //!< A Bit Lock signal. Was detected. P1: raw BLO state, P2: 0 static const Event BIT_LOCK = MAKE_EVENT(2, SEVERITY::INFO); //!< A Bit Lock signal. Was detected. P1: raw BLO state, P2: 0
static const Event BIT_LOCK_LOST = MAKE_EVENT(3, SEVERITY::INFO); //!< A previously found Bit Lock signal was lost. P1: raw BLO state, P2: 0 static const Event BIT_LOCK_LOST = MAKE_EVENT(3, SEVERITY::INFO); //!< A previously found Bit Lock signal was lost. P1: raw BLO state, P2: 0
// static const Event RF_CHAIN_LOST = MAKE_EVENT(4, SEVERITY::INFO); //!< The CCSDS Board detected that either bit lock or RF available or both are lost. No parameters. // static const Event RF_CHAIN_LOST = MAKE_EVENT(4, SEVERITY::INFO); //!< The CCSDS Board detected that either bit lock or RF available or both are lost. No parameters.
static const Event FRAME_PROCESSING_FAILED = MAKE_EVENT(5, SEVERITY::LOW); //!< The CCSDS Board could not interpret a TC static const Event FRAME_PROCESSING_FAILED = MAKE_EVENT(5, SEVERITY::LOW); //!< The CCSDS Board could not interpret a TC
/** /**
* The Constructor sets the passed parameters and nothing else. * The Constructor sets the passed parameters and nothing else.
* @param set_frame_buffer The buffer in which incoming frame candidates are stored. * @param set_frame_buffer The buffer in which incoming frame candidates are stored.
* @param setClcw The CLCW class to work on when returning CLCW information. * @param setClcw The CLCW class to work on when returning CLCW information.
* @param set_start_sequence_length Length of the Start sequence in front of every TC Transfer Frame. * @param set_start_sequence_length Length of the Start sequence in front of every TC Transfer Frame.
* @param set_scid The SCID to operate on. * @param set_scid The SCID to operate on.
*/ */
DataLinkLayer( uint8_t* set_frame_buffer, ClcwIF* setClcw, uint8_t set_start_sequence_length, uint16_t set_scid ); DataLinkLayer( uint8_t* set_frame_buffer, ClcwIF* setClcw, uint8_t set_start_sequence_length, uint16_t set_scid );
/** /**
* Empty virtual destructor. * Empty virtual destructor.
*/ */
~DataLinkLayer(); ~DataLinkLayer();
/** /**
* This method tries to process a frame that is placed in #frameBuffer. * This method tries to process a frame that is placed in #frameBuffer.
* The procedures described in the Standard are performed. * The procedures described in the Standard are performed.
* @param length Length of the incoming frame candidate. * @param length Length of the incoming frame candidate.
* @return @c RETURN_OK on successful handling, otherwise the return codes of the higher methods. * @return @c RETURN_OK on successful handling, otherwise the return codes of the higher methods.
*/ */
ReturnValue_t processFrame( uint16_t length ); ReturnValue_t processFrame( uint16_t length );
/** /**
* Configuration method to add a new TC Virtual Channel. * Configuration method to add a new TC Virtual Channel.
* Shall only be called during initialization. As soon as the method was called, the layer can * Shall only be called during initialization. As soon as the method was called, the layer can
* handle Frames directed to this VC. * handle Frames directed to this VC.
* @param virtualChannelId Id of the VC. Shall be smaller than 64. * @param virtualChannelId Id of the VC. Shall be smaller than 64.
* @param object Reference to the object that handles the Frame. * @param object Reference to the object that handles the Frame.
* @return @c RETURN_OK on success, @c RETURN_FAILED otherwise. * @return @c RETURN_OK on success, @c RETURN_FAILED otherwise.
*/ */
ReturnValue_t addVirtualChannel( uint8_t virtualChannelId, VirtualChannelReceptionIF* object ); ReturnValue_t addVirtualChannel( uint8_t virtualChannelId, VirtualChannelReceptionIF* object );
/** /**
* The initialization method calls the @c initialize routine of all virtual channels. * The initialization method calls the @c initialize routine of all virtual channels.
* @return The return code of the first failed VC initialization or @c RETURN_OK. * @return The return code of the first failed VC initialization or @c RETURN_OK.
*/ */
ReturnValue_t initialize(); ReturnValue_t initialize();
private: private:
typedef std::map<uint8_t, VirtualChannelReceptionIF*>::iterator virtualChannelIterator; //!< Typedef to simplify handling the #virtualChannels map. typedef std::map<uint8_t, VirtualChannelReceptionIF*>::iterator virtualChannelIterator; //!< Typedef to simplify handling the #virtualChannels map.
static const uint8_t FRAME_VERSION_NUMBER_DEFAULT = 0x00; //!< Constant for the default value of Frame Version Numbers. static const uint8_t FRAME_VERSION_NUMBER_DEFAULT = 0x00; //!< Constant for the default value of Frame Version Numbers.
static const uint8_t FRAME_PRIMARY_HEADER_LENGTH = 5; //!< Length of the frame's primary header. static const uint8_t FRAME_PRIMARY_HEADER_LENGTH = 5; //!< Length of the frame's primary header.
static const uint8_t START_SEQUENCE_PATTERN = 0x00; //!< The start sequence pattern which might be with the frame. static const uint8_t START_SEQUENCE_PATTERN = 0x00; //!< The start sequence pattern which might be with the frame.
static const bool USE_CRC = true; //!< A global, so called "Managed Parameter" that identifies if incoming frames have CRC's or not. static const bool USE_CRC = true; //!< A global, so called "Managed Parameter" that identifies if incoming frames have CRC's or not.
uint16_t spacecraftId; //!< The Space Craft Identifier (SCID) configured. uint16_t spacecraftId; //!< The Space Craft Identifier (SCID) configured.
uint8_t* frameBuffer; //!< A pointer to point to the current incoming frame. uint8_t* frameBuffer; //!< A pointer to point to the current incoming frame.
ClcwIF* clcw; //!< Pointer to store the CLCW to work on. ClcwIF* clcw; //!< Pointer to store the CLCW to work on.
uint16_t receivedDataLength; //!< Stores the length of the currently processed frame. uint16_t receivedDataLength; //!< Stores the length of the currently processed frame.
TcTransferFrame currentFrame; //!< Stores a more convenient access to the current frame. TcTransferFrame currentFrame; //!< Stores a more convenient access to the current frame.
uint8_t startSequenceLength; //!< Configured length of the start sequence. Maybe this must be done more variable. uint8_t startSequenceLength; //!< Configured length of the start sequence. Maybe this must be done more variable.
std::map<uint8_t, VirtualChannelReceptionIF*> virtualChannels; //!< Map of all virtual channels assigned. std::map<uint8_t, VirtualChannelReceptionIF*> virtualChannels; //!< Map of all virtual channels assigned.
/** /**
* Method that performs all possible frame validity checks (as specified). * Method that performs all possible frame validity checks (as specified).
* @return Various error codes or @c RETURN_OK on success. * @return Various error codes or @c RETURN_OK on success.
*/ */
ReturnValue_t frameValidationCheck(); ReturnValue_t frameValidationCheck();
/** /**
* First method to call. * First method to call.
* Removes start sequence bytes and checks if the complete frame was received. * Removes start sequence bytes and checks if the complete frame was received.
* SHOULDDO: Maybe handling the start sequence must be done more variable. * SHOULDDO: Maybe handling the start sequence must be done more variable.
* @return @c RETURN_OK or @c TOO_SHORT. * @return @c RETURN_OK or @c TOO_SHORT.
*/ */
ReturnValue_t frameDelimitingAndFillRemoval(); ReturnValue_t frameDelimitingAndFillRemoval();
/** /**
* Small helper method to check the CRC of the Frame. * Small helper method to check the CRC of the Frame.
* @return @c RETURN_OK or @c CRC_FAILED. * @return @c RETURN_OK or @c CRC_FAILED.
*/ */
ReturnValue_t frameCheckCRC(); ReturnValue_t frameCheckCRC();
/** /**
* Method that groups the reception process of all Frames. * Method that groups the reception process of all Frames.
* Calls #frameDelimitingAndFillRemoval and #frameValidationCheck. * Calls #frameDelimitingAndFillRemoval and #frameValidationCheck.
* @return The return codes of the sub calls. * @return The return codes of the sub calls.
*/ */
ReturnValue_t allFramesReception(); ReturnValue_t allFramesReception();
/** /**
* Dummy method for master channel demultiplexing. * Dummy method for master channel demultiplexing.
* As there's only one Master Channel here, the method calls #virtualChannelDemultiplexing. * As there's only one Master Channel here, the method calls #virtualChannelDemultiplexing.
* @return The return codes of #virtualChannelDemultiplexing. * @return The return codes of #virtualChannelDemultiplexing.
*/ */
ReturnValue_t masterChannelDemultiplexing(); ReturnValue_t masterChannelDemultiplexing();
/** /**
* Method to demultiplex the Frames to Virtual Channels (VC's). * Method to demultiplex the Frames to Virtual Channels (VC's).
* Looks up the requested VC in #virtualChannels and forwards the Frame to its * Looks up the requested VC in #virtualChannels and forwards the Frame to its
* #frameAcceptanceAndReportingMechanism method, if found. * #frameAcceptanceAndReportingMechanism method, if found.
* @return The higher method codes or @c VC_NOT_FOUND. * @return The higher method codes or @c VC_NOT_FOUND.
*/ */
ReturnValue_t virtualChannelDemultiplexing(); ReturnValue_t virtualChannelDemultiplexing();
}; };
#endif /* DATALINKLAYER_H_ */ #endif /* DATALINKLAYER_H_ */

View File

@ -1,54 +1,54 @@
/** /**
* @file Farm1StateIF.h * @file Farm1StateIF.h
* @brief This file defines the Farm1StateIF class. * @brief This file defines the Farm1StateIF class.
* @date 24.04.2013 * @date 24.04.2013
* @author baetz * @author baetz
*/ */
#ifndef FARM1STATEIF_H_ #ifndef FARM1STATEIF_H_
#define FARM1STATEIF_H_ #define FARM1STATEIF_H_
#include "../datalinklayer/CCSDSReturnValuesIF.h" #include "CCSDSReturnValuesIF.h"
class VirtualChannelReception; class VirtualChannelReception;
class TcTransferFrame; class TcTransferFrame;
class ClcwIF; class ClcwIF;
/** /**
* This is the interface for states of the FARM-1 state machine. * This is the interface for states of the FARM-1 state machine.
* Classes implementing this interface can be used as FARM-1 states. This is a simple implementation * Classes implementing this interface can be used as FARM-1 states. This is a simple implementation
* of the state pattern. * of the state pattern.
*/ */
class Farm1StateIF : public CCSDSReturnValuesIF { class Farm1StateIF : public CCSDSReturnValuesIF {
public: public:
/** /**
* A method that shall handle an incoming frame as AD Frame. * A method that shall handle an incoming frame as AD Frame.
* @param frame The frame to handle. * @param frame The frame to handle.
* @param clcw Any changes to the CLCW shall be done with the help of this interface. * @param clcw Any changes to the CLCW shall be done with the help of this interface.
* @return If forwarding to a MAP Channel is required, the return value shall be #FRAME_OK. * @return If forwarding to a MAP Channel is required, the return value shall be #FRAME_OK.
* Otherwise, an appropriate return value or error code shall be generated. * Otherwise, an appropriate return value or error code shall be generated.
*/ */
virtual ReturnValue_t handleADFrame( TcTransferFrame* frame, ClcwIF* clcw ) = 0; virtual ReturnValue_t handleADFrame( TcTransferFrame* frame, ClcwIF* clcw ) = 0;
/** /**
* This method shall handle frames that have been successfully identified as BC Unlock frames. * This method shall handle frames that have been successfully identified as BC Unlock frames.
* @param clcw Any changes to the CLCW shall be done with the help of this interface. * @param clcw Any changes to the CLCW shall be done with the help of this interface.
* @return If forwarding to a MAP Channel is required, the return value shall be #FRAME_OK. * @return If forwarding to a MAP Channel is required, the return value shall be #FRAME_OK.
* Otherwise, an appropriate return value or error code shall be generated. * Otherwise, an appropriate return value or error code shall be generated.
*/ */
virtual ReturnValue_t handleBCUnlockCommand( ClcwIF* clcw ) = 0; virtual ReturnValue_t handleBCUnlockCommand( ClcwIF* clcw ) = 0;
/** /**
* This method shall handle frames that have been successfully identified as BC Set VR frames. * This method shall handle frames that have been successfully identified as BC Set VR frames.
* @param clcw Any changes to the CLCW shall be done with the help of this interface. * @param clcw Any changes to the CLCW shall be done with the help of this interface.
* @param vr The V(r) value found in the frame. * @param vr The V(r) value found in the frame.
* @return If forwarding to a MAP Channel is required, the return value shall be #FRAME_OK. * @return If forwarding to a MAP Channel is required, the return value shall be #FRAME_OK.
* Otherwise, an appropriate return value or error code shall be generated. * Otherwise, an appropriate return value or error code shall be generated.
*/ */
virtual ReturnValue_t handleBCSetVrCommand( ClcwIF* clcw, uint8_t vr ) = 0; virtual ReturnValue_t handleBCSetVrCommand( ClcwIF* clcw, uint8_t vr ) = 0;
/** /**
* Empty virtual destructor. * Empty virtual destructor.
*/ */
virtual ~Farm1StateIF() { virtual ~Farm1StateIF() {
} }
}; };
#endif /* FARM1STATEIF_H_ */ #endif /* FARM1STATEIF_H_ */

View File

@ -1,35 +1,35 @@
/** /**
* @file Farm1StateLockout.cpp * @file Farm1StateLockout.cpp
* @brief This file defines the Farm1StateLockout class. * @brief This file defines the Farm1StateLockout class.
* @date 24.04.2013 * @date 24.04.2013
* @author baetz * @author baetz
*/ */
#include "../datalinklayer/ClcwIF.h" #include "ClcwIF.h"
#include "../datalinklayer/Farm1StateLockout.h" #include "Farm1StateLockout.h"
#include "../datalinklayer/TcTransferFrame.h" #include "TcTransferFrame.h"
#include "../datalinklayer/VirtualChannelReception.h" #include "VirtualChannelReception.h"
Farm1StateLockout::Farm1StateLockout(VirtualChannelReception* setMyVC) : myVC(setMyVC) { Farm1StateLockout::Farm1StateLockout(VirtualChannelReception* setMyVC) : myVC(setMyVC) {
} }
ReturnValue_t Farm1StateLockout::handleADFrame(TcTransferFrame* frame, ReturnValue_t Farm1StateLockout::handleADFrame(TcTransferFrame* frame,
ClcwIF* clcw) { ClcwIF* clcw) {
return FARM_IN_LOCKOUT; return FARM_IN_LOCKOUT;
} }
ReturnValue_t Farm1StateLockout::handleBCUnlockCommand(ClcwIF* clcw) { ReturnValue_t Farm1StateLockout::handleBCUnlockCommand(ClcwIF* clcw) {
myVC->farmBCounter++; myVC->farmBCounter++;
clcw->setRetransmitFlag(false); clcw->setRetransmitFlag(false);
clcw->setLockoutFlag( false ); clcw->setLockoutFlag( false );
clcw->setWaitFlag( false ); clcw->setWaitFlag( false );
myVC->currentState = &(myVC->openState); myVC->currentState = &(myVC->openState);
return BC_IS_UNLOCK_COMMAND; return BC_IS_UNLOCK_COMMAND;
} }
ReturnValue_t Farm1StateLockout::handleBCSetVrCommand(ClcwIF* clcw, ReturnValue_t Farm1StateLockout::handleBCSetVrCommand(ClcwIF* clcw,
uint8_t vr) { uint8_t vr) {
myVC->farmBCounter++; myVC->farmBCounter++;
return BC_IS_SET_VR_COMMAND; return BC_IS_SET_VR_COMMAND;
} }

View File

@ -1,59 +1,59 @@
/** /**
* @file Farm1StateLockout.h * @file Farm1StateLockout.h
* @brief This file defines the Farm1StateLockout class. * @brief This file defines the Farm1StateLockout class.
* @date 24.04.2013 * @date 24.04.2013
* @author baetz * @author baetz
*/ */
#ifndef FARM1STATELOCKOUT_H_ #ifndef FARM1STATELOCKOUT_H_
#define FARM1STATELOCKOUT_H_ #define FARM1STATELOCKOUT_H_
#include "../datalinklayer/Farm1StateIF.h" #include "Farm1StateIF.h"
/** /**
* This class represents the FARM-1 "Lockout" State. * This class represents the FARM-1 "Lockout" State.
* The Lockout state is reached if the received Transfer Frame Sequence Number is completely wrong * The Lockout state is reached if the received Transfer Frame Sequence Number is completely wrong
* (i.e. within the Lockout Window). No AD Frames are forwarded. To leave the State, a BC Unlock * (i.e. within the Lockout Window). No AD Frames are forwarded. To leave the State, a BC Unlock
* command is required. * command is required.
*/ */
class Farm1StateLockout : public Farm1StateIF { class Farm1StateLockout : public Farm1StateIF {
private: private:
/** /**
* This is a reference to the "owner" class the State works on. * This is a reference to the "owner" class the State works on.
*/ */
VirtualChannelReception* myVC; VirtualChannelReception* myVC;
public: public:
/** /**
* The default constructor if the State. * The default constructor if the State.
* Sets the "owner" of the State. * Sets the "owner" of the State.
* @param setMyVC The "owner" class. * @param setMyVC The "owner" class.
*/ */
Farm1StateLockout( VirtualChannelReception* setMyVC ); Farm1StateLockout( VirtualChannelReception* setMyVC );
/** /**
* All AD Frames are rejected with FARM_IN_LOCKOUT * All AD Frames are rejected with FARM_IN_LOCKOUT
* @param frame The frame to handle. * @param frame The frame to handle.
* @param clcw Any changes to the CLCW shall be done with the help of this interface. * @param clcw Any changes to the CLCW shall be done with the help of this interface.
* @return FARM_IN_LOCKOUT * @return FARM_IN_LOCKOUT
*/ */
ReturnValue_t handleADFrame( TcTransferFrame* frame, ClcwIF* clcw ); ReturnValue_t handleADFrame( TcTransferFrame* frame, ClcwIF* clcw );
/** /**
* These commands are handled as specified. * These commands are handled as specified.
* State changes to Farm1StateOpen. * State changes to Farm1StateOpen.
* @param clcw Any changes to the CLCW shall be done with the help of this interface. * @param clcw Any changes to the CLCW shall be done with the help of this interface.
* @return As the frame needs no forwarding to a MAP Channel, #BC_IS_UNLOCK_COMMAND * @return As the frame needs no forwarding to a MAP Channel, #BC_IS_UNLOCK_COMMAND
* is returned. * is returned.
*/ */
ReturnValue_t handleBCUnlockCommand( ClcwIF* clcw ); ReturnValue_t handleBCUnlockCommand( ClcwIF* clcw );
/** /**
* These commands are handled as specified. * These commands are handled as specified.
* The V(r) value is not set in Lockout State, even though the Command itself is accepted. * The V(r) value is not set in Lockout State, even though the Command itself is accepted.
* @param clcw Any changes to the CLCW shall be done with the help of this interface. * @param clcw Any changes to the CLCW shall be done with the help of this interface.
* @param vr The V(r) value found in the frame. * @param vr The V(r) value found in the frame.
* @return As the frame needs no forwarding to a MAP Channel, #BC_IS_SET_VR_COMMAND * @return As the frame needs no forwarding to a MAP Channel, #BC_IS_SET_VR_COMMAND
* is returned. * is returned.
*/ */
ReturnValue_t handleBCSetVrCommand( ClcwIF* clcw, uint8_t vr ); ReturnValue_t handleBCSetVrCommand( ClcwIF* clcw, uint8_t vr );
}; };
#endif /* FARM1STATELOCKOUT_H_ */ #endif /* FARM1STATELOCKOUT_H_ */

View File

@ -1,49 +1,49 @@
/** /**
* @file Farm1StateOpen.cpp * @file Farm1StateOpen.cpp
* @brief This file defines the Farm1StateOpen class. * @brief This file defines the Farm1StateOpen class.
* @date 24.04.2013 * @date 24.04.2013
* @author baetz * @author baetz
*/ */
#include "../datalinklayer/ClcwIF.h" #include "ClcwIF.h"
#include "../datalinklayer/Farm1StateOpen.h" #include "Farm1StateOpen.h"
#include "../datalinklayer/TcTransferFrame.h" #include "TcTransferFrame.h"
#include "../datalinklayer/VirtualChannelReception.h" #include "VirtualChannelReception.h"
Farm1StateOpen::Farm1StateOpen(VirtualChannelReception* setMyVC) : myVC(setMyVC) { Farm1StateOpen::Farm1StateOpen(VirtualChannelReception* setMyVC) : myVC(setMyVC) {
} }
ReturnValue_t Farm1StateOpen::handleADFrame(TcTransferFrame* frame, ReturnValue_t Farm1StateOpen::handleADFrame(TcTransferFrame* frame,
ClcwIF* clcw) { ClcwIF* clcw) {
int8_t diff = frame->getSequenceNumber() - myVC->vR; int8_t diff = frame->getSequenceNumber() - myVC->vR;
if (diff == 0 ) { if (diff == 0 ) {
myVC->vR++; myVC->vR++;
clcw->setRetransmitFlag(false); clcw->setRetransmitFlag(false);
return RETURN_OK; return RETURN_OK;
} else if (diff < myVC->positiveWindow && diff > 0 ) { } else if (diff < myVC->positiveWindow && diff > 0 ) {
clcw->setRetransmitFlag(true); clcw->setRetransmitFlag(true);
return NS_POSITIVE_W; return NS_POSITIVE_W;
} else if (diff < 0 && diff >= -myVC->negativeWindow) { } else if (diff < 0 && diff >= -myVC->negativeWindow) {
return NS_NEGATIVE_W; return NS_NEGATIVE_W;
} else { } else {
clcw->setLockoutFlag(true); clcw->setLockoutFlag(true);
myVC->currentState = &(myVC->lockoutState); myVC->currentState = &(myVC->lockoutState);
return NS_LOCKOUT; return NS_LOCKOUT;
} }
} }
ReturnValue_t Farm1StateOpen::handleBCUnlockCommand( ClcwIF* clcw ) { ReturnValue_t Farm1StateOpen::handleBCUnlockCommand( ClcwIF* clcw ) {
myVC->farmBCounter++; myVC->farmBCounter++;
clcw->setRetransmitFlag(false); clcw->setRetransmitFlag(false);
return BC_IS_UNLOCK_COMMAND; return BC_IS_UNLOCK_COMMAND;
} }
ReturnValue_t Farm1StateOpen::handleBCSetVrCommand( ClcwIF* clcw, uint8_t vr ) { ReturnValue_t Farm1StateOpen::handleBCSetVrCommand( ClcwIF* clcw, uint8_t vr ) {
myVC->farmBCounter++; myVC->farmBCounter++;
clcw->setRetransmitFlag(false); clcw->setRetransmitFlag(false);
myVC->vR = vr; myVC->vR = vr;
return BC_IS_SET_VR_COMMAND; return BC_IS_SET_VR_COMMAND;
} }

View File

@ -1,62 +1,62 @@
/** /**
* @file Farm1StateOpen.h * @file Farm1StateOpen.h
* @brief This file defines the Farm1StateOpen class. * @brief This file defines the Farm1StateOpen class.
* @date 24.04.2013 * @date 24.04.2013
* @author baetz * @author baetz
*/ */
#ifndef FARM1STATEOPEN_H_ #ifndef FARM1STATEOPEN_H_
#define FARM1STATEOPEN_H_ #define FARM1STATEOPEN_H_
#include "../datalinklayer/Farm1StateIF.h" #include "Farm1StateIF.h"
/** /**
* This class represents the FARM-1 "Open" State. * This class represents the FARM-1 "Open" State.
* The Open state is the state of normal operation. It handles all types of frames, * The Open state is the state of normal operation. It handles all types of frames,
* including AD Frames. If a wrong Frame Sequence Number is detected in an AD Frame, the * including AD Frames. If a wrong Frame Sequence Number is detected in an AD Frame, the
* State reacts as specified. * State reacts as specified.
*/ */
class Farm1StateOpen : public Farm1StateIF { class Farm1StateOpen : public Farm1StateIF {
private: private:
/** /**
* This is a reference to the "owner" class the State works on. * This is a reference to the "owner" class the State works on.
*/ */
VirtualChannelReception* myVC; VirtualChannelReception* myVC;
public: public:
/** /**
* The default constructor if the State. * The default constructor if the State.
* Sets the "owner" of the State. * Sets the "owner" of the State.
* @param setMyVC The "owner" class. * @param setMyVC The "owner" class.
*/ */
Farm1StateOpen( VirtualChannelReception* setMyVC ); Farm1StateOpen( VirtualChannelReception* setMyVC );
/** /**
* Method to check the validity of AD Frames. * Method to check the validity of AD Frames.
* It checks the Frame Sequence Number and reacts as specified in the standard. The state may * It checks the Frame Sequence Number and reacts as specified in the standard. The state may
* change to Farm1StateLockout. * change to Farm1StateLockout.
* @param frame The frame to handle. * @param frame The frame to handle.
* @param clcw Any changes to the CLCW shall be done with the help of this interface. * @param clcw Any changes to the CLCW shall be done with the help of this interface.
* @return If the Sequence Number is ok, it returns #RETURN_OK. Otherwise either #NS_POSITIVE_W, * @return If the Sequence Number is ok, it returns #RETURN_OK. Otherwise either #NS_POSITIVE_W,
* #NS_NEGATIVE_W or NS_LOCKOUT is returned. * #NS_NEGATIVE_W or NS_LOCKOUT is returned.
*/ */
ReturnValue_t handleADFrame( TcTransferFrame* frame, ClcwIF* clcw ); ReturnValue_t handleADFrame( TcTransferFrame* frame, ClcwIF* clcw );
/** /**
* These commands are handled as specified. * These commands are handled as specified.
* State does not change. * State does not change.
* @param clcw Any changes to the CLCW shall be done with the help of this interface. * @param clcw Any changes to the CLCW shall be done with the help of this interface.
* @return As the frame needs no forwarding to a MAP Channel, #BC_IS_UNLOCK_COMMAND * @return As the frame needs no forwarding to a MAP Channel, #BC_IS_UNLOCK_COMMAND
* is returned. * is returned.
*/ */
ReturnValue_t handleBCUnlockCommand( ClcwIF* clcw ); ReturnValue_t handleBCUnlockCommand( ClcwIF* clcw );
/** /**
* These commands are handled as specified. * These commands are handled as specified.
* State does not change. * State does not change.
* @param clcw Any changes to the CLCW shall be done with the help of this interface. * @param clcw Any changes to the CLCW shall be done with the help of this interface.
* @param vr The V(r) value found in the frame. * @param vr The V(r) value found in the frame.
* @return As the frame needs no forwarding to a MAP Channel, #BC_IS_SET_VR_COMMAND * @return As the frame needs no forwarding to a MAP Channel, #BC_IS_SET_VR_COMMAND
* is returned. * is returned.
*/ */
ReturnValue_t handleBCSetVrCommand( ClcwIF* clcw, uint8_t vr ); ReturnValue_t handleBCSetVrCommand( ClcwIF* clcw, uint8_t vr );
}; };
#endif /* FARM1STATEOPEN_H_ */ #endif /* FARM1STATEOPEN_H_ */

View File

@ -1,43 +1,43 @@
/** /**
* @file Farm1StateWait.cpp * @file Farm1StateWait.cpp
* @brief This file defines the Farm1StateWait class. * @brief This file defines the Farm1StateWait class.
* @date 24.04.2013 * @date 24.04.2013
* @author baetz * @author baetz
*/ */
#include "../datalinklayer/ClcwIF.h" #include "ClcwIF.h"
#include "../datalinklayer/Farm1StateWait.h" #include "Farm1StateWait.h"
#include "../datalinklayer/TcTransferFrame.h" #include "TcTransferFrame.h"
#include "../datalinklayer/VirtualChannelReception.h" #include "VirtualChannelReception.h"
Farm1StateWait::Farm1StateWait(VirtualChannelReception* setMyVC) : myVC(setMyVC) { Farm1StateWait::Farm1StateWait(VirtualChannelReception* setMyVC) : myVC(setMyVC) {
} }
ReturnValue_t Farm1StateWait::handleADFrame(TcTransferFrame* frame, ReturnValue_t Farm1StateWait::handleADFrame(TcTransferFrame* frame,
ClcwIF* clcw) { ClcwIF* clcw) {
int8_t diff = frame->getSequenceNumber() - myVC->vR; int8_t diff = frame->getSequenceNumber() - myVC->vR;
if ( diff < -myVC->negativeWindow || diff >= myVC->positiveWindow ) { if ( diff < -myVC->negativeWindow || diff >= myVC->positiveWindow ) {
clcw->setLockoutFlag(true); clcw->setLockoutFlag(true);
myVC->currentState = &(myVC->lockoutState); myVC->currentState = &(myVC->lockoutState);
} }
return FARM_IN_WAIT; return FARM_IN_WAIT;
} }
ReturnValue_t Farm1StateWait::handleBCUnlockCommand(ClcwIF* clcw) { ReturnValue_t Farm1StateWait::handleBCUnlockCommand(ClcwIF* clcw) {
myVC->farmBCounter++; myVC->farmBCounter++;
clcw->setRetransmitFlag(false); clcw->setRetransmitFlag(false);
clcw->setWaitFlag( false ); clcw->setWaitFlag( false );
myVC->currentState = &(myVC->openState); myVC->currentState = &(myVC->openState);
return BC_IS_UNLOCK_COMMAND; return BC_IS_UNLOCK_COMMAND;
} }
ReturnValue_t Farm1StateWait::handleBCSetVrCommand(ClcwIF* clcw, uint8_t vr) { ReturnValue_t Farm1StateWait::handleBCSetVrCommand(ClcwIF* clcw, uint8_t vr) {
myVC->farmBCounter++; myVC->farmBCounter++;
clcw->setWaitFlag( false ); clcw->setWaitFlag( false );
clcw->setRetransmitFlag(false); clcw->setRetransmitFlag(false);
myVC->vR = vr; myVC->vR = vr;
myVC->currentState = &(myVC->openState); myVC->currentState = &(myVC->openState);
return BC_IS_SET_VR_COMMAND; return BC_IS_SET_VR_COMMAND;
} }

View File

@ -1,58 +1,58 @@
/** /**
* @file Farm1StateWait.h * @file Farm1StateWait.h
* @brief This file defines the Farm1StateWait class. * @brief This file defines the Farm1StateWait class.
* @date 24.04.2013 * @date 24.04.2013
* @author baetz * @author baetz
*/ */
#ifndef FARM1STATEWAIT_H_ #ifndef FARM1STATEWAIT_H_
#define FARM1STATEWAIT_H_ #define FARM1STATEWAIT_H_
#include "../datalinklayer/Farm1StateIF.h" #include "Farm1StateIF.h"
/** /**
* This class represents the FARM-1 "Wait" State. * This class represents the FARM-1 "Wait" State.
* The Wait state is reached if higher level procedures inform the FARM-1 Machine to wait * The Wait state is reached if higher level procedures inform the FARM-1 Machine to wait
* for a certain period. Currently, it is not in use. * for a certain period. Currently, it is not in use.
*/ */
class Farm1StateWait : public Farm1StateIF { class Farm1StateWait : public Farm1StateIF {
private: private:
/** /**
* This is a reference to the "owner" class the State works on. * This is a reference to the "owner" class the State works on.
*/ */
VirtualChannelReception* myVC; VirtualChannelReception* myVC;
public: public:
/** /**
* The default constructor if the State. * The default constructor if the State.
* Sets the "owner" of the State. * Sets the "owner" of the State.
* @param setMyVC The "owner" class. * @param setMyVC The "owner" class.
*/ */
Farm1StateWait( VirtualChannelReception* setMyVC ); Farm1StateWait( VirtualChannelReception* setMyVC );
/** /**
* AD Frames are always discarded. * AD Frames are always discarded.
* If the frame number is in the lockout window, the state changes to Farm1StateLockout. * If the frame number is in the lockout window, the state changes to Farm1StateLockout.
* @param frame The frame to handle. * @param frame The frame to handle.
* @param clcw Any changes to the CLCW shall be done with the help of this interface. * @param clcw Any changes to the CLCW shall be done with the help of this interface.
* @return Always returns FARM_IN_WAIT. * @return Always returns FARM_IN_WAIT.
*/ */
ReturnValue_t handleADFrame( TcTransferFrame* frame, ClcwIF* clcw ); ReturnValue_t handleADFrame( TcTransferFrame* frame, ClcwIF* clcw );
/** /**
* These commands are handled as specified. * These commands are handled as specified.
* State changes to Farm1StateOpen. * State changes to Farm1StateOpen.
* @param clcw Any changes to the CLCW shall be done with the help of this interface. * @param clcw Any changes to the CLCW shall be done with the help of this interface.
* @return As the frame needs no forwarding to a MAP Channel, #BC_IS_UNLOCK_COMMAND * @return As the frame needs no forwarding to a MAP Channel, #BC_IS_UNLOCK_COMMAND
* is returned. * is returned.
*/ */
ReturnValue_t handleBCUnlockCommand( ClcwIF* clcw ); ReturnValue_t handleBCUnlockCommand( ClcwIF* clcw );
/** /**
* These commands are handled as specified. * These commands are handled as specified.
* @param clcw Any changes to the CLCW shall be done with the help of this interface. * @param clcw Any changes to the CLCW shall be done with the help of this interface.
* @param vr The V(r) value found in the frame. * @param vr The V(r) value found in the frame.
* @return As the frame needs no forwarding to a MAP Channel, #BC_IS_SET_VR_COMMAND * @return As the frame needs no forwarding to a MAP Channel, #BC_IS_SET_VR_COMMAND
* is returned. * is returned.
*/ */
ReturnValue_t handleBCSetVrCommand( ClcwIF* clcw, uint8_t vr ); ReturnValue_t handleBCSetVrCommand( ClcwIF* clcw, uint8_t vr );
}; };
#endif /* FARM1STATEWAIT_H_ */ #endif /* FARM1STATEWAIT_H_ */

View File

@ -1,154 +1,154 @@
/** /**
* @file MapPacketExtraction.cpp * @file MapPacketExtraction.cpp
* @brief This file defines the MapPacketExtraction class. * @brief This file defines the MapPacketExtraction class.
* @date 26.03.2013 * @date 26.03.2013
* @author baetz * @author baetz
*/ */
#include "../datalinklayer/MapPacketExtraction.h" #include "MapPacketExtraction.h"
#include "../ipc/QueueFactory.h" #include "../ipc/QueueFactory.h"
#include "../serviceinterface/ServiceInterfaceStream.h" #include "../serviceinterface/ServiceInterfaceStream.h"
#include "../storagemanager/StorageManagerIF.h" #include "../storagemanager/StorageManagerIF.h"
#include "../tmtcpacket/SpacePacketBase.h" #include "../tmtcpacket/SpacePacketBase.h"
#include "../tmtcservices/AcceptsTelecommandsIF.h" #include "../tmtcservices/AcceptsTelecommandsIF.h"
#include "../tmtcservices/TmTcMessage.h" #include "../tmtcservices/TmTcMessage.h"
#include <string.h> #include <string.h>
MapPacketExtraction::MapPacketExtraction(uint8_t setMapId, MapPacketExtraction::MapPacketExtraction(uint8_t setMapId,
object_id_t setPacketDestination) : object_id_t setPacketDestination) :
lastSegmentationFlag(NO_SEGMENTATION), mapId(setMapId), packetLength(0), lastSegmentationFlag(NO_SEGMENTATION), mapId(setMapId), packetLength(0), bufferPosition(
bufferPosition(packetBuffer), packetDestination(setPacketDestination), packetBuffer), packetDestination(setPacketDestination), packetStore(
packetStore(nullptr), tcQueueId(MessageQueueMessageIF::NO_QUEUE) { NULL), tcQueueId(MessageQueueSenderIF::NO_QUEUE) {
memset(packetBuffer, 0, sizeof(packetBuffer)); memset(packetBuffer, 0, sizeof(packetBuffer));
} }
ReturnValue_t MapPacketExtraction::extractPackets(TcTransferFrame* frame) { ReturnValue_t MapPacketExtraction::extractPackets(TcTransferFrame* frame) {
uint8_t segmentationFlag = frame->getSequenceFlags(); uint8_t segmentationFlag = frame->getSequenceFlags();
ReturnValue_t status = TOO_SHORT_MAP_EXTRACTION; ReturnValue_t status = TOO_SHORT_MAP_EXTRACTION;
switch (segmentationFlag) { switch (segmentationFlag) {
case NO_SEGMENTATION: case NO_SEGMENTATION:
status = unpackBlockingPackets(frame); status = unpackBlockingPackets(frame);
break; break;
case FIRST_PORTION: case FIRST_PORTION:
packetLength = frame->getDataLength(); packetLength = frame->getDataLength();
if (packetLength <= MAX_PACKET_SIZE) { if (packetLength <= MAX_PACKET_SIZE) {
memcpy(packetBuffer, frame->getDataField(), packetLength); memcpy(packetBuffer, frame->getDataField(), packetLength);
bufferPosition = &packetBuffer[packetLength]; bufferPosition = &packetBuffer[packetLength];
status = RETURN_OK; status = RETURN_OK;
} else { } else {
sif::error sif::error
<< "MapPacketExtraction::extractPackets. Packet too large! Size: " << "MapPacketExtraction::extractPackets. Packet too large! Size: "
<< packetLength << std::endl; << packetLength << std::endl;
clearBuffers(); clearBuffers();
status = CONTENT_TOO_LARGE; status = CONTENT_TOO_LARGE;
} }
break; break;
case CONTINUING_PORTION: case CONTINUING_PORTION:
case LAST_PORTION: case LAST_PORTION:
if (lastSegmentationFlag == FIRST_PORTION if (lastSegmentationFlag == FIRST_PORTION
|| lastSegmentationFlag == CONTINUING_PORTION) { || lastSegmentationFlag == CONTINUING_PORTION) {
packetLength += frame->getDataLength(); packetLength += frame->getDataLength();
if (packetLength <= MAX_PACKET_SIZE) { if (packetLength <= MAX_PACKET_SIZE) {
memcpy(bufferPosition, frame->getDataField(), memcpy(bufferPosition, frame->getDataField(),
frame->getDataLength()); frame->getDataLength());
bufferPosition = &packetBuffer[packetLength]; bufferPosition = &packetBuffer[packetLength];
if (segmentationFlag == LAST_PORTION) { if (segmentationFlag == LAST_PORTION) {
status = sendCompletePacket(packetBuffer, packetLength); status = sendCompletePacket(packetBuffer, packetLength);
clearBuffers(); clearBuffers();
} }
status = RETURN_OK; status = RETURN_OK;
} else { } else {
sif::error sif::error
<< "MapPacketExtraction::extractPackets. Packet too large! Size: " << "MapPacketExtraction::extractPackets. Packet too large! Size: "
<< packetLength << std::endl; << packetLength << std::endl;
clearBuffers(); clearBuffers();
status = CONTENT_TOO_LARGE; status = CONTENT_TOO_LARGE;
} }
} else { } else {
sif::error sif::error
<< "MapPacketExtraction::extractPackets. Illegal segment! Last flag: " << "MapPacketExtraction::extractPackets. Illegal segment! Last flag: "
<< (int) lastSegmentationFlag << std::endl; << (int) lastSegmentationFlag << std::endl;
clearBuffers(); clearBuffers();
status = ILLEGAL_SEGMENTATION_FLAG; status = ILLEGAL_SEGMENTATION_FLAG;
} }
break; break;
default: default:
sif::error sif::error
<< "MapPacketExtraction::extractPackets. Illegal segmentationFlag: " << "MapPacketExtraction::extractPackets. Illegal segmentationFlag: "
<< (int) segmentationFlag << std::endl; << (int) segmentationFlag << std::endl;
clearBuffers(); clearBuffers();
status = DATA_CORRUPTED; status = DATA_CORRUPTED;
break; break;
} }
lastSegmentationFlag = segmentationFlag; lastSegmentationFlag = segmentationFlag;
return status; return status;
} }
ReturnValue_t MapPacketExtraction::unpackBlockingPackets( ReturnValue_t MapPacketExtraction::unpackBlockingPackets(
TcTransferFrame* frame) { TcTransferFrame* frame) {
ReturnValue_t status = TOO_SHORT_BLOCKED_PACKET; ReturnValue_t status = TOO_SHORT_BLOCKED_PACKET;
uint32_t totalLength = frame->getDataLength(); uint32_t totalLength = frame->getDataLength();
if (totalLength > MAX_PACKET_SIZE) if (totalLength > MAX_PACKET_SIZE)
return CONTENT_TOO_LARGE; return CONTENT_TOO_LARGE;
uint8_t* position = frame->getDataField(); uint8_t* position = frame->getDataField();
while ((totalLength > SpacePacketBase::MINIMUM_SIZE)) { while ((totalLength > SpacePacketBase::MINIMUM_SIZE)) {
SpacePacketBase packet(position); SpacePacketBase packet(position);
uint32_t packetSize = packet.getFullSize(); uint32_t packetSize = packet.getFullSize();
if (packetSize <= totalLength) { if (packetSize <= totalLength) {
status = sendCompletePacket(packet.getWholeData(), status = sendCompletePacket(packet.getWholeData(),
packet.getFullSize()); packet.getFullSize());
totalLength -= packet.getFullSize(); totalLength -= packet.getFullSize();
position += packet.getFullSize(); position += packet.getFullSize();
status = RETURN_OK; status = RETURN_OK;
} else { } else {
status = DATA_CORRUPTED; status = DATA_CORRUPTED;
totalLength = 0; totalLength = 0;
} }
} }
if (totalLength > 0) { if (totalLength > 0) {
status = RESIDUAL_DATA; status = RESIDUAL_DATA;
} }
return status; return status;
} }
ReturnValue_t MapPacketExtraction::sendCompletePacket(uint8_t* data, ReturnValue_t MapPacketExtraction::sendCompletePacket(uint8_t* data,
uint32_t size) { uint32_t size) {
store_address_t store_id; store_address_t store_id;
ReturnValue_t status = this->packetStore->addData(&store_id, data, size); ReturnValue_t status = this->packetStore->addData(&store_id, data, size);
if (status == RETURN_OK) { if (status == RETURN_OK) {
TmTcMessage message(store_id); TmTcMessage message(store_id);
status = MessageQueueSenderIF::sendMessage(tcQueueId,&message); status = MessageQueueSenderIF::sendMessage(tcQueueId,&message);
} }
return status; return status;
} }
void MapPacketExtraction::clearBuffers() { void MapPacketExtraction::clearBuffers() {
memset(packetBuffer, 0, sizeof(packetBuffer)); memset(packetBuffer, 0, sizeof(packetBuffer));
bufferPosition = packetBuffer; bufferPosition = packetBuffer;
packetLength = 0; packetLength = 0;
lastSegmentationFlag = NO_SEGMENTATION; lastSegmentationFlag = NO_SEGMENTATION;
} }
ReturnValue_t MapPacketExtraction::initialize() { ReturnValue_t MapPacketExtraction::initialize() {
packetStore = objectManager->get<StorageManagerIF>(objects::TC_STORE); packetStore = objectManager->get<StorageManagerIF>(objects::TC_STORE);
AcceptsTelecommandsIF* distributor = objectManager->get< AcceptsTelecommandsIF* distributor = objectManager->get<
AcceptsTelecommandsIF>(packetDestination); AcceptsTelecommandsIF>(packetDestination);
if ((packetStore != NULL) && (distributor != NULL)) { if ((packetStore != NULL) && (distributor != NULL)) {
tcQueueId = distributor->getRequestQueue(); tcQueueId = distributor->getRequestQueue();
return RETURN_OK; return RETURN_OK;
} else { } else {
return RETURN_FAILED; return RETURN_FAILED;
} }
} }
void MapPacketExtraction::printPacketBuffer(void) { void MapPacketExtraction::printPacketBuffer(void) {
sif::debug << "DLL: packet_buffer contains: " << std::endl; sif::debug << "DLL: packet_buffer contains: " << std::endl;
for (uint32_t i = 0; i < this->packetLength; ++i) { for (uint32_t i = 0; i < this->packetLength; ++i) {
sif::debug << "packet_buffer[" << std::dec << i << "]: 0x" << std::hex sif::debug << "packet_buffer[" << std::dec << i << "]: 0x" << std::hex
<< (uint16_t) this->packetBuffer[i] << std::endl; << (uint16_t) this->packetBuffer[i] << std::endl;
} }
} }
uint8_t MapPacketExtraction::getMapId() const { uint8_t MapPacketExtraction::getMapId() const {
return mapId; return mapId;
} }

View File

@ -1,78 +1,78 @@
/** /**
* @file MapPacketExtraction.h * @file MapPacketExtraction.h
* @brief This file defines the MapPacketExtraction class. * @brief This file defines the MapPacketExtraction class.
* @date 26.03.2013 * @date 26.03.2013
* @author baetz * @author baetz
*/ */
#ifndef MAPPACKETEXTRACTION_H_ #ifndef MAPPACKETEXTRACTION_H_
#define MAPPACKETEXTRACTION_H_ #define MAPPACKETEXTRACTION_H_
#include "../datalinklayer/MapPacketExtractionIF.h" #include "MapPacketExtractionIF.h"
#include "../objectmanager/ObjectManagerIF.h" #include "../objectmanager/ObjectManagerIF.h"
#include "../returnvalues/HasReturnvaluesIF.h" #include "../returnvalues/HasReturnvaluesIF.h"
#include "../ipc/MessageQueueSenderIF.h" #include "../ipc/MessageQueueSenderIF.h"
class StorageManagerIF; class StorageManagerIF;
/** /**
* Implementation of a MAP Packet Extraction class. * Implementation of a MAP Packet Extraction class.
* The class implements the full MAP Packet Extraction functionality as described in the CCSDS * The class implements the full MAP Packet Extraction functionality as described in the CCSDS
* TC Space Data Link Protocol. It internally stores incomplete segmented packets until they are * TC Space Data Link Protocol. It internally stores incomplete segmented packets until they are
* fully received. All found packets are forwarded to a single distribution entity. * fully received. All found packets are forwarded to a single distribution entity.
*/ */
class MapPacketExtraction: public MapPacketExtractionIF { class MapPacketExtraction: public MapPacketExtractionIF {
private: private:
static const uint32_t MAX_PACKET_SIZE = 4096; static const uint32_t MAX_PACKET_SIZE = 4096;
uint8_t lastSegmentationFlag; //!< The segmentation flag of the last received frame. uint8_t lastSegmentationFlag; //!< The segmentation flag of the last received frame.
uint8_t mapId; //!< MAP ID of this MAP Channel. uint8_t mapId; //!< MAP ID of this MAP Channel.
uint32_t packetLength; //!< Complete length of the current Space Packet. uint32_t packetLength; //!< Complete length of the current Space Packet.
uint8_t* bufferPosition; //!< Position to write to in the internal Packet buffer. uint8_t* bufferPosition; //!< Position to write to in the internal Packet buffer.
uint8_t packetBuffer[MAX_PACKET_SIZE]; //!< The internal Space Packet Buffer. uint8_t packetBuffer[MAX_PACKET_SIZE]; //!< The internal Space Packet Buffer.
object_id_t packetDestination; object_id_t packetDestination;
StorageManagerIF* packetStore; //!< Pointer to the store where full TC packets are stored. StorageManagerIF* packetStore; //!< Pointer to the store where full TC packets are stored.
MessageQueueId_t tcQueueId; //!< QueueId to send found packets to the distributor. MessageQueueId_t tcQueueId; //!< QueueId to send found packets to the distributor.
/** /**
* Debug method to print the packet Buffer's content. * Debug method to print the packet Buffer's content.
*/ */
void printPacketBuffer(); void printPacketBuffer();
/** /**
* Method that is called if the segmentation flag is @c NO_SEGMENTATION. * Method that is called if the segmentation flag is @c NO_SEGMENTATION.
* The method extracts one or more packets within the frame and forwards them to the OBSW. * The method extracts one or more packets within the frame and forwards them to the OBSW.
* @param frame The TC Transfer Frame to work on. * @param frame The TC Transfer Frame to work on.
* @return @c RETURN_OK if all Packets were extracted. If something is entirely wrong, * @return @c RETURN_OK if all Packets were extracted. If something is entirely wrong,
* @c DATA_CORRUPTED is returned, if some bytes are left over @c RESIDUAL_DATA. * @c DATA_CORRUPTED is returned, if some bytes are left over @c RESIDUAL_DATA.
*/ */
ReturnValue_t unpackBlockingPackets(TcTransferFrame* frame); ReturnValue_t unpackBlockingPackets(TcTransferFrame* frame);
/** /**
* Helper method to forward a complete packet to the OBSW. * Helper method to forward a complete packet to the OBSW.
* @param data Pointer to the data, either directly from the frame or from the packetBuffer. * @param data Pointer to the data, either directly from the frame or from the packetBuffer.
* @param size Complete total size of the packet. * @param size Complete total size of the packet.
* @return Return Code of the Packet Store or the Message Queue. * @return Return Code of the Packet Store or the Message Queue.
*/ */
ReturnValue_t sendCompletePacket( uint8_t* data, uint32_t size ); ReturnValue_t sendCompletePacket( uint8_t* data, uint32_t size );
/** /**
* Helper method to reset the internal buffer. * Helper method to reset the internal buffer.
*/ */
void clearBuffers(); void clearBuffers();
public: public:
/** /**
* Default constructor. * Default constructor.
* Members are set to default values. * Members are set to default values.
* @param setMapId The MAP ID of the instance. * @param setMapId The MAP ID of the instance.
*/ */
MapPacketExtraction( uint8_t setMapId, object_id_t setPacketDestination ); MapPacketExtraction( uint8_t setMapId, object_id_t setPacketDestination );
ReturnValue_t extractPackets(TcTransferFrame* frame); ReturnValue_t extractPackets(TcTransferFrame* frame);
/** /**
* The #packetStore and the default destination of #tcQueue are initialized here. * The #packetStore and the default destination of #tcQueue are initialized here.
* @return @c RETURN_OK on success, @c RETURN_FAILED otherwise. * @return @c RETURN_OK on success, @c RETURN_FAILED otherwise.
*/ */
ReturnValue_t initialize(); ReturnValue_t initialize();
/** /**
* Getter. * Getter.
* @return The MAP ID of this instance. * @return The MAP ID of this instance.
*/ */
uint8_t getMapId() const; uint8_t getMapId() const;
}; };
#endif /* MAPPACKETEXTRACTION_H_ */ #endif /* MAPPACKETEXTRACTION_H_ */

View File

@ -1,47 +1,47 @@
/** /**
* @file MapPacketExtractionIF.h * @file MapPacketExtractionIF.h
* @brief This file defines the MapPacketExtractionIF class. * @brief This file defines the MapPacketExtractionIF class.
* @date 25.03.2013 * @date 25.03.2013
* @author baetz * @author baetz
*/ */
#ifndef MAPPACKETEXTRACTIONIF_H_ #ifndef MAPPACKETEXTRACTIONIF_H_
#define MAPPACKETEXTRACTIONIF_H_ #define MAPPACKETEXTRACTIONIF_H_
#include "../datalinklayer/CCSDSReturnValuesIF.h" #include "CCSDSReturnValuesIF.h"
#include "../datalinklayer/TcTransferFrame.h" #include "TcTransferFrame.h"
/** /**
* This is the interface for MAP Packet Extraction classes. * This is the interface for MAP Packet Extraction classes.
* All classes implementing this interface shall be able to extract blocked or segmented Space * All classes implementing this interface shall be able to extract blocked or segmented Space
* Packets on a certain MAP channel. This is done in accordance with the CCSDS TC Space Data Link * Packets on a certain MAP channel. This is done in accordance with the CCSDS TC Space Data Link
* Protocol. * Protocol.
*/ */
class MapPacketExtractionIF : public CCSDSReturnValuesIF { class MapPacketExtractionIF : public CCSDSReturnValuesIF {
protected: protected:
static const uint8_t FIRST_PORTION = 0b01; //!< Identification of the first part of a segmented Packet. static const uint8_t FIRST_PORTION = 0b01; //!< Identification of the first part of a segmented Packet.
static const uint8_t CONTINUING_PORTION = 0b00; //!< Identification of a continuing part of segmented Packets. static const uint8_t CONTINUING_PORTION = 0b00; //!< Identification of a continuing part of segmented Packets.
static const uint8_t LAST_PORTION = 0b10; //!< The last portion of a segmented Packet. static const uint8_t LAST_PORTION = 0b10; //!< The last portion of a segmented Packet.
static const uint8_t NO_SEGMENTATION = 0b11; //!< A Frame without segmentation but maybe with blocking. static const uint8_t NO_SEGMENTATION = 0b11; //!< A Frame without segmentation but maybe with blocking.
public: public:
/** /**
* Empty virtual destructor. * Empty virtual destructor.
*/ */
virtual ~MapPacketExtractionIF() { virtual ~MapPacketExtractionIF() {
} }
/** /**
* Method to call to handle a single Transfer Frame. * Method to call to handle a single Transfer Frame.
* The method tries to extract Packets from the frame as stated in the Standard. * The method tries to extract Packets from the frame as stated in the Standard.
* @param frame * @param frame
* @return * @return
*/ */
virtual ReturnValue_t extractPackets( TcTransferFrame* frame ) = 0; virtual ReturnValue_t extractPackets( TcTransferFrame* frame ) = 0;
/** /**
* Any post-instantiation initialization shall be done in this method. * Any post-instantiation initialization shall be done in this method.
* @return * @return
*/ */
virtual ReturnValue_t initialize() = 0; virtual ReturnValue_t initialize() = 0;
}; };
#endif /* MAPPACKETEXTRACTIONIF_H_ */ #endif /* MAPPACKETEXTRACTIONIF_H_ */

View File

@ -1,102 +1,102 @@
/** /**
* @file TcTransferFrame.cpp * @file TcTransferFrame.cpp
* @brief This file defines the TcTransferFrame class. * @brief This file defines the TcTransferFrame class.
* @date 27.04.2013 * @date 27.04.2013
* @author baetz * @author baetz
*/ */
#include "../datalinklayer/TcTransferFrame.h" #include "TcTransferFrame.h"
#include "../serviceinterface/ServiceInterfaceStream.h" #include "../serviceinterface/ServiceInterfaceStream.h"
TcTransferFrame::TcTransferFrame() { TcTransferFrame::TcTransferFrame() {
frame = NULL; frame = NULL;
} }
TcTransferFrame::TcTransferFrame(uint8_t* setData) { TcTransferFrame::TcTransferFrame(uint8_t* setData) {
this->frame = (tc_transfer_frame*)setData; this->frame = (tc_transfer_frame*)setData;
} }
uint8_t TcTransferFrame::getVersionNumber() { uint8_t TcTransferFrame::getVersionNumber() {
return (this->frame->header.flagsAndScid & 0b11000000) >> 6; return (this->frame->header.flagsAndScid & 0b11000000) >> 6;
} }
bool TcTransferFrame::bypassFlagSet() { bool TcTransferFrame::bypassFlagSet() {
return (this->frame->header.flagsAndScid & 0b00100000) != 0; return (this->frame->header.flagsAndScid & 0b00100000) != 0;
} }
bool TcTransferFrame::controlCommandFlagSet() { bool TcTransferFrame::controlCommandFlagSet() {
return (this->frame->header.flagsAndScid & 0b00010000) != 0; return (this->frame->header.flagsAndScid & 0b00010000) != 0;
} }
bool TcTransferFrame::spareIsZero() { bool TcTransferFrame::spareIsZero() {
return ( (this->frame->header.flagsAndScid & 0b00001100) == 0 ); return ( (this->frame->header.flagsAndScid & 0b00001100) == 0 );
} }
uint16_t TcTransferFrame::getSpacecraftId() { uint16_t TcTransferFrame::getSpacecraftId() {
return ( (this->frame->header.flagsAndScid & 0b00000011) << 8 ) + this->frame->header.spacecraftId_l; return ( (this->frame->header.flagsAndScid & 0b00000011) << 8 ) + this->frame->header.spacecraftId_l;
} }
uint8_t TcTransferFrame::getVirtualChannelId() { uint8_t TcTransferFrame::getVirtualChannelId() {
return (this->frame->header.vcidAndLength_h & 0b11111100) >> 2; return (this->frame->header.vcidAndLength_h & 0b11111100) >> 2;
} }
uint16_t TcTransferFrame::getFrameLength() { uint16_t TcTransferFrame::getFrameLength() {
return ( (this->frame->header.vcidAndLength_h & 0b00000011) << 8 ) + this->frame->header.length_l; return ( (this->frame->header.vcidAndLength_h & 0b00000011) << 8 ) + this->frame->header.length_l;
} }
uint16_t TcTransferFrame::getDataLength() { uint16_t TcTransferFrame::getDataLength() {
return this->getFrameLength() - this->getHeaderSize() -1 - FRAME_CRC_SIZE + 1; // -1 for the segment header. return this->getFrameLength() - this->getHeaderSize() -1 - FRAME_CRC_SIZE + 1; // -1 for the segment header.
} }
uint8_t TcTransferFrame::getSequenceNumber() { uint8_t TcTransferFrame::getSequenceNumber() {
return this->frame->header.sequenceNumber; return this->frame->header.sequenceNumber;
} }
uint8_t TcTransferFrame::getSequenceFlags() { uint8_t TcTransferFrame::getSequenceFlags() {
return (this->frame->dataField & 0b11000000)>>6; return (this->frame->dataField & 0b11000000)>>6;
} }
uint8_t TcTransferFrame::getMAPId() { uint8_t TcTransferFrame::getMAPId() {
return this->frame->dataField & 0b00111111; return this->frame->dataField & 0b00111111;
} }
uint8_t* TcTransferFrame::getDataField() { uint8_t* TcTransferFrame::getDataField() {
return &(this->frame->dataField) + 1; return &(this->frame->dataField) + 1;
} }
uint8_t* TcTransferFrame::getFullFrame() { uint8_t* TcTransferFrame::getFullFrame() {
return (uint8_t*)this->frame; return (uint8_t*)this->frame;
} }
uint16_t TcTransferFrame::getFullSize() { uint16_t TcTransferFrame::getFullSize() {
return this->getFrameLength() + 1; return this->getFrameLength() + 1;
} }
uint16_t TcTransferFrame::getHeaderSize() { uint16_t TcTransferFrame::getHeaderSize() {
return sizeof(frame->header); return sizeof(frame->header);
} }
uint16_t TcTransferFrame::getFullDataLength() { uint16_t TcTransferFrame::getFullDataLength() {
return this->getFrameLength() - this->getHeaderSize() - FRAME_CRC_SIZE + 1; return this->getFrameLength() - this->getHeaderSize() - FRAME_CRC_SIZE + 1;
} }
uint8_t* TcTransferFrame::getFullDataField() { uint8_t* TcTransferFrame::getFullDataField() {
return &frame->dataField; return &frame->dataField;
} }
void TcTransferFrame::print() { void TcTransferFrame::print() {
sif::debug << "Raw Frame: " << std::hex << std::endl; sif::debug << "Raw Frame: " << std::hex << std::endl;
for (uint16_t count = 0; count < this->getFullSize(); count++ ) { for (uint16_t count = 0; count < this->getFullSize(); count++ ) {
sif::debug << (uint16_t)this->getFullFrame()[count] << " "; sif::debug << (uint16_t)this->getFullFrame()[count] << " ";
} }
sif::debug << std::dec << std::endl; sif::debug << std::dec << std::endl;
// debug << "Frame Header:" << std::endl; // debug << "Frame Header:" << std::endl;
// debug << "Version Number: " << std::hex << (uint16_t)this->current_frame.getVersionNumber() << std::endl; // debug << "Version Number: " << std::hex << (uint16_t)this->current_frame.getVersionNumber() << std::endl;
// debug << "Bypass Flag set?| Ctrl Cmd Flag set?: " << (uint16_t)this->current_frame.bypassFlagSet() << " | " << (uint16_t)this->current_frame.controlCommandFlagSet() << std::endl; // debug << "Bypass Flag set?| Ctrl Cmd Flag set?: " << (uint16_t)this->current_frame.bypassFlagSet() << " | " << (uint16_t)this->current_frame.controlCommandFlagSet() << std::endl;
// debug << "SCID : " << this->current_frame.getSpacecraftId() << std::endl; // debug << "SCID : " << this->current_frame.getSpacecraftId() << std::endl;
// debug << "VCID : " << (uint16_t)this->current_frame.getVirtualChannelId() << std::endl; // debug << "VCID : " << (uint16_t)this->current_frame.getVirtualChannelId() << std::endl;
// debug << "Frame length: " << std::dec << this->current_frame.getFrameLength() << std::endl; // debug << "Frame length: " << std::dec << this->current_frame.getFrameLength() << std::endl;
// debug << "Sequence Number: " << (uint16_t)this->current_frame.getSequenceNumber() << std::endl; // debug << "Sequence Number: " << (uint16_t)this->current_frame.getSequenceNumber() << std::endl;
} }

View File

@ -1,49 +1,49 @@
/** /**
* @file TcTransferFrameLocal.cpp * @file TcTransferFrameLocal.cpp
* @brief This file defines the TcTransferFrameLocal class. * @brief This file defines the TcTransferFrameLocal class.
* @date 27.04.2013 * @date 27.04.2013
* @author baetz * @author baetz
*/ */
#include "../datalinklayer/TcTransferFrameLocal.h" #include "TcTransferFrameLocal.h"
#include "../globalfunctions/CRC.h" #include "../globalfunctions/CRC.h"
#include "../serviceinterface/ServiceInterfaceStream.h" #include "../serviceinterface/ServiceInterfaceStream.h"
#include <string.h> #include <string.h>
TcTransferFrameLocal::TcTransferFrameLocal(bool bypass, bool controlCommand, uint16_t scid, TcTransferFrameLocal::TcTransferFrameLocal(bool bypass, bool controlCommand, uint16_t scid,
uint8_t vcId, uint8_t sequenceNumber, uint8_t setSegmentHeader, uint8_t* data, uint16_t dataSize, uint16_t forceCrc) { uint8_t vcId, uint8_t sequenceNumber, uint8_t setSegmentHeader, uint8_t* data, uint16_t dataSize, uint16_t forceCrc) {
this->frame = (tc_transfer_frame*)&localData; this->frame = (tc_transfer_frame*)&localData;
frame->header.flagsAndScid = (bypass << 5) + (controlCommand << 4) + ((scid & 0x0300) >> 8); frame->header.flagsAndScid = (bypass << 5) + (controlCommand << 4) + ((scid & 0x0300) >> 8);
frame->header.spacecraftId_l = (scid & 0x00FF); frame->header.spacecraftId_l = (scid & 0x00FF);
frame->header.vcidAndLength_h = (vcId & 0b00111111) << 2; frame->header.vcidAndLength_h = (vcId & 0b00111111) << 2;
frame->header.length_l = sizeof(TcTransferFramePrimaryHeader) -1; frame->header.length_l = sizeof(TcTransferFramePrimaryHeader) -1;
frame->header.sequenceNumber = sequenceNumber; frame->header.sequenceNumber = sequenceNumber;
frame->dataField = setSegmentHeader; frame->dataField = setSegmentHeader;
if (data != NULL) { if (data != NULL) {
if (bypass && controlCommand) { if (bypass && controlCommand) {
memcpy(&(frame->dataField), data, dataSize); memcpy(&(frame->dataField), data, dataSize);
uint16_t totalSize = sizeof(TcTransferFramePrimaryHeader) + dataSize + FRAME_CRC_SIZE -1; uint16_t totalSize = sizeof(TcTransferFramePrimaryHeader) + dataSize + FRAME_CRC_SIZE -1;
frame->header.vcidAndLength_h |= (totalSize & 0x0300) >> 8; frame->header.vcidAndLength_h |= (totalSize & 0x0300) >> 8;
frame->header.length_l = (totalSize & 0x00FF); frame->header.length_l = (totalSize & 0x00FF);
uint16_t crc = CRC::crc16ccitt(getFullFrame(), getFullSize() -2); uint16_t crc = CRC::crc16ccitt(getFullFrame(), getFullSize() -2);
this->getFullFrame()[getFullSize()-2] = (crc & 0xFF00) >> 8; this->getFullFrame()[getFullSize()-2] = (crc & 0xFF00) >> 8;
this->getFullFrame()[getFullSize()-1] = (crc & 0x00FF); this->getFullFrame()[getFullSize()-1] = (crc & 0x00FF);
} else if (dataSize <= 1016) { } else if (dataSize <= 1016) {
memcpy(&(frame->dataField) +1, data, dataSize); memcpy(&(frame->dataField) +1, data, dataSize);
uint16_t dataCrcSize = sizeof(TcTransferFramePrimaryHeader) + 1 + dataSize + FRAME_CRC_SIZE -1; uint16_t dataCrcSize = sizeof(TcTransferFramePrimaryHeader) + 1 + dataSize + FRAME_CRC_SIZE -1;
frame->header.vcidAndLength_h |= (dataCrcSize & 0x0300) >> 8; frame->header.vcidAndLength_h |= (dataCrcSize & 0x0300) >> 8;
frame->header.length_l = (dataCrcSize & 0x00FF); frame->header.length_l = (dataCrcSize & 0x00FF);
uint16_t crc = CRC::crc16ccitt(getFullFrame(), getFullSize() -2); uint16_t crc = CRC::crc16ccitt(getFullFrame(), getFullSize() -2);
this->getFullFrame()[getFullSize()-2] = (crc & 0xFF00) >> 8; this->getFullFrame()[getFullSize()-2] = (crc & 0xFF00) >> 8;
this->getFullFrame()[getFullSize()-1] = (crc & 0x00FF); this->getFullFrame()[getFullSize()-1] = (crc & 0x00FF);
} else { } else {
sif::debug << "TcTransferFrameLocal: dataSize too large: " << dataSize << std::endl; sif::debug << "TcTransferFrameLocal: dataSize too large: " << dataSize << std::endl;
} }
} else { } else {
//No data in frame //No data in frame
} }
if (forceCrc != 0 ) { if (forceCrc != 0 ) {
localData.data[getFullSize()-2] = (forceCrc & 0xFF00) >> 8; localData.data[getFullSize()-2] = (forceCrc & 0xFF00) >> 8;
localData.data[getFullSize()-1] = (forceCrc & 0x00FF); localData.data[getFullSize()-1] = (forceCrc & 0x00FF);
} }
} }

View File

@ -1,49 +1,49 @@
/** /**
* @file TcTransferFrameLocal.h * @file TcTransferFrameLocal.h
* @brief This file defines the TcTransferFrameLocal class. * @brief This file defines the TcTransferFrameLocal class.
* @date 27.04.2013 * @date 27.04.2013
* @author baetz * @author baetz
*/ */
#ifndef TCTRANSFERFRAMELOCAL_H_ #ifndef TCTRANSFERFRAMELOCAL_H_
#define TCTRANSFERFRAMELOCAL_H_ #define TCTRANSFERFRAMELOCAL_H_
#include "../datalinklayer/TcTransferFrame.h" #include "TcTransferFrame.h"
/** /**
* This is a helper class to locally create TC Transfer Frames. * This is a helper class to locally create TC Transfer Frames.
* This is mainly required for testing purposes and therefore not very sophisticated. * This is mainly required for testing purposes and therefore not very sophisticated.
* @ingroup ccsds_handling * @ingroup ccsds_handling
*/ */
class TcTransferFrameLocal : public TcTransferFrame { class TcTransferFrameLocal : public TcTransferFrame {
private: private:
/** /**
* A stuct to locally store the complete data. * A stuct to locally store the complete data.
*/ */
struct frameData { struct frameData {
TcTransferFramePrimaryHeader header; //!< The primary header. TcTransferFramePrimaryHeader header; //!< The primary header.
uint8_t data[1019]; //!< The data field. uint8_t data[1019]; //!< The data field.
}; };
public: public:
frameData localData; //!< The local data in the Frame. frameData localData; //!< The local data in the Frame.
/** /**
* The default Constructor. * The default Constructor.
* All parameters in the Header are passed. * All parameters in the Header are passed.
* If a BC Frame is detected no segment header is created. * If a BC Frame is detected no segment header is created.
* Otherwise (AD and BD), the Segment Header is set. * Otherwise (AD and BD), the Segment Header is set.
* @param bypass The bypass flag. * @param bypass The bypass flag.
* @param controlCommand The Control Command flag. * @param controlCommand The Control Command flag.
* @param scid The SCID. * @param scid The SCID.
* @param vcId The VCID. * @param vcId The VCID.
* @param sequenceNumber The Frame Sequence Number N(s) * @param sequenceNumber The Frame Sequence Number N(s)
* @param setSegmentHeader A value for the Segment Header. * @param setSegmentHeader A value for the Segment Header.
* @param data Data to put into the Frame Data Field. * @param data Data to put into the Frame Data Field.
* @param dataSize Size of the Data. * @param dataSize Size of the Data.
* @param forceCrc if != 0, the value is used as CRC. * @param forceCrc if != 0, the value is used as CRC.
*/ */
TcTransferFrameLocal(bool bypass, bool controlCommand, uint16_t scid, uint8_t vcId, uint8_t sequenceNumber, TcTransferFrameLocal(bool bypass, bool controlCommand, uint16_t scid, uint8_t vcId, uint8_t sequenceNumber,
uint8_t setSegmentHeader = 0xC0, uint8_t* data = NULL, uint16_t dataSize = 0, uint16_t forceCrc = 0); uint8_t setSegmentHeader = 0xC0, uint8_t* data = NULL, uint16_t dataSize = 0, uint16_t forceCrc = 0);
}; };
#endif /* TCTRANSFERFRAMELOCAL_H_ */ #endif /* TCTRANSFERFRAMELOCAL_H_ */

View File

@ -1,121 +1,121 @@
/** /**
* @file VirtualChannelReception.cpp * @file VirtualChannelReception.cpp
* @brief This file defines the VirtualChannelReception class. * @brief This file defines the VirtualChannelReception class.
* @date 26.03.2013 * @date 26.03.2013
* @author baetz * @author baetz
*/ */
#include "../datalinklayer/BCFrame.h" #include "BCFrame.h"
#include "../datalinklayer/VirtualChannelReception.h" #include "VirtualChannelReception.h"
#include "../serviceinterface/ServiceInterfaceStream.h" #include "../serviceinterface/ServiceInterfaceStream.h"
VirtualChannelReception::VirtualChannelReception(uint8_t setChannelId, VirtualChannelReception::VirtualChannelReception(uint8_t setChannelId,
uint8_t setSlidingWindowWidth) : uint8_t setSlidingWindowWidth) :
channelId(setChannelId), slidingWindowWidth(setSlidingWindowWidth), positiveWindow( channelId(setChannelId), slidingWindowWidth(setSlidingWindowWidth), positiveWindow(
setSlidingWindowWidth / 2), negativeWindow(setSlidingWindowWidth / 2), currentState( setSlidingWindowWidth / 2), negativeWindow(setSlidingWindowWidth / 2), currentState(
&openState), openState(this), waitState(this), lockoutState(this), vR(0), farmBCounter( &openState), openState(this), waitState(this), lockoutState(this), vR(0), farmBCounter(
0) { 0) {
internalClcw.setVirtualChannel(channelId); internalClcw.setVirtualChannel(channelId);
} }
ReturnValue_t VirtualChannelReception::mapDemultiplexing(TcTransferFrame* frame) { ReturnValue_t VirtualChannelReception::mapDemultiplexing(TcTransferFrame* frame) {
uint8_t mapId = frame->getMAPId(); uint8_t mapId = frame->getMAPId();
mapChannelIterator iter = mapChannels.find(mapId); mapChannelIterator iter = mapChannels.find(mapId);
if (iter == mapChannels.end()) { if (iter == mapChannels.end()) {
// error << "VirtualChannelReception::mapDemultiplexing on VC " << std::hex << (int) channelId // error << "VirtualChannelReception::mapDemultiplexing on VC " << std::hex << (int) channelId
// << ": MapChannel " << (int) mapId << std::dec << " not found." << std::endl; // << ": MapChannel " << (int) mapId << std::dec << " not found." << std::endl;
return VC_NOT_FOUND; return VC_NOT_FOUND;
} else { } else {
return (iter->second)->extractPackets(frame); return (iter->second)->extractPackets(frame);
} }
} }
ReturnValue_t VirtualChannelReception::doFARM(TcTransferFrame* frame, ClcwIF* clcw) { ReturnValue_t VirtualChannelReception::doFARM(TcTransferFrame* frame, ClcwIF* clcw) {
uint8_t bypass = frame->bypassFlagSet(); uint8_t bypass = frame->bypassFlagSet();
uint8_t controlCommand = frame->controlCommandFlagSet(); uint8_t controlCommand = frame->controlCommandFlagSet();
uint8_t typeValue = (bypass << 1) + controlCommand; uint8_t typeValue = (bypass << 1) + controlCommand;
switch (typeValue) { switch (typeValue) {
case AD_FRAME: case AD_FRAME:
return currentState->handleADFrame(frame, clcw); return currentState->handleADFrame(frame, clcw);
case BD_FRAME: case BD_FRAME:
return handleBDFrame(frame, clcw); return handleBDFrame(frame, clcw);
case BC_FRAME: case BC_FRAME:
return handleBCFrame(frame, clcw); return handleBCFrame(frame, clcw);
default: default:
return ILLEGAL_FLAG_COMBINATION; return ILLEGAL_FLAG_COMBINATION;
} }
} }
ReturnValue_t VirtualChannelReception::frameAcceptanceAndReportingMechanism(TcTransferFrame* frame, ReturnValue_t VirtualChannelReception::frameAcceptanceAndReportingMechanism(TcTransferFrame* frame,
ClcwIF* clcw) { ClcwIF* clcw) {
ReturnValue_t result = RETURN_OK; ReturnValue_t result = RETURN_OK;
result = doFARM(frame, &internalClcw); result = doFARM(frame, &internalClcw);
internalClcw.setReceiverFrameSequenceNumber(vR); internalClcw.setReceiverFrameSequenceNumber(vR);
internalClcw.setFarmBCount(farmBCounter); internalClcw.setFarmBCount(farmBCounter);
clcw->setWhole(internalClcw.getAsWhole()); clcw->setWhole(internalClcw.getAsWhole());
switch (result) { switch (result) {
case RETURN_OK: case RETURN_OK:
return mapDemultiplexing(frame); return mapDemultiplexing(frame);
case BC_IS_SET_VR_COMMAND: case BC_IS_SET_VR_COMMAND:
case BC_IS_UNLOCK_COMMAND: case BC_IS_UNLOCK_COMMAND:
//Need to catch these codes to avoid error reporting later. //Need to catch these codes to avoid error reporting later.
return RETURN_OK; return RETURN_OK;
default: default:
break; break;
} }
return result; return result;
} }
ReturnValue_t VirtualChannelReception::addMapChannel(uint8_t mapId, MapPacketExtractionIF* object) { ReturnValue_t VirtualChannelReception::addMapChannel(uint8_t mapId, MapPacketExtractionIF* object) {
std::pair<mapChannelIterator, bool> returnValue = mapChannels.insert( std::pair<mapChannelIterator, bool> returnValue = mapChannels.insert(
std::pair<uint8_t, MapPacketExtractionIF*>(mapId, object)); std::pair<uint8_t, MapPacketExtractionIF*>(mapId, object));
if (returnValue.second == true) { if (returnValue.second == true) {
return RETURN_OK; return RETURN_OK;
} else { } else {
return RETURN_FAILED; return RETURN_FAILED;
} }
} }
ReturnValue_t VirtualChannelReception::handleBDFrame(TcTransferFrame* frame, ClcwIF* clcw) { ReturnValue_t VirtualChannelReception::handleBDFrame(TcTransferFrame* frame, ClcwIF* clcw) {
farmBCounter++; farmBCounter++;
return RETURN_OK; return RETURN_OK;
} }
ReturnValue_t VirtualChannelReception::handleBCFrame(TcTransferFrame* frame, ClcwIF* clcw) { ReturnValue_t VirtualChannelReception::handleBCFrame(TcTransferFrame* frame, ClcwIF* clcw) {
BcFrame content; BcFrame content;
ReturnValue_t returnValue = content.initialize(frame->getFullDataField(), ReturnValue_t returnValue = content.initialize(frame->getFullDataField(),
frame->getFullDataLength()); frame->getFullDataLength());
if (returnValue == BC_IS_UNLOCK_COMMAND) { if (returnValue == BC_IS_UNLOCK_COMMAND) {
returnValue = currentState->handleBCUnlockCommand(clcw); returnValue = currentState->handleBCUnlockCommand(clcw);
} else if (returnValue == BC_IS_SET_VR_COMMAND) { } else if (returnValue == BC_IS_SET_VR_COMMAND) {
returnValue = currentState->handleBCSetVrCommand(clcw, content.vR); returnValue = currentState->handleBCSetVrCommand(clcw, content.vR);
} else { } else {
//Do nothing //Do nothing
} }
return returnValue; return returnValue;
} }
uint8_t VirtualChannelReception::getChannelId() const { uint8_t VirtualChannelReception::getChannelId() const {
return channelId; return channelId;
} }
ReturnValue_t VirtualChannelReception::initialize() { ReturnValue_t VirtualChannelReception::initialize() {
ReturnValue_t returnValue = RETURN_FAILED; ReturnValue_t returnValue = RETURN_FAILED;
if ((slidingWindowWidth > 254) || (slidingWindowWidth % 2 != 0)) { if ((slidingWindowWidth > 254) || (slidingWindowWidth % 2 != 0)) {
sif::error << "VirtualChannelReception::initialize: Illegal sliding window width: " sif::error << "VirtualChannelReception::initialize: Illegal sliding window width: "
<< (int) slidingWindowWidth << std::endl; << (int) slidingWindowWidth << std::endl;
return RETURN_FAILED; return RETURN_FAILED;
} }
for (mapChannelIterator iterator = mapChannels.begin(); iterator != mapChannels.end(); for (mapChannelIterator iterator = mapChannels.begin(); iterator != mapChannels.end();
iterator++) { iterator++) {
returnValue = iterator->second->initialize(); returnValue = iterator->second->initialize();
if (returnValue != RETURN_OK) if (returnValue != RETURN_OK)
break; break;
} }
return returnValue; return returnValue;
} }
void VirtualChannelReception::setToWaitState() { void VirtualChannelReception::setToWaitState() {
internalClcw.setWaitFlag(true); internalClcw.setWaitFlag(true);
this->currentState = &waitState; this->currentState = &waitState;
} }

View File

@ -1,114 +1,114 @@
/** /**
* @file VirtualChannelReception.h * @file VirtualChannelReception.h
* @brief This file defines the VirtualChannelReception class. * @brief This file defines the VirtualChannelReception class.
* @date 25.03.2013 * @date 25.03.2013
* @author baetz * @author baetz
*/ */
#ifndef VIRTUALCHANNELRECEPTION_H_ #ifndef VIRTUALCHANNELRECEPTION_H_
#define VIRTUALCHANNELRECEPTION_H_ #define VIRTUALCHANNELRECEPTION_H_
#include "../datalinklayer/CCSDSReturnValuesIF.h" #include "CCSDSReturnValuesIF.h"
#include "../datalinklayer/Clcw.h" #include "Clcw.h"
#include "../datalinklayer/Farm1StateIF.h" #include "Farm1StateIF.h"
#include "../datalinklayer/Farm1StateLockout.h" #include "Farm1StateLockout.h"
#include "../datalinklayer/Farm1StateOpen.h" #include "Farm1StateOpen.h"
#include "../datalinklayer/Farm1StateWait.h" #include "Farm1StateWait.h"
#include "../datalinklayer/MapPacketExtractionIF.h" #include "MapPacketExtractionIF.h"
#include "../datalinklayer/VirtualChannelReceptionIF.h" #include "VirtualChannelReceptionIF.h"
#include <map> #include <map>
/** /**
* Implementation of a TC Virtual Channel. * Implementation of a TC Virtual Channel.
* This is a full implementation of a virtual channel as specified in the CCSDS TC Space Data Link * This is a full implementation of a virtual channel as specified in the CCSDS TC Space Data Link
* Protocol. It is designed to operate within an instance of the @c DataLinkLayer class. * Protocol. It is designed to operate within an instance of the @c DataLinkLayer class.
* Features: * Features:
* - any (6bit) Virtual Channel ID is assignable. * - any (6bit) Virtual Channel ID is assignable.
* - Supports an arbitrary number of MAP Channels (with a map). * - Supports an arbitrary number of MAP Channels (with a map).
* - Has a complete FARM-1 Machine built-in. * - Has a complete FARM-1 Machine built-in.
* *
* The FARM-1 state machine uses the State Pattern. * The FARM-1 state machine uses the State Pattern.
*/ */
class VirtualChannelReception : public VirtualChannelReceptionIF, public CCSDSReturnValuesIF { class VirtualChannelReception : public VirtualChannelReceptionIF, public CCSDSReturnValuesIF {
friend class Farm1StateOpen; friend class Farm1StateOpen;
friend class Farm1StateWait; friend class Farm1StateWait;
friend class Farm1StateLockout; friend class Farm1StateLockout;
private: private:
uint8_t channelId; //!< Stores the VCID that was assigned on construction. uint8_t channelId; //!< Stores the VCID that was assigned on construction.
uint8_t slidingWindowWidth; //!< A constant to set the FARM-1 sliding window width. uint8_t slidingWindowWidth; //!< A constant to set the FARM-1 sliding window width.
uint8_t positiveWindow; //!< The positive window for the FARM-1 machine. uint8_t positiveWindow; //!< The positive window for the FARM-1 machine.
uint8_t negativeWindow; //!< The negative window for the FARM-1 machine. uint8_t negativeWindow; //!< The negative window for the FARM-1 machine.
protected: protected:
Farm1StateIF* currentState; //!< The current state. To change, one of the other states must be assigned to this pointer. Farm1StateIF* currentState; //!< The current state. To change, one of the other states must be assigned to this pointer.
Farm1StateOpen openState; //!< Instance of the FARM-1 State "Open". Farm1StateOpen openState; //!< Instance of the FARM-1 State "Open".
Farm1StateWait waitState; //!< Instance of the FARM-1 State "Wait". Farm1StateWait waitState; //!< Instance of the FARM-1 State "Wait".
Farm1StateLockout lockoutState; //!< Instance of the FARM-1 State "Lockout". Farm1StateLockout lockoutState; //!< Instance of the FARM-1 State "Lockout".
Clcw internalClcw; //!< A CLCW class to internally set the values before writing them back to the TTC System. Clcw internalClcw; //!< A CLCW class to internally set the values before writing them back to the TTC System.
uint8_t vR; //!< The Receiver Frame Sequence Number V(R) as it shall be maintained for every Virtual Channel. uint8_t vR; //!< The Receiver Frame Sequence Number V(R) as it shall be maintained for every Virtual Channel.
uint8_t farmBCounter; //!< The FARM-B COunter as it shall be maintained for every Virtual Channel. uint8_t farmBCounter; //!< The FARM-B COunter as it shall be maintained for every Virtual Channel.
typedef std::map<uint8_t, MapPacketExtractionIF*>::iterator mapChannelIterator; //!< Typedef to simplify handling of the mapChannels map. typedef std::map<uint8_t, MapPacketExtractionIF*>::iterator mapChannelIterator; //!< Typedef to simplify handling of the mapChannels map.
std::map<uint8_t, MapPacketExtractionIF*> mapChannels; //!< A map that maintains all map Channels. Channels must be configured on initialization. MAy be omitted in a simplified version. std::map<uint8_t, MapPacketExtractionIF*> mapChannels; //!< A map that maintains all map Channels. Channels must be configured on initialization. MAy be omitted in a simplified version.
/** /**
* This method handles demultiplexing to different map channels. * This method handles demultiplexing to different map channels.
* It parses the entries of #mapChannels and forwards the Frame to a found MAP Channel. * It parses the entries of #mapChannels and forwards the Frame to a found MAP Channel.
* @param frame The frame to forward. * @param frame The frame to forward.
* @return #VC_NOT_FOUND or the return value of the map channel extraction. * @return #VC_NOT_FOUND or the return value of the map channel extraction.
*/ */
ReturnValue_t mapDemultiplexing( TcTransferFrame* frame ); ReturnValue_t mapDemultiplexing( TcTransferFrame* frame );
/** /**
* A sub-method that actually does the FARM-1 handling for different Frame types. * A sub-method that actually does the FARM-1 handling for different Frame types.
* @param frame The Tc Transfer Frame to handle. * @param frame The Tc Transfer Frame to handle.
* @param clcw Any changes on the CLCW shall be done with this method. * @param clcw Any changes on the CLCW shall be done with this method.
* @return The return code of higher methods or @c ILLEGAL_FLAG_COMBINATION. * @return The return code of higher methods or @c ILLEGAL_FLAG_COMBINATION.
*/ */
ReturnValue_t doFARM(TcTransferFrame* frame, ClcwIF* clcw); ReturnValue_t doFARM(TcTransferFrame* frame, ClcwIF* clcw);
/** /**
* Handles incoming BD Frames. * Handles incoming BD Frames.
* Handling these Frames is independent of the State, so no subcall to #currentState is * Handling these Frames is independent of the State, so no subcall to #currentState is
* required. * required.
* @param frame The Tc Transfer Frame to handle. * @param frame The Tc Transfer Frame to handle.
* @param clcw Any changes on the CLCW shall be done with this method. * @param clcw Any changes on the CLCW shall be done with this method.
* @return Always returns @c RETURN_OK. * @return Always returns @c RETURN_OK.
*/ */
ReturnValue_t handleBDFrame( TcTransferFrame* frame, ClcwIF* clcw ); ReturnValue_t handleBDFrame( TcTransferFrame* frame, ClcwIF* clcw );
/** /**
* Handles incoming BC Frames. * Handles incoming BC Frames.
* The type of the BC Frame is detected and checked first, then methods of #currentState are called. * The type of the BC Frame is detected and checked first, then methods of #currentState are called.
* @param frame The Tc Transfer Frame to handle. * @param frame The Tc Transfer Frame to handle.
* @param clcw Any changes on the CLCW shall be done with this method. * @param clcw Any changes on the CLCW shall be done with this method.
* @return The failure code of BC Frame interpretation or the return code of higher methods. * @return The failure code of BC Frame interpretation or the return code of higher methods.
*/ */
ReturnValue_t handleBCFrame( TcTransferFrame* frame, ClcwIF* clcw ); ReturnValue_t handleBCFrame( TcTransferFrame* frame, ClcwIF* clcw );
public: public:
/** /**
* Default constructor. * Default constructor.
* Only sets the channelId of the channel. Setting the Sliding Window width is possible as well. * Only sets the channelId of the channel. Setting the Sliding Window width is possible as well.
* @param setChannelId Virtual Channel Identifier (VCID) of the channel. * @param setChannelId Virtual Channel Identifier (VCID) of the channel.
*/ */
VirtualChannelReception( uint8_t setChannelId, uint8_t setSlidingWindowWidth ); VirtualChannelReception( uint8_t setChannelId, uint8_t setSlidingWindowWidth );
ReturnValue_t frameAcceptanceAndReportingMechanism( TcTransferFrame* frame, ClcwIF* clcw ); ReturnValue_t frameAcceptanceAndReportingMechanism( TcTransferFrame* frame, ClcwIF* clcw );
/** /**
* Helper method to simplify adding a mapChannel during construction. * Helper method to simplify adding a mapChannel during construction.
* @param mapId The mapId of the object to add. * @param mapId The mapId of the object to add.
* @param object Pointer to the MapPacketExtraction object itself. * @param object Pointer to the MapPacketExtraction object itself.
* @return @c RETURN_OK if the channel was successfully inserted, @c RETURN_FAILED otherwise. * @return @c RETURN_OK if the channel was successfully inserted, @c RETURN_FAILED otherwise.
*/ */
ReturnValue_t addMapChannel( uint8_t mapId, MapPacketExtractionIF* object ); ReturnValue_t addMapChannel( uint8_t mapId, MapPacketExtractionIF* object );
/** /**
* The initialization routine checks the set #slidingWindowWidth and initializes all MAP * The initialization routine checks the set #slidingWindowWidth and initializes all MAP
* channels. * channels.
* @return @c RETURN_OK on successful initialization, @c RETURN_FAILED otherwise. * @return @c RETURN_OK on successful initialization, @c RETURN_FAILED otherwise.
*/ */
ReturnValue_t initialize(); ReturnValue_t initialize();
/** /**
* Getter for the VCID. * Getter for the VCID.
* @return The #channelId. * @return The #channelId.
*/ */
uint8_t getChannelId() const; uint8_t getChannelId() const;
/** /**
* Small method to set the state to Farm1StateWait. * Small method to set the state to Farm1StateWait.
*/ */
void setToWaitState(); void setToWaitState();
}; };
#endif /* VIRTUALCHANNELRECEPTION_H_ */ #endif /* VIRTUALCHANNELRECEPTION_H_ */

View File

@ -1,57 +1,57 @@
/** /**
* @file VirtualChannelReceptionIF.h * @file VirtualChannelReceptionIF.h
* @brief This file defines the VirtualChannelReceptionIF class. * @brief This file defines the VirtualChannelReceptionIF class.
* @date 25.03.2013 * @date 25.03.2013
* @author baetz * @author baetz
*/ */
#ifndef VIRTUALCHANNELRECEPTIONIF_H_ #ifndef VIRTUALCHANNELRECEPTIONIF_H_
#define VIRTUALCHANNELRECEPTIONIF_H_ #define VIRTUALCHANNELRECEPTIONIF_H_
#include "../datalinklayer/ClcwIF.h" #include "ClcwIF.h"
#include "../datalinklayer/TcTransferFrame.h" #include "TcTransferFrame.h"
#include "../returnvalues/HasReturnvaluesIF.h" #include "../returnvalues/HasReturnvaluesIF.h"
/** /**
* This is the interface for Virtual Channel reception classes. * This is the interface for Virtual Channel reception classes.
* It represents a single TC Virtual Channel that operates on one IO * It represents a single TC Virtual Channel that operates on one IO
*/ */
class VirtualChannelReceptionIF { class VirtualChannelReceptionIF {
public: public:
/** /**
* Enum including all valid types of frames. * Enum including all valid types of frames.
* The type is made up by two flags, so 0b1111 is definitely illegal. * The type is made up by two flags, so 0b1111 is definitely illegal.
*/ */
enum frameType { enum frameType {
AD_FRAME = 0b00, AD_FRAME = 0b00,
BC_FRAME = 0b11, BC_FRAME = 0b11,
BD_FRAME = 0b10, BD_FRAME = 0b10,
ILLEGAL_FRAME = 0b1111 ILLEGAL_FRAME = 0b1111
}; };
/** /**
* Empty virtual destructor. * Empty virtual destructor.
*/ */
virtual ~VirtualChannelReceptionIF() { virtual ~VirtualChannelReceptionIF() {
} }
/** /**
* This method shall accept frames and do all FARM-1 stuff. * This method shall accept frames and do all FARM-1 stuff.
* Handling the Frame includes forwarding to higher-level procedures. * Handling the Frame includes forwarding to higher-level procedures.
* @param frame The Tc Transfer Frame that was received and checked. * @param frame The Tc Transfer Frame that was received and checked.
* @param clcw Any changes to the CLCW value are forwarded by using this parameter. * @param clcw Any changes to the CLCW value are forwarded by using this parameter.
* @return The return Value shall indicate successful processing with @c RETURN_OK. * @return The return Value shall indicate successful processing with @c RETURN_OK.
*/ */
virtual ReturnValue_t frameAcceptanceAndReportingMechanism( TcTransferFrame* frame, ClcwIF* clcw ) = 0; virtual ReturnValue_t frameAcceptanceAndReportingMechanism( TcTransferFrame* frame, ClcwIF* clcw ) = 0;
/** /**
* If any other System Objects are required for operation they shall be initialized here. * If any other System Objects are required for operation they shall be initialized here.
* @return @c RETURN_OK for successful initialization. * @return @c RETURN_OK for successful initialization.
*/ */
virtual ReturnValue_t initialize() = 0; virtual ReturnValue_t initialize() = 0;
/** /**
* Getter for the VCID. * Getter for the VCID.
* @return The #channelId. * @return The #channelId.
*/ */
virtual uint8_t getChannelId() const = 0; virtual uint8_t getChannelId() const = 0;
}; };
#endif /* VIRTUALCHANNELRECEPTIONIF_H_ */ #endif /* VIRTUALCHANNELRECEPTIONIF_H_ */