Merge branch 'mueller/pus-15-tm-storage' into develop
This commit is contained in:
commit
bdfe31dba4
@ -15,6 +15,7 @@ enum framework_objects : object_id_t {
|
|||||||
PUS_SERVICE_8_FUNCTION_MGMT = 0x53000008,
|
PUS_SERVICE_8_FUNCTION_MGMT = 0x53000008,
|
||||||
PUS_SERVICE_9_TIME_MGMT = 0x53000009,
|
PUS_SERVICE_9_TIME_MGMT = 0x53000009,
|
||||||
PUS_SERVICE_11_TC_SCHEDULER = 0x53000011,
|
PUS_SERVICE_11_TC_SCHEDULER = 0x53000011,
|
||||||
|
PUS_SERVICE_15_TM_STORAGE = 0x53000015,
|
||||||
PUS_SERVICE_17_TEST = 0x53000017,
|
PUS_SERVICE_17_TEST = 0x53000017,
|
||||||
PUS_SERVICE_20_PARAMETERS = 0x53000020,
|
PUS_SERVICE_20_PARAMETERS = 0x53000020,
|
||||||
PUS_SERVICE_200_MODE_MGMT = 0x53000200,
|
PUS_SERVICE_200_MODE_MGMT = 0x53000200,
|
||||||
|
@ -246,6 +246,20 @@ ReturnValue_t CCSDSTime::convertFromASCII(Clock::TimeOfDay_t* to, const uint8_t*
|
|||||||
return UNSUPPORTED_TIME_FORMAT;
|
return UNSUPPORTED_TIME_FORMAT;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ReturnValue_t CCSDSTime::convertToAsciiWithSecs(int8_t* to, const Clock::TimeOfDay_t* from,
|
||||||
|
uint8_t length) {
|
||||||
|
if (from == nullptr or to == nullptr) {
|
||||||
|
return returnvalue::FAILED;
|
||||||
|
}
|
||||||
|
int count = snprintf(reinterpret_cast<char*>(to), length,
|
||||||
|
"%4" SCNu32 "-%2" SCNu32 "-%2" SCNu32 "T%2" SCNu32 ":%2" SCNu32 ":%2" SCNu32,
|
||||||
|
from->year, from->month, from->day, from->hour, from->minute, from->second);
|
||||||
|
if (count >= length) {
|
||||||
|
return returnvalue::FAILED;
|
||||||
|
}
|
||||||
|
return returnvalue::OK;
|
||||||
|
}
|
||||||
|
|
||||||
ReturnValue_t CCSDSTime::checkCcs(const uint8_t* time, uint8_t length) {
|
ReturnValue_t CCSDSTime::checkCcs(const uint8_t* time, uint8_t length) {
|
||||||
const Ccs_mseconds* time_struct = reinterpret_cast<const Ccs_mseconds*>(time);
|
const Ccs_mseconds* time_struct = reinterpret_cast<const Ccs_mseconds*>(time);
|
||||||
|
|
||||||
|
@ -207,7 +207,8 @@ class CCSDSTime {
|
|||||||
|
|
||||||
static ReturnValue_t convertFromASCII(Clock::TimeOfDay_t *to, uint8_t const *from,
|
static ReturnValue_t convertFromASCII(Clock::TimeOfDay_t *to, uint8_t const *from,
|
||||||
uint8_t length);
|
uint8_t length);
|
||||||
|
static ReturnValue_t convertToAsciiWithSecs(int8_t *to, const Clock::TimeOfDay_t *from,
|
||||||
|
uint8_t length);
|
||||||
static uint32_t subsecondsToMicroseconds(uint16_t subseconds);
|
static uint32_t subsecondsToMicroseconds(uint16_t subseconds);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -6,47 +6,12 @@
|
|||||||
#include "fsfw/returnvalues/returnvalue.h"
|
#include "fsfw/returnvalues/returnvalue.h"
|
||||||
#include "tmStorageConf.h"
|
#include "tmStorageConf.h"
|
||||||
|
|
||||||
class TmPacketMinimal;
|
class PusTmReader;
|
||||||
class SpacePacketBase;
|
class SpacePacketReader;
|
||||||
class TmStoreBackendIF;
|
class TmStoreBackendIF;
|
||||||
|
|
||||||
class TmStoreFrontendIF {
|
class TmStoreFrontendIF {
|
||||||
public:
|
public:
|
||||||
virtual TmStoreBackendIF* getBackend() const = 0;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* What do I need to implement here?
|
|
||||||
* This is propably used by PUS Service 15 so we should propably check for messages..
|
|
||||||
* Provide base implementation?
|
|
||||||
* @param opCode
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
virtual ReturnValue_t performOperation(uint8_t opCode) = 0;
|
|
||||||
/**
|
|
||||||
* Callback from the back-end to indicate a certain packet was received.
|
|
||||||
* front-end takes care of discarding/downloading the packet.
|
|
||||||
* @param packet Pointer to the newly received Space Packet.
|
|
||||||
* @param address Start address of the packet found
|
|
||||||
* @param isLastPacket Indicates if no more packets can be fetched.
|
|
||||||
* @return If more packets shall be fetched, returnvalue::OK must be returned.
|
|
||||||
* Any other code stops fetching packets.
|
|
||||||
*/
|
|
||||||
virtual ReturnValue_t packetRetrieved(TmPacketMinimal* packet, uint32_t address) = 0;
|
|
||||||
virtual void noMorePacketsInStore() = 0;
|
|
||||||
virtual void handleRetrievalFailed(ReturnValue_t errorCode, uint32_t parameter1 = 0,
|
|
||||||
uint32_t parameter2 = 0) = 0;
|
|
||||||
/**
|
|
||||||
* To get the queue where commands shall be sent.
|
|
||||||
* @return Id of command queue.
|
|
||||||
*/
|
|
||||||
virtual MessageQueueId_t getCommandQueue() const = 0;
|
|
||||||
virtual ReturnValue_t fetchPackets(ApidSsc start, ApidSsc end) = 0;
|
|
||||||
virtual ReturnValue_t deletePackets(ApidSsc upTo) = 0;
|
|
||||||
virtual ReturnValue_t checkPacket(SpacePacketBase* tmPacket) = 0;
|
|
||||||
virtual bool isEnabled() const = 0;
|
|
||||||
virtual void setEnabled(bool enabled) = 0;
|
|
||||||
virtual void resetDownlinkedPacketCount() = 0;
|
|
||||||
virtual ReturnValue_t setDumpTarget(object_id_t dumpTarget) = 0;
|
|
||||||
static const uint8_t INTERFACE_ID = CLASS_ID::TM_STORE_FRONTEND_IF;
|
static const uint8_t INTERFACE_ID = CLASS_ID::TM_STORE_FRONTEND_IF;
|
||||||
static const ReturnValue_t BUSY = MAKE_RETURN_CODE(1);
|
static const ReturnValue_t BUSY = MAKE_RETURN_CODE(1);
|
||||||
static const ReturnValue_t LAST_PACKET_FOUND = MAKE_RETURN_CODE(2);
|
static const ReturnValue_t LAST_PACKET_FOUND = MAKE_RETURN_CODE(2);
|
||||||
@ -57,7 +22,38 @@ class TmStoreFrontendIF {
|
|||||||
static const ReturnValue_t ALL_DELETED = MAKE_RETURN_CODE(7);
|
static const ReturnValue_t ALL_DELETED = MAKE_RETURN_CODE(7);
|
||||||
static const ReturnValue_t INVALID_DATA = MAKE_RETURN_CODE(8);
|
static const ReturnValue_t INVALID_DATA = MAKE_RETURN_CODE(8);
|
||||||
static const ReturnValue_t NOT_READY = MAKE_RETURN_CODE(9);
|
static const ReturnValue_t NOT_READY = MAKE_RETURN_CODE(9);
|
||||||
virtual ~TmStoreFrontendIF() {}
|
|
||||||
|
virtual ~TmStoreFrontendIF() = default;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* To get the queue where commands shall be sent.
|
||||||
|
* @return Id of command queue.
|
||||||
|
*/
|
||||||
|
virtual MessageQueueId_t getCommandQueue() const = 0;
|
||||||
|
|
||||||
|
virtual TmStoreBackendIF* getBackend() const = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Callback from the back-end to indicate a certain packet was received.
|
||||||
|
* front-end takes care of discarding/downloading the packet.
|
||||||
|
* @param packet Pointer to the newly received Space Packet.
|
||||||
|
* @param address Start address of the packet found
|
||||||
|
* @param isLastPacket Indicates if no more packets can be fetched.
|
||||||
|
* @return If more packets shall be fetched, returnvalue::OK must be returned.
|
||||||
|
* Any other code stops fetching packets.
|
||||||
|
*/
|
||||||
|
virtual ReturnValue_t packetRetrieved(PusTmReader* packet, uint32_t address) = 0;
|
||||||
|
virtual void noMorePacketsInStore() = 0;
|
||||||
|
virtual void handleRetrievalFailed(ReturnValue_t errorCode, uint32_t parameter1 = 0,
|
||||||
|
uint32_t parameter2 = 0) = 0;
|
||||||
|
|
||||||
|
virtual ReturnValue_t fetchPackets(ApidSsc start, ApidSsc end) = 0;
|
||||||
|
virtual ReturnValue_t deletePackets(ApidSsc upTo) = 0;
|
||||||
|
virtual ReturnValue_t checkPacket(SpacePacketReader* tmPacket) = 0;
|
||||||
|
virtual bool isEnabled() const = 0;
|
||||||
|
virtual void setEnabled(bool enabled) = 0;
|
||||||
|
virtual void resetDownlinkedPacketCount() = 0;
|
||||||
|
virtual ReturnValue_t setDumpTarget(object_id_t dumpTarget) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* FSFW_TMTCSERVICES_TMSTOREFRONTENDIF_H_ */
|
#endif /* FSFW_TMTCSERVICES_TMSTOREFRONTENDIF_H_ */
|
||||||
|
15
src/fsfw/tmstorage/TmStoreFrontendSimpleIF.h
Normal file
15
src/fsfw/tmstorage/TmStoreFrontendSimpleIF.h
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
#ifndef FSFW_SRC_FSFW_TMSTORAGE_TMSTOREBACKENDSIMPLEIF_H_
|
||||||
|
#define FSFW_SRC_FSFW_TMSTORAGE_TMSTOREBACKENDSIMPLEIF_H_
|
||||||
|
|
||||||
|
#include <fsfw/ipc/messageQueueDefinitions.h>
|
||||||
|
|
||||||
|
class TmStoreFrontendSimpleIF {
|
||||||
|
public:
|
||||||
|
virtual ~TmStoreFrontendSimpleIF() = default;
|
||||||
|
|
||||||
|
virtual MessageQueueId_t getCommandQueue() const = 0;
|
||||||
|
|
||||||
|
private:
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif /* FSFW_SRC_FSFW_TMSTORAGE_TMSTOREBACKENDSIMPLEIF_H_ */
|
@ -1,6 +1,10 @@
|
|||||||
#ifndef FSFW_TMSTORAGE_TMSTOREPACKETS_H_
|
#ifndef FSFW_TMSTORAGE_TMSTOREPACKETS_H_
|
||||||
#define FSFW_TMSTORAGE_TMSTOREPACKETS_H_
|
#define FSFW_TMSTORAGE_TMSTOREPACKETS_H_
|
||||||
|
|
||||||
|
#include <fsfw/tmtcpacket/pus/tm/PusTmReader.h>
|
||||||
|
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
#include "fsfw/globalfunctions/timevalOperations.h"
|
#include "fsfw/globalfunctions/timevalOperations.h"
|
||||||
#include "fsfw/serialize/SerialBufferAdapter.h"
|
#include "fsfw/serialize/SerialBufferAdapter.h"
|
||||||
#include "fsfw/serialize/SerialFixedArrayListAdapter.h"
|
#include "fsfw/serialize/SerialFixedArrayListAdapter.h"
|
||||||
@ -24,7 +28,7 @@ class ServiceSubservice : public SerialLinkedListAdapter<SerializeIF> {
|
|||||||
|
|
||||||
class ApidSsc : public SerializeIF {
|
class ApidSsc : public SerializeIF {
|
||||||
public:
|
public:
|
||||||
ApidSsc() : apid(SpacePacketBase::LIMIT_APID), ssc(0) {}
|
ApidSsc() : apid(ccsds::LIMIT_APID), ssc(0) {}
|
||||||
ApidSsc(uint16_t apid, uint16_t ssc) : apid(apid), ssc(ssc) {}
|
ApidSsc(uint16_t apid, uint16_t ssc) : apid(apid), ssc(ssc) {}
|
||||||
uint16_t apid;
|
uint16_t apid;
|
||||||
uint16_t ssc;
|
uint16_t ssc;
|
||||||
@ -62,51 +66,59 @@ class ChangeSelectionDefinition : public SerialLinkedListAdapter<SerializeIF> {
|
|||||||
|
|
||||||
class TmPacketInformation : public SerializeIF {
|
class TmPacketInformation : public SerializeIF {
|
||||||
public:
|
public:
|
||||||
TmPacketInformation(TmPacketMinimal* packet) { setContent(packet); }
|
TmPacketInformation(PusTmReader* packet, size_t timestampLen) : rawTimestamp(timestampLen) {
|
||||||
TmPacketInformation()
|
setContent(packet);
|
||||||
: apid(SpacePacketBase::LIMIT_APID),
|
}
|
||||||
|
TmPacketInformation(size_t timestampLen)
|
||||||
|
: apid(ccsds::LIMIT_APID),
|
||||||
sourceSequenceCount(0),
|
sourceSequenceCount(0),
|
||||||
serviceType(0),
|
serviceType(0),
|
||||||
serviceSubtype(0),
|
serviceSubtype(0),
|
||||||
subCounter(0) {}
|
subCounter(0),
|
||||||
|
rawTimestamp(timestampLen) {}
|
||||||
void reset() {
|
void reset() {
|
||||||
apid = SpacePacketBase::LIMIT_APID;
|
apid = ccsds::LIMIT_APID;
|
||||||
sourceSequenceCount = 0;
|
sourceSequenceCount = 0;
|
||||||
serviceType = 0;
|
serviceType = 0;
|
||||||
serviceSubtype = 0;
|
serviceSubtype = 0;
|
||||||
subCounter = 0;
|
subCounter = 0;
|
||||||
memset(rawTimestamp, 0, sizeof(rawTimestamp));
|
memset(rawTimestamp.data(), 0, rawTimestamp.size());
|
||||||
}
|
}
|
||||||
void setContent(TmPacketMinimal* packet) {
|
void setContent(PusTmReader* packet) {
|
||||||
apid = packet->getAPID();
|
apid = packet->getApid();
|
||||||
sourceSequenceCount = packet->getPacketSequenceCount();
|
sourceSequenceCount = packet->getSequenceCount();
|
||||||
serviceType = packet->getService();
|
serviceType = packet->getService();
|
||||||
serviceSubtype = packet->getSubService();
|
serviceSubtype = packet->getSubService();
|
||||||
subCounter = packet->getPacketSubcounter();
|
subCounter = packet->getMessageTypeCounter();
|
||||||
memset(rawTimestamp, 0, sizeof(rawTimestamp));
|
memset(rawTimestamp.data(), 0, rawTimestamp.size());
|
||||||
const uint8_t* pField = NULL;
|
// TODO: Fix all of this
|
||||||
uint32_t size = 0;
|
// const uint8_t* pField = NULL;
|
||||||
ReturnValue_t result = packet->getPacketTimeRaw(&pField, &size);
|
// uint32_t size = 0;
|
||||||
if (result != returnvalue::OK) {
|
// auto* timeReader = packet->getTimeReader();
|
||||||
return;
|
// ReturnValue_t result = packet->getPacketTimeRaw(&pField, &size);
|
||||||
}
|
// if (result != returnvalue::OK) {
|
||||||
if (*pField == CCSDSTime::P_FIELD_CDS_SHORT && size <= TimeStamperIF::MISSION_TIMESTAMP_SIZE) {
|
// return;
|
||||||
// Shortcut to avoid converting CDS back and forth.
|
//}
|
||||||
memcpy(rawTimestamp, pField, size);
|
// if (*pField == CCSDSTime::P_FIELD_CDS_SHORT && size <= TimeStamperIF::MISSION_TIMESTAMP_SIZE)
|
||||||
return;
|
// {
|
||||||
}
|
// Shortcut to avoid converting CDS back and forth.
|
||||||
timeval time = {0, 0};
|
// TODO: Fix
|
||||||
result = packet->getPacketTime(&time);
|
// memcpy(rawTimestamp, pField, size);
|
||||||
if (result != returnvalue::OK) {
|
// return;
|
||||||
return;
|
// }
|
||||||
}
|
// timeval time = {0, 0};
|
||||||
|
// result = packet->getPacketTime(&time);
|
||||||
CCSDSTime::CDS_short cdsFormat;
|
// if (result != returnvalue::OK) {
|
||||||
result = CCSDSTime::convertToCcsds(&cdsFormat, &time);
|
// return;
|
||||||
if (result != returnvalue::OK) {
|
// }
|
||||||
return;
|
//
|
||||||
}
|
// CCSDSTime::CDS_short cdsFormat;
|
||||||
memcpy(rawTimestamp, &cdsFormat, sizeof(cdsFormat));
|
// result = CCSDSTime::convertToCcsds(&cdsFormat, &time);
|
||||||
|
// if (result != returnvalue::OK) {
|
||||||
|
// return;
|
||||||
|
// }
|
||||||
|
// TODO: Fix
|
||||||
|
// memcpy(rawTimestamp, &cdsFormat, sizeof(cdsFormat));
|
||||||
}
|
}
|
||||||
void setContent(TmPacketInformation* content) {
|
void setContent(TmPacketInformation* content) {
|
||||||
apid = content->apid;
|
apid = content->apid;
|
||||||
@ -114,9 +126,10 @@ class TmPacketInformation : public SerializeIF {
|
|||||||
serviceType = content->serviceType;
|
serviceType = content->serviceType;
|
||||||
serviceSubtype = content->serviceSubtype;
|
serviceSubtype = content->serviceSubtype;
|
||||||
subCounter = content->subCounter;
|
subCounter = content->subCounter;
|
||||||
memcpy(rawTimestamp, content->rawTimestamp, sizeof(rawTimestamp));
|
// TODO: Fix
|
||||||
|
// memcpy(rawTimestamp, content->rawTimestamp, sizeof(rawTimestamp));
|
||||||
}
|
}
|
||||||
bool isValid() const { return (apid < SpacePacketBase::LIMIT_APID) ? true : false; }
|
bool isValid() const { return (apid < ccsds::LIMIT_APID) ? true : false; }
|
||||||
static void reset(TmPacketInformation* packet) { packet->reset(); }
|
static void reset(TmPacketInformation* packet) { packet->reset(); }
|
||||||
|
|
||||||
static bool isOlderThan(const TmPacketInformation* packet, const timeval* cmpTime) {
|
static bool isOlderThan(const TmPacketInformation* packet, const timeval* cmpTime) {
|
||||||
@ -216,7 +229,7 @@ class TmPacketInformation : public SerializeIF {
|
|||||||
if (result != returnvalue::OK) {
|
if (result != returnvalue::OK) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
SerialBufferAdapter<uint8_t> adapter(rawTimestamp, sizeof(rawTimestamp));
|
SerialBufferAdapter<uint8_t> adapter(rawTimestamp.data(), rawTimestamp.size());
|
||||||
return adapter.serialize(buffer, size, maxSize, streamEndianness);
|
return adapter.serialize(buffer, size, maxSize, streamEndianness);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -227,7 +240,7 @@ class TmPacketInformation : public SerializeIF {
|
|||||||
size += SerializeAdapter::getSerializedSize(&serviceType);
|
size += SerializeAdapter::getSerializedSize(&serviceType);
|
||||||
size += SerializeAdapter::getSerializedSize(&serviceSubtype);
|
size += SerializeAdapter::getSerializedSize(&serviceSubtype);
|
||||||
size += SerializeAdapter::getSerializedSize(&subCounter);
|
size += SerializeAdapter::getSerializedSize(&subCounter);
|
||||||
SerialBufferAdapter<uint8_t> adapter(rawTimestamp, sizeof(rawTimestamp));
|
SerialBufferAdapter<uint8_t> adapter(rawTimestamp.data(), rawTimestamp.size());
|
||||||
size += adapter.getSerializedSize();
|
size += adapter.getSerializedSize();
|
||||||
return size;
|
return size;
|
||||||
};
|
};
|
||||||
@ -253,7 +266,7 @@ class TmPacketInformation : public SerializeIF {
|
|||||||
if (result != returnvalue::OK) {
|
if (result != returnvalue::OK) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
SerialBufferAdapter<uint8_t> adapter(rawTimestamp, sizeof(rawTimestamp));
|
SerialBufferAdapter<uint8_t> adapter(rawTimestamp.data(), rawTimestamp.size());
|
||||||
return adapter.deSerialize(buffer, size, streamEndianness);
|
return adapter.deSerialize(buffer, size, streamEndianness);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -263,6 +276,6 @@ class TmPacketInformation : public SerializeIF {
|
|||||||
uint8_t serviceType;
|
uint8_t serviceType;
|
||||||
uint8_t serviceSubtype;
|
uint8_t serviceSubtype;
|
||||||
uint8_t subCounter;
|
uint8_t subCounter;
|
||||||
uint8_t rawTimestamp[TimeStamperIF::MISSION_TIMESTAMP_SIZE];
|
std::vector<uint8_t> rawTimestamp;
|
||||||
};
|
};
|
||||||
#endif /* FSFW_TMSTORAGE_TMSTOREPACKETS_H_ */
|
#endif /* FSFW_TMSTORAGE_TMSTOREPACKETS_H_ */
|
||||||
|
@ -2,7 +2,6 @@
|
|||||||
|
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <fsfw_hal/linux/serial/SerialComIF.h>
|
|
||||||
#include <termios.h>
|
#include <termios.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user