This commit is contained in:
2022-08-08 12:32:06 +02:00
parent d2b15ee4fa
commit 5792aff5e3
32 changed files with 476 additions and 657 deletions

View File

@ -9,7 +9,7 @@
#define MISSION_UTILITY_PUSPACKETCREATOR_H_
class PusPacketCreator {
public:
public:
static void createPusPacketAndPrint();
};

View File

@ -8,15 +8,14 @@ namespace task {
void printInitError(const char *objName, object_id_t objectId) {
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "InitMission: Adding object " << objName << "(" << std::setw(8)
<< std::setfill('0') << std::hex << objectId << std::dec
<< ") failed." << std::endl;
sif::error << "InitMission: Adding object " << objName << "(" << std::setw(8) << std::setfill('0')
<< std::hex << objectId << std::dec << ") failed." << std::endl;
#else
sif::printError("InitMission: Adding object %s (0x%08x) failed.\n", objName,
static_cast<unsigned int>(objectId));
#endif
}
} // namespace task
} // namespace task
#endif /* MISSION_UTILITY_TASKCREATION_H_ */

View File

@ -1,18 +1,19 @@
#include "TmFunnel.h"
#include <fsfw/ipc/QueueFactory.h>
#include "fsfw/tmtcpacket/pus/tm.h"
#include <fsfw/objectmanager/ObjectManager.h>
#include <fsfw/serviceinterface/ServiceInterface.h>
#include <fsfw/tmtcpacket/pus/tm.h>
#include "fsfw/tmtcpacket/pus/tm.h"
object_id_t TmFunnel::downlinkDestination = objects::NO_OBJECT;
object_id_t TmFunnel::storageDestination = objects::NO_OBJECT;
TmFunnel::TmFunnel(TimeReaderIF& timeReader, object_id_t objectId, uint32_t messageDepth)
TmFunnel::TmFunnel(TimeReaderIF &timeReader, object_id_t objectId, uint32_t messageDepth)
: SystemObject(objectId), timeReader(timeReader), messageDepth(messageDepth) {
tmQueue = QueueFactory::instance()->createMessageQueue(
messageDepth, MessageQueueMessage::MAX_MESSAGE_SIZE);
tmQueue = QueueFactory::instance()->createMessageQueue(messageDepth,
MessageQueueMessage::MAX_MESSAGE_SIZE);
storageQueue = QueueFactory::instance()->createMessageQueue(
messageDepth, MessageQueueMessage::MAX_MESSAGE_SIZE);
}
@ -45,14 +46,13 @@ ReturnValue_t TmFunnel::performOperation(uint8_t operationCode) {
ReturnValue_t TmFunnel::handlePacket(TmTcMessage *message) {
uint8_t *packetData = nullptr;
size_t size = 0;
ReturnValue_t result =
tmPool->modifyData(message->getStorageId(), &packetData, &size);
ReturnValue_t result = tmPool->modifyData(message->getStorageId(), &packetData, &size);
if (result != HasReturnvaluesIF::RETURN_OK) {
return result;
}
PusTmZeroCopyWriter packet(timeReader, packetData, size);
result = packet.parseDataWithoutCrcCheck();
if(result != HasReturnvaluesIF::RETURN_OK) {
if (result != HasReturnvaluesIF::RETURN_OK) {
return result;
}
packet.setSequenceCount(sourceSequenceCount++);
@ -73,8 +73,7 @@ ReturnValue_t TmFunnel::handlePacket(TmTcMessage *message) {
if (result != HasReturnvaluesIF::RETURN_OK) {
tmPool->deleteData(message->getStorageId());
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "TmFunnel::handlePacket: Error sending to storage handler"
<< std::endl;
sif::error << "TmFunnel::handlePacket: Error sending to storage handler" << std::endl;
#endif
return result;
}
@ -98,8 +97,7 @@ ReturnValue_t TmFunnel::initialize() {
ObjectManager::instance()->get<AcceptsTelemetryIF>(downlinkDestination);
if (tmTarget == nullptr) {
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "TmFunnel::initialize: Downlink Destination not set."
<< std::endl;
sif::error << "TmFunnel::initialize: Downlink Destination not set." << std::endl;
sif::error << "Make sure the downlink destination object is set up "
"properly and implements "
"AcceptsTelemetryIF"
@ -114,12 +112,12 @@ ReturnValue_t TmFunnel::initialize() {
return SystemObject::initialize();
}
AcceptsTelemetryIF *storageTarget =
ObjectManager::instance()->get<AcceptsTelemetryIF>(storageDestination);
auto *storageTarget = ObjectManager::instance()->get<AcceptsTelemetryIF>(storageDestination);
if (storageTarget != nullptr) {
storageQueue->setDefaultDestination(
storageTarget->getReportReceptionQueue());
storageQueue->setDefaultDestination(storageTarget->getReportReceptionQueue());
}
return SystemObject::initialize();
}
const char *TmFunnel::getName() const { return "TM Funnel"; }

View File

@ -21,26 +21,25 @@ void setStaticFrameworkObjectIds();
* @ingroup utility
* @author J. Meier
*/
class TmFunnel : public AcceptsTelemetryIF,
public ExecutableObjectIF,
public SystemObject {
class TmFunnel : public AcceptsTelemetryIF, public ExecutableObjectIF, public SystemObject {
friend void(Factory::setStaticFrameworkObjectIds)();
public:
explicit TmFunnel(TimeReaderIF& timeReader, object_id_t objectId, uint32_t messageDepth = 20);
public:
explicit TmFunnel(TimeReaderIF &timeReader, object_id_t objectId, uint32_t messageDepth = 20);
const char *getName() const override;
~TmFunnel() override;
MessageQueueId_t getReportReceptionQueue(uint8_t virtualChannel) override;
ReturnValue_t performOperation(uint8_t operationCode) override;
ReturnValue_t initialize() override;
protected:
protected:
static object_id_t downlinkDestination;
static object_id_t storageDestination;
private:
private:
uint16_t sourceSequenceCount = 0;
TimeReaderIF& timeReader;
TimeReaderIF &timeReader;
MessageQueueIF *tmQueue = nullptr;
MessageQueueIF *storageQueue = nullptr;

View File

@ -39,19 +39,19 @@
#define CONV_STR2DEC_4(str, i) (CONV_STR2DEC_3(str, i) * 10 + str[i + 3] - '0')
// Custom "glue logic" to convert the month name to a usable number
#define GET_MONTH(str, i) \
(str[i] == 'J' && str[i + 1] == 'a' && str[i + 2] == 'n' ? 1 \
: str[i] == 'F' && str[i + 1] == 'e' && str[i + 2] == 'b' ? 2 \
: str[i] == 'M' && str[i + 1] == 'a' && str[i + 2] == 'r' ? 3 \
: str[i] == 'A' && str[i + 1] == 'p' && str[i + 2] == 'r' ? 4 \
: str[i] == 'M' && str[i + 1] == 'a' && str[i + 2] == 'y' ? 5 \
: str[i] == 'J' && str[i + 1] == 'u' && str[i + 2] == 'n' ? 6 \
: str[i] == 'J' && str[i + 1] == 'u' && str[i + 2] == 'l' ? 7 \
: str[i] == 'A' && str[i + 1] == 'u' && str[i + 2] == 'g' ? 8 \
: str[i] == 'S' && str[i + 1] == 'e' && str[i + 2] == 'p' ? 9 \
: str[i] == 'O' && str[i + 1] == 'c' && str[i + 2] == 't' ? 10 \
: str[i] == 'N' && str[i + 1] == 'o' && str[i + 2] == 'v' ? 11 \
: str[i] == 'D' && str[i + 1] == 'e' && str[i + 2] == 'c' ? 12 \
#define GET_MONTH(str, i) \
(str[i] == 'J' && str[i + 1] == 'a' && str[i + 2] == 'n' ? 1 \
: str[i] == 'F' && str[i + 1] == 'e' && str[i + 2] == 'b' ? 2 \
: str[i] == 'M' && str[i + 1] == 'a' && str[i + 2] == 'r' ? 3 \
: str[i] == 'A' && str[i + 1] == 'p' && str[i + 2] == 'r' ? 4 \
: str[i] == 'M' && str[i + 1] == 'a' && str[i + 2] == 'y' ? 5 \
: str[i] == 'J' && str[i + 1] == 'u' && str[i + 2] == 'n' ? 6 \
: str[i] == 'J' && str[i + 1] == 'u' && str[i + 2] == 'l' ? 7 \
: str[i] == 'A' && str[i + 1] == 'u' && str[i + 2] == 'g' ? 8 \
: str[i] == 'S' && str[i + 1] == 'e' && str[i + 2] == 'p' ? 9 \
: str[i] == 'O' && str[i + 1] == 'c' && str[i + 2] == 't' ? 10 \
: str[i] == 'N' && str[i + 1] == 'o' && str[i + 2] == 'v' ? 11 \
: str[i] == 'D' && str[i + 1] == 'e' && str[i + 2] == 'c' ? 12 \
: 0)
// extract the information from the time string given by __TIME__ and __DATE__
@ -63,37 +63,30 @@
#define __TIME_YEARS__ CONV_STR2DEC_4(__DATE__, 7)
// Days in February
#define _UNIX_TIMESTAMP_FDAY(year) \
(((year) % 400) == 0UL \
? 29UL \
: (((year) % 100) == 0UL ? 28UL : (((year) % 4) == 0UL ? 29UL : 28UL)))
#define _UNIX_TIMESTAMP_FDAY(year) \
(((year) % 400) == 0UL ? 29UL \
: (((year) % 100) == 0UL ? 28UL : (((year) % 4) == 0UL ? 29UL : 28UL)))
// Days in the year
#define _UNIX_TIMESTAMP_YDAY(year, month, day) \
(/* January */ day /* February */ + (month >= 2 ? 31UL : 0UL) /* March */ + \
(month >= 3 ? _UNIX_TIMESTAMP_FDAY(year) : 0UL) /* April */ + \
(month >= 4 ? 31UL : 0UL) /* May */ + \
(month >= 5 ? 30UL : 0UL) /* June */ + \
(month >= 6 ? 31UL : 0UL) /* July */ + \
(month >= 7 ? 30UL : 0UL) /* August */ + \
(month >= 8 ? 31UL : 0UL) /* September */ + \
(month >= 9 ? 31UL : 0UL) /* October */ + \
(month >= 10 ? 30UL : 0UL) /* November */ + \
(month >= 11 ? 31UL : 0UL) /* December */ + (month >= 12 ? 30UL : 0UL))
#define _UNIX_TIMESTAMP_YDAY(year, month, day) \
(/* January */ day /* February */ + (month >= 2 ? 31UL : 0UL) /* March */ + \
(month >= 3 ? _UNIX_TIMESTAMP_FDAY(year) : 0UL) /* April */ + \
(month >= 4 ? 31UL : 0UL) /* May */ + (month >= 5 ? 30UL : 0UL) /* June */ + \
(month >= 6 ? 31UL : 0UL) /* July */ + (month >= 7 ? 30UL : 0UL) /* August */ + \
(month >= 8 ? 31UL : 0UL) /* September */ + (month >= 9 ? 31UL : 0UL) /* October */ + \
(month >= 10 ? 30UL : 0UL) /* November */ + (month >= 11 ? 31UL : 0UL) /* December */ + \
(month >= 12 ? 30UL : 0UL))
// get the UNIX timestamp from a digits representation
#define _UNIX_TIMESTAMP(year, month, day, hour, minute, second) \
(/* time */ second + minute * SEC_PER_MIN + hour * SEC_PER_HOUR + \
/* year day (month + day) */ (_UNIX_TIMESTAMP_YDAY(year, month, day) - 1) * \
SEC_PER_DAY + \
/* year */ (year - 1970UL) * SEC_PER_YEAR + \
((year - 1969UL) / 4UL) * SEC_PER_DAY - \
((year - 1901UL) / 100UL) * SEC_PER_DAY + \
((year - 1601UL) / 400UL) * SEC_PER_DAY)
#define _UNIX_TIMESTAMP(year, month, day, hour, minute, second) \
(/* time */ second + minute * SEC_PER_MIN + hour * SEC_PER_HOUR + \
/* year day (month + day) */ (_UNIX_TIMESTAMP_YDAY(year, month, day) - 1) * SEC_PER_DAY + \
/* year */ (year - 1970UL) * SEC_PER_YEAR + ((year - 1969UL) / 4UL) * SEC_PER_DAY - \
((year - 1901UL) / 100UL) * SEC_PER_DAY + ((year - 1601UL) / 400UL) * SEC_PER_DAY)
// the UNIX timestamp
#define UNIX_TIMESTAMP \
(_UNIX_TIMESTAMP(__TIME_YEARS__, __TIME_MONTH__, __TIME_DAYS__, \
__TIME_HOURS__, __TIME_MINUTES__, __TIME_SECONDS__))
#define UNIX_TIMESTAMP \
(_UNIX_TIMESTAMP(__TIME_YEARS__, __TIME_MONTH__, __TIME_DAYS__, __TIME_HOURS__, \
__TIME_MINUTES__, __TIME_SECONDS__))
#endif

View File

@ -10,11 +10,9 @@ void utility::commonInitPrint(const char *const os, const char *const board) {
}
#if FSFW_CPP_OSTREAM_ENABLED == 1
std::cout << "-- FSFW Example (" << os << ") v" << FSFW_EXAMPLE_VERSION << "."
<< FSFW_EXAMPLE_SUBVERSION << "." << FSFW_EXAMPLE_REVISION << " --"
<< std::endl;
<< FSFW_EXAMPLE_SUBVERSION << "." << FSFW_EXAMPLE_REVISION << " --" << std::endl;
std::cout << "-- Compiled for " << board << " --" << std::endl;
std::cout << "-- Compiled on " << __DATE__ << " " << __TIME__ << " --"
<< std::endl;
std::cout << "-- Compiled on " << __DATE__ << " " << __TIME__ << " --" << std::endl;
#else
printf("\n\r-- FSFW Example (%s) v%d.%d.%d --\n", os, FSFW_EXAMPLE_VERSION,
FSFW_EXAMPLE_SUBVERSION, FSFW_EXAMPLE_REVISION);