Merge remote-tracking branch 'upstream/development' into eive/develop

This commit is contained in:
Robin Müller 2021-09-16 11:40:12 +02:00
commit 7b5334ccec
No known key found for this signature in database
GPG Key ID: 11D4952C8CCEF814
55 changed files with 840 additions and 318 deletions

View File

@ -10,6 +10,7 @@ endif()
option(FSFW_WARNING_SHADOW_LOCAL_GCC "Enable -Wshadow=local warning in GCC" ON)
# Options to exclude parts of the FSFW from compilation.
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)
# Optional sources
@ -38,7 +39,7 @@ elseif(${CMAKE_CXX_STANDARD} LESS 11)
endif()
# 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")
set(FSFW_OSAL OS_FSFW)
endif()
@ -62,35 +63,28 @@ endif()
set(FSFW_OSAL_DEFINITION FSFW_OSAL_HOST)
if(FSFW_OSAL MATCHES host)
set(OS_FSFW_NAME "Host")
set(OS_FSFW_NAME "Host")
set(FSFW_OSAL_HOST ON)
elseif(FSFW_OSAL MATCHES linux)
set(OS_FSFW_NAME "Linux")
set(FSFW_OSAL_DEFINITION FSFW_OSAL_LINUX)
set(OS_FSFW_NAME "Linux")
set(FSFW_OSAL_LINUX ON)
elseif(FSFW_OSAL MATCHES freertos)
set(OS_FSFW_NAME "FreeRTOS")
set(FSFW_OSAL_DEFINITION FSFW_OSAL_FREERTOS)
target_link_libraries(${LIB_FSFW_NAME} PRIVATE
set(OS_FSFW_NAME "FreeRTOS")
set(FSFW_OSAL_FREERTOS ON)
target_link_libraries(${LIB_FSFW_NAME} PRIVATE
${LIB_OS_NAME}
)
)
elseif(FSFW_OSAL STREQUAL rtems)
set(OS_FSFW_NAME "RTEMS")
set(FSFW_OSAL_DEFINITION FSFW_OSAL_RTEMS)
set(OS_FSFW_NAME "RTEMS")
set(FSFW_OSAL_RTEMS ON)
else()
message(WARNING
"Invalid operating system for FSFW specified! Setting to host.."
)
set(OS_FSFW_NAME "Host")
set(OS_FSFW "host")
message(WARNING
"Invalid operating system for FSFW specified! Setting to host.."
)
set(OS_FSFW_NAME "Host")
set(OS_FSFW "host")
endif()
target_compile_definitions(${LIB_FSFW_NAME} PRIVATE
${FSFW_OSAL_DEFINITION}
)
target_compile_definitions(${LIB_FSFW_NAME} INTERFACE
${FSFW_OSAL_DEFINITION}
)
message(STATUS "Compiling FSFW for the ${OS_FSFW_NAME} operating system.")
add_subdirectory(src)

View File

@ -3,9 +3,9 @@
#include "fsfw/datapool/PoolReadGuard.h"
GyroHandlerL3GD20H::GyroHandlerL3GD20H(object_id_t objectId, object_id_t deviceCommunication,
CookieIF *comCookie):
CookieIF *comCookie, uint8_t switchId, uint32_t transitionDelayMs):
DeviceHandlerBase(objectId, deviceCommunication, comCookie),
dataset(this) {
switchId(switchId), transitionDelayMs(transitionDelayMs), dataset(this) {
#if FSFW_HAL_L3GD20_GYRO_DEBUG == 1
debugDivider = new PeriodicOperationDivider(5);
#endif
@ -47,7 +47,7 @@ ReturnValue_t GyroHandlerL3GD20H::buildTransitionDeviceCommand(DeviceCommandId_t
switch(internalState) {
case(InternalState::NONE):
case(InternalState::NORMAL): {
return HasReturnvaluesIF::RETURN_OK;
return NOTHING_TO_SEND;
}
case(InternalState::CONFIGURE): {
*id = L3GD20H::CONFIGURE_CTRL_REGS;
@ -66,10 +66,11 @@ ReturnValue_t GyroHandlerL3GD20H::buildTransitionDeviceCommand(DeviceCommandId_t
default:
#if FSFW_CPP_OSTREAM_ENABLED == 1
/* Might be a configuration error. */
sif::debug << "GyroHandler::buildTransitionDeviceCommand: Unknown internal state!" <<
std::endl;
sif::warning << "GyroL3GD20Handler::buildTransitionDeviceCommand: "
"Unknown internal state!" << std::endl;
#else
sif::printDebug("GyroHandler::buildTransitionDeviceCommand: Unknown internal state!\n");
sif::printDebug("GyroL3GD20Handler::buildTransitionDeviceCommand: "
"Unknown internal state!\n");
#endif
return HasReturnvaluesIF::RETURN_OK;
}
@ -144,7 +145,7 @@ ReturnValue_t GyroHandlerL3GD20H::buildCommandFromCommand(
ReturnValue_t GyroHandlerL3GD20H::scanForReply(const uint8_t *start, size_t len,
DeviceCommandId_t *foundId, size_t *foundLen) {
/* For SPI, the ID will always be the one of the last sent command. */
// For SPI, the ID will always be the one of the last sent command
*foundId = this->getPendingCommand();
*foundLen = this->rawPacketLen;
@ -166,7 +167,7 @@ ReturnValue_t GyroHandlerL3GD20H::interpretDeviceReply(DeviceCommandId_t id,
commandExecuted = true;
}
else {
/* Attempt reconfiguration. */
// Attempt reconfiguration
internalState = InternalState::CONFIGURE;
return DeviceHandlerIF::DEVICE_REPLY_INVALID;
}
@ -199,13 +200,12 @@ ReturnValue_t GyroHandlerL3GD20H::interpretDeviceReply(DeviceCommandId_t id,
if(debugDivider->checkAndIncrement()) {
/* Set terminal to utf-8 if there is an issue with micro printout. */
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::info << "GyroHandlerL3GD20H: Angular velocities in degrees per second:" <<
std::endl;
sif::info << "X: " << angVelocX << " \xC2\xB0" << std::endl;
sif::info << "Y: " << angVelocY << " \xC2\xB0" << std::endl;
sif::info << "Z: " << angVelocZ << " \xC2\xB0" << std::endl;
sif::info << "GyroHandlerL3GD20H: Angular velocities (deg/s):" << std::endl;
sif::info << "X: " << angVelocX << std::endl;
sif::info << "Y: " << angVelocY << std::endl;
sif::info << "Z: " << angVelocZ << std::endl;
#else
sif::printInfo("GyroHandlerL3GD20H: Angular velocities in degrees per second:\n");
sif::printInfo("GyroHandlerL3GD20H: Angular velocities (deg/s):\n");
sif::printInfo("X: %f\n", angVelocX);
sif::printInfo("Y: %f\n", angVelocY);
sif::printInfo("Z: %f\n", angVelocZ);
@ -231,7 +231,7 @@ ReturnValue_t GyroHandlerL3GD20H::interpretDeviceReply(DeviceCommandId_t id,
uint32_t GyroHandlerL3GD20H::getTransitionDelayMs(Mode_t from, Mode_t to) {
return 10000;
return this->transitionDelayMs;
}
void GyroHandlerL3GD20H::setGoNormalModeAtStartup() {
@ -240,14 +240,10 @@ void GyroHandlerL3GD20H::setGoNormalModeAtStartup() {
ReturnValue_t GyroHandlerL3GD20H::initializeLocalDataPool(
localpool::DataPool &localDataPoolMap, LocalDataPoolManager &poolManager) {
localDataPoolMap.emplace(L3GD20H::ANG_VELOC_X,
new PoolEntry<float>({0.0}));
localDataPoolMap.emplace(L3GD20H::ANG_VELOC_Y,
new PoolEntry<float>({0.0}));
localDataPoolMap.emplace(L3GD20H::ANG_VELOC_Z,
new PoolEntry<float>({0.0}));
localDataPoolMap.emplace(L3GD20H::TEMPERATURE,
new PoolEntry<float>({0.0}));
localDataPoolMap.emplace(L3GD20H::ANG_VELOC_X, new PoolEntry<float>({0.0}));
localDataPoolMap.emplace(L3GD20H::ANG_VELOC_Y, new PoolEntry<float>({0.0}));
localDataPoolMap.emplace(L3GD20H::ANG_VELOC_Z, new PoolEntry<float>({0.0}));
localDataPoolMap.emplace(L3GD20H::TEMPERATURE, new PoolEntry<float>({0.0}));
return HasReturnvaluesIF::RETURN_OK;
}

View File

@ -7,10 +7,6 @@
#include <fsfw/devicehandlers/DeviceHandlerBase.h>
#include <fsfw/globalfunctions/PeriodicOperationDivider.h>
#ifndef FSFW_HAL_L3GD20_GYRO_DEBUG
#define FSFW_HAL_L3GD20_GYRO_DEBUG 0
#endif /* FSFW_HAL_L3GD20_GYRO_DEBUG */
/**
* @brief Device Handler for the L3GD20H gyroscope sensor
* (https://www.st.com/en/mems-and-sensors/l3gd20h.html)
@ -23,9 +19,12 @@
class GyroHandlerL3GD20H: public DeviceHandlerBase {
public:
GyroHandlerL3GD20H(object_id_t objectId, object_id_t deviceCommunication,
CookieIF* comCookie);
CookieIF* comCookie, uint8_t switchId, uint32_t transitionDelayMs = 10000);
virtual ~GyroHandlerL3GD20H();
/**
* @brief Configure device handler to go to normal mode immediately
*/
void setGoNormalModeAtStartup();
protected:
@ -51,6 +50,8 @@ protected:
LocalDataPoolManager &poolManager) override;
private:
uint8_t switchId = 0;
uint32_t transitionDelayMs = 0;
GyroPrimaryDataset dataset;
enum class InternalState {

View File

@ -15,10 +15,10 @@ UnixFileGuard::UnixFileGuard(std::string device, int* fileDescriptor, int flags,
if (*fileDescriptor < 0) {
#if FSFW_VERBOSE_LEVEL >= 1
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::warning << diagnosticPrefix << "Opening device failed with error code " <<
sif::warning << diagnosticPrefix << ": Opening device failed with error code " <<
errno << ": " << strerror(errno) << std::endl;
#else
sif::printWarning("%sOpening device failed with error code %d: %s\n",
sif::printWarning("%s: Opening device failed with error code %d: %s\n",
diagnosticPrefix, errno, strerror(errno));
#endif /* FSFW_CPP_OSTREAM_ENABLED == 1 */
#endif /* FSFW_VERBOSE_LEVEL >= 1 */

View File

@ -85,7 +85,7 @@ ReturnValue_t SpiComIF::initializeInterface(CookieIF *cookie) {
int fileDescriptor = 0;
UnixFileGuard fileHelper(spiCookie->getSpiDevice(), &fileDescriptor, O_RDWR,
"SpiComIF::initializeInterface: ");
"SpiComIF::initializeInterface");
if(fileHelper.getOpenResult() != HasReturnvaluesIF::RETURN_OK) {
return fileHelper.getOpenResult();
}
@ -179,7 +179,7 @@ ReturnValue_t SpiComIF::performRegularSendOperation(SpiCookie *spiCookie, const
/* Prepare transfer */
int fileDescriptor = 0;
std::string device = spiCookie->getSpiDevice();
UnixFileGuard fileHelper(device, &fileDescriptor, O_RDWR, "SpiComIF::sendMessage: ");
UnixFileGuard fileHelper(device, &fileDescriptor, O_RDWR, "SpiComIF::sendMessage");
if(fileHelper.getOpenResult() != HasReturnvaluesIF::RETURN_OK) {
return OPENING_FILE_FAILED;
}
@ -268,7 +268,7 @@ ReturnValue_t SpiComIF::performHalfDuplexReception(SpiCookie* spiCookie) {
std::string device = spiCookie->getSpiDevice();
int fileDescriptor = 0;
UnixFileGuard fileHelper(device, &fileDescriptor, O_RDWR,
"SpiComIF::requestReceiveMessage: ");
"SpiComIF::requestReceiveMessage");
if(fileHelper.getOpenResult() != HasReturnvaluesIF::RETURN_OK) {
return OPENING_FILE_FAILED;
}

View File

@ -1,6 +1,7 @@
#include "fsfw_hal/linux/uart/UartComIF.h"
#include "UartComIF.h"
#include "OBSWConfig.h"
#include "fsfw_hal/linux/utility.h"
#include "fsfw/serviceinterface/ServiceInterface.h"
#include <cstring>
@ -60,7 +61,13 @@ int UartComIF::configureUartPort(UartCookie* uartCookie) {
struct termios options = {};
std::string deviceFile = uartCookie->getDeviceFile();
int fd = open(deviceFile.c_str(), O_RDWR);
int flags = O_RDWR;
if(uartCookie->getUartMode() == UartModes::CANONICAL) {
// In non-canonical mode, don't specify O_NONBLOCK because these properties will be
// controlled by the VTIME and VMIN parameters and O_NONBLOCK would override this
flags |= O_NONBLOCK;
}
int fd = open(deviceFile.c_str(), flags);
if (fd < 0) {
sif::warning << "UartComIF::configureUartPort: Failed to open uart " << deviceFile <<
@ -259,23 +266,22 @@ void UartComIF::configureBaudrate(struct termios* options, UartCookie* uartCooki
ReturnValue_t UartComIF::sendMessage(CookieIF *cookie,
const uint8_t *sendData, size_t sendLen) {
int fd = 0;
std::string deviceFile;
UartDeviceMapIter uartDeviceMapIter;
if(sendData == nullptr) {
sif::debug << "UartComIF::sendMessage: Send Data is nullptr" << std::endl;
return RETURN_FAILED;
}
if(sendLen == 0) {
return RETURN_OK;
}
if(sendData == nullptr) {
sif::warning << "UartComIF::sendMessage: Send data is nullptr" << std::endl;
return RETURN_FAILED;
}
UartCookie* uartCookie = dynamic_cast<UartCookie*>(cookie);
if(uartCookie == nullptr) {
sif::debug << "UartComIF::sendMessasge: Invalid UART Cookie!" << std::endl;
sif::warning << "UartComIF::sendMessasge: Invalid UART Cookie!" << std::endl;
return NULLPOINTER;
}
@ -347,12 +353,13 @@ ReturnValue_t UartComIF::handleCanonicalRead(UartCookie& uartCookie, UartDeviceM
size_t maxReplySize = uartCookie.getMaxReplyLen();
int fd = iter->second.fileDescriptor;
auto bufferPtr = iter->second.replyBuffer.data();
iter->second.replyLen = 0;
do {
size_t allowedReadSize = 0;
if(currentBytesRead >= maxReplySize) {
// Overflow risk. Emit warning, trigger event and break. If this happens,
// the reception buffer is not large enough or data is not polled often enough.
#if OBSW_VERBOSE_LEVEL >= 1
#if FSFW_VERBOSE_LEVEL >= 1
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::warning << "UartComIF::requestReceiveMessage: Next read would cause overflow!"
<< std::endl;
@ -370,7 +377,20 @@ ReturnValue_t UartComIF::handleCanonicalRead(UartCookie& uartCookie, UartDeviceM
bytesRead = read(fd, bufferPtr, allowedReadSize);
if (bytesRead < 0) {
return RETURN_FAILED;
// EAGAIN: No data available in non-blocking mode
if(errno != EAGAIN) {
#if FSFW_VERBOSE_LEVEL >= 1
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::warning << "UartComIF::handleCanonicalRead: read failed with code" <<
errno << ": " << strerror(errno) << std::endl;
#else
sif::printWarning("UartComIF::handleCanonicalRead: read failed with code %d: %s\n",
errno, strerror(errno));
#endif
#endif
return RETURN_FAILED;
}
}
else if(bytesRead > 0) {
iter->second.replyLen += bytesRead;

View File

@ -4,8 +4,8 @@
UartCookie::UartCookie(object_id_t handlerId, std::string deviceFile, UartModes uartMode,
uint32_t baudrate, size_t maxReplyLen):
handlerId(handlerId), deviceFile(deviceFile), uartMode(uartMode), baudrate(baudrate),
maxReplyLen(maxReplyLen) {
handlerId(handlerId), deviceFile(deviceFile), uartMode(uartMode),
baudrate(baudrate), maxReplyLen(maxReplyLen) {
}
UartCookie::~UartCookie() {}

View File

@ -3,6 +3,11 @@
#include "FSFWConfig.h"
#cmakedefine FSFW_OSAL_RTEMS
#cmakedefine FSFW_OSAL_FREERTOS
#cmakedefine FSFW_OSAL_LINUX
#cmakedefine FSFW_OSAL_HOST
#cmakedefine FSFW_ADD_RMAP
#cmakedefine FSFW_ADD_DATALINKLAYER
#cmakedefine FSFW_ADD_TMSTORAGE

View File

@ -4,7 +4,7 @@
const char* const FSFW_VERSION_NAME = "ASTP";
#define FSFW_VERSION 1
#define FSFW_SUBVERSION 3
#define FSFW_REVISION 0
#define FSFW_SUBVERSION 2
#define FSFW_REVISION 0
#endif /* FSFW_VERSION_H_ */

View File

@ -32,6 +32,17 @@ ReturnValue_t ActionHelper::initialize(MessageQueueIF* queueToUse_) {
setQueueToUse(queueToUse_);
}
if(queueToUse == nullptr) {
#if FSFW_VERBOSE_LEVEL >= 1
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::warning << "ActionHelper::initialize: No queue set" << std::endl;
#else
sif::printWarning("ActionHelper::initialize: No queue set\n");
#endif
#endif /* FSFW_VERBOSE_LEVEL >= 1 */
return HasReturnvaluesIF::RETURN_FAILED;
}
return HasReturnvaluesIF::RETURN_OK;
}

View File

@ -469,7 +469,7 @@ ReturnValue_t DeviceHandlerBase::updateReplyMapEntry(DeviceCommandId_t deviceRep
auto replyIter = deviceReplyMap.find(deviceReply);
if (replyIter == deviceReplyMap.end()) {
triggerEvent(INVALID_DEVICE_COMMAND, deviceReply);
return RETURN_FAILED;
return COMMAND_NOT_SUPPORTED;
} else {
DeviceReplyInfo *info = &(replyIter->second);
if (maxDelayCycles != 0) {
@ -481,6 +481,25 @@ ReturnValue_t DeviceHandlerBase::updateReplyMapEntry(DeviceCommandId_t deviceRep
}
}
ReturnValue_t DeviceHandlerBase::updatePeriodicReply(bool enable, DeviceCommandId_t deviceReply) {
auto replyIter = deviceReplyMap.find(deviceReply);
if (replyIter == deviceReplyMap.end()) {
triggerEvent(INVALID_DEVICE_COMMAND, deviceReply);
return COMMAND_NOT_SUPPORTED;
} else {
DeviceReplyInfo *info = &(replyIter->second);
if(not info->periodic) {
return COMMAND_NOT_SUPPORTED;
}
if(enable) {
info->delayCycles = info->maxDelayCycles;
}
else {
info->delayCycles = 0;
}
}
return HasReturnvaluesIF::RETURN_OK;
}
ReturnValue_t DeviceHandlerBase::setReplyDataset(DeviceCommandId_t replyId,
LocalPoolDataSetBase *dataSet) {

View File

@ -449,7 +449,9 @@ protected:
* @param replyLen Will be supplied to the requestReceiveMessage call of
* the communication interface.
* @param periodic Indicates if the command is periodic (i.e. it is sent
* by the device repeatedly without request) or not. Default is aperiodic (0)
* by the device repeatedly without request) or not. Default is aperiodic (0).
* Please note that periodic replies are disabled by default. You can enable them with
* #updatePeriodicReply
* @return - @c RETURN_OK when the command was successfully inserted,
* - @c RETURN_FAILED else.
*/
@ -464,7 +466,9 @@ protected:
* @param maxDelayCycles The maximum number of delay cycles the reply waits
* until it times out.
* @param periodic Indicates if the command is periodic (i.e. it is sent
* by the device repeatedly without request) or not. Default is aperiodic (0)
* by the device repeatedly without request) or not. Default is aperiodic (0).
* Please note that periodic replies are disabled by default. You can enable them with
* #updatePeriodicReply
* @return - @c RETURN_OK when the command was successfully inserted,
* - @c RETURN_FAILED else.
*/
@ -480,6 +484,14 @@ protected:
*/
ReturnValue_t insertInCommandMap(DeviceCommandId_t deviceCommand);
/**
* Enables a periodic reply for a given command. It sets to delay cycles to the specified
* maximum delay cycles for a given reply ID if enabled or to 0 if disabled.
* @param enable Specify whether to enable or disable a given periodic reply
* @return
*/
ReturnValue_t updatePeriodicReply(bool enable, DeviceCommandId_t deviceReply);
/**
* @brief This function returns the reply length of the next reply to read.
*
@ -493,16 +505,14 @@ protected:
virtual size_t getNextReplyLength(DeviceCommandId_t deviceCommand);
/**
* @brief This is a helper method to facilitate updating entries
* in the reply map.
* @brief This is a helper method to facilitate updating entries in the reply map.
* @param deviceCommand Identifier of the reply to update.
* @param delayCycles The current number of delay cycles to wait.
* As stated in #fillCommandAndCookieMap, to disable periodic commands,
* this is set to zero.
* @param delayCycles The current number of delay cycles to wait. As stated in
* #fillCommandAndReplyMap, to disable periodic commands, this is set to zero.
* @param maxDelayCycles The maximum number of delay cycles the reply waits
* until it times out. By passing 0 the entry remains untouched.
* @param periodic Indicates if the command is periodic (i.e. it is sent
* by the device repeatedly without request) or not.Default is aperiodic (0).
* by the device repeatedly without request) or not. Default is aperiodic (0).
* Warning: The setting always overrides the value that was entered in the map.
* @return - @c RETURN_OK when the command was successfully inserted,
* - @c RETURN_FAILED else.

View File

@ -1,124 +1,296 @@
#include "fsfw/globalfunctions/DleEncoder.h"
DleEncoder::DleEncoder() {}
DleEncoder::DleEncoder(bool escapeStxEtx, bool escapeCr):
escapeStxEtx(escapeStxEtx), escapeCr(escapeCr) {}
DleEncoder::~DleEncoder() {}
ReturnValue_t DleEncoder::encode(const uint8_t* sourceStream,
size_t sourceLen, uint8_t* destStream, size_t maxDestLen,
size_t* encodedLen, bool addStxEtx) {
if (maxDestLen < 2) {
return STREAM_TOO_SHORT;
}
size_t encodedIndex = 0, sourceIndex = 0;
uint8_t nextByte;
if (addStxEtx) {
destStream[0] = STX_CHAR;
++encodedIndex;
}
size_t sourceLen, uint8_t* destStream, size_t maxDestLen,
size_t* encodedLen, bool addStxEtx) {
if(escapeStxEtx) {
return encodeStreamEscaped(sourceStream, sourceLen,
destStream, maxDestLen, encodedLen, addStxEtx);
}
else {
return encodeStreamNonEscaped(sourceStream, sourceLen,
destStream, maxDestLen, encodedLen, addStxEtx);
}
while (encodedIndex < maxDestLen and sourceIndex < sourceLen)
{
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 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::encodeStreamEscaped(const uint8_t *sourceStream, size_t sourceLen,
uint8_t *destStream, size_t maxDestLen, size_t *encodedLen,
bool addStxEtx) {
size_t encodedIndex = 0;
size_t sourceIndex = 0;
uint8_t nextByte = 0;
if(addStxEtx) {
if(maxDestLen < 1) {
return STREAM_TOO_SHORT;
}
destStream[encodedIndex++] = STX_CHAR;
}
while (encodedIndex < maxDestLen and sourceIndex < sourceLen) {
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) {
if (addStxEtx) {
if(encodedIndex + 1 >= maxDestLen) {
return STREAM_TOO_SHORT;
}
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 = 0;
size_t sourceIndex = 0;
uint8_t nextByte = 0;
if(addStxEtx) {
if(maxDestLen < 2) {
return STREAM_TOO_SHORT;
}
destStream[encodedIndex++] = DLE_CHAR;
destStream[encodedIndex++] = STX_CHAR;
}
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) {
if (addStxEtx) {
if(encodedIndex + 2 >= maxDestLen) {
return STREAM_TOO_SHORT;
}
destStream[encodedIndex++] = DLE_CHAR;
destStream[encodedIndex++] = ETX_CHAR;
}
*encodedLen = encodedIndex;
return RETURN_OK;
}
else {
return STREAM_TOO_SHORT;
}
}
ReturnValue_t DleEncoder::decode(const uint8_t *sourceStream,
size_t sourceStreamLen, size_t *readLen, uint8_t *destStream,
size_t maxDestStreamlen, size_t *decodedLen) {
size_t encodedIndex = 0, decodedIndex = 0;
uint8_t nextByte;
if (*sourceStream != STX_CHAR) {
return DECODING_ERROR;
}
++encodedIndex;
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) {
*readLen = ++encodedIndex;
return DECODING_ERROR;
}
else {
*readLen = ++encodedIndex;
*decodedLen = decodedIndex;
return RETURN_OK;
}
size_t sourceStreamLen, size_t *readLen, uint8_t *destStream,
size_t maxDestStreamlen, size_t *decodedLen) {
if(escapeStxEtx) {
return decodeStreamEscaped(sourceStream, sourceStreamLen,
readLen, destStream, maxDestStreamlen, decodedLen);
}
else {
return decodeStreamNonEscaped(sourceStream, sourceStreamLen,
readLen, destStream, maxDestStreamlen, decodedLen);
}
}
ReturnValue_t DleEncoder::decodeStreamEscaped(const uint8_t *sourceStream, size_t sourceStreamLen,
size_t *readLen, uint8_t *destStream,
size_t maxDestStreamlen, size_t *decodedLen) {
size_t encodedIndex = 0;
size_t decodedIndex = 0;
uint8_t nextByte;
//init to 0 so that we can just return in the first checks (which do not consume anything from
//the source stream)
*readLen = 0;
if(maxDestStreamlen < 1) {
return STREAM_TOO_SHORT;
}
if (sourceStream[encodedIndex++] != STX_CHAR) {
return DECODING_ERROR;
}
while ((encodedIndex < sourceStreamLen)
and (decodedIndex < maxDestStreamlen)
and (sourceStream[encodedIndex] != ETX_CHAR)
and (sourceStream[encodedIndex] != STX_CHAR)) {
if (sourceStream[encodedIndex] == DLE_CHAR) {
if(encodedIndex + 1 >= sourceStreamLen) {
//reached the end of the sourceStream
*readLen = sourceStreamLen;
return DECODING_ERROR;
}
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 {
// Set readLen so user can resume parsing after incorrect data
*readLen = encodedIndex + 2;
return DECODING_ERROR;
}
}
++encodedIndex;
}
else {
destStream[decodedIndex] = sourceStream[encodedIndex];
}
++encodedIndex;
++decodedIndex;
}
if (sourceStream[encodedIndex] != ETX_CHAR) {
if(decodedIndex == maxDestStreamlen) {
//so far we did not find anything wrong here, so let user try again
*readLen = 0;
return STREAM_TOO_SHORT;
}
else {
*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) {
size_t encodedIndex = 0;
size_t decodedIndex = 0;
uint8_t nextByte;
//init to 0 so that we can just return in the first checks (which do not consume anything from
//the source stream)
*readLen = 0;
if(maxDestStreamlen < 2) {
return STREAM_TOO_SHORT;
}
if (sourceStream[encodedIndex++] != DLE_CHAR) {
return DECODING_ERROR;
}
if (sourceStream[encodedIndex++] != STX_CHAR) {
*readLen = 1;
return DECODING_ERROR;
}
while ((encodedIndex < sourceStreamLen) && (decodedIndex < maxDestStreamlen)) {
if (sourceStream[encodedIndex] == DLE_CHAR) {
if(encodedIndex + 1 >= sourceStreamLen) {
*readLen = encodedIndex;
return DECODING_ERROR;
}
nextByte = sourceStream[encodedIndex + 1];
if(nextByte == STX_CHAR) {
// Set readLen so the DLE/STX char combination is preserved. Could be start of
// another frame
*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 {
*readLen = encodedIndex;
return DECODING_ERROR;
}
}
else {
destStream[decodedIndex] = sourceStream[encodedIndex];
}
++encodedIndex;
++decodedIndex;
}
if(decodedIndex == maxDestStreamlen) {
//so far we did not find anything wrong here, so let user try again
*readLen = 0;
return STREAM_TOO_SHORT;
} else {
*readLen = encodedIndex;
return DECODING_ERROR;
}
}
void DleEncoder::setEscapeMode(bool escapeStxEtx) {
this->escapeStxEtx = escapeStxEtx;
}

View File

@ -1,7 +1,7 @@
#ifndef FRAMEWORK_GLOBALFUNCTIONS_DLEENCODER_H_
#define FRAMEWORK_GLOBALFUNCTIONS_DLEENCODER_H_
#include "../returnvalues/HasReturnvaluesIF.h"
#include "fsfw/returnvalues/HasReturnvaluesIF.h"
#include <cstddef>
/**
@ -12,52 +12,69 @@
* https://en.wikipedia.org/wiki/C0_and_C1_control_codes
*
* This encoder can be used to achieve a basic transport layer when using
* char based transmission systems.
* 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.
* char based transmission systems. There are two implemented variants:
*
* 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
* 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 {
private:
DleEncoder();
virtual ~DleEncoder();
public:
static constexpr uint8_t INTERFACE_ID = CLASS_ID::DLE_ENCODER;
static constexpr ReturnValue_t STREAM_TOO_SHORT = MAKE_RETURN_CODE(0x01);
static constexpr ReturnValue_t DECODING_ERROR = MAKE_RETURN_CODE(0x02);
/**
* Create an encoder instance with the given configuration.
* @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);
//! Start Of Text character. First character is encoded stream
static constexpr uint8_t STX_CHAR = 0x02;
//! End Of Text character. Last character in encoded stream
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;
void setEscapeMode(bool escapeStxEtx);
virtual ~DleEncoder();
static constexpr uint8_t INTERFACE_ID = CLASS_ID::DLE_ENCODER;
static constexpr ReturnValue_t STREAM_TOO_SHORT = MAKE_RETURN_CODE(0x01);
static constexpr ReturnValue_t DECODING_ERROR = MAKE_RETURN_CODE(0x02);
//! Start Of Text character. First character is encoded stream
static constexpr uint8_t STX_CHAR = 0x02;
//! End Of Text character. Last character in encoded stream
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
* and ending it with an ETX marker. STX, ETX and DLE characters inside
* the stream are escaped by DLE characters and also replaced by adding
* 0x40 (which is reverted in the decoding process).
* and ending it with an ETX marker. DLE characters inside
* the stream are escaped by DLE characters. STX, ETX and CR characters can be escaped with a
* 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 sourceLen
* @param destStream
* @param maxDestLen
* @param encodedLen
* @param addStxEtx
* Adding STX and ETX can be omitted, if they are added manually.
* @param addStxEtx Adding STX start marker and ETX end marker can be omitted,
* if they are added manually
* @return
* - RETURN_OK for successful encoding operation
* - STREAM_TOO_SHORT if the destination stream is too short
*/
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,
bool addStxEtx = true);
@ -70,10 +87,32 @@ public:
* @param maxDestStreamlen
* @param decodedLen
* @return
* - RETURN_OK for successful decode operation
* - DECODE_ERROR if the source stream is invalid
* - STREAM_TOO_SHORT if the destination stream is too short
*/
static ReturnValue_t decode(const uint8_t *sourceStream,
size_t sourceStreamLen, size_t *readLen, uint8_t *destStream,
size_t maxDestStreamlen, size_t *decodedLen);
ReturnValue_t decode(const uint8_t *sourceStream,
size_t sourceStreamLen, size_t *readLen, uint8_t *destStream,
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_ */

View File

@ -13,10 +13,10 @@
/**
* @brief FailureReport class to serialize a failure report
* @brief Subservice 1, 3, 5, 7
* @brief Subservice 2, 4, 6, 8
* @ingroup spacepackets
*/
class FailureReport: public SerializeIF { //!< [EXPORT] : [SUBSERVICE] 1, 3, 5, 7
class FailureReport: public SerializeIF { //!< [EXPORT] : [SUBSERVICE] 2, 4, 6, 8
public:
FailureReport(uint8_t failureSubtype_, uint16_t packetId_,
uint16_t packetSequenceControl_, uint8_t stepNumber_,
@ -108,10 +108,10 @@ private:
};
/**
* @brief Subservices 2, 4, 6, 8
* @brief Subservices 1, 3, 5, 7
* @ingroup spacepackets
*/
class SuccessReport: public SerializeIF { //!< [EXPORT] : [SUBSERVICE] 2, 4, 6, 8
class SuccessReport: public SerializeIF { //!< [EXPORT] : [SUBSERVICE] 1, 3, 5, 7
public:
SuccessReport(uint8_t subtype_, uint16_t packetId_,
uint16_t packetSequenceControl_,uint8_t stepNumber_) :

View File

@ -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(container)
add_subdirectory(osal)

View File

@ -1,17 +1,21 @@
#include "CatchFactory.h"
#include "datapoollocal/LocalPoolOwnerBase.h"
#include "mocks/HkReceiverMock.h"
#include <fsfw/datapoollocal/LocalDataPoolManager.h>
#include <fsfw/devicehandlers/DeviceHandlerBase.h>
#include <fsfw/events/EventManager.h>
#include <fsfw/health/HealthTable.h>
#include <fsfw/internalError/InternalErrorReporter.h>
#include <fsfw/internalerror/InternalErrorReporter.h>
#include <fsfw/objectmanager/frameworkObjects.h>
#include <fsfw/storagemanager/PoolManager.h>
#include <fsfw/tmtcpacket/pus/tm/TmPacketStored.h>
#include <fsfw/tmtcservices/CommandingServiceBase.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.
@ -26,7 +30,7 @@
*
* @ingroup init
*/
void Factory::produce(void) {
void Factory::produceFrameworkObjects(void* args) {
setStaticFrameworkObjectIds();
new EventManager(objects::EVENT_MANAGER);
new HealthTable(objects::HEALTH_TABLE);
@ -55,7 +59,6 @@ void Factory::produce(void) {
};
new PoolManager(objects::IPC_STORE, poolCfg);
}
}
void Factory::setStaticFrameworkObjectIds() {
@ -77,5 +80,4 @@ void Factory::setStaticFrameworkObjectIds() {
TmPacketBase::timeStamperId = objects::NO_OBJECT;
}
#endif

View File

@ -0,0 +1,24 @@
#ifndef FSFW_CATCHFACTORY_H_
#define FSFW_CATCHFACTORY_H_
#include "TestsConfig.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_ */

View File

@ -6,7 +6,7 @@
* from the eclipse market place to get colored characters.
*/
#include <TestsConfig.h>
#include "CatchRunner.h"
#define CATCH_CONFIG_COLOUR_WINDOWS
@ -14,11 +14,11 @@
extern int customSetup();
int main( int argc, char* argv[] ) {
int fsfwtest::customMain(int argc, char* argv[]) {
customSetup();
// Catch internal function call
int result = Catch::Session().run( argc, argv );
int result = Catch::Session().run(argc, argv);
// global clean-up
return result;

View 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_ */

View File

@ -5,10 +5,9 @@
#include <gcov.h>
#endif
#include <fsfw/objectmanager/ObjectManager.h>
#include <fsfw/objectmanager/ObjectManagerIF.h>
#include <fsfw/storagemanager/StorageManagerIF.h>
#include <fsfw/serviceinterface/ServiceInterfaceStream.h>
#include "fsfw/objectmanager/ObjectManager.h"
#include "fsfw/storagemanager/StorageManagerIF.h"
#include "fsfw/serviceinterface/ServiceInterface.h"
/* Global instantiations normally done in main.cpp */
@ -24,13 +23,11 @@ ServiceInterfaceStream warning("WARNING");
}
#endif
/* Global object manager */
ObjectManagerIF *objectManager;
int customSetup() {
// global setup
objectManager = new ObjectManager(Factory::produce);
objectManager -> initialize();
ObjectManager* objMan = ObjectManager::instance();
objMan->setObjectFactoryFunction(Factory::produceFrameworkObjects, nullptr);
objMan->initialize();
return 0;
}

View File

@ -1,13 +1,10 @@
#include "TestActionHelper.h"
#include <unittest/core/CatchDefinitions.h>
#include "fsfw_tests/unit/mocks/MessageQueueMockBase.h"
#include <fsfw/action/ActionHelper.h>
#include <fsfw/ipc/CommandMessage.h>
#include <fsfw/tests/unit/mocks/MessageQueueMockBase.h>
#include <catch2/catch_test_macros.hpp>
#include <array>

View File

@ -1,12 +1,11 @@
#ifndef UNITTEST_HOSTED_TESTACTIONHELPER_H_
#define UNITTEST_HOSTED_TESTACTIONHELPER_H_
#include "fsfw_tests/unit/CatchDefinitions.h"
#include <fsfw/action/HasActionsIF.h>
#include <fsfw/ipc/MessageQueueIF.h>
#include <unittest/core/CatchDefinitions.h>
#include <cstring>
class ActionHelperOwnerMockBase: public HasActionsIF {
public:
bool getCommandQueueCalled = false;

View File

@ -1,4 +1,4 @@
#include <unittest/core/CatchDefinitions.h>
#include "fsfw_tests/unit/CatchDefinitions.h"
#include <fsfw/container/SimpleRingBuffer.h>
#include <catch2/catch_test_macros.hpp>

View File

@ -1,8 +1,9 @@
#include "fsfw_tests/unit/CatchDefinitions.h"
#include <fsfw/container/ArrayList.h>
#include <fsfw/returnvalues/HasReturnvaluesIF.h>
#include <catch2/catch_test_macros.hpp>
#include <unittest/core/CatchDefinitions.h>
/**
* @brief Array List test

View File

@ -1,9 +1,10 @@
#include "fsfw_tests/unit/CatchDefinitions.h"
#include <fsfw/container/DynamicFIFO.h>
#include <fsfw/container/FIFO.h>
#include <fsfw/returnvalues/HasReturnvaluesIF.h>
#include <catch2/catch_test_macros.hpp>
#include <unittest/core/CatchDefinitions.h>
TEST_CASE( "Dynamic Fifo Tests", "[TestDynamicFifo]") {
INFO("Dynamic Fifo Tests");

View File

@ -1,9 +1,10 @@
#include "fsfw_tests/unit/CatchDefinitions.h"
#include <fsfw/container/DynamicFIFO.h>
#include <fsfw/container/FIFO.h>
#include <fsfw/returnvalues/HasReturnvaluesIF.h>
#include <catch2/catch_test_macros.hpp>
#include <unittest/core/CatchDefinitions.h>
TEST_CASE( "Static Fifo Tests", "[TestFifo]") {
INFO("Fifo Tests");

View File

@ -1,8 +1,9 @@
#include "fsfw_tests/unit/CatchDefinitions.h"
#include <fsfw/container/FixedArrayList.h>
#include <fsfw/returnvalues/HasReturnvaluesIF.h>
#include <catch2/catch_test_macros.hpp>
#include <unittest/core/CatchDefinitions.h>
TEST_CASE( "FixedArrayList Tests", "[TestFixedArrayList]") {

View File

@ -1,8 +1,9 @@
#include "fsfw_tests/unit/CatchDefinitions.h"
#include <fsfw/container/FixedMap.h>
#include <fsfw/returnvalues/HasReturnvaluesIF.h>
#include <catch2/catch_test_macros.hpp>
#include <unittest/core/CatchDefinitions.h>
template class FixedMap<unsigned int, unsigned short>;

View File

@ -1,8 +1,9 @@
#include "fsfw_tests/unit/CatchDefinitions.h"
#include <fsfw/container/FixedOrderedMultimap.h>
#include <fsfw/returnvalues/HasReturnvaluesIF.h>
#include <catch2/catch_test_macros.hpp>
#include <unittest/core/CatchDefinitions.h>
TEST_CASE( "FixedOrderedMultimap Tests", "[TestFixedOrderedMultimap]") {
INFO("FixedOrderedMultimap Tests");

View File

@ -1,10 +1,11 @@
#include "fsfw_tests/unit/CatchDefinitions.h"
#include <fsfw/container/PlacementFactory.h>
#include <fsfw/storagemanager/LocalPool.h>
#include <fsfw/returnvalues/HasReturnvaluesIF.h>
#include <fsfw/container/ArrayList.h>
#include <catch2/catch_test_macros.hpp>
#include <unittest/core/CatchDefinitions.h>
TEST_CASE( "PlacementFactory Tests", "[TestPlacementFactory]") {
INFO("PlacementFactory Tests");

View File

@ -1,7 +1,5 @@
#include "LocalPoolOwnerBase.h"
#include <catch2/catch_test_macros.hpp>
#include <catch2/catch_approx.hpp>
#include "fsfw_tests/unit/CatchDefinitions.h"
#include <fsfw/objectmanager/ObjectManager.h>
#include <fsfw/datapoollocal/HasLocalDataPoolIF.h>
@ -10,7 +8,8 @@
#include <fsfw/datapool/PoolReadGuard.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]") {
LocalPoolOwnerBase* poolOwner = ObjectManager::instance()->

View File

@ -1,7 +1,5 @@
#include "LocalPoolOwnerBase.h"
#include <catch2/catch_test_macros.hpp>
#include <catch2/catch_approx.hpp>
#include "fsfw_tests/unit/CatchDefinitions.h"
#include <fsfw/objectmanager/ObjectManager.h>
#include <fsfw/datapool/PoolReadGuard.h>
@ -10,7 +8,10 @@
#include <fsfw/housekeeping/HousekeepingSnapshot.h>
#include <fsfw/ipc/CommandMessageCleaner.h>
#include <fsfw/timemanager/CCSDSTime.h>
#include <unittest/core/CatchDefinitions.h>
#include <catch2/catch_test_macros.hpp>
#include <catch2/catch_approx.hpp>
#include <iostream>

View File

@ -2,6 +2,7 @@
#define FSFW_UNITTEST_TESTS_DATAPOOLLOCAL_LOCALPOOLOWNERBASE_H_
#include "objects/systemObjectList.h"
#include "../mocks/MessageQueueMockBase.h"
#include <fsfw/datapoollocal/HasLocalDataPoolIF.h>
#include <fsfw/datapoollocal/LocalDataSet.h>
@ -10,7 +11,6 @@
#include <fsfw/datapoollocal/LocalPoolVector.h>
#include <fsfw/ipc/QueueFactory.h>
#include <fsfw/datapoollocal/StaticLocalDataSet.h>
#include <fsfw/tests/unit/mocks/MessageQueueMockBase.h>
#include <fsfw/datapool/PoolReadGuard.h>
namespace lpool {

View File

@ -1,10 +1,10 @@
#include "LocalPoolOwnerBase.h"
#include "fsfw_tests/unit/CatchDefinitions.h"
#include <catch2/catch_test_macros.hpp>
#include <fsfw/objectmanager/ObjectManager.h>
#include <fsfw/datapoollocal/HasLocalDataPoolIF.h>
#include <unittest/core/CatchDefinitions.h>
#include <catch2/catch_test_macros.hpp>
TEST_CASE("LocalPoolVariable" , "[LocPoolVarTest]") {
LocalPoolOwnerBase* poolOwner = ObjectManager::instance()->

View File

@ -1,9 +1,10 @@
#include "LocalPoolOwnerBase.h"
#include "fsfw_tests/unit/CatchDefinitions.h"
#include <catch2/catch_test_macros.hpp>
#include <fsfw/objectmanager/ObjectManager.h>
#include <fsfw/datapoollocal/HasLocalDataPoolIF.h>
#include <unittest/core/CatchDefinitions.h>
TEST_CASE("LocalPoolVector" , "[LocPoolVecTest]") {
LocalPoolOwnerBase* poolOwner = ObjectManager::instance()->

View File

@ -1,2 +1,3 @@
target_sources(${TARGET_NAME} PRIVATE
testDleEncoder.cpp
)

View File

@ -0,0 +1,222 @@
#include "fsfw/globalfunctions/DleEncoder.h"
#include "fsfw_tests/unit/CatchDefinitions.h"
#include "catch2/catch_test_macros.hpp"
#include <array>
const std::vector<uint8_t> TEST_ARRAY_0 = { 0, 0, 0, 0, 0 };
const std::vector<uint8_t> TEST_ARRAY_1 = { 0, DleEncoder::DLE_CHAR, 5};
const std::vector<uint8_t> TEST_ARRAY_2 = { 0, DleEncoder::STX_CHAR, 5};
const std::vector<uint8_t> TEST_ARRAY_3 = { 0, DleEncoder::CARRIAGE_RETURN, DleEncoder::ETX_CHAR};
const std::vector<uint8_t> TEST_ARRAY_4 = { DleEncoder::DLE_CHAR, DleEncoder::ETX_CHAR,
DleEncoder::STX_CHAR };
const std::vector<uint8_t> TEST_ARRAY_0_ENCODED_ESCAPED = {
DleEncoder::STX_CHAR, 0, 0, 0, 0, 0, DleEncoder::ETX_CHAR
};
const std::vector<uint8_t> TEST_ARRAY_0_ENCODED_NON_ESCAPED = {
DleEncoder::DLE_CHAR, DleEncoder::STX_CHAR, 0, 0, 0, 0, 0,
DleEncoder::DLE_CHAR, DleEncoder::ETX_CHAR
};
const std::vector<uint8_t> TEST_ARRAY_1_ENCODED_ESCAPED = {
DleEncoder::STX_CHAR, 0, DleEncoder::DLE_CHAR, DleEncoder::DLE_CHAR, 5, DleEncoder::ETX_CHAR
};
const std::vector<uint8_t> TEST_ARRAY_1_ENCODED_NON_ESCAPED = {
DleEncoder::DLE_CHAR, DleEncoder::STX_CHAR, 0, DleEncoder::DLE_CHAR, DleEncoder::DLE_CHAR,
5, DleEncoder::DLE_CHAR, DleEncoder::ETX_CHAR
};
const std::vector<uint8_t> TEST_ARRAY_2_ENCODED_ESCAPED = {
DleEncoder::STX_CHAR, 0, DleEncoder::DLE_CHAR, DleEncoder::STX_CHAR + 0x40,
5, DleEncoder::ETX_CHAR
};
const std::vector<uint8_t> TEST_ARRAY_2_ENCODED_NON_ESCAPED = {
DleEncoder::DLE_CHAR, DleEncoder::STX_CHAR, 0,
DleEncoder::STX_CHAR, 5, DleEncoder::DLE_CHAR, DleEncoder::ETX_CHAR
};
const std::vector<uint8_t> TEST_ARRAY_3_ENCODED_ESCAPED = {
DleEncoder::STX_CHAR, 0, DleEncoder::CARRIAGE_RETURN,
DleEncoder::DLE_CHAR, DleEncoder::ETX_CHAR + 0x40, DleEncoder::ETX_CHAR
};
const std::vector<uint8_t> TEST_ARRAY_3_ENCODED_NON_ESCAPED = {
DleEncoder::DLE_CHAR, DleEncoder::STX_CHAR, 0,
DleEncoder::CARRIAGE_RETURN, DleEncoder::ETX_CHAR, DleEncoder::DLE_CHAR,
DleEncoder::ETX_CHAR
};
const std::vector<uint8_t> TEST_ARRAY_4_ENCODED_ESCAPED = {
DleEncoder::STX_CHAR, DleEncoder::DLE_CHAR, DleEncoder::DLE_CHAR,
DleEncoder::DLE_CHAR, DleEncoder::ETX_CHAR + 0x40, DleEncoder::DLE_CHAR,
DleEncoder::STX_CHAR + 0x40, DleEncoder::ETX_CHAR
};
const std::vector<uint8_t> TEST_ARRAY_4_ENCODED_NON_ESCAPED = {
DleEncoder::DLE_CHAR, DleEncoder::STX_CHAR, DleEncoder::DLE_CHAR, DleEncoder::DLE_CHAR,
DleEncoder::ETX_CHAR, DleEncoder::STX_CHAR, DleEncoder::DLE_CHAR, DleEncoder::ETX_CHAR
};
TEST_CASE("DleEncoder" , "[DleEncoder]") {
DleEncoder dleEncoder;
ReturnValue_t result = HasReturnvaluesIF::RETURN_OK;
std::array<uint8_t, 32> buffer;
size_t encodedLen = 0;
size_t readLen = 0;
size_t decodedLen = 0;
auto testLambdaEncode = [&](DleEncoder& encoder, const std::vector<uint8_t>& vecToEncode,
const std::vector<uint8_t>& expectedVec) {
result = encoder.encode(vecToEncode.data(), vecToEncode.size(),
buffer.data(), buffer.size(), &encodedLen);
REQUIRE(result == retval::CATCH_OK);
for(size_t idx = 0; idx < expectedVec.size(); idx++) {
REQUIRE(buffer[idx] == expectedVec[idx]);
}
REQUIRE(encodedLen == expectedVec.size());
};
auto testLambdaDecode = [&](DleEncoder& encoder, const std::vector<uint8_t>& testVecEncoded,
const std::vector<uint8_t>& expectedVec) {
result = encoder.decode(testVecEncoded.data(),
testVecEncoded.size(),
&readLen, buffer.data(), buffer.size(), &decodedLen);
REQUIRE(result == retval::CATCH_OK);
REQUIRE(readLen == testVecEncoded.size());
REQUIRE(decodedLen == expectedVec.size());
for(size_t idx = 0; idx < decodedLen; idx++) {
REQUIRE(buffer[idx] == expectedVec[idx]);
}
};
SECTION("Encoding") {
testLambdaEncode(dleEncoder, TEST_ARRAY_0, TEST_ARRAY_0_ENCODED_ESCAPED);
testLambdaEncode(dleEncoder, TEST_ARRAY_1, TEST_ARRAY_1_ENCODED_ESCAPED);
testLambdaEncode(dleEncoder, TEST_ARRAY_2, TEST_ARRAY_2_ENCODED_ESCAPED);
testLambdaEncode(dleEncoder, TEST_ARRAY_3, TEST_ARRAY_3_ENCODED_ESCAPED);
testLambdaEncode(dleEncoder, TEST_ARRAY_4, TEST_ARRAY_4_ENCODED_ESCAPED);
auto testFaultyEncoding = [&](const std::vector<uint8_t>& vecToEncode,
const std::vector<uint8_t>& expectedVec) {
for(size_t faultyDestSize = 0; faultyDestSize < expectedVec.size(); faultyDestSize ++) {
result = dleEncoder.encode(vecToEncode.data(), vecToEncode.size(),
buffer.data(), faultyDestSize, &encodedLen);
REQUIRE(result == DleEncoder::STREAM_TOO_SHORT);
}
};
testFaultyEncoding(TEST_ARRAY_0, TEST_ARRAY_0_ENCODED_ESCAPED);
testFaultyEncoding(TEST_ARRAY_1, TEST_ARRAY_1_ENCODED_ESCAPED);
testFaultyEncoding(TEST_ARRAY_2, TEST_ARRAY_2_ENCODED_ESCAPED);
testFaultyEncoding(TEST_ARRAY_3, TEST_ARRAY_3_ENCODED_ESCAPED);
testFaultyEncoding(TEST_ARRAY_4, TEST_ARRAY_4_ENCODED_ESCAPED);
dleEncoder.setEscapeMode(false);
testLambdaEncode(dleEncoder, TEST_ARRAY_0, TEST_ARRAY_0_ENCODED_NON_ESCAPED);
testLambdaEncode(dleEncoder, TEST_ARRAY_1, TEST_ARRAY_1_ENCODED_NON_ESCAPED);
testLambdaEncode(dleEncoder, TEST_ARRAY_2, TEST_ARRAY_2_ENCODED_NON_ESCAPED);
testLambdaEncode(dleEncoder, TEST_ARRAY_3, TEST_ARRAY_3_ENCODED_NON_ESCAPED);
testLambdaEncode(dleEncoder, TEST_ARRAY_4, TEST_ARRAY_4_ENCODED_NON_ESCAPED);
testFaultyEncoding(TEST_ARRAY_0, TEST_ARRAY_0_ENCODED_NON_ESCAPED);
testFaultyEncoding(TEST_ARRAY_1, TEST_ARRAY_1_ENCODED_NON_ESCAPED);
testFaultyEncoding(TEST_ARRAY_2, TEST_ARRAY_2_ENCODED_NON_ESCAPED);
testFaultyEncoding(TEST_ARRAY_3, TEST_ARRAY_3_ENCODED_NON_ESCAPED);
testFaultyEncoding(TEST_ARRAY_4, TEST_ARRAY_4_ENCODED_NON_ESCAPED);
dleEncoder.setEscapeMode(true);
}
SECTION("Decoding") {
testLambdaDecode(dleEncoder, TEST_ARRAY_0_ENCODED_ESCAPED, TEST_ARRAY_0);
testLambdaDecode(dleEncoder, TEST_ARRAY_1_ENCODED_ESCAPED, TEST_ARRAY_1);
testLambdaDecode(dleEncoder, TEST_ARRAY_2_ENCODED_ESCAPED, TEST_ARRAY_2);
testLambdaDecode(dleEncoder, TEST_ARRAY_3_ENCODED_ESCAPED, TEST_ARRAY_3);
testLambdaDecode(dleEncoder, TEST_ARRAY_4_ENCODED_ESCAPED, TEST_ARRAY_4);
// Faulty source data
auto testArray1EncodedFaulty = TEST_ARRAY_1_ENCODED_ESCAPED;
testArray1EncodedFaulty[3] = 0;
result = dleEncoder.decode(testArray1EncodedFaulty.data(), testArray1EncodedFaulty.size(),
&readLen, buffer.data(), buffer.size(), &encodedLen);
REQUIRE(result == static_cast<int>(DleEncoder::DECODING_ERROR));
auto testArray2EncodedFaulty = TEST_ARRAY_2_ENCODED_ESCAPED;
testArray2EncodedFaulty[5] = 0;
result = dleEncoder.decode(testArray2EncodedFaulty.data(), testArray2EncodedFaulty.size(),
&readLen, buffer.data(), buffer.size(), &encodedLen);
REQUIRE(result == static_cast<int>(DleEncoder::DECODING_ERROR));
auto testArray4EncodedFaulty = TEST_ARRAY_4_ENCODED_ESCAPED;
testArray4EncodedFaulty[2] = 0;
result = dleEncoder.decode(testArray4EncodedFaulty.data(), testArray4EncodedFaulty.size(),
&readLen, buffer.data(), buffer.size(), &encodedLen);
REQUIRE(result == static_cast<int>(DleEncoder::DECODING_ERROR));
auto testArray4EncodedFaulty2 = TEST_ARRAY_4_ENCODED_ESCAPED;
testArray4EncodedFaulty2[4] = 0;
result = dleEncoder.decode(testArray4EncodedFaulty2.data(), testArray4EncodedFaulty2.size(),
&readLen, buffer.data(), buffer.size(), &encodedLen);
REQUIRE(result == static_cast<int>(DleEncoder::DECODING_ERROR));
auto testFaultyDecoding = [&](const std::vector<uint8_t>& vecToDecode,
const std::vector<uint8_t>& expectedVec) {
for(size_t faultyDestSizes = 0;
faultyDestSizes < expectedVec.size();
faultyDestSizes ++) {
result = dleEncoder.decode(vecToDecode.data(),
vecToDecode.size(), &readLen,
buffer.data(), faultyDestSizes, &decodedLen);
REQUIRE(result == static_cast<int>(DleEncoder::STREAM_TOO_SHORT));
}
};
testFaultyDecoding(TEST_ARRAY_0_ENCODED_ESCAPED, TEST_ARRAY_0);
testFaultyDecoding(TEST_ARRAY_1_ENCODED_ESCAPED, TEST_ARRAY_1);
testFaultyDecoding(TEST_ARRAY_2_ENCODED_ESCAPED, TEST_ARRAY_2);
testFaultyDecoding(TEST_ARRAY_3_ENCODED_ESCAPED, TEST_ARRAY_3);
testFaultyDecoding(TEST_ARRAY_4_ENCODED_ESCAPED, TEST_ARRAY_4);
dleEncoder.setEscapeMode(false);
testLambdaDecode(dleEncoder, TEST_ARRAY_0_ENCODED_NON_ESCAPED, TEST_ARRAY_0);
testLambdaDecode(dleEncoder, TEST_ARRAY_1_ENCODED_NON_ESCAPED, TEST_ARRAY_1);
testLambdaDecode(dleEncoder, TEST_ARRAY_2_ENCODED_NON_ESCAPED, TEST_ARRAY_2);
testLambdaDecode(dleEncoder, TEST_ARRAY_3_ENCODED_NON_ESCAPED, TEST_ARRAY_3);
testLambdaDecode(dleEncoder, TEST_ARRAY_4_ENCODED_NON_ESCAPED, TEST_ARRAY_4);
testFaultyDecoding(TEST_ARRAY_0_ENCODED_NON_ESCAPED, TEST_ARRAY_0);
testFaultyDecoding(TEST_ARRAY_1_ENCODED_NON_ESCAPED, TEST_ARRAY_1);
testFaultyDecoding(TEST_ARRAY_2_ENCODED_NON_ESCAPED, TEST_ARRAY_2);
testFaultyDecoding(TEST_ARRAY_3_ENCODED_NON_ESCAPED, TEST_ARRAY_3);
testFaultyDecoding(TEST_ARRAY_4_ENCODED_NON_ESCAPED, TEST_ARRAY_4);
// Faulty source data
testArray1EncodedFaulty = TEST_ARRAY_1_ENCODED_NON_ESCAPED;
auto prevVal = testArray1EncodedFaulty[0];
testArray1EncodedFaulty[0] = 0;
result = dleEncoder.decode(testArray1EncodedFaulty.data(), testArray1EncodedFaulty.size(),
&readLen, buffer.data(), buffer.size(), &encodedLen);
REQUIRE(result == static_cast<int>(DleEncoder::DECODING_ERROR));
testArray1EncodedFaulty[0] = prevVal;
testArray1EncodedFaulty[1] = 0;
result = dleEncoder.decode(testArray1EncodedFaulty.data(), testArray1EncodedFaulty.size(),
&readLen, buffer.data(), buffer.size(), &encodedLen);
REQUIRE(result == static_cast<int>(DleEncoder::DECODING_ERROR));
testArray1EncodedFaulty = TEST_ARRAY_1_ENCODED_NON_ESCAPED;
testArray1EncodedFaulty[6] = 0;
result = dleEncoder.decode(testArray1EncodedFaulty.data(), testArray1EncodedFaulty.size(),
&readLen, buffer.data(), buffer.size(), &encodedLen);
REQUIRE(result == static_cast<int>(DleEncoder::DECODING_ERROR));
testArray1EncodedFaulty = TEST_ARRAY_1_ENCODED_NON_ESCAPED;
testArray1EncodedFaulty[7] = 0;
result = dleEncoder.decode(testArray1EncodedFaulty.data(), testArray1EncodedFaulty.size(),
&readLen, buffer.data(), buffer.size(), &encodedLen);
REQUIRE(result == static_cast<int>(DleEncoder::DECODING_ERROR));
testArray4EncodedFaulty = TEST_ARRAY_4_ENCODED_NON_ESCAPED;
testArray4EncodedFaulty[3] = 0;
result = dleEncoder.decode(testArray4EncodedFaulty.data(), testArray4EncodedFaulty.size(),
&readLen, buffer.data(), buffer.size(), &encodedLen);
REQUIRE(result == static_cast<int>(DleEncoder::DECODING_ERROR));
dleEncoder.setEscapeMode(true);
}
}

View File

@ -1,9 +1,12 @@
#ifndef FSFW_UNITTEST_TESTS_MOCKS_MESSAGEQUEUEMOCKBASE_H_
#define FSFW_UNITTEST_TESTS_MOCKS_MESSAGEQUEUEMOCKBASE_H_
#include <fsfw/ipc/MessageQueueIF.h>
#include <fsfw/ipc/MessageQueueMessage.h>
#include <unittest/core/CatchDefinitions.h>
#include "fsfw_tests/unit/CatchDefinitions.h"
#include "fsfw/ipc/CommandMessage.h"
#include "fsfw/ipc/MessageQueueIF.h"
#include "fsfw/ipc/MessageQueueMessage.h"
#include <cstring>
#include <queue>

View File

@ -1,8 +1,9 @@
#include "fsfw_tests/unit/CatchDefinitions.h"
#include <fsfw/ipc/MessageQueueIF.h>
#include <fsfw/ipc/QueueFactory.h>
#include <catch2/catch_test_macros.hpp>
#include <unittest/core/CatchDefinitions.h>
#include <array>

View File

@ -1,7 +1,9 @@
#include "fsfw_tests/unit/CatchDefinitions.h"
#include <fsfw/serialize/SerialBufferAdapter.h>
#include <catch2/catch_test_macros.hpp>
#include <unittest/core/CatchDefinitions.h>
#include <array>

View File

@ -1,10 +1,9 @@
#include "TestSerialLinkedPacket.h"
#include <unittest/core/CatchDefinitions.h>
#include "fsfw_tests/unit/CatchDefinitions.h"
#include <fsfw/globalfunctions/arrayprinter.h>
#include <catch2/catch_test_macros.hpp>
#include <unittest/core/CatchDefinitions.h>
#include <array>

View File

@ -1,8 +1,8 @@
#include "fsfw_tests/unit/CatchDefinitions.h"
#include <fsfw/serialize/SerializeAdapter.h>
#include <catch2/catch_test_macros.hpp>
#include <catch2/catch_approx.hpp>
#include <unittest/core/CatchDefinitions.h>
#include <array>

View File

@ -1,6 +1,9 @@
#include "fsfw_tests/unit/CatchDefinitions.h"
#include <fsfw/storagemanager/LocalPool.h>
#include <catch2/catch_test_macros.hpp>
#include <unittest/core/CatchDefinitions.h>
#include <array>
#include <cstring>

View File

@ -1,8 +1,9 @@
#include "fsfw_tests/unit/CatchDefinitions.h"
#include <fsfw/objectmanager/ObjectManager.h>
#include <fsfw/storagemanager/LocalPool.h>
#include <catch2/catch_test_macros.hpp>
#include <unittest/core/CatchDefinitions.h>
#include <cstring>

View File

@ -32,7 +32,7 @@ if(NOT FSFW_OSAL)
set(FSFW_OSAL host CACHE STRING "OS for the FSFW.")
endif()
option(CUSTOM_UNITTEST_RUNNER
option(FSFW_CUSTOM_UNITTEST_RUNNER
"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(TARGET_NAME ${CMAKE_PROJECT_NAME})
if(CUSTOM_UNITTEST_RUNNER)
if(FSFW_CUSTOM_UNITTEST_RUNNER)
set(CATCH2_TARGET Catch2)
else()
set(CATCH2_TARGET Catch2WithMain)

View File

@ -1,6 +1,8 @@
#ifndef FSFW_UNITTEST_CONFIG_TESTSCONFIG_H_
#define FSFW_UNITTEST_CONFIG_TESTSCONFIG_H_
#define FSFW_ADD_DEFAULT_FACTORY_FUNCTIONS 1
#ifdef __cplusplus
#include "objects/systemObjectList.h"

View File

@ -1 +0,0 @@
add_subdirectory(core)

View File

@ -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()

View File

@ -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_ */

View File

@ -1,3 +0,0 @@
CXXSRC += $(wildcard $(CURRENTPATH)/*.cpp)
INCLUDES += $(CURRENTPATH)