Compare commits
19 Commits
small-fix-
...
mueller/fs
Author | SHA1 | Date | |
---|---|---|---|
715d5ac39f | |||
d959474271 | |||
80355910ee | |||
04800df31e | |||
1e85cdadfd | |||
ebc02673dd | |||
eb8e236cd4 | |||
7dec45ccf2 | |||
2b01e86f9c | |||
60fd3d43c0 | |||
67980cb592 | |||
3010f2f925 | |||
01651f0521 | |||
c7f300671f | |||
7d3223d766 | |||
7ae82a5cb4 | |||
28ecd0e5c6 | |||
7345c18b04 | |||
64a7fde301 |
@ -360,7 +360,7 @@ if(NOT FSFW_CONFIG_PATH)
|
||||
if(NOT FSFW_BUILD_DOCS)
|
||||
message(
|
||||
WARNING
|
||||
"${MSG_PREFIX} Flight Software Framework configuration path not set")
|
||||
"${MSG_PREFIX} Flight Software Framework configuration path FSFW_CONFIG_PATH not set")
|
||||
message(
|
||||
WARNING
|
||||
"${MSG_PREFIX} Setting default configuration from ${DEF_CONF_PATH} ..")
|
||||
|
@ -1323,10 +1323,10 @@ ReturnValue_t DeviceHandlerBase::executeAction(ActionId_t actionId, MessageQueue
|
||||
} else if (iter->second.isExecuting) {
|
||||
result = COMMAND_ALREADY_SENT;
|
||||
} else {
|
||||
iter->second.sendReplyTo = commandedBy;
|
||||
result = buildCommandFromCommand(actionId, data, size);
|
||||
}
|
||||
if (result == returnvalue::OK) {
|
||||
iter->second.sendReplyTo = commandedBy;
|
||||
iter->second.isExecuting = true;
|
||||
cookieInfo.pendingCommand = iter;
|
||||
cookieInfo.state = COOKIE_WRITE_READY;
|
||||
|
@ -1052,8 +1052,23 @@ class DeviceHandlerBase : public DeviceHandlerIF,
|
||||
|
||||
bool isAwaitingReply();
|
||||
|
||||
/**
|
||||
* Wrapper function for @handleDeviceTm which wraps the raw buffer with @SerialBufferAdapter.
|
||||
* For interpreted data, prefer the other function.
|
||||
* @param rawData
|
||||
* @param rawDataLen
|
||||
* @param replyId
|
||||
* @param forceDirectTm
|
||||
*/
|
||||
void handleDeviceTm(const uint8_t *rawData, size_t rawDataLen, DeviceCommandId_t replyId,
|
||||
bool forceDirectTm = false);
|
||||
/**
|
||||
* Can be used to handle Service 8 data replies. This will also generate the TM wiretapping
|
||||
* packets accordingly.
|
||||
* @param dataSet
|
||||
* @param replyId
|
||||
* @param forceDirectTm
|
||||
*/
|
||||
void handleDeviceTm(const SerializeIF &dataSet, DeviceCommandId_t replyId,
|
||||
bool forceDirectTm = false);
|
||||
|
||||
|
@ -4,8 +4,6 @@
|
||||
#include <stdint.h>
|
||||
|
||||
#include "fwSubsystemIdRanges.h"
|
||||
// could be moved to more suitable location
|
||||
#include <events/subsystemIdRanges.h>
|
||||
|
||||
using EventId_t = uint16_t;
|
||||
using EventSeverity_t = uint8_t;
|
||||
|
@ -161,7 +161,7 @@ void TcpTmTcServer::handleServerOperation(socket_t& connSocket) {
|
||||
|
||||
while (true) {
|
||||
ssize_t retval = recv(connSocket, reinterpret_cast<char*>(receptionBuffer.data()),
|
||||
receptionBuffer.capacity(), tcpConfig.tcpFlags);
|
||||
receptionBuffer.size(), tcpConfig.tcpFlags);
|
||||
if (retval == 0) {
|
||||
size_t availableReadData = ringBuffer.getAvailableReadData();
|
||||
if (availableReadData > lastRingBufferSize) {
|
||||
@ -335,31 +335,27 @@ ReturnValue_t TcpTmTcServer::handleTcRingBufferData(size_t availableReadData) {
|
||||
}
|
||||
ringBuffer.readData(receptionBuffer.data(), readAmount, true);
|
||||
const uint8_t* bufPtr = receptionBuffer.data();
|
||||
const uint8_t** bufPtrPtr = &bufPtr;
|
||||
size_t startIdx = 0;
|
||||
size_t foundSize = 0;
|
||||
size_t readLen = 0;
|
||||
while (readLen < readAmount) {
|
||||
if (spacePacketParser == nullptr) {
|
||||
return returnvalue::FAILED;
|
||||
}
|
||||
result =
|
||||
spacePacketParser->parseSpacePackets(bufPtrPtr, readAmount, startIdx, foundSize, readLen);
|
||||
SpacePacketParser::FoundPacketInfo info;
|
||||
if (spacePacketParser == nullptr) {
|
||||
return returnvalue::FAILED;
|
||||
}
|
||||
spacePacketParser->reset();
|
||||
while (spacePacketParser->getAmountRead() < readAmount) {
|
||||
result = spacePacketParser->parseSpacePackets(&bufPtr, readAmount, info);
|
||||
switch (result) {
|
||||
case (SpacePacketParser::NO_PACKET_FOUND):
|
||||
case (SpacePacketParser::SPLIT_PACKET): {
|
||||
break;
|
||||
}
|
||||
case (returnvalue::OK): {
|
||||
result = handleTcReception(receptionBuffer.data() + startIdx, foundSize);
|
||||
result = handleTcReception(receptionBuffer.data() + info.startIdx, info.sizeFound);
|
||||
if (result != returnvalue::OK) {
|
||||
status = result;
|
||||
}
|
||||
}
|
||||
}
|
||||
ringBuffer.deleteData(foundSize);
|
||||
ringBuffer.deleteData(info.sizeFound);
|
||||
lastRingBufferSize = ringBuffer.getAvailableReadData();
|
||||
std::memset(receptionBuffer.data() + startIdx, 0, foundSize);
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
@ -38,8 +38,9 @@ class Service11TelecommandScheduling final : public PusServiceBase {
|
||||
static constexpr uint8_t CLASS_ID = CLASS_ID::PUS_SERVICE_11;
|
||||
|
||||
static constexpr ReturnValue_t INVALID_TYPE_TIME_WINDOW = returnvalue::makeCode(CLASS_ID, 1);
|
||||
static constexpr ReturnValue_t TIMESHIFTING_NOT_POSSIBLE = returnvalue::makeCode(CLASS_ID, 2);
|
||||
static constexpr ReturnValue_t INVALID_RELATIVE_TIME = returnvalue::makeCode(CLASS_ID, 3);
|
||||
static constexpr ReturnValue_t INVALID_TIME_WINDOW = returnvalue::makeCode(CLASS_ID, 2);
|
||||
static constexpr ReturnValue_t TIMESHIFTING_NOT_POSSIBLE = returnvalue::makeCode(CLASS_ID, 3);
|
||||
static constexpr ReturnValue_t INVALID_RELATIVE_TIME = returnvalue::makeCode(CLASS_ID, 4);
|
||||
|
||||
static constexpr uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::PUS_SERVICE_11;
|
||||
|
||||
|
@ -571,12 +571,17 @@ inline ReturnValue_t Service11TelecommandScheduling<MAX_NUM_TCS>::getMapFilterFr
|
||||
if (result != returnvalue::OK) {
|
||||
return result;
|
||||
}
|
||||
if(fromTimestamp > toTimestamp) {
|
||||
return INVALID_TIME_WINDOW;
|
||||
}
|
||||
itBegin = telecommandMap.begin();
|
||||
itEnd = telecommandMap.begin();
|
||||
|
||||
while (itBegin->first < fromTimestamp && itBegin != telecommandMap.end()) {
|
||||
itBegin++;
|
||||
}
|
||||
|
||||
//start looking for end beginning at begin
|
||||
itEnd = itBegin;
|
||||
while (itEnd->first <= toTimestamp && itEnd != telecommandMap.end()) {
|
||||
itEnd++;
|
||||
}
|
||||
@ -586,17 +591,6 @@ inline ReturnValue_t Service11TelecommandScheduling<MAX_NUM_TCS>::getMapFilterFr
|
||||
default:
|
||||
return returnvalue::FAILED;
|
||||
}
|
||||
|
||||
// additional security check, this should never be true
|
||||
if (itBegin > itEnd) {
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::error << "11::getMapFilterFromData: itBegin > itEnd\n" << std::endl;
|
||||
#else
|
||||
sif::printError("11::getMapFilterFromData: itBegin > itEnd\n");
|
||||
#endif
|
||||
return returnvalue::FAILED;
|
||||
}
|
||||
|
||||
// the map range should now be set according to the sent filter.
|
||||
return returnvalue::OK;
|
||||
}
|
||||
|
@ -1,8 +1,6 @@
|
||||
#ifndef FSFW_RETURNVALUES_RETURNVALUE_H_
|
||||
#define FSFW_RETURNVALUES_RETURNVALUE_H_
|
||||
|
||||
#include <returnvalues/classIds.h>
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
#include "FwClassIds.h"
|
||||
|
@ -6,17 +6,9 @@
|
||||
SpacePacketParser::SpacePacketParser(std::vector<uint16_t> validPacketIds)
|
||||
: validPacketIds(validPacketIds) {}
|
||||
|
||||
ReturnValue_t SpacePacketParser::parseSpacePackets(const uint8_t* buffer, const size_t maxSize,
|
||||
size_t& startIndex, size_t& foundSize) {
|
||||
const uint8_t** tempPtr = &buffer;
|
||||
size_t readLen = 0;
|
||||
return parseSpacePackets(tempPtr, maxSize, startIndex, foundSize, readLen);
|
||||
}
|
||||
|
||||
ReturnValue_t SpacePacketParser::parseSpacePackets(const uint8_t** buffer, const size_t maxSize,
|
||||
size_t& startIndex, size_t& foundSize,
|
||||
size_t& readLen) {
|
||||
if (buffer == nullptr or maxSize < 5) {
|
||||
FoundPacketInfo& packetInfo) {
|
||||
if (buffer == nullptr or nextStartIdx > maxSize) {
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::warning << "SpacePacketParser::parseSpacePackets: Frame invalid" << std::endl;
|
||||
#else
|
||||
@ -26,35 +18,32 @@ ReturnValue_t SpacePacketParser::parseSpacePackets(const uint8_t** buffer, const
|
||||
}
|
||||
const uint8_t* bufPtr = *buffer;
|
||||
|
||||
auto verifyLengthField = [&](size_t idx) {
|
||||
uint16_t lengthField = bufPtr[idx + 4] << 8 | bufPtr[idx + 5];
|
||||
auto verifyLengthField = [&](size_t localIdx) {
|
||||
uint16_t lengthField = (bufPtr[localIdx + 4] << 8) | bufPtr[localIdx + 5];
|
||||
size_t packetSize = lengthField + 7;
|
||||
startIndex = idx;
|
||||
ReturnValue_t result = returnvalue::OK;
|
||||
if (lengthField == 0) {
|
||||
// Skip whole header for now
|
||||
foundSize = 6;
|
||||
result = NO_PACKET_FOUND;
|
||||
} else if (packetSize + idx > maxSize) {
|
||||
if (packetSize + localIdx + amountRead > maxSize) {
|
||||
// Don't increment buffer and read length here, user has to decide what to do
|
||||
foundSize = packetSize;
|
||||
packetInfo.sizeFound = packetSize;
|
||||
return SPLIT_PACKET;
|
||||
} else {
|
||||
foundSize = packetSize;
|
||||
packetInfo.sizeFound = packetSize;
|
||||
}
|
||||
*buffer += foundSize;
|
||||
readLen += idx + foundSize;
|
||||
*buffer += packetInfo.sizeFound;
|
||||
packetInfo.startIdx = localIdx + amountRead;
|
||||
nextStartIdx = localIdx + amountRead + packetInfo.sizeFound;
|
||||
amountRead = nextStartIdx;
|
||||
return result;
|
||||
};
|
||||
|
||||
size_t idx = 0;
|
||||
// Space packet ID as start marker
|
||||
if (validPacketIds.size() > 0) {
|
||||
while (idx < maxSize - 5) {
|
||||
uint16_t currentPacketId = bufPtr[idx] << 8 | bufPtr[idx + 1];
|
||||
while (idx + amountRead < maxSize - 5) {
|
||||
uint16_t currentPacketId = (bufPtr[idx] << 8) | bufPtr[idx + 1];
|
||||
if (std::find(validPacketIds.begin(), validPacketIds.end(), currentPacketId) !=
|
||||
validPacketIds.end()) {
|
||||
if (idx + 5 >= maxSize) {
|
||||
if (idx + amountRead >= maxSize - 5) {
|
||||
return SPLIT_PACKET;
|
||||
}
|
||||
return verifyLengthField(idx);
|
||||
@ -62,10 +51,10 @@ ReturnValue_t SpacePacketParser::parseSpacePackets(const uint8_t** buffer, const
|
||||
idx++;
|
||||
}
|
||||
}
|
||||
startIndex = 0;
|
||||
foundSize = maxSize;
|
||||
*buffer += foundSize;
|
||||
readLen += foundSize;
|
||||
nextStartIdx = maxSize;
|
||||
packetInfo.sizeFound = maxSize;
|
||||
amountRead = maxSize;
|
||||
*buffer += maxSize;
|
||||
return NO_PACKET_FOUND;
|
||||
}
|
||||
// Assume that the user verified a valid start of a space packet
|
||||
|
@ -17,9 +17,11 @@
|
||||
*/
|
||||
class SpacePacketParser {
|
||||
public:
|
||||
//! The first entry is the index inside the buffer while the second index
|
||||
//! is the size of the PUS packet starting at that index.
|
||||
using IndexSizePair = std::pair<size_t, size_t>;
|
||||
|
||||
struct FoundPacketInfo {
|
||||
size_t startIdx = 0;
|
||||
size_t sizeFound = 0;
|
||||
};
|
||||
|
||||
static constexpr uint8_t INTERFACE_ID = CLASS_ID::SPACE_PACKET_PARSER;
|
||||
static constexpr ReturnValue_t NO_PACKET_FOUND = MAKE_RETURN_CODE(0x00);
|
||||
@ -36,44 +38,32 @@ class SpacePacketParser {
|
||||
SpacePacketParser(std::vector<uint16_t> validPacketIds);
|
||||
|
||||
/**
|
||||
* Parse a given frame for space packets but also increment the given buffer and assign the
|
||||
* total number of bytes read so far
|
||||
* Parse a given frame for space packets but also increments the given buffer.
|
||||
* @param buffer Parser will look for space packets in this buffer
|
||||
* @param maxSize Maximum size of the buffer
|
||||
* @param startIndex Start index of a found space packet
|
||||
* @param foundSize Found size of the space packet
|
||||
* @param readLen Length read so far. This value is incremented by the number of parsed
|
||||
* bytes which also includes the size of a found packet
|
||||
* -@c NO_PACKET_FOUND if no packet was found in the given buffer or the length field is
|
||||
* invalid. foundSize will be set to the size of the space packet header. buffer and
|
||||
* readLen will be incremented accordingly.
|
||||
* -@c SPLIT_PACKET if a packet was found but the detected size exceeds maxSize. foundSize
|
||||
* will be set to the detected packet size and startIndex will be set to the start of the
|
||||
* detected packet. buffer and read length will not be incremented but the found length
|
||||
* will be assigned.
|
||||
* -@c returnvalue::OK if a packet was found
|
||||
* @param packetInfo Information about packets found.
|
||||
* -@c NO_PACKET_FOUND if no packet was found in the given buffer
|
||||
* -@c SPLIT_PACKET if a packet was found but the detected size exceeds maxSize. packetInfo
|
||||
* will contain the detected packet size and start index.
|
||||
* -@c returnvalue::OK if a packet was found. Packet size and start index will be set in
|
||||
* packetInfo
|
||||
*/
|
||||
ReturnValue_t parseSpacePackets(const uint8_t** buffer, const size_t maxSize, size_t& startIndex,
|
||||
size_t& foundSize, size_t& readLen);
|
||||
ReturnValue_t parseSpacePackets(const uint8_t** buffer, const size_t maxSize,
|
||||
FoundPacketInfo& packetInfo);
|
||||
|
||||
/**
|
||||
* Parse a given frame for space packets
|
||||
* @param buffer Parser will look for space packets in this buffer
|
||||
* @param maxSize Maximum size of the buffer
|
||||
* @param startIndex Start index of a found space packet
|
||||
* @param foundSize Found size of the space packet
|
||||
* -@c NO_PACKET_FOUND if no packet was found in the given buffer or the length field is
|
||||
* invalid. foundSize will be set to the size of the space packet header
|
||||
* -@c SPLIT_PACKET if a packet was found but the detected size exceeds maxSize. foundSize
|
||||
* will be set to the detected packet size and startIndex will be set to the start of the
|
||||
* detected packet
|
||||
* -@c returnvalue::OK if a packet was found
|
||||
*/
|
||||
ReturnValue_t parseSpacePackets(const uint8_t* buffer, const size_t maxSize, size_t& startIndex,
|
||||
size_t& foundSize);
|
||||
size_t getAmountRead() {
|
||||
return amountRead;
|
||||
}
|
||||
|
||||
void reset() {
|
||||
nextStartIdx = 0;
|
||||
amountRead = 0;
|
||||
}
|
||||
|
||||
private:
|
||||
std::vector<uint16_t> validPacketIds;
|
||||
size_t nextStartIdx = 0;
|
||||
size_t amountRead = 0;
|
||||
};
|
||||
|
||||
#endif /* FRAMEWORK_TMTCSERVICES_PUSPARSER_H_ */
|
||||
|
@ -1 +1,3 @@
|
||||
add_subdirectory(gpio)
|
||||
|
||||
target_sources(${LIB_FSFW_NAME} PRIVATE printChar.c)
|
10
src/fsfw_hal/common/printChar.c
Normal file
10
src/fsfw_hal/common/printChar.c
Normal file
@ -0,0 +1,10 @@
|
||||
#include <stdio.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
void __attribute__((weak)) printChar(const char* character, bool errStream) {
|
||||
if (errStream) {
|
||||
fprintf(stderr, "%c", *character);
|
||||
} else {
|
||||
printf("%c", *character);
|
||||
}
|
||||
}
|
@ -2,7 +2,6 @@
|
||||
#define MISSION_DEVICES_MGMLIS3MDLHANDLER_H_
|
||||
|
||||
#include "devicedefinitions/MgmLIS3HandlerDefs.h"
|
||||
#include "events/subsystemIdRanges.h"
|
||||
#include "fsfw/devicehandlers/DeviceHandlerBase.h"
|
||||
#include "fsfw/globalfunctions/PeriodicOperationDivider.h"
|
||||
|
||||
|
@ -18,6 +18,7 @@ add_subdirectory(power)
|
||||
add_subdirectory(util)
|
||||
add_subdirectory(container)
|
||||
add_subdirectory(osal)
|
||||
add_subdirectory(pus)
|
||||
add_subdirectory(serialize)
|
||||
add_subdirectory(datapoollocal)
|
||||
add_subdirectory(storagemanager)
|
||||
|
3
unittests/pus/CMakeLists.txt
Normal file
3
unittests/pus/CMakeLists.txt
Normal file
@ -0,0 +1,3 @@
|
||||
target_sources(${FSFW_TEST_TGT} PRIVATE
|
||||
testService11.cpp
|
||||
)
|
14
unittests/pus/testService11.cpp
Normal file
14
unittests/pus/testService11.cpp
Normal file
@ -0,0 +1,14 @@
|
||||
#include <fsfw/pus/Service11TelecommandScheduling.h>
|
||||
|
||||
#include <catch2/catch_test_macros.hpp>
|
||||
|
||||
#include "objects/systemObjectList.h"
|
||||
#include "tmtc/apid.h"
|
||||
#include "tmtc/pusIds.h"
|
||||
|
||||
TEST_CASE("PUS Service 11", "[pus-srvc11]") {
|
||||
Service11TelecommandScheduling<13> pusService11(objects::PUS_SERVICE_11_TC_SCHEDULER,
|
||||
apid::DEFAULT_APID, pus::PUS_SERVICE_11, nullptr);
|
||||
|
||||
// TODO test something...
|
||||
}
|
Reference in New Issue
Block a user