Merge remote-tracking branch 'upstream/mueller/master' into mueller/master
This commit is contained in:
commit
cac9a0eecd
@ -184,6 +184,7 @@ endif()
|
|||||||
target_include_directories(${LIB_FSFW_NAME} INTERFACE
|
target_include_directories(${LIB_FSFW_NAME} INTERFACE
|
||||||
${CMAKE_SOURCE_DIR}
|
${CMAKE_SOURCE_DIR}
|
||||||
${FSFW_CONFIG_PATH_ABSOLUTE}
|
${FSFW_CONFIG_PATH_ABSOLUTE}
|
||||||
|
${FSFW_ADD_INC_PATHS_ABS}
|
||||||
)
|
)
|
||||||
|
|
||||||
# Includes path required to compile FSFW itself as well
|
# Includes path required to compile FSFW itself as well
|
||||||
|
@ -17,6 +17,8 @@
|
|||||||
#define FSFW_DISABLE_PRINTOUT 0
|
#define FSFW_DISABLE_PRINTOUT 0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#define FSFW_USE_PUS_C_TELEMETRY 1
|
||||||
|
|
||||||
//! Can be used to disable the ANSI color sequences for C stdio.
|
//! Can be used to disable the ANSI color sequences for C stdio.
|
||||||
#define FSFW_COLORED_OUTPUT 1
|
#define FSFW_COLORED_OUTPUT 1
|
||||||
|
|
||||||
@ -40,10 +42,17 @@
|
|||||||
//! Specify whether a special mode store is used for Subsystem components.
|
//! Specify whether a special mode store is used for Subsystem components.
|
||||||
#define FSFW_USE_MODESTORE 0
|
#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 {
|
namespace fsfwconfig {
|
||||||
//! Default timestamp size. The default timestamp will be an eight byte CDC
|
|
||||||
//! short timestamp.
|
//! Default timestamp size. The default timestamp will be an seven 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.
|
//! Configure the allocated pool sizes for the event manager.
|
||||||
static constexpr size_t FSFW_EVENTMGMR_MATCHTREE_NODES = 240;
|
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
|
//! Defines the FIFO depth of each commanding service base which
|
||||||
//! also determines how many commands a CSB service can handle in one cycle
|
//! 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 !
|
//! each CSB service !
|
||||||
static constexpr uint8_t FSFW_CSB_FIFO_DEPTH = 6;
|
static constexpr uint8_t FSFW_CSB_FIFO_DEPTH = 6;
|
||||||
|
|
||||||
static constexpr size_t FSFW_PRINT_BUFFER_SIZE = 124;
|
static constexpr size_t FSFW_PRINT_BUFFER_SIZE = 124;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* CONFIG_FSFWCONFIG_H_ */
|
#endif /* CONFIG_FSFWCONFIG_H_ */
|
||||||
|
@ -24,6 +24,13 @@
|
|||||||
* 1. check logic when active-> checkChildrenStateOn
|
* 1. check logic when active-> checkChildrenStateOn
|
||||||
* 2. transition logic to change the mode -> commandChildren
|
* 2. transition logic to change the mode -> commandChildren
|
||||||
*
|
*
|
||||||
|
* Important:
|
||||||
|
*
|
||||||
|
* The implementation must call registerChild(object_id_t child)
|
||||||
|
* for all commanded children during initialization.
|
||||||
|
* The implementation must call the initialization function of the base class.
|
||||||
|
* (This will call the function in SubsystemBase)
|
||||||
|
*
|
||||||
*/
|
*/
|
||||||
class AssemblyBase: public SubsystemBase {
|
class AssemblyBase: public SubsystemBase {
|
||||||
public:
|
public:
|
||||||
@ -41,9 +48,6 @@ public:
|
|||||||
virtual ~AssemblyBase();
|
virtual ~AssemblyBase();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
// SHOULDDO: Change that OVERWRITE_HEALTH may be returned
|
|
||||||
// (or return internalState directly?)
|
|
||||||
/**
|
/**
|
||||||
* Command children to reach [mode,submode] combination
|
* Command children to reach [mode,submode] combination
|
||||||
* Can be done by setting #commandsOutstanding correctly,
|
* Can be done by setting #commandsOutstanding correctly,
|
||||||
@ -68,6 +72,18 @@ protected:
|
|||||||
virtual ReturnValue_t checkChildrenStateOn(Mode_t wantedMode,
|
virtual ReturnValue_t checkChildrenStateOn(Mode_t wantedMode,
|
||||||
Submode_t wantedSubmode) = 0;
|
Submode_t wantedSubmode) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check whether a combination of mode and submode is valid.
|
||||||
|
*
|
||||||
|
* Ground Controller like precise return values from HasModesIF.
|
||||||
|
* So, please return any of them.
|
||||||
|
*
|
||||||
|
* @param mode The targeted mode
|
||||||
|
* @param submode The targeted submmode
|
||||||
|
* @return Any information why this combination is invalid from HasModesIF
|
||||||
|
* like HasModesIF::INVALID_SUBMODE.
|
||||||
|
* On success return HasReturnvaluesIF::RETURN_OK
|
||||||
|
*/
|
||||||
virtual ReturnValue_t isModeCombinationValid(Mode_t mode,
|
virtual ReturnValue_t isModeCombinationValid(Mode_t mode,
|
||||||
Submode_t submode) = 0;
|
Submode_t submode) = 0;
|
||||||
|
|
||||||
|
@ -16,9 +16,9 @@ ReturnValue_t HealthDevice::performOperation(uint8_t opCode) {
|
|||||||
CommandMessage command;
|
CommandMessage command;
|
||||||
ReturnValue_t result = commandQueue->receiveMessage(&command);
|
ReturnValue_t result = commandQueue->receiveMessage(&command);
|
||||||
if (result == HasReturnvaluesIF::RETURN_OK) {
|
if (result == HasReturnvaluesIF::RETURN_OK) {
|
||||||
healthHelper.handleHealthCommand(&command);
|
result = healthHelper.handleHealthCommand(&command);
|
||||||
}
|
}
|
||||||
return HasReturnvaluesIF::RETURN_OK;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
ReturnValue_t HealthDevice::initialize() {
|
ReturnValue_t HealthDevice::initialize() {
|
||||||
|
@ -81,11 +81,17 @@ void HealthTable::printAll(uint8_t* pointer, size_t maxSize) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
for (const auto& health: healthMap) {
|
for (const auto& health: healthMap) {
|
||||||
SerializeAdapter::serialize(&health.first,
|
result = SerializeAdapter::serialize(&health.first,
|
||||||
&pointer, &size, maxSize, SerializeIF::Endianness::BIG);
|
&pointer, &size, maxSize, SerializeIF::Endianness::BIG);
|
||||||
|
if(result != HasReturnvaluesIF::RETURN_OK) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
uint8_t healthValue = health.second;
|
uint8_t healthValue = health.second;
|
||||||
SerializeAdapter::serialize(&healthValue, &pointer, &size,
|
result = SerializeAdapter::serialize(&healthValue, &pointer, &size,
|
||||||
maxSize, SerializeIF::Endianness::BIG);
|
maxSize, SerializeIF::Endianness::BIG);
|
||||||
|
if(result != HasReturnvaluesIF::RETURN_OK) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -96,7 +102,7 @@ ReturnValue_t HealthTable::iterate(HealthEntry *value, bool reset) {
|
|||||||
mapIterator = healthMap.begin();
|
mapIterator = healthMap.begin();
|
||||||
}
|
}
|
||||||
if (mapIterator == healthMap.end()) {
|
if (mapIterator == healthMap.end()) {
|
||||||
result = HasReturnvaluesIF::RETURN_FAILED;
|
return HasReturnvaluesIF::RETURN_FAILED;
|
||||||
}
|
}
|
||||||
*value = *mapIterator;
|
*value = *mapIterator;
|
||||||
mapIterator++;
|
mapIterator++;
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
//! Debugging preprocessor define.
|
//! Debugging preprocessor define.
|
||||||
#define FSFW_UDP_RCV_WIRETAPPING_ENABLED 0
|
#define FSFW_UDP_RECV_WIRETAPPING_ENABLED 0
|
||||||
|
|
||||||
UdpTcPollingTask::UdpTcPollingTask(object_id_t objectId,
|
UdpTcPollingTask::UdpTcPollingTask(object_id_t objectId,
|
||||||
object_id_t tmtcUnixUdpBridge, size_t maxRecvSize,
|
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);
|
tcpip::handleError(tcpip::Protocol::UDP, tcpip::ErrorSources::RECVFROM_CALL, 1000);
|
||||||
continue;
|
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 <<
|
sif::debug << "UdpTcPollingTask::performOperation: " << bytesReceived <<
|
||||||
" bytes received" << std::endl;
|
" bytes received" << std::endl;
|
||||||
|
#else
|
||||||
#endif
|
#endif
|
||||||
|
#endif /* FSFW_UDP_RCV_WIRETAPPING_ENABLED == 1 */
|
||||||
|
|
||||||
ReturnValue_t result = handleSuccessfullTcRead(bytesReceived);
|
ReturnValue_t result = handleSuccessfullTcRead(bytesReceived);
|
||||||
if(result != HasReturnvaluesIF::RETURN_FAILED) {
|
if(result != HasReturnvaluesIF::RETURN_FAILED) {
|
||||||
@ -84,7 +87,7 @@ ReturnValue_t UdpTcPollingTask::performOperation(uint8_t opCode) {
|
|||||||
ReturnValue_t UdpTcPollingTask::handleSuccessfullTcRead(size_t bytesRead) {
|
ReturnValue_t UdpTcPollingTask::handleSuccessfullTcRead(size_t bytesRead) {
|
||||||
store_address_t storeId;
|
store_address_t storeId;
|
||||||
|
|
||||||
#if FSFW_UDP_RCV_WIRETAPPING_ENABLED == 1
|
#if FSFW_UDP_RECV_WIRETAPPING_ENABLED == 1
|
||||||
arrayprinter::print(receptionBuffer.data(), bytesRead);
|
arrayprinter::print(receptionBuffer.data(), bytesRead);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -70,6 +70,7 @@ ReturnValue_t UdpTmTcBridge::initialize() {
|
|||||||
hints.ai_family = AF_INET;
|
hints.ai_family = AF_INET;
|
||||||
hints.ai_socktype = SOCK_DGRAM;
|
hints.ai_socktype = SOCK_DGRAM;
|
||||||
hints.ai_protocol = IPPROTO_UDP;
|
hints.ai_protocol = IPPROTO_UDP;
|
||||||
|
hints.ai_flags = AI_PASSIVE;
|
||||||
|
|
||||||
/* Set up UDP socket:
|
/* Set up UDP socket:
|
||||||
https://en.wikipedia.org/wiki/Getaddrinfo
|
https://en.wikipedia.org/wiki/Getaddrinfo
|
||||||
@ -95,6 +96,10 @@ ReturnValue_t UdpTmTcBridge::initialize() {
|
|||||||
return HasReturnvaluesIF::RETURN_FAILED;
|
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));
|
retval = bind(serverSocket, addrResult->ai_addr, static_cast<int>(addrResult->ai_addrlen));
|
||||||
if(retval != 0) {
|
if(retval != 0) {
|
||||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||||
@ -121,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 */
|
/* The target address can be set by different threads so this lock ensures thread-safety */
|
||||||
MutexGuard lock(mutex, timeoutType, mutexTimeoutMs);
|
MutexGuard lock(mutex, timeoutType, mutexTimeoutMs);
|
||||||
|
|
||||||
#if FSFW_CPP_OSTREAM_ENABLED == 1 && FSFW_UDP_SEND_WIRETAPPING_ENABLED == 1
|
#if FSFW_UDP_SEND_WIRETAPPING_ENABLED == 1
|
||||||
char ipAddress [15];
|
tcpip::printAddress(&clientAddress);
|
||||||
sif::debug << "IP Address Sender: "<< inet_ntop(AF_INET,
|
|
||||||
&clientAddress.sin_addr.s_addr, ipAddress, 15) << std::endl;
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int bytesSent = sendto(
|
int bytesSent = sendto(
|
||||||
@ -152,13 +155,11 @@ void UdpTmTcBridge::checkAndSetClientAddress(sockaddr& newAddress) {
|
|||||||
/* The target address can be set by different threads so this lock ensures thread-safety */
|
/* The target address can be set by different threads so this lock ensures thread-safety */
|
||||||
MutexGuard lock(mutex, timeoutType, mutexTimeoutMs);
|
MutexGuard lock(mutex, timeoutType, mutexTimeoutMs);
|
||||||
|
|
||||||
#if FSFW_CPP_OSTREAM_ENABLED == 1 && FSFW_UDP_SEND_WIRETAPPING_ENABLED == 1
|
#if FSFW_UDP_SEND_WIRETAPPING_ENABLED == 1
|
||||||
char ipAddress [15];
|
tcpip::printAddress(&newAddress);
|
||||||
sif::debug << "IP Address Sender: "<< inet_ntop(AF_INET,
|
tcpip::printAddress(&clientAddress);
|
||||||
&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;
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
registerCommConnect();
|
registerCommConnect();
|
||||||
|
|
||||||
/* Set new IP address to reply to */
|
/* Set new IP address to reply to */
|
||||||
|
@ -1,4 +1,9 @@
|
|||||||
#include "tcpipCommon.h"
|
#include "tcpipCommon.h"
|
||||||
|
#include <fsfw/serviceinterface/ServiceInterface.h>
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
#include <ws2tcpip.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
void tcpip::determineErrorStrings(Protocol protocol, ErrorSources errorSrc, std::string &protStr,
|
void tcpip::determineErrorStrings(Protocol protocol, ErrorSources errorSrc, std::string &protStr,
|
||||||
std::string &srcString) {
|
std::string &srcString) {
|
||||||
@ -34,3 +39,37 @@ void tcpip::determineErrorStrings(Protocol protocol, ErrorSources errorSrc, std:
|
|||||||
srcString = "unknown call";
|
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 "../../timemanager/clockDefinitions.h"
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
#include <winsock2.h>
|
||||||
|
#else
|
||||||
|
#include <netdb.h>
|
||||||
|
#include <arpa/inet.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace tcpip {
|
namespace tcpip {
|
||||||
|
|
||||||
const char* const DEFAULT_SERVER_PORT = "7301";
|
const char* const DEFAULT_SERVER_PORT = "7301";
|
||||||
@ -28,8 +35,8 @@ enum class ErrorSources {
|
|||||||
void determineErrorStrings(Protocol protocol, ErrorSources errorSrc, std::string& protStr,
|
void determineErrorStrings(Protocol protocol, ErrorSources errorSrc, std::string& protStr,
|
||||||
std::string& srcString);
|
std::string& srcString);
|
||||||
|
|
||||||
|
void printAddress(struct sockaddr* addr);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#endif /* FSFW_OSAL_COMMON_TCPIPCOMMON_H_ */
|
#endif /* FSFW_OSAL_COMMON_TCPIPCOMMON_H_ */
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
#include "../../ipc/MutexFactory.h"
|
#include "../../ipc/MutexFactory.h"
|
||||||
#include "../../osal/host/Mutex.h"
|
#include "../../osal/host/Mutex.h"
|
||||||
#include "../../osal/host/FixedTimeslotTask.h"
|
#include "../../osal/host/FixedTimeslotTask.h"
|
||||||
#include "../../serviceinterface/ServiceInterfaceStream.h"
|
#include "../../serviceinterface/ServiceInterface.h"
|
||||||
#include "../../tasks/ExecutableObjectIF.h"
|
#include "../../tasks/ExecutableObjectIF.h"
|
||||||
|
|
||||||
#include <thread>
|
#include <thread>
|
||||||
|
@ -21,7 +21,7 @@ PeriodicTask::PeriodicTask(const char *name, TaskPriority setPriority,
|
|||||||
void (*setDeadlineMissedFunc)()) :
|
void (*setDeadlineMissedFunc)()) :
|
||||||
started(false), taskName(name), period(setPeriod),
|
started(false), taskName(name), period(setPeriod),
|
||||||
deadlineMissedFunc(setDeadlineMissedFunc) {
|
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
|
// task handles for Windows / Linux
|
||||||
mainThread = std::thread(&PeriodicTask::taskEntryPoint, this, this);
|
mainThread = std::thread(&PeriodicTask::taskEntryPoint, this, this);
|
||||||
#if defined(_WIN32)
|
#if defined(_WIN32)
|
||||||
|
@ -181,11 +181,14 @@ void PosixThread::createTask(void* (*fnc_)(void*), void* arg_) {
|
|||||||
sif::error << "Posix Thread attribute setinheritsched failed with: " <<
|
sif::error << "Posix Thread attribute setinheritsched failed with: " <<
|
||||||
strerror(status) << std::endl;
|
strerror(status) << std::endl;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
#ifndef FSFW_USE_REALTIME_FOR_LINUX
|
||||||
// TODO FIFO -> This needs root privileges for the process
|
#error "Please define FSFW_USE_REALTIME_FOR_LINUX with either 0 or 1"
|
||||||
status = pthread_attr_setschedpolicy(&attributes,SCHED_FIFO);
|
#endif
|
||||||
if(status != 0){
|
#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
|
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||||
sif::error << "Posix Thread attribute schedule policy failed with: " <<
|
sif::error << "Posix Thread attribute schedule policy failed with: " <<
|
||||||
strerror(status) << std::endl;
|
strerror(status) << std::endl;
|
||||||
@ -200,14 +203,14 @@ void PosixThread::createTask(void* (*fnc_)(void*), void* arg_) {
|
|||||||
sif::error << "Posix Thread attribute schedule params failed with: " <<
|
sif::error << "Posix Thread attribute schedule params failed with: " <<
|
||||||
strerror(status) << std::endl;
|
strerror(status) << std::endl;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
//Set Signal Mask for suspend until startTask is called
|
//Set Signal Mask for suspend until startTask is called
|
||||||
sigset_t waitSignal;
|
sigset_t waitSignal;
|
||||||
sigemptyset(&waitSignal);
|
sigemptyset(&waitSignal);
|
||||||
sigaddset(&waitSignal, SIGUSR1);
|
sigaddset(&waitSignal, SIGUSR1);
|
||||||
status = pthread_sigmask(SIG_BLOCK, &waitSignal, NULL);
|
status = pthread_sigmask(SIG_BLOCK, &waitSignal, NULL);
|
||||||
if(status != 0){
|
if(status != 0){
|
||||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||||
sif::error << "Posix Thread sigmask failed failed with: " <<
|
sif::error << "Posix Thread sigmask failed failed with: " <<
|
||||||
strerror(status) << " errno: " << strerror(errno) << std::endl;
|
strerror(status) << " errno: " << strerror(errno) << std::endl;
|
||||||
@ -218,8 +221,16 @@ void PosixThread::createTask(void* (*fnc_)(void*), void* arg_) {
|
|||||||
status = pthread_create(&thread,&attributes,fnc_,arg_);
|
status = pthread_create(&thread,&attributes,fnc_,arg_);
|
||||||
if(status != 0){
|
if(status != 0){
|
||||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||||
sif::error << "Posix Thread create failed with: " <<
|
sif::error << "PosixThread::createTask: Failed with: " <<
|
||||||
strerror(status) << std::endl;
|
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
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -99,8 +99,8 @@ void tcpip::handleError(Protocol protocol, ErrorSources errorSrc, dur_millis_t s
|
|||||||
sif::warning << "tcpip::handleError: " << protocolString << " | " << errorSrcString <<
|
sif::warning << "tcpip::handleError: " << protocolString << " | " << errorSrcString <<
|
||||||
" | " << infoString << std::endl;
|
" | " << infoString << std::endl;
|
||||||
#else
|
#else
|
||||||
sif::printWarning("tcpip::handleError: %s | %s | %s\n", protocolString,
|
sif::printWarning("tcpip::handleError: %s | %s | %s\n", protocolString.c_str(),
|
||||||
errorSrcString, infoString);
|
errorSrcString.c_str(), infoString.c_str());
|
||||||
#endif /* FSFW_CPP_OSTREAM_ENABLED == 1 */
|
#endif /* FSFW_CPP_OSTREAM_ENABLED == 1 */
|
||||||
|
|
||||||
if(sleepDuration > 0) {
|
if(sleepDuration > 0) {
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
#include "Service17Test.h"
|
#include "Service17Test.h"
|
||||||
|
#include <FSFWConfig.h>
|
||||||
|
|
||||||
#include "../serviceinterface/ServiceInterfaceStream.h"
|
#include "../serviceinterface/ServiceInterface.h"
|
||||||
#include "../objectmanager/SystemObject.h"
|
#include "../objectmanager/SystemObject.h"
|
||||||
#include "../tmtcpacket/pus/TmPacketStored.h"
|
#include "../tmtcpacket/pus/TmPacketStored.h"
|
||||||
|
|
||||||
@ -17,15 +18,25 @@ Service17Test::~Service17Test() {
|
|||||||
ReturnValue_t Service17Test::handleRequest(uint8_t subservice) {
|
ReturnValue_t Service17Test::handleRequest(uint8_t subservice) {
|
||||||
switch(subservice) {
|
switch(subservice) {
|
||||||
case Subservice::CONNECTION_TEST: {
|
case Subservice::CONNECTION_TEST: {
|
||||||
TmPacketStored connectionPacket(apid, serviceId,
|
#if FSFW_USE_PUS_C_TELEMETRY == 0
|
||||||
|
TmPacketStoredPusA connectionPacket(apid, serviceId,
|
||||||
Subservice::CONNECTION_TEST_REPORT, packetSubCounter++);
|
Subservice::CONNECTION_TEST_REPORT, packetSubCounter++);
|
||||||
|
#else
|
||||||
|
TmPacketStoredPusC connectionPacket(apid, serviceId,
|
||||||
|
Subservice::CONNECTION_TEST_REPORT, packetSubCounter++);
|
||||||
|
#endif
|
||||||
connectionPacket.sendPacket(requestQueue->getDefaultDestination(),
|
connectionPacket.sendPacket(requestQueue->getDefaultDestination(),
|
||||||
requestQueue->getId());
|
requestQueue->getId());
|
||||||
return HasReturnvaluesIF::RETURN_OK;
|
return HasReturnvaluesIF::RETURN_OK;
|
||||||
}
|
}
|
||||||
case Subservice::EVENT_TRIGGER_TEST: {
|
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++);
|
Subservice::CONNECTION_TEST_REPORT, packetSubCounter++);
|
||||||
|
#else
|
||||||
|
TmPacketStoredPusC connectionPacket(apid, serviceId,
|
||||||
|
Subservice::CONNECTION_TEST_REPORT, packetSubCounter++);
|
||||||
|
#endif
|
||||||
connectionPacket.sendPacket(requestQueue->getDefaultDestination(),
|
connectionPacket.sendPacket(requestQueue->getDefaultDestination(),
|
||||||
requestQueue->getId());
|
requestQueue->getId());
|
||||||
triggerEvent(TEST, 1234, 5678);
|
triggerEvent(TEST, 1234, 5678);
|
||||||
|
@ -68,8 +68,13 @@ ReturnValue_t Service1TelecommandVerification::generateFailureReport(
|
|||||||
message->getTcSequenceControl(), message->getStep(),
|
message->getTcSequenceControl(), message->getStep(),
|
||||||
message->getErrorCode(), message->getParameter1(),
|
message->getErrorCode(), message->getParameter1(),
|
||||||
message->getParameter2());
|
message->getParameter2());
|
||||||
TmPacketStored tmPacket(apid, serviceId, message->getReportId(),
|
#if FSFW_USE_PUS_C_TELEMETRY == 0
|
||||||
|
TmPacketStoredPusA tmPacket(apid, serviceId, message->getReportId(),
|
||||||
packetSubCounter++, &report);
|
packetSubCounter++, &report);
|
||||||
|
#else
|
||||||
|
TmPacketStoredPusC tmPacket(apid, serviceId, message->getReportId(),
|
||||||
|
packetSubCounter++, &report);
|
||||||
|
#endif
|
||||||
ReturnValue_t result = tmPacket.sendPacket(tmQueue->getDefaultDestination(),
|
ReturnValue_t result = tmPacket.sendPacket(tmQueue->getDefaultDestination(),
|
||||||
tmQueue->getId());
|
tmQueue->getId());
|
||||||
return result;
|
return result;
|
||||||
@ -79,8 +84,13 @@ ReturnValue_t Service1TelecommandVerification::generateSuccessReport(
|
|||||||
PusVerificationMessage *message) {
|
PusVerificationMessage *message) {
|
||||||
SuccessReport report(message->getReportId(),message->getTcPacketId(),
|
SuccessReport report(message->getReportId(),message->getTcPacketId(),
|
||||||
message->getTcSequenceControl(),message->getStep());
|
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);
|
packetSubCounter++, &report);
|
||||||
|
#else
|
||||||
|
TmPacketStoredPusC tmPacket(apid, serviceId, message->getReportId(),
|
||||||
|
packetSubCounter++, &report);
|
||||||
|
#endif
|
||||||
ReturnValue_t result = tmPacket.sendPacket(tmQueue->getDefaultDestination(),
|
ReturnValue_t result = tmPacket.sendPacket(tmQueue->getDefaultDestination(),
|
||||||
tmQueue->getId());
|
tmQueue->getId());
|
||||||
return result;
|
return result;
|
||||||
|
@ -52,8 +52,13 @@ ReturnValue_t Service5EventReporting::generateEventReport(
|
|||||||
{
|
{
|
||||||
EventReport report(message.getEventId(),message.getReporter(),
|
EventReport report(message.getEventId(),message.getReporter(),
|
||||||
message.getParameter1(),message.getParameter2());
|
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);
|
message.getSeverity(), packetSubCounter++, &report);
|
||||||
|
#else
|
||||||
|
TmPacketStoredPusC tmPacket(PusServiceBase::apid, PusServiceBase::serviceId,
|
||||||
|
message.getSeverity(), packetSubCounter++, &report);
|
||||||
|
#endif
|
||||||
ReturnValue_t result = tmPacket.sendPacket(
|
ReturnValue_t result = tmPacket.sendPacket(
|
||||||
requestQueue->getDefaultDestination(),requestQueue->getId());
|
requestQueue->getDefaultDestination(),requestQueue->getId());
|
||||||
if(result != HasReturnvaluesIF::RETURN_OK) {
|
if(result != HasReturnvaluesIF::RETURN_OK) {
|
||||||
|
@ -5,8 +5,7 @@
|
|||||||
|
|
||||||
SubsystemBase::SubsystemBase(object_id_t setObjectId, object_id_t parent,
|
SubsystemBase::SubsystemBase(object_id_t setObjectId, object_id_t parent,
|
||||||
Mode_t initialMode, uint16_t commandQueueDepth) :
|
Mode_t initialMode, uint16_t commandQueueDepth) :
|
||||||
SystemObject(setObjectId), mode(initialMode), submode(SUBMODE_NONE),
|
SystemObject(setObjectId), mode(initialMode),
|
||||||
childrenChangedMode(false),
|
|
||||||
commandQueue(QueueFactory::instance()->createMessageQueue(
|
commandQueue(QueueFactory::instance()->createMessageQueue(
|
||||||
commandQueueDepth, CommandMessage::MAX_MESSAGE_SIZE)),
|
commandQueueDepth, CommandMessage::MAX_MESSAGE_SIZE)),
|
||||||
healthHelper(this, setObjectId), modeHelper(this), parentId(parent) {
|
healthHelper(this, setObjectId), modeHelper(this), parentId(parent) {
|
||||||
@ -167,16 +166,16 @@ MessageQueueId_t SubsystemBase::getCommandQueue() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ReturnValue_t SubsystemBase::initialize() {
|
ReturnValue_t SubsystemBase::initialize() {
|
||||||
MessageQueueId_t parentQueue = 0;
|
MessageQueueId_t parentQueue = MessageQueueIF::NO_QUEUE;
|
||||||
ReturnValue_t result = SystemObject::initialize();
|
ReturnValue_t result = SystemObject::initialize();
|
||||||
|
|
||||||
if (result != RETURN_OK) {
|
if (result != RETURN_OK) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (parentId != 0) {
|
if (parentId != objects::NO_OBJECT) {
|
||||||
SubsystemBase *parent = objectManager->get<SubsystemBase>(parentId);
|
SubsystemBase *parent = objectManager->get<SubsystemBase>(parentId);
|
||||||
if (parent == NULL) {
|
if (parent == nullptr) {
|
||||||
return RETURN_FAILED;
|
return RETURN_FAILED;
|
||||||
}
|
}
|
||||||
parentQueue = parent->getCommandQueue();
|
parentQueue = parent->getCommandQueue();
|
||||||
|
@ -37,6 +37,17 @@ public:
|
|||||||
|
|
||||||
virtual MessageQueueId_t getCommandQueue() const override;
|
virtual MessageQueueId_t getCommandQueue() const override;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Function to register the child objects.
|
||||||
|
* Performs a checks if the child does implement HasHealthIF and/or HasModesIF
|
||||||
|
*
|
||||||
|
* Also adds them to the internal childrenMap.
|
||||||
|
*
|
||||||
|
* @param objectId
|
||||||
|
* @return RETURN_OK if successful
|
||||||
|
* CHILD_DOESNT_HAVE_MODES if Child is no HasHealthIF and no HasModesIF
|
||||||
|
* COULD_NOT_INSERT_CHILD If the Child could not be added to the ChildrenMap
|
||||||
|
*/
|
||||||
ReturnValue_t registerChild(object_id_t objectId);
|
ReturnValue_t registerChild(object_id_t objectId);
|
||||||
|
|
||||||
virtual ReturnValue_t initialize() override;
|
virtual ReturnValue_t initialize() override;
|
||||||
@ -56,9 +67,9 @@ protected:
|
|||||||
|
|
||||||
Mode_t mode;
|
Mode_t mode;
|
||||||
|
|
||||||
Submode_t submode;
|
Submode_t submode = SUBMODE_NONE;
|
||||||
|
|
||||||
bool childrenChangedMode;
|
bool childrenChangedMode = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Always check this against <=0, so you are robust against too many replies
|
* Always check this against <=0, so you are robust against too many replies
|
||||||
|
@ -1,350 +1,352 @@
|
|||||||
#include "../devicehandlers/DeviceHandlerFailureIsolation.h"
|
|
||||||
#include "Heater.h"
|
#include "Heater.h"
|
||||||
|
|
||||||
|
#include "../devicehandlers/DeviceHandlerFailureIsolation.h"
|
||||||
#include "../power/Fuse.h"
|
#include "../power/Fuse.h"
|
||||||
#include "../ipc/QueueFactory.h"
|
#include "../ipc/QueueFactory.h"
|
||||||
|
|
||||||
Heater::Heater(uint32_t objectId, uint8_t switch0, uint8_t switch1) :
|
Heater::Heater(uint32_t objectId, uint8_t switch0, uint8_t switch1) :
|
||||||
HealthDevice(objectId, 0), internalState(STATE_OFF), powerSwitcher(
|
HealthDevice(objectId, 0), internalState(STATE_OFF), switch0(switch0), switch1(switch1),
|
||||||
NULL), pcduQueueId(0), switch0(switch0), switch1(switch1), wasOn(
|
heaterOnCountdown(10800000)/*about two orbits*/,
|
||||||
false), timedOut(false), reactedToBeingFaulty(false), passive(
|
parameterHelper(this) {
|
||||||
false), eventQueue(NULL), heaterOnCountdown(10800000)/*about two orbits*/, parameterHelper(
|
eventQueue = QueueFactory::instance()->createMessageQueue();
|
||||||
this), lastAction(CLEAR) {
|
|
||||||
eventQueue = QueueFactory::instance()->createMessageQueue();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Heater::~Heater() {
|
Heater::~Heater() {
|
||||||
QueueFactory::instance()->deleteMessageQueue(eventQueue);
|
QueueFactory::instance()->deleteMessageQueue(eventQueue);
|
||||||
}
|
}
|
||||||
|
|
||||||
ReturnValue_t Heater::set() {
|
ReturnValue_t Heater::set() {
|
||||||
passive = false;
|
passive = false;
|
||||||
//wait for clear before doing anything
|
//wait for clear before doing anything
|
||||||
if (internalState == STATE_WAIT) {
|
if (internalState == STATE_WAIT) {
|
||||||
return HasReturnvaluesIF::RETURN_OK;
|
return HasReturnvaluesIF::RETURN_OK;
|
||||||
}
|
}
|
||||||
if (healthHelper.healthTable->isHealthy(getObjectId())) {
|
if (healthHelper.healthTable->isHealthy(getObjectId())) {
|
||||||
doAction(SET);
|
doAction(SET);
|
||||||
if ((internalState == STATE_OFF) || (internalState == STATE_PASSIVE)){
|
if ((internalState == STATE_OFF) || (internalState == STATE_PASSIVE)){
|
||||||
return HasReturnvaluesIF::RETURN_FAILED;
|
return HasReturnvaluesIF::RETURN_FAILED;
|
||||||
} else {
|
} else {
|
||||||
return HasReturnvaluesIF::RETURN_OK;
|
return HasReturnvaluesIF::RETURN_OK;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (healthHelper.healthTable->isFaulty(getObjectId())) {
|
if (healthHelper.healthTable->isFaulty(getObjectId())) {
|
||||||
if (!reactedToBeingFaulty) {
|
if (!reactedToBeingFaulty) {
|
||||||
reactedToBeingFaulty = true;
|
reactedToBeingFaulty = true;
|
||||||
doAction(CLEAR);
|
doAction(CLEAR);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return HasReturnvaluesIF::RETURN_FAILED;
|
return HasReturnvaluesIF::RETURN_FAILED;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Heater::clear(bool passive) {
|
void Heater::clear(bool passive) {
|
||||||
this->passive = passive;
|
this->passive = passive;
|
||||||
//Force switching off
|
//Force switching off
|
||||||
if (internalState == STATE_WAIT) {
|
if (internalState == STATE_WAIT) {
|
||||||
internalState = STATE_ON;
|
internalState = STATE_ON;
|
||||||
}
|
}
|
||||||
if (healthHelper.healthTable->isHealthy(getObjectId())) {
|
if (healthHelper.healthTable->isHealthy(getObjectId())) {
|
||||||
doAction(CLEAR);
|
doAction(CLEAR);
|
||||||
} else if (healthHelper.healthTable->isFaulty(getObjectId())) {
|
} else if (healthHelper.healthTable->isFaulty(getObjectId())) {
|
||||||
if (!reactedToBeingFaulty) {
|
if (!reactedToBeingFaulty) {
|
||||||
reactedToBeingFaulty = true;
|
reactedToBeingFaulty = true;
|
||||||
doAction(CLEAR);
|
doAction(CLEAR);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Heater::doAction(Action action) {
|
void Heater::doAction(Action action) {
|
||||||
//only act if we are not in the right state or in a transition
|
//only act if we are not in the right state or in a transition
|
||||||
if (action == SET) {
|
if (action == SET) {
|
||||||
if ((internalState == STATE_OFF) || (internalState == STATE_PASSIVE)
|
if ((internalState == STATE_OFF) || (internalState == STATE_PASSIVE)
|
||||||
|| (internalState == STATE_EXTERNAL_CONTROL)) {
|
|| (internalState == STATE_EXTERNAL_CONTROL)) {
|
||||||
switchCountdown.setTimeout(powerSwitcher->getSwitchDelayMs());
|
switchCountdown.setTimeout(powerSwitcher->getSwitchDelayMs());
|
||||||
internalState = STATE_WAIT_FOR_SWITCHES_ON;
|
internalState = STATE_WAIT_FOR_SWITCHES_ON;
|
||||||
powerSwitcher->sendSwitchCommand(switch0, PowerSwitchIF::SWITCH_ON);
|
powerSwitcher->sendSwitchCommand(switch0, PowerSwitchIF::SWITCH_ON);
|
||||||
powerSwitcher->sendSwitchCommand(switch1, PowerSwitchIF::SWITCH_ON);
|
powerSwitcher->sendSwitchCommand(switch1, PowerSwitchIF::SWITCH_ON);
|
||||||
}
|
}
|
||||||
} else { //clear
|
} else { //clear
|
||||||
if ((internalState == STATE_ON) || (internalState == STATE_FAULTY)
|
if ((internalState == STATE_ON) || (internalState == STATE_FAULTY)
|
||||||
|| (internalState == STATE_EXTERNAL_CONTROL)) {
|
|| (internalState == STATE_EXTERNAL_CONTROL)) {
|
||||||
internalState = STATE_WAIT_FOR_SWITCHES_OFF;
|
internalState = STATE_WAIT_FOR_SWITCHES_OFF;
|
||||||
switchCountdown.setTimeout(powerSwitcher->getSwitchDelayMs());
|
switchCountdown.setTimeout(powerSwitcher->getSwitchDelayMs());
|
||||||
powerSwitcher->sendSwitchCommand(switch0,
|
powerSwitcher->sendSwitchCommand(switch0,
|
||||||
PowerSwitchIF::SWITCH_OFF);
|
PowerSwitchIF::SWITCH_OFF);
|
||||||
powerSwitcher->sendSwitchCommand(switch1,
|
powerSwitcher->sendSwitchCommand(switch1,
|
||||||
PowerSwitchIF::SWITCH_OFF);
|
PowerSwitchIF::SWITCH_OFF);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Heater::setPowerSwitcher(PowerSwitchIF* powerSwitch) {
|
void Heater::setPowerSwitcher(PowerSwitchIF* powerSwitch) {
|
||||||
this->powerSwitcher = powerSwitch;
|
this->powerSwitcher = powerSwitch;
|
||||||
}
|
}
|
||||||
|
|
||||||
ReturnValue_t Heater::performOperation(uint8_t opCode) {
|
ReturnValue_t Heater::performOperation(uint8_t opCode) {
|
||||||
handleQueue();
|
handleQueue();
|
||||||
handleEventQueue();
|
handleEventQueue();
|
||||||
|
|
||||||
if (!healthHelper.healthTable->isFaulty(getObjectId())) {
|
if (!healthHelper.healthTable->isFaulty(getObjectId())) {
|
||||||
reactedToBeingFaulty = false;
|
reactedToBeingFaulty = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (internalState) {
|
switch (internalState) {
|
||||||
case STATE_ON:
|
case STATE_ON:
|
||||||
if ((powerSwitcher->getSwitchState(switch0) == PowerSwitchIF::SWITCH_OFF)
|
if ((powerSwitcher->getSwitchState(switch0) == PowerSwitchIF::SWITCH_OFF)
|
||||||
|| (powerSwitcher->getSwitchState(switch1)
|
|| (powerSwitcher->getSwitchState(switch1)
|
||||||
== PowerSwitchIF::SWITCH_OFF)) {
|
== PowerSwitchIF::SWITCH_OFF)) {
|
||||||
//switch went off on its own
|
//switch went off on its own
|
||||||
//trigger event. FDIR can confirm if it is caused by MniOps and decide on the action
|
//trigger event. FDIR can confirm if it is caused by MniOps and decide on the action
|
||||||
//do not trigger FD events when under external control
|
//do not trigger FD events when under external control
|
||||||
if (healthHelper.getHealth() != EXTERNAL_CONTROL) {
|
if (healthHelper.getHealth() != EXTERNAL_CONTROL) {
|
||||||
triggerEvent(PowerSwitchIF::SWITCH_WENT_OFF);
|
triggerEvent(PowerSwitchIF::SWITCH_WENT_OFF);
|
||||||
} else {
|
} else {
|
||||||
internalState = STATE_EXTERNAL_CONTROL;
|
internalState = STATE_EXTERNAL_CONTROL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case STATE_OFF:
|
case STATE_OFF:
|
||||||
//check if heater is on, ie both switches are on
|
//check if heater is on, ie both switches are on
|
||||||
//if so, just command it to off, to resolve the situation or force a switch stayed on event
|
//if so, just command it to off, to resolve the situation or force a switch stayed on event
|
||||||
//But, only do anything if not already faulty (state off is the stable point for being faulty)
|
//But, only do anything if not already faulty (state off is the stable point for being faulty)
|
||||||
if ((!healthHelper.healthTable->isFaulty(getObjectId()))
|
if ((!healthHelper.healthTable->isFaulty(getObjectId()))
|
||||||
&& (powerSwitcher->getSwitchState(switch0)
|
&& (powerSwitcher->getSwitchState(switch0)
|
||||||
== PowerSwitchIF::SWITCH_ON)
|
== PowerSwitchIF::SWITCH_ON)
|
||||||
&& (powerSwitcher->getSwitchState(switch1)
|
&& (powerSwitcher->getSwitchState(switch1)
|
||||||
== PowerSwitchIF::SWITCH_ON)) {
|
== PowerSwitchIF::SWITCH_ON)) {
|
||||||
//do not trigger FD events when under external control
|
//do not trigger FD events when under external control
|
||||||
if (healthHelper.getHealth() != EXTERNAL_CONTROL) {
|
if (healthHelper.getHealth() != EXTERNAL_CONTROL) {
|
||||||
internalState = STATE_WAIT_FOR_SWITCHES_OFF;
|
internalState = STATE_WAIT_FOR_SWITCHES_OFF;
|
||||||
switchCountdown.setTimeout(powerSwitcher->getSwitchDelayMs());
|
switchCountdown.setTimeout(powerSwitcher->getSwitchDelayMs());
|
||||||
powerSwitcher->sendSwitchCommand(switch0,
|
powerSwitcher->sendSwitchCommand(switch0,
|
||||||
PowerSwitchIF::SWITCH_OFF);
|
PowerSwitchIF::SWITCH_OFF);
|
||||||
powerSwitcher->sendSwitchCommand(switch1,
|
powerSwitcher->sendSwitchCommand(switch1,
|
||||||
PowerSwitchIF::SWITCH_OFF);
|
PowerSwitchIF::SWITCH_OFF);
|
||||||
} else {
|
} else {
|
||||||
internalState = STATE_EXTERNAL_CONTROL;
|
internalState = STATE_EXTERNAL_CONTROL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case STATE_PASSIVE:
|
case STATE_PASSIVE:
|
||||||
break;
|
break;
|
||||||
case STATE_WAIT_FOR_SWITCHES_ON:
|
case STATE_WAIT_FOR_SWITCHES_ON:
|
||||||
if (switchCountdown.hasTimedOut()) {
|
if (switchCountdown.hasTimedOut()) {
|
||||||
if ((powerSwitcher->getSwitchState(switch0)
|
if ((powerSwitcher->getSwitchState(switch0)
|
||||||
== PowerSwitchIF::SWITCH_OFF)
|
== PowerSwitchIF::SWITCH_OFF)
|
||||||
|| (powerSwitcher->getSwitchState(switch1)
|
|| (powerSwitcher->getSwitchState(switch1)
|
||||||
== PowerSwitchIF::SWITCH_OFF)) {
|
== PowerSwitchIF::SWITCH_OFF)) {
|
||||||
triggerEvent(HEATER_STAYED_OFF);
|
triggerEvent(HEATER_STAYED_OFF);
|
||||||
internalState = STATE_WAIT_FOR_FDIR; //wait before retrying or anything
|
internalState = STATE_WAIT_FOR_FDIR; //wait before retrying or anything
|
||||||
} else {
|
} else {
|
||||||
triggerEvent(HEATER_ON);
|
triggerEvent(HEATER_ON);
|
||||||
internalState = STATE_ON;
|
internalState = STATE_ON;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case STATE_WAIT_FOR_SWITCHES_OFF:
|
case STATE_WAIT_FOR_SWITCHES_OFF:
|
||||||
if (switchCountdown.hasTimedOut()) {
|
if (switchCountdown.hasTimedOut()) {
|
||||||
//only check for both being on (ie heater still on)
|
//only check for both being on (ie heater still on)
|
||||||
if ((powerSwitcher->getSwitchState(switch0)
|
if ((powerSwitcher->getSwitchState(switch0)
|
||||||
== PowerSwitchIF::SWITCH_ON)
|
== PowerSwitchIF::SWITCH_ON)
|
||||||
&& (powerSwitcher->getSwitchState(switch1)
|
&& (powerSwitcher->getSwitchState(switch1)
|
||||||
== PowerSwitchIF::SWITCH_ON)) {
|
== PowerSwitchIF::SWITCH_ON)) {
|
||||||
if (healthHelper.healthTable->isFaulty(getObjectId())) {
|
if (healthHelper.healthTable->isFaulty(getObjectId())) {
|
||||||
if (passive) {
|
if (passive) {
|
||||||
internalState = STATE_PASSIVE;
|
internalState = STATE_PASSIVE;
|
||||||
} else {
|
} else {
|
||||||
internalState = STATE_OFF; //just accept it
|
internalState = STATE_OFF; //just accept it
|
||||||
}
|
}
|
||||||
triggerEvent(HEATER_ON); //but throw an event to make it more visible
|
triggerEvent(HEATER_ON); //but throw an event to make it more visible
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
triggerEvent(HEATER_STAYED_ON);
|
triggerEvent(HEATER_STAYED_ON);
|
||||||
internalState = STATE_WAIT_FOR_FDIR; //wait before retrying or anything
|
internalState = STATE_WAIT_FOR_FDIR; //wait before retrying or anything
|
||||||
} else {
|
} else {
|
||||||
triggerEvent(HEATER_OFF);
|
triggerEvent(HEATER_OFF);
|
||||||
if (passive) {
|
if (passive) {
|
||||||
internalState = STATE_PASSIVE;
|
internalState = STATE_PASSIVE;
|
||||||
} else {
|
} else {
|
||||||
internalState = STATE_OFF;
|
internalState = STATE_OFF;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((powerSwitcher->getSwitchState(switch0) == PowerSwitchIF::SWITCH_ON)
|
if ((powerSwitcher->getSwitchState(switch0) == PowerSwitchIF::SWITCH_ON)
|
||||||
&& (powerSwitcher->getSwitchState(switch1)
|
&& (powerSwitcher->getSwitchState(switch1)
|
||||||
== PowerSwitchIF::SWITCH_ON)) {
|
== PowerSwitchIF::SWITCH_ON)) {
|
||||||
if (wasOn) {
|
if (wasOn) {
|
||||||
if (heaterOnCountdown.hasTimedOut()) {
|
if (heaterOnCountdown.hasTimedOut()) {
|
||||||
//SHOULDDO this means if a heater fails in single mode, the timeout will start again
|
//SHOULDDO this means if a heater fails in single mode, the timeout will start again
|
||||||
//I am not sure if this is a bug, but atm I have no idea how to fix this and think
|
//I am not sure if this is a bug, but atm I have no idea how to fix this and think
|
||||||
//it will be ok. whatcouldpossiblygowrong™
|
//it will be ok. whatcouldpossiblygowrong™
|
||||||
if (!timedOut) {
|
if (!timedOut) {
|
||||||
triggerEvent(HEATER_TIMEOUT);
|
triggerEvent(HEATER_TIMEOUT);
|
||||||
timedOut = true;
|
timedOut = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
wasOn = true;
|
wasOn = true;
|
||||||
heaterOnCountdown.resetTimer();
|
heaterOnCountdown.resetTimer();
|
||||||
timedOut = false;
|
timedOut = false;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
wasOn = false;
|
wasOn = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return HasReturnvaluesIF::RETURN_OK;
|
return HasReturnvaluesIF::RETURN_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Heater::setSwitch(uint8_t number, ReturnValue_t state,
|
void Heater::setSwitch(uint8_t number, ReturnValue_t state,
|
||||||
uint32_t* uptimeOfSwitching) {
|
uint32_t* uptimeOfSwitching) {
|
||||||
if (powerSwitcher == NULL) {
|
if (powerSwitcher == NULL) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (powerSwitcher->getSwitchState(number) == state) {
|
if (powerSwitcher->getSwitchState(number) == state) {
|
||||||
*uptimeOfSwitching = INVALID_UPTIME;
|
*uptimeOfSwitching = INVALID_UPTIME;
|
||||||
} else {
|
} else {
|
||||||
if ((*uptimeOfSwitching == INVALID_UPTIME)) {
|
if ((*uptimeOfSwitching == INVALID_UPTIME)) {
|
||||||
powerSwitcher->sendSwitchCommand(number, state);
|
powerSwitcher->sendSwitchCommand(number, state);
|
||||||
Clock::getUptime(uptimeOfSwitching);
|
Clock::getUptime(uptimeOfSwitching);
|
||||||
} else {
|
} else {
|
||||||
uint32_t currentUptime;
|
uint32_t currentUptime;
|
||||||
Clock::getUptime(¤tUptime);
|
Clock::getUptime(¤tUptime);
|
||||||
if (currentUptime - *uptimeOfSwitching
|
if (currentUptime - *uptimeOfSwitching
|
||||||
> powerSwitcher->getSwitchDelayMs()) {
|
> powerSwitcher->getSwitchDelayMs()) {
|
||||||
*uptimeOfSwitching = INVALID_UPTIME;
|
*uptimeOfSwitching = INVALID_UPTIME;
|
||||||
if (healthHelper.healthTable->isHealthy(getObjectId())) {
|
if (healthHelper.healthTable->isHealthy(getObjectId())) {
|
||||||
if (state == PowerSwitchIF::SWITCH_ON) {
|
if (state == PowerSwitchIF::SWITCH_ON) {
|
||||||
triggerEvent(HEATER_STAYED_OFF);
|
triggerEvent(HEATER_STAYED_OFF);
|
||||||
} else {
|
} else {
|
||||||
triggerEvent(HEATER_STAYED_ON);
|
triggerEvent(HEATER_STAYED_ON);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//SHOULDDO MiniOps during switch timeout leads to a faulty switch
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
MessageQueueId_t Heater::getCommandQueue() const {
|
MessageQueueId_t Heater::getCommandQueue() const {
|
||||||
return commandQueue->getId();
|
return commandQueue->getId();
|
||||||
}
|
}
|
||||||
|
|
||||||
ReturnValue_t Heater::initialize() {
|
ReturnValue_t Heater::initialize() {
|
||||||
ReturnValue_t result = SystemObject::initialize();
|
ReturnValue_t result = SystemObject::initialize();
|
||||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
EventManagerIF* manager = objectManager->get<EventManagerIF>(
|
EventManagerIF* manager = objectManager->get<EventManagerIF>(
|
||||||
objects::EVENT_MANAGER);
|
objects::EVENT_MANAGER);
|
||||||
if (manager == NULL) {
|
if (manager == NULL) {
|
||||||
return HasReturnvaluesIF::RETURN_FAILED;
|
return HasReturnvaluesIF::RETURN_FAILED;
|
||||||
}
|
}
|
||||||
result = manager->registerListener(eventQueue->getId());
|
result = manager->registerListener(eventQueue->getId());
|
||||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
ConfirmsFailuresIF* pcdu = objectManager->get<ConfirmsFailuresIF>(
|
ConfirmsFailuresIF* pcdu = objectManager->get<ConfirmsFailuresIF>(
|
||||||
DeviceHandlerFailureIsolation::powerConfirmationId);
|
DeviceHandlerFailureIsolation::powerConfirmationId);
|
||||||
if (pcdu == NULL) {
|
if (pcdu == NULL) {
|
||||||
return HasReturnvaluesIF::RETURN_FAILED;
|
return HasReturnvaluesIF::RETURN_FAILED;
|
||||||
}
|
}
|
||||||
pcduQueueId = pcdu->getEventReceptionQueue();
|
pcduQueueId = pcdu->getEventReceptionQueue();
|
||||||
|
|
||||||
result = manager->subscribeToAllEventsFrom(eventQueue->getId(),
|
result = manager->subscribeToAllEventsFrom(eventQueue->getId(),
|
||||||
getObjectId());
|
getObjectId());
|
||||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
result = parameterHelper.initialize();
|
result = parameterHelper.initialize();
|
||||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
result = healthHelper.initialize();
|
result = healthHelper.initialize();
|
||||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
return HasReturnvaluesIF::RETURN_OK;
|
return HasReturnvaluesIF::RETURN_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Heater::handleQueue() {
|
void Heater::handleQueue() {
|
||||||
CommandMessage command;
|
CommandMessage command;
|
||||||
ReturnValue_t result = commandQueue->receiveMessage(&command);
|
ReturnValue_t result = commandQueue->receiveMessage(&command);
|
||||||
if (result == HasReturnvaluesIF::RETURN_OK) {
|
if (result == HasReturnvaluesIF::RETURN_OK) {
|
||||||
result = healthHelper.handleHealthCommand(&command);
|
result = healthHelper.handleHealthCommand(&command);
|
||||||
if (result == HasReturnvaluesIF::RETURN_OK) {
|
if (result == HasReturnvaluesIF::RETURN_OK) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
parameterHelper.handleParameterMessage(&command);
|
result = parameterHelper.handleParameterMessage(&command);
|
||||||
}
|
if (result == HasReturnvaluesIF::RETURN_OK) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ReturnValue_t Heater::getParameter(uint8_t domainId, uint8_t uniqueId,
|
ReturnValue_t Heater::getParameter(uint8_t domainId, uint8_t uniqueId,
|
||||||
ParameterWrapper* parameterWrapper, const ParameterWrapper* newValues,
|
ParameterWrapper* parameterWrapper, const ParameterWrapper* newValues,
|
||||||
uint16_t startAtIndex) {
|
uint16_t startAtIndex) {
|
||||||
if (domainId != DOMAIN_ID_BASE) {
|
if (domainId != DOMAIN_ID_BASE) {
|
||||||
return INVALID_DOMAIN_ID;
|
return INVALID_DOMAIN_ID;
|
||||||
}
|
}
|
||||||
switch (uniqueId) {
|
switch (uniqueId) {
|
||||||
case 0:
|
case 0:
|
||||||
parameterWrapper->set(heaterOnCountdown.timeout);
|
parameterWrapper->set(heaterOnCountdown.timeout);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
return INVALID_IDENTIFIER_ID;
|
return INVALID_IDENTIFIER_ID;
|
||||||
}
|
}
|
||||||
return HasReturnvaluesIF::RETURN_OK;
|
return HasReturnvaluesIF::RETURN_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Heater::handleEventQueue() {
|
void Heater::handleEventQueue() {
|
||||||
EventMessage event;
|
EventMessage event;
|
||||||
for (ReturnValue_t result = eventQueue->receiveMessage(&event);
|
for (ReturnValue_t result = eventQueue->receiveMessage(&event);
|
||||||
result == HasReturnvaluesIF::RETURN_OK;
|
result == HasReturnvaluesIF::RETURN_OK;
|
||||||
result = eventQueue->receiveMessage(&event)) {
|
result = eventQueue->receiveMessage(&event)) {
|
||||||
switch (event.getMessageId()) {
|
switch (event.getMessageId()) {
|
||||||
case EventMessage::EVENT_MESSAGE:
|
case EventMessage::EVENT_MESSAGE:
|
||||||
switch (event.getEvent()) {
|
switch (event.getEvent()) {
|
||||||
case Fuse::FUSE_WENT_OFF:
|
case Fuse::FUSE_WENT_OFF:
|
||||||
case HEATER_STAYED_OFF:
|
case HEATER_STAYED_OFF:
|
||||||
case HEATER_STAYED_ON://Setting it faulty does not help, but we need to reach a stable state and can check for being faulty before throwing this event again.
|
// HEATER_STAYED_ON is a setting if faulty does not help, but we need to reach a stable state and can check
|
||||||
if (healthHelper.healthTable->isCommandable(getObjectId())) {
|
// for being faulty before throwing this event again.
|
||||||
healthHelper.setHealth(HasHealthIF::FAULTY);
|
case HEATER_STAYED_ON:
|
||||||
internalState = STATE_FAULTY;
|
if (healthHelper.healthTable->isCommandable(getObjectId())) {
|
||||||
}
|
healthHelper.setHealth(HasHealthIF::FAULTY);
|
||||||
break;
|
internalState = STATE_FAULTY;
|
||||||
case PowerSwitchIF::SWITCH_WENT_OFF:
|
}
|
||||||
internalState = STATE_WAIT;
|
break;
|
||||||
event.setMessageId(EventMessage::CONFIRMATION_REQUEST);
|
case PowerSwitchIF::SWITCH_WENT_OFF:
|
||||||
if (pcduQueueId != 0) {
|
internalState = STATE_WAIT;
|
||||||
eventQueue->sendMessage(pcduQueueId, &event);
|
event.setMessageId(EventMessage::CONFIRMATION_REQUEST);
|
||||||
} else {
|
if (pcduQueueId != 0) {
|
||||||
healthHelper.setHealth(HasHealthIF::FAULTY);
|
eventQueue->sendMessage(pcduQueueId, &event);
|
||||||
internalState = STATE_FAULTY;
|
} else {
|
||||||
}
|
healthHelper.setHealth(HasHealthIF::FAULTY);
|
||||||
break;
|
internalState = STATE_FAULTY;
|
||||||
default:
|
}
|
||||||
return;
|
break;
|
||||||
}
|
default:
|
||||||
break;
|
return;
|
||||||
case EventMessage::YOUR_FAULT:
|
}
|
||||||
healthHelper.setHealth(HasHealthIF::FAULTY);
|
break;
|
||||||
internalState = STATE_FAULTY;
|
case EventMessage::YOUR_FAULT:
|
||||||
break;
|
healthHelper.setHealth(HasHealthIF::FAULTY);
|
||||||
case EventMessage::MY_FAULT:
|
internalState = STATE_FAULTY;
|
||||||
//do nothing, we are already in STATE_WAIT and wait for a clear()
|
break;
|
||||||
break;
|
case EventMessage::MY_FAULT:
|
||||||
default:
|
//do nothing, we are already in STATE_WAIT and wait for a clear()
|
||||||
return;
|
break;
|
||||||
}
|
default:
|
||||||
}
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
115
thermal/Heater.h
115
thermal/Heater.h
@ -1,90 +1,93 @@
|
|||||||
#ifndef FRAMEWORK_THERMAL_HEATER_H_
|
#ifndef FSFW_THERMAL_HEATER_H_
|
||||||
#define FRAMEWORK_THERMAL_HEATER_H_
|
#define FSFW_THERMAL_HEATER_H_
|
||||||
|
|
||||||
#include "../devicehandlers/HealthDevice.h"
|
#include "../devicehandlers/HealthDevice.h"
|
||||||
#include "../parameters/ParameterHelper.h"
|
#include "../parameters/ParameterHelper.h"
|
||||||
#include "../power/PowerSwitchIF.h"
|
#include "../power/PowerSwitchIF.h"
|
||||||
#include "../returnvalues/HasReturnvaluesIF.h"
|
#include "../returnvalues/HasReturnvaluesIF.h"
|
||||||
#include "../timemanager/Countdown.h"
|
#include "../timemanager/Countdown.h"
|
||||||
#include <stdint.h>
|
#include <cstdint>
|
||||||
//class RedundantHeater;
|
|
||||||
|
|
||||||
class Heater: public HealthDevice, public ReceivesParameterMessagesIF {
|
class Heater: public HealthDevice, public ReceivesParameterMessagesIF {
|
||||||
friend class RedundantHeater;
|
friend class RedundantHeater;
|
||||||
public:
|
public:
|
||||||
|
|
||||||
static const uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::HEATER;
|
static const uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::HEATER;
|
||||||
static const Event HEATER_ON = MAKE_EVENT(0, severity::INFO);
|
static const Event HEATER_ON = MAKE_EVENT(0, severity::INFO);
|
||||||
static const Event HEATER_OFF = MAKE_EVENT(1, severity::INFO);
|
static const Event HEATER_OFF = MAKE_EVENT(1, severity::INFO);
|
||||||
static const Event HEATER_TIMEOUT = MAKE_EVENT(2, severity::LOW);
|
static const Event HEATER_TIMEOUT = MAKE_EVENT(2, severity::LOW);
|
||||||
static const Event HEATER_STAYED_ON = MAKE_EVENT(3, severity::LOW);
|
static const Event HEATER_STAYED_ON = MAKE_EVENT(3, severity::LOW);
|
||||||
static const Event HEATER_STAYED_OFF = MAKE_EVENT(4, severity::LOW);
|
static const Event HEATER_STAYED_OFF = MAKE_EVENT(4, severity::LOW);
|
||||||
|
|
||||||
Heater(uint32_t objectId, uint8_t switch0, uint8_t switch1);
|
Heater(uint32_t objectId, uint8_t switch0, uint8_t switch1);
|
||||||
virtual ~Heater();
|
virtual ~Heater();
|
||||||
|
|
||||||
ReturnValue_t performOperation(uint8_t opCode);
|
ReturnValue_t performOperation(uint8_t opCode);
|
||||||
|
|
||||||
ReturnValue_t initialize();
|
ReturnValue_t initialize();
|
||||||
|
|
||||||
ReturnValue_t set();
|
ReturnValue_t set();
|
||||||
void clear(bool passive);
|
void clear(bool passive);
|
||||||
|
|
||||||
void setPowerSwitcher(PowerSwitchIF *powerSwitch);
|
void setPowerSwitcher(PowerSwitchIF *powerSwitch);
|
||||||
|
|
||||||
MessageQueueId_t getCommandQueue() const;
|
MessageQueueId_t getCommandQueue() const;
|
||||||
|
|
||||||
ReturnValue_t getParameter(uint8_t domainId, uint8_t uniqueId,
|
ReturnValue_t getParameter(uint8_t domainId, uint8_t uniqueId,
|
||||||
ParameterWrapper *parameterWrapper,
|
ParameterWrapper *parameterWrapper,
|
||||||
const ParameterWrapper *newValues, uint16_t startAtIndex);
|
const ParameterWrapper *newValues, uint16_t startAtIndex);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
static const uint32_t INVALID_UPTIME = 0;
|
static const uint32_t INVALID_UPTIME = 0;
|
||||||
|
|
||||||
enum InternalState {
|
enum InternalState {
|
||||||
STATE_ON,
|
STATE_ON,
|
||||||
STATE_OFF,
|
STATE_OFF,
|
||||||
STATE_PASSIVE,
|
STATE_PASSIVE,
|
||||||
STATE_WAIT_FOR_SWITCHES_ON,
|
STATE_WAIT_FOR_SWITCHES_ON,
|
||||||
STATE_WAIT_FOR_SWITCHES_OFF,
|
STATE_WAIT_FOR_SWITCHES_OFF,
|
||||||
STATE_WAIT_FOR_FDIR, //used to avoid doing anything until fdir decided what to do
|
STATE_WAIT_FOR_FDIR, // Used to avoid doing anything until fdir decided what to do
|
||||||
STATE_FAULTY,
|
STATE_FAULTY,
|
||||||
STATE_WAIT, //used when waiting for system to recover from miniops
|
STATE_WAIT, // Used when waiting for system to recover from miniops
|
||||||
STATE_EXTERNAL_CONTROL //entered when under external control and a fdir reaction would be triggered. This is useful when leaving external control into an unknown state
|
// Entered when under external control and a fdir reaction would be triggered.
|
||||||
//if no fdir reaction is triggered under external control the state is still ok and no need for any special treatment is needed
|
// This is useful when leaving external control into an unknown state
|
||||||
} internalState;
|
STATE_EXTERNAL_CONTROL
|
||||||
|
// If no fdir reaction is triggered under external control the state is still ok and
|
||||||
|
// no need for any special treatment is needed
|
||||||
|
} internalState;
|
||||||
|
|
||||||
PowerSwitchIF *powerSwitcher;
|
PowerSwitchIF *powerSwitcher = nullptr;
|
||||||
MessageQueueId_t pcduQueueId;
|
MessageQueueId_t pcduQueueId = MessageQueueIF::NO_QUEUE;
|
||||||
|
|
||||||
uint8_t switch0;
|
uint8_t switch0;
|
||||||
uint8_t switch1;
|
uint8_t switch1;
|
||||||
|
|
||||||
bool wasOn;
|
bool wasOn = false;
|
||||||
|
|
||||||
bool timedOut;
|
bool timedOut = false;
|
||||||
|
|
||||||
bool reactedToBeingFaulty;
|
bool reactedToBeingFaulty = false;
|
||||||
|
|
||||||
bool passive;
|
bool passive = false;
|
||||||
|
|
||||||
MessageQueueIF* eventQueue;
|
MessageQueueIF* eventQueue = nullptr;
|
||||||
Countdown heaterOnCountdown;
|
Countdown heaterOnCountdown;
|
||||||
Countdown switchCountdown;
|
Countdown switchCountdown;
|
||||||
ParameterHelper parameterHelper;
|
ParameterHelper parameterHelper;
|
||||||
|
|
||||||
enum Action {
|
enum Action {
|
||||||
SET, CLEAR
|
SET, CLEAR
|
||||||
} lastAction;
|
} lastAction = CLEAR;
|
||||||
|
|
||||||
void doAction(Action action);
|
void doAction(Action action);
|
||||||
|
|
||||||
void setSwitch(uint8_t number, ReturnValue_t state,
|
void setSwitch(uint8_t number, ReturnValue_t state,
|
||||||
uint32_t *upTimeOfSwitching);
|
uint32_t *upTimeOfSwitching);
|
||||||
|
|
||||||
void handleQueue();
|
void handleQueue();
|
||||||
|
|
||||||
void handleEventQueue();
|
void handleEventQueue();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* FRAMEWORK_THERMAL_HEATER_H_ */
|
#endif /* FSFW_THERMAL_HEATER_H_ */
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
#ifndef TEMPERATURESENSOR_H_
|
#ifndef FSFW_THERMAL_TEMPERATURESENSOR_H_
|
||||||
#define TEMPERATURESENSOR_H_
|
#define FSFW_THERMAL_TEMPERATURESENSOR_H_
|
||||||
|
|
||||||
#include "tcsDefinitions.h"
|
#include "tcsDefinitions.h"
|
||||||
#include "AbstractTemperatureSensor.h"
|
#include "AbstractTemperatureSensor.h"
|
||||||
@ -60,23 +60,22 @@ public:
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Instantiate Temperature Sensor Object.
|
* Instantiate Temperature Sensor Object.
|
||||||
* @param setObjectid objectId of the sensor object
|
* @param setObjectid objectId of the sensor object
|
||||||
* @param inputValue Pointer to input value which is converted to a temperature
|
* @param inputTemperature Pointer to a raw input value which is converted to an floating
|
||||||
* @param variableGpid Global Pool ID of the output value
|
* point C output temperature
|
||||||
* @param inputVariable Input variable handle
|
* @param outputGpid Global Pool ID of the output value
|
||||||
* @param vectorIndex Vector Index for the sensor monitor
|
* @param vectorIndex Vector Index for the sensor monitor
|
||||||
* @param parameters Calculation parameters, temperature limits, gradient limit
|
* @param parameters Calculation parameters, temperature limits, gradient limit
|
||||||
* @param outputSet Output dataset for the output temperature to fetch it with read()
|
* @param outputSet Output dataset for the output temperature to fetch it with read()
|
||||||
* @param thermalModule respective thermal module, if it has one
|
* @param thermalModule Respective thermal module, if it has one
|
||||||
*/
|
*/
|
||||||
TemperatureSensor(object_id_t setObjectid,
|
TemperatureSensor(object_id_t setObjectid,lp_var_t<limitType>* inputTemperature,
|
||||||
inputType *inputValue, gp_id_t variableGpid, PoolVariableIF* inputVariable,
|
gp_id_t outputGpid, uint8_t vectorIndex, Parameters parameters = {0, 0, 0, 0, 0, 0},
|
||||||
uint8_t vectorIndex, Parameters parameters = {0, 0, 0, 0, 0, 0},
|
LocalPoolDataSetBase *outputSet = nullptr, ThermalModuleIF *thermalModule = nullptr) :
|
||||||
LocalPoolDataSetBase *outputSet = NULL, ThermalModuleIF *thermalModule = NULL) :
|
|
||||||
AbstractTemperatureSensor(setObjectid, thermalModule), parameters(parameters),
|
AbstractTemperatureSensor(setObjectid, thermalModule), parameters(parameters),
|
||||||
inputValue(inputValue), poolVariable(inputVariable),
|
inputTemperature(inputTemperature),
|
||||||
outputTemperature(variableGpid, outputSet, PoolVariableIF::VAR_WRITE),
|
outputTemperature(outputGpid, outputSet, PoolVariableIF::VAR_WRITE),
|
||||||
sensorMonitor(setObjectid, DOMAIN_ID_SENSOR, poolVariable,
|
sensorMonitor(setObjectid, DOMAIN_ID_SENSOR, outputGpid,
|
||||||
DEFAULT_CONFIRMATION_COUNT, parameters.lowerLimit, parameters.upperLimit,
|
DEFAULT_CONFIRMATION_COUNT, parameters.lowerLimit, parameters.upperLimit,
|
||||||
TEMP_SENSOR_LOW, TEMP_SENSOR_HIGH),
|
TEMP_SENSOR_LOW, TEMP_SENSOR_HIGH),
|
||||||
oldTemperature(20), uptimeOfOldTemperature({ thermal::INVALID_TEMPERATURE, 0 }) {
|
oldTemperature(20), uptimeOfOldTemperature({ thermal::INVALID_TEMPERATURE, 0 }) {
|
||||||
@ -110,10 +109,7 @@ protected:
|
|||||||
|
|
||||||
UsedParameters parameters;
|
UsedParameters parameters;
|
||||||
|
|
||||||
inputType* inputValue;
|
lp_var_t<limitType>* inputTemperature;
|
||||||
|
|
||||||
PoolVariableIF* poolVariable;
|
|
||||||
|
|
||||||
lp_var_t<float> outputTemperature;
|
lp_var_t<float> outputTemperature;
|
||||||
|
|
||||||
LimitMonitor<limitType> sensorMonitor;
|
LimitMonitor<limitType> sensorMonitor;
|
||||||
@ -122,22 +118,27 @@ protected:
|
|||||||
timeval uptimeOfOldTemperature;
|
timeval uptimeOfOldTemperature;
|
||||||
|
|
||||||
void doChildOperation() {
|
void doChildOperation() {
|
||||||
if ((not poolVariable->isValid()) or
|
ReturnValue_t result = inputTemperature->read(MutexIF::TimeoutType::WAITING, 20);
|
||||||
|
if(result != HasReturnvaluesIF::RETURN_OK) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((not inputTemperature->isValid()) or
|
||||||
(not healthHelper.healthTable->isHealthy(getObjectId()))) {
|
(not healthHelper.healthTable->isHealthy(getObjectId()))) {
|
||||||
setInvalid();
|
setInvalid();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
outputTemperature = calculateOutputTemperature(*inputValue);
|
outputTemperature = calculateOutputTemperature(inputTemperature->value);
|
||||||
outputTemperature.setValid(PoolVariableIF::VALID);
|
outputTemperature.setValid(PoolVariableIF::VALID);
|
||||||
|
|
||||||
timeval uptime;
|
timeval uptime;
|
||||||
Clock::getUptime(&uptime);
|
Clock::getUptime(&uptime);
|
||||||
|
|
||||||
if (uptimeOfOldTemperature.tv_sec != INVALID_UPTIME) {
|
if (uptimeOfOldTemperature.tv_sec != INVALID_UPTIME) {
|
||||||
//In theory, we could use an AbsValueMonitor to monitor the gradient.
|
// In theory, we could use an AbsValueMonitor to monitor the gradient.
|
||||||
//But this would require storing the maxGradient in DP and quite some overhead.
|
// But this would require storing the maxGradient in DP and quite some overhead.
|
||||||
//The concept of delta limits is a bit strange anyway.
|
// The concept of delta limits is a bit strange anyway.
|
||||||
float deltaTime;
|
float deltaTime;
|
||||||
float deltaTemp;
|
float deltaTemp;
|
||||||
|
|
||||||
@ -150,11 +151,11 @@ protected:
|
|||||||
}
|
}
|
||||||
if (parameters.gradient < deltaTemp / deltaTime) {
|
if (parameters.gradient < deltaTemp / deltaTime) {
|
||||||
triggerEvent(TEMP_SENSOR_GRADIENT);
|
triggerEvent(TEMP_SENSOR_GRADIENT);
|
||||||
//Don't set invalid, as we did not recognize it as invalid with full authority, let FDIR handle it
|
// Don't set invalid, as we did not recognize it as invalid with full authority,
|
||||||
|
// let FDIR handle it
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//Check is done against raw limits. SHOULDDO: Why? Using C would be more easy to handle.
|
|
||||||
sensorMonitor.doCheck(outputTemperature.value);
|
sensorMonitor.doCheck(outputTemperature.value);
|
||||||
|
|
||||||
if (sensorMonitor.isOutOfLimits()) {
|
if (sensorMonitor.isOutOfLimits()) {
|
||||||
@ -181,7 +182,10 @@ public:
|
|||||||
static const uint16_t ADDRESS_C = 2;
|
static const uint16_t ADDRESS_C = 2;
|
||||||
static const uint16_t ADDRESS_GRADIENT = 3;
|
static const uint16_t ADDRESS_GRADIENT = 3;
|
||||||
|
|
||||||
static const uint16_t DEFAULT_CONFIRMATION_COUNT = 1; //!< Changed due to issue with later temperature checking even tough the sensor monitor was confirming already (Was 10 before with comment = Correlates to a 10s confirmation time. Chosen rather large, should not be so bad for components and helps survive glitches.)
|
//! Changed due to issue with later temperature checking even tough the sensor monitor was
|
||||||
|
//! confirming already (Was 10 before with comment = Correlates to a 10s confirmation time.
|
||||||
|
//! Chosen rather large, should not be so bad for components and helps survive glitches.)
|
||||||
|
static const uint16_t DEFAULT_CONFIRMATION_COUNT = 1;
|
||||||
|
|
||||||
static const uint8_t DOMAIN_ID_SENSOR = 1;
|
static const uint8_t DOMAIN_ID_SENSOR = 1;
|
||||||
|
|
||||||
@ -221,4 +225,4 @@ public:
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* TEMPERATURESENSOR_H_ */
|
#endif /* FSFW_THERMAL_TEMPERATURESENSOR_H_ */
|
||||||
|
@ -25,6 +25,6 @@ uint32_t TimeMessage::getCounterValue() {
|
|||||||
return temp;
|
return temp;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t TimeMessage::getMinimumMessageSize() {
|
size_t TimeMessage::getMinimumMessageSize() const {
|
||||||
return this->MAX_SIZE;
|
return this->MAX_SIZE;
|
||||||
}
|
}
|
||||||
|
@ -11,7 +11,7 @@ protected:
|
|||||||
* @brief This call always returns the same fixed size of the message.
|
* @brief This call always returns the same fixed size of the message.
|
||||||
* @return Returns HEADER_SIZE + \c sizeof(timeval) + sizeof(uint32_t).
|
* @return Returns HEADER_SIZE + \c sizeof(timeval) + sizeof(uint32_t).
|
||||||
*/
|
*/
|
||||||
size_t getMinimumMessageSize();
|
size_t getMinimumMessageSize() const override;
|
||||||
public:
|
public:
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
#ifndef FSFW_TIMEMANAGER_TIMESTAMPERIF_H_
|
#ifndef FSFW_TIMEMANAGER_TIMESTAMPERIF_H_
|
||||||
#define FSFW_TIMEMANAGER_TIMESTAMPERIF_H_
|
#define FSFW_TIMEMANAGER_TIMESTAMPERIF_H_
|
||||||
|
|
||||||
|
#include <FSFWConfig.h>
|
||||||
#include "../returnvalues/HasReturnvaluesIF.h"
|
#include "../returnvalues/HasReturnvaluesIF.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -16,8 +17,8 @@ public:
|
|||||||
|
|
||||||
//! This is a mission-specific constant and determines the total
|
//! This is a mission-specific constant and determines the total
|
||||||
//! size reserved for timestamps.
|
//! size reserved for timestamps.
|
||||||
//! TODO: Default define in FSFWConfig ?
|
static const uint8_t MISSION_TIMESTAMP_SIZE = fsfwconfig::FSFW_MISSION_TIMESTAMP_SIZE;
|
||||||
static const uint8_t MISSION_TIMESTAMP_SIZE = 8;
|
|
||||||
virtual ReturnValue_t addTimeStamp(uint8_t* buffer,
|
virtual ReturnValue_t addTimeStamp(uint8_t* buffer,
|
||||||
const uint8_t maxSize) = 0;
|
const uint8_t maxSize) = 0;
|
||||||
virtual ~TimeStamperIF() {}
|
virtual ~TimeStamperIF() {}
|
||||||
|
@ -4,5 +4,9 @@ target_sources(${LIB_FSFW_NAME}
|
|||||||
TcPacketStored.cpp
|
TcPacketStored.cpp
|
||||||
TmPacketBase.cpp
|
TmPacketBase.cpp
|
||||||
TmPacketMinimal.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/CRC.h"
|
||||||
#include "../../globalfunctions/arrayprinter.h"
|
#include "../../globalfunctions/arrayprinter.h"
|
||||||
#include "../../objectmanager/ObjectManagerIF.h"
|
#include "../../objectmanager/ObjectManagerIF.h"
|
||||||
#include "../../serviceinterface/ServiceInterfaceStream.h"
|
#include "../../serviceinterface/ServiceInterface.h"
|
||||||
#include "../../timemanager/CCSDSTime.h"
|
#include "../../timemanager/CCSDSTime.h"
|
||||||
|
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
|
||||||
TimeStamperIF* TmPacketBase::timeStamper = nullptr;
|
TimeStamperIF* TmPacketBase::timeStamper = nullptr;
|
||||||
object_id_t TmPacketBase::timeStamperId = 0;
|
object_id_t TmPacketBase::timeStamperId = objects::NO_OBJECT;
|
||||||
|
|
||||||
TmPacketBase::TmPacketBase(uint8_t* setData) :
|
TmPacketBase::TmPacketBase(uint8_t* setData):
|
||||||
SpacePacketBase(setData) {
|
SpacePacketBase(setData) {
|
||||||
tmData = reinterpret_cast<TmPacketPointer*>(setData);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TmPacketBase::~TmPacketBase() {
|
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() {
|
uint16_t TmPacketBase::getSourceDataSize() {
|
||||||
return getPacketDataLength() - sizeof(tmData->data_field)
|
return getPacketDataLength() - getDataFieldSize() - CRC_SIZE + 1;
|
||||||
- CRC_SIZE + 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
uint16_t TmPacketBase::getErrorControl() {
|
uint16_t TmPacketBase::getErrorControl() {
|
||||||
uint32_t size = getSourceDataSize() + CRC_SIZE;
|
uint32_t size = getSourceDataSize() + CRC_SIZE;
|
||||||
uint8_t* p_to_buffer = &tmData->data;
|
uint8_t* p_to_buffer = getSourceData();
|
||||||
return (p_to_buffer[size - 2] << 8) + p_to_buffer[size - 1];
|
return (p_to_buffer[size - 2] << 8) + p_to_buffer[size - 1];
|
||||||
}
|
}
|
||||||
|
|
||||||
void TmPacketBase::setErrorControl() {
|
void TmPacketBase::setErrorControl() {
|
||||||
uint32_t full_size = getFullSize();
|
uint32_t full_size = getFullSize();
|
||||||
uint16_t crc = CRC::crc16ccitt(getWholeData(), full_size - CRC_SIZE);
|
uint16_t crc = CRC::crc16ccitt(getWholeData(), full_size - CRC_SIZE);
|
||||||
uint32_t size = getSourceDataSize();
|
uint32_t size = getSourceDataSize();
|
||||||
getSourceData()[size] = (crc & 0XFF00) >> 8; // CRCH
|
getSourceData()[size] = (crc & 0XFF00) >> 8; // CRCH
|
||||||
getSourceData()[size + 1] = (crc) & 0X00FF; // CRCL
|
getSourceData()[size + 1] = (crc) & 0X00FF; // CRCL
|
||||||
}
|
}
|
||||||
|
|
||||||
void TmPacketBase::setData(const uint8_t* p_Data) {
|
ReturnValue_t TmPacketBase::getPacketTime(timeval* timestamp) const {
|
||||||
SpacePacketBase::setData(p_Data);
|
size_t tempSize = 0;
|
||||||
tmData = (TmPacketPointer*) p_Data;
|
return CCSDSTime::convertFromCcsds(timestamp, getPacketTimeRaw(),
|
||||||
|
&tempSize, getTimestampSize());
|
||||||
}
|
}
|
||||||
|
|
||||||
void TmPacketBase::print() {
|
void TmPacketBase::print() {
|
||||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||||
sif::debug << "TmPacketBase::print: " << std::endl;
|
sif::debug << "TmPacketBase::print: " << std::endl;
|
||||||
#endif
|
#endif
|
||||||
arrayprinter::print(getWholeData(), getFullSize());
|
arrayprinter::print(getWholeData(), getFullSize());
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TmPacketBase::checkAndSetStamper() {
|
bool TmPacketBase::checkAndSetStamper() {
|
||||||
if (timeStamper == NULL) {
|
if (timeStamper == NULL) {
|
||||||
timeStamper = objectManager->get<TimeStamperIF>(timeStamperId);
|
timeStamper = objectManager->get<TimeStamperIF>(timeStamperId);
|
||||||
if (timeStamper == NULL) {
|
if (timeStamper == NULL) {
|
||||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||||
sif::error << "TmPacketBase::checkAndSetStamper: Stamper not found!"
|
sif::warning << "TmPacketBase::checkAndSetStamper: Stamper not found!" << std::endl;
|
||||||
<< std::endl;
|
#else
|
||||||
|
sif::printWarning("TmPacketBase::checkAndSetStamper: Stamper not found!\n");
|
||||||
#endif
|
#endif
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
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();
|
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.
|
* This class is the basic data handler for any ECSS PUS Telemetry packet.
|
||||||
@ -49,61 +23,83 @@ struct TmPacketPointer {
|
|||||||
* @ingroup tmtcpackets
|
* @ingroup tmtcpackets
|
||||||
*/
|
*/
|
||||||
class TmPacketBase : public SpacePacketBase {
|
class TmPacketBase : public SpacePacketBase {
|
||||||
friend void (Factory::setStaticFrameworkObjectIds)();
|
friend void (Factory::setStaticFrameworkObjectIds)();
|
||||||
public:
|
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;
|
|
||||||
|
|
||||||
/**
|
//! Maximum size of a TM Packet in this mission.
|
||||||
* This is the default constructor.
|
//! TODO: Make this dependant on a config variable.
|
||||||
* It sets its internal data pointer to the address passed and also
|
static const uint32_t MISSION_TM_PACKET_MAX_SIZE = 2048;
|
||||||
* forwards the data pointer to the parent SpacePacketBase class.
|
//! First four bits of first byte of secondary header
|
||||||
* @param set_address The position where the packet data lies.
|
static const uint8_t VERSION_NUMBER_BYTE = 0b00010000;
|
||||||
*/
|
|
||||||
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
|
* This is the default constructor.
|
||||||
* byte of the Data Field Header.
|
* It sets its internal data pointer to the address passed and also
|
||||||
* @return The packet's PUS Service ID.
|
* forwards the data pointer to the parent SpacePacketBase class.
|
||||||
*/
|
* @param set_address The position where the packet data lies.
|
||||||
uint8_t getService();
|
*/
|
||||||
/**
|
TmPacketBase( uint8_t* setData );
|
||||||
* This is a getter for the packet's PUS Service Subtype, which is the
|
/**
|
||||||
* third byte of the Data Field Header.
|
* This is the empty default destructor.
|
||||||
* @return The packet's PUS Service Subtype.
|
*/
|
||||||
*/
|
virtual ~TmPacketBase();
|
||||||
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 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
|
* With this method, the Error Control Field is updated to match the
|
||||||
* current content of the packet. This method is not protected because
|
* current content of the packet. This method is not protected because
|
||||||
@ -111,79 +107,24 @@ public:
|
|||||||
* like the sequence count.
|
* like the sequence count.
|
||||||
*/
|
*/
|
||||||
void setErrorControl();
|
void setErrorControl();
|
||||||
|
/**
|
||||||
/**
|
* This getter returns the Error Control Field of the packet.
|
||||||
* This getter returns the Error Control Field of the packet.
|
*
|
||||||
*
|
* The field is placed after any possible Source Data. If no
|
||||||
* The field is placed after any possible Source Data. If no
|
* Source Data is present there's still an Error Control field. It is
|
||||||
* Source Data is present there's still an Error Control field. It is
|
* supposed to be a 16bit-CRC.
|
||||||
* supposed to be a 16bit-CRC.
|
* @return The PUS Error Control
|
||||||
* @return The PUS Error Control
|
*/
|
||||||
*/
|
uint16_t getErrorControl();
|
||||||
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;
|
|
||||||
|
|
||||||
protected:
|
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.
|
* The timeStamper is responsible for adding a timestamp to the packet.
|
||||||
* Does set the timestamp (to now), but not the error control field.
|
* It is initialized lazy.
|
||||||
* @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,
|
static TimeStamperIF* timeStamper;
|
||||||
uint8_t packetSubcounter);
|
//! The ID to use when looking for a time stamper.
|
||||||
|
static object_id_t timeStamperId;
|
||||||
/**
|
|
||||||
* 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.
|
* Checks if a time stamper is available and tries to set it if not.
|
||||||
|
87
tmtcpacket/pus/TmPacketPusA.cpp
Normal file
87
tmtcpacket/pus/TmPacketPusA.cpp
Normal file
@ -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);
|
||||||
|
}
|
129
tmtcpacket/pus/TmPacketPusA.h
Normal file
129
tmtcpacket/pus/TmPacketPusA.h
Normal file
@ -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_ */
|
87
tmtcpacket/pus/TmPacketPusC.cpp
Normal file
87
tmtcpacket/pus/TmPacketPusC.cpp
Normal file
@ -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);
|
||||||
|
}
|
126
tmtcpacket/pus/TmPacketPusC.h
Normal file
126
tmtcpacket/pus/TmPacketPusC.h
Normal file
@ -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_
|
#ifndef FSFW_TMTCPACKET_PUS_TMPACKETSTORED_H_
|
||||||
#define FSFW_TMTCPACKET_PUS_TMPACKETSTORED_H_
|
#define FSFW_TMTCPACKET_PUS_TMPACKETSTORED_H_
|
||||||
|
|
||||||
#include "TmPacketBase.h"
|
#include <FSFWConfig.h>
|
||||||
|
|
||||||
#include "../../serialize/SerializeIF.h"
|
#if FSFW_USE_PUS_C_TELEMETRY == 1
|
||||||
#include "../../storagemanager/StorageManagerIF.h"
|
#include "TmPacketStoredPusC.h"
|
||||||
#include "../../internalError/InternalErrorReporterIF.h"
|
#else
|
||||||
#include "../../ipc/MessageQueueSenderIF.h"
|
#include "TmPacketStoredPusA.h"
|
||||||
|
#endif
|
||||||
/**
|
|
||||||
* 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();
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
#endif /* FSFW_TMTCPACKET_PUS_TMPACKETSTORED_H_ */
|
#endif /* FSFW_TMTCPACKET_PUS_TMPACKETSTORED_H_ */
|
||||||
|
94
tmtcpacket/pus/TmPacketStoredBase.cpp
Normal file
94
tmtcpacket/pus/TmPacketStoredBase.cpp
Normal file
@ -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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
89
tmtcpacket/pus/TmPacketStoredBase.h
Normal file
89
tmtcpacket/pus/TmPacketStoredBase.h
Normal file
@ -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_ */
|
||||||
|
|
79
tmtcpacket/pus/TmPacketStoredPusA.cpp
Normal file
79
tmtcpacket/pus/TmPacketStoredPusA.cpp
Normal file
@ -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);
|
||||||
|
}
|
65
tmtcpacket/pus/TmPacketStoredPusA.h
Normal file
65
tmtcpacket/pus/TmPacketStoredPusA.h
Normal file
@ -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_ */
|
80
tmtcpacket/pus/TmPacketStoredPusC.cpp
Normal file
80
tmtcpacket/pus/TmPacketStoredPusC.cpp
Normal file
@ -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);
|
||||||
|
}
|
68
tmtcpacket/pus/TmPacketStoredPusC.h
Normal file
68
tmtcpacket/pus/TmPacketStoredPusC.h
Normal file
@ -0,0 +1,68 @@
|
|||||||
|
#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 C 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
|
||||||
|
* @param destinationId Destination ID containing the application process ID as specified
|
||||||
|
* by PUS C
|
||||||
|
* @param timeRefField 4 bit time reference field as specified by PUS C
|
||||||
|
*/
|
||||||
|
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 "AcceptsTelemetryIF.h"
|
||||||
#include "CommandingServiceBase.h"
|
#include "CommandingServiceBase.h"
|
||||||
#include "TmTcMessage.h"
|
#include "TmTcMessage.h"
|
||||||
|
#include <FSFWConfig.h>
|
||||||
|
|
||||||
#include "../tcdistribution/PUSDistributorIF.h"
|
#include "../tcdistribution/PUSDistributorIF.h"
|
||||||
#include "../objectmanager/ObjectManagerIF.h"
|
#include "../objectmanager/ObjectManagerIF.h"
|
||||||
@ -293,8 +294,13 @@ void CommandingServiceBase::handleRequestQueue() {
|
|||||||
ReturnValue_t CommandingServiceBase::sendTmPacket(uint8_t subservice,
|
ReturnValue_t CommandingServiceBase::sendTmPacket(uint8_t subservice,
|
||||||
const uint8_t* data, size_t dataLen, const uint8_t* headerData,
|
const uint8_t* data, size_t dataLen, const uint8_t* headerData,
|
||||||
size_t headerSize) {
|
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);
|
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(
|
ReturnValue_t result = tmPacketStored.sendPacket(
|
||||||
requestQueue->getDefaultDestination(), requestQueue->getId());
|
requestQueue->getDefaultDestination(), requestQueue->getId());
|
||||||
if (result == HasReturnvaluesIF::RETURN_OK) {
|
if (result == HasReturnvaluesIF::RETURN_OK) {
|
||||||
@ -311,8 +317,13 @@ ReturnValue_t CommandingServiceBase::sendTmPacket(uint8_t subservice,
|
|||||||
size_t size = 0;
|
size_t size = 0;
|
||||||
SerializeAdapter::serialize(&objectId, &pBuffer, &size,
|
SerializeAdapter::serialize(&objectId, &pBuffer, &size,
|
||||||
sizeof(object_id_t), SerializeIF::Endianness::BIG);
|
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);
|
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(
|
ReturnValue_t result = tmPacketStored.sendPacket(
|
||||||
requestQueue->getDefaultDestination(), requestQueue->getId());
|
requestQueue->getDefaultDestination(), requestQueue->getId());
|
||||||
if (result == HasReturnvaluesIF::RETURN_OK) {
|
if (result == HasReturnvaluesIF::RETURN_OK) {
|
||||||
@ -324,8 +335,13 @@ ReturnValue_t CommandingServiceBase::sendTmPacket(uint8_t subservice,
|
|||||||
|
|
||||||
ReturnValue_t CommandingServiceBase::sendTmPacket(uint8_t subservice,
|
ReturnValue_t CommandingServiceBase::sendTmPacket(uint8_t subservice,
|
||||||
SerializeIF* content, SerializeIF* header) {
|
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);
|
this->tmPacketCounter, content, header);
|
||||||
|
#else
|
||||||
|
TmPacketStoredPusC tmPacketStored(this->apid, this->service, subservice,
|
||||||
|
this->tmPacketCounter, content, header);
|
||||||
|
#endif
|
||||||
ReturnValue_t result = tmPacketStored.sendPacket(
|
ReturnValue_t result = tmPacketStored.sendPacket(
|
||||||
requestQueue->getDefaultDestination(), requestQueue->getId());
|
requestQueue->getDefaultDestination(), requestQueue->getId());
|
||||||
if (result == HasReturnvaluesIF::RETURN_OK) {
|
if (result == HasReturnvaluesIF::RETURN_OK) {
|
||||||
|
@ -21,7 +21,7 @@ TmTcMessage::TmTcMessage(store_address_t storeId) {
|
|||||||
this->setStorageId(storeId);
|
this->setStorageId(storeId);
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t TmTcMessage::getMinimumMessageSize() {
|
size_t TmTcMessage::getMinimumMessageSize() const {
|
||||||
return this->HEADER_SIZE + sizeof(store_address_t);
|
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.
|
* @brief This call always returns the same fixed size of the message.
|
||||||
* @return Returns HEADER_SIZE + @c sizeof(store_address_t).
|
* @return Returns HEADER_SIZE + @c sizeof(store_address_t).
|
||||||
*/
|
*/
|
||||||
size_t getMinimumMessageSize();
|
size_t getMinimumMessageSize() const override;
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
* @brief In the default constructor, only the message_size is set.
|
* @brief In the default constructor, only the message_size is set.
|
||||||
|
3
unittest/tests/tmtcpacket/CMakeLists.txt
Normal file
3
unittest/tests/tmtcpacket/CMakeLists.txt
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
target_sources(${TARGET_NAME} PRIVATE
|
||||||
|
PusTmTest.cpp
|
||||||
|
)
|
3
unittest/tests/tmtcpacket/PusTmTest.cpp
Normal file
3
unittest/tests/tmtcpacket/PusTmTest.cpp
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
|||||||
|
#include "CatchFactory.h"
|
||||||
#include <fsfw/datapoollocal/LocalDataPoolManager.h>
|
#include <fsfw/datapoollocal/LocalDataPoolManager.h>
|
||||||
#include <fsfw/devicehandlers/DeviceHandlerBase.h>
|
#include <fsfw/devicehandlers/DeviceHandlerBase.h>
|
||||||
#include "CatchFactory.h"
|
|
||||||
|
|
||||||
#include <fsfw/events/EventManager.h>
|
#include <fsfw/events/EventManager.h>
|
||||||
#include <fsfw/health/HealthTable.h>
|
#include <fsfw/health/HealthTable.h>
|
||||||
@ -74,7 +74,7 @@ void Factory::setStaticFrameworkObjectIds() {
|
|||||||
|
|
||||||
DeviceHandlerFailureIsolation::powerConfirmationId = objects::NO_OBJECT;
|
DeviceHandlerFailureIsolation::powerConfirmationId = objects::NO_OBJECT;
|
||||||
|
|
||||||
TmPacketStored::timeStamperId = objects::NO_OBJECT;
|
TmPacketBase::timeStamperId = objects::NO_OBJECT;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user