Compare commits
84 Commits
mueller/re
...
docker_d5
Author | SHA1 | Date | |
---|---|---|---|
9c7248e78e | |||
ecf51b2913 | |||
8bbde05413 | |||
d79b5348d8 | |||
92e3ab04f3 | |||
003a6d00fa | |||
9ee1896553 | |||
a5b5523111 | |||
62cd39e573 | |||
278ed36db8 | |||
aed30d54ef | |||
1126db2c8a | |||
a64a04d7fe | |||
80467bf097 | |||
6a6aa7fdd6 | |||
7e379d2159 | |||
6ae709acc3 | |||
d52f335455 | |||
04b619a15c | |||
282704e0fd | |||
07ef9a0ec3 | |||
80464f2a81 | |||
16688316a8 | |||
3583e30ee6 | |||
1e395dc402 | |||
f5421e9abd | |||
4c3f9feb93 | |||
b7ed8ff390 | |||
75dc7a405d | |||
b7a1f79d5b | |||
f0b7a103d4 | |||
ee93f4a4ca | |||
d64ad71529 | |||
26bc80964e | |||
eb03bf52a6 | |||
80355910ee | |||
04800df31e | |||
1e85cdadfd | |||
ebc02673dd | |||
9202c6c17f | |||
5f8c549993 | |||
04bff7a522 | |||
5c20cc804e | |||
eb8e236cd4 | |||
7dec45ccf2 | |||
2b01e86f9c | |||
60fd3d43c0 | |||
67980cb592 | |||
3010f2f925 | |||
01651f0521 | |||
c7f300671f | |||
7d3223d766 | |||
7ae82a5cb4 | |||
28ecd0e5c6 | |||
7345c18b04 | |||
158007fa7f | |||
ab719a3e59 | |||
64a7fde301 | |||
9131ca688b | |||
8e6cee7761 | |||
c756297e5c | |||
0f27c7e7e7 | |||
20d42add03 | |||
a9277622ce | |||
aea9db75cb | |||
9fedd03ed8 | |||
10fc4dd89d | |||
0cc8af5eb0 | |||
92d65aa3a5 | |||
342a56410c | |||
2cab73d972 | |||
cb23911ccd | |||
b499dedd76 | |||
1bb487373d | |||
3bffb4f968 | |||
6bcb208968 | |||
6c2b5ab39e | |||
a7039bad41 | |||
6605ffb6b1 | |||
e2e0190cae | |||
fd278e410b | |||
ff4cbea571 | |||
a46d8c34d9 | |||
ba5c6410d6 |
@ -10,8 +10,6 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
|
||||
|
||||
# [v6.0.0]
|
||||
|
||||
## Changes
|
||||
|
||||
## Added
|
||||
|
||||
- Add new `UnsignedByteField` class
|
||||
|
@ -80,7 +80,7 @@ set(FSFW_CATCH2_LIB_MAJOR_VERSION
|
||||
3
|
||||
CACHE STRING "Catch2 library major version requirement")
|
||||
set(FSFW_CATCH2_LIB_VERSION
|
||||
v${FSFW_CATCH2_LIB_MAJOR_VERSION}.0.0-preview5
|
||||
v${FSFW_CATCH2_LIB_MAJOR_VERSION}.1.0
|
||||
CACHE STRING "Catch2 library exact version requirement")
|
||||
|
||||
# Keep this off by default for now. See PR:
|
||||
@ -360,7 +360,8 @@ 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} ..")
|
||||
|
@ -5,16 +5,21 @@ RUN apt-get --yes upgrade
|
||||
|
||||
#tzdata is a dependency, won't install otherwise
|
||||
ARG DEBIAN_FRONTEND=noninteractive
|
||||
RUN apt-get --yes install gcc g++ cmake make lcov git valgrind nano iputils-ping
|
||||
RUN apt-get --yes install gcc g++ cmake make lcov git valgrind nano iputils-ping python3 pip doxygen graphviz
|
||||
|
||||
RUN python3 -m pip install sphinx breathe
|
||||
|
||||
RUN git clone https://github.com/catchorg/Catch2.git && \
|
||||
cd Catch2 && \
|
||||
git checkout v3.0.0-preview5 && \
|
||||
cmake -Bbuild -H. -DBUILD_TESTING=OFF && \
|
||||
cmake --build build/ --target install
|
||||
cd Catch2 && \
|
||||
git checkout v3.1.0 && \
|
||||
cmake -Bbuild -H. -DBUILD_TESTING=OFF && \
|
||||
cmake --build build/ --target install
|
||||
|
||||
RUN git clone https://github.com/ETLCPP/etl.git && \
|
||||
cd etl && \
|
||||
git checkout 20.28.0 && \
|
||||
cmake -B build . && \
|
||||
cmake --install build/
|
||||
cd etl && \
|
||||
git checkout 20.28.0 && \
|
||||
cmake -B build . && \
|
||||
cmake --install build/
|
||||
|
||||
#ssh needs a valid user to work
|
||||
RUN adduser --uid 114 jenkins
|
||||
|
33
automation/Jenkinsfile
vendored
33
automation/Jenkinsfile
vendored
@ -1,9 +1,10 @@
|
||||
pipeline {
|
||||
environment {
|
||||
BUILDDIR = 'cmake-build-tests'
|
||||
DOCDDIR = 'cmake-build-documentation'
|
||||
}
|
||||
agent {
|
||||
docker { image 'fsfw-ci:d3'}
|
||||
docker { image 'fsfw-ci:d5'}
|
||||
}
|
||||
stages {
|
||||
stage('Clean') {
|
||||
@ -39,5 +40,35 @@ pipeline {
|
||||
}
|
||||
}
|
||||
}
|
||||
stage('Documentation') {
|
||||
when {
|
||||
branch 'development'
|
||||
}
|
||||
steps {
|
||||
dir(DOCDDIR) {
|
||||
sh 'cmake -DFSFW_BUILD_DOCS=ON -DFSFW_OSAL=host ..'
|
||||
sh 'make Sphinx'
|
||||
sh 'cd docs/sphinx'
|
||||
sshagent(credentials: ['documentation-buildfix']) {
|
||||
sh 'scp -r ./* buildfix@documents.intra.irs.uni-stuttgart.de:/mnt/data/www/html/fsfw/development'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
stage('Master Documentation') {
|
||||
when {
|
||||
branch 'master'
|
||||
}
|
||||
steps {
|
||||
dir(DOCDDIR) {
|
||||
sh 'cmake -DFSFW_BUILD_DOCS=ON -DFSFW_OSAL=host ..'
|
||||
sh 'make Sphinx'
|
||||
sh 'cd docs/sphinx'
|
||||
sshagent(credentials: ['documentation-buildfix']) {
|
||||
sh 'scp -r ./* buildfix@documents.intra.irs.uni-stuttgart.de:/mnt/data/www/html/fsfw/master'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -4,6 +4,10 @@
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
|
||||
// It is assumed the user has a subsystem and class ID list in some user header files.
|
||||
// #include "events/subsystemIdRanges.h"
|
||||
// #include "returnvalues/classIds.h"
|
||||
|
||||
//! Used to determine whether C++ ostreams are used which can increase
|
||||
//! the binary size significantly. If this is disabled,
|
||||
//! the C stdio functions can be used alternatively
|
||||
|
@ -35,7 +35,7 @@ void Factory::produceFsfwObjects(void) {
|
||||
}
|
||||
|
||||
void Factory::setStaticFrameworkObjectIds() {
|
||||
PusServiceBase::packetSource = objects::NO_OBJECT;
|
||||
PusServiceBase::PUS_DISTRIBUTOR = objects::NO_OBJECT;
|
||||
PusServiceBase::PACKET_DESTINATION = objects::NO_OBJECT;
|
||||
|
||||
CommandingServiceBase::defaultPacketSource = objects::NO_OBJECT;
|
||||
|
@ -3,6 +3,11 @@ if [[ ! -f README.md ]]; then
|
||||
cd ..
|
||||
fi
|
||||
|
||||
folder_list=(
|
||||
"./src"
|
||||
"./unittests"
|
||||
)
|
||||
|
||||
cmake_fmt="cmake-format"
|
||||
file_selectors="-iname CMakeLists.txt"
|
||||
if command -v ${cmake_fmt} &> /dev/null; then
|
||||
@ -15,8 +20,10 @@ fi
|
||||
cpp_format="clang-format"
|
||||
file_selectors="-iname *.h -o -iname *.cpp -o -iname *.c -o -iname *.tpp"
|
||||
if command -v ${cpp_format} &> /dev/null; then
|
||||
find ./src ${file_selectors} | xargs ${cpp_format} --style=file -i
|
||||
find ./unittests ${file_selectors} | xargs ${cpp_format} --style=file -i
|
||||
for dir in ${folder_list[@]}; do
|
||||
echo "Auto-formatting ${dir} recursively"
|
||||
find ${dir} ${file_selectors} | xargs clang-format --style=file -i
|
||||
done
|
||||
else
|
||||
echo "No ${cpp_format} tool found, not formatting C++/C files"
|
||||
fi
|
||||
|
@ -3,7 +3,6 @@
|
||||
#include "fsfw/cfdp/CfdpMessage.h"
|
||||
#include "fsfw/ipc/CommandMessage.h"
|
||||
#include "fsfw/ipc/QueueFactory.h"
|
||||
#include "fsfw/objectmanager/ObjectManager.h"
|
||||
#include "fsfw/storagemanager/storeAddress.h"
|
||||
#include "fsfw/tmtcservices/AcceptsTelemetryIF.h"
|
||||
|
||||
|
@ -21,7 +21,7 @@ cfdp::Lv& cfdp::Lv::operator=(const Lv& other) {
|
||||
if (value == nullptr or otherSize == 0) {
|
||||
this->zeroLen = true;
|
||||
}
|
||||
this->value.setBuffer(value, otherSize);
|
||||
this->value.setConstBuffer(value, otherSize);
|
||||
return *this;
|
||||
}
|
||||
|
||||
@ -70,7 +70,7 @@ ReturnValue_t cfdp::Lv::deSerialize(const uint8_t** buffer, size_t* size,
|
||||
}
|
||||
zeroLen = false;
|
||||
// Zero-copy implementation
|
||||
value.setBuffer(const_cast<uint8_t*>(*buffer + 1), lengthField);
|
||||
value.setConstBuffer(*buffer + 1, lengthField);
|
||||
*buffer += 1 + lengthField;
|
||||
*size -= 1 + lengthField;
|
||||
return returnvalue::OK;
|
||||
|
@ -75,7 +75,7 @@ ReturnValue_t cfdp::Tlv::deSerialize(const uint8_t **buffer, size_t *size,
|
||||
}
|
||||
zeroLen = false;
|
||||
// Zero-copy implementation
|
||||
value.setBuffer(const_cast<uint8_t *>(*buffer + 1), lengthField);
|
||||
value.setConstBuffer(*buffer + 1, lengthField);
|
||||
*buffer += 1 + lengthField;
|
||||
*size -= 1 + lengthField;
|
||||
return returnvalue::OK;
|
||||
@ -96,7 +96,7 @@ void cfdp::Tlv::setValue(uint8_t *value, size_t len) {
|
||||
if (len > 0) {
|
||||
zeroLen = false;
|
||||
}
|
||||
this->value.setBuffer(value, len);
|
||||
this->value.setConstBuffer(value, len);
|
||||
}
|
||||
|
||||
uint8_t cfdp::Tlv::getLengthField() const { return this->value.getSerializedSize() - 1; }
|
||||
|
@ -243,13 +243,14 @@ class LocalDataPoolManager : public ProvidesDataPoolSubscriptionIF, public Acces
|
||||
LocalDataPoolManager* getPoolManagerHandle() override;
|
||||
ReturnValue_t subscribeForRegularPeriodicPacket(subdp::RegularHkPeriodicParams params) override;
|
||||
ReturnValue_t subscribeForDiagPeriodicPacket(subdp::DiagnosticsHkPeriodicParams params) override;
|
||||
ReturnValue_t subscribeForPeriodicPacket(subdp::ParamsBase& params);
|
||||
|
||||
ReturnValue_t subscribeForRegularUpdatePacket(subdp::RegularHkUpdateParams params) override;
|
||||
ReturnValue_t subscribeForDiagUpdatePacket(subdp::DiagnosticsHkUpdateParams params) override;
|
||||
ReturnValue_t subscribeForUpdatePacket(subdp::ParamsBase& params);
|
||||
|
||||
protected:
|
||||
ReturnValue_t subscribeForPeriodicPacket(subdp::ParamsBase& params);
|
||||
ReturnValue_t subscribeForUpdatePacket(subdp::ParamsBase& params);
|
||||
|
||||
/** Core data structure for the actual pool data */
|
||||
localpool::DataPool localPoolMap;
|
||||
/** Every housekeeping data manager has a mutex to protect access
|
||||
|
@ -8,6 +8,7 @@
|
||||
#include "fsfw/ipc/MessageQueueMessage.h"
|
||||
#include "fsfw/ipc/QueueFactory.h"
|
||||
#include "fsfw/objectmanager/ObjectManager.h"
|
||||
#include "fsfw/serialize/SerialBufferAdapter.h"
|
||||
#include "fsfw/serviceinterface/ServiceInterface.h"
|
||||
#include "fsfw/storagemanager/StorageManagerIF.h"
|
||||
#include "fsfw/subsystem/SubsystemBase.h"
|
||||
@ -1257,28 +1258,30 @@ ReturnValue_t DeviceHandlerBase::letChildHandleMessage(CommandMessage* message)
|
||||
return returnvalue::FAILED;
|
||||
}
|
||||
|
||||
void DeviceHandlerBase::handleDeviceTM(SerializeIF* dataSet, DeviceCommandId_t replyId,
|
||||
bool forceDirectTm) {
|
||||
if (dataSet == nullptr) {
|
||||
return;
|
||||
}
|
||||
void DeviceHandlerBase::handleDeviceTm(const uint8_t* rawData, size_t rawDataLen,
|
||||
DeviceCommandId_t replyId, bool forceDirectTm) {
|
||||
SerialBufferAdapter bufferWrapper(rawData, rawDataLen);
|
||||
handleDeviceTm(bufferWrapper, replyId, forceDirectTm);
|
||||
}
|
||||
|
||||
DeviceReplyMap::iterator iter = deviceReplyMap.find(replyId);
|
||||
void DeviceHandlerBase::handleDeviceTm(const SerializeIF& dataSet, DeviceCommandId_t replyId,
|
||||
bool forceDirectTm) {
|
||||
auto iter = deviceReplyMap.find(replyId);
|
||||
if (iter == deviceReplyMap.end()) {
|
||||
triggerEvent(DEVICE_UNKNOWN_REPLY, replyId);
|
||||
return;
|
||||
}
|
||||
|
||||
/* Regular replies to a command */
|
||||
// Regular replies to a command
|
||||
if (iter->second.command != deviceCommandMap.end()) {
|
||||
MessageQueueId_t queueId = iter->second.command->second.sendReplyTo;
|
||||
|
||||
if (queueId != NO_COMMANDER) {
|
||||
/* This may fail, but we'll ignore the fault. */
|
||||
actionHelper.reportData(queueId, replyId, dataSet);
|
||||
// This may fail, but we'll ignore the fault.
|
||||
actionHelper.reportData(queueId, replyId, const_cast<SerializeIF*>(&dataSet));
|
||||
}
|
||||
|
||||
/* This check should make sure we get any TM but don't get anything doubled. */
|
||||
// This check should make sure we get any TM but don't get anything doubled.
|
||||
if (wiretappingMode == TM && (requestedRawTraffic != queueId)) {
|
||||
DeviceTmReportingWrapper wrapper(getObjectId(), replyId, dataSet);
|
||||
actionHelper.reportData(requestedRawTraffic, replyId, &wrapper);
|
||||
@ -1289,22 +1292,17 @@ void DeviceHandlerBase::handleDeviceTM(SerializeIF* dataSet, DeviceCommandId_t r
|
||||
// hiding of sender needed so the service will handle it as
|
||||
// unexpected Data, no matter what state (progress or completed)
|
||||
// it is in
|
||||
actionHelper.reportData(defaultRawReceiver, replyId, dataSet, true);
|
||||
actionHelper.reportData(defaultRawReceiver, replyId, const_cast<SerializeIF*>(&dataSet),
|
||||
true);
|
||||
}
|
||||
}
|
||||
/* Unrequested or aperiodic replies */
|
||||
// Unrequested or aperiodic replies
|
||||
else {
|
||||
DeviceTmReportingWrapper wrapper(getObjectId(), replyId, dataSet);
|
||||
if (wiretappingMode == TM) {
|
||||
actionHelper.reportData(requestedRawTraffic, replyId, &wrapper);
|
||||
}
|
||||
if (forceDirectTm and defaultRawReceiver != MessageQueueIF::NO_QUEUE) {
|
||||
// sid_t setSid = sid_t(this->getObjectId(), replyId);
|
||||
// LocalPoolDataSetBase* dataset = getDataSetHandle(setSid);
|
||||
// if(dataset != nullptr) {
|
||||
// poolManager.generateHousekeepingPacket(setSid, dataset, true);
|
||||
// }
|
||||
|
||||
// hiding of sender needed so the service will handle it as
|
||||
// unexpected Data, no matter what state (progress or completed)
|
||||
// it is in
|
||||
@ -1325,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,9 +1052,25 @@ class DeviceHandlerBase : public DeviceHandlerIF,
|
||||
|
||||
bool isAwaitingReply();
|
||||
|
||||
void handleDeviceTM(SerializeIF *dataSet, DeviceCommandId_t replyId, bool forceDirectTm = false);
|
||||
// void handleDeviceTM(uint8_t* data, size_t dataSize, DeviceCommandId_t replyId,
|
||||
// bool forceDirectTm);
|
||||
/**
|
||||
* 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);
|
||||
|
||||
virtual ReturnValue_t checkModeCommand(Mode_t mode, Submode_t submode,
|
||||
uint32_t *msToReachTheMode);
|
||||
|
@ -3,10 +3,10 @@
|
||||
#include "fsfw/serialize/SerializeAdapter.h"
|
||||
|
||||
DeviceTmReportingWrapper::DeviceTmReportingWrapper(object_id_t objectId, ActionId_t actionId,
|
||||
SerializeIF* data)
|
||||
const SerializeIF& data)
|
||||
: objectId(objectId), actionId(actionId), data(data) {}
|
||||
|
||||
DeviceTmReportingWrapper::~DeviceTmReportingWrapper() {}
|
||||
DeviceTmReportingWrapper::~DeviceTmReportingWrapper() = default;
|
||||
|
||||
ReturnValue_t DeviceTmReportingWrapper::serialize(uint8_t** buffer, size_t* size, size_t maxSize,
|
||||
Endianness streamEndianness) const {
|
||||
@ -19,22 +19,14 @@ ReturnValue_t DeviceTmReportingWrapper::serialize(uint8_t** buffer, size_t* size
|
||||
if (result != returnvalue::OK) {
|
||||
return result;
|
||||
}
|
||||
return data->serialize(buffer, size, maxSize, streamEndianness);
|
||||
return data.serialize(buffer, size, maxSize, streamEndianness);
|
||||
}
|
||||
|
||||
size_t DeviceTmReportingWrapper::getSerializedSize() const {
|
||||
return sizeof(objectId) + sizeof(ActionId_t) + data->getSerializedSize();
|
||||
return sizeof(objectId) + sizeof(ActionId_t) + data.getSerializedSize();
|
||||
}
|
||||
|
||||
ReturnValue_t DeviceTmReportingWrapper::deSerialize(const uint8_t** buffer, size_t* size,
|
||||
Endianness streamEndianness) {
|
||||
ReturnValue_t result = SerializeAdapter::deSerialize(&objectId, buffer, size, streamEndianness);
|
||||
if (result != returnvalue::OK) {
|
||||
return result;
|
||||
}
|
||||
result = SerializeAdapter::deSerialize(&actionId, buffer, size, streamEndianness);
|
||||
if (result != returnvalue::OK) {
|
||||
return result;
|
||||
}
|
||||
return data->deSerialize(buffer, size, streamEndianness);
|
||||
return returnvalue::FAILED;
|
||||
}
|
||||
|
@ -7,21 +7,22 @@
|
||||
|
||||
class DeviceTmReportingWrapper : public SerializeIF {
|
||||
public:
|
||||
DeviceTmReportingWrapper(object_id_t objectId, ActionId_t actionId, SerializeIF* data);
|
||||
virtual ~DeviceTmReportingWrapper();
|
||||
DeviceTmReportingWrapper(object_id_t objectId, ActionId_t actionId, const SerializeIF& data);
|
||||
~DeviceTmReportingWrapper() override;
|
||||
|
||||
virtual ReturnValue_t serialize(uint8_t** buffer, size_t* size, size_t maxSize,
|
||||
Endianness streamEndianness) const override;
|
||||
ReturnValue_t serialize(uint8_t** buffer, size_t* size, size_t maxSize,
|
||||
Endianness streamEndianness) const override;
|
||||
|
||||
virtual size_t getSerializedSize() const override;
|
||||
|
||||
virtual ReturnValue_t deSerialize(const uint8_t** buffer, size_t* size,
|
||||
Endianness streamEndianness) override;
|
||||
[[nodiscard]] size_t getSerializedSize() const override;
|
||||
|
||||
private:
|
||||
object_id_t objectId;
|
||||
ActionId_t actionId;
|
||||
SerializeIF* data;
|
||||
const SerializeIF& data;
|
||||
|
||||
// Deserialization forbidden
|
||||
ReturnValue_t deSerialize(const uint8_t** buffer, size_t* size,
|
||||
Endianness streamEndianness) override;
|
||||
};
|
||||
|
||||
#endif /* FSFW_DEVICEHANDLERS_DEVICETMREPORTINGWRAPPER_H_ */
|
||||
|
@ -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;
|
||||
|
@ -12,7 +12,7 @@ MessageQueueMessage::MessageQueueMessage() : messageSize(getMinimumMessageSize()
|
||||
MessageQueueMessage::MessageQueueMessage(uint8_t* data, size_t size)
|
||||
: messageSize(MessageQueueMessage::HEADER_SIZE + size) {
|
||||
if (size <= MessageQueueMessage::MAX_DATA_SIZE) {
|
||||
std::memcpy(internalBuffer + MessageQueueMessage::HEADER_SIZE, data, size);
|
||||
std::memcpy(MessageQueueMessage::getData(), data, size);
|
||||
this->messageSize = MessageQueueMessage::HEADER_SIZE + size;
|
||||
} else {
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
|
@ -8,7 +8,7 @@
|
||||
#include "../serialize/SerialLinkedListAdapter.h"
|
||||
#include "../serialize/SerializeElement.h"
|
||||
#include "../serviceinterface/ServiceInterface.h"
|
||||
#include "../timemanager/TimeStamperIF.h"
|
||||
#include "../timemanager/TimeWriterIF.h"
|
||||
#include "HasMonitorsIF.h"
|
||||
#include "MonitoringIF.h"
|
||||
#include "monitoringConf.h"
|
||||
@ -34,9 +34,9 @@ class MonitoringReportContent : public SerialLinkedListAdapter<SerializeIF> {
|
||||
SerializeElement<T> limitValue;
|
||||
SerializeElement<ReturnValue_t> oldState;
|
||||
SerializeElement<ReturnValue_t> newState;
|
||||
uint8_t rawTimestamp[TimeStamperIF::MAXIMUM_TIMESTAMP_LEN] = {};
|
||||
uint8_t rawTimestamp[TimeWriterIF::MAXIMUM_TIMESTAMP_LEN] = {};
|
||||
SerializeElement<SerialBufferAdapter<uint8_t>> timestampSerializer;
|
||||
TimeStamperIF* timeStamper;
|
||||
TimeWriterIF* timeStamper;
|
||||
MonitoringReportContent()
|
||||
: SerialLinkedListAdapter<SerializeIF>(¶meterObjectId),
|
||||
monitorId(0),
|
||||
@ -79,7 +79,7 @@ class MonitoringReportContent : public SerialLinkedListAdapter<SerializeIF> {
|
||||
}
|
||||
bool checkAndSetStamper() {
|
||||
if (timeStamper == nullptr) {
|
||||
timeStamper = ObjectManager::instance()->get<TimeStamperIF>(timeStamperId);
|
||||
timeStamper = ObjectManager::instance()->get<TimeWriterIF>(timeStamperId);
|
||||
if (timeStamper == nullptr) {
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::error << "MonitoringReportContent::checkAndSetStamper: "
|
||||
|
@ -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;
|
||||
|
||||
|
@ -564,12 +564,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++;
|
||||
}
|
||||
@ -579,16 +584,6 @@ inline ReturnValue_t Service11TelecommandScheduling<MAX_NUM_TCS>::getMapFilterFr
|
||||
default:
|
||||
return returnvalue::FAILED;
|
||||
}
|
||||
|
||||
// additional security check, this should never be true
|
||||
if (itBegin->first > itEnd->first) {
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
#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;
|
||||
}
|
||||
|
@ -11,7 +11,7 @@ Service1TelecommandVerification::Service1TelecommandVerification(object_id_t obj
|
||||
uint16_t apid, uint8_t serviceId,
|
||||
object_id_t targetDestination,
|
||||
uint16_t messageQueueDepth,
|
||||
TimeStamperIF* timeStamper)
|
||||
TimeWriterIF* timeStamper)
|
||||
: SystemObject(objectId),
|
||||
apid(apid),
|
||||
serviceId(serviceId),
|
||||
@ -134,7 +134,7 @@ ReturnValue_t Service1TelecommandVerification::initialize() {
|
||||
storeHelper.setTmStore(*tmStore);
|
||||
}
|
||||
if (timeStamper == nullptr) {
|
||||
timeStamper = ObjectManager::instance()->get<TimeStamperIF>(objects::TIME_STAMPER);
|
||||
timeStamper = ObjectManager::instance()->get<TimeWriterIF>(objects::TIME_STAMPER);
|
||||
if (timeStamper == nullptr) {
|
||||
return ObjectManagerIF::CHILD_INIT_FAILED;
|
||||
}
|
||||
|
@ -47,7 +47,7 @@ class Service1TelecommandVerification : public AcceptsVerifyMessageIF,
|
||||
|
||||
Service1TelecommandVerification(object_id_t objectId, uint16_t apid, uint8_t serviceId,
|
||||
object_id_t targetDestination, uint16_t messageQueueDepth,
|
||||
TimeStamperIF* timeStamper = nullptr);
|
||||
TimeWriterIF* timeStamper = nullptr);
|
||||
~Service1TelecommandVerification() override;
|
||||
|
||||
/**
|
||||
@ -87,7 +87,7 @@ class Service1TelecommandVerification : public AcceptsVerifyMessageIF,
|
||||
TmStoreHelper storeHelper;
|
||||
TmStoreAndSendWrapper tmHelper;
|
||||
InternalErrorReporterIF* errReporter = nullptr;
|
||||
TimeStamperIF* timeStamper = nullptr;
|
||||
TimeWriterIF* timeStamper = nullptr;
|
||||
StorageManagerIF* tmStore = nullptr;
|
||||
MessageQueueIF* tmQueue = nullptr;
|
||||
|
||||
|
@ -1,8 +1,6 @@
|
||||
#ifndef FSFW_RETURNVALUES_RETURNVALUE_H_
|
||||
#define FSFW_RETURNVALUES_RETURNVALUE_H_
|
||||
|
||||
#include <returnvalues/classIds.h>
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
#include "FwClassIds.h"
|
||||
|
@ -21,7 +21,7 @@ SerialBufferAdapter<count_t>::SerialBufferAdapter(uint8_t* buffer, count_t buffe
|
||||
bufferLength(bufferLength) {}
|
||||
|
||||
template <typename count_t>
|
||||
SerialBufferAdapter<count_t>::~SerialBufferAdapter() {}
|
||||
SerialBufferAdapter<count_t>::~SerialBufferAdapter() = default;
|
||||
|
||||
template <typename count_t>
|
||||
ReturnValue_t SerialBufferAdapter<count_t>::serialize(uint8_t** buffer, size_t* size,
|
||||
@ -119,10 +119,10 @@ const uint8_t* SerialBufferAdapter<count_t>::getConstBuffer() const {
|
||||
}
|
||||
|
||||
template <typename count_t>
|
||||
void SerialBufferAdapter<count_t>::setBuffer(uint8_t* buffer, count_t bufferLength) {
|
||||
this->buffer = buffer;
|
||||
this->constBuffer = buffer;
|
||||
this->bufferLength = bufferLength;
|
||||
void SerialBufferAdapter<count_t>::setConstBuffer(const uint8_t* buf, count_t bufLen) {
|
||||
this->buffer = nullptr;
|
||||
this->bufferLength = bufLen;
|
||||
this->constBuffer = buf;
|
||||
}
|
||||
|
||||
// forward Template declaration for linker
|
||||
|
@ -21,6 +21,7 @@
|
||||
template <typename count_t>
|
||||
class SerialBufferAdapter : public SerializeIF {
|
||||
public:
|
||||
SerialBufferAdapter() = default;
|
||||
/**
|
||||
* Constructor for constant uint8_t buffer. Length field can be serialized optionally.
|
||||
* Type of length can be supplied as template type.
|
||||
@ -40,12 +41,12 @@ class SerialBufferAdapter : public SerializeIF {
|
||||
*/
|
||||
SerialBufferAdapter(uint8_t* buffer, count_t bufferLength, bool serializeLength = false);
|
||||
|
||||
virtual ~SerialBufferAdapter();
|
||||
~SerialBufferAdapter() override;
|
||||
|
||||
virtual ReturnValue_t serialize(uint8_t** buffer, size_t* size, size_t maxSize,
|
||||
Endianness streamEndianness) const override;
|
||||
ReturnValue_t serialize(uint8_t** buffer, size_t* size, size_t maxSize,
|
||||
Endianness streamEndianness) const override;
|
||||
|
||||
virtual size_t getSerializedSize() const override;
|
||||
[[nodiscard]] size_t getSerializedSize() const override;
|
||||
|
||||
/**
|
||||
* @brief This function deserializes a buffer into the member buffer.
|
||||
@ -59,12 +60,12 @@ class SerialBufferAdapter : public SerializeIF {
|
||||
* @param bigEndian
|
||||
* @return
|
||||
*/
|
||||
virtual ReturnValue_t deSerialize(const uint8_t** buffer, size_t* size,
|
||||
Endianness streamEndianness) override;
|
||||
ReturnValue_t deSerialize(const uint8_t** buffer, size_t* size,
|
||||
Endianness streamEndianness) override;
|
||||
|
||||
uint8_t* getBuffer();
|
||||
const uint8_t* getConstBuffer() const;
|
||||
void setBuffer(uint8_t* buffer, count_t bufferLength);
|
||||
[[nodiscard]] const uint8_t* getConstBuffer() const;
|
||||
void setConstBuffer(const uint8_t* buf, count_t bufLen);
|
||||
|
||||
private:
|
||||
bool serializeLength = false;
|
||||
|
@ -1,8 +1,8 @@
|
||||
#include "fsfw/serviceinterface/ServiceInterfaceBuffer.h"
|
||||
#include "ServiceInterfaceBuffer.h"
|
||||
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
|
||||
#include <inttypes.h>
|
||||
#include <cinttypes>
|
||||
|
||||
#include <cstring>
|
||||
|
||||
@ -16,8 +16,6 @@
|
||||
// to be implemented by bsp
|
||||
extern "C" void printChar(const char*, bool errStream);
|
||||
|
||||
#ifndef UT699
|
||||
|
||||
ServiceInterfaceBuffer::ServiceInterfaceBuffer(std::string setMessage, bool addCrToPreamble,
|
||||
bool buffered, bool errStream, uint16_t port)
|
||||
: isActive(true),
|
||||
@ -58,6 +56,9 @@ ServiceInterfaceBuffer::ServiceInterfaceBuffer(std::string setMessage, bool addC
|
||||
}
|
||||
|
||||
void ServiceInterfaceBuffer::putChars(char const* begin, char const* end) {
|
||||
if (not isActive) {
|
||||
return;
|
||||
}
|
||||
char array[BUF_SIZE];
|
||||
uint32_t length = end - begin;
|
||||
if (length > sizeof(array)) {
|
||||
@ -74,8 +75,6 @@ void ServiceInterfaceBuffer::putChars(char const* begin, char const* end) {
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
int ServiceInterfaceBuffer::overflow(int c) {
|
||||
if (not buffered and this->isActive) {
|
||||
if (c != Traits::eof()) {
|
||||
@ -169,89 +168,4 @@ void ServiceInterfaceBuffer::setAsciiColorPrefix(std::string colorPrefix) {
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef UT699
|
||||
#include "../osal/rtems/Interrupt.h"
|
||||
|
||||
ServiceInterfaceBuffer::ServiceInterfaceBuffer(std::string set_message, uint16_t port) {
|
||||
this->log_message = set_message;
|
||||
this->isActive = true;
|
||||
setp(buf, buf + BUF_SIZE);
|
||||
}
|
||||
|
||||
void ServiceInterfaceBuffer::putChars(char const* begin, char const* end) {
|
||||
char array[BUF_SIZE];
|
||||
uint32_t length = end - begin;
|
||||
if (length > sizeof(array)) {
|
||||
length = sizeof(array);
|
||||
}
|
||||
memcpy(array, begin, length);
|
||||
|
||||
if (!Interrupt::isInterruptInProgress()) {
|
||||
std::cout << array;
|
||||
} else {
|
||||
// Uncomment the following line if you need ISR debug output.
|
||||
// printk(array);
|
||||
}
|
||||
}
|
||||
#endif // UT699
|
||||
|
||||
#ifdef ML505
|
||||
#include <bsp_flp/network/networkconfig.h>
|
||||
ServiceInterfaceBuffer::ServiceInterfaceBuffer(std::string set_message, uint16_t port)
|
||||
: isActive(true),
|
||||
log_message(set_message),
|
||||
udpSocket(0),
|
||||
remoteAddressLength(sizeof(remoteAddress)) {
|
||||
setp(buf, buf + BUF_SIZE);
|
||||
memset((uint8_t*)&remoteAddress, 0, sizeof(remoteAddress));
|
||||
remoteAddress.sin_family = AF_INET;
|
||||
remoteAddress.sin_port = htons(port);
|
||||
remoteAddress.sin_addr.s_addr = htonl(inet_addr("192.168.250.100"));
|
||||
}
|
||||
|
||||
void ServiceInterfaceBuffer::putChars(char const* begin, char const* end) {
|
||||
char array[BUF_SIZE];
|
||||
uint32_t length = end - begin;
|
||||
if (length > sizeof(array)) {
|
||||
length = sizeof(array);
|
||||
}
|
||||
memcpy(array, begin, length);
|
||||
|
||||
if (udpSocket <= 0) {
|
||||
initSocket();
|
||||
}
|
||||
|
||||
if (udpSocket > 0) {
|
||||
sendto(udpSocket, array, length, 0, (sockaddr*)&remoteAddress, sizeof(remoteAddress));
|
||||
}
|
||||
}
|
||||
|
||||
void ServiceInterfaceBuffer::initSocket() {
|
||||
sockaddr_in address;
|
||||
memset((uint8_t*)&address, 0, sizeof(address));
|
||||
address.sin_family = AF_INET;
|
||||
address.sin_port = htons(0);
|
||||
address.sin_addr.s_addr = htonl(INADDR_ANY);
|
||||
|
||||
udpSocket = socket(PF_INET, SOCK_DGRAM, 0);
|
||||
if (socket < 0) {
|
||||
printf("Error opening socket!\n");
|
||||
return;
|
||||
}
|
||||
timeval timeout = {0, 20};
|
||||
if (setsockopt(udpSocket, SOL_SOCKET, SO_RCVTIMEO, &timeout, sizeof(timeout)) < 0) {
|
||||
printf("Error setting SO_RCVTIMEO socket options!\n");
|
||||
return;
|
||||
}
|
||||
if (setsockopt(udpSocket, SOL_SOCKET, SO_SNDTIMEO, &timeout, sizeof(timeout)) < 0) {
|
||||
printf("Error setting SO_SNDTIMEO socket options!\n");
|
||||
return;
|
||||
}
|
||||
if (bind(udpSocket, (sockaddr*)&address, sizeof(address)) < 0) {
|
||||
printf("Error binding socket!\n");
|
||||
}
|
||||
}
|
||||
|
||||
#endif // ML505
|
||||
|
||||
#endif /* FSFW_CPP_OSTREAM_ENABLED == 1 */
|
||||
#endif
|
||||
|
@ -1,9 +1,8 @@
|
||||
#ifndef FRAMEWORK_SERVICEINTERFACE_SERVICEINTERFACEBUFFER_H_
|
||||
#define FRAMEWORK_SERVICEINTERFACE_SERVICEINTERFACEBUFFER_H_
|
||||
|
||||
#include <FSFWConfig.h>
|
||||
|
||||
#include "../returnvalues/returnvalue.h"
|
||||
#include "fsfw/FSFW.h"
|
||||
#include "fsfw/returnvalues/returnvalue.h"
|
||||
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
|
||||
@ -11,8 +10,6 @@
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
|
||||
#ifndef UT699
|
||||
|
||||
/**
|
||||
* @brief This is the underlying stream buffer which implements the
|
||||
* streambuf class and overloads the overflow() and sync() methods
|
||||
@ -77,85 +74,6 @@ class ServiceInterfaceBuffer : public std::streambuf {
|
||||
bool crAdditionEnabled() const;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef UT699
|
||||
class ServiceInterfaceBuffer : public std::basic_streambuf<char, std::char_traits<char> > {
|
||||
friend class ServiceInterfaceStream;
|
||||
|
||||
public:
|
||||
ServiceInterfaceBuffer(std::string set_message, uint16_t port);
|
||||
|
||||
protected:
|
||||
bool isActive;
|
||||
// This is called when buffer becomes full. If
|
||||
// buffer is not used, then this is called every
|
||||
// time when characters are put to stream.
|
||||
virtual int overflow(int c = Traits::eof());
|
||||
|
||||
// This function is called when stream is flushed,
|
||||
// for example when std::endl is put to stream.
|
||||
virtual int sync(void);
|
||||
|
||||
private:
|
||||
// For additional message information
|
||||
std::string log_message;
|
||||
// For EOF detection
|
||||
typedef std::char_traits<char> Traits;
|
||||
|
||||
// Work in buffer mode. It is also possible to work without buffer.
|
||||
static size_t const BUF_SIZE = 128;
|
||||
char buf[BUF_SIZE];
|
||||
|
||||
// In this function, the characters are parsed.
|
||||
void putChars(char const* begin, char const* end);
|
||||
};
|
||||
#endif // UT699
|
||||
|
||||
#ifdef ML505
|
||||
#include <arpa/inet.h>
|
||||
#include <netinet/in.h>
|
||||
#include <netinet/udp.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
class ServiceInterfaceBuffer : public std::basic_streambuf<char, std::char_traits<char> > {
|
||||
friend class ServiceInterfaceStream;
|
||||
|
||||
public:
|
||||
ServiceInterfaceBuffer(std::string set_message, uint16_t port);
|
||||
|
||||
protected:
|
||||
bool isActive;
|
||||
// This is called when buffer becomes full. If
|
||||
// buffer is not used, then this is called every
|
||||
// time when characters are put to stream.
|
||||
virtual int overflow(int c = Traits::eof());
|
||||
|
||||
// This function is called when stream is flushed,
|
||||
// for example when std::endl is put to stream.
|
||||
virtual int sync(void);
|
||||
|
||||
private:
|
||||
// For additional message information
|
||||
std::string log_message;
|
||||
// For EOF detection
|
||||
typedef std::char_traits<char> Traits;
|
||||
|
||||
// Work in buffer mode. It is also possible to work without buffer.
|
||||
static size_t const BUF_SIZE = 128;
|
||||
char buf[BUF_SIZE];
|
||||
|
||||
// In this function, the characters are parsed.
|
||||
void putChars(char const* begin, char const* end);
|
||||
|
||||
int udpSocket;
|
||||
sockaddr_in remoteAddress;
|
||||
socklen_t remoteAddressLength;
|
||||
void initSocket();
|
||||
};
|
||||
#endif // ML505
|
||||
|
||||
#endif /* FSFW_CPP_OSTREAM_ENABLED == 1 */
|
||||
|
||||
#endif /* FRAMEWORK_SERVICEINTERFACE_SERVICEINTERFACEBUFFER_H_ */
|
||||
|
@ -5,7 +5,6 @@
|
||||
|
||||
#include "../returnvalues/returnvalue.h"
|
||||
#include "../tmtcpacket/cfdp/CfdpPacketStored.h"
|
||||
|
||||
#include "../tmtcservices/AcceptsTelecommandsIF.h"
|
||||
#include "../tmtcservices/VerificationReporter.h"
|
||||
#include "CFDPDistributorIF.h"
|
||||
|
@ -1,13 +1,9 @@
|
||||
#ifndef FSFW_TCDISTRIBUTION_TCPACKETCHECKIF_H_
|
||||
#define FSFW_TCDISTRIBUTION_TCPACKETCHECKIF_H_
|
||||
|
||||
<<<<<<< HEAD:src/fsfw/tcdistribution/CcsdsPacketCheckIF.h
|
||||
#include <cstddef>
|
||||
=======
|
||||
#include "../returnvalues/returnvalue.h"
|
||||
>>>>>>> origin/development:src/fsfw/tcdistribution/TcPacketCheckIF.h
|
||||
|
||||
#include "fsfw/returnvalues/HasReturnvaluesIF.h"
|
||||
#include "fsfw/returnvalues/returnvalue.h"
|
||||
|
||||
class SpacePacketReader;
|
||||
|
||||
|
@ -103,7 +103,7 @@ ReturnValue_t PusDistributor::callbackAfterSending(ReturnValue_t queueStatus) {
|
||||
if (queueStatus != returnvalue::OK) {
|
||||
tcStatus = queueStatus;
|
||||
}
|
||||
if (tcStatus != RETURN_OK) {
|
||||
if (tcStatus != returnvalue::OK) {
|
||||
verifyChannel->sendFailureReport({tcverif::ACCEPTANCE_FAILURE, reader, tcStatus});
|
||||
// A failed packet is deleted immediately after reporting,
|
||||
// otherwise it will block memory.
|
||||
@ -111,7 +111,7 @@ ReturnValue_t PusDistributor::callbackAfterSending(ReturnValue_t queueStatus) {
|
||||
return returnvalue::FAILED;
|
||||
} else {
|
||||
verifyChannel->sendSuccessReport({tcverif::ACCEPTANCE_SUCCESS, reader});
|
||||
return RETURN_OK;
|
||||
return returnvalue::OK;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
#define FSFW_TCDISTRIBUTION_TCPACKETCHECKPUS_H_
|
||||
|
||||
#include "fsfw/FSFW.h"
|
||||
#include "fsfw/returnvalues/HasReturnvaluesIF.h"
|
||||
#include "fsfw/returnvalues/returnvalue.h"
|
||||
#include "fsfw/tmtcpacket/pus/defs.h"
|
||||
#include "fsfw/tmtcservices/PusVerificationReport.h"
|
||||
|
||||
|
@ -9,4 +9,3 @@ ReturnValue_t CfdpPacketChecker::checkPacket(const SpacePacketReader& currentPac
|
||||
}
|
||||
|
||||
uint16_t CfdpPacketChecker::getApid() const { return apid; }
|
||||
|
||||
|
@ -4,7 +4,7 @@
|
||||
#include <cstdint>
|
||||
|
||||
#include "fsfw/returnvalues/FwClassIds.h"
|
||||
#include "fsfw/returnvalues/HasReturnvaluesIF.h"
|
||||
#include "fsfw/returnvalues/returnvalue.h"
|
||||
|
||||
namespace tcdistrib {
|
||||
static const uint8_t INTERFACE_ID = CLASS_ID::PACKET_CHECK;
|
||||
|
@ -39,13 +39,13 @@ class CCSDSTime {
|
||||
* Struct for CDS day-segmented format.
|
||||
*/
|
||||
struct CDS_short {
|
||||
uint8_t pField;
|
||||
uint8_t dayMSB;
|
||||
uint8_t dayLSB;
|
||||
uint8_t msDay_hh;
|
||||
uint8_t msDay_h;
|
||||
uint8_t msDay_l;
|
||||
uint8_t msDay_ll;
|
||||
uint8_t pField = P_FIELD_CDS_SHORT;
|
||||
uint8_t dayMSB = 0;
|
||||
uint8_t dayLSB = 0;
|
||||
uint8_t msDay_hh = 0;
|
||||
uint8_t msDay_h = 0;
|
||||
uint8_t msDay_l = 0;
|
||||
uint8_t msDay_ll = 0;
|
||||
};
|
||||
/**
|
||||
* Struct for the CCS fromat in day of month variation with max resolution
|
||||
|
@ -6,11 +6,6 @@
|
||||
|
||||
CdsShortTimeStamper::CdsShortTimeStamper(object_id_t objectId) : SystemObject(objectId) {}
|
||||
|
||||
ReturnValue_t CdsShortTimeStamper::addTimeStamp(uint8_t *buffer, const uint8_t maxSize) {
|
||||
size_t serLen = 0;
|
||||
return serialize(&buffer, &serLen, maxSize, SerializeIF::Endianness::NETWORK);
|
||||
}
|
||||
|
||||
ReturnValue_t CdsShortTimeStamper::serialize(uint8_t **buffer, size_t *size, size_t maxSize,
|
||||
SerializeIF::Endianness streamEndianness) const {
|
||||
if (*size + getSerializedSize() > maxSize) {
|
||||
@ -33,15 +28,22 @@ size_t CdsShortTimeStamper::getSerializedSize() const { return getTimestampSize(
|
||||
|
||||
ReturnValue_t CdsShortTimeStamper::deSerialize(const uint8_t **buffer, size_t *size,
|
||||
SerializeIF::Endianness streamEndianness) {
|
||||
return returnvalue::FAILED;
|
||||
}
|
||||
|
||||
ReturnValue_t CdsShortTimeStamper::readTimeStamp(const uint8_t *buffer, size_t maxSize) {
|
||||
if (maxSize < getTimestampSize()) {
|
||||
if (size == nullptr or buffer == nullptr) {
|
||||
return returnvalue::FAILED;
|
||||
}
|
||||
if (*size < getTimestampSize()) {
|
||||
return SerializeIF::STREAM_TOO_SHORT;
|
||||
}
|
||||
size_t foundLen = 0;
|
||||
return CCSDSTime::convertFromCcsds(&readTime, buffer, &foundLen, maxSize);
|
||||
if (((**buffer >> 4) & 0b111) != CCSDSTime::TimeCodeIdentification::CDS) {
|
||||
return BAD_TIMESTAMP;
|
||||
}
|
||||
auto res = CCSDSTime::convertFromCcsds(&readTime, *buffer, &foundLen, *size);
|
||||
if (res == returnvalue::OK) {
|
||||
*size -= getSerializedSize();
|
||||
*buffer += getSerializedSize();
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
timeval &CdsShortTimeStamper::getTime() { return readTime; }
|
||||
|
@ -3,7 +3,7 @@
|
||||
|
||||
#include "CCSDSTime.h"
|
||||
#include "TimeReaderIF.h"
|
||||
#include "TimeStamperIF.h"
|
||||
#include "TimeWriterIF.h"
|
||||
#include "fsfw/objectmanager/SystemObject.h"
|
||||
|
||||
/**
|
||||
@ -15,7 +15,7 @@
|
||||
* overriding the #addTimeStamp function.
|
||||
* @ingroup utility
|
||||
*/
|
||||
class CdsShortTimeStamper : public TimeStamperIF, public TimeReaderIF, public SystemObject {
|
||||
class CdsShortTimeStamper : public TimeWriterIF, public TimeReaderIF, public SystemObject {
|
||||
public:
|
||||
static constexpr size_t TIMESTAMP_LEN = 7;
|
||||
/**
|
||||
@ -25,20 +25,11 @@ class CdsShortTimeStamper : public TimeStamperIF, public TimeReaderIF, public Sy
|
||||
*/
|
||||
explicit CdsShortTimeStamper(object_id_t objectId);
|
||||
|
||||
/**
|
||||
* Adds a CCSDS CDC short 8 byte timestamp to the given buffer.
|
||||
* This function can be overriden to use a custom timestamp.
|
||||
* @param buffer
|
||||
* @param maxSize
|
||||
* @return
|
||||
*/
|
||||
ReturnValue_t addTimeStamp(uint8_t *buffer, uint8_t maxSize) override;
|
||||
ReturnValue_t serialize(uint8_t **buffer, size_t *size, size_t maxSize,
|
||||
Endianness streamEndianness) const override;
|
||||
[[nodiscard]] size_t getSerializedSize() const override;
|
||||
ReturnValue_t deSerialize(const uint8_t **buffer, size_t *size,
|
||||
Endianness streamEndianness) override;
|
||||
ReturnValue_t readTimeStamp(const uint8_t *buffer, size_t maxSize) override;
|
||||
timeval &getTime() override;
|
||||
[[nodiscard]] size_t getTimestampSize() const override;
|
||||
|
||||
|
@ -4,13 +4,29 @@
|
||||
#include <cstdlib>
|
||||
|
||||
#include "TimeStampIF.h"
|
||||
#include "fsfw/returnvalues/HasReturnvaluesIF.h"
|
||||
#include "fsfw/returnvalues/returnvalue.h"
|
||||
#include "fsfw/serialize/SerializeIF.h"
|
||||
|
||||
class TimeReaderIF : public TimeStampIF {
|
||||
class TimeReaderIF : public SerializeIF, public TimeStampIF {
|
||||
public:
|
||||
~TimeReaderIF() override = default;
|
||||
virtual ReturnValue_t readTimeStamp(const uint8_t* buffer, size_t maxSize) = 0;
|
||||
virtual timeval& getTime() = 0;
|
||||
|
||||
[[nodiscard]] size_t getSerializedSize() const override { return getTimestampSize(); }
|
||||
|
||||
ReturnValue_t readTimeStamp(const uint8_t* buf, size_t maxSize) {
|
||||
size_t dummy = 0;
|
||||
return deSerialize(buf, dummy, maxSize, SerializeIF::Endianness::NETWORK);
|
||||
}
|
||||
|
||||
private:
|
||||
/**
|
||||
* Forbidden, use dedicated IF @TimeWriterIF
|
||||
*/
|
||||
[[nodiscard]] ReturnValue_t serialize(uint8_t** buffer, size_t* size, size_t maxSize,
|
||||
Endianness streamEndianness) const override {
|
||||
return returnvalue::FAILED;
|
||||
}
|
||||
};
|
||||
|
||||
#endif // FSFW_TIMEMANAGER_TIMEREADERIF_H
|
||||
|
@ -1,23 +0,0 @@
|
||||
#ifndef FSFW_TIMEMANAGER_TIMESTAMPERIF_H_
|
||||
#define FSFW_TIMEMANAGER_TIMESTAMPERIF_H_
|
||||
|
||||
#include "TimeStampIF.h"
|
||||
#include "fsfw/returnvalues/returnvalue.h"
|
||||
#include "fsfw/serialize/SerializeIF.h"
|
||||
|
||||
/**
|
||||
* A class implementing this IF provides facilities to add a time stamp to the
|
||||
* buffer provided.
|
||||
* Implementors need to ensure that calling the method is thread-safe, i.e.
|
||||
* addTimeStamp may be called in parallel from a different context.
|
||||
*/
|
||||
class TimeStamperIF : public SerializeIF, public TimeStampIF {
|
||||
public:
|
||||
virtual ReturnValue_t addTimeStamp(uint8_t* buffer, uint8_t maxSize) = 0;
|
||||
~TimeStamperIF() override = default;
|
||||
size_t getTimestampSize() const override { return getSerializedSize(); }
|
||||
|
||||
protected:
|
||||
};
|
||||
|
||||
#endif /* FSFW_TIMEMANAGER_TIMESTAMPERIF_H_ */
|
34
src/fsfw/timemanager/TimeWriterIF.h
Normal file
34
src/fsfw/timemanager/TimeWriterIF.h
Normal file
@ -0,0 +1,34 @@
|
||||
#ifndef FSFW_TIMEMANAGER_TIMESTAMPERIF_H_
|
||||
#define FSFW_TIMEMANAGER_TIMESTAMPERIF_H_
|
||||
|
||||
#include "TimeStampIF.h"
|
||||
#include "fsfw/returnvalues/returnvalue.h"
|
||||
#include "fsfw/serialize/SerializeIF.h"
|
||||
|
||||
/**
|
||||
* A class implementing this IF provides facilities to add a time stamp to the
|
||||
* buffer provided.
|
||||
* Implementors need to ensure that calling the method is thread-safe, i.e.
|
||||
* addTimeStamp may be called in parallel from a different context.
|
||||
*/
|
||||
class TimeWriterIF : public SerializeIF, public TimeStampIF {
|
||||
public:
|
||||
~TimeWriterIF() override = default;
|
||||
[[nodiscard]] size_t getTimestampSize() const override { return getSerializedSize(); }
|
||||
|
||||
ReturnValue_t addTimeStamp(uint8_t *buf, size_t maxSize) {
|
||||
size_t dummy = 0;
|
||||
return serialize(buf, dummy, maxSize, SerializeIF::Endianness::NETWORK);
|
||||
}
|
||||
|
||||
private:
|
||||
/**
|
||||
* Forbidden, use dedicated IF @TimeReaderIF
|
||||
*/
|
||||
ReturnValue_t deSerialize(const uint8_t **buffer, size_t *size,
|
||||
Endianness streamEndianness) override {
|
||||
return returnvalue::FAILED;
|
||||
}
|
||||
};
|
||||
|
||||
#endif /* FSFW_TIMEMANAGER_TIMESTAMPERIF_H_ */
|
@ -7,7 +7,7 @@
|
||||
#include "fsfw/serialize/SerialLinkedListAdapter.h"
|
||||
#include "fsfw/serialize/SerializeElement.h"
|
||||
#include "fsfw/timemanager/CCSDSTime.h"
|
||||
#include "fsfw/timemanager/TimeStamperIF.h"
|
||||
#include "fsfw/timemanager/TimeWriterIF.h"
|
||||
#include "fsfw/tmtcpacket/pus/tm/PusTmMinimal.h"
|
||||
#include "tmStorageConf.h"
|
||||
|
||||
|
@ -3,7 +3,7 @@
|
||||
|
||||
#include <cstddef>
|
||||
|
||||
#include "fsfw/returnvalues/HasReturnvaluesIF.h"
|
||||
#include "fsfw/returnvalues/returnvalue.h"
|
||||
#include "fsfw/tmtcpacket/ReadablePacketIF.h"
|
||||
#include "fsfw/tmtcpacket/RedirectableDataPointerIF.h"
|
||||
#include "fsfw/tmtcpacket/ccsds/defs.h"
|
||||
|
@ -7,11 +7,7 @@
|
||||
#include "fsfw/tmtcpacket/pus/tm/PusTmIF.h"
|
||||
#include "fsfw/tmtcpacket/pus/tm/PusTmMinimal.h"
|
||||
|
||||
<<<<<<< HEAD
|
||||
class PacketMatchTree : public MatchTree<PusTmIF*> {
|
||||
=======
|
||||
class PacketMatchTree : public MatchTree<TmPacketMinimal*> {
|
||||
>>>>>>> origin/development
|
||||
public:
|
||||
explicit PacketMatchTree(Node* root);
|
||||
explicit PacketMatchTree(iterator root);
|
||||
|
@ -7,6 +7,6 @@ class CustomUserDataIF {
|
||||
public:
|
||||
virtual ~CustomUserDataIF() = default;
|
||||
virtual ReturnValue_t setRawUserData(const uint8_t* data, size_t len) = 0;
|
||||
virtual ReturnValue_t setSerializableUserData(SerializeIF& serializable) = 0;
|
||||
virtual ReturnValue_t setSerializableUserData(const SerializeIF& serializable) = 0;
|
||||
};
|
||||
#endif // FSFW_TMTCPACKET_CREATORDATAIF_H
|
||||
|
@ -13,44 +13,6 @@ using PusChecksumT = uint16_t;
|
||||
//! Version numbers according to ECSS-E-ST-70-41C p.439
|
||||
enum PusVersion : uint8_t { PUS_A = 1, PUS_C = 2 };
|
||||
|
||||
struct RawData {
|
||||
const uint8_t* data;
|
||||
size_t len;
|
||||
};
|
||||
|
||||
enum DataTypes { RAW, SERIALIZABLE };
|
||||
|
||||
union DataUnion {
|
||||
RawData raw;
|
||||
SerializeIF* serializable;
|
||||
};
|
||||
|
||||
struct DataWrapper {
|
||||
DataTypes type;
|
||||
DataUnion dataUnion;
|
||||
using BufPairT = std::pair<const uint8_t*, size_t>;
|
||||
|
||||
[[nodiscard]] size_t getLength() const {
|
||||
if (type == DataTypes::RAW) {
|
||||
return dataUnion.raw.len;
|
||||
} else if (type == DataTypes::SERIALIZABLE and dataUnion.serializable != nullptr) {
|
||||
return dataUnion.serializable->getSerializedSize();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void setRawData(BufPairT bufPair) {
|
||||
type = DataTypes::RAW;
|
||||
dataUnion.raw.data = bufPair.first;
|
||||
dataUnion.raw.len = bufPair.second;
|
||||
}
|
||||
|
||||
void setSerializable(SerializeIF& serializable) {
|
||||
type = DataTypes::SERIALIZABLE;
|
||||
dataUnion.serializable = &serializable;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* This struct defines the data structure of a Space Packet when accessed
|
||||
* via a pointer.
|
||||
|
@ -14,7 +14,6 @@ PusTcCreator::PusTcCreator(SpacePacketParams spParams, PusTcParams pusParams)
|
||||
ReturnValue_t PusTcCreator::serialize(uint8_t **buffer, size_t *size, size_t maxSize,
|
||||
SerializeIF::Endianness streamEndianness) const {
|
||||
const uint8_t *start = *buffer;
|
||||
size_t userDataLen = pusParams.dataWrapper.getLength();
|
||||
if (*size + getSerializedSize() > maxSize) {
|
||||
return SerializeIF::BUFFER_TOO_SHORT;
|
||||
}
|
||||
@ -37,17 +36,8 @@ ReturnValue_t PusTcCreator::serialize(uint8_t **buffer, size_t *size, size_t max
|
||||
if (result != returnvalue::OK) {
|
||||
return result;
|
||||
}
|
||||
if (pusParams.dataWrapper.type == ecss::DataTypes::RAW) {
|
||||
const uint8_t *data = pusParams.dataWrapper.dataUnion.raw.data;
|
||||
if (data != nullptr and userDataLen > 0) {
|
||||
std::memcpy(*buffer, data, userDataLen);
|
||||
*buffer += userDataLen;
|
||||
*size += userDataLen;
|
||||
}
|
||||
} else if (pusParams.dataWrapper.type == ecss::DataTypes::SERIALIZABLE and
|
||||
pusParams.dataWrapper.dataUnion.serializable != nullptr) {
|
||||
result = pusParams.dataWrapper.dataUnion.serializable->serialize(buffer, size, maxSize,
|
||||
streamEndianness);
|
||||
if (pusParams.appData != nullptr) {
|
||||
result = pusParams.appData->serialize(buffer, size, maxSize, streamEndianness);
|
||||
if (result != returnvalue::OK) {
|
||||
return result;
|
||||
}
|
||||
@ -58,8 +48,11 @@ ReturnValue_t PusTcCreator::serialize(uint8_t **buffer, size_t *size, size_t max
|
||||
}
|
||||
|
||||
void PusTcCreator::updateSpLengthField() {
|
||||
spCreator.setDataLen(ecss::PusTcDataFieldHeader::MIN_SIZE + pusParams.dataWrapper.getLength() +
|
||||
1);
|
||||
size_t len = ecss::PusTcDataFieldHeader::MIN_SIZE + 1;
|
||||
if (pusParams.appData != nullptr) {
|
||||
len += pusParams.appData->getSerializedSize();
|
||||
}
|
||||
spCreator.setDataLen(len);
|
||||
}
|
||||
|
||||
size_t PusTcCreator::getSerializedSize() const { return spCreator.getFullPacketLen(); }
|
||||
@ -91,14 +84,15 @@ SpacePacketParams &PusTcCreator::getSpParams() { return spCreator.getParams(); }
|
||||
|
||||
ReturnValue_t PusTcCreator::setRawUserData(const uint8_t *data, size_t len) {
|
||||
// TODO: Check length field?
|
||||
pusParams.dataWrapper.setRawData({data, len});
|
||||
pusParams.bufAdapter.setConstBuffer(data, len);
|
||||
pusParams.appData = &pusParams.bufAdapter;
|
||||
updateSpLengthField();
|
||||
return returnvalue::OK;
|
||||
}
|
||||
|
||||
ReturnValue_t PusTcCreator::setSerializableUserData(SerializeIF &serializable) {
|
||||
ReturnValue_t PusTcCreator::setSerializableUserData(const SerializeIF &serializable) {
|
||||
// TODO: Check length field?
|
||||
pusParams.dataWrapper.setSerializable(serializable);
|
||||
pusParams.appData = &serializable;
|
||||
updateSpLengthField();
|
||||
return returnvalue::OK;
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
#ifndef FSFW_TMTCPACKET_TCPACKETDESERIALIZER_H
|
||||
#define FSFW_TMTCPACKET_TCPACKETDESERIALIZER_H
|
||||
|
||||
#include "fsfw/serialize/SerialBufferAdapter.h"
|
||||
#include "fsfw/tmtcpacket/RedirectableDataPointerIF.h"
|
||||
#include "fsfw/tmtcpacket/ccsds/SpacePacketCreator.h"
|
||||
#include "fsfw/tmtcpacket/ccsds/SpacePacketIF.h"
|
||||
@ -11,11 +12,19 @@
|
||||
struct PusTcParams {
|
||||
PusTcParams(uint8_t service_, uint8_t subservice_) : service(service_), subservice(subservice_) {}
|
||||
|
||||
void setRawAppData(const uint8_t *data, size_t len) {
|
||||
bufAdapter.setConstBuffer(data, len);
|
||||
appData = &bufAdapter;
|
||||
}
|
||||
|
||||
void setSerializableAppData(const SerializeIF &serializable) { appData = &serializable; }
|
||||
|
||||
uint8_t service;
|
||||
uint8_t subservice;
|
||||
uint8_t ackFlags = ecss::ACK_ALL;
|
||||
uint16_t sourceId = 0;
|
||||
ecss::DataWrapper dataWrapper{};
|
||||
SerialBufferAdapter<uint8_t> bufAdapter;
|
||||
const SerializeIF *appData = nullptr;
|
||||
uint8_t pusVersion = ecss::PusVersion::PUS_C;
|
||||
};
|
||||
|
||||
@ -51,7 +60,7 @@ class PusTcCreator : public PusTcIF, public SerializeIF, public CustomUserDataIF
|
||||
[[nodiscard]] uint8_t getSubService() const override;
|
||||
[[nodiscard]] uint16_t getSourceId() const override;
|
||||
ReturnValue_t setRawUserData(const uint8_t *data, size_t len) override;
|
||||
ReturnValue_t setSerializableUserData(SerializeIF &serializable) override;
|
||||
ReturnValue_t setSerializableUserData(const SerializeIF &serializable) override;
|
||||
|
||||
// Load all big endian helpers into the class namespace
|
||||
using SerializeIF::serializeBe;
|
||||
|
@ -3,7 +3,7 @@
|
||||
#include <utility>
|
||||
|
||||
#include "fsfw/globalfunctions/CRC.h"
|
||||
#include "fsfw/timemanager/TimeStamperIF.h"
|
||||
#include "fsfw/timemanager/TimeWriterIF.h"
|
||||
|
||||
PusTmCreator::PusTmCreator(SpacePacketParams initSpParams, PusTmParams initPusParams)
|
||||
: pusParams(initPusParams), spCreator(std::move(initSpParams)) {
|
||||
@ -30,7 +30,7 @@ uint8_t PusTmCreator::getSubService() const { return pusParams.secHeader.subserv
|
||||
|
||||
PusTmParams& PusTmCreator::getParams() { return pusParams; }
|
||||
|
||||
void PusTmCreator::setTimeStamper(TimeStamperIF& timeStamper_) {
|
||||
void PusTmCreator::setTimeStamper(TimeWriterIF& timeStamper_) {
|
||||
pusParams.secHeader.timeStamper = &timeStamper_;
|
||||
updateSpLengthField();
|
||||
}
|
||||
@ -51,7 +51,6 @@ ReturnValue_t PusTmCreator::serialize(uint8_t** buffer, size_t* size, size_t max
|
||||
if (result != returnvalue::OK) {
|
||||
return result;
|
||||
}
|
||||
size_t userDataLen = pusParams.dataWrapper.getLength();
|
||||
**buffer =
|
||||
((pusParams.secHeader.pusVersion << 4) & 0xF0) | (pusParams.secHeader.scTimeRefStatus & 0x0F);
|
||||
*buffer += 1;
|
||||
@ -77,15 +76,8 @@ ReturnValue_t PusTmCreator::serialize(uint8_t** buffer, size_t* size, size_t max
|
||||
}
|
||||
}
|
||||
|
||||
if (pusParams.dataWrapper.type == ecss::DataTypes::RAW and
|
||||
pusParams.dataWrapper.dataUnion.raw.data != nullptr) {
|
||||
std::memcpy(*buffer, pusParams.dataWrapper.dataUnion.raw.data, userDataLen);
|
||||
*buffer += userDataLen;
|
||||
*size += userDataLen;
|
||||
} else if (pusParams.dataWrapper.type == ecss::DataTypes::SERIALIZABLE and
|
||||
pusParams.dataWrapper.dataUnion.serializable != nullptr) {
|
||||
result = pusParams.dataWrapper.dataUnion.serializable->serialize(buffer, size, maxSize,
|
||||
streamEndianness);
|
||||
if (pusParams.sourceData != nullptr) {
|
||||
result = pusParams.sourceData->serialize(buffer, size, maxSize, streamEndianness);
|
||||
if (result != returnvalue::OK) {
|
||||
return result;
|
||||
}
|
||||
@ -106,13 +98,15 @@ ReturnValue_t PusTmCreator::deSerialize(const uint8_t** buffer, size_t* size,
|
||||
return returnvalue::FAILED;
|
||||
}
|
||||
|
||||
TimeStamperIF* PusTmCreator::getTimestamper() const { return pusParams.secHeader.timeStamper; }
|
||||
TimeWriterIF* PusTmCreator::getTimestamper() const { return pusParams.secHeader.timeStamper; }
|
||||
|
||||
SpacePacketParams& PusTmCreator::getSpParams() { return spCreator.getParams(); }
|
||||
|
||||
void PusTmCreator::updateSpLengthField() {
|
||||
size_t headerLen = PusTmIF::MIN_SEC_HEADER_LEN + pusParams.dataWrapper.getLength() +
|
||||
sizeof(ecss::PusChecksumT) - 1;
|
||||
size_t headerLen = PusTmIF::MIN_SEC_HEADER_LEN + sizeof(ecss::PusChecksumT) - 1;
|
||||
if (pusParams.sourceData != nullptr) {
|
||||
headerLen += pusParams.sourceData->getSerializedSize();
|
||||
}
|
||||
if (pusParams.secHeader.timeStamper != nullptr) {
|
||||
headerLen += pusParams.secHeader.timeStamper->getSerializedSize();
|
||||
}
|
||||
@ -134,12 +128,17 @@ void PusTmCreator::setMessageTypeCounter(uint16_t messageTypeCounter) {
|
||||
void PusTmCreator::setDestId(uint16_t destId) { pusParams.secHeader.destId = destId; }
|
||||
|
||||
ReturnValue_t PusTmCreator::setRawUserData(const uint8_t* data, size_t len) {
|
||||
pusParams.dataWrapper.setRawData({data, len});
|
||||
if (data == nullptr or len == 0) {
|
||||
pusParams.sourceData = nullptr;
|
||||
} else {
|
||||
pusParams.adapter.setConstBuffer(data, len);
|
||||
pusParams.sourceData = &pusParams.adapter;
|
||||
}
|
||||
updateSpLengthField();
|
||||
return returnvalue::OK;
|
||||
}
|
||||
ReturnValue_t PusTmCreator::setSerializableUserData(SerializeIF& serializable) {
|
||||
pusParams.dataWrapper.setSerializable(serializable);
|
||||
ReturnValue_t PusTmCreator::setSerializableUserData(const SerializeIF& serializable) {
|
||||
pusParams.sourceData = &serializable;
|
||||
updateSpLengthField();
|
||||
return returnvalue::OK;
|
||||
}
|
||||
|
@ -2,17 +2,18 @@
|
||||
#define FSFW_TMTCPACKET_TMPACKETCREATOR_H
|
||||
|
||||
#include "PusTmIF.h"
|
||||
#include "fsfw/serialize/SerialBufferAdapter.h"
|
||||
#include "fsfw/tmtcpacket/ccsds/SpacePacketCreator.h"
|
||||
#include "fsfw/tmtcpacket/pus/CustomUserDataIF.h"
|
||||
|
||||
struct PusTmSecHeader {
|
||||
PusTmSecHeader() = default;
|
||||
PusTmSecHeader(uint8_t service, uint8_t subservice, TimeStamperIF* timeStamper)
|
||||
PusTmSecHeader(uint8_t service, uint8_t subservice, TimeWriterIF* timeStamper)
|
||||
: service(service), subservice(subservice), timeStamper(timeStamper) {}
|
||||
|
||||
uint8_t service = 0;
|
||||
uint8_t subservice = 0;
|
||||
TimeStamperIF* timeStamper = nullptr;
|
||||
TimeWriterIF* timeStamper = nullptr;
|
||||
uint8_t pusVersion = ecss::PusVersion::PUS_C;
|
||||
uint8_t scTimeRefStatus = 0;
|
||||
uint16_t messageTypeCounter = 0;
|
||||
@ -22,22 +23,28 @@ struct PusTmSecHeader {
|
||||
struct PusTmParams {
|
||||
PusTmParams() = default;
|
||||
explicit PusTmParams(PusTmSecHeader secHeader) : secHeader(secHeader){};
|
||||
PusTmParams(PusTmSecHeader secHeader, ecss::DataWrapper dataWrapper)
|
||||
: secHeader(secHeader), dataWrapper(dataWrapper) {}
|
||||
|
||||
PusTmParams(uint8_t service, uint8_t subservice, TimeStamperIF* timeStamper)
|
||||
PusTmParams(PusTmSecHeader secHeader, const SerializeIF& data)
|
||||
: secHeader(secHeader), sourceData(&data) {}
|
||||
PusTmParams(PusTmSecHeader secHeader, const uint8_t* data, size_t dataLen)
|
||||
: secHeader(secHeader), adapter(data, dataLen), sourceData(&adapter) {}
|
||||
PusTmParams(uint8_t service, uint8_t subservice, TimeWriterIF* timeStamper)
|
||||
: secHeader(service, subservice, timeStamper) {}
|
||||
|
||||
PusTmParams(uint8_t service, uint8_t subservice, TimeStamperIF* timeStamper,
|
||||
ecss::DataWrapper dataWrapper_)
|
||||
PusTmParams(uint8_t service, uint8_t subservice, TimeWriterIF* timeStamper,
|
||||
const SerializeIF& data_)
|
||||
: PusTmParams(service, subservice, timeStamper) {
|
||||
dataWrapper = dataWrapper_;
|
||||
sourceData = &data_;
|
||||
}
|
||||
|
||||
PusTmParams(uint8_t service, uint8_t subservice, TimeWriterIF* timeStamper, const uint8_t* data,
|
||||
size_t dataLen)
|
||||
: secHeader(service, subservice, timeStamper), adapter(data, dataLen), sourceData(&adapter) {}
|
||||
PusTmSecHeader secHeader;
|
||||
ecss::DataWrapper dataWrapper{};
|
||||
SerialBufferAdapter<uint8_t> adapter;
|
||||
const SerializeIF* sourceData = nullptr;
|
||||
};
|
||||
|
||||
class TimeStamperIF;
|
||||
class TimeWriterIF;
|
||||
|
||||
/**
|
||||
* This class provides a high-level interface to create PUS TM packets and then @serialize
|
||||
@ -55,7 +62,7 @@ class PusTmCreator : public SerializeIF, public PusTmIF, public CustomUserDataIF
|
||||
PusTmCreator(SpacePacketParams initSpParams, PusTmParams initPusParams);
|
||||
~PusTmCreator() override = default;
|
||||
|
||||
void setTimeStamper(TimeStamperIF& timeStamper);
|
||||
void setTimeStamper(TimeWriterIF& timeStamper);
|
||||
/**
|
||||
* This function disables the CRC16 calculation on serialization. This is useful to avoid
|
||||
* duplicate calculation if some lower level component needs to update fields like the sequence
|
||||
@ -85,9 +92,9 @@ class PusTmCreator : public SerializeIF, public PusTmIF, public CustomUserDataIF
|
||||
ReturnValue_t serialize(uint8_t** buffer, size_t* size, size_t maxSize,
|
||||
Endianness streamEndianness) const override;
|
||||
[[nodiscard]] size_t getSerializedSize() const override;
|
||||
[[nodiscard]] TimeStamperIF* getTimestamper() const;
|
||||
[[nodiscard]] TimeWriterIF* getTimestamper() const;
|
||||
ReturnValue_t setRawUserData(const uint8_t* data, size_t len) override;
|
||||
ReturnValue_t setSerializableUserData(SerializeIF& serializable) override;
|
||||
ReturnValue_t setSerializableUserData(const SerializeIF& serializable) override;
|
||||
|
||||
// Load all big endian (network endian) helpers into scope
|
||||
using SerializeIF::serializeBe;
|
||||
|
@ -4,7 +4,7 @@
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
|
||||
#include "fsfw/timemanager/TimeStamperIF.h"
|
||||
#include "fsfw/timemanager/TimeWriterIF.h"
|
||||
#include "fsfw/tmtcpacket/pus/PusIF.h"
|
||||
#include "fsfw/tmtcpacket/pus/defs.h"
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
#define FRAMEWORK_TMTCPACKET_PUS_TMPACKETMINIMAL_H_
|
||||
|
||||
#include "PusTmIF.h"
|
||||
#include "fsfw/returnvalues/HasReturnvaluesIF.h"
|
||||
#include "fsfw/returnvalues/returnvalue.h"
|
||||
#include "fsfw/tmtcpacket/ccsds/SpacePacketReader.h"
|
||||
#include "fsfw/tmtcpacket/pus/RawUserDataReaderIF.h"
|
||||
|
||||
|
@ -104,7 +104,7 @@ ReturnValue_t CommandingServiceBase::initialize() {
|
||||
// This avoids duplicate calculation of the CRC16
|
||||
tmStoreHelper.disableCrcCalculation();
|
||||
if (tmTimeStamper == nullptr) {
|
||||
tmTimeStamper = ObjectManager::instance()->get<TimeStamperIF>(objects::TIME_STAMPER);
|
||||
tmTimeStamper = ObjectManager::instance()->get<TimeWriterIF>(objects::TIME_STAMPER);
|
||||
if (tmTimeStamper == nullptr) {
|
||||
return ObjectManagerIF::CHILD_INIT_FAILED;
|
||||
}
|
||||
|
@ -272,7 +272,7 @@ class CommandingServiceBase : public SystemObject,
|
||||
MessageQueueIF* commandQueue = nullptr;
|
||||
MessageQueueIF* requestQueue = nullptr;
|
||||
|
||||
TimeStamperIF* tmTimeStamper = nullptr;
|
||||
TimeWriterIF* tmTimeStamper = nullptr;
|
||||
VerificationReporterIF* verificationReporter;
|
||||
|
||||
InternalErrorReporterIF* errReporter = nullptr;
|
||||
|
@ -178,7 +178,7 @@ ReturnValue_t PusServiceBase::initializeTmStoreHelper(TmStoreHelper& tmStoreHelp
|
||||
}
|
||||
|
||||
if (psbParams.timeStamper == nullptr) {
|
||||
auto timerStamper = ObjectManager::instance()->get<TimeStamperIF>(objects::TIME_STAMPER);
|
||||
auto timerStamper = ObjectManager::instance()->get<TimeWriterIF>(objects::TIME_STAMPER);
|
||||
if (timerStamper != nullptr) {
|
||||
tmStoreHelper.setTimeStamper(*timerStamper);
|
||||
}
|
||||
|
@ -65,7 +65,7 @@ struct PsbParams {
|
||||
* register itself at that object.
|
||||
*/
|
||||
PUSDistributorIF* pusDistributor = nullptr;
|
||||
TimeStamperIF* timeStamper = nullptr;
|
||||
TimeWriterIF* timeStamper = nullptr;
|
||||
};
|
||||
|
||||
namespace Factory {
|
||||
|
@ -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,10 @@
|
||||
*/
|
||||
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 +37,30 @@ 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_ */
|
||||
|
@ -5,7 +5,7 @@
|
||||
#include "fsfw/internalerror/InternalErrorReporterIF.h"
|
||||
#include "fsfw/ipc/MessageQueueIF.h"
|
||||
#include "fsfw/ipc/messageQueueDefinitions.h"
|
||||
#include "fsfw/returnvalues/HasReturnvaluesIF.h"
|
||||
#include "fsfw/returnvalues/returnvalue.h"
|
||||
|
||||
class TmSendHelper {
|
||||
public:
|
||||
|
@ -11,7 +11,7 @@ TmStoreHelper::TmStoreHelper(uint16_t defaultApid, StorageManagerIF& tmStore) :
|
||||
}
|
||||
|
||||
TmStoreHelper::TmStoreHelper(uint16_t defaultApid, StorageManagerIF& tmStore,
|
||||
TimeStamperIF& timeStamper)
|
||||
TimeWriterIF& timeStamper)
|
||||
: tmStore(&tmStore) {
|
||||
creator.setApid(defaultApid);
|
||||
creator.setTimeStamper(timeStamper);
|
||||
@ -59,7 +59,7 @@ ReturnValue_t TmStoreHelper::addPacketToStore() {
|
||||
SerializeIF::Endianness::NETWORK);
|
||||
}
|
||||
|
||||
void TmStoreHelper::setTimeStamper(TimeStamperIF& timeStamper_) {
|
||||
void TmStoreHelper::setTimeStamper(TimeWriterIF& timeStamper_) {
|
||||
creator.setTimeStamper(timeStamper_);
|
||||
}
|
||||
|
||||
@ -67,7 +67,7 @@ void TmStoreHelper::setApid(uint16_t apid) { creator.setApid(apid); }
|
||||
|
||||
PusTmCreator& TmStoreHelper::getCreatorRef() { return creator; }
|
||||
|
||||
TimeStamperIF* TmStoreHelper::getTimeStamper() const { return creator.getTimestamper(); }
|
||||
TimeWriterIF* TmStoreHelper::getTimeStamper() const { return creator.getTimestamper(); }
|
||||
|
||||
uint16_t TmStoreHelper::getApid() const { return creator.getApid(); }
|
||||
|
||||
|
@ -4,14 +4,14 @@
|
||||
#include "fsfw/internalerror/InternalErrorReporterIF.h"
|
||||
#include "fsfw/ipc/MessageQueueMessageIF.h"
|
||||
#include "fsfw/storagemanager/StorageManagerIF.h"
|
||||
#include "fsfw/timemanager/TimeStamperIF.h"
|
||||
#include "fsfw/timemanager/TimeWriterIF.h"
|
||||
#include "fsfw/tmtcpacket/pus/tm/PusTmCreator.h"
|
||||
|
||||
class TmStoreHelper {
|
||||
public:
|
||||
explicit TmStoreHelper(uint16_t defaultApid);
|
||||
TmStoreHelper(uint16_t defaultApid, StorageManagerIF& tmStore);
|
||||
TmStoreHelper(uint16_t defaultApid, StorageManagerIF& tmStore, TimeStamperIF& timeStamper);
|
||||
TmStoreHelper(uint16_t defaultApid, StorageManagerIF& tmStore, TimeWriterIF& timeStamper);
|
||||
|
||||
void disableCrcCalculation();
|
||||
[[nodiscard]] bool crcCalculationEnabled() const;
|
||||
@ -20,8 +20,8 @@ class TmStoreHelper {
|
||||
|
||||
PusTmCreator& getCreatorRef();
|
||||
|
||||
void setTimeStamper(TimeStamperIF& timeStamper);
|
||||
[[nodiscard]] TimeStamperIF* getTimeStamper() const;
|
||||
void setTimeStamper(TimeWriterIF& timeStamper);
|
||||
[[nodiscard]] TimeWriterIF* getTimeStamper() const;
|
||||
|
||||
[[nodiscard]] StorageManagerIF* getTmStore() const;
|
||||
void setTmStore(StorageManagerIF& store);
|
||||
|
@ -5,7 +5,7 @@
|
||||
|
||||
namespace tcverif {
|
||||
|
||||
enum VerifFlags : uint8_t {
|
||||
enum VerificationFlags : uint8_t {
|
||||
NONE = 0b0000,
|
||||
ACCEPTANCE = 0b0001,
|
||||
START = 0b0010,
|
||||
|
@ -1,7 +1,7 @@
|
||||
#ifndef FSFW_TMTCSERVICES_TCHELPERS_H
|
||||
#define FSFW_TMTCSERVICES_TCHELPERS_H
|
||||
|
||||
#include "fsfw/returnvalues/HasReturnvaluesIF.h"
|
||||
#include "fsfw/returnvalues/returnvalue.h"
|
||||
#include "fsfw/storagemanager/StorageManagerIF.h"
|
||||
#include "fsfw/tmtcpacket/pus/tc.h"
|
||||
|
||||
|
@ -10,48 +10,33 @@ namespace telemetry {
|
||||
class DataWithObjectIdPrefix : public SerializeIF {
|
||||
public:
|
||||
DataWithObjectIdPrefix(object_id_t objectId, const uint8_t* srcData, size_t srcDataLen)
|
||||
: objectId(objectId) {
|
||||
dataWrapper.type = ecss::DataTypes::RAW;
|
||||
dataWrapper.dataUnion.raw.data = srcData;
|
||||
dataWrapper.dataUnion.raw.len = srcDataLen;
|
||||
}
|
||||
: objectId(objectId), bufAdapter(srcData, srcDataLen), userData(&bufAdapter) {}
|
||||
|
||||
DataWithObjectIdPrefix(object_id_t objectId, SerializeIF& serializable) : objectId(objectId) {
|
||||
dataWrapper.type = ecss::DataTypes::SERIALIZABLE;
|
||||
dataWrapper.dataUnion.serializable = &serializable;
|
||||
}
|
||||
DataWithObjectIdPrefix(object_id_t objectId, const SerializeIF& serializable)
|
||||
: objectId(objectId), userData(&serializable) {}
|
||||
|
||||
ReturnValue_t serialize(uint8_t** buffer, size_t* size, size_t maxSize,
|
||||
Endianness streamEndianness) const override {
|
||||
if (*size + getSerializedSize() > maxSize) {
|
||||
return SerializeIF::BUFFER_TOO_SHORT;
|
||||
}
|
||||
if (dataWrapper.type != ecss::DataTypes::RAW) {
|
||||
if ((dataWrapper.dataUnion.raw.data == nullptr) and (dataWrapper.dataUnion.raw.len > 0)) {
|
||||
return returnvalue::FAILED;
|
||||
}
|
||||
} else if (dataWrapper.type == ecss::DataTypes::SERIALIZABLE) {
|
||||
if (dataWrapper.dataUnion.serializable == nullptr) {
|
||||
return returnvalue::FAILED;
|
||||
}
|
||||
}
|
||||
ReturnValue_t result =
|
||||
SerializeAdapter::serialize(&objectId, buffer, size, maxSize, streamEndianness);
|
||||
if (result != returnvalue::OK) {
|
||||
return result;
|
||||
}
|
||||
if (dataWrapper.type != ecss::DataTypes::RAW) {
|
||||
std::memcpy(*buffer, dataWrapper.dataUnion.raw.data, dataWrapper.dataUnion.raw.len);
|
||||
*buffer += dataWrapper.dataUnion.raw.len;
|
||||
*size += dataWrapper.dataUnion.raw.len;
|
||||
} else {
|
||||
return dataWrapper.dataUnion.serializable->serialize(buffer, size, maxSize, streamEndianness);
|
||||
if (userData != nullptr) {
|
||||
return userData->serialize(buffer, size, maxSize, streamEndianness);
|
||||
}
|
||||
return returnvalue::OK;
|
||||
}
|
||||
|
||||
[[nodiscard]] size_t getSerializedSize() const override {
|
||||
return sizeof(objectId) + dataWrapper.getLength();
|
||||
size_t len = 0;
|
||||
if (userData != nullptr) {
|
||||
len += userData->getSerializedSize();
|
||||
}
|
||||
return len;
|
||||
}
|
||||
|
||||
ReturnValue_t deSerialize(const uint8_t** buffer, size_t* size,
|
||||
@ -63,7 +48,8 @@ class DataWithObjectIdPrefix : public SerializeIF {
|
||||
|
||||
private:
|
||||
object_id_t objectId;
|
||||
ecss::DataWrapper dataWrapper{};
|
||||
SerialBufferAdapter<uint8_t> bufAdapter;
|
||||
const SerializeIF* userData = nullptr;
|
||||
};
|
||||
|
||||
} // namespace telemetry
|
||||
|
@ -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)
|
||||
|
@ -4,9 +4,9 @@
|
||||
#include <array>
|
||||
|
||||
#include "fsfw/timemanager/TimeReaderIF.h"
|
||||
#include "fsfw/timemanager/TimeStamperIF.h"
|
||||
#include "fsfw/timemanager/TimeWriterIF.h"
|
||||
|
||||
class CdsShortTimestamperMock : public TimeStamperIF, public TimeReaderIF {
|
||||
class CdsShortTimestamperMock : public TimeWriterIF, public TimeReaderIF {
|
||||
public:
|
||||
unsigned int serializeCallCount = 0;
|
||||
unsigned int deserializeCallCount = 0;
|
||||
@ -61,7 +61,6 @@ class CdsShortTimestamperMock : public TimeStamperIF, public TimeReaderIF {
|
||||
}
|
||||
|
||||
[[nodiscard]] size_t getTimestampSize() const override { return getSerializedSize(); }
|
||||
ReturnValue_t addTimeStamp(uint8_t *buffer, uint8_t maxSize) override { return 0; }
|
||||
|
||||
void reset() {
|
||||
serializeCallCount = 0;
|
||||
@ -75,9 +74,6 @@ class CdsShortTimestamperMock : public TimeStamperIF, public TimeReaderIF {
|
||||
serFailRetval = returnvalue::FAILED;
|
||||
}
|
||||
|
||||
ReturnValue_t readTimeStamp(const uint8_t *buffer, size_t maxSize) override {
|
||||
return deSerialize(&buffer, &maxSize, SerializeIF::Endianness::NETWORK);
|
||||
}
|
||||
timeval &getTime() override { return dummyTime; }
|
||||
|
||||
private:
|
||||
|
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...
|
||||
}
|
@ -64,7 +64,8 @@ TEST_CASE("Serial Buffer Adapter", "[single-file]") {
|
||||
SECTION("Test set buffer function") {
|
||||
SerialBufferAdapter<uint8_t> tv_serial_buffer_adapter_loc =
|
||||
SerialBufferAdapter<uint8_t>((uint8_t*)nullptr, 0, true);
|
||||
tv_serial_buffer_adapter_loc.setBuffer(test_serial_buffer.data(), test_serial_buffer.size());
|
||||
tv_serial_buffer_adapter_loc.setConstBuffer(test_serial_buffer.data(),
|
||||
test_serial_buffer.size());
|
||||
serialized_size = 0;
|
||||
arrayPtr = testArray.data();
|
||||
SerializeAdapter::serialize(&test_value_bool, &arrayPtr, &serialized_size, testArray.size(),
|
||||
|
@ -71,7 +71,7 @@ TEST_CASE("PUS TC Creator", "[pus-tc-creator]") {
|
||||
SECTION("Test with Application Data Raw") {
|
||||
auto& params = creator.getPusParams();
|
||||
std::array<uint8_t, 3> data{1, 2, 3};
|
||||
params.dataWrapper.setRawData({data.data(), data.size()});
|
||||
params.setRawAppData(data.data(), data.size());
|
||||
// To get correct size information, the SP length field needs to be updated automatically
|
||||
REQUIRE(creator.getSerializedSize() == 13);
|
||||
creator.updateSpLengthField();
|
||||
|
@ -44,9 +44,7 @@ TEST_CASE("TM Store And Send Helper", "[tm-store-send-helper]") {
|
||||
REQUIRE(creator.getSubService() == 2);
|
||||
REQUIRE(creator.getService() == 17);
|
||||
auto& params = creator.getParams();
|
||||
REQUIRE(params.dataWrapper.type == ecss::DataTypes::RAW);
|
||||
REQUIRE(params.dataWrapper.dataUnion.raw.data == nullptr);
|
||||
REQUIRE(params.dataWrapper.dataUnion.raw.len == 0);
|
||||
REQUIRE(params.sourceData == nullptr);
|
||||
REQUIRE(tmHelper.sendCounter == 0);
|
||||
REQUIRE(tmHelper.storeAndSendTmPacket() == returnvalue::OK);
|
||||
REQUIRE(tmHelper.sendCounter == 1);
|
||||
@ -65,9 +63,9 @@ TEST_CASE("TM Store And Send Helper", "[tm-store-send-helper]") {
|
||||
REQUIRE(tmHelper.prepareTmPacket(2, data.data(), data.size()) == returnvalue::OK);
|
||||
auto& creator = storeHelper.getCreatorRef();
|
||||
auto& params = creator.getParams();
|
||||
REQUIRE(params.dataWrapper.type == ecss::DataTypes::RAW);
|
||||
REQUIRE(params.dataWrapper.dataUnion.raw.data == data.data());
|
||||
REQUIRE(params.dataWrapper.dataUnion.raw.len == data.size());
|
||||
REQUIRE(params.sourceData != nullptr);
|
||||
REQUIRE(params.sourceData->getSerializedSize() == data.size());
|
||||
REQUIRE(params.adapter.getConstBuffer() == data.data());
|
||||
}
|
||||
|
||||
SECTION("Serializable Helper") {
|
||||
@ -75,8 +73,7 @@ TEST_CASE("TM Store And Send Helper", "[tm-store-send-helper]") {
|
||||
REQUIRE(tmHelper.prepareTmPacket(2, simpleSer) == returnvalue::OK);
|
||||
auto& creator = storeHelper.getCreatorRef();
|
||||
auto& params = creator.getParams();
|
||||
REQUIRE(params.dataWrapper.type == ecss::DataTypes::SERIALIZABLE);
|
||||
REQUIRE(params.dataWrapper.dataUnion.serializable == &simpleSer);
|
||||
REQUIRE(params.sourceData == &simpleSer);
|
||||
}
|
||||
|
||||
SECTION("Object ID prefix Helper") {
|
||||
@ -86,8 +83,7 @@ TEST_CASE("TM Store And Send Helper", "[tm-store-send-helper]") {
|
||||
REQUIRE(tmHelper.prepareTmPacket(2, dataWithObjId) == returnvalue::OK);
|
||||
auto& creator = storeHelper.getCreatorRef();
|
||||
auto& params = creator.getParams();
|
||||
REQUIRE(params.dataWrapper.type == ecss::DataTypes::SERIALIZABLE);
|
||||
REQUIRE(params.dataWrapper.dataUnion.serializable == &dataWithObjId);
|
||||
REQUIRE(params.sourceData == &dataWithObjId);
|
||||
}
|
||||
|
||||
// TODO: Error handling
|
||||
|
Reference in New Issue
Block a user