linux working
This commit is contained in:
@ -0,0 +1,2 @@
|
||||
CXXSRC += $(wildcard $(CURRENTPATH)/utility/*.cpp)
|
||||
CSRC += $(wildcard $(CURRENTPATH)/utility/*.c)
|
23
mission/utility/TimeStamper.cpp
Normal file
23
mission/utility/TimeStamper.cpp
Normal file
@ -0,0 +1,23 @@
|
||||
#include <fsfw/timemanager/Clock.h>
|
||||
#include <mission/utility/TimeStamper.h>
|
||||
#include <cstring>
|
||||
|
||||
TimeStamper::TimeStamper(object_id_t objectId): SystemObject(objectId) {}
|
||||
|
||||
|
||||
ReturnValue_t TimeStamper::addTimeStamp(uint8_t* buffer,
|
||||
const uint8_t maxSize) {
|
||||
if(maxSize < TimeStamperIF::MISSION_TIMESTAMP_SIZE) {
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
}
|
||||
|
||||
timeval now;
|
||||
Clock::getClock_timeval(&now);
|
||||
CCSDSTime::CDS_short cds;
|
||||
ReturnValue_t result = CCSDSTime::convertToCcsds(&cds,&now);
|
||||
if(result != HasReturnvaluesIF::RETURN_OK){
|
||||
return result;
|
||||
}
|
||||
std::memcpy(buffer,&cds,sizeof(cds));
|
||||
return result;
|
||||
}
|
18
mission/utility/TimeStamper.h
Normal file
18
mission/utility/TimeStamper.h
Normal file
@ -0,0 +1,18 @@
|
||||
#ifndef MISSION_UTILITY_TIMESTAMPER_H_
|
||||
#define MISSION_UTILITY_TIMESTAMPER_H_
|
||||
|
||||
#include <fsfw/timemanager/TimeStamperIF.h>
|
||||
#include <fsfw/timemanager/CCSDSTime.h>
|
||||
#include <fsfw/objectmanager/SystemObject.h>
|
||||
|
||||
/**
|
||||
* @brief
|
||||
* @ingroup utility
|
||||
*/
|
||||
class TimeStamper: public TimeStamperIF, public SystemObject {
|
||||
public:
|
||||
TimeStamper(object_id_t objectId);
|
||||
virtual ReturnValue_t addTimeStamp(uint8_t* buffer, const uint8_t maxSize);
|
||||
};
|
||||
|
||||
#endif /* MISSION_UTILITY_TIMESTAMPER_H_ */
|
112
mission/utility/TmFunnel.cpp
Normal file
112
mission/utility/TmFunnel.cpp
Normal file
@ -0,0 +1,112 @@
|
||||
#include <mission/utility/TmFunnel.h>
|
||||
|
||||
#include <fsfw/ipc/QueueFactory.h>
|
||||
#include <fsfw/tmtcpacket/pus/TmPacketBase.h>
|
||||
#include <fsfw/tmtcpacket/pus/TmPacketStored.h>
|
||||
#include <fsfw/serviceinterface/ServiceInterfaceStream.h>
|
||||
|
||||
object_id_t TmFunnel::downlinkDestination = objects::NO_OBJECT;
|
||||
object_id_t TmFunnel::storageDestination = objects::NO_OBJECT;
|
||||
|
||||
TmFunnel::TmFunnel(object_id_t objectId_): SystemObject(objectId_),
|
||||
sourceSequenceCount(0), storageTargetSet(false) {
|
||||
tmQueue = QueueFactory::instance()->createMessageQueue(messageDepth,
|
||||
MessageQueueMessage::MAX_MESSAGE_SIZE);
|
||||
storageQueue = QueueFactory::instance()->createMessageQueue(messageDepth,
|
||||
MessageQueueMessage::MAX_MESSAGE_SIZE);
|
||||
}
|
||||
|
||||
TmFunnel::~TmFunnel() {
|
||||
}
|
||||
|
||||
MessageQueueId_t TmFunnel::getReportReceptionQueue(uint8_t virtualChannel) {
|
||||
return tmQueue->getId();
|
||||
}
|
||||
|
||||
ReturnValue_t TmFunnel::performOperation(uint8_t operationCode) {
|
||||
TmTcMessage currentMessage;
|
||||
ReturnValue_t status = tmQueue->receiveMessage(¤tMessage);
|
||||
while(status == HasReturnvaluesIF::RETURN_OK)
|
||||
{
|
||||
status = handlePacket(¤tMessage);
|
||||
if(status != HasReturnvaluesIF::RETURN_OK){
|
||||
break;
|
||||
}
|
||||
status = tmQueue->receiveMessage(¤tMessage);
|
||||
}
|
||||
|
||||
if (status == MessageQueueIF::EMPTY) {
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
else {
|
||||
return status;
|
||||
}
|
||||
}
|
||||
|
||||
ReturnValue_t TmFunnel::handlePacket(TmTcMessage* message) {
|
||||
uint8_t* packetData = nullptr;
|
||||
size_t size = 0;
|
||||
ReturnValue_t result = tmPool->modifyData(message->getStorageId(),
|
||||
&packetData, &size);
|
||||
if(result != HasReturnvaluesIF::RETURN_OK){
|
||||
return result;
|
||||
}
|
||||
TmPacketBase packet(packetData);
|
||||
packet.setPacketSequenceCount(this->sourceSequenceCount);
|
||||
sourceSequenceCount++;
|
||||
sourceSequenceCount = sourceSequenceCount %
|
||||
SpacePacketBase::LIMIT_SEQUENCE_COUNT;
|
||||
packet.setErrorControl();
|
||||
|
||||
result = tmQueue->sendToDefault(message);
|
||||
if(result != HasReturnvaluesIF::RETURN_OK){
|
||||
tmPool->deleteData(message->getStorageId());
|
||||
sif::error << "TmFunnel::handlePacket: Error sending to downlink "
|
||||
"handler" << std::endl;
|
||||
return result;
|
||||
}
|
||||
|
||||
if(storageTargetSet) {
|
||||
result = storageQueue->sendToDefault(message);
|
||||
if(result != HasReturnvaluesIF::RETURN_OK){
|
||||
tmPool->deleteData(message->getStorageId());
|
||||
sif::error << "TmFunnel::handlePacket: Error sending to storage "
|
||||
"handler" << std::endl;
|
||||
return result;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
ReturnValue_t TmFunnel::initialize() {
|
||||
|
||||
tmPool = objectManager->get<StorageManagerIF>(objects::TM_STORE);
|
||||
if(tmPool == nullptr) {
|
||||
sif::error << "TmFunnel::initialize: TM store not set."
|
||||
<< std::endl;
|
||||
sif::error << "Make sure the tm store is set up properly"
|
||||
" and implements StorageManagerIF" << std::endl;
|
||||
return ObjectManagerIF::CHILD_INIT_FAILED;
|
||||
}
|
||||
|
||||
AcceptsTelemetryIF* tmTarget =
|
||||
objectManager->get<AcceptsTelemetryIF>(downlinkDestination);
|
||||
if(tmTarget == nullptr){
|
||||
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" << std::endl;
|
||||
return ObjectManagerIF::CHILD_INIT_FAILED;
|
||||
}
|
||||
tmQueue->setDefaultDestination(tmTarget->getReportReceptionQueue());
|
||||
|
||||
AcceptsTelemetryIF* storageTarget =
|
||||
objectManager->get<AcceptsTelemetryIF>(storageDestination);
|
||||
if(storageTarget != nullptr) {
|
||||
storageTargetSet = true;
|
||||
storageQueue->setDefaultDestination(
|
||||
storageTarget->getReportReceptionQueue());
|
||||
}
|
||||
|
||||
return SystemObject::initialize();
|
||||
}
|
52
mission/utility/TmFunnel.h
Normal file
52
mission/utility/TmFunnel.h
Normal file
@ -0,0 +1,52 @@
|
||||
#ifndef MISSION_UTILITY_TMFUNNEL_H_
|
||||
#define MISSION_UTILITY_TMFUNNEL_H_
|
||||
|
||||
#include <fsfw/objectmanager/SystemObject.h>
|
||||
#include <fsfw/tasks/ExecutableObjectIF.h>
|
||||
#include <fsfw/tmtcservices/AcceptsTelemetryIF.h>
|
||||
#include <fsfw/ipc/MessageQueueIF.h>
|
||||
#include <fsfw/tmtcservices/TmTcMessage.h>
|
||||
|
||||
namespace Factory{
|
||||
void setStaticFrameworkObjectIds();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief TM Recipient.
|
||||
* @details
|
||||
* Main telemetry receiver. All generated telemetry is funneled into
|
||||
* this object.
|
||||
* @ingroup utility
|
||||
* @author J. Meier
|
||||
*/
|
||||
class TmFunnel: public AcceptsTelemetryIF,
|
||||
public ExecutableObjectIF,
|
||||
public SystemObject {
|
||||
friend void (Factory::setStaticFrameworkObjectIds)();
|
||||
public:
|
||||
TmFunnel(object_id_t objectId);
|
||||
virtual ~TmFunnel();
|
||||
|
||||
virtual MessageQueueId_t getReportReceptionQueue(
|
||||
uint8_t virtualChannel = 0) override;
|
||||
virtual ReturnValue_t performOperation(uint8_t operationCode = 0) override;
|
||||
virtual ReturnValue_t initialize() override;
|
||||
|
||||
protected:
|
||||
static object_id_t downlinkDestination;
|
||||
static object_id_t storageDestination;
|
||||
|
||||
private:
|
||||
|
||||
uint16_t sourceSequenceCount;
|
||||
bool storageTargetSet;
|
||||
MessageQueueIF* tmQueue = nullptr;
|
||||
MessageQueueIF* storageQueue = nullptr;
|
||||
|
||||
StorageManagerIF* tmPool = nullptr;
|
||||
uint32_t messageDepth = 10;
|
||||
|
||||
ReturnValue_t handlePacket(TmTcMessage* message);
|
||||
};
|
||||
|
||||
#endif /* MISSION_UTILITY_TMFUNNEL_H_ */
|
Reference in New Issue
Block a user