Merge remote-tracking branch 'ksat/mueller/master' into mueller/master
This commit is contained in:
commit
d0d4359017
@ -10,6 +10,7 @@ endif()
|
|||||||
option(FSFW_WARNING_SHADOW_LOCAL_GCC "Enable -Wshadow=local warning in GCC" ON)
|
option(FSFW_WARNING_SHADOW_LOCAL_GCC "Enable -Wshadow=local warning in GCC" ON)
|
||||||
# Options to exclude parts of the FSFW from compilation.
|
# Options to exclude parts of the FSFW from compilation.
|
||||||
option(FSFW_ADD_INTERNAL_TESTS "Add internal unit tests" ON)
|
option(FSFW_ADD_INTERNAL_TESTS "Add internal unit tests" ON)
|
||||||
|
option(FSFW_ADD_UNITTESTS "Add regular unittests. Requires Catch2" OFF)
|
||||||
option(FSFW_ADD_HAL "Add Hardware Abstraction Layer" ON)
|
option(FSFW_ADD_HAL "Add Hardware Abstraction Layer" ON)
|
||||||
|
|
||||||
# Optional sources
|
# Optional sources
|
||||||
@ -38,7 +39,7 @@ elseif(${CMAKE_CXX_STANDARD} LESS 11)
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Backwards comptability
|
# Backwards comptability
|
||||||
if(OS_FSFW)
|
if(OS_FSFW AND NOT FSFW_OSAL)
|
||||||
message(WARNING "Please pass the FSFW OSAL as FSFW_OSAL instead of OS_FSFW")
|
message(WARNING "Please pass the FSFW OSAL as FSFW_OSAL instead of OS_FSFW")
|
||||||
set(FSFW_OSAL OS_FSFW)
|
set(FSFW_OSAL OS_FSFW)
|
||||||
endif()
|
endif()
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
# Core
|
# Core
|
||||||
|
|
||||||
add_subdirectory(action)
|
add_subdirectory(action)
|
||||||
|
add_subdirectory(cfdp)
|
||||||
add_subdirectory(container)
|
add_subdirectory(container)
|
||||||
add_subdirectory(controller)
|
add_subdirectory(controller)
|
||||||
add_subdirectory(datapool)
|
add_subdirectory(datapool)
|
||||||
|
59
src/fsfw/cfdp/CFDPHandler.cpp
Normal file
59
src/fsfw/cfdp/CFDPHandler.cpp
Normal file
@ -0,0 +1,59 @@
|
|||||||
|
#include "fsfw/cfdp/CFDPHandler.h"
|
||||||
|
|
||||||
|
#include "fsfw/tmtcservices/AcceptsTelemetryIF.h"
|
||||||
|
#include "fsfw/ipc/QueueFactory.h"
|
||||||
|
#include "fsfw/objectmanager/ObjectManager.h"
|
||||||
|
|
||||||
|
object_id_t CFDPHandler::packetSource = 0;
|
||||||
|
object_id_t CFDPHandler::packetDestination = 0;
|
||||||
|
|
||||||
|
CFDPHandler::CFDPHandler(object_id_t setObjectId, CFDPDistributor* dist) : SystemObject(setObjectId) {
|
||||||
|
requestQueue = QueueFactory::instance()->createMessageQueue(CFDP_HANDLER_MAX_RECEPTION);
|
||||||
|
distributor = dist;
|
||||||
|
}
|
||||||
|
|
||||||
|
CFDPHandler::~CFDPHandler() {}
|
||||||
|
|
||||||
|
ReturnValue_t CFDPHandler::initialize() {
|
||||||
|
ReturnValue_t result = SystemObject::initialize();
|
||||||
|
if (result != RETURN_OK) {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
this->distributor->registerHandler(this);
|
||||||
|
return HasReturnvaluesIF::RETURN_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
ReturnValue_t CFDPHandler::handleRequest(uint8_t subservice) {
|
||||||
|
#if FSFW_VERBOSE_LEVEL >= 1
|
||||||
|
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||||
|
sif::debug << "CFDPHandler::handleRequest" << std::endl;
|
||||||
|
#else
|
||||||
|
sif::printDebug("CFDPHandler::handleRequest");
|
||||||
|
#endif /* !FSFW_CPP_OSTREAM_ENABLED == 1 */
|
||||||
|
#endif
|
||||||
|
return RETURN_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
ReturnValue_t CFDPHandler::performOperation(uint8_t opCode) {
|
||||||
|
ReturnValue_t result = this->performService();
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
ReturnValue_t CFDPHandler::performService() {
|
||||||
|
#if FSFW_VERBOSE_LEVEL >= 1
|
||||||
|
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||||
|
sif::debug << "CFDPHandler::performService" << std::endl;
|
||||||
|
#else
|
||||||
|
sif::printDebug("CFDPHandler::performService");
|
||||||
|
#endif /* !FSFW_CPP_OSTREAM_ENABLED == 1 */
|
||||||
|
#endif
|
||||||
|
return RETURN_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint16_t CFDPHandler::getIdentifier() {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
MessageQueueId_t CFDPHandler::getRequestQueue() {
|
||||||
|
return this->requestQueue->getId();
|
||||||
|
}
|
63
src/fsfw/cfdp/CFDPHandler.h
Normal file
63
src/fsfw/cfdp/CFDPHandler.h
Normal file
@ -0,0 +1,63 @@
|
|||||||
|
#ifndef FSFW_CFDP_CFDPHANDLER_H_
|
||||||
|
#define FSFW_CFDP_CFDPHANDLER_H_
|
||||||
|
|
||||||
|
#include "fsfw/tmtcservices/AcceptsTelecommandsIF.h"
|
||||||
|
#include "fsfw/objectmanager/SystemObject.h"
|
||||||
|
#include "fsfw/returnvalues/HasReturnvaluesIF.h"
|
||||||
|
#include "fsfw/tasks/ExecutableObjectIF.h"
|
||||||
|
#include "fsfw/tcdistribution/CFDPDistributor.h"
|
||||||
|
|
||||||
|
#include "fsfw/ipc/MessageQueueIF.h"
|
||||||
|
|
||||||
|
namespace Factory{
|
||||||
|
void setStaticFrameworkObjectIds();
|
||||||
|
}
|
||||||
|
|
||||||
|
class CFDPHandler :
|
||||||
|
public ExecutableObjectIF,
|
||||||
|
public AcceptsTelecommandsIF,
|
||||||
|
public SystemObject,
|
||||||
|
public HasReturnvaluesIF {
|
||||||
|
friend void (Factory::setStaticFrameworkObjectIds)();
|
||||||
|
public:
|
||||||
|
CFDPHandler(object_id_t setObjectId, CFDPDistributor* distributor);
|
||||||
|
/**
|
||||||
|
* The destructor is empty.
|
||||||
|
*/
|
||||||
|
virtual ~CFDPHandler();
|
||||||
|
|
||||||
|
virtual ReturnValue_t handleRequest(uint8_t subservice);
|
||||||
|
|
||||||
|
virtual ReturnValue_t performService();
|
||||||
|
virtual ReturnValue_t initialize() override;
|
||||||
|
virtual uint16_t getIdentifier() override;
|
||||||
|
MessageQueueId_t getRequestQueue() override;
|
||||||
|
ReturnValue_t performOperation(uint8_t opCode) override;
|
||||||
|
protected:
|
||||||
|
/**
|
||||||
|
* This is a complete instance of the telecommand reception queue
|
||||||
|
* of the class. It is initialized on construction of the class.
|
||||||
|
*/
|
||||||
|
MessageQueueIF* requestQueue = nullptr;
|
||||||
|
|
||||||
|
CFDPDistributor* distributor = nullptr;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The current CFDP packet to be processed.
|
||||||
|
* It is deleted after handleRequest was executed.
|
||||||
|
*/
|
||||||
|
CFDPPacketStored currentPacket;
|
||||||
|
|
||||||
|
static object_id_t packetSource;
|
||||||
|
|
||||||
|
static object_id_t packetDestination;
|
||||||
|
private:
|
||||||
|
/**
|
||||||
|
* This constant sets the maximum number of packets accepted per call.
|
||||||
|
* Remember that one packet must be completely handled in one
|
||||||
|
* #handleRequest call.
|
||||||
|
*/
|
||||||
|
static const uint8_t CFDP_HANDLER_MAX_RECEPTION = 10;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif /* FSFW_CFDP_CFDPHANDLER_H_ */
|
4
src/fsfw/cfdp/CMakeLists.txt
Normal file
4
src/fsfw/cfdp/CMakeLists.txt
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
target_sources(${LIB_FSFW_NAME}
|
||||||
|
PRIVATE
|
||||||
|
CFDPHandler.cpp
|
||||||
|
)
|
@ -1,124 +1,247 @@
|
|||||||
#include "fsfw/globalfunctions/DleEncoder.h"
|
#include "fsfw/globalfunctions/DleEncoder.h"
|
||||||
|
|
||||||
DleEncoder::DleEncoder() {}
|
DleEncoder::DleEncoder(bool escapeStxEtx, bool escapeCr): escapeStxEtx(escapeStxEtx),
|
||||||
|
escapeCr(escapeCr) {}
|
||||||
|
|
||||||
DleEncoder::~DleEncoder() {}
|
DleEncoder::~DleEncoder() {}
|
||||||
|
|
||||||
ReturnValue_t DleEncoder::encode(const uint8_t* sourceStream,
|
ReturnValue_t DleEncoder::encode(const uint8_t* sourceStream,
|
||||||
size_t sourceLen, uint8_t* destStream, size_t maxDestLen,
|
size_t sourceLen, uint8_t* destStream, size_t maxDestLen,
|
||||||
size_t* encodedLen, bool addStxEtx) {
|
size_t* encodedLen, bool addStxEtx) {
|
||||||
if (maxDestLen < 2) {
|
size_t minAllowedLen = 0;
|
||||||
return STREAM_TOO_SHORT;
|
if(escapeStxEtx) {
|
||||||
}
|
minAllowedLen = 2;
|
||||||
size_t encodedIndex = 0, sourceIndex = 0;
|
|
||||||
uint8_t nextByte;
|
}
|
||||||
|
else {
|
||||||
|
minAllowedLen = 1;
|
||||||
|
|
||||||
|
}
|
||||||
|
if(maxDestLen < minAllowedLen) {
|
||||||
|
return STREAM_TOO_SHORT;
|
||||||
|
}
|
||||||
if (addStxEtx) {
|
if (addStxEtx) {
|
||||||
|
if(not escapeStxEtx) {
|
||||||
|
destStream[0] = DLE_CHAR;
|
||||||
|
}
|
||||||
destStream[0] = STX_CHAR;
|
destStream[0] = STX_CHAR;
|
||||||
++encodedIndex;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
while (encodedIndex < maxDestLen and sourceIndex < sourceLen)
|
if(escapeStxEtx) {
|
||||||
{
|
return encodeStreamEscaped(sourceStream, sourceLen,
|
||||||
nextByte = sourceStream[sourceIndex];
|
destStream, maxDestLen, encodedLen, addStxEtx);
|
||||||
// STX, ETX and CR characters in the stream need to be escaped with DLE
|
}
|
||||||
if (nextByte == STX_CHAR or nextByte == ETX_CHAR or nextByte == CARRIAGE_RETURN) {
|
else {
|
||||||
if (encodedIndex + 1 >= maxDestLen) {
|
return encodeStreamNonEscaped(sourceStream, sourceLen,
|
||||||
return STREAM_TOO_SHORT;
|
destStream, maxDestLen, encodedLen, addStxEtx);
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
destStream[encodedIndex] = DLE_CHAR;
|
|
||||||
++encodedIndex;
|
|
||||||
/* Escaped byte will be actual byte + 0x40. This prevents
|
|
||||||
* STX, ETX, and carriage return characters from appearing
|
|
||||||
* in the encoded data stream at all, so when polling an
|
|
||||||
* encoded stream, the transmission can be stopped at ETX.
|
|
||||||
* 0x40 was chosen at random with special requirements:
|
|
||||||
* - Prevent going from one control char to another
|
|
||||||
* - Prevent overflow for common characters */
|
|
||||||
destStream[encodedIndex] = nextByte + 0x40;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// DLE characters are simply escaped with DLE.
|
|
||||||
else if (nextByte == DLE_CHAR) {
|
|
||||||
if (encodedIndex + 1 >= maxDestLen) {
|
|
||||||
return STREAM_TOO_SHORT;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
destStream[encodedIndex] = DLE_CHAR;
|
|
||||||
++encodedIndex;
|
|
||||||
destStream[encodedIndex] = DLE_CHAR;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
destStream[encodedIndex] = nextByte;
|
|
||||||
}
|
|
||||||
++encodedIndex;
|
|
||||||
++sourceIndex;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (sourceIndex == sourceLen and encodedIndex < maxDestLen) {
|
}
|
||||||
if (addStxEtx) {
|
|
||||||
destStream[encodedIndex] = ETX_CHAR;
|
ReturnValue_t DleEncoder::encodeStreamEscaped(const uint8_t *sourceStream, size_t sourceLen,
|
||||||
++encodedIndex;
|
uint8_t *destStream, size_t maxDestLen, size_t *encodedLen,
|
||||||
}
|
bool addStxEtx) {
|
||||||
*encodedLen = encodedIndex;
|
size_t encodedIndex = 1;
|
||||||
return RETURN_OK;
|
size_t sourceIndex = 0;
|
||||||
}
|
uint8_t nextByte = 0;
|
||||||
else {
|
while (encodedIndex < maxDestLen and sourceIndex < sourceLen) {
|
||||||
return STREAM_TOO_SHORT;
|
nextByte = sourceStream[sourceIndex];
|
||||||
}
|
// STX, ETX and CR characters in the stream need to be escaped with DLE
|
||||||
|
if ((nextByte == STX_CHAR or nextByte == ETX_CHAR) or
|
||||||
|
(this->escapeCr and nextByte == CARRIAGE_RETURN)) {
|
||||||
|
if (encodedIndex + 1 >= maxDestLen) {
|
||||||
|
return STREAM_TOO_SHORT;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
destStream[encodedIndex] = DLE_CHAR;
|
||||||
|
++encodedIndex;
|
||||||
|
/* Escaped byte will be actual byte + 0x40. This prevents
|
||||||
|
* STX, ETX, and carriage return characters from appearing
|
||||||
|
* in the encoded data stream at all, so when polling an
|
||||||
|
* encoded stream, the transmission can be stopped at ETX.
|
||||||
|
* 0x40 was chosen at random with special requirements:
|
||||||
|
* - Prevent going from one control char to another
|
||||||
|
* - Prevent overflow for common characters */
|
||||||
|
destStream[encodedIndex] = nextByte + 0x40;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// DLE characters are simply escaped with DLE.
|
||||||
|
else if (nextByte == DLE_CHAR) {
|
||||||
|
if (encodedIndex + 1 >= maxDestLen) {
|
||||||
|
return STREAM_TOO_SHORT;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
destStream[encodedIndex] = DLE_CHAR;
|
||||||
|
++encodedIndex;
|
||||||
|
destStream[encodedIndex] = DLE_CHAR;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
destStream[encodedIndex] = nextByte;
|
||||||
|
}
|
||||||
|
++encodedIndex;
|
||||||
|
++sourceIndex;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (sourceIndex == sourceLen and encodedIndex < maxDestLen) {
|
||||||
|
if (addStxEtx) {
|
||||||
|
destStream[encodedIndex] = ETX_CHAR;
|
||||||
|
++encodedIndex;
|
||||||
|
}
|
||||||
|
*encodedLen = encodedIndex;
|
||||||
|
return RETURN_OK;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return STREAM_TOO_SHORT;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ReturnValue_t DleEncoder::encodeStreamNonEscaped(const uint8_t *sourceStream, size_t sourceLen,
|
||||||
|
uint8_t *destStream, size_t maxDestLen, size_t *encodedLen,
|
||||||
|
bool addStxEtx) {
|
||||||
|
size_t encodedIndex = 1;
|
||||||
|
size_t sourceIndex = 0;
|
||||||
|
uint8_t nextByte = 0;
|
||||||
|
while (encodedIndex < maxDestLen and sourceIndex < sourceLen) {
|
||||||
|
nextByte = sourceStream[sourceIndex];
|
||||||
|
// DLE characters are simply escaped with DLE.
|
||||||
|
if (nextByte == DLE_CHAR) {
|
||||||
|
if (encodedIndex + 1 >= maxDestLen) {
|
||||||
|
return STREAM_TOO_SHORT;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
destStream[encodedIndex] = DLE_CHAR;
|
||||||
|
++encodedIndex;
|
||||||
|
destStream[encodedIndex] = DLE_CHAR;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
destStream[encodedIndex] = nextByte;
|
||||||
|
}
|
||||||
|
++encodedIndex;
|
||||||
|
++sourceIndex;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (sourceIndex == sourceLen and encodedIndex < maxDestLen) {
|
||||||
|
if (addStxEtx) {
|
||||||
|
destStream[encodedIndex] = ETX_CHAR;
|
||||||
|
++encodedIndex;
|
||||||
|
}
|
||||||
|
*encodedLen = encodedIndex;
|
||||||
|
return RETURN_OK;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return STREAM_TOO_SHORT;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ReturnValue_t DleEncoder::decode(const uint8_t *sourceStream,
|
ReturnValue_t DleEncoder::decode(const uint8_t *sourceStream,
|
||||||
size_t sourceStreamLen, size_t *readLen, uint8_t *destStream,
|
size_t sourceStreamLen, size_t *readLen, uint8_t *destStream,
|
||||||
size_t maxDestStreamlen, size_t *decodedLen) {
|
size_t maxDestStreamlen, size_t *decodedLen) {
|
||||||
size_t encodedIndex = 0, decodedIndex = 0;
|
size_t encodedIndex = 0;
|
||||||
uint8_t nextByte;
|
if(not escapeStxEtx) {
|
||||||
if (*sourceStream != STX_CHAR) {
|
if (*sourceStream != DLE_CHAR) {
|
||||||
return DECODING_ERROR;
|
return DECODING_ERROR;
|
||||||
|
}
|
||||||
|
++encodedIndex;
|
||||||
}
|
}
|
||||||
++encodedIndex;
|
if (sourceStream[encodedIndex] != STX_CHAR) {
|
||||||
|
return DECODING_ERROR;
|
||||||
while ((encodedIndex < sourceStreamLen) && (decodedIndex < maxDestStreamlen)
|
|
||||||
&& (sourceStream[encodedIndex] != ETX_CHAR)
|
|
||||||
&& (sourceStream[encodedIndex] != STX_CHAR)) {
|
|
||||||
if (sourceStream[encodedIndex] == DLE_CHAR) {
|
|
||||||
nextByte = sourceStream[encodedIndex + 1];
|
|
||||||
// The next byte is a DLE character that was escaped by another
|
|
||||||
// DLE character, so we can write it to the destination stream.
|
|
||||||
if (nextByte == DLE_CHAR) {
|
|
||||||
destStream[decodedIndex] = nextByte;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
/* The next byte is a STX, DTX or 0x0D character which
|
|
||||||
* was escaped by a DLE character. The actual byte was
|
|
||||||
* also encoded by adding + 0x40 to prevent having control chars,
|
|
||||||
* in the stream at all, so we convert it back. */
|
|
||||||
if (nextByte == 0x42 or nextByte == 0x43 or nextByte == 0x4D) {
|
|
||||||
destStream[decodedIndex] = nextByte - 0x40;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
return DECODING_ERROR;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
++encodedIndex;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
destStream[decodedIndex] = sourceStream[encodedIndex];
|
|
||||||
}
|
|
||||||
|
|
||||||
++encodedIndex;
|
|
||||||
++decodedIndex;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sourceStream[encodedIndex] != ETX_CHAR) {
|
if(escapeStxEtx) {
|
||||||
*readLen = ++encodedIndex;
|
return decodeStreamEscaped(sourceStream, sourceStreamLen,
|
||||||
return DECODING_ERROR;
|
readLen, destStream, maxDestStreamlen, decodedLen);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
*readLen = ++encodedIndex;
|
return decodeStreamNonEscaped(sourceStream, sourceStreamLen,
|
||||||
*decodedLen = decodedIndex;
|
readLen, destStream, maxDestStreamlen, decodedLen);
|
||||||
return RETURN_OK;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ReturnValue_t DleEncoder::decodeStreamEscaped(const uint8_t *sourceStream, size_t sourceStreamLen,
|
||||||
|
size_t *readLen, uint8_t *destStream,
|
||||||
|
size_t maxDestStreamlen, size_t *decodedLen) {
|
||||||
|
// Skip start marker, was already checked
|
||||||
|
size_t encodedIndex = 1;
|
||||||
|
size_t decodedIndex = 0;
|
||||||
|
uint8_t nextByte;
|
||||||
|
while ((encodedIndex < sourceStreamLen) && (decodedIndex < maxDestStreamlen)
|
||||||
|
&& (sourceStream[encodedIndex] != ETX_CHAR)
|
||||||
|
&& (sourceStream[encodedIndex] != STX_CHAR)) {
|
||||||
|
if (sourceStream[encodedIndex] == DLE_CHAR) {
|
||||||
|
nextByte = sourceStream[encodedIndex + 1];
|
||||||
|
// The next byte is a DLE character that was escaped by another
|
||||||
|
// DLE character, so we can write it to the destination stream.
|
||||||
|
if (nextByte == DLE_CHAR) {
|
||||||
|
destStream[decodedIndex] = nextByte;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
/* The next byte is a STX, DTX or 0x0D character which
|
||||||
|
* was escaped by a DLE character. The actual byte was
|
||||||
|
* also encoded by adding + 0x40 to prevent having control chars,
|
||||||
|
* in the stream at all, so we convert it back. */
|
||||||
|
if ((nextByte == STX_CHAR + 0x40 or nextByte == ETX_CHAR + 0x40) or
|
||||||
|
(this->escapeCr and nextByte == CARRIAGE_RETURN + 0x40)) {
|
||||||
|
destStream[decodedIndex] = nextByte - 0x40;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return DECODING_ERROR;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
++encodedIndex;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
destStream[decodedIndex] = sourceStream[encodedIndex];
|
||||||
|
}
|
||||||
|
|
||||||
|
++encodedIndex;
|
||||||
|
++decodedIndex;
|
||||||
|
}
|
||||||
|
if (sourceStream[encodedIndex] != ETX_CHAR) {
|
||||||
|
*readLen = ++encodedIndex;
|
||||||
|
return DECODING_ERROR;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
*readLen = ++encodedIndex;
|
||||||
|
*decodedLen = decodedIndex;
|
||||||
|
return RETURN_OK;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ReturnValue_t DleEncoder::decodeStreamNonEscaped(const uint8_t *sourceStream,
|
||||||
|
size_t sourceStreamLen, size_t *readLen, uint8_t *destStream,
|
||||||
|
size_t maxDestStreamlen, size_t *decodedLen) {
|
||||||
|
// Skip start marker, was already checked
|
||||||
|
size_t encodedIndex = 2;
|
||||||
|
size_t decodedIndex = 0;
|
||||||
|
uint8_t nextByte;
|
||||||
|
while ((encodedIndex < sourceStreamLen) && (decodedIndex < maxDestStreamlen)) {
|
||||||
|
if (sourceStream[encodedIndex] == DLE_CHAR) {
|
||||||
|
nextByte = sourceStream[encodedIndex + 1];
|
||||||
|
if(nextByte == STX_CHAR) {
|
||||||
|
*readLen = ++encodedIndex;
|
||||||
|
return DECODING_ERROR;
|
||||||
|
}
|
||||||
|
else if(nextByte == DLE_CHAR) {
|
||||||
|
// The next byte is a DLE character that was escaped by another
|
||||||
|
// DLE character, so we can write it to the destination stream.
|
||||||
|
destStream[decodedIndex] = nextByte;
|
||||||
|
++encodedIndex;
|
||||||
|
}
|
||||||
|
else if(nextByte == ETX_CHAR) {
|
||||||
|
// End of stream reached
|
||||||
|
*readLen = encodedIndex + 2;
|
||||||
|
*decodedLen = decodedIndex;
|
||||||
|
return RETURN_OK;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
destStream[decodedIndex] = sourceStream[encodedIndex];
|
||||||
|
}
|
||||||
|
++encodedIndex;
|
||||||
|
++decodedIndex;
|
||||||
|
}
|
||||||
|
return DECODING_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#ifndef FRAMEWORK_GLOBALFUNCTIONS_DLEENCODER_H_
|
#ifndef FRAMEWORK_GLOBALFUNCTIONS_DLEENCODER_H_
|
||||||
#define FRAMEWORK_GLOBALFUNCTIONS_DLEENCODER_H_
|
#define FRAMEWORK_GLOBALFUNCTIONS_DLEENCODER_H_
|
||||||
|
|
||||||
#include "../returnvalues/HasReturnvaluesIF.h"
|
#include "fsfw/returnvalues/HasReturnvaluesIF.h"
|
||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -12,52 +12,64 @@
|
|||||||
* https://en.wikipedia.org/wiki/C0_and_C1_control_codes
|
* https://en.wikipedia.org/wiki/C0_and_C1_control_codes
|
||||||
*
|
*
|
||||||
* This encoder can be used to achieve a basic transport layer when using
|
* This encoder can be used to achieve a basic transport layer when using
|
||||||
* char based transmission systems.
|
* char based transmission systems. There are two implemented variants:
|
||||||
* The passed source strean is converted into a encoded stream by adding
|
|
||||||
* a STX marker at the start of the stream and an ETX marker at the end of
|
|
||||||
* the stream. Any STX, ETX, DLE and CR occurrences in the source stream are
|
|
||||||
* escaped by a DLE character. The encoder also replaces escaped control chars
|
|
||||||
* by another char, so STX, ETX and CR should not appear anywhere in the actual
|
|
||||||
* encoded data stream.
|
|
||||||
*
|
*
|
||||||
* When using a strictly char based reception of packets encoded with DLE,
|
* 1. Escaped variant
|
||||||
|
*
|
||||||
|
* The encoded stream starts with a STX marker and ends with an ETX marker.
|
||||||
|
* STX and ETX occurrences in the stream are escaped and internally encoded as well so the
|
||||||
|
* receiver side can simply check for STX and ETX markers as frame delimiters. When using a
|
||||||
|
* strictly char based reception of packets encoded with DLE,
|
||||||
* STX can be used to notify a reader that actual data will start to arrive
|
* STX can be used to notify a reader that actual data will start to arrive
|
||||||
* while ETX can be used to notify the reader that the data has ended.
|
* while ETX can be used to notify the reader that the data has ended.
|
||||||
|
*
|
||||||
|
* 2. Non-escaped variant
|
||||||
|
*
|
||||||
|
* The encoded stream starts with DLE STX and ends with DLE ETX. All DLE occurrences in the stream
|
||||||
|
* are escaped with DLE. If the receiver detects a DLE char, it needs to read the next char
|
||||||
|
* to determine whether a start (STX) or end (ETX) of a frame has been detected.
|
||||||
*/
|
*/
|
||||||
class DleEncoder: public HasReturnvaluesIF {
|
class DleEncoder: public HasReturnvaluesIF {
|
||||||
private:
|
|
||||||
DleEncoder();
|
|
||||||
virtual ~DleEncoder();
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static constexpr uint8_t INTERFACE_ID = CLASS_ID::DLE_ENCODER;
|
/**
|
||||||
static constexpr ReturnValue_t STREAM_TOO_SHORT = MAKE_RETURN_CODE(0x01);
|
* Create an encoder instance with the given configuration.
|
||||||
static constexpr ReturnValue_t DECODING_ERROR = MAKE_RETURN_CODE(0x02);
|
* @param escapeStxEtx Determines whether the algorithm works in escaped or non-escaped mode
|
||||||
|
* @param escapeCr In escaped mode, escape all CR occurrences as well
|
||||||
|
*/
|
||||||
|
DleEncoder(bool escapeStxEtx = true, bool escapeCr = false);
|
||||||
|
virtual ~DleEncoder();
|
||||||
|
|
||||||
//! Start Of Text character. First character is encoded stream
|
static constexpr uint8_t INTERFACE_ID = CLASS_ID::DLE_ENCODER;
|
||||||
static constexpr uint8_t STX_CHAR = 0x02;
|
static constexpr ReturnValue_t STREAM_TOO_SHORT = MAKE_RETURN_CODE(0x01);
|
||||||
//! End Of Text character. Last character in encoded stream
|
static constexpr ReturnValue_t DECODING_ERROR = MAKE_RETURN_CODE(0x02);
|
||||||
static constexpr uint8_t ETX_CHAR = 0x03;
|
|
||||||
//! Data Link Escape character. Used to escape STX, ETX and DLE occurrences
|
//! Start Of Text character. First character is encoded stream
|
||||||
//! in the source stream.
|
static constexpr uint8_t STX_CHAR = 0x02;
|
||||||
static constexpr uint8_t DLE_CHAR = 0x10;
|
//! End Of Text character. Last character in encoded stream
|
||||||
static constexpr uint8_t CARRIAGE_RETURN = 0x0D;
|
static constexpr uint8_t ETX_CHAR = 0x03;
|
||||||
|
//! Data Link Escape character. Used to escape STX, ETX and DLE occurrences
|
||||||
|
//! in the source stream.
|
||||||
|
static constexpr uint8_t DLE_CHAR = 0x10;
|
||||||
|
static constexpr uint8_t CARRIAGE_RETURN = 0x0D;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Encodes the give data stream by preceding it with the STX marker
|
* Encodes the give data stream by preceding it with the STX marker
|
||||||
* and ending it with an ETX marker. STX, ETX and DLE characters inside
|
* and ending it with an ETX marker. DLE characters inside
|
||||||
* the stream are escaped by DLE characters and also replaced by adding
|
* the stream are escaped by DLE characters. STX, ETX and CR characters can be escaped with a
|
||||||
* 0x40 (which is reverted in the decoding process).
|
* DLE character as well. The escaped characters are also encoded by adding
|
||||||
|
* 0x40 (which is reverted in the decoding process). This is performed so the source stream
|
||||||
|
* does not have STX/ETX/CR occurrences anymore, so the receiving side can simply parse for
|
||||||
|
* start and end markers
|
||||||
* @param sourceStream
|
* @param sourceStream
|
||||||
* @param sourceLen
|
* @param sourceLen
|
||||||
* @param destStream
|
* @param destStream
|
||||||
* @param maxDestLen
|
* @param maxDestLen
|
||||||
* @param encodedLen
|
* @param encodedLen
|
||||||
* @param addStxEtx
|
* @param addStxEtx Adding STX start marker and ETX end marker can be omitted,
|
||||||
* Adding STX and ETX can be omitted, if they are added manually.
|
* if they are added manually
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
static ReturnValue_t encode(const uint8_t *sourceStream, size_t sourceLen,
|
ReturnValue_t encode(const uint8_t *sourceStream, size_t sourceLen,
|
||||||
uint8_t *destStream, size_t maxDestLen, size_t *encodedLen,
|
uint8_t *destStream, size_t maxDestLen, size_t *encodedLen,
|
||||||
bool addStxEtx = true);
|
bool addStxEtx = true);
|
||||||
|
|
||||||
@ -71,9 +83,28 @@ public:
|
|||||||
* @param decodedLen
|
* @param decodedLen
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
static ReturnValue_t decode(const uint8_t *sourceStream,
|
ReturnValue_t decode(const uint8_t *sourceStream,
|
||||||
size_t sourceStreamLen, size_t *readLen, uint8_t *destStream,
|
size_t sourceStreamLen, size_t *readLen, uint8_t *destStream,
|
||||||
size_t maxDestStreamlen, size_t *decodedLen);
|
size_t maxDestStreamlen, size_t *decodedLen);
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
ReturnValue_t encodeStreamEscaped(const uint8_t *sourceStream, size_t sourceLen,
|
||||||
|
uint8_t *destStream, size_t maxDestLen, size_t *encodedLen,
|
||||||
|
bool addStxEtx = true);
|
||||||
|
|
||||||
|
ReturnValue_t encodeStreamNonEscaped(const uint8_t *sourceStream, size_t sourceLen,
|
||||||
|
uint8_t *destStream, size_t maxDestLen, size_t *encodedLen,
|
||||||
|
bool addStxEtx = true);
|
||||||
|
|
||||||
|
ReturnValue_t decodeStreamEscaped(const uint8_t *sourceStream, size_t sourceStreamLen,
|
||||||
|
size_t *readLen, uint8_t *destStream, size_t maxDestStreamlen, size_t *decodedLen);
|
||||||
|
|
||||||
|
ReturnValue_t decodeStreamNonEscaped(const uint8_t *sourceStream, size_t sourceStreamLen,
|
||||||
|
size_t *readLen, uint8_t *destStream, size_t maxDestStreamlen, size_t *decodedLen);
|
||||||
|
|
||||||
|
bool escapeStxEtx;
|
||||||
|
bool escapeCr;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* FRAMEWORK_GLOBALFUNCTIONS_DLEENCODER_H_ */
|
#endif /* FRAMEWORK_GLOBALFUNCTIONS_DLEENCODER_H_ */
|
||||||
|
13
src/fsfw/memory/FileSystemArgsIF.h
Normal file
13
src/fsfw/memory/FileSystemArgsIF.h
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
#ifndef FSFW_SRC_FSFW_MEMORY_FILESYSTEMARGS_H_
|
||||||
|
#define FSFW_SRC_FSFW_MEMORY_FILESYSTEMARGS_H_
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Empty base interface which can be implemented by to pass arguments via the HasFileSystemIF.
|
||||||
|
* Users can then dynamic_cast the base pointer to the require child pointer.
|
||||||
|
*/
|
||||||
|
class FileSystemArgsIF {
|
||||||
|
public:
|
||||||
|
virtual~ FileSystemArgsIF() {};
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif /* FSFW_SRC_FSFW_MEMORY_FILESYSTEMARGS_H_ */
|
@ -1,9 +1,10 @@
|
|||||||
#ifndef FSFW_MEMORY_HASFILESYSTEMIF_H_
|
#ifndef FSFW_MEMORY_HASFILESYSTEMIF_H_
|
||||||
#define FSFW_MEMORY_HASFILESYSTEMIF_H_
|
#define FSFW_MEMORY_HASFILESYSTEMIF_H_
|
||||||
|
|
||||||
#include "../returnvalues/HasReturnvaluesIF.h"
|
#include "FileSystemArgsIF.h"
|
||||||
#include "../returnvalues/FwClassIds.h"
|
#include "fsfw/returnvalues/HasReturnvaluesIF.h"
|
||||||
#include "../ipc/messageQueueDefinitions.h"
|
#include "fsfw/returnvalues/FwClassIds.h"
|
||||||
|
#include "fsfw/ipc/messageQueueDefinitions.h"
|
||||||
|
|
||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
|
|
||||||
@ -59,7 +60,7 @@ public:
|
|||||||
*/
|
*/
|
||||||
virtual ReturnValue_t appendToFile(const char* repositoryPath,
|
virtual ReturnValue_t appendToFile(const char* repositoryPath,
|
||||||
const char* filename, const uint8_t* data, size_t size,
|
const char* filename, const uint8_t* data, size_t size,
|
||||||
uint16_t packetNumber, void* args = nullptr) = 0;
|
uint16_t packetNumber, FileSystemArgsIF* args = nullptr) = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Generic function to create a new file.
|
* @brief Generic function to create a new file.
|
||||||
@ -72,7 +73,7 @@ public:
|
|||||||
*/
|
*/
|
||||||
virtual ReturnValue_t createFile(const char* repositoryPath,
|
virtual ReturnValue_t createFile(const char* repositoryPath,
|
||||||
const char* filename, const uint8_t* data = nullptr,
|
const char* filename, const uint8_t* data = nullptr,
|
||||||
size_t size = 0, void* args = nullptr) = 0;
|
size_t size = 0, FileSystemArgsIF* args = nullptr) = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Generic function to delete a file.
|
* @brief Generic function to delete a file.
|
||||||
@ -82,23 +83,29 @@ public:
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
virtual ReturnValue_t removeFile(const char* repositoryPath,
|
virtual ReturnValue_t removeFile(const char* repositoryPath,
|
||||||
const char* filename, void* args = nullptr) = 0;
|
const char* filename, FileSystemArgsIF* args = nullptr) = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Generic function to create a directory
|
* @brief Generic function to create a directory
|
||||||
* @param repositoryPath
|
* @param repositoryPath
|
||||||
|
* @param Equivalent to the -p flag in Unix systems. If some required parent directories
|
||||||
|
* do not exist, create them as well
|
||||||
* @param args Any other arguments which an implementation might require
|
* @param args Any other arguments which an implementation might require
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
virtual ReturnValue_t createDirectory(const char* repositoryPath, void* args = nullptr) = 0;
|
virtual ReturnValue_t createDirectory(const char* repositoryPath, const char* dirname,
|
||||||
|
bool createParentDirs, FileSystemArgsIF* args = nullptr) = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Generic function to remove a directory
|
* @brief Generic function to remove a directory
|
||||||
* @param repositoryPath
|
* @param repositoryPath
|
||||||
* @param args Any other arguments which an implementation might require
|
* @param args Any other arguments which an implementation might require
|
||||||
*/
|
*/
|
||||||
virtual ReturnValue_t removeDirectory(const char* repositoryPath,
|
virtual ReturnValue_t removeDirectory(const char* repositoryPath, const char* dirname,
|
||||||
bool deleteRecurively = false, void* args = nullptr) = 0;
|
bool deleteRecurively = false, FileSystemArgsIF* args = nullptr) = 0;
|
||||||
|
|
||||||
|
virtual ReturnValue_t renameFile(const char* repositoryPath, const char* oldFilename,
|
||||||
|
const char* newFilename, FileSystemArgsIF* args = nullptr) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -19,6 +19,9 @@ enum framework_objects: object_id_t {
|
|||||||
PUS_SERVICE_200_MODE_MGMT = 0x53000200,
|
PUS_SERVICE_200_MODE_MGMT = 0x53000200,
|
||||||
PUS_SERVICE_201_HEALTH = 0x53000201,
|
PUS_SERVICE_201_HEALTH = 0x53000201,
|
||||||
|
|
||||||
|
/* CFDP Distributer */
|
||||||
|
CFDP_PACKET_DISTRIBUTOR = 0x53001000,
|
||||||
|
|
||||||
//Generic IDs for IPC, modes, health, events
|
//Generic IDs for IPC, modes, health, events
|
||||||
HEALTH_TABLE = 0x53010000,
|
HEALTH_TABLE = 0x53010000,
|
||||||
// MODE_STORE = 0x53010100,
|
// MODE_STORE = 0x53010100,
|
||||||
|
@ -62,8 +62,13 @@ ReturnValue_t CommandExecutor::close() {
|
|||||||
|
|
||||||
void CommandExecutor::printLastError(std::string funcName) const {
|
void CommandExecutor::printLastError(std::string funcName) const {
|
||||||
if(lastError != 0) {
|
if(lastError != 0) {
|
||||||
|
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||||
sif::error << funcName << " pclose failed with code " <<
|
sif::error << funcName << " pclose failed with code " <<
|
||||||
lastError << ": " << strerror(lastError) << std::endl;
|
lastError << ": " << strerror(lastError) << std::endl;
|
||||||
|
#else
|
||||||
|
sif::printError("%s pclose failed with code %d: %s", funcName, lastError,
|
||||||
|
strerror(lastError));
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -98,15 +103,23 @@ ReturnValue_t CommandExecutor::check(bool& bytesRead) {
|
|||||||
ssize_t readBytes = read(currentFd, readVec.data(), readVec.size());
|
ssize_t readBytes = read(currentFd, readVec.data(), readVec.size());
|
||||||
if(readBytes == 0) {
|
if(readBytes == 0) {
|
||||||
// Should not happen
|
// Should not happen
|
||||||
|
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||||
sif::warning << "CommandExecutor::check: "
|
sif::warning << "CommandExecutor::check: "
|
||||||
"No bytes read after poll event.." << std::endl;
|
"No bytes read after poll event.." << std::endl;
|
||||||
|
#else
|
||||||
|
sif::printWarning("CommandExecutor::check: No bytes read after poll event..\n");
|
||||||
|
#endif
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
else if(readBytes > 0) {
|
else if(readBytes > 0) {
|
||||||
bytesRead = true;
|
bytesRead = true;
|
||||||
if(printOutput) {
|
if(printOutput) {
|
||||||
|
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||||
// It is assumed the command output is line terminated
|
// It is assumed the command output is line terminated
|
||||||
sif::info << currentCmd << " | " << readVec.data();
|
sif::info << currentCmd << " | " << readVec.data();
|
||||||
|
#else
|
||||||
|
sif::printInfo("%s | %s", currentCmd, readVec.data());
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
if(ringBuffer != nullptr) {
|
if(ringBuffer != nullptr) {
|
||||||
ringBuffer->writeData(reinterpret_cast<const uint8_t*>(
|
ringBuffer->writeData(reinterpret_cast<const uint8_t*>(
|
||||||
@ -120,17 +133,25 @@ ReturnValue_t CommandExecutor::check(bool& bytesRead) {
|
|||||||
return BYTES_READ;
|
return BYTES_READ;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||||
// Should also not happen
|
// Should also not happen
|
||||||
sif::warning << "CommandExecutor::check: Error " << errno << ": " <<
|
sif::warning << "CommandExecutor::check: Error " << errno << ": " <<
|
||||||
strerror(errno) << std::endl;
|
strerror(errno) << std::endl;
|
||||||
|
#else
|
||||||
|
sif::printWarning("CommandExecutor::check: Error %d: %s\n", errno, strerror(errno));
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(waiter.revents & POLLERR) {
|
else if(waiter.revents & POLLERR) {
|
||||||
|
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||||
sif::warning << "CommandExecuter::check: Poll error" << std::endl;
|
sif::warning << "CommandExecuter::check: Poll error" << std::endl;
|
||||||
|
#else
|
||||||
|
sif::printWarning("CommandExecuter::check: Poll error\n");
|
||||||
|
#endif
|
||||||
return COMMAND_ERROR;
|
return COMMAND_ERROR;
|
||||||
}
|
}
|
||||||
else if(waiter.revents & POLLHUP) {
|
else if(waiter.revents & POLLHUP) {
|
||||||
int result = pclose(currentCmdFile);
|
result = pclose(currentCmdFile);
|
||||||
if(result != 0) {
|
if(result != 0) {
|
||||||
lastError = result;
|
lastError = result;
|
||||||
return HasReturnvaluesIF::RETURN_FAILED;
|
return HasReturnvaluesIF::RETURN_FAILED;
|
||||||
@ -165,7 +186,11 @@ ReturnValue_t CommandExecutor::executeBlocking() {
|
|||||||
while(fgets(readVec.data(), readVec.size(), currentCmdFile) != nullptr) {
|
while(fgets(readVec.data(), readVec.size(), currentCmdFile) != nullptr) {
|
||||||
std::string output(readVec.data());
|
std::string output(readVec.data());
|
||||||
if(printOutput) {
|
if(printOutput) {
|
||||||
|
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||||
sif::info << currentCmd << " | " << output;
|
sif::info << currentCmd << " | " << output;
|
||||||
|
#else
|
||||||
|
sif::printInfo("%s | %s", currentCmd, output);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
if(ringBuffer != nullptr) {
|
if(ringBuffer != nullptr) {
|
||||||
ringBuffer->writeData(reinterpret_cast<const uint8_t*>(output.data()), output.size());
|
ringBuffer->writeData(reinterpret_cast<const uint8_t*>(output.data()), output.size());
|
||||||
|
@ -50,8 +50,6 @@ bool Timer::isSet() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Timer::resetTimer() {
|
void Timer::resetTimer() {
|
||||||
if(not this->set) {
|
set = false;
|
||||||
set = false;
|
|
||||||
}
|
|
||||||
setTimer(0);
|
setTimer(0);
|
||||||
}
|
}
|
||||||
|
@ -7,8 +7,8 @@
|
|||||||
#define CCSDS_DISTRIBUTOR_DEBUGGING 0
|
#define CCSDS_DISTRIBUTOR_DEBUGGING 0
|
||||||
|
|
||||||
CCSDSDistributor::CCSDSDistributor(uint16_t setDefaultApid,
|
CCSDSDistributor::CCSDSDistributor(uint16_t setDefaultApid,
|
||||||
object_id_t setObjectId):
|
object_id_t setObjectId):
|
||||||
TcDistributor(setObjectId), defaultApid( setDefaultApid ) {
|
TcDistributor(setObjectId), defaultApid( setDefaultApid ) {
|
||||||
}
|
}
|
||||||
|
|
||||||
CCSDSDistributor::~CCSDSDistributor() {}
|
CCSDSDistributor::~CCSDSDistributor() {}
|
||||||
@ -16,97 +16,97 @@ CCSDSDistributor::~CCSDSDistributor() {}
|
|||||||
TcDistributor::TcMqMapIter CCSDSDistributor::selectDestination() {
|
TcDistributor::TcMqMapIter CCSDSDistributor::selectDestination() {
|
||||||
#if CCSDS_DISTRIBUTOR_DEBUGGING == 1
|
#if CCSDS_DISTRIBUTOR_DEBUGGING == 1
|
||||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||||
sif::debug << "CCSDSDistributor::selectDestination received: " <<
|
sif::debug << "CCSDSDistributor::selectDestination received: " <<
|
||||||
this->currentMessage.getStorageId().poolIndex << ", " <<
|
this->currentMessage.getStorageId().poolIndex << ", " <<
|
||||||
this->currentMessage.getStorageId().packetIndex << std::endl;
|
this->currentMessage.getStorageId().packetIndex << std::endl;
|
||||||
#else
|
#else
|
||||||
sif::printDebug("CCSDSDistributor::selectDestination received: %d, %d\n",
|
sif::printDebug("CCSDSDistributor::selectDestination received: %d, %d\n",
|
||||||
currentMessage.getStorageId().poolIndex, currentMessage.getStorageId().packetIndex);
|
currentMessage.getStorageId().poolIndex, currentMessage.getStorageId().packetIndex);
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
const uint8_t* packet = nullptr;
|
const uint8_t* packet = nullptr;
|
||||||
size_t size = 0;
|
size_t size = 0;
|
||||||
ReturnValue_t result = this->tcStore->getData(currentMessage.getStorageId(),
|
ReturnValue_t result = this->tcStore->getData(currentMessage.getStorageId(),
|
||||||
&packet, &size );
|
&packet, &size );
|
||||||
if(result != HasReturnvaluesIF::RETURN_OK) {
|
if(result != HasReturnvaluesIF::RETURN_OK) {
|
||||||
#if FSFW_VERBOSE_LEVEL >= 1
|
#if FSFW_VERBOSE_LEVEL >= 1
|
||||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||||
sif::error << "CCSDSDistributor::selectDestination: Getting data from"
|
sif::error << "CCSDSDistributor::selectDestination: Getting data from"
|
||||||
" store failed!" << std::endl;
|
" store failed!" << std::endl;
|
||||||
#else
|
#else
|
||||||
sif::printError("CCSDSDistributor::selectDestination: Getting data from"
|
sif::printError("CCSDSDistributor::selectDestination: Getting data from"
|
||||||
" store failed!\n");
|
" store failed!\n");
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
SpacePacketBase currentPacket(packet);
|
SpacePacketBase currentPacket(packet);
|
||||||
|
|
||||||
#if FSFW_CPP_OSTREAM_ENABLED == 1 && CCSDS_DISTRIBUTOR_DEBUGGING == 1
|
#if FSFW_CPP_OSTREAM_ENABLED == 1 && CCSDS_DISTRIBUTOR_DEBUGGING == 1
|
||||||
sif::info << "CCSDSDistributor::selectDestination has packet with APID " << std::hex <<
|
sif::info << "CCSDSDistributor::selectDestination has packet with APID " << std::hex <<
|
||||||
currentPacket.getAPID() << std::dec << std::endl;
|
currentPacket.getAPID() << std::dec << std::endl;
|
||||||
#endif
|
#endif
|
||||||
TcMqMapIter position = this->queueMap.find(currentPacket.getAPID());
|
TcMqMapIter position = this->queueMap.find(currentPacket.getAPID());
|
||||||
if ( position != this->queueMap.end() ) {
|
if ( position != this->queueMap.end() ) {
|
||||||
return position;
|
return position;
|
||||||
} else {
|
} else {
|
||||||
//The APID was not found. Forward packet to main SW-APID anyway to
|
//The APID was not found. Forward packet to main SW-APID anyway to
|
||||||
// create acceptance failure report.
|
// create acceptance failure report.
|
||||||
return this->queueMap.find( this->defaultApid );
|
return this->queueMap.find( this->defaultApid );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
MessageQueueId_t CCSDSDistributor::getRequestQueue() {
|
MessageQueueId_t CCSDSDistributor::getRequestQueue() {
|
||||||
return tcQueue->getId();
|
return tcQueue->getId();
|
||||||
}
|
}
|
||||||
|
|
||||||
ReturnValue_t CCSDSDistributor::registerApplication(
|
ReturnValue_t CCSDSDistributor::registerApplication(
|
||||||
AcceptsTelecommandsIF* application) {
|
AcceptsTelecommandsIF* application) {
|
||||||
ReturnValue_t returnValue = RETURN_OK;
|
ReturnValue_t returnValue = RETURN_OK;
|
||||||
auto insertPair = this->queueMap.emplace(application->getIdentifier(),
|
auto insertPair = this->queueMap.emplace(application->getIdentifier(),
|
||||||
application->getRequestQueue());
|
application->getRequestQueue());
|
||||||
if(not insertPair.second) {
|
if(not insertPair.second) {
|
||||||
returnValue = RETURN_FAILED;
|
returnValue = RETURN_FAILED;
|
||||||
}
|
}
|
||||||
return returnValue;
|
return returnValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
ReturnValue_t CCSDSDistributor::registerApplication(uint16_t apid,
|
ReturnValue_t CCSDSDistributor::registerApplication(uint16_t apid,
|
||||||
MessageQueueId_t id) {
|
MessageQueueId_t id) {
|
||||||
ReturnValue_t returnValue = RETURN_OK;
|
ReturnValue_t returnValue = RETURN_OK;
|
||||||
auto insertPair = this->queueMap.emplace(apid, id);
|
auto insertPair = this->queueMap.emplace(apid, id);
|
||||||
if(not insertPair.second) {
|
if(not insertPair.second) {
|
||||||
returnValue = RETURN_FAILED;
|
returnValue = RETURN_FAILED;
|
||||||
}
|
}
|
||||||
return returnValue;
|
return returnValue;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
uint16_t CCSDSDistributor::getIdentifier() {
|
uint16_t CCSDSDistributor::getIdentifier() {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
ReturnValue_t CCSDSDistributor::initialize() {
|
ReturnValue_t CCSDSDistributor::initialize() {
|
||||||
ReturnValue_t status = this->TcDistributor::initialize();
|
ReturnValue_t status = this->TcDistributor::initialize();
|
||||||
this->tcStore = ObjectManager::instance()->get<StorageManagerIF>( objects::TC_STORE );
|
this->tcStore = ObjectManager::instance()->get<StorageManagerIF>( objects::TC_STORE );
|
||||||
if (this->tcStore == nullptr) {
|
if (this->tcStore == nullptr) {
|
||||||
#if FSFW_VERBOSE_LEVEL >= 1
|
#if FSFW_VERBOSE_LEVEL >= 1
|
||||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||||
sif::error << "CCSDSDistributor::initialize: Could not initialize"
|
sif::error << "CCSDSDistributor::initialize: Could not initialize"
|
||||||
" TC store!" << std::endl;
|
" TC store!" << std::endl;
|
||||||
#else
|
#else
|
||||||
sif::printError("CCSDSDistributor::initialize: Could not initialize"
|
sif::printError("CCSDSDistributor::initialize: Could not initialize"
|
||||||
" TC store!\n");
|
" TC store!\n");
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
status = RETURN_FAILED;
|
status = RETURN_FAILED;
|
||||||
}
|
}
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
ReturnValue_t CCSDSDistributor::callbackAfterSending(
|
ReturnValue_t CCSDSDistributor::callbackAfterSending(
|
||||||
ReturnValue_t queueStatus) {
|
ReturnValue_t queueStatus) {
|
||||||
if (queueStatus != RETURN_OK) {
|
if (queueStatus != RETURN_OK) {
|
||||||
tcStore->deleteData(currentMessage.getStorageId());
|
tcStore->deleteData(currentMessage.getStorageId());
|
||||||
}
|
}
|
||||||
return RETURN_OK;
|
return RETURN_OK;
|
||||||
}
|
}
|
||||||
|
@ -15,56 +15,57 @@
|
|||||||
* The Secondary Header (with Service/Subservice) is ignored.
|
* The Secondary Header (with Service/Subservice) is ignored.
|
||||||
* @ingroup tc_distribution
|
* @ingroup tc_distribution
|
||||||
*/
|
*/
|
||||||
class CCSDSDistributor : public TcDistributor,
|
class CCSDSDistributor:
|
||||||
public CCSDSDistributorIF,
|
public TcDistributor,
|
||||||
public AcceptsTelecommandsIF {
|
public CCSDSDistributorIF,
|
||||||
|
public AcceptsTelecommandsIF {
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
* @brief The constructor sets the default APID and calls the
|
* @brief The constructor sets the default APID and calls the
|
||||||
* TcDistributor ctor with a certain object id.
|
* TcDistributor ctor with a certain object id.
|
||||||
* @details
|
* @details
|
||||||
* @c tcStore is set in the @c initialize method.
|
* @c tcStore is set in the @c initialize method.
|
||||||
* @param setDefaultApid The default APID, where packets with unknown
|
* @param setDefaultApid The default APID, where packets with unknown
|
||||||
* destination are sent to.
|
* destination are sent to.
|
||||||
*/
|
*/
|
||||||
CCSDSDistributor(uint16_t setDefaultApid, object_id_t setObjectId);
|
CCSDSDistributor(uint16_t setDefaultApid, object_id_t setObjectId);
|
||||||
/**
|
/**
|
||||||
* The destructor is empty.
|
* The destructor is empty.
|
||||||
*/
|
*/
|
||||||
virtual ~CCSDSDistributor();
|
virtual ~CCSDSDistributor();
|
||||||
|
|
||||||
MessageQueueId_t getRequestQueue() override;
|
MessageQueueId_t getRequestQueue() override;
|
||||||
ReturnValue_t registerApplication( uint16_t apid,
|
ReturnValue_t registerApplication( uint16_t apid,
|
||||||
MessageQueueId_t id) override;
|
MessageQueueId_t id) override;
|
||||||
ReturnValue_t registerApplication(
|
ReturnValue_t registerApplication(
|
||||||
AcceptsTelecommandsIF* application) override;
|
AcceptsTelecommandsIF* application) override;
|
||||||
uint16_t getIdentifier() override;
|
uint16_t getIdentifier() override;
|
||||||
ReturnValue_t initialize() override;
|
ReturnValue_t initialize() override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
/**
|
/**
|
||||||
* This implementation checks if an application with fitting APID has
|
* This implementation checks if an application with fitting APID has
|
||||||
* registered and forwards the packet to the according message queue.
|
* registered and forwards the packet to the according message queue.
|
||||||
* If the packet is not found, it returns the queue to @c defaultApid,
|
* If the packet is not found, it returns the queue to @c defaultApid,
|
||||||
* where a Acceptance Failure message should be generated.
|
* where a Acceptance Failure message should be generated.
|
||||||
* @return Iterator to map entry of found APID or iterator to default APID.
|
* @return Iterator to map entry of found APID or iterator to default APID.
|
||||||
*/
|
*/
|
||||||
TcMqMapIter selectDestination() override;
|
TcMqMapIter selectDestination() override;
|
||||||
/**
|
/**
|
||||||
* The callback here handles the generation of acceptance
|
* The callback here handles the generation of acceptance
|
||||||
* success/failure messages.
|
* success/failure messages.
|
||||||
*/
|
*/
|
||||||
ReturnValue_t callbackAfterSending( ReturnValue_t queueStatus ) override;
|
ReturnValue_t callbackAfterSending( ReturnValue_t queueStatus ) override;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The default APID, where packets with unknown APID are sent to.
|
* The default APID, where packets with unknown APID are sent to.
|
||||||
*/
|
*/
|
||||||
uint16_t defaultApid;
|
uint16_t defaultApid;
|
||||||
/**
|
/**
|
||||||
* A reference to the TC storage must be maintained, as this class handles
|
* A reference to the TC storage must be maintained, as this class handles
|
||||||
* pure Space Packets and there exists no SpacePacketStored class.
|
* pure Space Packets and there exists no SpacePacketStored class.
|
||||||
*/
|
*/
|
||||||
StorageManagerIF* tcStore = nullptr;
|
StorageManagerIF* tcStore = nullptr;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -13,31 +13,30 @@
|
|||||||
*/
|
*/
|
||||||
class CCSDSDistributorIF {
|
class CCSDSDistributorIF {
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
* With this call, a class implementing the CCSDSApplicationIF can register
|
* With this call, a class implementing the CCSDSApplicationIF can register
|
||||||
* at the distributor.
|
* at the distributor.
|
||||||
* @param application A pointer to the Application to register.
|
* @param application A pointer to the Application to register.
|
||||||
* @return - @c RETURN_OK on success,
|
* @return - @c RETURN_OK on success,
|
||||||
* - @c RETURN_FAILED on failure.
|
* - @c RETURN_FAILED on failure.
|
||||||
*/
|
*/
|
||||||
virtual ReturnValue_t registerApplication(
|
virtual ReturnValue_t registerApplication(
|
||||||
AcceptsTelecommandsIF* application) = 0;
|
AcceptsTelecommandsIF* application) = 0;
|
||||||
/**
|
/**
|
||||||
* With this call, other Applications can register to the CCSDS distributor.
|
* With this call, other Applications can register to the CCSDS distributor.
|
||||||
* This is done by passing an APID and a MessageQueueId to the method.
|
* This is done by passing an APID and a MessageQueueId to the method.
|
||||||
* @param apid The APID to register.
|
* @param apid The APID to register.
|
||||||
* @param id The MessageQueueId of the message queue to send the
|
* @param id The MessageQueueId of the message queue to send the
|
||||||
* TC Packets to.
|
* TC Packets to.
|
||||||
* @return - @c RETURN_OK on success,
|
* @return - @c RETURN_OK on success,
|
||||||
* - @c RETURN_FAILED on failure.
|
* - @c RETURN_FAILED on failure.
|
||||||
*/
|
*/
|
||||||
virtual ReturnValue_t registerApplication( uint16_t apid,
|
virtual ReturnValue_t registerApplication( uint16_t apid,
|
||||||
MessageQueueId_t id) = 0;
|
MessageQueueId_t id) = 0;
|
||||||
/**
|
/**
|
||||||
* The empty virtual destructor.
|
* The empty virtual destructor.
|
||||||
*/
|
*/
|
||||||
virtual ~CCSDSDistributorIF() {
|
virtual ~CCSDSDistributorIF() {}
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
147
src/fsfw/tcdistribution/CFDPDistributor.cpp
Normal file
147
src/fsfw/tcdistribution/CFDPDistributor.cpp
Normal file
@ -0,0 +1,147 @@
|
|||||||
|
#include "fsfw/tcdistribution/CCSDSDistributorIF.h"
|
||||||
|
#include "fsfw/tcdistribution/CFDPDistributor.h"
|
||||||
|
|
||||||
|
#include "fsfw/tmtcpacket/cfdp/CFDPPacketStored.h"
|
||||||
|
|
||||||
|
#include "fsfw/objectmanager/ObjectManager.h"
|
||||||
|
|
||||||
|
#ifndef FSFW_CFDP_DISTRIBUTOR_DEBUGGING
|
||||||
|
#define FSFW_CFDP_DISTRIBUTOR_DEBUGGING 1
|
||||||
|
#endif
|
||||||
|
|
||||||
|
CFDPDistributor::CFDPDistributor(uint16_t setApid, object_id_t setObjectId,
|
||||||
|
object_id_t setPacketSource):
|
||||||
|
TcDistributor(setObjectId), apid(setApid), checker(setApid),
|
||||||
|
tcStatus(RETURN_FAILED), packetSource(setPacketSource) {
|
||||||
|
}
|
||||||
|
|
||||||
|
CFDPDistributor::~CFDPDistributor() {}
|
||||||
|
|
||||||
|
CFDPDistributor::TcMqMapIter CFDPDistributor::selectDestination() {
|
||||||
|
#if FSFW_CFDP_DISTRIBUTOR_DEBUGGING == 1
|
||||||
|
store_address_t storeId = this->currentMessage.getStorageId();
|
||||||
|
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||||
|
sif::debug << "CFDPDistributor::handlePacket received: " << storeId.poolIndex << ", " <<
|
||||||
|
storeId.packetIndex << std::endl;
|
||||||
|
#else
|
||||||
|
sif::printDebug("CFDPDistributor::handlePacket received: %d, %d\n", storeId.poolIndex,
|
||||||
|
storeId.packetIndex);
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
TcMqMapIter queueMapIt = this->queueMap.end();
|
||||||
|
if(this->currentPacket == nullptr) {
|
||||||
|
return queueMapIt;
|
||||||
|
}
|
||||||
|
this->currentPacket->setStoreAddress(this->currentMessage.getStorageId());
|
||||||
|
if (currentPacket->getWholeData() != nullptr) {
|
||||||
|
tcStatus = checker.checkPacket(currentPacket);
|
||||||
|
if(tcStatus != HasReturnvaluesIF::RETURN_OK) {
|
||||||
|
#if FSFW_VERBOSE_LEVEL >= 1
|
||||||
|
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||||
|
sif::debug << "PUSDistributor::handlePacket: Packet format invalid, code " <<
|
||||||
|
static_cast<int>(tcStatus) << std::endl;
|
||||||
|
#else
|
||||||
|
sif::printDebug("PUSDistributor::handlePacket: Packet format invalid, code %d\n",
|
||||||
|
static_cast<int>(tcStatus));
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
queueMapIt = this->queueMap.find(0);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
tcStatus = PACKET_LOST;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (queueMapIt == this->queueMap.end()) {
|
||||||
|
tcStatus = DESTINATION_NOT_FOUND;
|
||||||
|
#if FSFW_VERBOSE_LEVEL >= 1
|
||||||
|
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||||
|
sif::debug << "CFDPDistributor::handlePacket: Destination not found" << std::endl;
|
||||||
|
#else
|
||||||
|
sif::printDebug("CFDPDistributor::handlePacket: Destination not found\n");
|
||||||
|
#endif /* !FSFW_CPP_OSTREAM_ENABLED == 1 */
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
if (tcStatus != RETURN_OK) {
|
||||||
|
return this->queueMap.end();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return queueMapIt;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
ReturnValue_t CFDPDistributor::registerHandler(AcceptsTelecommandsIF* handler) {
|
||||||
|
uint16_t handlerId = handler->getIdentifier(); //should be 0, because CFDPHandler does not set a set a service-ID
|
||||||
|
#if FSFW_CFDP_DISTRIBUTOR_DEBUGGING == 1
|
||||||
|
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||||
|
sif::info << "CFDPDistributor::registerHandler: Handler ID: " << static_cast<int>(handlerId) << std::endl;
|
||||||
|
#else
|
||||||
|
sif::printInfo("CFDPDistributor::registerHandler: Handler ID: %d\n", static_cast<int>(handlerId));
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
MessageQueueId_t queue = handler->getRequestQueue();
|
||||||
|
auto returnPair = queueMap.emplace(handlerId, queue);
|
||||||
|
if (not returnPair.second) {
|
||||||
|
#if FSFW_VERBOSE_LEVEL >= 1
|
||||||
|
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||||
|
sif::error << "CFDPDistributor::registerHandler: Service ID already"
|
||||||
|
" exists in map" << std::endl;
|
||||||
|
#else
|
||||||
|
sif::printError("CFDPDistributor::registerHandler: Service ID already exists in map\n");
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
return SERVICE_ID_ALREADY_EXISTS;
|
||||||
|
}
|
||||||
|
return HasReturnvaluesIF::RETURN_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
MessageQueueId_t CFDPDistributor::getRequestQueue() {
|
||||||
|
return tcQueue->getId();
|
||||||
|
}
|
||||||
|
|
||||||
|
//ReturnValue_t CFDPDistributor::callbackAfterSending(ReturnValue_t queueStatus) {
|
||||||
|
// if (queueStatus != RETURN_OK) {
|
||||||
|
// tcStatus = queueStatus;
|
||||||
|
// }
|
||||||
|
// if (tcStatus != RETURN_OK) {
|
||||||
|
// this->verifyChannel.sendFailureReport(tc_verification::ACCEPTANCE_FAILURE,
|
||||||
|
// currentPacket, tcStatus);
|
||||||
|
// // A failed packet is deleted immediately after reporting,
|
||||||
|
// // otherwise it will block memory.
|
||||||
|
// currentPacket->deletePacket();
|
||||||
|
// return RETURN_FAILED;
|
||||||
|
// } else {
|
||||||
|
// this->verifyChannel.sendSuccessReport(tc_verification::ACCEPTANCE_SUCCESS,
|
||||||
|
// currentPacket);
|
||||||
|
// return RETURN_OK;
|
||||||
|
// }
|
||||||
|
//}
|
||||||
|
|
||||||
|
uint16_t CFDPDistributor::getIdentifier() {
|
||||||
|
return this->apid;
|
||||||
|
}
|
||||||
|
|
||||||
|
ReturnValue_t CFDPDistributor::initialize() {
|
||||||
|
currentPacket = new CFDPPacketStored();
|
||||||
|
if(currentPacket == nullptr) {
|
||||||
|
// Should not happen, memory allocation failed!
|
||||||
|
return ObjectManagerIF::CHILD_INIT_FAILED;
|
||||||
|
}
|
||||||
|
|
||||||
|
CCSDSDistributorIF* ccsdsDistributor = ObjectManager::instance()->get<CCSDSDistributorIF>(
|
||||||
|
packetSource);
|
||||||
|
if (ccsdsDistributor == nullptr) {
|
||||||
|
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||||
|
sif::error << "CFDPDistributor::initialize: Packet source invalid" << std::endl;
|
||||||
|
sif::error << " Make sure it exists and implements CCSDSDistributorIF!" << std::endl;
|
||||||
|
#else
|
||||||
|
sif::printError("CFDPDistributor::initialize: Packet source invalid\n");
|
||||||
|
sif::printError("Make sure it exists and implements CCSDSDistributorIF\n");
|
||||||
|
#endif
|
||||||
|
return RETURN_FAILED;
|
||||||
|
}
|
||||||
|
return ccsdsDistributor->registerApplication(this);
|
||||||
|
}
|
72
src/fsfw/tcdistribution/CFDPDistributor.h
Normal file
72
src/fsfw/tcdistribution/CFDPDistributor.h
Normal file
@ -0,0 +1,72 @@
|
|||||||
|
#ifndef FSFW_TCDISTRIBUTION_CFDPDISTRIBUTOR_H_
|
||||||
|
#define FSFW_TCDISTRIBUTION_CFDPDISTRIBUTOR_H_
|
||||||
|
|
||||||
|
#include <fsfw/tcdistribution/TcPacketCheckCFDP.h>
|
||||||
|
#include "CFDPDistributorIF.h"
|
||||||
|
#include "TcDistributor.h"
|
||||||
|
#include "../tmtcpacket/cfdp/CFDPPacketStored.h"
|
||||||
|
#include "../returnvalues/HasReturnvaluesIF.h"
|
||||||
|
#include "../tmtcservices/AcceptsTelecommandsIF.h"
|
||||||
|
#include "../tmtcservices/VerificationReporter.h"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This class accepts CFDP Telecommands and forwards them to Application
|
||||||
|
* services.
|
||||||
|
* @ingroup tc_distribution
|
||||||
|
*/
|
||||||
|
class CFDPDistributor:
|
||||||
|
public TcDistributor,
|
||||||
|
public CFDPDistributorIF,
|
||||||
|
public AcceptsTelecommandsIF {
|
||||||
|
public:
|
||||||
|
/**
|
||||||
|
* The ctor passes @c set_apid to the checker class and calls the
|
||||||
|
* TcDistribution ctor with a certain object id.
|
||||||
|
* @param setApid The APID of this receiving Application.
|
||||||
|
* @param setObjectId Object ID of the distributor itself
|
||||||
|
* @param setPacketSource Object ID of the source of TC packets.
|
||||||
|
* Must implement CCSDSDistributorIF.
|
||||||
|
*/
|
||||||
|
CFDPDistributor(uint16_t setApid, object_id_t setObjectId,
|
||||||
|
object_id_t setPacketSource);
|
||||||
|
/**
|
||||||
|
* The destructor is empty.
|
||||||
|
*/
|
||||||
|
virtual ~CFDPDistributor();
|
||||||
|
ReturnValue_t registerHandler(AcceptsTelecommandsIF* handler) override;
|
||||||
|
MessageQueueId_t getRequestQueue() override;
|
||||||
|
ReturnValue_t initialize() override;
|
||||||
|
uint16_t getIdentifier() override;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
uint16_t apid;
|
||||||
|
/**
|
||||||
|
* The currently handled packet is stored here.
|
||||||
|
*/
|
||||||
|
CFDPPacketStored* currentPacket = nullptr;
|
||||||
|
TcPacketCheckCFDP checker;
|
||||||
|
/**
|
||||||
|
* With this variable, the current check status is stored to generate
|
||||||
|
* acceptance messages later.
|
||||||
|
*/
|
||||||
|
ReturnValue_t tcStatus;
|
||||||
|
|
||||||
|
const object_id_t packetSource;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method reads the packet service, checks if such a service is
|
||||||
|
* registered and forwards the packet to the destination.
|
||||||
|
* It also initiates the formal packet check and sending of verification
|
||||||
|
* messages.
|
||||||
|
* @return Iterator to map entry of found service id
|
||||||
|
* or iterator to @c map.end().
|
||||||
|
*/
|
||||||
|
TcMqMapIter selectDestination() override;
|
||||||
|
/**
|
||||||
|
* The callback here handles the generation of acceptance
|
||||||
|
* success/failure messages.
|
||||||
|
*/
|
||||||
|
//ReturnValue_t callbackAfterSending(ReturnValue_t queueStatus) override;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif /* FSFW_TCDISTRIBUTION_CFDPDISTRIBUTOR_H_ */
|
27
src/fsfw/tcdistribution/CFDPDistributorIF.h
Normal file
27
src/fsfw/tcdistribution/CFDPDistributorIF.h
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
#ifndef FSFW_TCDISTRIBUTION_CFDPDISTRIBUTORIF_H_
|
||||||
|
#define FSFW_TCDISTRIBUTION_CFDPDISTRIBUTORIF_H_
|
||||||
|
|
||||||
|
#include "../tmtcservices/AcceptsTelecommandsIF.h"
|
||||||
|
#include "../ipc/MessageQueueSenderIF.h"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This interface allows CFDP Services to register themselves at a CFDP Distributor.
|
||||||
|
* @ingroup tc_distribution
|
||||||
|
*/
|
||||||
|
class CFDPDistributorIF {
|
||||||
|
public:
|
||||||
|
/**
|
||||||
|
* The empty virtual destructor.
|
||||||
|
*/
|
||||||
|
virtual ~CFDPDistributorIF() {
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* With this method, Handlers can register themselves at the CFDP Distributor.
|
||||||
|
* @param handler A pointer to the registering Handler.
|
||||||
|
* @return - @c RETURN_OK on success,
|
||||||
|
* - @c RETURN_FAILED on failure.
|
||||||
|
*/
|
||||||
|
virtual ReturnValue_t registerHandler(AcceptsTelecommandsIF* handler) = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif /* FSFW_TCDISTRIBUTION_CFDPDISTRIBUTORIF_H_ */
|
@ -2,5 +2,8 @@ target_sources(${LIB_FSFW_NAME} PRIVATE
|
|||||||
CCSDSDistributor.cpp
|
CCSDSDistributor.cpp
|
||||||
PUSDistributor.cpp
|
PUSDistributor.cpp
|
||||||
TcDistributor.cpp
|
TcDistributor.cpp
|
||||||
TcPacketCheck.cpp
|
TcPacketCheckPUS.cpp
|
||||||
|
TcPacketCheckCFDP.cpp
|
||||||
|
CFDPDistributor.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
#include "PUSDistributorIF.h"
|
#include "PUSDistributorIF.h"
|
||||||
#include "TcDistributor.h"
|
#include "TcDistributor.h"
|
||||||
#include "TcPacketCheck.h"
|
#include "TcPacketCheckPUS.h"
|
||||||
|
|
||||||
#include "fsfw/tmtcpacket/pus/tc.h"
|
#include "fsfw/tmtcpacket/pus/tc.h"
|
||||||
#include "fsfw/returnvalues/HasReturnvaluesIF.h"
|
#include "fsfw/returnvalues/HasReturnvaluesIF.h"
|
||||||
@ -17,65 +17,65 @@
|
|||||||
* @ingroup tc_distribution
|
* @ingroup tc_distribution
|
||||||
*/
|
*/
|
||||||
class PUSDistributor: public TcDistributor,
|
class PUSDistributor: public TcDistributor,
|
||||||
public PUSDistributorIF,
|
public PUSDistributorIF,
|
||||||
public AcceptsTelecommandsIF {
|
public AcceptsTelecommandsIF {
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
* The ctor passes @c set_apid to the checker class and calls the
|
* The ctor passes @c set_apid to the checker class and calls the
|
||||||
* TcDistribution ctor with a certain object id.
|
* TcDistribution ctor with a certain object id.
|
||||||
* @param setApid The APID of this receiving Application.
|
* @param setApid The APID of this receiving Application.
|
||||||
* @param setObjectId Object ID of the distributor itself
|
* @param setObjectId Object ID of the distributor itself
|
||||||
* @param setPacketSource Object ID of the source of TC packets.
|
* @param setPacketSource Object ID of the source of TC packets.
|
||||||
* Must implement CCSDSDistributorIF.
|
* Must implement CCSDSDistributorIF.
|
||||||
*/
|
*/
|
||||||
PUSDistributor(uint16_t setApid, object_id_t setObjectId,
|
PUSDistributor(uint16_t setApid, object_id_t setObjectId,
|
||||||
object_id_t setPacketSource);
|
object_id_t setPacketSource);
|
||||||
/**
|
/**
|
||||||
* The destructor is empty.
|
* The destructor is empty.
|
||||||
*/
|
*/
|
||||||
virtual ~PUSDistributor();
|
virtual ~PUSDistributor();
|
||||||
ReturnValue_t registerService(AcceptsTelecommandsIF* service) override;
|
ReturnValue_t registerService(AcceptsTelecommandsIF* service) override;
|
||||||
MessageQueueId_t getRequestQueue() override;
|
MessageQueueId_t getRequestQueue() override;
|
||||||
ReturnValue_t initialize() override;
|
ReturnValue_t initialize() override;
|
||||||
uint16_t getIdentifier() override;
|
uint16_t getIdentifier() override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
/**
|
/**
|
||||||
* This attribute contains the class, that performs a formal packet check.
|
* This attribute contains the class, that performs a formal packet check.
|
||||||
*/
|
*/
|
||||||
TcPacketCheck checker;
|
TcPacketCheckPUS checker;
|
||||||
/**
|
/**
|
||||||
* With this class, verification messages are sent to the
|
* With this class, verification messages are sent to the
|
||||||
* TC Verification service.
|
* TC Verification service.
|
||||||
*/
|
*/
|
||||||
VerificationReporter verifyChannel;
|
VerificationReporter verifyChannel;
|
||||||
/**
|
/**
|
||||||
* The currently handled packet is stored here.
|
* The currently handled packet is stored here.
|
||||||
*/
|
*/
|
||||||
TcPacketStoredPus* currentPacket = nullptr;
|
TcPacketStoredPus* currentPacket = nullptr;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* With this variable, the current check status is stored to generate
|
* With this variable, the current check status is stored to generate
|
||||||
* acceptance messages later.
|
* acceptance messages later.
|
||||||
*/
|
*/
|
||||||
ReturnValue_t tcStatus;
|
ReturnValue_t tcStatus;
|
||||||
|
|
||||||
const object_id_t packetSource;
|
const object_id_t packetSource;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method reads the packet service, checks if such a service is
|
* This method reads the packet service, checks if such a service is
|
||||||
* registered and forwards the packet to the destination.
|
* registered and forwards the packet to the destination.
|
||||||
* It also initiates the formal packet check and sending of verification
|
* It also initiates the formal packet check and sending of verification
|
||||||
* messages.
|
* messages.
|
||||||
* @return Iterator to map entry of found service id
|
* @return Iterator to map entry of found service id
|
||||||
* or iterator to @c map.end().
|
* or iterator to @c map.end().
|
||||||
*/
|
*/
|
||||||
TcMqMapIter selectDestination() override;
|
TcMqMapIter selectDestination() override;
|
||||||
/**
|
/**
|
||||||
* The callback here handles the generation of acceptance
|
* The callback here handles the generation of acceptance
|
||||||
* success/failure messages.
|
* success/failure messages.
|
||||||
*/
|
*/
|
||||||
ReturnValue_t callbackAfterSending(ReturnValue_t queueStatus) override;
|
ReturnValue_t callbackAfterSending(ReturnValue_t queueStatus) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* FSFW_TCDISTRIBUTION_PUSDISTRIBUTOR_H_ */
|
#endif /* FSFW_TCDISTRIBUTION_PUSDISTRIBUTOR_H_ */
|
||||||
|
@ -10,18 +10,18 @@
|
|||||||
*/
|
*/
|
||||||
class PUSDistributorIF {
|
class PUSDistributorIF {
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
* The empty virtual destructor.
|
* The empty virtual destructor.
|
||||||
*/
|
*/
|
||||||
virtual ~PUSDistributorIF() {
|
virtual ~PUSDistributorIF() {
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* With this method, Services can register themselves at the PUS Distributor.
|
* With this method, Services can register themselves at the PUS Distributor.
|
||||||
* @param service A pointer to the registering Service.
|
* @param service A pointer to the registering Service.
|
||||||
* @return - @c RETURN_OK on success,
|
* @return - @c RETURN_OK on success,
|
||||||
* - @c RETURN_FAILED on failure.
|
* - @c RETURN_FAILED on failure.
|
||||||
*/
|
*/
|
||||||
virtual ReturnValue_t registerService( AcceptsTelecommandsIF* service ) = 0;
|
virtual ReturnValue_t registerService( AcceptsTelecommandsIF* service ) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* FSFW_TCDISTRIBUTION_PUSDISTRIBUTORIF_H_ */
|
#endif /* FSFW_TCDISTRIBUTION_PUSDISTRIBUTORIF_H_ */
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#include "fsfw/tcdistribution/TcPacketCheck.h"
|
#include "fsfw/tcdistribution/TcPacketCheckPUS.h"
|
||||||
|
|
||||||
#include "fsfw/globalfunctions/CRC.h"
|
#include "fsfw/globalfunctions/CRC.h"
|
||||||
#include "fsfw/tmtcpacket/pus/tc/TcPacketBase.h"
|
#include "fsfw/tmtcpacket/pus/tc/TcPacketBase.h"
|
||||||
@ -7,10 +7,10 @@
|
|||||||
#include "fsfw/storagemanager/StorageManagerIF.h"
|
#include "fsfw/storagemanager/StorageManagerIF.h"
|
||||||
#include "fsfw/tmtcservices/VerificationCodes.h"
|
#include "fsfw/tmtcservices/VerificationCodes.h"
|
||||||
|
|
||||||
TcPacketCheck::TcPacketCheck(uint16_t setApid): apid(setApid) {
|
TcPacketCheckPUS::TcPacketCheckPUS(uint16_t setApid): apid(setApid) {
|
||||||
}
|
}
|
||||||
|
|
||||||
ReturnValue_t TcPacketCheck::checkPacket(TcPacketStoredBase* currentPacket) {
|
ReturnValue_t TcPacketCheckPUS::checkPacket(TcPacketStoredBase* currentPacket) {
|
||||||
TcPacketBase* tcPacketBase = currentPacket->getPacketBase();
|
TcPacketBase* tcPacketBase = currentPacket->getPacketBase();
|
||||||
if(tcPacketBase == nullptr) {
|
if(tcPacketBase == nullptr) {
|
||||||
return RETURN_FAILED;
|
return RETURN_FAILED;
|
||||||
@ -41,6 +41,6 @@ ReturnValue_t TcPacketCheck::checkPacket(TcPacketStoredBase* currentPacket) {
|
|||||||
return RETURN_OK;
|
return RETURN_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint16_t TcPacketCheck::getApid() const {
|
uint16_t TcPacketCheckPUS::getApid() const {
|
||||||
return apid;
|
return apid;
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
#ifndef FSFW_TCDISTRIBUTION_TCPACKETCHECK_H_
|
#ifndef FSFW_TCDISTRIBUTION_TCPACKETCHECKPUS_H_
|
||||||
#define FSFW_TCDISTRIBUTION_TCPACKETCHECK_H_
|
#define FSFW_TCDISTRIBUTION_TCPACKETCHECKPUS_H_
|
||||||
|
|
||||||
|
#include "TcPacketCheckIF.h"
|
||||||
|
|
||||||
#include "fsfw/FSFW.h"
|
#include "fsfw/FSFW.h"
|
||||||
#include "fsfw/returnvalues/HasReturnvaluesIF.h"
|
#include "fsfw/returnvalues/HasReturnvaluesIF.h"
|
||||||
@ -12,7 +14,9 @@ class TcPacketStoredBase;
|
|||||||
* Currently, it only checks if the APID and CRC are correct.
|
* Currently, it only checks if the APID and CRC are correct.
|
||||||
* @ingroup tc_distribution
|
* @ingroup tc_distribution
|
||||||
*/
|
*/
|
||||||
class TcPacketCheck : public HasReturnvaluesIF {
|
class TcPacketCheckPUS :
|
||||||
|
public TcPacketCheckIF,
|
||||||
|
public HasReturnvaluesIF {
|
||||||
protected:
|
protected:
|
||||||
/**
|
/**
|
||||||
* Describes the version number a packet must have to pass.
|
* Describes the version number a packet must have to pass.
|
||||||
@ -49,18 +53,11 @@ public:
|
|||||||
* The constructor only sets the APID attribute.
|
* The constructor only sets the APID attribute.
|
||||||
* @param set_apid The APID to set.
|
* @param set_apid The APID to set.
|
||||||
*/
|
*/
|
||||||
TcPacketCheck(uint16_t setApid);
|
TcPacketCheckPUS(uint16_t setApid);
|
||||||
/**
|
|
||||||
* This is the actual method to formally check a certain Telecommand Packet.
|
ReturnValue_t checkPacket(TcPacketStoredBase* currentPacket) override;
|
||||||
* The packet's Application Data can not be checked here.
|
|
||||||
* @param current_packet The packt to check
|
|
||||||
* @return - @c RETURN_OK on success.
|
|
||||||
* - @c INCORRECT_CHECKSUM if checksum is invalid.
|
|
||||||
* - @c ILLEGAL_APID if APID does not match.
|
|
||||||
*/
|
|
||||||
ReturnValue_t checkPacket(TcPacketStoredBase* currentPacket);
|
|
||||||
|
|
||||||
uint16_t getApid() const;
|
uint16_t getApid() const;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* FSFW_TCDISTRIBUTION_TCPACKETCHECK_H_ */
|
#endif /* FSFW_TCDISTRIBUTION_TCPACKETCHECKPUS_H_ */
|
||||||
|
13
src/fsfw/tcdistribution/TcPacketCheckCFDP.cpp
Normal file
13
src/fsfw/tcdistribution/TcPacketCheckCFDP.cpp
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
#include "fsfw/tcdistribution/TcPacketCheckCFDP.h"
|
||||||
|
#include "fsfw/tmtcpacket/cfdp/CFDPPacketStored.h"
|
||||||
|
|
||||||
|
TcPacketCheckCFDP::TcPacketCheckCFDP(uint16_t setApid): apid(setApid) {
|
||||||
|
}
|
||||||
|
|
||||||
|
ReturnValue_t TcPacketCheckCFDP::checkPacket(SpacePacketBase* currentPacket) {
|
||||||
|
return RETURN_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint16_t TcPacketCheckCFDP::getApid() const {
|
||||||
|
return apid;
|
||||||
|
}
|
35
src/fsfw/tcdistribution/TcPacketCheckCFDP.h
Normal file
35
src/fsfw/tcdistribution/TcPacketCheckCFDP.h
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
#ifndef FSFW_TCDISTRIBUTION_TCPACKETCHECKCFDP_H_
|
||||||
|
#define FSFW_TCDISTRIBUTION_TCPACKETCHECKCFDP_H_
|
||||||
|
|
||||||
|
#include "TcPacketCheckIF.h"
|
||||||
|
|
||||||
|
#include "fsfw/FSFW.h"
|
||||||
|
|
||||||
|
class CFDPPacketStored;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This class performs a formal packet check for incoming CFDP Packets.
|
||||||
|
* @ingroup tc_distribution
|
||||||
|
*/
|
||||||
|
class TcPacketCheckCFDP :
|
||||||
|
public TcPacketCheckIF,
|
||||||
|
public HasReturnvaluesIF {
|
||||||
|
protected:
|
||||||
|
/**
|
||||||
|
* The packet id each correct packet should have.
|
||||||
|
* It is composed of the APID and some static fields.
|
||||||
|
*/
|
||||||
|
uint16_t apid;
|
||||||
|
public:
|
||||||
|
/**
|
||||||
|
* The constructor only sets the APID attribute.
|
||||||
|
* @param set_apid The APID to set.
|
||||||
|
*/
|
||||||
|
TcPacketCheckCFDP(uint16_t setApid);
|
||||||
|
|
||||||
|
ReturnValue_t checkPacket(SpacePacketBase* currentPacket) override;
|
||||||
|
|
||||||
|
uint16_t getApid() const;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif /* FSFW_TCDISTRIBUTION_TCPACKETCHECKCFDP_H_ */
|
31
src/fsfw/tcdistribution/TcPacketCheckIF.h
Normal file
31
src/fsfw/tcdistribution/TcPacketCheckIF.h
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
#ifndef FSFW_TCDISTRIBUTION_TCPACKETCHECKIF_H_
|
||||||
|
#define FSFW_TCDISTRIBUTION_TCPACKETCHECKIF_H_
|
||||||
|
|
||||||
|
#include "../returnvalues/HasReturnvaluesIF.h"
|
||||||
|
|
||||||
|
class SpacePacketBase;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This interface is used by PacketCheckers for PUS packets and CFDP packets .
|
||||||
|
* @ingroup tc_distribution
|
||||||
|
*/
|
||||||
|
class TcPacketCheckIF {
|
||||||
|
public:
|
||||||
|
/**
|
||||||
|
* The empty virtual destructor.
|
||||||
|
*/
|
||||||
|
virtual ~TcPacketCheckIF() {
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This is the actual method to formally check a certain Packet.
|
||||||
|
* The packet's Application Data can not be checked here.
|
||||||
|
* @param current_packet The packet to check
|
||||||
|
* @return - @c RETURN_OK on success.
|
||||||
|
* - @c INCORRECT_CHECKSUM if checksum is invalid.
|
||||||
|
* - @c ILLEGAL_APID if APID does not match.
|
||||||
|
*/
|
||||||
|
virtual ReturnValue_t checkPacket(SpacePacketBase* currentPacket) = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif /* FSFW_TCDISTRIBUTION_TCPACKETCHECKIF_H_ */
|
48
src/fsfw/tcdistribution/TcPacketCheckPUS.cpp
Normal file
48
src/fsfw/tcdistribution/TcPacketCheckPUS.cpp
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
#include "fsfw/tcdistribution/TcPacketCheckPUS.h"
|
||||||
|
|
||||||
|
#include "fsfw/globalfunctions/CRC.h"
|
||||||
|
#include "fsfw/tmtcpacket/pus/tc/TcPacketStoredPus.h"
|
||||||
|
#include "fsfw/tmtcpacket/pus/tc/TcPacketBase.h"
|
||||||
|
#include "fsfw/tmtcpacket/pus/tc/TcPacketStoredBase.h"
|
||||||
|
#include "fsfw/serviceinterface/ServiceInterface.h"
|
||||||
|
#include "fsfw/storagemanager/StorageManagerIF.h"
|
||||||
|
#include "fsfw/tmtcservices/VerificationCodes.h"
|
||||||
|
|
||||||
|
TcPacketCheckPUS::TcPacketCheckPUS(uint16_t setApid): apid(setApid) {
|
||||||
|
}
|
||||||
|
|
||||||
|
ReturnValue_t TcPacketCheckPUS::checkPacket(SpacePacketBase* currentPacket) {
|
||||||
|
TcPacketStoredBase* storedPacket = dynamic_cast<TcPacketStoredBase*>(currentPacket);
|
||||||
|
TcPacketBase* tcPacketBase = storedPacket->getPacketBase();
|
||||||
|
if(tcPacketBase == nullptr) {
|
||||||
|
return RETURN_FAILED;
|
||||||
|
}
|
||||||
|
uint16_t calculated_crc = CRC::crc16ccitt(tcPacketBase->getWholeData(),
|
||||||
|
tcPacketBase->getFullSize());
|
||||||
|
if (calculated_crc != 0) {
|
||||||
|
return INCORRECT_CHECKSUM;
|
||||||
|
}
|
||||||
|
bool condition = (not tcPacketBase->hasSecondaryHeader()) or
|
||||||
|
(tcPacketBase->getPacketVersionNumber() != CCSDS_VERSION_NUMBER) or
|
||||||
|
(not tcPacketBase->isTelecommand());
|
||||||
|
if (condition) {
|
||||||
|
return INCORRECT_PRIMARY_HEADER;
|
||||||
|
}
|
||||||
|
if (tcPacketBase->getAPID() != this->apid)
|
||||||
|
return ILLEGAL_APID;
|
||||||
|
|
||||||
|
if (not storedPacket->isSizeCorrect()) {
|
||||||
|
return INCOMPLETE_PACKET;
|
||||||
|
}
|
||||||
|
|
||||||
|
condition = (tcPacketBase->getSecondaryHeaderFlag() != CCSDS_SECONDARY_HEADER_FLAG) ||
|
||||||
|
(tcPacketBase->getPusVersionNumber() != PUS_VERSION_NUMBER);
|
||||||
|
if (condition) {
|
||||||
|
return INCORRECT_SECONDARY_HEADER;
|
||||||
|
}
|
||||||
|
return RETURN_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint16_t TcPacketCheckPUS::getApid() const {
|
||||||
|
return apid;
|
||||||
|
}
|
63
src/fsfw/tcdistribution/TcPacketCheckPUS.h
Normal file
63
src/fsfw/tcdistribution/TcPacketCheckPUS.h
Normal file
@ -0,0 +1,63 @@
|
|||||||
|
#ifndef FSFW_TCDISTRIBUTION_TCPACKETCHECKPUS_H_
|
||||||
|
#define FSFW_TCDISTRIBUTION_TCPACKETCHECKPUS_H_
|
||||||
|
|
||||||
|
#include "TcPacketCheckIF.h"
|
||||||
|
|
||||||
|
#include "fsfw/FSFW.h"
|
||||||
|
#include "fsfw/returnvalues/HasReturnvaluesIF.h"
|
||||||
|
#include "fsfw/tmtcservices/PusVerificationReport.h"
|
||||||
|
|
||||||
|
class TcPacketStoredBase;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This class performs a formal packet check for incoming PUS Telecommand Packets.
|
||||||
|
* Currently, it only checks if the APID and CRC are correct.
|
||||||
|
* @ingroup tc_distribution
|
||||||
|
*/
|
||||||
|
class TcPacketCheckPUS :
|
||||||
|
public TcPacketCheckIF,
|
||||||
|
public HasReturnvaluesIF {
|
||||||
|
protected:
|
||||||
|
/**
|
||||||
|
* Describes the version number a packet must have to pass.
|
||||||
|
*/
|
||||||
|
static constexpr uint8_t CCSDS_VERSION_NUMBER = 0;
|
||||||
|
/**
|
||||||
|
* Describes the secondary header a packet must have to pass.
|
||||||
|
*/
|
||||||
|
static constexpr uint8_t CCSDS_SECONDARY_HEADER_FLAG = 0;
|
||||||
|
/**
|
||||||
|
* Describes the TC Packet PUS Version Number a packet must have to pass.
|
||||||
|
*/
|
||||||
|
#if FSFW_USE_PUS_C_TELECOMMANDS == 1
|
||||||
|
static constexpr uint8_t PUS_VERSION_NUMBER = 2;
|
||||||
|
#else
|
||||||
|
static constexpr uint8_t PUS_VERSION_NUMBER = 1;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The packet id each correct packet should have.
|
||||||
|
* It is composed of the APID and some static fields.
|
||||||
|
*/
|
||||||
|
uint16_t apid;
|
||||||
|
public:
|
||||||
|
static const uint8_t INTERFACE_ID = CLASS_ID::TC_PACKET_CHECK;
|
||||||
|
static const ReturnValue_t ILLEGAL_APID = MAKE_RETURN_CODE( 0 );
|
||||||
|
static const ReturnValue_t INCOMPLETE_PACKET = MAKE_RETURN_CODE( 1 );
|
||||||
|
static const ReturnValue_t INCORRECT_CHECKSUM = MAKE_RETURN_CODE( 2 );
|
||||||
|
static const ReturnValue_t ILLEGAL_PACKET_TYPE = MAKE_RETURN_CODE( 3 );
|
||||||
|
static const ReturnValue_t ILLEGAL_PACKET_SUBTYPE = MAKE_RETURN_CODE( 4 );
|
||||||
|
static const ReturnValue_t INCORRECT_PRIMARY_HEADER = MAKE_RETURN_CODE( 5 );
|
||||||
|
static const ReturnValue_t INCORRECT_SECONDARY_HEADER = MAKE_RETURN_CODE( 6 );
|
||||||
|
/**
|
||||||
|
* The constructor only sets the APID attribute.
|
||||||
|
* @param set_apid The APID to set.
|
||||||
|
*/
|
||||||
|
TcPacketCheckPUS(uint16_t setApid);
|
||||||
|
|
||||||
|
ReturnValue_t checkPacket(SpacePacketBase* currentPacket) override;
|
||||||
|
|
||||||
|
uint16_t getApid() const;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif /* FSFW_TCDISTRIBUTION_TCPACKETCHECKPUS_H_ */
|
@ -3,5 +3,6 @@ target_sources(${LIB_FSFW_NAME} PRIVATE
|
|||||||
SpacePacketBase.cpp
|
SpacePacketBase.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
|
add_subdirectory(cfdp)
|
||||||
add_subdirectory(packetmatcher)
|
add_subdirectory(packetmatcher)
|
||||||
add_subdirectory(pus)
|
add_subdirectory(pus)
|
20
src/fsfw/tmtcpacket/cfdp/CFDPPacket.cpp
Normal file
20
src/fsfw/tmtcpacket/cfdp/CFDPPacket.cpp
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
#include "fsfw/tmtcpacket/cfdp/CFDPPacket.h"
|
||||||
|
|
||||||
|
#include "fsfw/globalfunctions/CRC.h"
|
||||||
|
#include "fsfw/globalfunctions/arrayprinter.h"
|
||||||
|
#include "fsfw/serviceinterface/ServiceInterface.h"
|
||||||
|
|
||||||
|
#include <cstring>
|
||||||
|
|
||||||
|
CFDPPacket::CFDPPacket(const uint8_t* setData): SpacePacketBase(setData) {}
|
||||||
|
|
||||||
|
CFDPPacket::~CFDPPacket() {}
|
||||||
|
|
||||||
|
void CFDPPacket::print() {
|
||||||
|
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||||
|
sif::info << "CFDPPacket::print:" << std::endl;
|
||||||
|
#else
|
||||||
|
sif::printInfo("CFDPPacket::print:\n");
|
||||||
|
#endif
|
||||||
|
arrayprinter::print(getWholeData(), getFullSize());
|
||||||
|
}
|
27
src/fsfw/tmtcpacket/cfdp/CFDPPacket.h
Normal file
27
src/fsfw/tmtcpacket/cfdp/CFDPPacket.h
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
#ifndef FSFW_INC_FSFW_TMTCPACKET_CFDP_CFDPPACKET_H_
|
||||||
|
#define FSFW_INC_FSFW_TMTCPACKET_CFDP_CFDPPACKET_H_
|
||||||
|
|
||||||
|
#include "fsfw/tmtcpacket/SpacePacketBase.h"
|
||||||
|
|
||||||
|
class CFDPPacket : public SpacePacketBase {
|
||||||
|
public:
|
||||||
|
/**
|
||||||
|
* This is the default constructor.
|
||||||
|
* It sets its internal data pointer to the address passed and also
|
||||||
|
* forwards the data pointer to the parent SpacePacketBase class.
|
||||||
|
* @param setData The position where the packet data lies.
|
||||||
|
*/
|
||||||
|
CFDPPacket( const uint8_t* setData );
|
||||||
|
/**
|
||||||
|
* This is the empty default destructor.
|
||||||
|
*/
|
||||||
|
virtual ~CFDPPacket();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This is a debugging helper method that prints the whole packet content
|
||||||
|
* to the screen.
|
||||||
|
*/
|
||||||
|
void print();
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif /* FSFW_INC_FSFW_TMTCPACKET_CFDP_CFDPPACKET_H_ */
|
85
src/fsfw/tmtcpacket/cfdp/CFDPPacketStored.cpp
Normal file
85
src/fsfw/tmtcpacket/cfdp/CFDPPacketStored.cpp
Normal file
@ -0,0 +1,85 @@
|
|||||||
|
#include "fsfw/tmtcpacket/cfdp/CFDPPacketStored.h"
|
||||||
|
#include "fsfw/objectmanager/ObjectManager.h"
|
||||||
|
|
||||||
|
StorageManagerIF* CFDPPacketStored::store = nullptr;
|
||||||
|
|
||||||
|
CFDPPacketStored::CFDPPacketStored(): CFDPPacket(nullptr) {
|
||||||
|
}
|
||||||
|
|
||||||
|
CFDPPacketStored::CFDPPacketStored(store_address_t setAddress): CFDPPacket(nullptr) {
|
||||||
|
this->setStoreAddress(setAddress);
|
||||||
|
}
|
||||||
|
|
||||||
|
CFDPPacketStored::CFDPPacketStored(const uint8_t* data, size_t size): CFDPPacket(data) {
|
||||||
|
if (this->getFullSize() != size) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (this->checkAndSetStore()) {
|
||||||
|
ReturnValue_t status = store->addData(&storeAddress, data, size);
|
||||||
|
if (status != HasReturnvaluesIF::RETURN_OK) {
|
||||||
|
this->setData(nullptr);
|
||||||
|
}
|
||||||
|
const uint8_t* storePtr = nullptr;
|
||||||
|
// Repoint base data pointer to the data in the store.
|
||||||
|
store->getData(storeAddress, &storePtr, &size);
|
||||||
|
this->setData(storePtr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ReturnValue_t CFDPPacketStored::deletePacket() {
|
||||||
|
ReturnValue_t result = this->store->deleteData(this->storeAddress);
|
||||||
|
this->storeAddress.raw = StorageManagerIF::INVALID_ADDRESS;
|
||||||
|
this->setData(nullptr);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//CFDPPacket* CFDPPacketStored::getPacketBase() {
|
||||||
|
// return this;
|
||||||
|
//}
|
||||||
|
void CFDPPacketStored::setStoreAddress(store_address_t setAddress) {
|
||||||
|
this->storeAddress = setAddress;
|
||||||
|
const uint8_t* tempData = nullptr;
|
||||||
|
size_t tempSize;
|
||||||
|
ReturnValue_t status = StorageManagerIF::RETURN_FAILED;
|
||||||
|
if (this->checkAndSetStore()) {
|
||||||
|
status = this->store->getData(this->storeAddress, &tempData, &tempSize);
|
||||||
|
}
|
||||||
|
if (status == StorageManagerIF::RETURN_OK) {
|
||||||
|
this->setData(tempData);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
this->setData(nullptr);
|
||||||
|
this->storeAddress.raw = StorageManagerIF::INVALID_ADDRESS;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
store_address_t CFDPPacketStored::getStoreAddress() {
|
||||||
|
return this->storeAddress;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CFDPPacketStored::checkAndSetStore() {
|
||||||
|
if (this->store == nullptr) {
|
||||||
|
this->store = ObjectManager::instance()->get<StorageManagerIF>(objects::TC_STORE);
|
||||||
|
if (this->store == nullptr) {
|
||||||
|
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||||
|
sif::error << "CFDPPacketStored::CFDPPacketStored: TC Store not found!"
|
||||||
|
<< std::endl;
|
||||||
|
#endif
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CFDPPacketStored::isSizeCorrect() {
|
||||||
|
const uint8_t* temp_data = nullptr;
|
||||||
|
size_t temp_size;
|
||||||
|
ReturnValue_t status = this->store->getData(this->storeAddress, &temp_data,
|
||||||
|
&temp_size);
|
||||||
|
if (status == StorageManagerIF::RETURN_OK) {
|
||||||
|
if (this->getFullSize() == temp_size) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
64
src/fsfw/tmtcpacket/cfdp/CFDPPacketStored.h
Normal file
64
src/fsfw/tmtcpacket/cfdp/CFDPPacketStored.h
Normal file
@ -0,0 +1,64 @@
|
|||||||
|
#ifndef FSFW_INC_FSFW_TMTCPACKET_CFDP_CFDPPACKETSTORED_H_
|
||||||
|
#define FSFW_INC_FSFW_TMTCPACKET_CFDP_CFDPPACKETSTORED_H_
|
||||||
|
|
||||||
|
#include "../pus/tc/TcPacketStoredBase.h"
|
||||||
|
#include "CFDPPacket.h"
|
||||||
|
|
||||||
|
class CFDPPacketStored:
|
||||||
|
public CFDPPacket {
|
||||||
|
public:
|
||||||
|
/**
|
||||||
|
* Create stored packet with existing data.
|
||||||
|
* @param data
|
||||||
|
* @param size
|
||||||
|
*/
|
||||||
|
CFDPPacketStored(const uint8_t* data, size_t size);
|
||||||
|
/**
|
||||||
|
* Create stored packet from existing packet in store
|
||||||
|
* @param setAddress
|
||||||
|
*/
|
||||||
|
CFDPPacketStored(store_address_t setAddress);
|
||||||
|
CFDPPacketStored();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Getter function for the raw data.
|
||||||
|
* @param dataPtr [out] Pointer to the data pointer to set
|
||||||
|
* @param dataSize [out] Address of size to set.
|
||||||
|
* @return -@c RETURN_OK if data was retrieved successfully.
|
||||||
|
*/
|
||||||
|
ReturnValue_t getData(const uint8_t ** dataPtr, size_t* dataSize);
|
||||||
|
|
||||||
|
void setStoreAddress(store_address_t setAddress);
|
||||||
|
|
||||||
|
store_address_t getStoreAddress();
|
||||||
|
|
||||||
|
ReturnValue_t deletePacket();
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
bool isSizeCorrect();
|
||||||
|
protected:
|
||||||
|
/**
|
||||||
|
* This is a pointer to the store all instances of the class use.
|
||||||
|
* If the store is not yet set (i.e. @c store is NULL), every constructor
|
||||||
|
* call tries to set it and throws an error message in case of failures.
|
||||||
|
* The default store is objects::TC_STORE.
|
||||||
|
*/
|
||||||
|
static StorageManagerIF* store;
|
||||||
|
/**
|
||||||
|
* The address where the packet data of the object instance is stored.
|
||||||
|
*/
|
||||||
|
store_address_t storeAddress;
|
||||||
|
/**
|
||||||
|
* A helper method to check if a store is assigned to the class.
|
||||||
|
* If not, the method tries to retrieve the store from the global
|
||||||
|
* ObjectManager.
|
||||||
|
* @return @li @c true if the store is linked or could be created.
|
||||||
|
* @li @c false otherwise.
|
||||||
|
*/
|
||||||
|
bool checkAndSetStore();
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#endif /* FSFW_INC_FSFW_TMTCPACKET_CFDP_CFDPPACKETSTORED_H_ */
|
4
src/fsfw/tmtcpacket/cfdp/CMakeLists.txt
Normal file
4
src/fsfw/tmtcpacket/cfdp/CMakeLists.txt
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
target_sources(${LIB_FSFW_NAME} PRIVATE
|
||||||
|
CFDPPacket.cpp
|
||||||
|
CFDPPacketStored.cpp
|
||||||
|
)
|
@ -14,7 +14,6 @@
|
|||||||
#include "fsfw/container/FIFO.h"
|
#include "fsfw/container/FIFO.h"
|
||||||
#include "fsfw/serialize/SerializeIF.h"
|
#include "fsfw/serialize/SerializeIF.h"
|
||||||
|
|
||||||
class TcPacketStored;
|
|
||||||
class TcPacketStoredBase;
|
class TcPacketStoredBase;
|
||||||
|
|
||||||
namespace Factory{
|
namespace Factory{
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
#include "fsfw_tests/internal/InternalUnitTester.h"
|
#include "fsfw_tests/internal/InternalUnitTester.h"
|
||||||
#include "fsfw_tests/internal/UnittDefinitions.h"
|
#include "fsfw_tests/internal/UnittDefinitions.h"
|
||||||
|
|
||||||
#include "fsfw_tests/internal/osal/IntTestMq.h"
|
#include "fsfw_tests/internal/osal/testMq.h"
|
||||||
#include "fsfw_tests/internal/osal/IntTestSemaphore.h"
|
#include "fsfw_tests/internal/osal/testSemaphore.h"
|
||||||
#include "fsfw_tests/internal/osal/IntTestMutex.h"
|
#include "fsfw_tests/internal/osal/testMutex.h"
|
||||||
#include "fsfw_tests/internal/serialize/IntTestSerialization.h"
|
#include "fsfw_tests/internal/serialize/IntTestSerialization.h"
|
||||||
#include "fsfw_tests/internal/globalfunctions/TestArrayPrinter.h"
|
#include "fsfw_tests/internal/globalfunctions/TestArrayPrinter.h"
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
target_sources(${LIB_FSFW_NAME} PRIVATE
|
target_sources(${LIB_FSFW_NAME} PRIVATE
|
||||||
IntTestMq.cpp
|
testMq.cpp
|
||||||
IntTestMutex.cpp
|
testMutex.cpp
|
||||||
IntTestSemaphore.cpp
|
testSemaphore.cpp
|
||||||
)
|
)
|
||||||
|
1
tests/src/fsfw_tests/internal/osal/testCmdExecutor.cpp
Normal file
1
tests/src/fsfw_tests/internal/osal/testCmdExecutor.cpp
Normal file
@ -0,0 +1 @@
|
|||||||
|
#include "testCmdExecutor.h"
|
10
tests/src/fsfw_tests/internal/osal/testCmdExecutor.h
Normal file
10
tests/src/fsfw_tests/internal/osal/testCmdExecutor.h
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
#ifndef FSFW_TESTS_SRC_FSFW_TESTS_INTERNAL_OSAL_TESTCMDEXECUTOR_H_
|
||||||
|
#define FSFW_TESTS_SRC_FSFW_TESTS_INTERNAL_OSAL_TESTCMDEXECUTOR_H_
|
||||||
|
|
||||||
|
namespace testcmdexec {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#endif /* FSFW_TESTS_SRC_FSFW_TESTS_INTERNAL_OSAL_TESTCMDEXECUTOR_H_ */
|
@ -1,4 +1,4 @@
|
|||||||
#include "fsfw_tests/internal/osal/IntTestMq.h"
|
#include "testMq.h"
|
||||||
#include "fsfw_tests/internal/UnittDefinitions.h"
|
#include "fsfw_tests/internal/UnittDefinitions.h"
|
||||||
|
|
||||||
#include <fsfw/ipc/MessageQueueIF.h>
|
#include <fsfw/ipc/MessageQueueIF.h>
|
@ -1,4 +1,4 @@
|
|||||||
#include "fsfw_tests/internal/osal/IntTestMutex.h"
|
#include "testMutex.h"
|
||||||
#include "fsfw_tests/internal/UnittDefinitions.h"
|
#include "fsfw_tests/internal/UnittDefinitions.h"
|
||||||
#include "fsfw/platform.h"
|
#include "fsfw/platform.h"
|
||||||
|
|
@ -1,5 +1,5 @@
|
|||||||
#include "fsfw/FSFW.h"
|
#include "fsfw/FSFW.h"
|
||||||
#include "fsfw_tests/internal/osal/IntTestSemaphore.h"
|
#include "testSemaphore.h"
|
||||||
#include "fsfw_tests/internal/UnittDefinitions.h"
|
#include "fsfw_tests/internal/UnittDefinitions.h"
|
||||||
|
|
||||||
#include "fsfw/tasks/SemaphoreFactory.h"
|
#include "fsfw/tasks/SemaphoreFactory.h"
|
@ -1,3 +1,16 @@
|
|||||||
|
target_sources(${TARGET_NAME} PRIVATE
|
||||||
|
CatchDefinitions.cpp
|
||||||
|
CatchFactory.cpp
|
||||||
|
printChar.cpp
|
||||||
|
)
|
||||||
|
|
||||||
|
if(FSFW_CUSTOM_UNITTEST_RUNNER)
|
||||||
|
target_sources(${TARGET_NAME} PRIVATE
|
||||||
|
CatchRunner.cpp
|
||||||
|
CatchSetup.cpp
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
|
||||||
add_subdirectory(action)
|
add_subdirectory(action)
|
||||||
add_subdirectory(container)
|
add_subdirectory(container)
|
||||||
add_subdirectory(osal)
|
add_subdirectory(osal)
|
||||||
|
@ -1,17 +1,21 @@
|
|||||||
#include "CatchFactory.h"
|
#include "CatchFactory.h"
|
||||||
|
#include "datapoollocal/LocalPoolOwnerBase.h"
|
||||||
|
#include "mocks/HkReceiverMock.h"
|
||||||
|
|
||||||
#include <fsfw/datapoollocal/LocalDataPoolManager.h>
|
#include <fsfw/datapoollocal/LocalDataPoolManager.h>
|
||||||
#include <fsfw/devicehandlers/DeviceHandlerBase.h>
|
#include <fsfw/devicehandlers/DeviceHandlerBase.h>
|
||||||
|
|
||||||
#include <fsfw/events/EventManager.h>
|
#include <fsfw/events/EventManager.h>
|
||||||
#include <fsfw/health/HealthTable.h>
|
#include <fsfw/health/HealthTable.h>
|
||||||
#include <fsfw/internalError/InternalErrorReporter.h>
|
#include <fsfw/internalerror/InternalErrorReporter.h>
|
||||||
#include <fsfw/objectmanager/frameworkObjects.h>
|
#include <fsfw/objectmanager/frameworkObjects.h>
|
||||||
#include <fsfw/storagemanager/PoolManager.h>
|
#include <fsfw/storagemanager/PoolManager.h>
|
||||||
#include <fsfw/tmtcpacket/pus/tm/TmPacketStored.h>
|
#include <fsfw/tmtcpacket/pus/tm/TmPacketStored.h>
|
||||||
#include <fsfw/tmtcservices/CommandingServiceBase.h>
|
#include <fsfw/tmtcservices/CommandingServiceBase.h>
|
||||||
#include <fsfw/tmtcservices/PusServiceBase.h>
|
#include <fsfw/tmtcservices/PusServiceBase.h>
|
||||||
#include <fsfw/unittest/tests/datapoollocal/LocalPoolOwnerBase.h>
|
|
||||||
#include <fsfw/unittest/tests/mocks/HkReceiverMock.h>
|
|
||||||
|
#if FSFW_ADD_DEFAULT_FACTORY_FUNCTIONS == 1
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Produces system objects.
|
* @brief Produces system objects.
|
||||||
@ -26,7 +30,7 @@
|
|||||||
*
|
*
|
||||||
* @ingroup init
|
* @ingroup init
|
||||||
*/
|
*/
|
||||||
void Factory::produce(void) {
|
void Factory::produceFrameworkObjects(void* args) {
|
||||||
setStaticFrameworkObjectIds();
|
setStaticFrameworkObjectIds();
|
||||||
new EventManager(objects::EVENT_MANAGER);
|
new EventManager(objects::EVENT_MANAGER);
|
||||||
new HealthTable(objects::HEALTH_TABLE);
|
new HealthTable(objects::HEALTH_TABLE);
|
||||||
@ -55,7 +59,6 @@ void Factory::produce(void) {
|
|||||||
};
|
};
|
||||||
new PoolManager(objects::IPC_STORE, poolCfg);
|
new PoolManager(objects::IPC_STORE, poolCfg);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Factory::setStaticFrameworkObjectIds() {
|
void Factory::setStaticFrameworkObjectIds() {
|
||||||
@ -77,5 +80,4 @@ void Factory::setStaticFrameworkObjectIds() {
|
|||||||
TmPacketBase::timeStamperId = objects::NO_OBJECT;
|
TmPacketBase::timeStamperId = objects::NO_OBJECT;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
24
tests/src/fsfw_tests/unit/CatchFactory.h
Normal file
24
tests/src/fsfw_tests/unit/CatchFactory.h
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
#ifndef FSFW_CATCHFACTORY_H_
|
||||||
|
#define FSFW_CATCHFACTORY_H_
|
||||||
|
|
||||||
|
#include "TestConfig.h"
|
||||||
|
#include "fsfw/objectmanager/SystemObjectIF.h"
|
||||||
|
#include "fsfw/objectmanager/ObjectManager.h"
|
||||||
|
|
||||||
|
// TODO: It is possible to solve this more cleanly using a special class which
|
||||||
|
// is allowed to set the object IDs and has virtual functions.
|
||||||
|
#if FSFW_ADD_DEFAULT_FACTORY_FUNCTIONS == 1
|
||||||
|
|
||||||
|
namespace Factory {
|
||||||
|
/**
|
||||||
|
* @brief Creates all SystemObject elements which are persistent
|
||||||
|
* during execution.
|
||||||
|
*/
|
||||||
|
void produceFrameworkObjects(void* args);
|
||||||
|
void setStaticFrameworkObjectIds();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* FSFW_ADD_DEFAULT_FSFW_FACTORY == 1 */
|
||||||
|
|
||||||
|
#endif /* FSFW_CATCHFACTORY_H_ */
|
@ -6,7 +6,7 @@
|
|||||||
* from the eclipse market place to get colored characters.
|
* from the eclipse market place to get colored characters.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <TestsConfig.h>
|
#include "CatchRunner.h"
|
||||||
|
|
||||||
#define CATCH_CONFIG_COLOUR_WINDOWS
|
#define CATCH_CONFIG_COLOUR_WINDOWS
|
||||||
|
|
||||||
@ -14,11 +14,11 @@
|
|||||||
|
|
||||||
extern int customSetup();
|
extern int customSetup();
|
||||||
|
|
||||||
int main( int argc, char* argv[] ) {
|
int fsfwtest::customMain(int argc, char* argv[]) {
|
||||||
customSetup();
|
customSetup();
|
||||||
|
|
||||||
// Catch internal function call
|
// Catch internal function call
|
||||||
int result = Catch::Session().run( argc, argv );
|
int result = Catch::Session().run(argc, argv);
|
||||||
|
|
||||||
// global clean-up
|
// global clean-up
|
||||||
return result;
|
return result;
|
14
tests/src/fsfw_tests/unit/CatchRunner.h
Normal file
14
tests/src/fsfw_tests/unit/CatchRunner.h
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
#ifndef FSFW_TESTS_USER_UNITTEST_CORE_CATCHRUNNER_H_
|
||||||
|
#define FSFW_TESTS_USER_UNITTEST_CORE_CATCHRUNNER_H_
|
||||||
|
|
||||||
|
namespace fsfwtest {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Can be called by upper level main() if default Catch2 main is overriden
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
int customMain(int argc, char* argv[]);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* FSFW_TESTS_USER_UNITTEST_CORE_CATCHRUNNER_H_ */
|
@ -5,10 +5,9 @@
|
|||||||
#include <gcov.h>
|
#include <gcov.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <fsfw/objectmanager/ObjectManager.h>
|
#include "fsfw/objectmanager/ObjectManager.h"
|
||||||
#include <fsfw/objectmanager/ObjectManagerIF.h>
|
#include "fsfw/storagemanager/StorageManagerIF.h"
|
||||||
#include <fsfw/storagemanager/StorageManagerIF.h>
|
#include "fsfw/serviceinterface/ServiceInterface.h"
|
||||||
#include <fsfw/serviceinterface/ServiceInterfaceStream.h>
|
|
||||||
|
|
||||||
|
|
||||||
/* Global instantiations normally done in main.cpp */
|
/* Global instantiations normally done in main.cpp */
|
||||||
@ -24,13 +23,11 @@ ServiceInterfaceStream warning("WARNING");
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Global object manager */
|
|
||||||
ObjectManagerIF *objectManager;
|
|
||||||
|
|
||||||
int customSetup() {
|
int customSetup() {
|
||||||
// global setup
|
// global setup
|
||||||
objectManager = new ObjectManager(Factory::produce);
|
ObjectManager* objMan = ObjectManager::instance();
|
||||||
objectManager -> initialize();
|
objMan->setObjectFactoryFunction(Factory::produceFrameworkObjects, nullptr);
|
||||||
|
objMan->initialize();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
@ -1,13 +1,10 @@
|
|||||||
#include "TestActionHelper.h"
|
#include "TestActionHelper.h"
|
||||||
|
#include "fsfw_tests/unit/mocks/MessageQueueMockBase.h"
|
||||||
#include <unittest/core/CatchDefinitions.h>
|
|
||||||
|
|
||||||
#include <fsfw/action/ActionHelper.h>
|
#include <fsfw/action/ActionHelper.h>
|
||||||
#include <fsfw/ipc/CommandMessage.h>
|
#include <fsfw/ipc/CommandMessage.h>
|
||||||
#include <fsfw/tests/unit/mocks/MessageQueueMockBase.h>
|
|
||||||
|
|
||||||
#include <catch2/catch_test_macros.hpp>
|
#include <catch2/catch_test_macros.hpp>
|
||||||
|
|
||||||
#include <array>
|
#include <array>
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,12 +1,11 @@
|
|||||||
#ifndef UNITTEST_HOSTED_TESTACTIONHELPER_H_
|
#ifndef UNITTEST_HOSTED_TESTACTIONHELPER_H_
|
||||||
#define UNITTEST_HOSTED_TESTACTIONHELPER_H_
|
#define UNITTEST_HOSTED_TESTACTIONHELPER_H_
|
||||||
|
|
||||||
|
#include "fsfw_tests/unit/CatchDefinitions.h"
|
||||||
#include <fsfw/action/HasActionsIF.h>
|
#include <fsfw/action/HasActionsIF.h>
|
||||||
#include <fsfw/ipc/MessageQueueIF.h>
|
#include <fsfw/ipc/MessageQueueIF.h>
|
||||||
#include <unittest/core/CatchDefinitions.h>
|
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
|
||||||
|
|
||||||
class ActionHelperOwnerMockBase: public HasActionsIF {
|
class ActionHelperOwnerMockBase: public HasActionsIF {
|
||||||
public:
|
public:
|
||||||
bool getCommandQueueCalled = false;
|
bool getCommandQueueCalled = false;
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#include <unittest/core/CatchDefinitions.h>
|
#include "fsfw_tests/unit/CatchDefinitions.h"
|
||||||
#include <fsfw/container/SimpleRingBuffer.h>
|
#include <fsfw/container/SimpleRingBuffer.h>
|
||||||
|
|
||||||
#include <catch2/catch_test_macros.hpp>
|
#include <catch2/catch_test_macros.hpp>
|
||||||
|
@ -1,8 +1,9 @@
|
|||||||
|
#include "fsfw_tests/unit/CatchDefinitions.h"
|
||||||
|
|
||||||
#include <fsfw/container/ArrayList.h>
|
#include <fsfw/container/ArrayList.h>
|
||||||
#include <fsfw/returnvalues/HasReturnvaluesIF.h>
|
#include <fsfw/returnvalues/HasReturnvaluesIF.h>
|
||||||
|
|
||||||
#include <catch2/catch_test_macros.hpp>
|
#include <catch2/catch_test_macros.hpp>
|
||||||
#include <unittest/core/CatchDefinitions.h>
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Array List test
|
* @brief Array List test
|
||||||
|
@ -1,9 +1,10 @@
|
|||||||
|
#include "fsfw_tests/unit/CatchDefinitions.h"
|
||||||
|
|
||||||
#include <fsfw/container/DynamicFIFO.h>
|
#include <fsfw/container/DynamicFIFO.h>
|
||||||
#include <fsfw/container/FIFO.h>
|
#include <fsfw/container/FIFO.h>
|
||||||
#include <fsfw/returnvalues/HasReturnvaluesIF.h>
|
#include <fsfw/returnvalues/HasReturnvaluesIF.h>
|
||||||
|
|
||||||
#include <catch2/catch_test_macros.hpp>
|
#include <catch2/catch_test_macros.hpp>
|
||||||
#include <unittest/core/CatchDefinitions.h>
|
|
||||||
|
|
||||||
TEST_CASE( "Dynamic Fifo Tests", "[TestDynamicFifo]") {
|
TEST_CASE( "Dynamic Fifo Tests", "[TestDynamicFifo]") {
|
||||||
INFO("Dynamic Fifo Tests");
|
INFO("Dynamic Fifo Tests");
|
||||||
|
@ -1,9 +1,10 @@
|
|||||||
|
#include "fsfw_tests/unit/CatchDefinitions.h"
|
||||||
|
|
||||||
#include <fsfw/container/DynamicFIFO.h>
|
#include <fsfw/container/DynamicFIFO.h>
|
||||||
#include <fsfw/container/FIFO.h>
|
#include <fsfw/container/FIFO.h>
|
||||||
#include <fsfw/returnvalues/HasReturnvaluesIF.h>
|
#include <fsfw/returnvalues/HasReturnvaluesIF.h>
|
||||||
|
|
||||||
#include <catch2/catch_test_macros.hpp>
|
#include <catch2/catch_test_macros.hpp>
|
||||||
#include <unittest/core/CatchDefinitions.h>
|
|
||||||
|
|
||||||
TEST_CASE( "Static Fifo Tests", "[TestFifo]") {
|
TEST_CASE( "Static Fifo Tests", "[TestFifo]") {
|
||||||
INFO("Fifo Tests");
|
INFO("Fifo Tests");
|
||||||
|
@ -1,8 +1,9 @@
|
|||||||
|
#include "fsfw_tests/unit/CatchDefinitions.h"
|
||||||
|
|
||||||
#include <fsfw/container/FixedArrayList.h>
|
#include <fsfw/container/FixedArrayList.h>
|
||||||
#include <fsfw/returnvalues/HasReturnvaluesIF.h>
|
#include <fsfw/returnvalues/HasReturnvaluesIF.h>
|
||||||
|
|
||||||
#include <catch2/catch_test_macros.hpp>
|
#include <catch2/catch_test_macros.hpp>
|
||||||
#include <unittest/core/CatchDefinitions.h>
|
|
||||||
|
|
||||||
|
|
||||||
TEST_CASE( "FixedArrayList Tests", "[TestFixedArrayList]") {
|
TEST_CASE( "FixedArrayList Tests", "[TestFixedArrayList]") {
|
||||||
|
@ -1,8 +1,9 @@
|
|||||||
|
#include "fsfw_tests/unit/CatchDefinitions.h"
|
||||||
|
|
||||||
#include <fsfw/container/FixedMap.h>
|
#include <fsfw/container/FixedMap.h>
|
||||||
#include <fsfw/returnvalues/HasReturnvaluesIF.h>
|
#include <fsfw/returnvalues/HasReturnvaluesIF.h>
|
||||||
|
|
||||||
#include <catch2/catch_test_macros.hpp>
|
#include <catch2/catch_test_macros.hpp>
|
||||||
#include <unittest/core/CatchDefinitions.h>
|
|
||||||
|
|
||||||
template class FixedMap<unsigned int, unsigned short>;
|
template class FixedMap<unsigned int, unsigned short>;
|
||||||
|
|
||||||
|
@ -1,8 +1,9 @@
|
|||||||
|
#include "fsfw_tests/unit/CatchDefinitions.h"
|
||||||
|
|
||||||
#include <fsfw/container/FixedOrderedMultimap.h>
|
#include <fsfw/container/FixedOrderedMultimap.h>
|
||||||
#include <fsfw/returnvalues/HasReturnvaluesIF.h>
|
#include <fsfw/returnvalues/HasReturnvaluesIF.h>
|
||||||
|
|
||||||
#include <catch2/catch_test_macros.hpp>
|
#include <catch2/catch_test_macros.hpp>
|
||||||
#include <unittest/core/CatchDefinitions.h>
|
|
||||||
|
|
||||||
TEST_CASE( "FixedOrderedMultimap Tests", "[TestFixedOrderedMultimap]") {
|
TEST_CASE( "FixedOrderedMultimap Tests", "[TestFixedOrderedMultimap]") {
|
||||||
INFO("FixedOrderedMultimap Tests");
|
INFO("FixedOrderedMultimap Tests");
|
||||||
|
@ -1,10 +1,11 @@
|
|||||||
|
#include "fsfw_tests/unit/CatchDefinitions.h"
|
||||||
|
|
||||||
#include <fsfw/container/PlacementFactory.h>
|
#include <fsfw/container/PlacementFactory.h>
|
||||||
#include <fsfw/storagemanager/LocalPool.h>
|
#include <fsfw/storagemanager/LocalPool.h>
|
||||||
#include <fsfw/returnvalues/HasReturnvaluesIF.h>
|
#include <fsfw/returnvalues/HasReturnvaluesIF.h>
|
||||||
#include <fsfw/container/ArrayList.h>
|
#include <fsfw/container/ArrayList.h>
|
||||||
|
|
||||||
#include <catch2/catch_test_macros.hpp>
|
#include <catch2/catch_test_macros.hpp>
|
||||||
#include <unittest/core/CatchDefinitions.h>
|
|
||||||
|
|
||||||
TEST_CASE( "PlacementFactory Tests", "[TestPlacementFactory]") {
|
TEST_CASE( "PlacementFactory Tests", "[TestPlacementFactory]") {
|
||||||
INFO("PlacementFactory Tests");
|
INFO("PlacementFactory Tests");
|
||||||
|
@ -1,7 +1,5 @@
|
|||||||
#include "LocalPoolOwnerBase.h"
|
#include "LocalPoolOwnerBase.h"
|
||||||
|
#include "fsfw_tests/unit/CatchDefinitions.h"
|
||||||
#include <catch2/catch_test_macros.hpp>
|
|
||||||
#include <catch2/catch_approx.hpp>
|
|
||||||
|
|
||||||
#include <fsfw/objectmanager/ObjectManager.h>
|
#include <fsfw/objectmanager/ObjectManager.h>
|
||||||
#include <fsfw/datapoollocal/HasLocalDataPoolIF.h>
|
#include <fsfw/datapoollocal/HasLocalDataPoolIF.h>
|
||||||
@ -10,7 +8,8 @@
|
|||||||
#include <fsfw/datapool/PoolReadGuard.h>
|
#include <fsfw/datapool/PoolReadGuard.h>
|
||||||
#include <fsfw/globalfunctions/bitutility.h>
|
#include <fsfw/globalfunctions/bitutility.h>
|
||||||
|
|
||||||
#include <unittest/core/CatchDefinitions.h>
|
#include <catch2/catch_test_macros.hpp>
|
||||||
|
#include <catch2/catch_approx.hpp>
|
||||||
|
|
||||||
TEST_CASE("DataSetTest" , "[DataSetTest]") {
|
TEST_CASE("DataSetTest" , "[DataSetTest]") {
|
||||||
LocalPoolOwnerBase* poolOwner = ObjectManager::instance()->
|
LocalPoolOwnerBase* poolOwner = ObjectManager::instance()->
|
||||||
|
@ -1,7 +1,5 @@
|
|||||||
#include "LocalPoolOwnerBase.h"
|
#include "LocalPoolOwnerBase.h"
|
||||||
|
#include "fsfw_tests/unit/CatchDefinitions.h"
|
||||||
#include <catch2/catch_test_macros.hpp>
|
|
||||||
#include <catch2/catch_approx.hpp>
|
|
||||||
|
|
||||||
#include <fsfw/objectmanager/ObjectManager.h>
|
#include <fsfw/objectmanager/ObjectManager.h>
|
||||||
#include <fsfw/datapool/PoolReadGuard.h>
|
#include <fsfw/datapool/PoolReadGuard.h>
|
||||||
@ -10,7 +8,10 @@
|
|||||||
#include <fsfw/housekeeping/HousekeepingSnapshot.h>
|
#include <fsfw/housekeeping/HousekeepingSnapshot.h>
|
||||||
#include <fsfw/ipc/CommandMessageCleaner.h>
|
#include <fsfw/ipc/CommandMessageCleaner.h>
|
||||||
#include <fsfw/timemanager/CCSDSTime.h>
|
#include <fsfw/timemanager/CCSDSTime.h>
|
||||||
#include <unittest/core/CatchDefinitions.h>
|
|
||||||
|
#include <catch2/catch_test_macros.hpp>
|
||||||
|
#include <catch2/catch_approx.hpp>
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
|
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
#define FSFW_UNITTEST_TESTS_DATAPOOLLOCAL_LOCALPOOLOWNERBASE_H_
|
#define FSFW_UNITTEST_TESTS_DATAPOOLLOCAL_LOCALPOOLOWNERBASE_H_
|
||||||
|
|
||||||
#include "objects/systemObjectList.h"
|
#include "objects/systemObjectList.h"
|
||||||
|
#include "../mocks/MessageQueueMockBase.h"
|
||||||
|
|
||||||
#include <fsfw/datapoollocal/HasLocalDataPoolIF.h>
|
#include <fsfw/datapoollocal/HasLocalDataPoolIF.h>
|
||||||
#include <fsfw/datapoollocal/LocalDataSet.h>
|
#include <fsfw/datapoollocal/LocalDataSet.h>
|
||||||
@ -10,7 +11,6 @@
|
|||||||
#include <fsfw/datapoollocal/LocalPoolVector.h>
|
#include <fsfw/datapoollocal/LocalPoolVector.h>
|
||||||
#include <fsfw/ipc/QueueFactory.h>
|
#include <fsfw/ipc/QueueFactory.h>
|
||||||
#include <fsfw/datapoollocal/StaticLocalDataSet.h>
|
#include <fsfw/datapoollocal/StaticLocalDataSet.h>
|
||||||
#include <fsfw/tests/unit/mocks/MessageQueueMockBase.h>
|
|
||||||
#include <fsfw/datapool/PoolReadGuard.h>
|
#include <fsfw/datapool/PoolReadGuard.h>
|
||||||
|
|
||||||
namespace lpool {
|
namespace lpool {
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
#include "LocalPoolOwnerBase.h"
|
#include "LocalPoolOwnerBase.h"
|
||||||
|
#include "fsfw_tests/unit/CatchDefinitions.h"
|
||||||
|
|
||||||
#include <catch2/catch_test_macros.hpp>
|
|
||||||
#include <fsfw/objectmanager/ObjectManager.h>
|
#include <fsfw/objectmanager/ObjectManager.h>
|
||||||
#include <fsfw/datapoollocal/HasLocalDataPoolIF.h>
|
#include <fsfw/datapoollocal/HasLocalDataPoolIF.h>
|
||||||
#include <unittest/core/CatchDefinitions.h>
|
|
||||||
|
|
||||||
|
#include <catch2/catch_test_macros.hpp>
|
||||||
|
|
||||||
TEST_CASE("LocalPoolVariable" , "[LocPoolVarTest]") {
|
TEST_CASE("LocalPoolVariable" , "[LocPoolVarTest]") {
|
||||||
LocalPoolOwnerBase* poolOwner = ObjectManager::instance()->
|
LocalPoolOwnerBase* poolOwner = ObjectManager::instance()->
|
||||||
|
@ -1,9 +1,10 @@
|
|||||||
#include "LocalPoolOwnerBase.h"
|
#include "LocalPoolOwnerBase.h"
|
||||||
|
#include "fsfw_tests/unit/CatchDefinitions.h"
|
||||||
|
|
||||||
#include <catch2/catch_test_macros.hpp>
|
#include <catch2/catch_test_macros.hpp>
|
||||||
#include <fsfw/objectmanager/ObjectManager.h>
|
#include <fsfw/objectmanager/ObjectManager.h>
|
||||||
#include <fsfw/datapoollocal/HasLocalDataPoolIF.h>
|
#include <fsfw/datapoollocal/HasLocalDataPoolIF.h>
|
||||||
#include <unittest/core/CatchDefinitions.h>
|
|
||||||
|
|
||||||
TEST_CASE("LocalPoolVector" , "[LocPoolVecTest]") {
|
TEST_CASE("LocalPoolVector" , "[LocPoolVecTest]") {
|
||||||
LocalPoolOwnerBase* poolOwner = ObjectManager::instance()->
|
LocalPoolOwnerBase* poolOwner = ObjectManager::instance()->
|
||||||
|
@ -1,2 +1,3 @@
|
|||||||
target_sources(${TARGET_NAME} PRIVATE
|
target_sources(${TARGET_NAME} PRIVATE
|
||||||
|
testDleEncoder.cpp
|
||||||
)
|
)
|
||||||
|
62
tests/src/fsfw_tests/unit/globalfunctions/testDleEncoder.cpp
Normal file
62
tests/src/fsfw_tests/unit/globalfunctions/testDleEncoder.cpp
Normal file
@ -0,0 +1,62 @@
|
|||||||
|
#include "fsfw/globalfunctions/DleEncoder.h"
|
||||||
|
#include "fsfw_tests/unit/CatchDefinitions.h"
|
||||||
|
#include "catch2/catch_test_macros.hpp"
|
||||||
|
|
||||||
|
#include <array>
|
||||||
|
|
||||||
|
const std::array<uint8_t, 5> TEST_ARRAY_0 = { 0 };
|
||||||
|
const std::array<uint8_t, 3> TEST_ARRAY_1 = { 0, DleEncoder::DLE_CHAR, 5};
|
||||||
|
const std::array<uint8_t, 3> TEST_ARRAY_2 = { 0, DleEncoder::STX_CHAR, 5};
|
||||||
|
const std::array<uint8_t, 3> TEST_ARRAY_3 = { 0, DleEncoder::CARRIAGE_RETURN, DleEncoder::ETX_CHAR};
|
||||||
|
|
||||||
|
TEST_CASE("DleEncoder" , "[DleEncoder]") {
|
||||||
|
|
||||||
|
DleEncoder dleEncoder;
|
||||||
|
std::array<uint8_t, 32> buffer;
|
||||||
|
SECTION("Encoding") {
|
||||||
|
size_t encodedLen = 0;
|
||||||
|
ReturnValue_t result = dleEncoder.encode(TEST_ARRAY_0.data(), TEST_ARRAY_0.size(),
|
||||||
|
buffer.data(), buffer.size(), &encodedLen);
|
||||||
|
REQUIRE(result == retval::CATCH_OK);
|
||||||
|
std::vector<uint8_t> expected = {DleEncoder::STX_CHAR, 0, 0, 0, 0, 0,
|
||||||
|
DleEncoder::ETX_CHAR};
|
||||||
|
for(size_t idx = 0; idx < expected.size(); idx++) {
|
||||||
|
REQUIRE(buffer[idx] == expected[idx]);
|
||||||
|
}
|
||||||
|
REQUIRE(encodedLen == 7);
|
||||||
|
|
||||||
|
result = dleEncoder.encode(TEST_ARRAY_1.data(), TEST_ARRAY_1.size(),
|
||||||
|
buffer.data(), buffer.size(), &encodedLen);
|
||||||
|
REQUIRE(result == retval::CATCH_OK);
|
||||||
|
expected = std::vector<uint8_t>{DleEncoder::STX_CHAR, 0, DleEncoder::DLE_CHAR,
|
||||||
|
DleEncoder::DLE_CHAR, 5, DleEncoder::ETX_CHAR};
|
||||||
|
for(size_t idx = 0; idx < expected.size(); idx++) {
|
||||||
|
REQUIRE(buffer[idx] == expected[idx]);
|
||||||
|
}
|
||||||
|
REQUIRE(encodedLen == expected.size());
|
||||||
|
|
||||||
|
result = dleEncoder.encode(TEST_ARRAY_2.data(), TEST_ARRAY_2.size(),
|
||||||
|
buffer.data(), buffer.size(), &encodedLen);
|
||||||
|
REQUIRE(result == retval::CATCH_OK);
|
||||||
|
expected = std::vector<uint8_t>{DleEncoder::STX_CHAR, 0, DleEncoder::DLE_CHAR,
|
||||||
|
DleEncoder::STX_CHAR + 0x40, 5, DleEncoder::ETX_CHAR};
|
||||||
|
for(size_t idx = 0; idx < expected.size(); idx++) {
|
||||||
|
REQUIRE(buffer[idx] == expected[idx]);
|
||||||
|
}
|
||||||
|
REQUIRE(encodedLen == expected.size());
|
||||||
|
|
||||||
|
result = dleEncoder.encode(TEST_ARRAY_3.data(), TEST_ARRAY_3.size(),
|
||||||
|
buffer.data(), buffer.size(), &encodedLen);
|
||||||
|
REQUIRE(result == retval::CATCH_OK);
|
||||||
|
expected = std::vector<uint8_t>{DleEncoder::STX_CHAR, 0, DleEncoder::CARRIAGE_RETURN,
|
||||||
|
DleEncoder::DLE_CHAR, DleEncoder::ETX_CHAR + 0x40, DleEncoder::ETX_CHAR};
|
||||||
|
for(size_t idx = 0; idx < expected.size(); idx++) {
|
||||||
|
REQUIRE(buffer[idx] == expected[idx]);
|
||||||
|
}
|
||||||
|
REQUIRE(encodedLen == expected.size());
|
||||||
|
}
|
||||||
|
|
||||||
|
SECTION("Decoding") {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@ -1,9 +1,12 @@
|
|||||||
#ifndef FSFW_UNITTEST_TESTS_MOCKS_MESSAGEQUEUEMOCKBASE_H_
|
#ifndef FSFW_UNITTEST_TESTS_MOCKS_MESSAGEQUEUEMOCKBASE_H_
|
||||||
#define FSFW_UNITTEST_TESTS_MOCKS_MESSAGEQUEUEMOCKBASE_H_
|
#define FSFW_UNITTEST_TESTS_MOCKS_MESSAGEQUEUEMOCKBASE_H_
|
||||||
|
|
||||||
#include <fsfw/ipc/MessageQueueIF.h>
|
#include "fsfw_tests/unit/CatchDefinitions.h"
|
||||||
#include <fsfw/ipc/MessageQueueMessage.h>
|
|
||||||
#include <unittest/core/CatchDefinitions.h>
|
#include "fsfw/ipc/CommandMessage.h"
|
||||||
|
#include "fsfw/ipc/MessageQueueIF.h"
|
||||||
|
#include "fsfw/ipc/MessageQueueMessage.h"
|
||||||
|
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
|
||||||
#include <queue>
|
#include <queue>
|
||||||
|
@ -1,8 +1,9 @@
|
|||||||
|
#include "fsfw_tests/unit/CatchDefinitions.h"
|
||||||
|
|
||||||
#include <fsfw/ipc/MessageQueueIF.h>
|
#include <fsfw/ipc/MessageQueueIF.h>
|
||||||
#include <fsfw/ipc/QueueFactory.h>
|
#include <fsfw/ipc/QueueFactory.h>
|
||||||
|
|
||||||
#include <catch2/catch_test_macros.hpp>
|
#include <catch2/catch_test_macros.hpp>
|
||||||
#include <unittest/core/CatchDefinitions.h>
|
|
||||||
|
|
||||||
#include <array>
|
#include <array>
|
||||||
|
|
||||||
|
@ -1,7 +1,9 @@
|
|||||||
|
#include "fsfw_tests/unit/CatchDefinitions.h"
|
||||||
|
|
||||||
#include <fsfw/serialize/SerialBufferAdapter.h>
|
#include <fsfw/serialize/SerialBufferAdapter.h>
|
||||||
|
|
||||||
#include <catch2/catch_test_macros.hpp>
|
#include <catch2/catch_test_macros.hpp>
|
||||||
#include <unittest/core/CatchDefinitions.h>
|
|
||||||
|
|
||||||
#include <array>
|
#include <array>
|
||||||
|
|
||||||
|
@ -1,10 +1,9 @@
|
|||||||
#include "TestSerialLinkedPacket.h"
|
#include "TestSerialLinkedPacket.h"
|
||||||
#include <unittest/core/CatchDefinitions.h>
|
#include "fsfw_tests/unit/CatchDefinitions.h"
|
||||||
|
|
||||||
#include <fsfw/globalfunctions/arrayprinter.h>
|
#include <fsfw/globalfunctions/arrayprinter.h>
|
||||||
|
|
||||||
#include <catch2/catch_test_macros.hpp>
|
#include <catch2/catch_test_macros.hpp>
|
||||||
#include <unittest/core/CatchDefinitions.h>
|
|
||||||
|
|
||||||
#include <array>
|
#include <array>
|
||||||
|
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
|
#include "fsfw_tests/unit/CatchDefinitions.h"
|
||||||
#include <fsfw/serialize/SerializeAdapter.h>
|
#include <fsfw/serialize/SerializeAdapter.h>
|
||||||
|
|
||||||
#include <catch2/catch_test_macros.hpp>
|
#include <catch2/catch_test_macros.hpp>
|
||||||
#include <catch2/catch_approx.hpp>
|
#include <catch2/catch_approx.hpp>
|
||||||
#include <unittest/core/CatchDefinitions.h>
|
|
||||||
|
|
||||||
#include <array>
|
#include <array>
|
||||||
|
|
||||||
|
@ -1,6 +1,9 @@
|
|||||||
|
#include "fsfw_tests/unit/CatchDefinitions.h"
|
||||||
|
|
||||||
#include <fsfw/storagemanager/LocalPool.h>
|
#include <fsfw/storagemanager/LocalPool.h>
|
||||||
|
|
||||||
#include <catch2/catch_test_macros.hpp>
|
#include <catch2/catch_test_macros.hpp>
|
||||||
#include <unittest/core/CatchDefinitions.h>
|
|
||||||
#include <array>
|
#include <array>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
|
||||||
|
@ -1,8 +1,9 @@
|
|||||||
|
#include "fsfw_tests/unit/CatchDefinitions.h"
|
||||||
|
|
||||||
#include <fsfw/objectmanager/ObjectManager.h>
|
#include <fsfw/objectmanager/ObjectManager.h>
|
||||||
#include <fsfw/storagemanager/LocalPool.h>
|
#include <fsfw/storagemanager/LocalPool.h>
|
||||||
|
|
||||||
#include <catch2/catch_test_macros.hpp>
|
#include <catch2/catch_test_macros.hpp>
|
||||||
#include <unittest/core/CatchDefinitions.h>
|
|
||||||
|
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
|
||||||
|
@ -32,7 +32,7 @@ if(NOT FSFW_OSAL)
|
|||||||
set(FSFW_OSAL host CACHE STRING "OS for the FSFW.")
|
set(FSFW_OSAL host CACHE STRING "OS for the FSFW.")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
option(CUSTOM_UNITTEST_RUNNER
|
option(FSFW_CUSTOM_UNITTEST_RUNNER
|
||||||
"Specify whether custom main or Catch2 main is used" TRUE
|
"Specify whether custom main or Catch2 main is used" TRUE
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -49,7 +49,7 @@ set(CMAKE_CXX_STANDARD_REQUIRED True)
|
|||||||
|
|
||||||
# Set names and variables
|
# Set names and variables
|
||||||
set(TARGET_NAME ${CMAKE_PROJECT_NAME})
|
set(TARGET_NAME ${CMAKE_PROJECT_NAME})
|
||||||
if(CUSTOM_UNITTEST_RUNNER)
|
if(FSFW_CUSTOM_UNITTEST_RUNNER)
|
||||||
set(CATCH2_TARGET Catch2)
|
set(CATCH2_TARGET Catch2)
|
||||||
else()
|
else()
|
||||||
set(CATCH2_TARGET Catch2WithMain)
|
set(CATCH2_TARGET Catch2WithMain)
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
#ifndef FSFW_UNITTEST_CONFIG_TESTSCONFIG_H_
|
#ifndef FSFW_UNITTEST_CONFIG_TESTSCONFIG_H_
|
||||||
#define FSFW_UNITTEST_CONFIG_TESTSCONFIG_H_
|
#define FSFW_UNITTEST_CONFIG_TESTSCONFIG_H_
|
||||||
|
|
||||||
|
#define FSFW_ADD_DEFAULT_FACTORY_FUNCTIONS 1
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|
||||||
#include "objects/systemObjectList.h"
|
#include "objects/systemObjectList.h"
|
||||||
|
@ -1 +0,0 @@
|
|||||||
add_subdirectory(core)
|
|
@ -1,13 +0,0 @@
|
|||||||
target_sources(${TARGET_NAME} PRIVATE
|
|
||||||
CatchDefinitions.cpp
|
|
||||||
CatchFactory.cpp
|
|
||||||
CatchRunner.cpp
|
|
||||||
CatchSetup.cpp
|
|
||||||
printChar.cpp
|
|
||||||
)
|
|
||||||
|
|
||||||
if(CUSTOM_UNITTEST_RUNNER)
|
|
||||||
target_sources(${TARGET_NAME} PRIVATE
|
|
||||||
CatchRunner.cpp
|
|
||||||
)
|
|
||||||
endif()
|
|
@ -1,16 +0,0 @@
|
|||||||
#ifndef FSFW_CATCHFACTORY_H_
|
|
||||||
#define FSFW_CATCHFACTORY_H_
|
|
||||||
|
|
||||||
#include <fsfw/objectmanager/SystemObjectIF.h>
|
|
||||||
|
|
||||||
namespace Factory {
|
|
||||||
/**
|
|
||||||
* @brief Creates all SystemObject elements which are persistent
|
|
||||||
* during execution.
|
|
||||||
*/
|
|
||||||
void produce(void* args);
|
|
||||||
void setStaticFrameworkObjectIds();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif /* FSFW_CATCHFACTORY_H_ */
|
|
@ -1,3 +0,0 @@
|
|||||||
CXXSRC += $(wildcard $(CURRENTPATH)/*.cpp)
|
|
||||||
|
|
||||||
INCLUDES += $(CURRENTPATH)
|
|
Loading…
Reference in New Issue
Block a user