updating code from Flying Laptop
This is the framework of Flying Laptop OBSW version A.13.0.
This commit is contained in:
@ -15,8 +15,7 @@
|
||||
*/
|
||||
class CCSDSReturnValuesIF: public HasReturnvaluesIF {
|
||||
public:
|
||||
static const uint8_t INTERFACE_ID = CCSDS_HANDLER_IF; //!< Basic ID of the interface.
|
||||
static const ReturnValue_t FRAME_OK = RETURN_OK; //!< A value to indicate that a frame is ok.
|
||||
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_UNLOCK_COMMAND = MAKE_RETURN_CODE( 0x02 ); //!< A value to describe a BC frame.
|
||||
|
@ -1,13 +1,5 @@
|
||||
/*
|
||||
* DataLinkLayer.cpp
|
||||
*
|
||||
* Created on: 02.03.2012
|
||||
* Author: baetz
|
||||
*/
|
||||
|
||||
#include <framework/datalinklayer/DataLinkLayer.h>
|
||||
#include <framework/globalfunctions/crc_ccitt.h>
|
||||
#include <framework/osal/OSAL.h>
|
||||
#include <framework/serviceinterface/ServiceInterfaceStream.h>
|
||||
|
||||
DataLinkLayer::DataLinkLayer(uint8_t* set_frame_buffer, ClcwIF* setClcw,
|
||||
@ -25,15 +17,15 @@ ReturnValue_t DataLinkLayer::frameDelimitingAndFillRemoval() {
|
||||
if ((receivedDataLength - startSequenceLength) < FRAME_PRIMARY_HEADER_LENGTH) {
|
||||
return SHORTER_THAN_HEADER;
|
||||
}
|
||||
//Removing start sequence
|
||||
//TODO: What does the start sequence look like? Better search for the pattern.
|
||||
//Removing start sequence.
|
||||
//SHOULDDO: Not implemented here.
|
||||
while ( *frameBuffer == START_SEQUENCE_PATTERN ) {
|
||||
frameBuffer++;
|
||||
}
|
||||
TcTransferFrame frame_candidate(frameBuffer);
|
||||
this->currentFrame = frame_candidate; //should work with shallow copy.
|
||||
|
||||
return FRAME_OK;
|
||||
return RETURN_OK;
|
||||
}
|
||||
|
||||
ReturnValue_t DataLinkLayer::frameValidationCheck() {
|
||||
@ -64,14 +56,14 @@ ReturnValue_t DataLinkLayer::frameValidationCheck() {
|
||||
if (USE_CRC) {
|
||||
return this->frameCheckCRC();
|
||||
}
|
||||
return FRAME_OK;
|
||||
return RETURN_OK;
|
||||
}
|
||||
|
||||
ReturnValue_t DataLinkLayer::frameCheckCRC() {
|
||||
uint16_t checkValue = ::Calculate_CRC(this->currentFrame.getFullFrame(),
|
||||
this->currentFrame.getFullSize());
|
||||
if (checkValue == 0) {
|
||||
return FRAME_OK;
|
||||
return RETURN_OK;
|
||||
} else {
|
||||
return CRC_FAILED;
|
||||
}
|
||||
@ -80,7 +72,7 @@ ReturnValue_t DataLinkLayer::frameCheckCRC() {
|
||||
|
||||
ReturnValue_t DataLinkLayer::allFramesReception() {
|
||||
ReturnValue_t status = this->frameDelimitingAndFillRemoval();
|
||||
if (status != FRAME_OK) {
|
||||
if (status != RETURN_OK) {
|
||||
return status;
|
||||
}
|
||||
return this->frameValidationCheck();
|
||||
@ -96,7 +88,7 @@ ReturnValue_t DataLinkLayer::virtualChannelDemultiplexing() {
|
||||
virtualChannelIterator iter = virtualChannels.find(vcId);
|
||||
if (iter == virtualChannels.end()) {
|
||||
//Do not report because passive board will get this error all the time.
|
||||
return FRAME_OK;
|
||||
return RETURN_OK;
|
||||
} else {
|
||||
return (iter->second)->frameAcceptanceAndReportingMechanism(¤tFrame, clcw);
|
||||
}
|
||||
@ -105,7 +97,7 @@ ReturnValue_t DataLinkLayer::virtualChannelDemultiplexing() {
|
||||
ReturnValue_t DataLinkLayer::processFrame(uint16_t length) {
|
||||
receivedDataLength = length;
|
||||
ReturnValue_t status = allFramesReception();
|
||||
if (status != FRAME_OK) {
|
||||
if (status != RETURN_OK) {
|
||||
error << "DataLinkLayer::processFrame: frame reception failed. Error code: " << std::hex
|
||||
<< status << std::dec << std::endl;
|
||||
// currentFrame.print();
|
||||
|
@ -1,10 +1,3 @@
|
||||
/*
|
||||
* DataLinkLayer.h
|
||||
*
|
||||
* Created on: Feb 29, 2012
|
||||
* Author: baetz
|
||||
*/
|
||||
|
||||
#ifndef DATALINKLAYER_H_
|
||||
#define DATALINKLAYER_H_
|
||||
|
||||
@ -26,11 +19,11 @@ class VirtualChannelReception;
|
||||
class DataLinkLayer : public CCSDSReturnValuesIF {
|
||||
public:
|
||||
static const uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::SYSTEM_1;
|
||||
static const Event RF_AVAILABLE = MAKE_EVENT(0, SEVERITY::INFO); //!< The CCSDS Board detected a RF available signal.
|
||||
static const Event RF_LOST = MAKE_EVENT(1, SEVERITY::INFO); //!< The CCSDS Board lost a previously found RF available signal.
|
||||
static const Event BIT_LOCK = MAKE_EVENT(2, SEVERITY::INFO); //!< The CCSDS Board detected a Bit Lock signal.
|
||||
static const Event BIT_LOCK_LOST = MAKE_EVENT(3, SEVERITY::INFO); //!< The CCSDS Board lost a previously found Bit Lock signal.
|
||||
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.
|
||||
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 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 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
|
||||
/**
|
||||
* The Constructor sets the passed parameters and nothing else.
|
||||
@ -80,19 +73,19 @@ private:
|
||||
std::map<uint8_t, VirtualChannelReceptionIF*> virtualChannels; //!< Map of all virtual channels assigned.
|
||||
/**
|
||||
* Method that performs all possible frame validity checks (as specified).
|
||||
* @return Various error codes or @c FRAME_OK on success.
|
||||
* @return Various error codes or @c RETURN_OK on success.
|
||||
*/
|
||||
ReturnValue_t frameValidationCheck();
|
||||
/**
|
||||
* First method to call.
|
||||
* Removes start sequence bytes and checks if the complete frame was received.
|
||||
* TODO: Maybe handling the start sequence must be done more variable.
|
||||
* @return @c FRAME_OK or @c TOO_SHORT.
|
||||
* SHOULDDO: Maybe handling the start sequence must be done more variable.
|
||||
* @return @c RETURN_OK or @c TOO_SHORT.
|
||||
*/
|
||||
ReturnValue_t frameDelimitingAndFillRemoval();
|
||||
/**
|
||||
* Small helper method to check the CRC of the Frame.
|
||||
* @return @c FRAME_OK or @c CRC_FAILED.
|
||||
* @return @c RETURN_OK or @c CRC_FAILED.
|
||||
*/
|
||||
ReturnValue_t frameCheckCRC();
|
||||
/**
|
||||
|
@ -22,7 +22,7 @@ ReturnValue_t Farm1StateOpen::handleADFrame(TcTransferFrame* frame,
|
||||
if (diff == 0 ) {
|
||||
myVC->vR++;
|
||||
clcw->setRetransmitFlag(false);
|
||||
return FRAME_OK;
|
||||
return RETURN_OK;
|
||||
} else if (diff < myVC->positiveWindow && diff > 0 ) {
|
||||
clcw->setRetransmitFlag(true);
|
||||
return NS_POSITIVE_W;
|
||||
|
@ -35,7 +35,7 @@ public:
|
||||
* change to Farm1StateLockout.
|
||||
* @param frame The frame to handle.
|
||||
* @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 #FRAME_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.
|
||||
*/
|
||||
ReturnValue_t handleADFrame( TcTransferFrame* frame, ClcwIF* clcw );
|
||||
|
@ -6,17 +6,19 @@
|
||||
*/
|
||||
|
||||
#include <framework/datalinklayer/MapPacketExtraction.h>
|
||||
#include <framework/ipc/QueueFactory.h>
|
||||
#include <framework/serviceinterface/ServiceInterfaceStream.h>
|
||||
#include <framework/storagemanager/StorageManagerIF.h>
|
||||
#include <framework/tmtcpacket/SpacePacketBase.h>
|
||||
#include <framework/tmtcservices/AcceptsTelecommandsIF.h>
|
||||
#include <framework/tmtcservices/TmTcMessage.h>
|
||||
#include <string.h>
|
||||
|
||||
MapPacketExtraction::MapPacketExtraction(uint8_t setMapId,
|
||||
object_id_t setPacketDestination) :
|
||||
lastSegmentationFlag(NO_SEGMENTATION), mapId(setMapId), packetLength(0), bufferPosition(
|
||||
packetBuffer), packetDestination(setPacketDestination), packetStore(
|
||||
NULL) {
|
||||
NULL), tcQueueId(MessageQueueSenderIF::NO_QUEUE) {
|
||||
memset(packetBuffer, 0, sizeof(packetBuffer));
|
||||
}
|
||||
|
||||
@ -32,7 +34,7 @@ ReturnValue_t MapPacketExtraction::extractPackets(TcTransferFrame* frame) {
|
||||
if (packetLength <= MAX_PACKET_SIZE) {
|
||||
memcpy(packetBuffer, frame->getDataField(), packetLength);
|
||||
bufferPosition = &packetBuffer[packetLength];
|
||||
status = FRAME_OK;
|
||||
status = RETURN_OK;
|
||||
} else {
|
||||
error
|
||||
<< "MapPacketExtraction::extractPackets. Packet too large! Size: "
|
||||
@ -54,7 +56,7 @@ ReturnValue_t MapPacketExtraction::extractPackets(TcTransferFrame* frame) {
|
||||
status = sendCompletePacket(packetBuffer, packetLength);
|
||||
clearBuffers();
|
||||
}
|
||||
status = FRAME_OK;
|
||||
status = RETURN_OK;
|
||||
} else {
|
||||
error
|
||||
<< "MapPacketExtraction::extractPackets. Packet too large! Size: "
|
||||
@ -97,7 +99,7 @@ ReturnValue_t MapPacketExtraction::unpackBlockingPackets(
|
||||
packet.getFullSize());
|
||||
totalLength -= packet.getFullSize();
|
||||
position += packet.getFullSize();
|
||||
status = FRAME_OK;
|
||||
status = RETURN_OK;
|
||||
} else {
|
||||
status = DATA_CORRUPTED;
|
||||
totalLength = 0;
|
||||
@ -115,7 +117,7 @@ ReturnValue_t MapPacketExtraction::sendCompletePacket(uint8_t* data,
|
||||
ReturnValue_t status = this->packetStore->addData(&store_id, data, size);
|
||||
if (status == RETURN_OK) {
|
||||
TmTcMessage message(store_id);
|
||||
status = this->tcQueue.sendToDefault(&message);
|
||||
status = MessageQueueSenderIF::sendMessage(tcQueueId,&message);
|
||||
}
|
||||
return status;
|
||||
}
|
||||
@ -132,7 +134,7 @@ ReturnValue_t MapPacketExtraction::initialize() {
|
||||
AcceptsTelecommandsIF* distributor = objectManager->get<
|
||||
AcceptsTelecommandsIF>(packetDestination);
|
||||
if ((packetStore != NULL) && (distributor != NULL)) {
|
||||
tcQueue.setDefaultDestination(distributor->getRequestQueue());
|
||||
tcQueueId = distributor->getRequestQueue();
|
||||
return RETURN_OK;
|
||||
} else {
|
||||
return RETURN_FAILED;
|
||||
|
@ -9,9 +9,10 @@
|
||||
#define MAPPACKETEXTRACTION_H_
|
||||
|
||||
#include <framework/datalinklayer/MapPacketExtractionIF.h>
|
||||
#include <framework/ipc/MessageQueueSender.h>
|
||||
#include <framework/objectmanager/ObjectManagerIF.h>
|
||||
#include <framework/returnvalues/HasReturnvaluesIF.h>
|
||||
#include <framework/ipc/MessageQueueSenderIF.h>
|
||||
|
||||
class StorageManagerIF;
|
||||
|
||||
/**
|
||||
@ -30,7 +31,7 @@ private:
|
||||
uint8_t packetBuffer[MAX_PACKET_SIZE]; //!< The internal Space Packet Buffer.
|
||||
object_id_t packetDestination;
|
||||
StorageManagerIF* packetStore; //!< Pointer to the store where full TC packets are stored.
|
||||
MessageQueueSender tcQueue; //!< Sender Queue 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.
|
||||
*/
|
||||
@ -39,7 +40,7 @@ private:
|
||||
* 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.
|
||||
* @param frame The TC Transfer Frame to work on.
|
||||
* @return @c FRAME_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.
|
||||
*/
|
||||
ReturnValue_t unpackBlockingPackets(TcTransferFrame* frame);
|
||||
|
@ -48,15 +48,22 @@ ReturnValue_t VirtualChannelReception::doFARM(TcTransferFrame* frame, ClcwIF* cl
|
||||
|
||||
ReturnValue_t VirtualChannelReception::frameAcceptanceAndReportingMechanism(TcTransferFrame* frame,
|
||||
ClcwIF* clcw) {
|
||||
ReturnValue_t status = FRAME_OK;
|
||||
status = doFARM(frame, &internalClcw);
|
||||
ReturnValue_t result = RETURN_OK;
|
||||
result = doFARM(frame, &internalClcw);
|
||||
internalClcw.setReceiverFrameSequenceNumber(vR);
|
||||
internalClcw.setFarmBCount(farmBCounter);
|
||||
clcw->setWhole(internalClcw.getAsWhole());
|
||||
if (status == FRAME_OK) {
|
||||
status = mapDemultiplexing(frame);
|
||||
switch (result) {
|
||||
case RETURN_OK:
|
||||
return mapDemultiplexing(frame);
|
||||
case BC_IS_SET_VR_COMMAND:
|
||||
case BC_IS_UNLOCK_COMMAND:
|
||||
//Need to catch these codes to avoid error reporting later.
|
||||
return RETURN_OK;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return status;
|
||||
return result;
|
||||
}
|
||||
|
||||
ReturnValue_t VirtualChannelReception::addMapChannel(uint8_t mapId, MapPacketExtractionIF* object) {
|
||||
@ -71,7 +78,7 @@ ReturnValue_t VirtualChannelReception::addMapChannel(uint8_t mapId, MapPacketExt
|
||||
|
||||
ReturnValue_t VirtualChannelReception::handleBDFrame(TcTransferFrame* frame, ClcwIF* clcw) {
|
||||
farmBCounter++;
|
||||
return FRAME_OK;
|
||||
return RETURN_OK;
|
||||
}
|
||||
|
||||
ReturnValue_t VirtualChannelReception::handleBCFrame(TcTransferFrame* frame, ClcwIF* clcw) {
|
||||
|
@ -67,7 +67,7 @@ protected:
|
||||
* required.
|
||||
* @param frame The Tc Transfer Frame to handle.
|
||||
* @param clcw Any changes on the CLCW shall be done with this method.
|
||||
* @return Always returns @c FRAME_OK.
|
||||
* @return Always returns @c RETURN_OK.
|
||||
*/
|
||||
ReturnValue_t handleBDFrame( TcTransferFrame* frame, ClcwIF* clcw );
|
||||
/**
|
||||
|
@ -38,7 +38,7 @@ public:
|
||||
* Handling the Frame includes forwarding to higher-level procedures.
|
||||
* @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.
|
||||
* @return The return Value shall indicate successful processing with @c FRAME_OK.
|
||||
* @return The return Value shall indicate successful processing with @c RETURN_OK.
|
||||
*/
|
||||
virtual ReturnValue_t frameAcceptanceAndReportingMechanism( TcTransferFrame* frame, ClcwIF* clcw ) = 0;
|
||||
/**
|
||||
|
Reference in New Issue
Block a user