Base to stage pull requests from #23
|
@ -184,6 +184,7 @@ endif()
|
|||
target_include_directories(${LIB_FSFW_NAME} INTERFACE
|
||||
${CMAKE_SOURCE_DIR}
|
||||
${FSFW_CONFIG_PATH_ABSOLUTE}
|
||||
${FSFW_ADD_INC_PATHS_ABS}
|
||||
)
|
||||
|
||||
# Includes path required to compile FSFW itself as well
|
||||
|
|
|
@ -3,9 +3,9 @@
|
|||
|
||||
const char* const FSFW_VERSION_NAME = "ASTP";
|
||||
|
||||
#define FSFW_VERSION 0
|
||||
#define FSFW_SUBVERSION 0
|
||||
#define FSFW_REVISION 1
|
||||
#define FSFW_VERSION 1
|
||||
#define FSFW_SUBVERSION 0
|
||||
#define FSFW_REVISION 0
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -147,11 +147,6 @@ ReturnValue_t ActionHelper::reportData(MessageQueueId_t reportTo,
|
|||
return result;
|
||||
}
|
||||
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
ipcStore->deleteData(storeAddress);
|
||||
return result;
|
||||
}
|
||||
|
||||
/* We don't need to report the objectId, as we receive REQUESTED data before the completion
|
||||
success message. True aperiodic replies need to be reported with another dedicated message. */
|
||||
ActionMessage::setDataReply(&reply, replyId, storeAddress);
|
||||
|
|
|
@ -17,6 +17,9 @@ SharedRingBuffer::SharedRingBuffer(object_id_t objectId, uint8_t *buffer,
|
|||
mutex = MutexFactory::instance()->createMutex();
|
||||
}
|
||||
|
||||
SharedRingBuffer::~SharedRingBuffer() {
|
||||
MutexFactory::instance()->deleteMutex(mutex);
|
||||
}
|
||||
|
||||
void SharedRingBuffer::setToUseReceiveSizeFIFO(size_t fifoDepth) {
|
||||
this->fifoDepth = fifoDepth;
|
||||
|
|
|
@ -26,6 +26,18 @@ public:
|
|||
*/
|
||||
SharedRingBuffer(object_id_t objectId, const size_t size,
|
||||
bool overwriteOld, size_t maxExcessBytes);
|
||||
/**
|
||||
* This constructor takes an external buffer with the specified size.
|
||||
* @param buffer
|
||||
* @param size
|
||||
* @param overwriteOld
|
||||
* If the ring buffer is overflowing at a write operartion, the oldest data
|
||||
* will be overwritten.
|
||||
*/
|
||||
SharedRingBuffer(object_id_t objectId, uint8_t* buffer, const size_t size,
|
||||
bool overwriteOld, size_t maxExcessBytes);
|
||||
|
||||
virtual~ SharedRingBuffer();
|
||||
|
||||
/**
|
||||
* @brief This function can be used to add an optional FIFO to the class
|
||||
|
@ -37,16 +49,7 @@ public:
|
|||
*/
|
||||
void setToUseReceiveSizeFIFO(size_t fifoDepth);
|
||||
|
||||
/**
|
||||
* This constructor takes an external buffer with the specified size.
|
||||
* @param buffer
|
||||
* @param size
|
||||
* @param overwriteOld
|
||||
* If the ring buffer is overflowing at a write operartion, the oldest data
|
||||
* will be overwritten.
|
||||
*/
|
||||
SharedRingBuffer(object_id_t objectId, uint8_t* buffer, const size_t size,
|
||||
bool overwriteOld, size_t maxExcessBytes);
|
||||
|
||||
|
||||
/**
|
||||
* Unless a read-only constant value is read, all operations on the
|
||||
|
|
|
@ -7,7 +7,7 @@ HkSwitchHelper::HkSwitchHelper(EventReportingProxyIF* eventProxy) :
|
|||
}
|
||||
|
||||
HkSwitchHelper::~HkSwitchHelper() {
|
||||
// TODO Auto-generated destructor stub
|
||||
QueueFactory::instance()->deleteMessageQueue(actionQueue);
|
||||
}
|
||||
|
||||
ReturnValue_t HkSwitchHelper::initialize() {
|
||||
|
|
|
@ -909,27 +909,29 @@ void LocalDataPoolManager::printWarningOrError(sif::OutputTypes outputType,
|
|||
errorPrint = "Unknown error";
|
||||
}
|
||||
}
|
||||
object_id_t objectId = 0xffffffff;
|
||||
if(owner != nullptr) {
|
||||
objectId = owner->getObjectId();
|
||||
}
|
||||
|
||||
if(outputType == sif::OutputTypes::OUT_WARNING) {
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::warning << "LocalDataPoolManager::" << functionName
|
||||
<< ": Object ID 0x" << std::setw(8) << std::setfill('0')
|
||||
<< std::hex << owner->getObjectId() << " | " << errorPrint
|
||||
<< std::dec << std::setfill(' ') << std::endl;
|
||||
sif::warning << "LocalDataPoolManager::" << functionName << ": Object ID 0x" <<
|
||||
std::setw(8) << std::setfill('0') << std::hex << objectId << " | " << errorPrint <<
|
||||
std::dec << std::setfill(' ') << std::endl;
|
||||
#else
|
||||
sif::printWarning("LocalDataPoolManager::%s: Object ID 0x%08x | %s\n",
|
||||
functionName, owner->getObjectId(), errorPrint);
|
||||
functionName, objectId, errorPrint);
|
||||
#endif /* FSFW_CPP_OSTREAM_ENABLED == 1 */
|
||||
}
|
||||
else if(outputType == sif::OutputTypes::OUT_ERROR) {
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::error << "LocalDataPoolManager::" << functionName
|
||||
<< ": Object ID 0x" << std::setw(8) << std::setfill('0')
|
||||
<< std::hex << owner->getObjectId() << " | " << errorPrint
|
||||
<< std::dec << std::setfill(' ') << std::endl;
|
||||
sif::error << "LocalDataPoolManager::" << functionName << ": Object ID 0x" <<
|
||||
std::setw(8) << std::setfill('0') << std::hex << objectId << " | " << errorPrint <<
|
||||
std::dec << std::setfill(' ') << std::endl;
|
||||
#else
|
||||
sif::printError("LocalDataPoolManager::%s: Object ID 0x%08x | %s\n",
|
||||
functionName, owner->getObjectId(), errorPrint);
|
||||
functionName, objectId, errorPrint);
|
||||
#endif /* FSFW_CPP_OSTREAM_ENABLED == 1 */
|
||||
}
|
||||
#endif /* #if FSFW_VERBOSE_LEVEL >= 1 */
|
||||
|
|
|
@ -17,6 +17,8 @@
|
|||
#define FSFW_DISABLE_PRINTOUT 0
|
||||
#endif
|
||||
|
||||
#define FSFW_USE_PUS_C_TELEMETRY 1
|
||||
|
||||
//! Can be used to disable the ANSI color sequences for C stdio.
|
||||
#define FSFW_COLORED_OUTPUT 1
|
||||
|
||||
|
@ -40,10 +42,17 @@
|
|||
//! Specify whether a special mode store is used for Subsystem components.
|
||||
#define FSFW_USE_MODESTORE 0
|
||||
|
||||
//! Defines if the real time scheduler for linux should be used.
|
||||
//! If set to 0, this will also disable priority settings for linux
|
||||
//! as most systems will not allow to set nice values without privileges
|
||||
//! For embedded linux system set this to 1.
|
||||
//! If set to 1 the binary needs "cap_sys_nice=eip" privileges to run
|
||||
#define FSFW_USE_REALTIME_FOR_LINUX 1
|
||||
|
||||
namespace fsfwconfig {
|
||||
//! Default timestamp size. The default timestamp will be an eight byte CDC
|
||||
//! short timestamp.
|
||||
static constexpr uint8_t FSFW_MISSION_TIMESTAMP_SIZE = 8;
|
||||
static constexpr uint8_t FSFW_MISSION_TIMESTAMP_SIZE = 7;
|
||||
|
||||
//! Configure the allocated pool sizes for the event manager.
|
||||
static constexpr size_t FSFW_EVENTMGMR_MATCHTREE_NODES = 240;
|
||||
|
@ -52,11 +61,12 @@ static constexpr size_t FSFW_EVENTMGMR_RANGEMATCHERS = 120;
|
|||
|
||||
//! Defines the FIFO depth of each commanding service base which
|
||||
//! also determines how many commands a CSB service can handle in one cycle
|
||||
//! simulataneously. This will increase the required RAM for
|
||||
//! simultaneously. This will increase the required RAM for
|
||||
//! each CSB service !
|
||||
static constexpr uint8_t FSFW_CSB_FIFO_DEPTH = 6;
|
||||
|
||||
static constexpr size_t FSFW_PRINT_BUFFER_SIZE = 124;
|
||||
|
||||
}
|
||||
|
||||
#endif /* CONFIG_FSFWCONFIG_H_ */
|
||||
|
|
|
@ -1483,7 +1483,7 @@ void DeviceHandlerBase::printWarningOrError(sif::OutputTypes errorType,
|
|||
if(errorCode == ObjectManagerIF::CHILD_INIT_FAILED) {
|
||||
errorPrint = "Initialization error";
|
||||
}
|
||||
if(errorCode == HasReturnvaluesIF::RETURN_FAILED) {
|
||||
else if(errorCode == HasReturnvaluesIF::RETURN_FAILED) {
|
||||
if(errorType == sif::OutputTypes::OUT_WARNING) {
|
||||
errorPrint = "Generic Warning";
|
||||
}
|
||||
|
@ -1495,6 +1495,9 @@ void DeviceHandlerBase::printWarningOrError(sif::OutputTypes errorType,
|
|||
errorPrint = "Unknown error";
|
||||
}
|
||||
}
|
||||
if(functionName == nullptr) {
|
||||
functionName = "unknown function";
|
||||
}
|
||||
|
||||
if(errorType == sif::OutputTypes::OUT_WARNING) {
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
|
@ -1504,7 +1507,7 @@ void DeviceHandlerBase::printWarningOrError(sif::OutputTypes errorType,
|
|||
<< std::setfill(' ') << std::endl;
|
||||
#else
|
||||
sif::printWarning("DeviceHandlerBase::%s: Object ID 0x%08x | %s\n",
|
||||
this->getObjectId(), errorPrint);
|
||||
functionName, this->getObjectId(), errorPrint);
|
||||
#endif
|
||||
}
|
||||
else if(errorType == sif::OutputTypes::OUT_ERROR) {
|
||||
|
@ -1515,7 +1518,7 @@ void DeviceHandlerBase::printWarningOrError(sif::OutputTypes errorType,
|
|||
<< std::setfill(' ') << std::endl;
|
||||
#else
|
||||
sif::printError("DeviceHandlerBase::%s: Object ID 0x%08x | %s\n",
|
||||
this->getObjectId(), errorPrint);
|
||||
functionName, this->getObjectId(), errorPrint);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
|
@ -16,9 +16,9 @@ ReturnValue_t HealthDevice::performOperation(uint8_t opCode) {
|
|||
CommandMessage command;
|
||||
ReturnValue_t result = commandQueue->receiveMessage(&command);
|
||||
if (result == HasReturnvaluesIF::RETURN_OK) {
|
||||
healthHelper.handleHealthCommand(&command);
|
||||
result = healthHelper.handleHealthCommand(&command);
|
||||
}
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
return result;
|
||||
}
|
||||
|
||||
ReturnValue_t HealthDevice::initialize() {
|
||||
|
|
|
@ -109,6 +109,6 @@ bool EventMessage::isClearedEventMessage() {
|
|||
return getEvent() == INVALID_EVENT;
|
||||
}
|
||||
|
||||
size_t EventMessage::getMinimumMessageSize() {
|
||||
size_t EventMessage::getMinimumMessageSize() const {
|
||||
return EVENT_MESSAGE_SIZE;
|
||||
}
|
||||
|
|
|
@ -45,7 +45,7 @@ public:
|
|||
|
||||
protected:
|
||||
static const Event INVALID_EVENT = 0;
|
||||
virtual size_t getMinimumMessageSize();
|
||||
virtual size_t getMinimumMessageSize() const override;
|
||||
|
||||
};
|
||||
|
||||
|
|
|
@ -51,7 +51,7 @@ void arrayprinter::printHex(const uint8_t *data, size_t size,
|
|||
#else
|
||||
// General format: 0x01, 0x02, 0x03 so it is number of chars times 6
|
||||
// plus line break plus small safety margin.
|
||||
char printBuffer[(size + 1) * 7 + 1];
|
||||
char printBuffer[(size + 1) * 7 + 1] = {};
|
||||
size_t currentPos = 0;
|
||||
for(size_t i = 0; i < size; i++) {
|
||||
// To avoid buffer overflows.
|
||||
|
@ -94,7 +94,7 @@ void arrayprinter::printDec(const uint8_t *data, size_t size,
|
|||
#else
|
||||
// General format: 32, 243, -12 so it is number of chars times 5
|
||||
// plus line break plus small safety margin.
|
||||
char printBuffer[(size + 1) * 5 + 1];
|
||||
char printBuffer[(size + 1) * 5 + 1] = {};
|
||||
size_t currentPos = 0;
|
||||
for(size_t i = 0; i < size; i++) {
|
||||
// To avoid buffer overflows.
|
||||
|
|
|
@ -68,14 +68,30 @@ void HealthTable::printAll(uint8_t* pointer, size_t maxSize) {
|
|||
MutexGuard(mutex, timeoutType, mutexTimeoutMs);
|
||||
size_t size = 0;
|
||||
uint16_t count = healthMap.size();
|
||||
SerializeAdapter::serialize(&count,
|
||||
ReturnValue_t result = SerializeAdapter::serialize(&count,
|
||||
&pointer, &size, maxSize, SerializeIF::Endianness::BIG);
|
||||
if(result != HasReturnvaluesIF::RETURN_OK) {
|
||||
#if FSFW_VERBOSE_LEVEL >= 1
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::warning << "HealthTable::printAll: Serialization of health table failed" << std::endl;
|
||||
#else
|
||||
sif::printWarning("HealthTable::printAll: Serialization of health table failed\n");
|
||||
#endif
|
||||
#endif /* FSFW_VERBOSE_LEVEL >= 1 */
|
||||
return;
|
||||
}
|
||||
for (const auto& health: healthMap) {
|
||||
SerializeAdapter::serialize(&health.first,
|
||||
result = SerializeAdapter::serialize(&health.first,
|
||||
&pointer, &size, maxSize, SerializeIF::Endianness::BIG);
|
||||
if(result != HasReturnvaluesIF::RETURN_OK) {
|
||||
return;
|
||||
}
|
||||
uint8_t healthValue = health.second;
|
||||
SerializeAdapter::serialize(&healthValue, &pointer, &size,
|
||||
result = SerializeAdapter::serialize(&healthValue, &pointer, &size,
|
||||
maxSize, SerializeIF::Endianness::BIG);
|
||||
if(result != HasReturnvaluesIF::RETURN_OK) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -86,7 +102,7 @@ ReturnValue_t HealthTable::iterate(HealthEntry *value, bool reset) {
|
|||
mapIterator = healthMap.begin();
|
||||
}
|
||||
if (mapIterator == healthMap.end()) {
|
||||
result = HasReturnvaluesIF::RETURN_FAILED;
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
}
|
||||
*value = *mapIterator;
|
||||
mapIterator++;
|
||||
|
|
|
@ -27,7 +27,7 @@ public:
|
|||
//! Returned if a reply method was called without partner
|
||||
static const ReturnValue_t NO_REPLY_PARTNER = MAKE_RETURN_CODE(3);
|
||||
//! Returned if the target destination is invalid.
|
||||
static constexpr ReturnValue_t DESTINVATION_INVALID = MAKE_RETURN_CODE(4);
|
||||
static constexpr ReturnValue_t DESTINATION_INVALID = MAKE_RETURN_CODE(4);
|
||||
|
||||
virtual ~MessageQueueIF() {}
|
||||
/**
|
||||
|
|
|
@ -111,7 +111,7 @@ ReturnValue_t Clock::getDateAndTime(TimeOfDay_t* time) {
|
|||
|
||||
ReturnValue_t Clock::convertTimeOfDayToTimeval(const TimeOfDay_t* from,
|
||||
timeval* to) {
|
||||
struct tm time_tm;
|
||||
struct tm time_tm = {};
|
||||
|
||||
time_tm.tm_year = from->year - 1900;
|
||||
time_tm.tm_mon = from->month - 1;
|
||||
|
|
|
@ -135,7 +135,7 @@ ReturnValue_t MessageQueue::sendMessageFromMessageQueue(MessageQueueId_t sendTo,
|
|||
QueueHandle_t destination = nullptr;
|
||||
|
||||
if(sendTo == MessageQueueIF::NO_QUEUE or sendTo == 0x00) {
|
||||
return MessageQueueIF::DESTINVATION_INVALID;
|
||||
return MessageQueueIF::DESTINATION_INVALID;
|
||||
}
|
||||
else {
|
||||
destination = reinterpret_cast<QueueHandle_t>(sendTo);
|
||||
|
|
|
@ -70,6 +70,7 @@ ReturnValue_t TcpTmTcServer::initialize() {
|
|||
#endif
|
||||
freeaddrinfo(addrResult);
|
||||
handleError(Protocol::TCP, ErrorSources::BIND_CALL);
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
}
|
||||
|
||||
freeaddrinfo(addrResult);
|
||||
|
@ -84,8 +85,8 @@ TcpTmTcServer::~TcpTmTcServer() {
|
|||
ReturnValue_t TcpTmTcServer::performOperation(uint8_t opCode) {
|
||||
using namespace tcpip;
|
||||
/* If a connection is accepted, the corresponding socket will be assigned to the new socket */
|
||||
socket_t clientSocket;
|
||||
sockaddr clientSockAddr;
|
||||
socket_t clientSocket = 0;
|
||||
sockaddr clientSockAddr = {};
|
||||
socklen_t connectorSockAddrLen = 0;
|
||||
int retval = 0;
|
||||
|
||||
|
@ -101,6 +102,7 @@ ReturnValue_t TcpTmTcServer::performOperation(uint8_t opCode) {
|
|||
|
||||
if(clientSocket == INVALID_SOCKET) {
|
||||
handleError(Protocol::TCP, ErrorSources::ACCEPT_CALL, 500);
|
||||
closeSocket(clientSocket);
|
||||
continue;
|
||||
};
|
||||
|
||||
|
@ -122,6 +124,7 @@ ReturnValue_t TcpTmTcServer::performOperation(uint8_t opCode) {
|
|||
|
||||
/* Done, shut down connection */
|
||||
retval = shutdown(clientSocket, SHUT_SEND);
|
||||
closeSocket(clientSocket);
|
||||
}
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
#endif
|
||||
|
||||
//! Debugging preprocessor define.
|
||||
#define FSFW_UDP_RCV_WIRETAPPING_ENABLED 0
|
||||
#define FSFW_UDP_RECV_WIRETAPPING_ENABLED 0
|
||||
|
||||
UdpTcPollingTask::UdpTcPollingTask(object_id_t objectId,
|
||||
object_id_t tmtcUnixUdpBridge, size_t maxRecvSize,
|
||||
|
@ -66,10 +66,13 @@ ReturnValue_t UdpTcPollingTask::performOperation(uint8_t opCode) {
|
|||
tcpip::handleError(tcpip::Protocol::UDP, tcpip::ErrorSources::RECVFROM_CALL, 1000);
|
||||
continue;
|
||||
}
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1 && FSFW_UDP_RCV_WIRETAPPING_ENABLED == 1
|
||||
#if FSFW_UDP_RECV_WIRETAPPING_ENABLED == 1
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::debug << "UdpTcPollingTask::performOperation: " << bytesReceived <<
|
||||
" bytes received" << std::endl;
|
||||
#else
|
||||
#endif
|
||||
#endif /* FSFW_UDP_RCV_WIRETAPPING_ENABLED == 1 */
|
||||
|
||||
ReturnValue_t result = handleSuccessfullTcRead(bytesReceived);
|
||||
if(result != HasReturnvaluesIF::RETURN_FAILED) {
|
||||
|
@ -84,7 +87,7 @@ ReturnValue_t UdpTcPollingTask::performOperation(uint8_t opCode) {
|
|||
ReturnValue_t UdpTcPollingTask::handleSuccessfullTcRead(size_t bytesRead) {
|
||||
store_address_t storeId;
|
||||
|
||||
#if FSFW_UDP_RCV_WIRETAPPING_ENABLED == 1
|
||||
#if FSFW_UDP_RECV_WIRETAPPING_ENABLED == 1
|
||||
arrayprinter::print(receptionBuffer.data(), bytesRead);
|
||||
#endif
|
||||
|
||||
|
|
|
@ -70,6 +70,7 @@ ReturnValue_t UdpTmTcBridge::initialize() {
|
|||
hints.ai_family = AF_INET;
|
||||
hints.ai_socktype = SOCK_DGRAM;
|
||||
hints.ai_protocol = IPPROTO_UDP;
|
||||
hints.ai_flags = AI_PASSIVE;
|
||||
|
||||
/* Set up UDP socket:
|
||||
https://en.wikipedia.org/wiki/Getaddrinfo
|
||||
|
@ -95,6 +96,10 @@ ReturnValue_t UdpTmTcBridge::initialize() {
|
|||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
}
|
||||
|
||||
#if FSFW_UDP_SEND_WIRETAPPING_ENABLED == 1
|
||||
tcpip::printAddress(addrResult->ai_addr);
|
||||
#endif
|
||||
|
||||
retval = bind(serverSocket, addrResult->ai_addr, static_cast<int>(addrResult->ai_addrlen));
|
||||
if(retval != 0) {
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
|
@ -103,6 +108,7 @@ ReturnValue_t UdpTmTcBridge::initialize() {
|
|||
#endif
|
||||
freeaddrinfo(addrResult);
|
||||
tcpip::handleError(tcpip::Protocol::UDP, tcpip::ErrorSources::BIND_CALL);
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
}
|
||||
freeaddrinfo(addrResult);
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
|
@ -120,10 +126,8 @@ ReturnValue_t UdpTmTcBridge::sendTm(const uint8_t *data, size_t dataLen) {
|
|||
/* The target address can be set by different threads so this lock ensures thread-safety */
|
||||
MutexGuard lock(mutex, timeoutType, mutexTimeoutMs);
|
||||
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1 && FSFW_UDP_SEND_WIRETAPPING_ENABLED == 1
|
||||
char ipAddress [15];
|
||||
sif::debug << "IP Address Sender: "<< inet_ntop(AF_INET,
|
||||
&clientAddress.sin_addr.s_addr, ipAddress, 15) << std::endl;
|
||||
#if FSFW_UDP_SEND_WIRETAPPING_ENABLED == 1
|
||||
tcpip::printAddress(&clientAddress);
|
||||
#endif
|
||||
|
||||
int bytesSent = sendto(
|
||||
|
@ -151,13 +155,11 @@ void UdpTmTcBridge::checkAndSetClientAddress(sockaddr& newAddress) {
|
|||
/* The target address can be set by different threads so this lock ensures thread-safety */
|
||||
MutexGuard lock(mutex, timeoutType, mutexTimeoutMs);
|
||||
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1 && FSFW_UDP_SEND_WIRETAPPING_ENABLED == 1
|
||||
char ipAddress [15];
|
||||
sif::debug << "IP Address Sender: "<< inet_ntop(AF_INET,
|
||||
&newAddress.sin_addr.s_addr, ipAddress, 15) << std::endl;
|
||||
sif::debug << "IP Address Old: " << inet_ntop(AF_INET,
|
||||
&clientAddress.sin_addr.s_addr, ipAddress, 15) << std::endl;
|
||||
#if FSFW_UDP_SEND_WIRETAPPING_ENABLED == 1
|
||||
tcpip::printAddress(&newAddress);
|
||||
tcpip::printAddress(&clientAddress);
|
||||
#endif
|
||||
|
||||
registerCommConnect();
|
||||
|
||||
/* Set new IP address to reply to */
|
||||
|
|
|
@ -1,4 +1,9 @@
|
|||
#include "tcpipCommon.h"
|
||||
#include <fsfw/serviceinterface/ServiceInterface.h>
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <ws2tcpip.h>
|
||||
#endif
|
||||
|
||||
void tcpip::determineErrorStrings(Protocol protocol, ErrorSources errorSrc, std::string &protStr,
|
||||
std::string &srcString) {
|
||||
|
@ -34,3 +39,37 @@ void tcpip::determineErrorStrings(Protocol protocol, ErrorSources errorSrc, std:
|
|||
srcString = "unknown call";
|
||||
}
|
||||
}
|
||||
|
||||
void tcpip::printAddress(struct sockaddr* addr) {
|
||||
char ipAddress[INET6_ADDRSTRLEN] = {};
|
||||
const char* stringPtr = NULL;
|
||||
switch(addr->sa_family) {
|
||||
case AF_INET: {
|
||||
struct sockaddr_in *addrIn = reinterpret_cast<struct sockaddr_in*>(addr);
|
||||
stringPtr = inet_ntop(AF_INET, &(addrIn->sin_addr), ipAddress, INET_ADDRSTRLEN);
|
||||
break;
|
||||
}
|
||||
case AF_INET6: {
|
||||
struct sockaddr_in6 *addrIn = reinterpret_cast<struct sockaddr_in6*>(addr);
|
||||
stringPtr = inet_ntop(AF_INET6, &(addrIn->sin6_addr), ipAddress, INET6_ADDRSTRLEN);
|
||||
break;
|
||||
}
|
||||
}
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
if(stringPtr == NULL) {
|
||||
sif::debug << "Could not convert IP address to text representation, error code "
|
||||
<< errno << std::endl;
|
||||
}
|
||||
else {
|
||||
sif::debug << "IP Address Sender: " << ipAddress << std::endl;
|
||||
}
|
||||
#else
|
||||
if(stringPtr == NULL) {
|
||||
sif::printDebug("Could not convert IP address to text representation, error code %d\n",
|
||||
errno);
|
||||
}
|
||||
else {
|
||||
sif::printDebug("IP Address Sender: %s\n", ipAddress);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -4,6 +4,13 @@
|
|||
#include "../../timemanager/clockDefinitions.h"
|
||||
#include <string>
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <winsock2.h>
|
||||
#else
|
||||
#include <netdb.h>
|
||||
#include <arpa/inet.h>
|
||||
#endif
|
||||
|
||||
namespace tcpip {
|
||||
|
||||
const char* const DEFAULT_SERVER_PORT = "7301";
|
||||
|
@ -28,8 +35,8 @@ enum class ErrorSources {
|
|||
void determineErrorStrings(Protocol protocol, ErrorSources errorSrc, std::string& protStr,
|
||||
std::string& srcString);
|
||||
|
||||
void printAddress(struct sockaddr* addr);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
#endif /* FSFW_OSAL_COMMON_TCPIPCOMMON_H_ */
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
#include "../../ipc/MutexFactory.h"
|
||||
#include "../../osal/host/Mutex.h"
|
||||
#include "../../osal/host/FixedTimeslotTask.h"
|
||||
#include "../../serviceinterface/ServiceInterfaceStream.h"
|
||||
#include "../../serviceinterface/ServiceInterface.h"
|
||||
#include "../../tasks/ExecutableObjectIF.h"
|
||||
|
||||
#include <thread>
|
||||
|
@ -38,7 +38,6 @@ FixedTimeslotTask::~FixedTimeslotTask(void) {
|
|||
if(mainThread.joinable()) {
|
||||
mainThread.join();
|
||||
}
|
||||
delete this;
|
||||
}
|
||||
|
||||
void FixedTimeslotTask::taskEntryPoint(void* argument) {
|
||||
|
@ -119,8 +118,11 @@ ReturnValue_t FixedTimeslotTask::addSlot(object_id_t componentId,
|
|||
}
|
||||
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::error << "Component " << std::hex << componentId <<
|
||||
" not found, not adding it to pst" << std::endl;
|
||||
sif::error << "Component " << std::hex << "0x" << componentId << "not found, "
|
||||
"not adding it to PST.." << std::dec << std::endl;
|
||||
#else
|
||||
sif::printError("Component 0x%08x not found, not adding it to PST..\n",
|
||||
static_cast<unsigned int>(componentId));
|
||||
#endif
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
}
|
||||
|
|
|
@ -64,9 +64,8 @@ ReturnValue_t MessageQueue::receiveMessage(MessageQueueMessageIF* message) {
|
|||
return MessageQueueIF::EMPTY;
|
||||
}
|
||||
MutexGuard mutexLock(queueLock, MutexIF::TimeoutType::WAITING, 20);
|
||||
MessageQueueMessage* currentMessage = &messageQueue.front();
|
||||
std::copy(currentMessage->getBuffer(),
|
||||
currentMessage->getBuffer() + messageSize, message->getBuffer());
|
||||
std::copy(messageQueue.front().data(), messageQueue.front().data() + messageSize,
|
||||
message->getBuffer());
|
||||
messageQueue.pop();
|
||||
// The last partner is the first uint32_t field in the message
|
||||
this->lastPartner = message->getSender();
|
||||
|
@ -80,7 +79,7 @@ MessageQueueId_t MessageQueue::getLastPartner() const {
|
|||
ReturnValue_t MessageQueue::flush(uint32_t* count) {
|
||||
*count = messageQueue.size();
|
||||
// Clears the queue.
|
||||
messageQueue = std::queue<MessageQueueMessage>();
|
||||
messageQueue = std::queue<std::vector<uint8_t>>();
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
||||
|
@ -106,6 +105,9 @@ bool MessageQueue::isDefaultDestinationSet() const {
|
|||
ReturnValue_t MessageQueue::sendMessageFromMessageQueue(MessageQueueId_t sendTo,
|
||||
MessageQueueMessageIF* message, MessageQueueId_t sentFrom,
|
||||
bool ignoreFault) {
|
||||
if(message == nullptr) {
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
}
|
||||
message->setSender(sentFrom);
|
||||
if(message->getMessageSize() > message->getMaximumMessageSize()) {
|
||||
// Actually, this should never happen or an error will be emitted
|
||||
|
@ -128,21 +130,10 @@ ReturnValue_t MessageQueue::sendMessageFromMessageQueue(MessageQueueId_t sendTo,
|
|||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
}
|
||||
if(targetQueue->messageQueue.size() < targetQueue->messageDepth) {
|
||||
MutexGuard mutexLock(targetQueue->queueLock,
|
||||
MutexIF::TimeoutType::WAITING, 20);
|
||||
// not ideal, works for now though.
|
||||
MessageQueueMessage* mqmMessage =
|
||||
dynamic_cast<MessageQueueMessage*>(message);
|
||||
if(message != nullptr) {
|
||||
targetQueue->messageQueue.push(*mqmMessage);
|
||||
}
|
||||
else {
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::error << "MessageQueue::sendMessageFromMessageQueue: Message"
|
||||
"is not MessageQueueMessage!" << std::endl;
|
||||
#endif
|
||||
}
|
||||
|
||||
MutexGuard mutexLock(targetQueue->queueLock, MutexIF::TimeoutType::WAITING, 20);
|
||||
targetQueue->messageQueue.push(std::vector<uint8_t>(message->getMaximumMessageSize()));
|
||||
memcpy(targetQueue->messageQueue.back().data(), message->getBuffer(),
|
||||
message->getMaximumMessageSize());
|
||||
}
|
||||
else {
|
||||
return MessageQueueIF::FULL;
|
||||
|
|
|
@ -212,7 +212,7 @@ protected:
|
|||
//static ReturnValue_t handleSendResult(BaseType_t result, bool ignoreFault);
|
||||
|
||||
private:
|
||||
std::queue<MessageQueueMessage> messageQueue;
|
||||
std::queue<std::vector<uint8_t>> messageQueue;
|
||||
/**
|
||||
* @brief The class stores the queue id it got assigned.
|
||||
* If initialization fails, the queue id is set to zero.
|
||||
|
|
|
@ -21,7 +21,7 @@ PeriodicTask::PeriodicTask(const char *name, TaskPriority setPriority,
|
|||
void (*setDeadlineMissedFunc)()) :
|
||||
started(false), taskName(name), period(setPeriod),
|
||||
deadlineMissedFunc(setDeadlineMissedFunc) {
|
||||
// It is propably possible to set task priorities by using the native
|
||||
// It is probably possible to set task priorities by using the native
|
||||
// task handles for Windows / Linux
|
||||
mainThread = std::thread(&PeriodicTask::taskEntryPoint, this, this);
|
||||
#if defined(_WIN32)
|
||||
|
@ -38,7 +38,6 @@ PeriodicTask::~PeriodicTask(void) {
|
|||
if(mainThread.joinable()) {
|
||||
mainThread.join();
|
||||
}
|
||||
delete this;
|
||||
}
|
||||
|
||||
void PeriodicTask::taskEntryPoint(void* argument) {
|
||||
|
|
|
@ -10,6 +10,10 @@ QueueMapManager::QueueMapManager() {
|
|||
mapLock = MutexFactory::instance()->createMutex();
|
||||
}
|
||||
|
||||
QueueMapManager::~QueueMapManager() {
|
||||
MutexFactory::instance()->deleteMutex(mapLock);
|
||||
}
|
||||
|
||||
QueueMapManager* QueueMapManager::instance() {
|
||||
if (mqManagerInstance == nullptr){
|
||||
mqManagerInstance = new QueueMapManager();
|
||||
|
|
|
@ -36,6 +36,8 @@ public:
|
|||
private:
|
||||
//! External instantiation is forbidden.
|
||||
QueueMapManager();
|
||||
~QueueMapManager();
|
||||
|
||||
uint32_t queueCounter = 0;
|
||||
MutexIF* mapLock;
|
||||
QueueMap queueMap;
|
||||
|
|
|
@ -373,7 +373,7 @@ ReturnValue_t MessageQueue::sendMessageFromMessageQueue(MessageQueueId_t sendTo,
|
|||
<<"mq_send to: " << sendTo << " sent from "
|
||||
<< sentFrom << std::endl;
|
||||
#endif
|
||||
return DESTINVATION_INVALID;
|
||||
return DESTINATION_INVALID;
|
||||
}
|
||||
case EINTR:
|
||||
//The call was interrupted by a signal.
|
||||
|
|
|
@ -184,8 +184,11 @@ void PosixThread::createTask(void* (*fnc_)(void*), void* arg_) {
|
|||
strerror(status) << std::endl;
|
||||
#endif
|
||||
}
|
||||
|
||||
// TODO FIFO -> This needs root privileges for the process
|
||||
#ifndef FSFW_USE_REALTIME_FOR_LINUX
|
||||
#error "Please define FSFW_USE_REALTIME_FOR_LINUX with either 0 or 1"
|
||||
#endif
|
||||
#if FSFW_USE_REALTIME_FOR_LINUX == 1
|
||||
// FIFO -> This needs root privileges for the process
|
||||
status = pthread_attr_setschedpolicy(&attributes,SCHED_FIFO);
|
||||
if(status != 0){
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
|
@ -203,7 +206,7 @@ void PosixThread::createTask(void* (*fnc_)(void*), void* arg_) {
|
|||
strerror(status) << std::endl;
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif
|
||||
//Set Signal Mask for suspend until startTask is called
|
||||
sigset_t waitSignal;
|
||||
sigemptyset(&waitSignal);
|
||||
|
@ -220,8 +223,16 @@ void PosixThread::createTask(void* (*fnc_)(void*), void* arg_) {
|
|||
status = pthread_create(&thread,&attributes,fnc_,arg_);
|
||||
if(status != 0){
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::error << "Posix Thread create failed with: " <<
|
||||
sif::error << "PosixThread::createTask: Failed with: " <<
|
||||
strerror(status) << std::endl;
|
||||
sif::error << "For FSFW_USE_REALTIME_FOR_LINUX == 1 make sure to call " <<
|
||||
"\"all sudo setcap 'cap_sys_nice=eip'\" on the application or set "
|
||||
"/etc/security/limit.conf" << std::endl;
|
||||
#else
|
||||
sif::printError("PosixThread::createTask: Create failed with: %s\n", strerror(status));
|
||||
sif::printError("For FSFW_USE_REALTIME_FOR_LINUX == 1 make sure to call "
|
||||
"\"all sudo setcap 'cap_sys_nice=eip'\" on the application or set "
|
||||
"/etc/security/limit.conf\n");
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#include "../common/tcpipHelpers.h"
|
||||
|
||||
#include "../../serviceinterface/ServiceInterface.h"
|
||||
#include "../../tasks/TaskFactory.h"
|
||||
|
||||
#include <errno.h>
|
||||
|
@ -98,8 +99,8 @@ void tcpip::handleError(Protocol protocol, ErrorSources errorSrc, dur_millis_t s
|
|||
sif::warning << "tcpip::handleError: " << protocolString << " | " << errorSrcString <<
|
||||
" | " << infoString << std::endl;
|
||||
#else
|
||||
sif::printWarning("tcpip::handleError: %s | %s | %s\n", protocolString,
|
||||
errorSrcString, infoString);
|
||||
sif::printWarning("tcpip::handleError: %s | %s | %s\n", protocolString.c_str(),
|
||||
errorSrcString.c_str(), infoString.c_str());
|
||||
#endif /* FSFW_CPP_OSTREAM_ENABLED == 1 */
|
||||
|
||||
if(sleepDuration > 0) {
|
||||
|
|
|
@ -61,8 +61,7 @@ ReturnValue_t CService200ModeCommanding::prepareCommand(
|
|||
return result;
|
||||
}
|
||||
|
||||
ModeMessage::setModeMessage(dynamic_cast<CommandMessage*>(message),
|
||||
ModeMessage::CMD_MODE_COMMAND, modeCommandPacket.getMode(),
|
||||
ModeMessage::setModeMessage(message, ModeMessage::CMD_MODE_COMMAND, modeCommandPacket.getMode(),
|
||||
modeCommandPacket.getSubmode());
|
||||
return result;
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#include "Service17Test.h"
|
||||
#include <FSFWConfig.h>
|
||||
|
||||
#include "../serviceinterface/ServiceInterfaceStream.h"
|
||||
#include "../serviceinterface/ServiceInterface.h"
|
||||
#include "../objectmanager/SystemObject.h"
|
||||
#include "../tmtcpacket/pus/TmPacketStored.h"
|
||||
|
||||
|
@ -17,15 +18,25 @@ Service17Test::~Service17Test() {
|
|||
ReturnValue_t Service17Test::handleRequest(uint8_t subservice) {
|
||||
switch(subservice) {
|
||||
case Subservice::CONNECTION_TEST: {
|
||||
TmPacketStored connectionPacket(apid, serviceId,
|
||||
#if FSFW_USE_PUS_C_TELEMETRY == 0
|
||||
TmPacketStoredPusA connectionPacket(apid, serviceId,
|
||||
Subservice::CONNECTION_TEST_REPORT, packetSubCounter++);
|
||||
#else
|
||||
TmPacketStoredPusC connectionPacket(apid, serviceId,
|
||||
Subservice::CONNECTION_TEST_REPORT, packetSubCounter++);
|
||||
#endif
|
||||
connectionPacket.sendPacket(requestQueue->getDefaultDestination(),
|
||||
requestQueue->getId());
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
case Subservice::EVENT_TRIGGER_TEST: {
|
||||
TmPacketStored connectionPacket(apid, serviceId,
|
||||
#if FSFW_USE_PUS_C_TELEMETRY == 0
|
||||
TmPacketStoredPusA connectionPacket(apid, serviceId,
|
||||
Subservice::CONNECTION_TEST_REPORT, packetSubCounter++);
|
||||
#else
|
||||
TmPacketStoredPusC connectionPacket(apid, serviceId,
|
||||
Subservice::CONNECTION_TEST_REPORT, packetSubCounter++);
|
||||
#endif
|
||||
connectionPacket.sendPacket(requestQueue->getDefaultDestination(),
|
||||
requestQueue->getId());
|
||||
triggerEvent(TEST, 1234, 5678);
|
||||
|
|
|
@ -15,7 +15,9 @@ Service1TelecommandVerification::Service1TelecommandVerification(
|
|||
tmQueue = QueueFactory::instance()->createMessageQueue(messageQueueDepth);
|
||||
}
|
||||
|
||||
Service1TelecommandVerification::~Service1TelecommandVerification() {}
|
||||
Service1TelecommandVerification::~Service1TelecommandVerification() {
|
||||
QueueFactory::instance()->deleteMessageQueue(tmQueue);
|
||||
}
|
||||
|
||||
MessageQueueId_t Service1TelecommandVerification::getVerificationQueue(){
|
||||
return tmQueue->getId();
|
||||
|
@ -66,8 +68,13 @@ ReturnValue_t Service1TelecommandVerification::generateFailureReport(
|
|||
message->getTcSequenceControl(), message->getStep(),
|
||||
message->getErrorCode(), message->getParameter1(),
|
||||
message->getParameter2());
|
||||
TmPacketStored tmPacket(apid, serviceId, message->getReportId(),
|
||||
#if FSFW_USE_PUS_C_TELEMETRY == 0
|
||||
TmPacketStoredPusA tmPacket(apid, serviceId, message->getReportId(),
|
||||
packetSubCounter++, &report);
|
||||
#else
|
||||
TmPacketStoredPusC tmPacket(apid, serviceId, message->getReportId(),
|
||||
packetSubCounter++, &report);
|
||||
#endif
|
||||
ReturnValue_t result = tmPacket.sendPacket(tmQueue->getDefaultDestination(),
|
||||
tmQueue->getId());
|
||||
return result;
|
||||
|
@ -77,8 +84,13 @@ ReturnValue_t Service1TelecommandVerification::generateSuccessReport(
|
|||
PusVerificationMessage *message) {
|
||||
SuccessReport report(message->getReportId(),message->getTcPacketId(),
|
||||
message->getTcSequenceControl(),message->getStep());
|
||||
TmPacketStored tmPacket(apid, serviceId, message->getReportId(),
|
||||
#if FSFW_USE_PUS_C_TELEMETRY == 0
|
||||
TmPacketStoredPusA tmPacket(apid, serviceId, message->getReportId(),
|
||||
packetSubCounter++, &report);
|
||||
#else
|
||||
TmPacketStoredPusC tmPacket(apid, serviceId, message->getReportId(),
|
||||
packetSubCounter++, &report);
|
||||
#endif
|
||||
ReturnValue_t result = tmPacket.sendPacket(tmQueue->getDefaultDestination(),
|
||||
tmQueue->getId());
|
||||
return result;
|
||||
|
|
|
@ -75,9 +75,8 @@ ReturnValue_t Service20ParameterManagement::checkInterfaceAndAcquireMessageQueue
|
|||
#else
|
||||
sif::printError("Service20ParameterManagement::checkInterfaceAndAcquire"
|
||||
"MessageQueue: Can't access object\n");
|
||||
sif::printError("Object ID: 0x%08x\n", objectId);
|
||||
sif::printError("Make sure it implements "
|
||||
"ReceivesParameterMessagesIF!\n");
|
||||
sif::printError("Object ID: 0x%08x\n", *objectId);
|
||||
sif::printError("Make sure it implements ReceivesParameterMessagesIF!\n");
|
||||
#endif
|
||||
|
||||
return CommandingServiceBase::INVALID_OBJECT;
|
||||
|
|
|
@ -15,7 +15,9 @@ Service5EventReporting::Service5EventReporting(object_id_t objectId,
|
|||
eventQueue = QueueFactory::instance()->createMessageQueue(messageQueueDepth);
|
||||
}
|
||||
|
||||
Service5EventReporting::~Service5EventReporting(){}
|
||||
Service5EventReporting::~Service5EventReporting() {
|
||||
QueueFactory::instance()->deleteMessageQueue(eventQueue);
|
||||
}
|
||||
|
||||
ReturnValue_t Service5EventReporting::performService() {
|
||||
EventMessage message;
|
||||
|
@ -50,8 +52,13 @@ ReturnValue_t Service5EventReporting::generateEventReport(
|
|||
{
|
||||
EventReport report(message.getEventId(),message.getReporter(),
|
||||
message.getParameter1(),message.getParameter2());
|
||||
TmPacketStored tmPacket(PusServiceBase::apid, PusServiceBase::serviceId,
|
||||
#if FSFW_USE_PUS_C_TELEMETRY == 0
|
||||
TmPacketStoredPusA tmPacket(PusServiceBase::apid, PusServiceBase::serviceId,
|
||||
message.getSeverity(), packetSubCounter++, &report);
|
||||
#else
|
||||
TmPacketStoredPusC tmPacket(PusServiceBase::apid, PusServiceBase::serviceId,
|
||||
message.getSeverity(), packetSubCounter++, &report);
|
||||
#endif
|
||||
ReturnValue_t result = tmPacket.sendPacket(
|
||||
requestQueue->getDefaultDestination(),requestQueue->getId());
|
||||
if(result != HasReturnvaluesIF::RETURN_OK) {
|
||||
|
|
|
@ -53,12 +53,14 @@ ReturnValue_t Service8FunctionManagement::checkInterfaceAndAcquireMessageQueue(
|
|||
ReturnValue_t Service8FunctionManagement::prepareCommand(
|
||||
CommandMessage* message, uint8_t subservice, const uint8_t* tcData,
|
||||
size_t tcDataLen, uint32_t* state, object_id_t objectId) {
|
||||
return prepareDirectCommand(dynamic_cast<CommandMessage*>(message),
|
||||
tcData, tcDataLen);
|
||||
return prepareDirectCommand(message, tcData, tcDataLen);
|
||||
}
|
||||
|
||||
ReturnValue_t Service8FunctionManagement::prepareDirectCommand(
|
||||
CommandMessage *message, const uint8_t *tcData, size_t tcDataLen) {
|
||||
if(message == nullptr) {
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
}
|
||||
if(tcDataLen < sizeof(object_id_t) + sizeof(ActionId_t)) {
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::debug << "Service8FunctionManagement::prepareDirectCommand:"
|
||||
|
|
|
@ -43,8 +43,8 @@ public:
|
|||
|
||||
private:
|
||||
DirectCommand(const DirectCommand &command);
|
||||
object_id_t objectId;
|
||||
ActionId_t actionId;
|
||||
object_id_t objectId = 0;
|
||||
ActionId_t actionId = 0;
|
||||
uint32_t parametersSize; //!< [EXPORT] : [IGNORE]
|
||||
const uint8_t * parameterBuffer; //!< [EXPORT] : [MAXSIZE] 65535 Bytes
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@ public:
|
|||
|
||||
}
|
||||
SerializeElement() :
|
||||
LinkedElement<SerializeIF>(this) {
|
||||
LinkedElement<SerializeIF>(this), entry() {
|
||||
}
|
||||
|
||||
ReturnValue_t serialize(uint8_t **buffer, size_t *size, size_t maxSize,
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
#include "CCSDSDistributor.h"
|
||||
|
||||
#include "../serviceinterface/ServiceInterfaceStream.h"
|
||||
#include "../serviceinterface/ServiceInterface.h"
|
||||
#include "../tmtcpacket/SpacePacketBase.h"
|
||||
|
||||
#define CCSDS_DISTRIBUTOR_DEBUGGING 0
|
||||
|
||||
CCSDSDistributor::CCSDSDistributor(uint16_t setDefaultApid,
|
||||
object_id_t setObjectId):
|
||||
TcDistributor(setObjectId), defaultApid( setDefaultApid ) {
|
||||
|
@ -11,26 +13,36 @@ CCSDSDistributor::CCSDSDistributor(uint16_t setDefaultApid,
|
|||
CCSDSDistributor::~CCSDSDistributor() {}
|
||||
|
||||
TcDistributor::TcMqMapIter CCSDSDistributor::selectDestination() {
|
||||
#if CCSDS_DISTRIBUTOR_DEBUGGING == 1
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
// sif::debug << "CCSDSDistributor::selectDestination received: " <<
|
||||
// this->currentMessage.getStorageId().pool_index << ", " <<
|
||||
// this->currentMessage.getStorageId().packet_index << std::endl;
|
||||
sif::debug << "CCSDSDistributor::selectDestination received: " <<
|
||||
this->currentMessage.getStorageId().poolIndex << ", " <<
|
||||
this->currentMessage.getStorageId().packetIndex << std::endl;
|
||||
#else
|
||||
sif::printDebug("CCSDSDistributor::selectDestination received: %d, %d\n",
|
||||
currentMessage.getStorageId().poolIndex, currentMessage.getStorageId().packetIndex);
|
||||
#endif
|
||||
#endif
|
||||
const uint8_t* packet = nullptr;
|
||||
size_t size = 0;
|
||||
ReturnValue_t result = this->tcStore->getData(currentMessage.getStorageId(),
|
||||
&packet, &size );
|
||||
if(result != HasReturnvaluesIF::RETURN_OK) {
|
||||
#if FSFW_VERBOSE_LEVEL >= 1
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::error << "CCSDSDistributor::selectDestination: Getting data from"
|
||||
" store failed!" << std::endl;
|
||||
#else
|
||||
sif::printError("CCSDSDistributor::selectDestination: Getting data from"
|
||||
" store failed!\n");
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
SpacePacketBase currentPacket(packet);
|
||||
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
// sif:: info << "CCSDSDistributor::selectDestination has packet with APID "
|
||||
// << std::hex << currentPacket.getAPID() << std::dec << std::endl;
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1 && CCSDS_DISTRIBUTOR_DEBUGGING == 1
|
||||
sif::info << "CCSDSDistributor::selectDestination has packet with APID " << std::hex <<
|
||||
currentPacket.getAPID() << std::dec << std::endl;
|
||||
#endif
|
||||
TcMqMapIter position = this->queueMap.find(currentPacket.getAPID());
|
||||
if ( position != this->queueMap.end() ) {
|
||||
|
@ -76,9 +88,14 @@ ReturnValue_t CCSDSDistributor::initialize() {
|
|||
ReturnValue_t status = this->TcDistributor::initialize();
|
||||
this->tcStore = objectManager->get<StorageManagerIF>( objects::TC_STORE );
|
||||
if (this->tcStore == nullptr) {
|
||||
#if FSFW_VERBOSE_LEVEL >= 1
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::error << "CCSDSDistributor::initialize: Could not initialize"
|
||||
" TC store!" << std::endl;
|
||||
#else
|
||||
sif::printError("CCSDSDistributor::initialize: Could not initialize"
|
||||
" TC store!\n");
|
||||
#endif
|
||||
#endif
|
||||
status = RETURN_FAILED;
|
||||
}
|
||||
|
|
|
@ -1,22 +1,24 @@
|
|||
#include "CCSDSDistributorIF.h"
|
||||
#include "PUSDistributor.h"
|
||||
|
||||
#include "../serviceinterface/ServiceInterfaceStream.h"
|
||||
#include "../serviceinterface/ServiceInterface.h"
|
||||
#include "../tmtcpacket/pus/TcPacketStored.h"
|
||||
#include "../tmtcservices/PusVerificationReport.h"
|
||||
|
||||
#define PUS_DISTRIBUTOR_DEBUGGING 0
|
||||
|
||||
PUSDistributor::PUSDistributor(uint16_t setApid, object_id_t setObjectId,
|
||||
object_id_t setPacketSource) :
|
||||
TcDistributor(setObjectId), checker(setApid), verifyChannel(),
|
||||
tcStatus(RETURN_FAILED), packetSource(setPacketSource) {}
|
||||
object_id_t setPacketSource) :
|
||||
TcDistributor(setObjectId), checker(setApid), verifyChannel(),
|
||||
tcStatus(RETURN_FAILED), packetSource(setPacketSource) {}
|
||||
|
||||
PUSDistributor::~PUSDistributor() {}
|
||||
|
||||
PUSDistributor::TcMqMapIter PUSDistributor::selectDestination() {
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
// sif:: debug << "PUSDistributor::handlePacket received: "
|
||||
// << this->current_packet_id.store_index << ", "
|
||||
// << this->current_packet_id.packet_index << std::endl;
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1 && PUS_DISTRIBUTOR_DEBUGGING == 1
|
||||
store_address_t storeId = this->currentMessage.getStorageId());
|
||||
sif:: debug << "PUSDistributor::handlePacket received: " << storeId.poolIndex << ", " <<
|
||||
storeId.packetIndex << std::endl;
|
||||
#endif
|
||||
TcMqMapIter queueMapIt = this->queueMap.end();
|
||||
if(this->currentPacket == nullptr) {
|
||||
|
@ -25,15 +27,17 @@ PUSDistributor::TcMqMapIter PUSDistributor::selectDestination() {
|
|||
this->currentPacket->setStoreAddress(this->currentMessage.getStorageId());
|
||||
if (currentPacket->getWholeData() != nullptr) {
|
||||
tcStatus = checker.checkPacket(currentPacket);
|
||||
#ifdef DEBUG
|
||||
if(tcStatus != HasReturnvaluesIF::RETURN_OK) {
|
||||
#if FSFW_VERBOSE_LEVEL >= 1
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::debug << "PUSDistributor::handlePacket: Packet format "
|
||||
<< "invalid, code "<< static_cast<int>(tcStatus)
|
||||
<< std::endl;
|
||||
sif::debug << "PUSDistributor::handlePacket: Packet format invalid, code " <<
|
||||
static_cast<int>(tcStatus) << std::endl;
|
||||
#else
|
||||
sif::printDebug("PUSDistributor::handlePacket: Packet format invalid, code %d\n",
|
||||
static_cast<int>(tcStatus));
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
uint32_t queue_id = currentPacket->getService();
|
||||
queueMapIt = this->queueMap.find(queue_id);
|
||||
}
|
||||
|
@ -43,11 +47,12 @@ PUSDistributor::TcMqMapIter PUSDistributor::selectDestination() {
|
|||
|
||||
if (queueMapIt == this->queueMap.end()) {
|
||||
tcStatus = DESTINATION_NOT_FOUND;
|
||||
#ifdef DEBUG
|
||||
#if FSFW_VERBOSE_LEVEL >= 1
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::debug << "PUSDistributor::handlePacket: Destination not found, "
|
||||
<< "code "<< static_cast<int>(tcStatus) << std::endl;
|
||||
#endif
|
||||
sif::debug << "PUSDistributor::handlePacket: Destination not found" << std::endl;
|
||||
#else
|
||||
sif::printDebug("PUSDistributor::handlePacket: Destination not found\n");
|
||||
#endif /* !FSFW_CPP_OSTREAM_ENABLED == 1 */
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -62,46 +67,54 @@ PUSDistributor::TcMqMapIter PUSDistributor::selectDestination() {
|
|||
|
||||
|
||||
ReturnValue_t PUSDistributor::registerService(AcceptsTelecommandsIF* service) {
|
||||
uint16_t serviceId = service->getIdentifier();
|
||||
uint16_t serviceId = service->getIdentifier();
|
||||
#if PUS_DISTRIBUTOR_DEBUGGING == 1
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
// sif::info << "Service ID: " << (int)serviceId << std::endl;
|
||||
sif::info << "Service ID: " << static_cast<int>(serviceId) << std::endl;
|
||||
#else
|
||||
sif::printInfo("Service ID: %d\n", static_cast<int>(serviceId));
|
||||
#endif
|
||||
MessageQueueId_t queue = service->getRequestQueue();
|
||||
auto returnPair = queueMap.emplace(serviceId, queue);
|
||||
if (not returnPair.second) {
|
||||
#endif
|
||||
MessageQueueId_t queue = service->getRequestQueue();
|
||||
auto returnPair = queueMap.emplace(serviceId, queue);
|
||||
if (not returnPair.second) {
|
||||
#if FSFW_VERBOSE_LEVEL >= 1
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::error << "PUSDistributor::registerService: Service ID already"
|
||||
" exists in map." << std::endl;
|
||||
sif::error << "PUSDistributor::registerService: Service ID already"
|
||||
" exists in map" << std::endl;
|
||||
#else
|
||||
sif::printError("PUSDistributor::registerService: Service ID already exists in map\n");
|
||||
#endif
|
||||
return SERVICE_ID_ALREADY_EXISTS;
|
||||
}
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
#endif
|
||||
return SERVICE_ID_ALREADY_EXISTS;
|
||||
}
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
||||
MessageQueueId_t PUSDistributor::getRequestQueue() {
|
||||
return tcQueue->getId();
|
||||
return tcQueue->getId();
|
||||
}
|
||||
|
||||
ReturnValue_t PUSDistributor::callbackAfterSending(ReturnValue_t queueStatus) {
|
||||
if (queueStatus != RETURN_OK) {
|
||||
tcStatus = queueStatus;
|
||||
}
|
||||
if (tcStatus != RETURN_OK) {
|
||||
this->verifyChannel.sendFailureReport(tc_verification::ACCEPTANCE_FAILURE,
|
||||
currentPacket, tcStatus);
|
||||
// A failed packet is deleted immediately after reporting,
|
||||
// otherwise it will block memory.
|
||||
currentPacket->deletePacket();
|
||||
return RETURN_FAILED;
|
||||
} else {
|
||||
this->verifyChannel.sendSuccessReport(tc_verification::ACCEPTANCE_SUCCESS,
|
||||
currentPacket);
|
||||
return RETURN_OK;
|
||||
}
|
||||
if (queueStatus != RETURN_OK) {
|
||||
tcStatus = queueStatus;
|
||||
}
|
||||
if (tcStatus != RETURN_OK) {
|
||||
this->verifyChannel.sendFailureReport(tc_verification::ACCEPTANCE_FAILURE,
|
||||
currentPacket, tcStatus);
|
||||
// A failed packet is deleted immediately after reporting,
|
||||
// otherwise it will block memory.
|
||||
currentPacket->deletePacket();
|
||||
return RETURN_FAILED;
|
||||
} else {
|
||||
this->verifyChannel.sendSuccessReport(tc_verification::ACCEPTANCE_SUCCESS,
|
||||
currentPacket);
|
||||
return RETURN_OK;
|
||||
}
|
||||
}
|
||||
|
||||
uint16_t PUSDistributor::getIdentifier() {
|
||||
return checker.getApid();
|
||||
return checker.getApid();
|
||||
}
|
||||
|
||||
ReturnValue_t PUSDistributor::initialize() {
|
||||
|
@ -111,15 +124,17 @@ ReturnValue_t PUSDistributor::initialize() {
|
|||
return ObjectManagerIF::CHILD_INIT_FAILED;
|
||||
}
|
||||
|
||||
CCSDSDistributorIF* ccsdsDistributor =
|
||||
objectManager->get<CCSDSDistributorIF>(packetSource);
|
||||
if (ccsdsDistributor == nullptr) {
|
||||
CCSDSDistributorIF* ccsdsDistributor =
|
||||
objectManager->get<CCSDSDistributorIF>(packetSource);
|
||||
if (ccsdsDistributor == nullptr) {
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::error << "PUSDistributor::initialize: Packet source invalid."
|
||||
<< " Make sure it exists and implements CCSDSDistributorIF!"
|
||||
<< std::endl;
|
||||
sif::error << "PUSDistributor::initialize: Packet source invalid" << std::endl;
|
||||
sif::error << " Make sure it exists and implements CCSDSDistributorIF!" << std::endl;
|
||||
#else
|
||||
sif::printError("PUSDistributor::initialize: Packet source invalid\n");
|
||||
sif::printError("Make sure it exists and implements CCSDSDistributorIF\n");
|
||||
#endif
|
||||
return RETURN_FAILED;
|
||||
}
|
||||
return ccsdsDistributor->registerApplication(this);
|
||||
return RETURN_FAILED;
|
||||
}
|
||||
return ccsdsDistributor->registerApplication(this);
|
||||
}
|
||||
|
|
|
@ -286,7 +286,10 @@ void Heater::handleQueue() {
|
|||
if (result == HasReturnvaluesIF::RETURN_OK) {
|
||||
return;
|
||||
}
|
||||
parameterHelper.handleParameterMessage(&command);
|
||||
result = parameterHelper.handleParameterMessage(&command);
|
||||
if (result == HasReturnvaluesIF::RETURN_OK) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,11 +1,14 @@
|
|||
#ifndef TEMPERATURESENSOR_H_
|
||||
#define TEMPERATURESENSOR_H_
|
||||
|
||||
#include "../thermal/AbstractTemperatureSensor.h"
|
||||
#include "../datapoolglob/GlobalDataSet.h"
|
||||
#include "../datapoolglob/GlobalPoolVariable.h"
|
||||
#include "tcsDefinitions.h"
|
||||
#include "AbstractTemperatureSensor.h"
|
||||
|
||||
#include "../datapoollocal/LocalPoolDataSetBase.h"
|
||||
#include "../datapoollocal/LocalPoolVariable.h"
|
||||
#include "../monitoring/LimitMonitor.h"
|
||||
|
||||
|
||||
/**
|
||||
* @brief This building block handles non-linear value conversion and
|
||||
* range checks for analog temperature sensors.
|
||||
|
@ -57,27 +60,26 @@ public:
|
|||
|
||||
/**
|
||||
* Instantiate Temperature Sensor Object.
|
||||
* @param setObjectid objectId of the sensor object
|
||||
* @param inputValue Input value which is converted to a temperature
|
||||
* @param poolVariable Pool Variable to store the temperature value
|
||||
* @param vectorIndex Vector Index for the sensor monitor
|
||||
* @param parameters Calculation parameters, temperature limits, gradient limit
|
||||
* @param datapoolId Datapool ID of the output temperature
|
||||
* @param outputSet Output dataset for the output temperature to fetch it with read()
|
||||
* @param setObjectid objectId of the sensor object
|
||||
* @param inputValue Pointer to input value which is converted to a temperature
|
||||
* @param variableGpid Global Pool ID of the output value
|
||||
* @param inputVariable Input variable handle
|
||||
* @param vectorIndex Vector Index for the sensor monitor
|
||||
* @param parameters Calculation parameters, temperature limits, gradient limit
|
||||
* @param outputSet Output dataset for the output temperature to fetch it with read()
|
||||
* @param thermalModule respective thermal module, if it has one
|
||||
*/
|
||||
TemperatureSensor(object_id_t setObjectid,
|
||||
inputType *inputValue, PoolVariableIF *poolVariable,
|
||||
uint8_t vectorIndex, uint32_t datapoolId, Parameters parameters = {0, 0, 0, 0, 0, 0},
|
||||
GlobDataSet *outputSet = NULL, ThermalModuleIF *thermalModule = NULL) :
|
||||
inputType *inputValue, gp_id_t variableGpid, PoolVariableIF* inputVariable,
|
||||
uint8_t vectorIndex, Parameters parameters = {0, 0, 0, 0, 0, 0},
|
||||
LocalPoolDataSetBase *outputSet = NULL, ThermalModuleIF *thermalModule = NULL) :
|
||||
AbstractTemperatureSensor(setObjectid, thermalModule), parameters(parameters),
|
||||
inputValue(inputValue), poolVariable(poolVariable),
|
||||
outputTemperature(datapoolId, outputSet, PoolVariableIF::VAR_WRITE),
|
||||
sensorMonitor(setObjectid, DOMAIN_ID_SENSOR,
|
||||
GlobalDataPool::poolIdAndPositionToPid(poolVariable->getDataPoolId(), vectorIndex),
|
||||
inputValue(inputValue), poolVariable(inputVariable),
|
||||
outputTemperature(variableGpid, outputSet, PoolVariableIF::VAR_WRITE),
|
||||
sensorMonitor(setObjectid, DOMAIN_ID_SENSOR, poolVariable,
|
||||
DEFAULT_CONFIRMATION_COUNT, parameters.lowerLimit, parameters.upperLimit,
|
||||
TEMP_SENSOR_LOW, TEMP_SENSOR_HIGH),
|
||||
oldTemperature(20), uptimeOfOldTemperature( { INVALID_TEMPERATURE, 0 }) {
|
||||
oldTemperature(20), uptimeOfOldTemperature({ thermal::INVALID_TEMPERATURE, 0 }) {
|
||||
}
|
||||
|
||||
|
||||
|
@ -98,7 +100,7 @@ protected:
|
|||
|
||||
private:
|
||||
void setInvalid() {
|
||||
outputTemperature = INVALID_TEMPERATURE;
|
||||
outputTemperature = thermal::INVALID_TEMPERATURE;
|
||||
outputTemperature.setValid(false);
|
||||
uptimeOfOldTemperature.tv_sec = INVALID_UPTIME;
|
||||
sensorMonitor.setToInvalid();
|
||||
|
@ -108,11 +110,11 @@ protected:
|
|||
|
||||
UsedParameters parameters;
|
||||
|
||||
inputType * inputValue;
|
||||
inputType* inputValue;
|
||||
|
||||
PoolVariableIF *poolVariable;
|
||||
PoolVariableIF* poolVariable;
|
||||
|
||||
gp_float_t outputTemperature;
|
||||
lp_var_t<float> outputTemperature;
|
||||
|
||||
LimitMonitor<limitType> sensorMonitor;
|
||||
|
||||
|
@ -120,8 +122,8 @@ protected:
|
|||
timeval uptimeOfOldTemperature;
|
||||
|
||||
void doChildOperation() {
|
||||
if (!poolVariable->isValid()
|
||||
|| !healthHelper.healthTable->isHealthy(getObjectId())) {
|
||||
if ((not poolVariable->isValid()) or
|
||||
(not healthHelper.healthTable->isHealthy(getObjectId()))) {
|
||||
setInvalid();
|
||||
return;
|
||||
}
|
||||
|
@ -152,13 +154,13 @@ protected:
|
|||
}
|
||||
}
|
||||
|
||||
//Check is done against raw limits. SHOULDDO: Why? Using <EFBFBD>C would be more easy to handle.
|
||||
//Check is done against raw limits. SHOULDDO: Why? Using C would be more easy to handle.
|
||||
sensorMonitor.doCheck(outputTemperature.value);
|
||||
|
||||
if (sensorMonitor.isOutOfLimits()) {
|
||||
uptimeOfOldTemperature.tv_sec = INVALID_UPTIME;
|
||||
outputTemperature.setValid(PoolVariableIF::INVALID);
|
||||
outputTemperature = INVALID_TEMPERATURE;
|
||||
outputTemperature = thermal::INVALID_TEMPERATURE;
|
||||
} else {
|
||||
oldTemperature = outputTemperature;
|
||||
uptimeOfOldTemperature = uptime;
|
||||
|
|
|
@ -25,6 +25,6 @@ uint32_t TimeMessage::getCounterValue() {
|
|||
return temp;
|
||||
}
|
||||
|
||||
size_t TimeMessage::getMinimumMessageSize() {
|
||||
size_t TimeMessage::getMinimumMessageSize() const {
|
||||
return this->MAX_SIZE;
|
||||
}
|
||||
|
|
|
@ -11,7 +11,7 @@ protected:
|
|||
* @brief This call always returns the same fixed size of the message.
|
||||
* @return Returns HEADER_SIZE + \c sizeof(timeval) + sizeof(uint32_t).
|
||||
*/
|
||||
size_t getMinimumMessageSize();
|
||||
size_t getMinimumMessageSize() const override;
|
||||
public:
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#ifndef FSFW_TIMEMANAGER_TIMESTAMPERIF_H_
|
||||
#define FSFW_TIMEMANAGER_TIMESTAMPERIF_H_
|
||||
|
||||
#include <FSFWConfig.h>
|
||||
#include "../returnvalues/HasReturnvaluesIF.h"
|
||||
|
||||
/**
|
||||
|
@ -16,8 +17,8 @@ public:
|
|||
|
||||
//! This is a mission-specific constant and determines the total
|
||||
//! size reserved for timestamps.
|
||||
//! TODO: Default define in FSFWConfig ?
|
||||
static const uint8_t MISSION_TIMESTAMP_SIZE = 8;
|
||||
static const uint8_t MISSION_TIMESTAMP_SIZE = fsfwconfig::FSFW_MISSION_TIMESTAMP_SIZE;
|
||||
|
||||
virtual ReturnValue_t addTimeStamp(uint8_t* buffer,
|
||||
const uint8_t maxSize) = 0;
|
||||
virtual ~TimeStamperIF() {}
|
||||
|
|
|
@ -4,5 +4,9 @@ target_sources(${LIB_FSFW_NAME}
|
|||
TcPacketStored.cpp
|
||||
TmPacketBase.cpp
|
||||
TmPacketMinimal.cpp
|
||||
TmPacketStored.cpp
|
||||
TmPacketStoredPusA.cpp
|
||||
TmPacketStoredPusC.cpp
|
||||
TmPacketPusA.cpp
|
||||
TmPacketPusC.cpp
|
||||
TmPacketStoredBase.cpp
|
||||
)
|
||||
|
|
|
@ -3,119 +3,66 @@
|
|||
#include "../../globalfunctions/CRC.h"
|
||||
#include "../../globalfunctions/arrayprinter.h"
|
||||
#include "../../objectmanager/ObjectManagerIF.h"
|
||||
#include "../../serviceinterface/ServiceInterfaceStream.h"
|
||||
#include "../../serviceinterface/ServiceInterface.h"
|
||||
#include "../../timemanager/CCSDSTime.h"
|
||||
|
||||
#include <cstring>
|
||||
|
||||
TimeStamperIF* TmPacketBase::timeStamper = nullptr;
|
||||
object_id_t TmPacketBase::timeStamperId = 0;
|
||||
object_id_t TmPacketBase::timeStamperId = objects::NO_OBJECT;
|
||||
|
||||
TmPacketBase::TmPacketBase(uint8_t* setData) :
|
||||
SpacePacketBase(setData) {
|
||||
tmData = reinterpret_cast<TmPacketPointer*>(setData);
|
||||
TmPacketBase::TmPacketBase(uint8_t* setData):
|
||||
SpacePacketBase(setData) {
|
||||
}
|
||||
|
||||
TmPacketBase::~TmPacketBase() {
|
||||
//Nothing to do.
|
||||
//Nothing to do.
|
||||
}
|
||||
|
||||
uint8_t TmPacketBase::getService() {
|
||||
return tmData->data_field.service_type;
|
||||
}
|
||||
|
||||
uint8_t TmPacketBase::getSubService() {
|
||||
return tmData->data_field.service_subtype;
|
||||
}
|
||||
|
||||
uint8_t* TmPacketBase::getSourceData() {
|
||||
return &tmData->data;
|
||||
}
|
||||
|
||||
uint16_t TmPacketBase::getSourceDataSize() {
|
||||
return getPacketDataLength() - sizeof(tmData->data_field)
|
||||
- CRC_SIZE + 1;
|
||||
return getPacketDataLength() - getDataFieldSize() - CRC_SIZE + 1;
|
||||
}
|
||||
|
||||
uint16_t TmPacketBase::getErrorControl() {
|
||||
uint32_t size = getSourceDataSize() + CRC_SIZE;
|
||||
uint8_t* p_to_buffer = &tmData->data;
|
||||
return (p_to_buffer[size - 2] << 8) + p_to_buffer[size - 1];
|
||||
uint32_t size = getSourceDataSize() + CRC_SIZE;
|
||||
uint8_t* p_to_buffer = getSourceData();
|
||||
return (p_to_buffer[size - 2] << 8) + p_to_buffer[size - 1];
|
||||
}
|
||||
|
||||
void TmPacketBase::setErrorControl() {
|
||||
uint32_t full_size = getFullSize();
|
||||
uint16_t crc = CRC::crc16ccitt(getWholeData(), full_size - CRC_SIZE);
|
||||
uint32_t size = getSourceDataSize();
|
||||
getSourceData()[size] = (crc & 0XFF00) >> 8; // CRCH
|
||||
getSourceData()[size + 1] = (crc) & 0X00FF; // CRCL
|
||||
uint32_t full_size = getFullSize();
|
||||
uint16_t crc = CRC::crc16ccitt(getWholeData(), full_size - CRC_SIZE);
|
||||
uint32_t size = getSourceDataSize();
|
||||
getSourceData()[size] = (crc & 0XFF00) >> 8; // CRCH
|
||||
getSourceData()[size + 1] = (crc) & 0X00FF; // CRCL
|
||||
}
|
||||
|
||||
void TmPacketBase::setData(const uint8_t* p_Data) {
|
||||
SpacePacketBase::setData(p_Data);
|
||||
tmData = (TmPacketPointer*) p_Data;
|
||||
ReturnValue_t TmPacketBase::getPacketTime(timeval* timestamp) const {
|
||||
size_t tempSize = 0;
|
||||
return CCSDSTime::convertFromCcsds(timestamp, getPacketTimeRaw(),
|
||||
&tempSize, getTimestampSize());
|
||||
}
|
||||
|
||||
void TmPacketBase::print() {
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::debug << "TmPacketBase::print: " << std::endl;
|
||||
sif::debug << "TmPacketBase::print: " << std::endl;
|
||||
#endif
|
||||
arrayprinter::print(getWholeData(), getFullSize());
|
||||
arrayprinter::print(getWholeData(), getFullSize());
|
||||
}
|
||||
|
||||
bool TmPacketBase::checkAndSetStamper() {
|
||||
if (timeStamper == NULL) {
|
||||
timeStamper = objectManager->get<TimeStamperIF>(timeStamperId);
|
||||
if (timeStamper == NULL) {
|
||||
if (timeStamper == NULL) {
|
||||
timeStamper = objectManager->get<TimeStamperIF>(timeStamperId);
|
||||
if (timeStamper == NULL) {
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::error << "TmPacketBase::checkAndSetStamper: Stamper not found!"
|
||||
<< std::endl;
|
||||
sif::warning << "TmPacketBase::checkAndSetStamper: Stamper not found!" << std::endl;
|
||||
#else
|
||||
sif::printWarning("TmPacketBase::checkAndSetStamper: Stamper not found!\n");
|
||||
#endif
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
ReturnValue_t TmPacketBase::getPacketTime(timeval* timestamp) const {
|
||||
size_t tempSize = 0;
|
||||
return CCSDSTime::convertFromCcsds(timestamp, tmData->data_field.time,
|
||||
&tempSize, sizeof(tmData->data_field.time));
|
||||
}
|
||||
|
||||
uint8_t* TmPacketBase::getPacketTimeRaw() const{
|
||||
return tmData->data_field.time;
|
||||
|
||||
}
|
||||
|
||||
void TmPacketBase::initializeTmPacket(uint16_t apid, uint8_t service,
|
||||
uint8_t subservice, uint8_t packetSubcounter) {
|
||||
//Set primary header:
|
||||
initSpacePacketHeader(false, true, apid);
|
||||
//Set data Field Header:
|
||||
//First, set to zero.
|
||||
memset(&tmData->data_field, 0, sizeof(tmData->data_field));
|
||||
|
||||
// NOTE: In PUS-C, the PUS Version is 2 and specified for the first 4 bits.
|
||||
// The other 4 bits of the first byte are the spacecraft time reference
|
||||
// status. To change to PUS-C, set 0b00100000.
|
||||
// Set CCSDS_secondary header flag to 0, version number to 001 and ack
|
||||
// to 0000
|
||||
tmData->data_field.version_type_ack = 0b00010000;
|
||||
tmData->data_field.service_type = service;
|
||||
tmData->data_field.service_subtype = subservice;
|
||||
tmData->data_field.subcounter = packetSubcounter;
|
||||
//Timestamp packet
|
||||
if (checkAndSetStamper()) {
|
||||
timeStamper->addTimeStamp(tmData->data_field.time,
|
||||
sizeof(tmData->data_field.time));
|
||||
}
|
||||
}
|
||||
|
||||
void TmPacketBase::setSourceDataSize(uint16_t size) {
|
||||
setPacketDataLength(size + sizeof(PUSTmDataFieldHeader) + CRC_SIZE - 1);
|
||||
}
|
||||
|
||||
size_t TmPacketBase::getTimestampSize() const {
|
||||
return sizeof(tmData->data_field.time);
|
||||
}
|
||||
|
|
|
@ -10,32 +10,6 @@ namespace Factory{
|
|||
void setStaticFrameworkObjectIds();
|
||||
}
|
||||
|
||||
/**
|
||||
* This struct defines a byte-wise structured PUS TM Data Field Header.
|
||||
* Any optional fields in the header must be added or removed here.
|
||||
* Currently, no Destination field is present, but an eigth-byte representation
|
||||
* for a time tag.
|
||||
* @ingroup tmtcpackets
|
||||
*/
|
||||
struct PUSTmDataFieldHeader {
|
||||
uint8_t version_type_ack;
|
||||
uint8_t service_type;
|
||||
uint8_t service_subtype;
|
||||
uint8_t subcounter;
|
||||
// uint8_t destination;
|
||||
uint8_t time[TimeStamperIF::MISSION_TIMESTAMP_SIZE];
|
||||
};
|
||||
|
||||
/**
|
||||
* This struct defines the data structure of a PUS Telecommand Packet when
|
||||
* accessed via a pointer.
|
||||
* @ingroup tmtcpackets
|
||||
*/
|
||||
struct TmPacketPointer {
|
||||
CCSDSPrimaryHeader primary;
|
||||
PUSTmDataFieldHeader data_field;
|
||||
uint8_t data;
|
||||
};
|
||||
|
||||
/**
|
||||
* This class is the basic data handler for any ECSS PUS Telemetry packet.
|
||||
|
@ -49,61 +23,83 @@ struct TmPacketPointer {
|
|||
* @ingroup tmtcpackets
|
||||
*/
|
||||
class TmPacketBase : public SpacePacketBase {
|
||||
friend void (Factory::setStaticFrameworkObjectIds)();
|
||||
friend void (Factory::setStaticFrameworkObjectIds)();
|
||||
public:
|
||||
/**
|
||||
* This constant defines the minimum size of a valid PUS Telemetry Packet.
|
||||
*/
|
||||
static const uint32_t TM_PACKET_MIN_SIZE = (sizeof(CCSDSPrimaryHeader) +
|
||||
sizeof(PUSTmDataFieldHeader) + 2);
|
||||
//! Maximum size of a TM Packet in this mission.
|
||||
//! TODO: Make this dependant on a config variable.
|
||||
static const uint32_t MISSION_TM_PACKET_MAX_SIZE = 2048;
|
||||
//! First byte of secondary header for PUS-A packets.
|
||||
//! TODO: Maybe also support PUS-C via config?
|
||||
static const uint8_t VERSION_NUMBER_BYTE_PUS_A = 0b00010000;
|
||||
|
||||
/**
|
||||
* This is the default constructor.
|
||||
* It sets its internal data pointer to the address passed and also
|
||||
* forwards the data pointer to the parent SpacePacketBase class.
|
||||
* @param set_address The position where the packet data lies.
|
||||
*/
|
||||
TmPacketBase( uint8_t* setData );
|
||||
/**
|
||||
* This is the empty default destructor.
|
||||
*/
|
||||
virtual ~TmPacketBase();
|
||||
//! Maximum size of a TM Packet in this mission.
|
||||
//! TODO: Make this dependant on a config variable.
|
||||
static const uint32_t MISSION_TM_PACKET_MAX_SIZE = 2048;
|
||||
//! First four bits of first byte of secondary header
|
||||
static const uint8_t VERSION_NUMBER_BYTE = 0b00010000;
|
||||
|
||||
/**
|
||||
* This is a getter for the packet's PUS Service ID, which is the second
|
||||
* byte of the Data Field Header.
|
||||
* @return The packet's PUS Service ID.
|
||||
*/
|
||||
uint8_t getService();
|
||||
/**
|
||||
* This is a getter for the packet's PUS Service Subtype, which is the
|
||||
* third byte of the Data Field Header.
|
||||
* @return The packet's PUS Service Subtype.
|
||||
*/
|
||||
uint8_t getSubService();
|
||||
/**
|
||||
* This is a getter for a pointer to the packet's Source data.
|
||||
*
|
||||
* These are the bytes that follow after the Data Field Header. They form
|
||||
* the packet's source data.
|
||||
* @return A pointer to the PUS Source Data.
|
||||
*/
|
||||
uint8_t* getSourceData();
|
||||
/**
|
||||
* This method calculates the size of the PUS Source data field.
|
||||
*
|
||||
* It takes the information stored in the CCSDS Packet Data Length field
|
||||
* and subtracts the Data Field Header size and the CRC size.
|
||||
* @return The size of the PUS Source Data (without Error Control field)
|
||||
*/
|
||||
uint16_t getSourceDataSize();
|
||||
/**
|
||||
* This is the default constructor.
|
||||
* It sets its internal data pointer to the address passed and also
|
||||
* forwards the data pointer to the parent SpacePacketBase class.
|
||||
* @param set_address The position where the packet data lies.
|
||||
*/
|
||||
TmPacketBase( uint8_t* setData );
|
||||
/**
|
||||
* This is the empty default destructor.
|
||||
*/
|
||||
virtual ~TmPacketBase();
|
||||
|
||||
/**
|
||||
* This is a getter for the packet's PUS Service ID, which is the second
|
||||
* byte of the Data Field Header.
|
||||
* @return The packet's PUS Service ID.
|
||||
*/
|
||||
virtual uint8_t getService() = 0;
|
||||
/**
|
||||
* This is a getter for the packet's PUS Service Subtype, which is the
|
||||
* third byte of the Data Field Header.
|
||||
* @return The packet's PUS Service Subtype.
|
||||
*/
|
||||
virtual uint8_t getSubService() = 0;
|
||||
/**
|
||||
* This is a getter for a pointer to the packet's Source data.
|
||||
*
|
||||
* These are the bytes that follow after the Data Field Header. They form
|
||||
* the packet's source data.
|
||||
* @return A pointer to the PUS Source Data.
|
||||
*/
|
||||
virtual uint8_t* getSourceData() = 0;
|
||||
/**
|
||||
* This method calculates the size of the PUS Source data field.
|
||||
*
|
||||
* It takes the information stored in the CCSDS Packet Data Length field
|
||||
* and subtracts the Data Field Header size and the CRC size.
|
||||
* @return The size of the PUS Source Data (without Error Control field)
|
||||
*/
|
||||
virtual uint16_t getSourceDataSize() = 0;
|
||||
|
||||
/**
|
||||
* Get size of data field which can differ based on implementation
|
||||
* @return
|
||||
*/
|
||||
virtual uint16_t getDataFieldSize() = 0;
|
||||
|
||||
virtual size_t getPacketMinimumSize() const = 0;
|
||||
|
||||
/**
|
||||
* Interprets the "time"-field in the secondary header and returns it in
|
||||
* timeval format.
|
||||
* @return Converted timestamp of packet.
|
||||
*/
|
||||
virtual ReturnValue_t getPacketTime(timeval* timestamp) const;
|
||||
/**
|
||||
* Returns a raw pointer to the beginning of the time field.
|
||||
* @return Raw pointer to time field.
|
||||
*/
|
||||
virtual uint8_t* getPacketTimeRaw() const = 0;
|
||||
|
||||
virtual size_t getTimestampSize() const = 0;
|
||||
|
||||
/**
|
||||
* This is a debugging helper method that prints the whole packet content
|
||||
* to the screen.
|
||||
*/
|
||||
void print();
|
||||
/**
|
||||
* With this method, the Error Control Field is updated to match the
|
||||
* current content of the packet. This method is not protected because
|
||||
|
@ -111,79 +107,24 @@ public:
|
|||
* like the sequence count.
|
||||
*/
|
||||
void setErrorControl();
|
||||
|
||||
/**
|
||||
* This getter returns the Error Control Field of the packet.
|
||||
*
|
||||
* The field is placed after any possible Source Data. If no
|
||||
* Source Data is present there's still an Error Control field. It is
|
||||
* supposed to be a 16bit-CRC.
|
||||
* @return The PUS Error Control
|
||||
*/
|
||||
uint16_t getErrorControl();
|
||||
|
||||
/**
|
||||
* This is a debugging helper method that prints the whole packet content
|
||||
* to the screen.
|
||||
*/
|
||||
void print();
|
||||
/**
|
||||
* Interprets the "time"-field in the secondary header and returns it in
|
||||
* timeval format.
|
||||
* @return Converted timestamp of packet.
|
||||
*/
|
||||
ReturnValue_t getPacketTime(timeval* timestamp) const;
|
||||
/**
|
||||
* Returns a raw pointer to the beginning of the time field.
|
||||
* @return Raw pointer to time field.
|
||||
*/
|
||||
uint8_t* getPacketTimeRaw() const;
|
||||
|
||||
size_t getTimestampSize() const;
|
||||
/**
|
||||
* This getter returns the Error Control Field of the packet.
|
||||
*
|
||||
* The field is placed after any possible Source Data. If no
|
||||
* Source Data is present there's still an Error Control field. It is
|
||||
* supposed to be a 16bit-CRC.
|
||||
* @return The PUS Error Control
|
||||
*/
|
||||
uint16_t getErrorControl();
|
||||
|
||||
protected:
|
||||
/**
|
||||
* A pointer to a structure which defines the data structure of
|
||||
* the packet's data.
|
||||
*
|
||||
* To be hardware-safe, all elements are of byte size.
|
||||
*/
|
||||
TmPacketPointer* tmData;
|
||||
/**
|
||||
* The timeStamper is responsible for adding a timestamp to the packet.
|
||||
* It is initialized lazy.
|
||||
*/
|
||||
static TimeStamperIF* timeStamper;
|
||||
//! The ID to use when looking for a time stamper.
|
||||
static object_id_t timeStamperId;
|
||||
|
||||
/**
|
||||
* Initializes the Tm Packet header.
|
||||
* Does set the timestamp (to now), but not the error control field.
|
||||
* @param apid APID used.
|
||||
* @param service PUS Service
|
||||
* @param subservice PUS Subservice
|
||||
* @param packetSubcounter Additional subcounter used.
|
||||
* The timeStamper is responsible for adding a timestamp to the packet.
|
||||
* It is initialized lazy.
|
||||
*/
|
||||
void initializeTmPacket(uint16_t apid, uint8_t service, uint8_t subservice,
|
||||
uint8_t packetSubcounter);
|
||||
|
||||
/**
|
||||
* With this method, the packet data pointer can be redirected to another
|
||||
* location.
|
||||
*
|
||||
* This call overwrites the parent's setData method to set both its
|
||||
* @c tc_data pointer and the parent's @c data pointer.
|
||||
*
|
||||
* @param p_data A pointer to another PUS Telemetry Packet.
|
||||
*/
|
||||
void setData( const uint8_t* pData );
|
||||
|
||||
/**
|
||||
* In case data was filled manually (almost never the case).
|
||||
* @param size Size of source data (without CRC and data filed header!).
|
||||
*/
|
||||
void setSourceDataSize(uint16_t size);
|
||||
static TimeStamperIF* timeStamper;
|
||||
//! The ID to use when looking for a time stamper.
|
||||
static object_id_t timeStamperId;
|
||||
|
||||
/**
|
||||
* Checks if a time stamper is available and tries to set it if not.
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
#ifndef FSFW_TMTCPACKET_PUS_TMPACKETIF_H_
|
||||
#define FSFW_TMTCPACKET_PUS_TMPACKETIF_H_
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#endif /* FSFW_TMTCPACKET_PUS_TMPACKETIF_H_ */
|
|
@ -0,0 +1,87 @@
|
|||
#include "TmPacketPusA.h"
|
||||
#include "TmPacketBase.h"
|
||||
|
||||
#include "../../globalfunctions/CRC.h"
|
||||
#include "../../globalfunctions/arrayprinter.h"
|
||||
#include "../../objectmanager/ObjectManagerIF.h"
|
||||
#include "../../serviceinterface/ServiceInterfaceStream.h"
|
||||
#include "../../timemanager/CCSDSTime.h"
|
||||
|
||||
#include <cstring>
|
||||
|
||||
|
||||
TmPacketPusA::TmPacketPusA(uint8_t* setData) : TmPacketBase(setData) {
|
||||
tmData = reinterpret_cast<TmPacketPointerPusA*>(setData);
|
||||
}
|
||||
|
||||
TmPacketPusA::~TmPacketPusA() {
|
||||
//Nothing to do.
|
||||
}
|
||||
|
||||
uint8_t TmPacketPusA::getService() {
|
||||
return tmData->data_field.service_type;
|
||||
}
|
||||
|
||||
uint8_t TmPacketPusA::getSubService() {
|
||||
return tmData->data_field.service_subtype;
|
||||
}
|
||||
|
||||
uint8_t* TmPacketPusA::getSourceData() {
|
||||
return &tmData->data;
|
||||
}
|
||||
|
||||
uint16_t TmPacketPusA::getSourceDataSize() {
|
||||
return getPacketDataLength() - sizeof(tmData->data_field)
|
||||
- CRC_SIZE + 1;
|
||||
}
|
||||
|
||||
void TmPacketPusA::setData(const uint8_t* p_Data) {
|
||||
SpacePacketBase::setData(p_Data);
|
||||
tmData = (TmPacketPointerPusA*) p_Data;
|
||||
}
|
||||
|
||||
|
||||
size_t TmPacketPusA::getPacketMinimumSize() const {
|
||||
return TM_PACKET_MIN_SIZE;
|
||||
}
|
||||
|
||||
uint16_t TmPacketPusA::getDataFieldSize() {
|
||||
return sizeof(PUSTmDataFieldHeaderPusA);
|
||||
}
|
||||
|
||||
uint8_t* TmPacketPusA::getPacketTimeRaw() const {
|
||||
return tmData->data_field.time;
|
||||
|
||||
}
|
||||
|
||||
void TmPacketPusA::initializeTmPacket(uint16_t apid, uint8_t service,
|
||||
uint8_t subservice, uint8_t packetSubcounter) {
|
||||
//Set primary header:
|
||||
initSpacePacketHeader(false, true, apid);
|
||||
//Set data Field Header:
|
||||
//First, set to zero.
|
||||
memset(&tmData->data_field, 0, sizeof(tmData->data_field));
|
||||
|
||||
// NOTE: In PUS-C, the PUS Version is 2 and specified for the first 4 bits.
|
||||
// The other 4 bits of the first byte are the spacecraft time reference
|
||||
// status. To change to PUS-C, set 0b00100000.
|
||||
// Set CCSDS_secondary header flag to 0, version number to 001 and ack
|
||||
// to 0000
|
||||
tmData->data_field.version_type_ack = 0b00010000;
|
||||
tmData->data_field.service_type = service;
|
||||
tmData->data_field.service_subtype = subservice;
|
||||
tmData->data_field.subcounter = packetSubcounter;
|
||||
//Timestamp packet
|
||||
if (TmPacketBase::checkAndSetStamper()) {
|
||||
timeStamper->addTimeStamp(tmData->data_field.time,
|
||||
sizeof(tmData->data_field.time));
|
||||
}
|
||||
}
|
||||
|
||||
void TmPacketPusA::setSourceDataSize(uint16_t size) {
|
||||
setPacketDataLength(size + sizeof(PUSTmDataFieldHeaderPusA) + CRC_SIZE - 1);
|
||||
}
|
||||
|
||||
size_t TmPacketPusA::getTimestampSize() const {
|
||||
return sizeof(tmData->data_field.time);
|
||||
}
|
|
@ -0,0 +1,129 @@
|
|||
#ifndef FSFW_TMTCPACKET_PUS_TMPACKETPUSA_H_
|
||||
#define FSFW_TMTCPACKET_PUS_TMPACKETPUSA_H_
|
||||
|
||||
#include "TmPacketBase.h"
|
||||
#include "../SpacePacketBase.h"
|
||||
#include "../../timemanager/TimeStamperIF.h"
|
||||
#include "../../timemanager/Clock.h"
|
||||
#include "../../objectmanager/SystemObjectIF.h"
|
||||
|
||||
namespace Factory{
|
||||
void setStaticFrameworkObjectIds();
|
||||
}
|
||||
|
||||
/**
|
||||
* This struct defines a byte-wise structured PUS TM Data Field Header.
|
||||
* Any optional fields in the header must be added or removed here.
|
||||
* Currently, no Destination field is present, but an eigth-byte representation
|
||||
* for a time tag.
|
||||
* @ingroup tmtcpackets
|
||||
*/
|
||||
struct PUSTmDataFieldHeaderPusA {
|
||||
uint8_t version_type_ack;
|
||||
uint8_t service_type;
|
||||
uint8_t service_subtype;
|
||||
uint8_t subcounter;
|
||||
// uint8_t destination;
|
||||
uint8_t time[TimeStamperIF::MISSION_TIMESTAMP_SIZE];
|
||||
};
|
||||
|
||||
/**
|
||||
* This struct defines the data structure of a PUS Telecommand Packet when
|
||||
* accessed via a pointer.
|
||||
* @ingroup tmtcpackets
|
||||
*/
|
||||
struct TmPacketPointerPusA {
|
||||
CCSDSPrimaryHeader primary;
|
||||
PUSTmDataFieldHeaderPusA data_field;
|
||||
uint8_t data;
|
||||
};
|
||||
|
||||
/**
|
||||
* PUS A packet implementation
|
||||
* @ingroup tmtcpackets
|
||||
*/
|
||||
class TmPacketPusA: public TmPacketBase {
|
||||
friend void (Factory::setStaticFrameworkObjectIds)();
|
||||
public:
|
||||
/**
|
||||
* This constant defines the minimum size of a valid PUS Telemetry Packet.
|
||||
*/
|
||||
static const uint32_t TM_PACKET_MIN_SIZE = (sizeof(CCSDSPrimaryHeader) +
|
||||
sizeof(PUSTmDataFieldHeaderPusA) + 2);
|
||||
//! Maximum size of a TM Packet in this mission.
|
||||
//! TODO: Make this dependant on a config variable.
|
||||
static const uint32_t MISSION_TM_PACKET_MAX_SIZE = 2048;
|
||||
|
||||
/**
|
||||
* This is the default constructor.
|
||||
* It sets its internal data pointer to the address passed and also
|
||||
* forwards the data pointer to the parent SpacePacketBase class.
|
||||
* @param set_address The position where the packet data lies.
|
||||
*/
|
||||
TmPacketPusA( uint8_t* setData );
|
||||
/**
|
||||
* This is the empty default destructor.
|
||||
*/
|
||||
virtual ~TmPacketPusA();
|
||||
|
||||
/* TmPacketBase implementations */
|
||||
uint8_t getService() override;
|
||||
uint8_t getSubService() override;
|
||||
uint8_t* getSourceData() override;
|
||||
uint16_t getSourceDataSize() override;
|
||||
uint16_t getDataFieldSize() override;
|
||||
|
||||
/**
|
||||
* Returns a raw pointer to the beginning of the time field.
|
||||
* @return Raw pointer to time field.
|
||||
*/
|
||||
uint8_t* getPacketTimeRaw() const override;
|
||||
size_t getTimestampSize() const override;
|
||||
|
||||
size_t getPacketMinimumSize() const override;
|
||||
|
||||
protected:
|
||||
/**
|
||||
* A pointer to a structure which defines the data structure of
|
||||
* the packet's data.
|
||||
*
|
||||
* To be hardware-safe, all elements are of byte size.
|
||||
*/
|
||||
TmPacketPointerPusA* tmData;
|
||||
|
||||
/**
|
||||
* Initializes the Tm Packet header.
|
||||
* Does set the timestamp (to now), but not the error control field.
|
||||
* @param apid APID used.
|
||||
* @param service PUS Service
|
||||
* @param subservice PUS Subservice
|
||||
* @param packetSubcounter Additional subcounter used.
|
||||
*/
|
||||
void initializeTmPacket(uint16_t apid, uint8_t service, uint8_t subservice,
|
||||
uint8_t packetSubcounter);
|
||||
|
||||
/**
|
||||
* With this method, the packet data pointer can be redirected to another
|
||||
* location.
|
||||
*
|
||||
* This call overwrites the parent's setData method to set both its
|
||||
* @c tc_data pointer and the parent's @c data pointer.
|
||||
*
|
||||
* @param p_data A pointer to another PUS Telemetry Packet.
|
||||
*/
|
||||
void setData( const uint8_t* pData );
|
||||
|
||||
/**
|
||||
* In case data was filled manually (almost never the case).
|
||||
* @param size Size of source data (without CRC and data filed header!).
|
||||
*/
|
||||
void setSourceDataSize(uint16_t size);
|
||||
|
||||
/**
|
||||
* Checks if a time stamper is available and tries to set it if not.
|
||||
* @return Returns false if setting failed.
|
||||
*/
|
||||
bool checkAndSetStamper();
|
||||
};
|
||||
|
||||
#endif /* FSFW_TMTCPACKET_PUS_TMPACKETPUSA_H_ */
|
|
@ -0,0 +1,87 @@
|
|||
#include "TmPacketPusC.h"
|
||||
#include "TmPacketBase.h"
|
||||
|
||||
#include "../../globalfunctions/CRC.h"
|
||||
#include "../../globalfunctions/arrayprinter.h"
|
||||
#include "../../objectmanager/ObjectManagerIF.h"
|
||||
#include "../../serviceinterface/ServiceInterfaceStream.h"
|
||||
#include "../../timemanager/CCSDSTime.h"
|
||||
|
||||
#include <cstring>
|
||||
|
||||
|
||||
TmPacketPusC::TmPacketPusC(uint8_t* setData) : TmPacketBase(setData) {
|
||||
tmData = reinterpret_cast<TmPacketPointerPusC*>(setData);
|
||||
}
|
||||
|
||||
TmPacketPusC::~TmPacketPusC() {
|
||||
//Nothing to do.
|
||||
}
|
||||
|
||||
uint8_t TmPacketPusC::getService() {
|
||||
return tmData->dataField.serviceType;
|
||||
}
|
||||
|
||||
uint8_t TmPacketPusC::getSubService() {
|
||||
return tmData->dataField.serviceSubtype;
|
||||
}
|
||||
|
||||
uint8_t* TmPacketPusC::getSourceData() {
|
||||
return &tmData->data;
|
||||
}
|
||||
|
||||
uint16_t TmPacketPusC::getSourceDataSize() {
|
||||
return getPacketDataLength() - sizeof(tmData->dataField) - CRC_SIZE + 1;
|
||||
}
|
||||
|
||||
void TmPacketPusC::setData(const uint8_t* p_Data) {
|
||||
SpacePacketBase::setData(p_Data);
|
||||
tmData = (TmPacketPointerPusC*) p_Data;
|
||||
}
|
||||
|
||||
|
||||
size_t TmPacketPusC::getPacketMinimumSize() const {
|
||||
return TM_PACKET_MIN_SIZE;
|
||||
}
|
||||
|
||||
uint16_t TmPacketPusC::getDataFieldSize() {
|
||||
return sizeof(PUSTmDataFieldHeaderPusC);
|
||||
}
|
||||
|
||||
uint8_t* TmPacketPusC::getPacketTimeRaw() const{
|
||||
return tmData->dataField.time;
|
||||
|
||||
}
|
||||
|
||||
void TmPacketPusC::initializeTmPacket(uint16_t apid, uint8_t service,
|
||||
uint8_t subservice, uint16_t packetSubcounter, uint16_t destinationId,
|
||||
uint8_t timeRefField) {
|
||||
//Set primary header:
|
||||
initSpacePacketHeader(false, true, apid);
|
||||
//Set data Field Header:
|
||||
//First, set to zero.
|
||||
memset(&tmData->dataField, 0, sizeof(tmData->dataField));
|
||||
|
||||
/* Only account for last 4 bytes for time reference field */
|
||||
timeRefField &= 0b1111;
|
||||
tmData->dataField.versionTimeReferenceField = VERSION_NUMBER_BYTE | timeRefField;
|
||||
tmData->dataField.serviceType = service;
|
||||
tmData->dataField.serviceSubtype = subservice;
|
||||
tmData->dataField.subcounterMsb = packetSubcounter << 8 & 0xff;
|
||||
tmData->dataField.subcounterLsb = packetSubcounter & 0xff;
|
||||
tmData->dataField.destinationIdMsb = destinationId << 8 & 0xff;
|
||||
tmData->dataField.destinationIdLsb = destinationId & 0xff;
|
||||
//Timestamp packet
|
||||
if (TmPacketBase::checkAndSetStamper()) {
|
||||
timeStamper->addTimeStamp(tmData->dataField.time,
|
||||
sizeof(tmData->dataField.time));
|
||||
}
|
||||
}
|
||||
|
||||
void TmPacketPusC::setSourceDataSize(uint16_t size) {
|
||||
setPacketDataLength(size + sizeof(PUSTmDataFieldHeaderPusC) + CRC_SIZE - 1);
|
||||
}
|
||||
|
||||
size_t TmPacketPusC::getTimestampSize() const {
|
||||
return sizeof(tmData->dataField.time);
|
||||
}
|
|
@ -0,0 +1,126 @@
|
|||
#ifndef FSFW_TMTCPACKET_PUS_TMPACKETPUSC_H_
|
||||
#define FSFW_TMTCPACKET_PUS_TMPACKETPUSC_H_
|
||||
|
||||
#include "TmPacketBase.h"
|
||||
#include "../SpacePacketBase.h"
|
||||
#include "../../timemanager/TimeStamperIF.h"
|
||||
#include "../../timemanager/Clock.h"
|
||||
#include "../../objectmanager/SystemObjectIF.h"
|
||||
|
||||
namespace Factory{
|
||||
void setStaticFrameworkObjectIds();
|
||||
}
|
||||
|
||||
/**
|
||||
* This struct defines a byte-wise structured PUS TM Data Field Header.
|
||||
* Any optional fields in the header must be added or removed here.
|
||||
* Currently, no Destination field is present, but an eigth-byte representation
|
||||
* for a time tag.
|
||||
* @ingroup tmtcpackets
|
||||
*/
|
||||
struct PUSTmDataFieldHeaderPusC {
|
||||
uint8_t versionTimeReferenceField;
|
||||
uint8_t serviceType;
|
||||
uint8_t serviceSubtype;
|
||||
uint8_t subcounterMsb;
|
||||
uint8_t subcounterLsb;
|
||||
uint8_t destinationIdMsb;
|
||||
uint8_t destinationIdLsb;
|
||||
uint8_t time[TimeStamperIF::MISSION_TIMESTAMP_SIZE];
|
||||
};
|
||||
|
||||
/**
|
||||
* This struct defines the data structure of a PUS Telecommand Packet when
|
||||
* accessed via a pointer.
|
||||
* @ingroup tmtcpackets
|
||||
*/
|
||||
struct TmPacketPointerPusC {
|
||||
CCSDSPrimaryHeader primary;
|
||||
PUSTmDataFieldHeaderPusC dataField;
|
||||
uint8_t data;
|
||||
};
|
||||
|
||||
/**
|
||||
* PUS A packet implementation
|
||||
* @ingroup tmtcpackets
|
||||
*/
|
||||
class TmPacketPusC: public TmPacketBase {
|
||||
friend void (Factory::setStaticFrameworkObjectIds)();
|
||||
public:
|
||||
/**
|
||||
* This constant defines the minimum size of a valid PUS Telemetry Packet.
|
||||
*/
|
||||
static const uint32_t TM_PACKET_MIN_SIZE = (sizeof(CCSDSPrimaryHeader) +
|
||||
sizeof(PUSTmDataFieldHeaderPusC) + 2);
|
||||
//! Maximum size of a TM Packet in this mission.
|
||||
//! TODO: Make this dependant on a config variable.
|
||||
static const uint32_t MISSION_TM_PACKET_MAX_SIZE = 2048;
|
||||
|
||||
/**
|
||||
* This is the default constructor.
|
||||
* It sets its internal data pointer to the address passed and also
|
||||
* forwards the data pointer to the parent SpacePacketBase class.
|
||||
* @param set_address The position where the packet data lies.
|
||||
*/
|
||||
TmPacketPusC( uint8_t* setData );
|
||||
/**
|
||||
* This is the empty default destructor.
|
||||
*/
|
||||
virtual ~TmPacketPusC();
|
||||
|
||||
/* TmPacketBase implementations */
|
||||
uint8_t getService() override;
|
||||
uint8_t getSubService() override;
|
||||
uint8_t* getSourceData() override;
|
||||
uint16_t getSourceDataSize() override;
|
||||
uint16_t getDataFieldSize() override;
|
||||
|
||||
/**
|
||||
* Returns a raw pointer to the beginning of the time field.
|
||||
* @return Raw pointer to time field.
|
||||
*/
|
||||
uint8_t* getPacketTimeRaw() const override;
|
||||
size_t getTimestampSize() const override;
|
||||
|
||||
size_t getPacketMinimumSize() const override;
|
||||
|
||||
protected:
|
||||
/**
|
||||
* A pointer to a structure which defines the data structure of
|
||||
* the packet's data.
|
||||
*
|
||||
* To be hardware-safe, all elements are of byte size.
|
||||
*/
|
||||
TmPacketPointerPusC* tmData;
|
||||
|
||||
/**
|
||||
* Initializes the Tm Packet header.
|
||||
* Does set the timestamp (to now), but not the error control field.
|
||||
* @param apid APID used.
|
||||
* @param service PUS Service
|
||||
* @param subservice PUS Subservice
|
||||
* @param packetSubcounter Additional subcounter used.
|
||||
*/
|
||||
void initializeTmPacket(uint16_t apid, uint8_t service, uint8_t subservice,
|
||||
uint16_t packetSubcounter, uint16_t destinationId = 0, uint8_t timeRefField = 0);
|
||||
|
||||
/**
|
||||
* With this method, the packet data pointer can be redirected to another
|
||||
* location.
|
||||
*
|
||||
* This call overwrites the parent's setData method to set both its
|
||||
* @c tc_data pointer and the parent's @c data pointer.
|
||||
*
|
||||
* @param p_data A pointer to another PUS Telemetry Packet.
|
||||
*/
|
||||
void setData( const uint8_t* pData );
|
||||
|
||||
/**
|
||||
* In case data was filled manually (almost never the case).
|
||||
* @param size Size of source data (without CRC and data filed header!).
|
||||
*/
|
||||
void setSourceDataSize(uint16_t size);
|
||||
|
||||
};
|
||||
|
||||
#endif /* FSFW_TMTCPACKET_PUS_TMPACKETPUSC_H_ */
|
|
@ -1,147 +0,0 @@
|
|||
#include "TmPacketStored.h"
|
||||
|
||||
#include "../../objectmanager/ObjectManagerIF.h"
|
||||
#include "../../serviceinterface/ServiceInterfaceStream.h"
|
||||
#include "../../tmtcservices/TmTcMessage.h"
|
||||
|
||||
#include <cstring>
|
||||
|
||||
StorageManagerIF *TmPacketStored::store = nullptr;
|
||||
InternalErrorReporterIF *TmPacketStored::internalErrorReporter = nullptr;
|
||||
|
||||
TmPacketStored::TmPacketStored(store_address_t setAddress) :
|
||||
TmPacketBase(nullptr), storeAddress(setAddress) {
|
||||
setStoreAddress(storeAddress);
|
||||
}
|
||||
|
||||
TmPacketStored::TmPacketStored(uint16_t apid, uint8_t service,
|
||||
uint8_t subservice, uint8_t packetSubcounter, const uint8_t *data,
|
||||
uint32_t size, const uint8_t *headerData, uint32_t headerSize) :
|
||||
TmPacketBase(NULL) {
|
||||
storeAddress.raw = StorageManagerIF::INVALID_ADDRESS;
|
||||
if (not checkAndSetStore()) {
|
||||
return;
|
||||
}
|
||||
uint8_t *pData = nullptr;
|
||||
ReturnValue_t returnValue = store->getFreeElement(&storeAddress,
|
||||
(TmPacketBase::TM_PACKET_MIN_SIZE + size + headerSize), &pData);
|
||||
|
||||
if (returnValue != store->RETURN_OK) {
|
||||
checkAndReportLostTm();
|
||||
return;
|
||||
}
|
||||
setData(pData);
|
||||
initializeTmPacket(apid, service, subservice, packetSubcounter);
|
||||
memcpy(getSourceData(), headerData, headerSize);
|
||||
memcpy(getSourceData() + headerSize, data, size);
|
||||
setPacketDataLength(
|
||||
size + headerSize + sizeof(PUSTmDataFieldHeader) + CRC_SIZE - 1);
|
||||
}
|
||||
|
||||
TmPacketStored::TmPacketStored(uint16_t apid, uint8_t service,
|
||||
uint8_t subservice, uint8_t packetSubcounter, SerializeIF *content,
|
||||
SerializeIF *header) :
|
||||
TmPacketBase(NULL) {
|
||||
storeAddress.raw = StorageManagerIF::INVALID_ADDRESS;
|
||||
if (not checkAndSetStore()) {
|
||||
return;
|
||||
}
|
||||
size_t sourceDataSize = 0;
|
||||
if (content != NULL) {
|
||||
sourceDataSize += content->getSerializedSize();
|
||||
}
|
||||
if (header != NULL) {
|
||||
sourceDataSize += header->getSerializedSize();
|
||||
}
|
||||
uint8_t *p_data = NULL;
|
||||
ReturnValue_t returnValue = store->getFreeElement(&storeAddress,
|
||||
(TmPacketBase::TM_PACKET_MIN_SIZE + sourceDataSize), &p_data);
|
||||
if (returnValue != store->RETURN_OK) {
|
||||
checkAndReportLostTm();
|
||||
}
|
||||
setData(p_data);
|
||||
initializeTmPacket(apid, service, subservice, packetSubcounter);
|
||||
uint8_t *putDataHere = getSourceData();
|
||||
size_t size = 0;
|
||||
if (header != NULL) {
|
||||
header->serialize(&putDataHere, &size, sourceDataSize,
|
||||
SerializeIF::Endianness::BIG);
|
||||
}
|
||||
if (content != NULL) {
|
||||
content->serialize(&putDataHere, &size, sourceDataSize,
|
||||
SerializeIF::Endianness::BIG);
|
||||
}
|
||||
setPacketDataLength(
|
||||
sourceDataSize + sizeof(PUSTmDataFieldHeader) + CRC_SIZE - 1);
|
||||
}
|
||||
|
||||
store_address_t TmPacketStored::getStoreAddress() {
|
||||
return storeAddress;
|
||||
}
|
||||
|
||||
void TmPacketStored::deletePacket() {
|
||||
store->deleteData(storeAddress);
|
||||
storeAddress.raw = StorageManagerIF::INVALID_ADDRESS;
|
||||
setData(nullptr);
|
||||
}
|
||||
|
||||
void TmPacketStored::setStoreAddress(store_address_t setAddress) {
|
||||
storeAddress = setAddress;
|
||||
const uint8_t* tempData = nullptr;
|
||||
size_t tempSize;
|
||||
if (not checkAndSetStore()) {
|
||||
return;
|
||||
}
|
||||
ReturnValue_t status = store->getData(storeAddress, &tempData, &tempSize);
|
||||
if (status == StorageManagerIF::RETURN_OK) {
|
||||
setData(tempData);
|
||||
} else {
|
||||
setData(nullptr);
|
||||
storeAddress.raw = StorageManagerIF::INVALID_ADDRESS;
|
||||
}
|
||||
}
|
||||
|
||||
bool TmPacketStored::checkAndSetStore() {
|
||||
if (store == nullptr) {
|
||||
store = objectManager->get<StorageManagerIF>(objects::TM_STORE);
|
||||
if (store == nullptr) {
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::error << "TmPacketStored::TmPacketStored: TM Store not found!"
|
||||
<< std::endl;
|
||||
#endif
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
ReturnValue_t TmPacketStored::sendPacket(MessageQueueId_t destination,
|
||||
MessageQueueId_t sentFrom, bool doErrorReporting) {
|
||||
if (getWholeData() == nullptr) {
|
||||
//SHOULDDO: More decent code.
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
}
|
||||
TmTcMessage tmMessage(getStoreAddress());
|
||||
ReturnValue_t result = MessageQueueSenderIF::sendMessage(destination,
|
||||
&tmMessage, sentFrom);
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
deletePacket();
|
||||
if (doErrorReporting) {
|
||||
checkAndReportLostTm();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
//SHOULDDO: In many cases, some counter is incremented for successfully sent packets. The check is often not done, but just incremented.
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
|
||||
}
|
||||
|
||||
void TmPacketStored::checkAndReportLostTm() {
|
||||
if (internalErrorReporter == nullptr) {
|
||||
internalErrorReporter = objectManager->get<InternalErrorReporterIF>(
|
||||
objects::INTERNAL_ERROR_REPORTER);
|
||||
}
|
||||
if (internalErrorReporter != nullptr) {
|
||||
internalErrorReporter->lostTm();
|
||||
}
|
||||
}
|
|
@ -1,108 +1,13 @@
|
|||
#ifndef FSFW_TMTCPACKET_PUS_TMPACKETSTORED_H_
|
||||
#define FSFW_TMTCPACKET_PUS_TMPACKETSTORED_H_
|
||||
|
||||
#include "TmPacketBase.h"
|
||||
#include <FSFWConfig.h>
|
||||
|
||||
#include "../../serialize/SerializeIF.h"
|
||||
#include "../../storagemanager/StorageManagerIF.h"
|
||||
#include "../../internalError/InternalErrorReporterIF.h"
|
||||
#include "../../ipc/MessageQueueSenderIF.h"
|
||||
|
||||
/**
|
||||
* This class generates a ECSS PUS Telemetry packet within a given
|
||||
* intermediate storage.
|
||||
* As most packets are passed between tasks with the help of a storage
|
||||
* anyway, it seems logical to create a Packet-In-Storage access class
|
||||
* which saves the user almost all storage handling operation.
|
||||
* Packets can both be newly created with the class and be "linked" to
|
||||
* packets in a store with the help of a storeAddress.
|
||||
* @ingroup tmtcpackets
|
||||
*/
|
||||
class TmPacketStored : public TmPacketBase {
|
||||
public:
|
||||
/**
|
||||
* This is a default constructor which does not set the data pointer.
|
||||
* However, it does try to set the packet store.
|
||||
*/
|
||||
TmPacketStored( store_address_t setAddress );
|
||||
/**
|
||||
* With this constructor, new space is allocated in the packet store and
|
||||
* a new PUS Telemetry Packet is created there.
|
||||
* Packet Application Data passed in data is copied into the packet.
|
||||
* The Application data is passed in two parts, first a header, then a
|
||||
* data field. This allows building a Telemetry Packet from two separate
|
||||
* data sources.
|
||||
* @param apid Sets the packet's APID field.
|
||||
* @param service Sets the packet's Service ID field.
|
||||
* This specifies the source service.
|
||||
* @param subservice Sets the packet's Service Subtype field.
|
||||
* This specifies the source sub-service.
|
||||
* @param packet_counter Sets the Packet counter field of this packet
|
||||
* @param data The payload data to be copied to the
|
||||
* Application Data Field
|
||||
* @param size The amount of data to be copied.
|
||||
* @param headerData The header Data of the Application field,
|
||||
* will be copied in front of data
|
||||
* @param headerSize The size of the headerDataF
|
||||
*/
|
||||
TmPacketStored( uint16_t apid, uint8_t service, uint8_t subservice,
|
||||
uint8_t packet_counter = 0, const uint8_t* data = nullptr,
|
||||
uint32_t size = 0, const uint8_t* headerData = nullptr,
|
||||
uint32_t headerSize = 0);
|
||||
/**
|
||||
* Another ctor to directly pass structured content and header data to the
|
||||
* packet to avoid additional buffers.
|
||||
*/
|
||||
TmPacketStored( uint16_t apid, uint8_t service, uint8_t subservice,
|
||||
uint8_t packet_counter, SerializeIF* content,
|
||||
SerializeIF* header = nullptr);
|
||||
/**
|
||||
* This is a getter for the current store address of the packet.
|
||||
* @return The current store address. The (raw) value is
|
||||
* @c StorageManagerIF::INVALID_ADDRESS if
|
||||
* the packet is not linked.
|
||||
*/
|
||||
store_address_t getStoreAddress();
|
||||
/**
|
||||
* With this call, the packet is deleted.
|
||||
* It removes itself from the store and sets its data pointer to NULL.
|
||||
*/
|
||||
void deletePacket();
|
||||
/**
|
||||
* With this call, a packet can be linked to another store. This is useful
|
||||
* if the packet is a class member and used for more than one packet.
|
||||
* @param setAddress The new packet id to link to.
|
||||
*/
|
||||
void setStoreAddress( store_address_t setAddress );
|
||||
|
||||
ReturnValue_t sendPacket( MessageQueueId_t destination,
|
||||
MessageQueueId_t sentFrom, bool doErrorReporting = true );
|
||||
private:
|
||||
/**
|
||||
* This is a pointer to the store all instances of the class use.
|
||||
* If the store is not yet set (i.e. @c store is NULL), every constructor
|
||||
* call tries to set it and throws an error message in case of failures.
|
||||
* The default store is objects::TM_STORE.
|
||||
*/
|
||||
static StorageManagerIF* store;
|
||||
|
||||
static InternalErrorReporterIF *internalErrorReporter;
|
||||
|
||||
/**
|
||||
* The address where the packet data of the object instance is stored.
|
||||
*/
|
||||
store_address_t storeAddress;
|
||||
/**
|
||||
* A helper method to check if a store is assigned to the class.
|
||||
* If not, the method tries to retrieve the store from the global
|
||||
* ObjectManager.
|
||||
* @return @li @c true if the store is linked or could be created.
|
||||
* @li @c false otherwise.
|
||||
*/
|
||||
bool checkAndSetStore();
|
||||
|
||||
void checkAndReportLostTm();
|
||||
};
|
||||
#if FSFW_USE_PUS_C_TELEMETRY == 1
|
||||
#include "TmPacketStoredPusC.h"
|
||||
#else
|
||||
#include "TmPacketStoredPusA.h"
|
||||
#endif
|
||||
|
||||
|
||||
#endif /* FSFW_TMTCPACKET_PUS_TMPACKETSTORED_H_ */
|
||||
|
|
|
@ -0,0 +1,94 @@
|
|||
#include "TmPacketStoredBase.h"
|
||||
|
||||
#include "../../objectmanager/ObjectManagerIF.h"
|
||||
#include "../../serviceinterface/ServiceInterfaceStream.h"
|
||||
#include "../../tmtcservices/TmTcMessage.h"
|
||||
|
||||
#include <cstring>
|
||||
|
||||
StorageManagerIF *TmPacketStoredBase::store = nullptr;
|
||||
InternalErrorReporterIF *TmPacketStoredBase::internalErrorReporter = nullptr;
|
||||
|
||||
TmPacketStoredBase::TmPacketStoredBase(store_address_t setAddress): storeAddress(setAddress) {
|
||||
setStoreAddress(storeAddress);
|
||||
}
|
||||
|
||||
TmPacketStoredBase::TmPacketStoredBase() {
|
||||
}
|
||||
|
||||
|
||||
TmPacketStoredBase::~TmPacketStoredBase() {
|
||||
}
|
||||
|
||||
store_address_t TmPacketStoredBase::getStoreAddress() {
|
||||
return storeAddress;
|
||||
}
|
||||
|
||||
void TmPacketStoredBase::deletePacket() {
|
||||
store->deleteData(storeAddress);
|
||||
storeAddress.raw = StorageManagerIF::INVALID_ADDRESS;
|
||||
setDataPointer(nullptr);
|
||||
}
|
||||
|
||||
void TmPacketStoredBase::setStoreAddress(store_address_t setAddress) {
|
||||
storeAddress = setAddress;
|
||||
const uint8_t* tempData = nullptr;
|
||||
size_t tempSize;
|
||||
if (not checkAndSetStore()) {
|
||||
return;
|
||||
}
|
||||
ReturnValue_t status = store->getData(storeAddress, &tempData, &tempSize);
|
||||
if (status == StorageManagerIF::RETURN_OK) {
|
||||
setDataPointer(tempData);
|
||||
} else {
|
||||
setDataPointer(nullptr);
|
||||
storeAddress.raw = StorageManagerIF::INVALID_ADDRESS;
|
||||
}
|
||||
}
|
||||
|
||||
bool TmPacketStoredBase::checkAndSetStore() {
|
||||
if (store == nullptr) {
|
||||
store = objectManager->get<StorageManagerIF>(objects::TM_STORE);
|
||||
if (store == nullptr) {
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::error << "TmPacketStored::TmPacketStored: TM Store not found!"
|
||||
<< std::endl;
|
||||
#endif
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
ReturnValue_t TmPacketStoredBase::sendPacket(MessageQueueId_t destination,
|
||||
MessageQueueId_t sentFrom, bool doErrorReporting) {
|
||||
if (getAllTmData() == nullptr) {
|
||||
//SHOULDDO: More decent code.
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
}
|
||||
TmTcMessage tmMessage(getStoreAddress());
|
||||
ReturnValue_t result = MessageQueueSenderIF::sendMessage(destination,
|
||||
&tmMessage, sentFrom);
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
deletePacket();
|
||||
if (doErrorReporting) {
|
||||
checkAndReportLostTm();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
//SHOULDDO: In many cases, some counter is incremented for successfully sent packets. The check is often not done, but just incremented.
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
|
||||
}
|
||||
|
||||
void TmPacketStoredBase::checkAndReportLostTm() {
|
||||
if (internalErrorReporter == nullptr) {
|
||||
internalErrorReporter = objectManager->get<InternalErrorReporterIF>(
|
||||
objects::INTERNAL_ERROR_REPORTER);
|
||||
}
|
||||
if (internalErrorReporter != nullptr) {
|
||||
internalErrorReporter->lostTm();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,89 @@
|
|||
#ifndef FSFW_TMTCPACKET_PUS_TMPACKETSTOREDBASE_H_
|
||||
#define FSFW_TMTCPACKET_PUS_TMPACKETSTOREDBASE_H_
|
||||
|
||||
#include "TmPacketBase.h"
|
||||
#include "TmPacketStoredBase.h"
|
||||
#include <FSFWConfig.h>
|
||||
|
||||
#include "../../tmtcpacket/pus/TmPacketPusA.h"
|
||||
#include "../../serialize/SerializeIF.h"
|
||||
#include "../../storagemanager/StorageManagerIF.h"
|
||||
#include "../../internalError/InternalErrorReporterIF.h"
|
||||
#include "../../ipc/MessageQueueSenderIF.h"
|
||||
|
||||
/**
|
||||
* This class generates a ECSS PUS Telemetry packet within a given
|
||||
* intermediate storage.
|
||||
* As most packets are passed between tasks with the help of a storage
|
||||
* anyway, it seems logical to create a Packet-In-Storage access class
|
||||
* which saves the user almost all storage handling operation.
|
||||
* Packets can both be newly created with the class and be "linked" to
|
||||
* packets in a store with the help of a storeAddress.
|
||||
* @ingroup tmtcpackets
|
||||
*/
|
||||
class TmPacketStoredBase {
|
||||
public:
|
||||
/**
|
||||
* This is a default constructor which does not set the data pointer.
|
||||
* However, it does try to set the packet store.
|
||||
*/
|
||||
TmPacketStoredBase( store_address_t setAddress );
|
||||
TmPacketStoredBase();
|
||||
|
||||
virtual ~TmPacketStoredBase();
|
||||
|
||||
virtual uint8_t* getAllTmData() = 0;
|
||||
virtual void setDataPointer(const uint8_t* newPointer) = 0;
|
||||
|
||||
/**
|
||||
* This is a getter for the current store address of the packet.
|
||||
* @return The current store address. The (raw) value is
|
||||
* @c StorageManagerIF::INVALID_ADDRESS if
|
||||
* the packet is not linked.
|
||||
*/
|
||||
store_address_t getStoreAddress();
|
||||
/**
|
||||
* With this call, the packet is deleted.
|
||||
* It removes itself from the store and sets its data pointer to NULL.
|
||||
*/
|
||||
void deletePacket();
|
||||
/**
|
||||
* With this call, a packet can be linked to another store. This is useful
|
||||
* if the packet is a class member and used for more than one packet.
|
||||
* @param setAddress The new packet id to link to.
|
||||
*/
|
||||
void setStoreAddress(store_address_t setAddress);
|
||||
|
||||
ReturnValue_t sendPacket(MessageQueueId_t destination, MessageQueueId_t sentFrom,
|
||||
bool doErrorReporting = true);
|
||||
|
||||
protected:
|
||||
/**
|
||||
* This is a pointer to the store all instances of the class use.
|
||||
* If the store is not yet set (i.e. @c store is NULL), every constructor
|
||||
* call tries to set it and throws an error message in case of failures.
|
||||
* The default store is objects::TM_STORE.
|
||||
*/
|
||||
static StorageManagerIF* store;
|
||||
|
||||
static InternalErrorReporterIF *internalErrorReporter;
|
||||
|
||||
/**
|
||||
* The address where the packet data of the object instance is stored.
|
||||
*/
|
||||
store_address_t storeAddress;
|
||||
/**
|
||||
* A helper method to check if a store is assigned to the class.
|
||||
* If not, the method tries to retrieve the store from the global
|
||||
* ObjectManager.
|
||||
* @return @li @c true if the store is linked or could be created.
|
||||
* @li @c false otherwise.
|
||||
*/
|
||||
bool checkAndSetStore();
|
||||
|
||||
void checkAndReportLostTm();
|
||||
};
|
||||
|
||||
|
||||
#endif /* FSFW_TMTCPACKET_PUS_TMPACKETSTOREDBASE_H_ */
|
||||
|
|
@ -0,0 +1,79 @@
|
|||
#include "TmPacketStoredPusA.h"
|
||||
|
||||
#include "../../serviceinterface/ServiceInterface.h"
|
||||
#include "../../tmtcservices/TmTcMessage.h"
|
||||
|
||||
#include <cstring>
|
||||
|
||||
TmPacketStoredPusA::TmPacketStoredPusA(store_address_t setAddress) :
|
||||
TmPacketStoredBase(setAddress), TmPacketPusA(nullptr){
|
||||
}
|
||||
|
||||
TmPacketStoredPusA::TmPacketStoredPusA(uint16_t apid, uint8_t service,
|
||||
uint8_t subservice, uint8_t packetSubcounter, const uint8_t *data,
|
||||
uint32_t size, const uint8_t *headerData, uint32_t headerSize) :
|
||||
TmPacketPusA(nullptr) {
|
||||
storeAddress.raw = StorageManagerIF::INVALID_ADDRESS;
|
||||
if (not TmPacketStoredBase::checkAndSetStore()) {
|
||||
return;
|
||||
}
|
||||
uint8_t *pData = nullptr;
|
||||
ReturnValue_t returnValue = store->getFreeElement(&storeAddress,
|
||||
(getPacketMinimumSize() + size + headerSize), &pData);
|
||||
|
||||
if (returnValue != store->RETURN_OK) {
|
||||
TmPacketStoredBase::checkAndReportLostTm();
|
||||
return;
|
||||
}
|
||||
setData(pData);
|
||||
initializeTmPacket(apid, service, subservice, packetSubcounter);
|
||||
memcpy(getSourceData(), headerData, headerSize);
|
||||
memcpy(getSourceData() + headerSize, data, size);
|
||||
setPacketDataLength(
|
||||
size + headerSize + sizeof(PUSTmDataFieldHeaderPusA) + CRC_SIZE - 1);
|
||||
}
|
||||
|
||||
TmPacketStoredPusA::TmPacketStoredPusA(uint16_t apid, uint8_t service,
|
||||
uint8_t subservice, uint8_t packetSubcounter, SerializeIF *content,
|
||||
SerializeIF *header) :
|
||||
TmPacketPusA(nullptr) {
|
||||
storeAddress.raw = StorageManagerIF::INVALID_ADDRESS;
|
||||
if (not TmPacketStoredBase::checkAndSetStore()) {
|
||||
return;
|
||||
}
|
||||
size_t sourceDataSize = 0;
|
||||
if (content != NULL) {
|
||||
sourceDataSize += content->getSerializedSize();
|
||||
}
|
||||
if (header != NULL) {
|
||||
sourceDataSize += header->getSerializedSize();
|
||||
}
|
||||
uint8_t *p_data = NULL;
|
||||
ReturnValue_t returnValue = store->getFreeElement(&storeAddress,
|
||||
(getPacketMinimumSize() + sourceDataSize), &p_data);
|
||||
if (returnValue != store->RETURN_OK) {
|
||||
TmPacketStoredBase::checkAndReportLostTm();
|
||||
}
|
||||
setData(p_data);
|
||||
initializeTmPacket(apid, service, subservice, packetSubcounter);
|
||||
uint8_t *putDataHere = getSourceData();
|
||||
size_t size = 0;
|
||||
if (header != NULL) {
|
||||
header->serialize(&putDataHere, &size, sourceDataSize,
|
||||
SerializeIF::Endianness::BIG);
|
||||
}
|
||||
if (content != NULL) {
|
||||
content->serialize(&putDataHere, &size, sourceDataSize,
|
||||
SerializeIF::Endianness::BIG);
|
||||
}
|
||||
setPacketDataLength(
|
||||
sourceDataSize + sizeof(PUSTmDataFieldHeaderPusA) + CRC_SIZE - 1);
|
||||
}
|
||||
|
||||
uint8_t* TmPacketStoredPusA::getAllTmData() {
|
||||
return getWholeData();
|
||||
}
|
||||
|
||||
void TmPacketStoredPusA::setDataPointer(const uint8_t *newPointer) {
|
||||
setData(newPointer);
|
||||
}
|
|
@ -0,0 +1,65 @@
|
|||
#ifndef FSFW_TMTCPACKET_PUS_TMPACKETSTORED_PUSA_H_
|
||||
#define FSFW_TMTCPACKET_PUS_TMPACKETSTORED_PUSA_H_
|
||||
|
||||
#include "TmPacketStoredBase.h"
|
||||
#include "TmPacketPusA.h"
|
||||
#include <FSFWConfig.h>
|
||||
|
||||
/**
|
||||
* This class generates a ECSS PUS A Telemetry packet within a given
|
||||
* intermediate storage.
|
||||
* As most packets are passed between tasks with the help of a storage
|
||||
* anyway, it seems logical to create a Packet-In-Storage access class
|
||||
* which saves the user almost all storage handling operation.
|
||||
* Packets can both be newly created with the class and be "linked" to
|
||||
* packets in a store with the help of a storeAddress.
|
||||
* @ingroup tmtcpackets
|
||||
*/
|
||||
class TmPacketStoredPusA :
|
||||
public TmPacketStoredBase,
|
||||
public TmPacketPusA {
|
||||
public:
|
||||
/**
|
||||
* This is a default constructor which does not set the data pointer.
|
||||
* However, it does try to set the packet store.
|
||||
*/
|
||||
TmPacketStoredPusA( store_address_t setAddress );
|
||||
/**
|
||||
* With this constructor, new space is allocated in the packet store and
|
||||
* a new PUS Telemetry Packet is created there.
|
||||
* Packet Application Data passed in data is copied into the packet.
|
||||
* The Application data is passed in two parts, first a header, then a
|
||||
* data field. This allows building a Telemetry Packet from two separate
|
||||
* data sources.
|
||||
* @param apid Sets the packet's APID field.
|
||||
* @param service Sets the packet's Service ID field.
|
||||
* This specifies the source service.
|
||||
* @param subservice Sets the packet's Service Subtype field.
|
||||
* This specifies the source sub-service.
|
||||
* @param packet_counter Sets the Packet counter field of this packet
|
||||
* @param data The payload data to be copied to the
|
||||
* Application Data Field
|
||||
* @param size The amount of data to be copied.
|
||||
* @param headerData The header Data of the Application field,
|
||||
* will be copied in front of data
|
||||
* @param headerSize The size of the headerDataF
|
||||
*/
|
||||
TmPacketStoredPusA( uint16_t apid, uint8_t service, uint8_t subservice,
|
||||
uint8_t packet_counter = 0, const uint8_t* data = nullptr,
|
||||
uint32_t size = 0, const uint8_t* headerData = nullptr,
|
||||
uint32_t headerSize = 0);
|
||||
/**
|
||||
* Another ctor to directly pass structured content and header data to the
|
||||
* packet to avoid additional buffers.
|
||||
*/
|
||||
TmPacketStoredPusA( uint16_t apid, uint8_t service, uint8_t subservice,
|
||||
uint8_t packet_counter, SerializeIF* content,
|
||||
SerializeIF* header = nullptr);
|
||||
|
||||
uint8_t* getAllTmData() override;
|
||||
void setDataPointer(const uint8_t* newPointer) override;
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif /* FSFW_TMTCPACKET_PUS_TMPACKETSTORED_PUSA_H_ */
|
|
@ -0,0 +1,80 @@
|
|||
#include "TmPacketStoredPusC.h"
|
||||
|
||||
#include "../../serviceinterface/ServiceInterface.h"
|
||||
#include "../../tmtcservices/TmTcMessage.h"
|
||||
|
||||
#include <cstring>
|
||||
|
||||
TmPacketStoredPusC::TmPacketStoredPusC(store_address_t setAddress) :
|
||||
TmPacketStoredBase(setAddress), TmPacketPusC(nullptr){
|
||||
}
|
||||
|
||||
TmPacketStoredPusC::TmPacketStoredPusC(uint16_t apid, uint8_t service,
|
||||
uint8_t subservice, uint16_t packetSubcounter, const uint8_t *data,
|
||||
uint32_t size, const uint8_t *headerData, uint32_t headerSize, uint16_t destinationId,
|
||||
uint8_t timeRefField) :
|
||||
TmPacketPusC(nullptr) {
|
||||
storeAddress.raw = StorageManagerIF::INVALID_ADDRESS;
|
||||
if (not TmPacketStoredBase::checkAndSetStore()) {
|
||||
return;
|
||||
}
|
||||
uint8_t *pData = nullptr;
|
||||
ReturnValue_t returnValue = store->getFreeElement(&storeAddress,
|
||||
(getPacketMinimumSize() + size + headerSize), &pData);
|
||||
|
||||
if (returnValue != store->RETURN_OK) {
|
||||
TmPacketStoredBase::checkAndReportLostTm();
|
||||
return;
|
||||
}
|
||||
setData(pData);
|
||||
initializeTmPacket(apid, service, subservice, packetSubcounter, destinationId, timeRefField);
|
||||
memcpy(getSourceData(), headerData, headerSize);
|
||||
memcpy(getSourceData() + headerSize, data, size);
|
||||
setPacketDataLength(
|
||||
size + headerSize + sizeof(PUSTmDataFieldHeaderPusC) + CRC_SIZE - 1);
|
||||
}
|
||||
|
||||
TmPacketStoredPusC::TmPacketStoredPusC(uint16_t apid, uint8_t service,
|
||||
uint8_t subservice, uint16_t packetSubcounter, SerializeIF *content,
|
||||
SerializeIF *header, uint16_t destinationId, uint8_t timeRefField) :
|
||||
TmPacketPusC(nullptr) {
|
||||
storeAddress.raw = StorageManagerIF::INVALID_ADDRESS;
|
||||
if (not TmPacketStoredBase::checkAndSetStore()) {
|
||||
return;
|
||||
}
|
||||
size_t sourceDataSize = 0;
|
||||
if (content != NULL) {
|
||||
sourceDataSize += content->getSerializedSize();
|
||||
}
|
||||
if (header != NULL) {
|
||||
sourceDataSize += header->getSerializedSize();
|
||||
}
|
||||
uint8_t *p_data = NULL;
|
||||
ReturnValue_t returnValue = store->getFreeElement(&storeAddress,
|
||||
(getPacketMinimumSize() + sourceDataSize), &p_data);
|
||||
if (returnValue != store->RETURN_OK) {
|
||||
TmPacketStoredBase::checkAndReportLostTm();
|
||||
}
|
||||
setData(p_data);
|
||||
initializeTmPacket(apid, service, subservice, packetSubcounter, destinationId, timeRefField);
|
||||
uint8_t *putDataHere = getSourceData();
|
||||
size_t size = 0;
|
||||
if (header != NULL) {
|
||||
header->serialize(&putDataHere, &size, sourceDataSize,
|
||||
SerializeIF::Endianness::BIG);
|
||||
}
|
||||
if (content != NULL) {
|
||||
content->serialize(&putDataHere, &size, sourceDataSize,
|
||||
SerializeIF::Endianness::BIG);
|
||||
}
|
||||
setPacketDataLength(
|
||||
sourceDataSize + sizeof(PUSTmDataFieldHeaderPusC) + CRC_SIZE - 1);
|
||||
}
|
||||
|
||||
uint8_t* TmPacketStoredPusC::getAllTmData() {
|
||||
return getWholeData();
|
||||
}
|
||||
|
||||
void TmPacketStoredPusC::setDataPointer(const uint8_t *newPointer) {
|
||||
setData(newPointer);
|
||||
}
|
|
@ -0,0 +1,65 @@
|
|||
#ifndef FSFW_TMTCPACKET_PUS_TMPACKETSTOREDPUSC_H_
|
||||
#define FSFW_TMTCPACKET_PUS_TMPACKETSTOREDPUSC_H_
|
||||
|
||||
#include <fsfw/tmtcpacket/pus/TmPacketPusC.h>
|
||||
#include <fsfw/tmtcpacket/pus/TmPacketStoredBase.h>
|
||||
|
||||
/**
|
||||
* This class generates a ECSS PUS A Telemetry packet within a given
|
||||
* intermediate storage.
|
||||
* As most packets are passed between tasks with the help of a storage
|
||||
* anyway, it seems logical to create a Packet-In-Storage access class
|
||||
* which saves the user almost all storage handling operation.
|
||||
* Packets can both be newly created with the class and be "linked" to
|
||||
* packets in a store with the help of a storeAddress.
|
||||
* @ingroup tmtcpackets
|
||||
*/
|
||||
class TmPacketStoredPusC:
|
||||
public TmPacketStoredBase,
|
||||
public TmPacketPusC {
|
||||
public:
|
||||
/**
|
||||
* This is a default constructor which does not set the data pointer.
|
||||
* However, it does try to set the packet store.
|
||||
*/
|
||||
TmPacketStoredPusC( store_address_t setAddress );
|
||||
/**
|
||||
* With this constructor, new space is allocated in the packet store and
|
||||
* a new PUS Telemetry Packet is created there.
|
||||
* Packet Application Data passed in data is copied into the packet.
|
||||
* The Application data is passed in two parts, first a header, then a
|
||||
* data field. This allows building a Telemetry Packet from two separate
|
||||
* data sources.
|
||||
* @param apid Sets the packet's APID field.
|
||||
* @param service Sets the packet's Service ID field.
|
||||
* This specifies the source service.
|
||||
* @param subservice Sets the packet's Service Subtype field.
|
||||
* This specifies the source sub-service.
|
||||
* @param packet_counter Sets the Packet counter field of this packet
|
||||
* @param data The payload data to be copied to the
|
||||
* Application Data Field
|
||||
* @param size The amount of data to be copied.
|
||||
* @param headerData The header Data of the Application field,
|
||||
* will be copied in front of data
|
||||
* @param headerSize The size of the headerDataF
|
||||
*/
|
||||
TmPacketStoredPusC( uint16_t apid, uint8_t service, uint8_t subservice,
|
||||
uint16_t packetCounter = 0, const uint8_t* data = nullptr,
|
||||
uint32_t size = 0, const uint8_t* headerData = nullptr,
|
||||
uint32_t headerSize = 0, uint16_t destinationId = 0, uint8_t timeRefField = 0);
|
||||
/**
|
||||
* Another ctor to directly pass structured content and header data to the
|
||||
* packet to avoid additional buffers.
|
||||
*/
|
||||
TmPacketStoredPusC( uint16_t apid, uint8_t service, uint8_t subservice,
|
||||
uint16_t packetCounter, SerializeIF* content,
|
||||
SerializeIF* header = nullptr, uint16_t destinationId = 0, uint8_t timeRefField = 0);
|
||||
|
||||
uint8_t* getAllTmData() override;
|
||||
void setDataPointer(const uint8_t* newPointer) override;
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif /* FSFW_TMTCPACKET_PUS_TMPACKETSTOREDPUSC_H_ */
|
|
@ -1,6 +1,7 @@
|
|||
#include "AcceptsTelemetryIF.h"
|
||||
#include "CommandingServiceBase.h"
|
||||
#include "TmTcMessage.h"
|
||||
#include <FSFWConfig.h>
|
||||
|
||||
#include "../tcdistribution/PUSDistributorIF.h"
|
||||
#include "../objectmanager/ObjectManagerIF.h"
|
||||
|
@ -293,8 +294,13 @@ void CommandingServiceBase::handleRequestQueue() {
|
|||
ReturnValue_t CommandingServiceBase::sendTmPacket(uint8_t subservice,
|
||||
const uint8_t* data, size_t dataLen, const uint8_t* headerData,
|
||||
size_t headerSize) {
|
||||
TmPacketStored tmPacketStored(this->apid, this->service, subservice,
|
||||
#if FSFW_USE_PUS_C_TELEMETRY == 0
|
||||
TmPacketStoredPusA tmPacketStored(this->apid, this->service, subservice,
|
||||
this->tmPacketCounter, data, dataLen, headerData, headerSize);
|
||||
#else
|
||||
TmPacketStoredPusC tmPacketStored(this->apid, this->service, subservice,
|
||||
this->tmPacketCounter, data, dataLen, headerData, headerSize);
|
||||
#endif
|
||||
ReturnValue_t result = tmPacketStored.sendPacket(
|
||||
requestQueue->getDefaultDestination(), requestQueue->getId());
|
||||
if (result == HasReturnvaluesIF::RETURN_OK) {
|
||||
|
@ -311,8 +317,13 @@ ReturnValue_t CommandingServiceBase::sendTmPacket(uint8_t subservice,
|
|||
size_t size = 0;
|
||||
SerializeAdapter::serialize(&objectId, &pBuffer, &size,
|
||||
sizeof(object_id_t), SerializeIF::Endianness::BIG);
|
||||
TmPacketStored tmPacketStored(this->apid, this->service, subservice,
|
||||
#if FSFW_USE_PUS_C_TELEMETRY == 0
|
||||
TmPacketStoredPusA tmPacketStored(this->apid, this->service, subservice,
|
||||
this->tmPacketCounter, data, dataLen, buffer, size);
|
||||
#else
|
||||
TmPacketStoredPusC tmPacketStored(this->apid, this->service, subservice,
|
||||
this->tmPacketCounter, data, dataLen, buffer, size);
|
||||
#endif
|
||||
ReturnValue_t result = tmPacketStored.sendPacket(
|
||||
requestQueue->getDefaultDestination(), requestQueue->getId());
|
||||
if (result == HasReturnvaluesIF::RETURN_OK) {
|
||||
|
@ -324,8 +335,13 @@ ReturnValue_t CommandingServiceBase::sendTmPacket(uint8_t subservice,
|
|||
|
||||
ReturnValue_t CommandingServiceBase::sendTmPacket(uint8_t subservice,
|
||||
SerializeIF* content, SerializeIF* header) {
|
||||
TmPacketStored tmPacketStored(this->apid, this->service, subservice,
|
||||
#if FSFW_USE_PUS_C_TELEMETRY == 0
|
||||
TmPacketStoredPusA tmPacketStored(this->apid, this->service, subservice,
|
||||
this->tmPacketCounter, content, header);
|
||||
#else
|
||||
TmPacketStoredPusC tmPacketStored(this->apid, this->service, subservice,
|
||||
this->tmPacketCounter, content, header);
|
||||
#endif
|
||||
ReturnValue_t result = tmPacketStored.sendPacket(
|
||||
requestQueue->getDefaultDestination(), requestQueue->getId());
|
||||
if (result == HasReturnvaluesIF::RETURN_OK) {
|
||||
|
|
|
@ -16,7 +16,9 @@ TmTcBridge::TmTcBridge(object_id_t objectId, object_id_t tcDestination,
|
|||
createMessageQueue(TMTC_RECEPTION_QUEUE_DEPTH);
|
||||
}
|
||||
|
||||
TmTcBridge::~TmTcBridge() {}
|
||||
TmTcBridge::~TmTcBridge() {
|
||||
QueueFactory::instance()->deleteMessageQueue(tmTcReceptionQueue);
|
||||
}
|
||||
|
||||
ReturnValue_t TmTcBridge::setNumberOfSentPacketsPerCycle(
|
||||
uint8_t sentPacketsPerCycle) {
|
||||
|
|
|
@ -21,7 +21,7 @@ TmTcMessage::TmTcMessage(store_address_t storeId) {
|
|||
this->setStorageId(storeId);
|
||||
}
|
||||
|
||||
size_t TmTcMessage::getMinimumMessageSize() {
|
||||
size_t TmTcMessage::getMinimumMessageSize() const {
|
||||
return this->HEADER_SIZE + sizeof(store_address_t);
|
||||
}
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@ protected:
|
|||
* @brief This call always returns the same fixed size of the message.
|
||||
* @return Returns HEADER_SIZE + @c sizeof(store_address_t).
|
||||
*/
|
||||
size_t getMinimumMessageSize();
|
||||
size_t getMinimumMessageSize() const override;
|
||||
public:
|
||||
/**
|
||||
* @brief In the default constructor, only the message_size is set.
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
target_sources(${TARGET_NAME} PRIVATE
|
||||
PusTmTest.cpp
|
||||
)
|
|
@ -0,0 +1,3 @@
|
|||
|
||||
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
#include "CatchFactory.h"
|
||||
#include <fsfw/datapoollocal/LocalDataPoolManager.h>
|
||||
#include <fsfw/devicehandlers/DeviceHandlerBase.h>
|
||||
#include "CatchFactory.h"
|
||||
|
||||
#include <fsfw/events/EventManager.h>
|
||||
#include <fsfw/health/HealthTable.h>
|
||||
|
@ -74,7 +74,7 @@ void Factory::setStaticFrameworkObjectIds() {
|
|||
|
||||
DeviceHandlerFailureIsolation::powerConfirmationId = objects::NO_OBJECT;
|
||||
|
||||
TmPacketStored::timeStamperId = objects::NO_OBJECT;
|
||||
TmPacketBase::timeStamperId = objects::NO_OBJECT;
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue