Merge pull request 'PUS C support for Telecommands and first FSFW.h file' (#432) from KSat/fsfw:mueller/update-package into development
Reviewed-on: fsfw/fsfw#432
This commit is contained in:
commit
2684e82c7f
13
CHANGELOG
13
CHANGELOG
@ -1,3 +1,16 @@
|
|||||||
|
## Changes from ASTP 1.0.0 to 1.1.0
|
||||||
|
|
||||||
|
### PUS
|
||||||
|
|
||||||
|
- Added PUS C support
|
||||||
|
|
||||||
|
### Configuration
|
||||||
|
|
||||||
|
- Additional configuration option fsfwconfig::FSFW_MAX_TM_PACKET_SIZE which
|
||||||
|
need to be specified in FSFWConfig.h
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## Changes from ASTP 0.0.1 to 1.0.0
|
## Changes from ASTP 0.0.1 to 1.0.0
|
||||||
|
|
||||||
### Host OSAL
|
### Host OSAL
|
||||||
|
7
FSFW.h
Normal file
7
FSFW.h
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
#ifndef FSFW_FSFW_H_
|
||||||
|
#define FSFW_FSFW_H_
|
||||||
|
|
||||||
|
#include "FSFWConfig.h"
|
||||||
|
|
||||||
|
|
||||||
|
#endif /* FSFW_FSFW_H_ */
|
@ -7,29 +7,30 @@
|
|||||||
//! Used to determine whether C++ ostreams are used which can increase
|
//! Used to determine whether C++ ostreams are used which can increase
|
||||||
//! the binary size significantly. If this is disabled,
|
//! the binary size significantly. If this is disabled,
|
||||||
//! the C stdio functions can be used alternatively
|
//! the C stdio functions can be used alternatively
|
||||||
#define FSFW_CPP_OSTREAM_ENABLED 1
|
#define FSFW_CPP_OSTREAM_ENABLED 1
|
||||||
|
|
||||||
//! More FSFW related printouts depending on level. Useful for development.
|
//! More FSFW related printouts depending on level. Useful for development.
|
||||||
#define FSFW_VERBOSE_LEVEL 1
|
#define FSFW_VERBOSE_LEVEL 1
|
||||||
|
|
||||||
//! Can be used to completely disable printouts, even the C stdio ones.
|
//! Can be used to completely disable printouts, even the C stdio ones.
|
||||||
#if FSFW_CPP_OSTREAM_ENABLED == 0 && FSFW_VERBOSE_LEVEL == 0
|
#if FSFW_CPP_OSTREAM_ENABLED == 0 && FSFW_VERBOSE_LEVEL == 0
|
||||||
#define FSFW_DISABLE_PRINTOUT 0
|
#define FSFW_DISABLE_PRINTOUT 0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define FSFW_USE_PUS_C_TELEMETRY 1
|
#define FSFW_USE_PUS_C_TELEMETRY 1
|
||||||
|
#define FSFW_USE_PUS_C_TELECOMMANDS 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
|
||||||
|
|
||||||
//! If FSFW_OBJ_EVENT_TRANSLATION is set to one,
|
//! If FSFW_OBJ_EVENT_TRANSLATION is set to one,
|
||||||
//! additional output which requires the translation files translateObjects
|
//! additional output which requires the translation files translateObjects
|
||||||
//! and translateEvents (and their compiled source files)
|
//! and translateEvents (and their compiled source files)
|
||||||
#define FSFW_OBJ_EVENT_TRANSLATION 0
|
#define FSFW_OBJ_EVENT_TRANSLATION 0
|
||||||
|
|
||||||
#if FSFW_OBJ_EVENT_TRANSLATION == 1
|
#if FSFW_OBJ_EVENT_TRANSLATION == 1
|
||||||
//! Specify whether info events are printed too.
|
//! Specify whether info events are printed too.
|
||||||
#define FSFW_DEBUG_INFO 1
|
#define FSFW_DEBUG_INFO 1
|
||||||
#include "objects/translateObjects.h"
|
#include "objects/translateObjects.h"
|
||||||
#include "events/translateEvents.h"
|
#include "events/translateEvents.h"
|
||||||
#else
|
#else
|
||||||
@ -37,17 +38,17 @@
|
|||||||
|
|
||||||
//! When using the newlib nano library, C99 support for stdio facilities
|
//! When using the newlib nano library, C99 support for stdio facilities
|
||||||
//! will not be provided. This define should be set to 1 if this is the case.
|
//! will not be provided. This define should be set to 1 if this is the case.
|
||||||
#define FSFW_NO_C99_IO 1
|
#define FSFW_NO_C99_IO 1
|
||||||
|
|
||||||
//! 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.
|
//! Defines if the real time scheduler for linux should be used.
|
||||||
//! If set to 0, this will also disable priority settings for linux
|
//! If set to 0, this will also disable priority settings for linux
|
||||||
//! as most systems will not allow to set nice values without privileges
|
//! as most systems will not allow to set nice values without privileges
|
||||||
//! For embedded linux system set this to 1.
|
//! For embedded linux system set this to 1.
|
||||||
//! If set to 1 the binary needs "cap_sys_nice=eip" privileges to run
|
//! If set to 1 the binary needs "cap_sys_nice=eip" privileges to run
|
||||||
#define FSFW_USE_REALTIME_FOR_LINUX 1
|
#define FSFW_USE_REALTIME_FOR_LINUX 1
|
||||||
|
|
||||||
namespace fsfwconfig {
|
namespace fsfwconfig {
|
||||||
|
|
||||||
@ -67,6 +68,8 @@ 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;
|
||||||
|
|
||||||
|
static constexpr size_t FSFW_MAX_TM_PACKET_SIZE = 2048;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* CONFIG_FSFWCONFIG_H_ */
|
#endif /* CONFIG_FSFWCONFIG_H_ */
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
#include "../serviceinterface/ServiceInterface.h"
|
#include "../serviceinterface/ServiceInterface.h"
|
||||||
#include "../objectmanager/SystemObject.h"
|
#include "../objectmanager/SystemObject.h"
|
||||||
#include "../tmtcpacket/pus/TmPacketStored.h"
|
#include "../tmtcpacket/pus/tm/TmPacketStored.h"
|
||||||
|
|
||||||
|
|
||||||
Service17Test::Service17Test(object_id_t objectId,
|
Service17Test::Service17Test(object_id_t objectId,
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
#include "../ipc/QueueFactory.h"
|
#include "../ipc/QueueFactory.h"
|
||||||
#include "../objectmanager/ObjectManager.h"
|
#include "../objectmanager/ObjectManager.h"
|
||||||
#include "../tmtcservices/PusVerificationReport.h"
|
#include "../tmtcservices/PusVerificationReport.h"
|
||||||
#include "../tmtcpacket/pus/TmPacketStored.h"
|
#include "../tmtcpacket/pus/tm/TmPacketStored.h"
|
||||||
#include "../serviceinterface/ServiceInterfaceStream.h"
|
#include "../serviceinterface/ServiceInterfaceStream.h"
|
||||||
#include "../tmtcservices/AcceptsTelemetryIF.h"
|
#include "../tmtcservices/AcceptsTelemetryIF.h"
|
||||||
|
|
||||||
|
@ -133,6 +133,9 @@ ReturnValue_t Service20ParameterManagement::prepareLoadCommand(
|
|||||||
store_address_t storeAddress;
|
store_address_t storeAddress;
|
||||||
size_t parameterDataLen = tcDataLen - sizeof(object_id_t) - sizeof(ParameterId_t) -
|
size_t parameterDataLen = tcDataLen - sizeof(object_id_t) - sizeof(ParameterId_t) -
|
||||||
sizeof(uint32_t);
|
sizeof(uint32_t);
|
||||||
|
if(parameterDataLen == 0) {
|
||||||
|
return CommandingServiceBase::INVALID_TC;
|
||||||
|
}
|
||||||
ReturnValue_t result = IPCStore->getFreeElement(&storeAddress,
|
ReturnValue_t result = IPCStore->getFreeElement(&storeAddress,
|
||||||
parameterDataLen, &storePointer);
|
parameterDataLen, &storePointer);
|
||||||
if(result != HasReturnvaluesIF::RETURN_OK) {
|
if(result != HasReturnvaluesIF::RETURN_OK) {
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
#include "../objectmanager/ObjectManager.h"
|
#include "../objectmanager/ObjectManager.h"
|
||||||
#include "../events/EventManagerIF.h"
|
#include "../events/EventManagerIF.h"
|
||||||
#include "../ipc/QueueFactory.h"
|
#include "../ipc/QueueFactory.h"
|
||||||
#include "../tmtcpacket/pus/TmPacketStored.h"
|
#include "../tmtcpacket/pus/tm/TmPacketStored.h"
|
||||||
|
|
||||||
|
|
||||||
Service5EventReporting::Service5EventReporting(object_id_t objectId,
|
Service5EventReporting::Service5EventReporting(object_id_t objectId,
|
||||||
|
@ -27,12 +27,11 @@ public:
|
|||||||
ParameterCommand(uint8_t* storePointer, size_t parameterDataLen):
|
ParameterCommand(uint8_t* storePointer, size_t parameterDataLen):
|
||||||
parameterBuffer(storePointer, parameterDataLen) {
|
parameterBuffer(storePointer, parameterDataLen) {
|
||||||
#if FSFW_VERBOSE_LEVEL >= 1
|
#if FSFW_VERBOSE_LEVEL >= 1
|
||||||
if(parameterDataLen < sizeof(object_id_t) + sizeof(ParameterId_t) + 4) {
|
if(parameterDataLen == 0) {
|
||||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||||
sif::warning << "ParameterCommand: Parameter data length is less than 12!"
|
sif::warning << "ParameterCommand: Parameter data length is 0" << std::endl;
|
||||||
<< std::endl;
|
|
||||||
#else
|
#else
|
||||||
sif::printWarning("ParameterCommand: Parameter data length is less than 12!\n");
|
sif::printWarning("ParameterCommand: Parameter data length is 0!\n");
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
#endif /* FSFW_VERBOSE_LEVEL >= 1 */
|
#endif /* FSFW_VERBOSE_LEVEL >= 1 */
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
target_sources(${LIB_FSFW_NAME}
|
target_sources(${LIB_FSFW_NAME} PRIVATE
|
||||||
PRIVATE
|
CCSDSDistributor.cpp
|
||||||
CCSDSDistributor.cpp
|
PUSDistributor.cpp
|
||||||
PUSDistributor.cpp
|
TcDistributor.cpp
|
||||||
TcDistributor.cpp
|
TcPacketCheck.cpp
|
||||||
TcPacketCheck.cpp
|
|
||||||
)
|
)
|
||||||
|
@ -3,7 +3,6 @@
|
|||||||
|
|
||||||
#include "../objectmanager/ObjectManager.h"
|
#include "../objectmanager/ObjectManager.h"
|
||||||
#include "../serviceinterface/ServiceInterface.h"
|
#include "../serviceinterface/ServiceInterface.h"
|
||||||
#include "../tmtcpacket/pus/TcPacketStored.h"
|
|
||||||
#include "../tmtcservices/PusVerificationReport.h"
|
#include "../tmtcservices/PusVerificationReport.h"
|
||||||
|
|
||||||
#define PUS_DISTRIBUTOR_DEBUGGING 0
|
#define PUS_DISTRIBUTOR_DEBUGGING 0
|
||||||
@ -119,7 +118,7 @@ uint16_t PUSDistributor::getIdentifier() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ReturnValue_t PUSDistributor::initialize() {
|
ReturnValue_t PUSDistributor::initialize() {
|
||||||
currentPacket = new TcPacketStored();
|
currentPacket = new TcPacketStoredPus();
|
||||||
if(currentPacket == nullptr) {
|
if(currentPacket == nullptr) {
|
||||||
// Should not happen, memory allocation failed!
|
// Should not happen, memory allocation failed!
|
||||||
return ObjectManagerIF::CHILD_INIT_FAILED;
|
return ObjectManagerIF::CHILD_INIT_FAILED;
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
#include "TcDistributor.h"
|
#include "TcDistributor.h"
|
||||||
#include "TcPacketCheck.h"
|
#include "TcPacketCheck.h"
|
||||||
|
|
||||||
|
#include "../tmtcpacket/pus/tc.h"
|
||||||
#include "../returnvalues/HasReturnvaluesIF.h"
|
#include "../returnvalues/HasReturnvaluesIF.h"
|
||||||
#include "../tmtcservices/AcceptsTelecommandsIF.h"
|
#include "../tmtcservices/AcceptsTelecommandsIF.h"
|
||||||
#include "../tmtcservices/VerificationReporter.h"
|
#include "../tmtcservices/VerificationReporter.h"
|
||||||
@ -51,7 +52,8 @@ protected:
|
|||||||
/**
|
/**
|
||||||
* The currently handled packet is stored here.
|
* The currently handled packet is stored here.
|
||||||
*/
|
*/
|
||||||
TcPacketStored* currentPacket = nullptr;
|
TcPacketStoredPus* currentPacket = nullptr;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* With this variable, the current check status is stored to generate
|
* With this variable, the current check status is stored to generate
|
||||||
* acceptance messages later.
|
* acceptance messages later.
|
||||||
|
@ -1,39 +1,46 @@
|
|||||||
#include "TcPacketCheck.h"
|
#include "TcPacketCheck.h"
|
||||||
|
|
||||||
#include "../globalfunctions/CRC.h"
|
#include "../globalfunctions/CRC.h"
|
||||||
#include "../serviceinterface/ServiceInterfaceStream.h"
|
#include "../tmtcpacket/pus/tc/TcPacketBase.h"
|
||||||
|
#include "../tmtcpacket/pus/tc/TcPacketStoredBase.h"
|
||||||
|
#include "../serviceinterface/ServiceInterface.h"
|
||||||
#include "../storagemanager/StorageManagerIF.h"
|
#include "../storagemanager/StorageManagerIF.h"
|
||||||
#include "../tmtcservices/VerificationCodes.h"
|
#include "../tmtcservices/VerificationCodes.h"
|
||||||
|
|
||||||
TcPacketCheck::TcPacketCheck( uint16_t setApid ) : apid(setApid) {
|
TcPacketCheck::TcPacketCheck(uint16_t setApid): apid(setApid) {
|
||||||
}
|
}
|
||||||
|
|
||||||
ReturnValue_t TcPacketCheck::checkPacket( TcPacketStored* currentPacket ) {
|
ReturnValue_t TcPacketCheck::checkPacket(TcPacketStoredBase* currentPacket) {
|
||||||
uint16_t calculated_crc = CRC::crc16ccitt( currentPacket->getWholeData(),
|
TcPacketBase* tcPacketBase = currentPacket->getPacketBase();
|
||||||
currentPacket->getFullSize() );
|
if(tcPacketBase == nullptr) {
|
||||||
if ( calculated_crc != 0 ) {
|
return RETURN_FAILED;
|
||||||
return INCORRECT_CHECKSUM;
|
}
|
||||||
}
|
uint16_t calculated_crc = CRC::crc16ccitt(tcPacketBase->getWholeData(),
|
||||||
bool condition = (not currentPacket->hasSecondaryHeader()) or
|
tcPacketBase->getFullSize());
|
||||||
(currentPacket->getPacketVersionNumber() != CCSDS_VERSION_NUMBER) or
|
if (calculated_crc != 0) {
|
||||||
(not currentPacket->isTelecommand());
|
return INCORRECT_CHECKSUM;
|
||||||
if ( condition ) {
|
}
|
||||||
return INCORRECT_PRIMARY_HEADER;
|
bool condition = (not tcPacketBase->hasSecondaryHeader()) or
|
||||||
}
|
(tcPacketBase->getPacketVersionNumber() != CCSDS_VERSION_NUMBER) or
|
||||||
if ( currentPacket->getAPID() != this->apid )
|
(not tcPacketBase->isTelecommand());
|
||||||
return ILLEGAL_APID;
|
if (condition) {
|
||||||
|
return INCORRECT_PRIMARY_HEADER;
|
||||||
|
}
|
||||||
|
if (tcPacketBase->getAPID() != this->apid)
|
||||||
|
return ILLEGAL_APID;
|
||||||
|
|
||||||
if ( not currentPacket->isSizeCorrect() ) {
|
if (not currentPacket->isSizeCorrect()) {
|
||||||
return INCOMPLETE_PACKET;
|
return INCOMPLETE_PACKET;
|
||||||
}
|
}
|
||||||
condition = (currentPacket->getSecondaryHeaderFlag() != CCSDS_SECONDARY_HEADER_FLAG) ||
|
|
||||||
(currentPacket->getPusVersionNumber() != PUS_VERSION_NUMBER);
|
condition = (tcPacketBase->getSecondaryHeaderFlag() != CCSDS_SECONDARY_HEADER_FLAG) ||
|
||||||
if ( condition ) {
|
(tcPacketBase->getPusVersionNumber() != PUS_VERSION_NUMBER);
|
||||||
return INCORRECT_SECONDARY_HEADER;
|
if (condition) {
|
||||||
}
|
return INCORRECT_SECONDARY_HEADER;
|
||||||
return RETURN_OK;
|
}
|
||||||
|
return RETURN_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint16_t TcPacketCheck::getApid() const {
|
uint16_t TcPacketCheck::getApid() const {
|
||||||
return apid;
|
return apid;
|
||||||
}
|
}
|
||||||
|
@ -1,10 +1,12 @@
|
|||||||
#ifndef FSFW_TCDISTRIBUTION_TCPACKETCHECK_H_
|
#ifndef FSFW_TCDISTRIBUTION_TCPACKETCHECK_H_
|
||||||
#define FSFW_TCDISTRIBUTION_TCPACKETCHECK_H_
|
#define FSFW_TCDISTRIBUTION_TCPACKETCHECK_H_
|
||||||
|
|
||||||
|
#include "../FSFW.h"
|
||||||
#include "../returnvalues/HasReturnvaluesIF.h"
|
#include "../returnvalues/HasReturnvaluesIF.h"
|
||||||
#include "../tmtcpacket/pus/TcPacketStored.h"
|
|
||||||
#include "../tmtcservices/PusVerificationReport.h"
|
#include "../tmtcservices/PusVerificationReport.h"
|
||||||
|
|
||||||
|
class TcPacketStoredBase;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class performs a formal packet check for incoming PUS Telecommand Packets.
|
* This class performs a formal packet check for incoming PUS Telecommand Packets.
|
||||||
* Currently, it only checks if the APID and CRC are correct.
|
* Currently, it only checks if the APID and CRC are correct.
|
||||||
@ -12,49 +14,53 @@
|
|||||||
*/
|
*/
|
||||||
class TcPacketCheck : public HasReturnvaluesIF {
|
class TcPacketCheck : public HasReturnvaluesIF {
|
||||||
protected:
|
protected:
|
||||||
/**
|
/**
|
||||||
* Describes the version number a packet must have to pass.
|
* Describes the version number a packet must have to pass.
|
||||||
*/
|
*/
|
||||||
static constexpr uint8_t CCSDS_VERSION_NUMBER = 0;
|
static constexpr uint8_t CCSDS_VERSION_NUMBER = 0;
|
||||||
/**
|
/**
|
||||||
* Describes the secondary header a packet must have to pass.
|
* Describes the secondary header a packet must have to pass.
|
||||||
*/
|
*/
|
||||||
static constexpr uint8_t CCSDS_SECONDARY_HEADER_FLAG = 0;
|
static constexpr uint8_t CCSDS_SECONDARY_HEADER_FLAG = 0;
|
||||||
/**
|
/**
|
||||||
* Describes the TC Packet PUS Version Number a packet must have to pass.
|
* Describes the TC Packet PUS Version Number a packet must have to pass.
|
||||||
*/
|
*/
|
||||||
static constexpr uint8_t PUS_VERSION_NUMBER = 1;
|
#if FSFW_USE_PUS_C_TELECOMMANDS == 1
|
||||||
/**
|
static constexpr uint8_t PUS_VERSION_NUMBER = 2;
|
||||||
* The packet id each correct packet should have.
|
#else
|
||||||
* It is composed of the APID and some static fields.
|
static constexpr uint8_t PUS_VERSION_NUMBER = 1;
|
||||||
*/
|
#endif
|
||||||
uint16_t apid;
|
|
||||||
public:
|
|
||||||
static const uint8_t INTERFACE_ID = CLASS_ID::TC_PACKET_CHECK;
|
|
||||||
static const ReturnValue_t ILLEGAL_APID = MAKE_RETURN_CODE( 0 );
|
|
||||||
static const ReturnValue_t INCOMPLETE_PACKET = MAKE_RETURN_CODE( 1 );
|
|
||||||
static const ReturnValue_t INCORRECT_CHECKSUM = MAKE_RETURN_CODE( 2 );
|
|
||||||
static const ReturnValue_t ILLEGAL_PACKET_TYPE = MAKE_RETURN_CODE( 3 );
|
|
||||||
static const ReturnValue_t ILLEGAL_PACKET_SUBTYPE = MAKE_RETURN_CODE( 4 );
|
|
||||||
static const ReturnValue_t INCORRECT_PRIMARY_HEADER = MAKE_RETURN_CODE( 5 );
|
|
||||||
static const ReturnValue_t INCORRECT_SECONDARY_HEADER = MAKE_RETURN_CODE( 6 );
|
|
||||||
/**
|
|
||||||
* The constructor only sets the APID attribute.
|
|
||||||
* @param set_apid The APID to set.
|
|
||||||
*/
|
|
||||||
TcPacketCheck( uint16_t setApid );
|
|
||||||
/**
|
|
||||||
* This is the actual method to formally check a certain Telecommand Packet.
|
|
||||||
* The packet's Application Data can not be checked here.
|
|
||||||
* @param current_packet The packt to check
|
|
||||||
* @return - @c RETURN_OK on success.
|
|
||||||
* - @c INCORRECT_CHECKSUM if checksum is invalid.
|
|
||||||
* - @c ILLEGAL_APID if APID does not match.
|
|
||||||
*/
|
|
||||||
ReturnValue_t checkPacket( TcPacketStored* currentPacket );
|
|
||||||
|
|
||||||
uint16_t getApid() const;
|
/**
|
||||||
|
* The packet id each correct packet should have.
|
||||||
|
* It is composed of the APID and some static fields.
|
||||||
|
*/
|
||||||
|
uint16_t apid;
|
||||||
|
public:
|
||||||
|
static const uint8_t INTERFACE_ID = CLASS_ID::TC_PACKET_CHECK;
|
||||||
|
static const ReturnValue_t ILLEGAL_APID = MAKE_RETURN_CODE( 0 );
|
||||||
|
static const ReturnValue_t INCOMPLETE_PACKET = MAKE_RETURN_CODE( 1 );
|
||||||
|
static const ReturnValue_t INCORRECT_CHECKSUM = MAKE_RETURN_CODE( 2 );
|
||||||
|
static const ReturnValue_t ILLEGAL_PACKET_TYPE = MAKE_RETURN_CODE( 3 );
|
||||||
|
static const ReturnValue_t ILLEGAL_PACKET_SUBTYPE = MAKE_RETURN_CODE( 4 );
|
||||||
|
static const ReturnValue_t INCORRECT_PRIMARY_HEADER = MAKE_RETURN_CODE( 5 );
|
||||||
|
static const ReturnValue_t INCORRECT_SECONDARY_HEADER = MAKE_RETURN_CODE( 6 );
|
||||||
|
/**
|
||||||
|
* The constructor only sets the APID attribute.
|
||||||
|
* @param set_apid The APID to set.
|
||||||
|
*/
|
||||||
|
TcPacketCheck(uint16_t setApid);
|
||||||
|
/**
|
||||||
|
* This is the actual method to formally check a certain Telecommand Packet.
|
||||||
|
* The packet's Application Data can not be checked here.
|
||||||
|
* @param current_packet The packt to check
|
||||||
|
* @return - @c RETURN_OK on success.
|
||||||
|
* - @c INCORRECT_CHECKSUM if checksum is invalid.
|
||||||
|
* - @c ILLEGAL_APID if APID does not match.
|
||||||
|
*/
|
||||||
|
ReturnValue_t checkPacket(TcPacketStoredBase* currentPacket);
|
||||||
|
|
||||||
|
uint16_t getApid() const;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
#endif /* FSFW_TCDISTRIBUTION_TCPACKETCHECK_H_ */
|
#endif /* FSFW_TCDISTRIBUTION_TCPACKETCHECK_H_ */
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
#include "../serialize/SerializeElement.h"
|
#include "../serialize/SerializeElement.h"
|
||||||
#include "../serialize/SerialLinkedListAdapter.h"
|
#include "../serialize/SerialLinkedListAdapter.h"
|
||||||
#include "../serialize/SerialBufferAdapter.h"
|
#include "../serialize/SerialBufferAdapter.h"
|
||||||
#include "../tmtcpacket/pus/TmPacketMinimal.h"
|
#include "../tmtcpacket/pus/tm/TmPacketMinimal.h"
|
||||||
#include "../timemanager/TimeStamperIF.h"
|
#include "../timemanager/TimeStamperIF.h"
|
||||||
#include "../timemanager/CCSDSTime.h"
|
#include "../timemanager/CCSDSTime.h"
|
||||||
#include "../globalfunctions/timevalOperations.h"
|
#include "../globalfunctions/timevalOperations.h"
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
target_sources(${LIB_FSFW_NAME}
|
target_sources(${LIB_FSFW_NAME} PRIVATE
|
||||||
PRIVATE
|
SpacePacket.cpp
|
||||||
SpacePacket.cpp
|
SpacePacketBase.cpp
|
||||||
SpacePacketBase.cpp
|
|
||||||
)
|
)
|
||||||
|
|
||||||
add_subdirectory(packetmatcher)
|
add_subdirectory(packetmatcher)
|
||||||
|
@ -72,7 +72,7 @@ void SpacePacketBase::setPacketSequenceCount( uint16_t new_count) {
|
|||||||
this->data->header.sequence_control_l = ( (new_count%LIMIT_SEQUENCE_COUNT) & 0x00FF );
|
this->data->header.sequence_control_l = ( (new_count%LIMIT_SEQUENCE_COUNT) & 0x00FF );
|
||||||
}
|
}
|
||||||
|
|
||||||
uint16_t SpacePacketBase::getPacketDataLength( void ) {
|
uint16_t SpacePacketBase::getPacketDataLength() const {
|
||||||
return ( (this->data->header.packet_length_h) << 8 )
|
return ( (this->data->header.packet_length_h) << 8 )
|
||||||
+ this->data->header.packet_length_l;
|
+ this->data->header.packet_length_l;
|
||||||
}
|
}
|
||||||
|
@ -138,9 +138,11 @@ public:
|
|||||||
* Returns the packet data length, which is the fifth and sixth byte of the
|
* Returns the packet data length, which is the fifth and sixth byte of the
|
||||||
* CCSDS Primary Header. The packet data length is the size of every kind
|
* CCSDS Primary Header. The packet data length is the size of every kind
|
||||||
* of data \b after the CCSDS Primary Header \b -1.
|
* of data \b after the CCSDS Primary Header \b -1.
|
||||||
* @return The CCSDS packet data length.
|
* @return
|
||||||
|
* The CCSDS packet data length. uint16_t is sufficient,
|
||||||
|
* because this is limit in CCSDS standard
|
||||||
*/
|
*/
|
||||||
uint16_t getPacketDataLength( void ); //uint16_t is sufficient, because this is limit in CCSDS standard
|
uint16_t getPacketDataLength(void) const;
|
||||||
/**
|
/**
|
||||||
* Sets the packet data length, which is the fifth and sixth byte of the
|
* Sets the packet data length, which is the fifth and sixth byte of the
|
||||||
* CCSDS Primary Header.
|
* CCSDS Primary Header.
|
||||||
|
@ -1,38 +1,38 @@
|
|||||||
#ifndef FRAMEWORK_TMTCPACKET_PACKETMATCHER_APIDMATCHER_H_
|
#ifndef FSFW_TMTCPACKET_PACKETMATCHER_APIDMATCHER_H_
|
||||||
#define FRAMEWORK_TMTCPACKET_PACKETMATCHER_APIDMATCHER_H_
|
#define FSFW_TMTCPACKET_PACKETMATCHER_APIDMATCHER_H_
|
||||||
|
|
||||||
#include "../../globalfunctions/matching/SerializeableMatcherIF.h"
|
#include "../../globalfunctions/matching/SerializeableMatcherIF.h"
|
||||||
#include "../../serialize/SerializeAdapter.h"
|
#include "../../serialize/SerializeAdapter.h"
|
||||||
#include "../../tmtcpacket/pus/TmPacketMinimal.h"
|
#include "../../tmtcpacket/pus/tm/TmPacketMinimal.h"
|
||||||
|
|
||||||
class ApidMatcher: public SerializeableMatcherIF<TmPacketMinimal*> {
|
class ApidMatcher: public SerializeableMatcherIF<TmPacketMinimal*> {
|
||||||
private:
|
private:
|
||||||
uint16_t apid;
|
uint16_t apid;
|
||||||
public:
|
public:
|
||||||
ApidMatcher(uint16_t setApid) :
|
ApidMatcher(uint16_t setApid) :
|
||||||
apid(setApid) {
|
apid(setApid) {
|
||||||
}
|
}
|
||||||
ApidMatcher(TmPacketMinimal* test) :
|
ApidMatcher(TmPacketMinimal* test) :
|
||||||
apid(test->getAPID()) {
|
apid(test->getAPID()) {
|
||||||
}
|
}
|
||||||
bool match(TmPacketMinimal* packet) {
|
bool match(TmPacketMinimal* packet) {
|
||||||
if (packet->getAPID() == apid) {
|
if (packet->getAPID() == apid) {
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ReturnValue_t serialize(uint8_t** buffer, size_t* size,
|
ReturnValue_t serialize(uint8_t** buffer, size_t* size,
|
||||||
size_t maxSize, Endianness streamEndianness) const {
|
size_t maxSize, Endianness streamEndianness) const {
|
||||||
return SerializeAdapter::serialize(&apid, buffer, size, maxSize, streamEndianness);
|
return SerializeAdapter::serialize(&apid, buffer, size, maxSize, streamEndianness);
|
||||||
}
|
}
|
||||||
size_t getSerializedSize() const {
|
size_t getSerializedSize() const {
|
||||||
return SerializeAdapter::getSerializedSize(&apid);
|
return SerializeAdapter::getSerializedSize(&apid);
|
||||||
}
|
}
|
||||||
ReturnValue_t deSerialize(const uint8_t** buffer, size_t* size,
|
ReturnValue_t deSerialize(const uint8_t** buffer, size_t* size,
|
||||||
Endianness streamEndianness) {
|
Endianness streamEndianness) {
|
||||||
return SerializeAdapter::deSerialize(&apid, buffer, size, streamEndianness);
|
return SerializeAdapter::deSerialize(&apid, buffer, size, streamEndianness);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -5,197 +5,194 @@
|
|||||||
|
|
||||||
// This should be configurable..
|
// This should be configurable..
|
||||||
const LocalPool::LocalPoolConfig PacketMatchTree::poolConfig = {
|
const LocalPool::LocalPoolConfig PacketMatchTree::poolConfig = {
|
||||||
{10, sizeof(ServiceMatcher)},
|
{10, sizeof(ServiceMatcher)},
|
||||||
{20, sizeof(SubServiceMatcher)},
|
{20, sizeof(SubServiceMatcher)},
|
||||||
{2, sizeof(ApidMatcher)},
|
{2, sizeof(ApidMatcher)},
|
||||||
{40, sizeof(PacketMatchTree::Node)}
|
{40, sizeof(PacketMatchTree::Node)}
|
||||||
};
|
};
|
||||||
|
|
||||||
PacketMatchTree::PacketMatchTree(Node* root) :
|
PacketMatchTree::PacketMatchTree(Node* root): MatchTree<TmPacketMinimal*>(root, 2),
|
||||||
MatchTree<TmPacketMinimal*>(root, 2),
|
factoryBackend(0, poolConfig, false, true),
|
||||||
factoryBackend(0, poolConfig, false, true),
|
factory(&factoryBackend) {
|
||||||
factory(&factoryBackend) {
|
|
||||||
}
|
}
|
||||||
|
|
||||||
PacketMatchTree::PacketMatchTree(iterator root) :
|
PacketMatchTree::PacketMatchTree(iterator root): MatchTree<TmPacketMinimal*>(root.element, 2),
|
||||||
MatchTree<TmPacketMinimal*>(root.element, 2),
|
factoryBackend(0, poolConfig, false, true),
|
||||||
factoryBackend(0, poolConfig, false, true),
|
factory(&factoryBackend) {
|
||||||
factory(&factoryBackend) {
|
|
||||||
}
|
}
|
||||||
|
|
||||||
PacketMatchTree::PacketMatchTree() :
|
PacketMatchTree::PacketMatchTree(): MatchTree<TmPacketMinimal*>((Node*) NULL, 2),
|
||||||
MatchTree<TmPacketMinimal*>((Node*) NULL, 2),
|
factoryBackend(0, poolConfig, false, true),
|
||||||
factoryBackend(0, poolConfig, false, true),
|
factory(&factoryBackend) {
|
||||||
factory(&factoryBackend) {
|
|
||||||
}
|
}
|
||||||
|
|
||||||
PacketMatchTree::~PacketMatchTree() {
|
PacketMatchTree::~PacketMatchTree() {
|
||||||
}
|
}
|
||||||
|
|
||||||
ReturnValue_t PacketMatchTree::addMatch(uint16_t apid, uint8_t type,
|
ReturnValue_t PacketMatchTree::addMatch(uint16_t apid, uint8_t type,
|
||||||
uint8_t subtype) {
|
uint8_t subtype) {
|
||||||
//We assume adding APID is always requested.
|
//We assume adding APID is always requested.
|
||||||
TmPacketMinimal::TmPacketMinimalPointer data;
|
TmPacketMinimal::TmPacketMinimalPointer data;
|
||||||
data.data_field.service_type = type;
|
data.data_field.service_type = type;
|
||||||
data.data_field.service_subtype = subtype;
|
data.data_field.service_subtype = subtype;
|
||||||
TmPacketMinimal testPacket((uint8_t*) &data);
|
TmPacketMinimal testPacket((uint8_t*) &data);
|
||||||
testPacket.setAPID(apid);
|
testPacket.setAPID(apid);
|
||||||
iterator lastTest;
|
iterator lastTest;
|
||||||
iterator rollback;
|
iterator rollback;
|
||||||
ReturnValue_t result = findOrInsertMatch<TmPacketMinimal*, ApidMatcher>(
|
ReturnValue_t result = findOrInsertMatch<TmPacketMinimal*, ApidMatcher>(
|
||||||
this->begin(), &testPacket, &lastTest);
|
this->begin(), &testPacket, &lastTest);
|
||||||
if (result == NEW_NODE_CREATED) {
|
if (result == NEW_NODE_CREATED) {
|
||||||
rollback = lastTest;
|
rollback = lastTest;
|
||||||
} else if (result != RETURN_OK) {
|
} else if (result != RETURN_OK) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
if (type == 0) {
|
if (type == 0) {
|
||||||
//Check if lastTest has no children, otherwise, delete them,
|
//Check if lastTest has no children, otherwise, delete them,
|
||||||
//as a more general check is requested.
|
//as a more general check is requested.
|
||||||
if (lastTest.left() != this->end()) {
|
if (lastTest.left() != this->end()) {
|
||||||
removeElementAndAllChildren(lastTest.left());
|
removeElementAndAllChildren(lastTest.left());
|
||||||
}
|
}
|
||||||
return RETURN_OK;
|
return RETURN_OK;
|
||||||
}
|
}
|
||||||
//Type insertion required.
|
//Type insertion required.
|
||||||
result = findOrInsertMatch<TmPacketMinimal*, ServiceMatcher>(
|
result = findOrInsertMatch<TmPacketMinimal*, ServiceMatcher>(
|
||||||
lastTest.left(), &testPacket, &lastTest);
|
lastTest.left(), &testPacket, &lastTest);
|
||||||
if (result == NEW_NODE_CREATED) {
|
if (result == NEW_NODE_CREATED) {
|
||||||
if (rollback == this->end()) {
|
if (rollback == this->end()) {
|
||||||
rollback = lastTest;
|
rollback = lastTest;
|
||||||
}
|
}
|
||||||
} else if (result != RETURN_OK) {
|
} else if (result != RETURN_OK) {
|
||||||
if (rollback != this->end()) {
|
if (rollback != this->end()) {
|
||||||
removeElementAndAllChildren(rollback);
|
removeElementAndAllChildren(rollback);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
if (subtype == 0) {
|
if (subtype == 0) {
|
||||||
if (lastTest.left() != this->end()) {
|
if (lastTest.left() != this->end()) {
|
||||||
//See above
|
//See above
|
||||||
removeElementAndAllChildren(lastTest.left());
|
removeElementAndAllChildren(lastTest.left());
|
||||||
}
|
}
|
||||||
return RETURN_OK;
|
return RETURN_OK;
|
||||||
}
|
}
|
||||||
//Subtype insertion required.
|
//Subtype insertion required.
|
||||||
result = findOrInsertMatch<TmPacketMinimal*, SubServiceMatcher>(
|
result = findOrInsertMatch<TmPacketMinimal*, SubServiceMatcher>(
|
||||||
lastTest.left(), &testPacket, &lastTest);
|
lastTest.left(), &testPacket, &lastTest);
|
||||||
if (result == NEW_NODE_CREATED) {
|
if (result == NEW_NODE_CREATED) {
|
||||||
return RETURN_OK;
|
return RETURN_OK;
|
||||||
} else if (result != RETURN_OK) {
|
} else if (result != RETURN_OK) {
|
||||||
if (rollback != this->end()) {
|
if (rollback != this->end()) {
|
||||||
removeElementAndAllChildren(rollback);
|
removeElementAndAllChildren(rollback);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
return RETURN_OK;
|
return RETURN_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename VALUE_T, typename INSERTION_T>
|
template<typename VALUE_T, typename INSERTION_T>
|
||||||
ReturnValue_t PacketMatchTree::findOrInsertMatch(iterator startAt, VALUE_T test,
|
ReturnValue_t PacketMatchTree::findOrInsertMatch(iterator startAt, VALUE_T test,
|
||||||
iterator* lastTest) {
|
iterator* lastTest) {
|
||||||
bool attachToBranch = AND;
|
bool attachToBranch = AND;
|
||||||
iterator iter = startAt;
|
iterator iter = startAt;
|
||||||
while (iter != this->end()) {
|
while (iter != this->end()) {
|
||||||
bool isMatch = iter->match(test);
|
bool isMatch = iter->match(test);
|
||||||
attachToBranch = OR;
|
attachToBranch = OR;
|
||||||
*lastTest = iter;
|
*lastTest = iter;
|
||||||
if (isMatch) {
|
if (isMatch) {
|
||||||
return RETURN_OK;
|
return RETURN_OK;
|
||||||
} else {
|
} else {
|
||||||
//Go down OR branch.
|
//Go down OR branch.
|
||||||
iter = iter.right();
|
iter = iter.right();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//Only reached if nothing was found.
|
//Only reached if nothing was found.
|
||||||
SerializeableMatcherIF<VALUE_T>* newContent = factory.generate<INSERTION_T>(
|
SerializeableMatcherIF<VALUE_T>* newContent = factory.generate<INSERTION_T>(
|
||||||
test);
|
test);
|
||||||
if (newContent == NULL) {
|
if (newContent == NULL) {
|
||||||
return FULL;
|
return FULL;
|
||||||
}
|
}
|
||||||
Node* newNode = factory.generate<Node>(newContent);
|
Node* newNode = factory.generate<Node>(newContent);
|
||||||
if (newNode == NULL) {
|
if (newNode == NULL) {
|
||||||
//Need to make sure partially generated content is deleted, otherwise, that's a leak.
|
//Need to make sure partially generated content is deleted, otherwise, that's a leak.
|
||||||
factory.destroy<INSERTION_T>(static_cast<INSERTION_T*>(newContent));
|
factory.destroy<INSERTION_T>(static_cast<INSERTION_T*>(newContent));
|
||||||
return FULL;
|
return FULL;
|
||||||
}
|
}
|
||||||
*lastTest = insert(attachToBranch, *lastTest, newNode);
|
*lastTest = insert(attachToBranch, *lastTest, newNode);
|
||||||
if (*lastTest == end()) {
|
if (*lastTest == end()) {
|
||||||
//This actaully never fails, so creating a dedicated returncode seems an overshoot.
|
//This actaully never fails, so creating a dedicated returncode seems an overshoot.
|
||||||
return RETURN_FAILED;
|
return RETURN_FAILED;
|
||||||
}
|
}
|
||||||
return NEW_NODE_CREATED;
|
return NEW_NODE_CREATED;
|
||||||
}
|
}
|
||||||
|
|
||||||
ReturnValue_t PacketMatchTree::removeMatch(uint16_t apid, uint8_t type,
|
ReturnValue_t PacketMatchTree::removeMatch(uint16_t apid, uint8_t type,
|
||||||
uint8_t subtype) {
|
uint8_t subtype) {
|
||||||
TmPacketMinimal::TmPacketMinimalPointer data;
|
TmPacketMinimal::TmPacketMinimalPointer data;
|
||||||
data.data_field.service_type = type;
|
data.data_field.service_type = type;
|
||||||
data.data_field.service_subtype = subtype;
|
data.data_field.service_subtype = subtype;
|
||||||
TmPacketMinimal testPacket((uint8_t*) &data);
|
TmPacketMinimal testPacket((uint8_t*) &data);
|
||||||
testPacket.setAPID(apid);
|
testPacket.setAPID(apid);
|
||||||
iterator foundElement = findMatch(begin(), &testPacket);
|
iterator foundElement = findMatch(begin(), &testPacket);
|
||||||
if (foundElement == this->end()) {
|
if (foundElement == this->end()) {
|
||||||
return NO_MATCH;
|
return NO_MATCH;
|
||||||
}
|
}
|
||||||
if (type == 0) {
|
if (type == 0) {
|
||||||
if (foundElement.left() == end()) {
|
if (foundElement.left() == end()) {
|
||||||
return removeElementAndReconnectChildren(foundElement);
|
return removeElementAndReconnectChildren(foundElement);
|
||||||
} else {
|
} else {
|
||||||
return TOO_GENERAL_REQUEST;
|
return TOO_GENERAL_REQUEST;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//Go down AND branch. Will abort if empty.
|
//Go down AND branch. Will abort if empty.
|
||||||
foundElement = findMatch(foundElement.left(), &testPacket);
|
foundElement = findMatch(foundElement.left(), &testPacket);
|
||||||
if (foundElement == this->end()) {
|
if (foundElement == this->end()) {
|
||||||
return NO_MATCH;
|
return NO_MATCH;
|
||||||
}
|
}
|
||||||
if (subtype == 0) {
|
if (subtype == 0) {
|
||||||
if (foundElement.left() == end()) {
|
if (foundElement.left() == end()) {
|
||||||
return removeElementAndReconnectChildren(foundElement);
|
return removeElementAndReconnectChildren(foundElement);
|
||||||
} else {
|
} else {
|
||||||
return TOO_GENERAL_REQUEST;
|
return TOO_GENERAL_REQUEST;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//Again, go down AND branch.
|
//Again, go down AND branch.
|
||||||
foundElement = findMatch(foundElement.left(), &testPacket);
|
foundElement = findMatch(foundElement.left(), &testPacket);
|
||||||
if (foundElement == end()) {
|
if (foundElement == end()) {
|
||||||
return NO_MATCH;
|
return NO_MATCH;
|
||||||
}
|
}
|
||||||
return removeElementAndReconnectChildren(foundElement);
|
return removeElementAndReconnectChildren(foundElement);
|
||||||
}
|
}
|
||||||
|
|
||||||
PacketMatchTree::iterator PacketMatchTree::findMatch(iterator startAt,
|
PacketMatchTree::iterator PacketMatchTree::findMatch(iterator startAt,
|
||||||
TmPacketMinimal* test) {
|
TmPacketMinimal* test) {
|
||||||
iterator iter = startAt;
|
iterator iter = startAt;
|
||||||
while (iter != end()) {
|
while (iter != end()) {
|
||||||
bool isMatch = iter->match(test);
|
bool isMatch = iter->match(test);
|
||||||
if (isMatch) {
|
if (isMatch) {
|
||||||
break;
|
break;
|
||||||
} else {
|
} else {
|
||||||
iter = iter.right(); //next OR element
|
iter = iter.right(); //next OR element
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return iter;
|
return iter;
|
||||||
}
|
}
|
||||||
|
|
||||||
ReturnValue_t PacketMatchTree::initialize() {
|
ReturnValue_t PacketMatchTree::initialize() {
|
||||||
return factoryBackend.initialize();
|
return factoryBackend.initialize();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
ReturnValue_t PacketMatchTree::changeMatch(bool addToMatch, uint16_t apid,
|
ReturnValue_t PacketMatchTree::changeMatch(bool addToMatch, uint16_t apid,
|
||||||
uint8_t type, uint8_t subtype) {
|
uint8_t type, uint8_t subtype) {
|
||||||
if (addToMatch) {
|
if (addToMatch) {
|
||||||
return addMatch(apid, type, subtype);
|
return addMatch(apid, type, subtype);
|
||||||
} else {
|
} else {
|
||||||
return removeMatch(apid, type, subtype);
|
return removeMatch(apid, type, subtype);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ReturnValue_t PacketMatchTree::cleanUpElement(iterator position) {
|
ReturnValue_t PacketMatchTree::cleanUpElement(iterator position) {
|
||||||
factory.destroy(position.element->value);
|
factory.destroy(position.element->value);
|
||||||
//Go on anyway, there's nothing we can do.
|
//Go on anyway, there's nothing we can do.
|
||||||
//SHOULDDO: Throw event, or write debug message?
|
//SHOULDDO: Throw event, or write debug message?
|
||||||
return factory.destroy(position.element);
|
return factory.destroy(position.element);
|
||||||
}
|
}
|
||||||
|
@ -1,36 +1,36 @@
|
|||||||
#ifndef FRAMEWORK_TMTCPACKET_PACKETMATCHER_PACKETMATCHTREE_H_
|
#ifndef FSFW_TMTCPACKET_PACKETMATCHER_PACKETMATCHTREE_H_
|
||||||
#define FRAMEWORK_TMTCPACKET_PACKETMATCHER_PACKETMATCHTREE_H_
|
#define FSFW_TMTCPACKET_PACKETMATCHER_PACKETMATCHTREE_H_
|
||||||
|
|
||||||
#include "../../container/PlacementFactory.h"
|
#include "../../container/PlacementFactory.h"
|
||||||
#include "../../globalfunctions/matching/MatchTree.h"
|
#include "../../globalfunctions/matching/MatchTree.h"
|
||||||
#include "../../storagemanager/LocalPool.h"
|
#include "../../storagemanager/LocalPool.h"
|
||||||
#include "../../tmtcpacket/pus/TmPacketMinimal.h"
|
#include "../../tmtcpacket/pus/tm/TmPacketMinimal.h"
|
||||||
|
|
||||||
class PacketMatchTree: public MatchTree<TmPacketMinimal*>, public HasReturnvaluesIF {
|
class PacketMatchTree: public MatchTree<TmPacketMinimal*>, public HasReturnvaluesIF {
|
||||||
public:
|
public:
|
||||||
PacketMatchTree(Node* root);
|
PacketMatchTree(Node* root);
|
||||||
PacketMatchTree(iterator root);
|
PacketMatchTree(iterator root);
|
||||||
PacketMatchTree();
|
PacketMatchTree();
|
||||||
virtual ~PacketMatchTree();
|
virtual ~PacketMatchTree();
|
||||||
ReturnValue_t changeMatch(bool addToMatch, uint16_t apid, uint8_t type = 0,
|
ReturnValue_t changeMatch(bool addToMatch, uint16_t apid, uint8_t type = 0,
|
||||||
uint8_t subtype = 0);
|
uint8_t subtype = 0);
|
||||||
ReturnValue_t addMatch(uint16_t apid, uint8_t type = 0,
|
ReturnValue_t addMatch(uint16_t apid, uint8_t type = 0,
|
||||||
uint8_t subtype = 0);
|
uint8_t subtype = 0);
|
||||||
ReturnValue_t removeMatch(uint16_t apid, uint8_t type = 0,
|
ReturnValue_t removeMatch(uint16_t apid, uint8_t type = 0,
|
||||||
uint8_t subtype = 0);
|
uint8_t subtype = 0);
|
||||||
ReturnValue_t initialize();
|
ReturnValue_t initialize();
|
||||||
protected:
|
protected:
|
||||||
ReturnValue_t cleanUpElement(iterator position);
|
ReturnValue_t cleanUpElement(iterator position);
|
||||||
private:
|
private:
|
||||||
static const uint8_t N_POOLS = 4;
|
static const uint8_t N_POOLS = 4;
|
||||||
LocalPool factoryBackend;
|
LocalPool factoryBackend;
|
||||||
PlacementFactory factory;
|
PlacementFactory factory;
|
||||||
static const LocalPool::LocalPoolConfig poolConfig;
|
static const LocalPool::LocalPoolConfig poolConfig;
|
||||||
static const uint16_t POOL_SIZES[N_POOLS];
|
static const uint16_t POOL_SIZES[N_POOLS];
|
||||||
static const uint16_t N_ELEMENTS[N_POOLS];
|
static const uint16_t N_ELEMENTS[N_POOLS];
|
||||||
template<typename VALUE_T, typename INSERTION_T>
|
template<typename VALUE_T, typename INSERTION_T>
|
||||||
ReturnValue_t findOrInsertMatch(iterator startAt, VALUE_T test, iterator* lastTest);
|
ReturnValue_t findOrInsertMatch(iterator startAt, VALUE_T test, iterator* lastTest);
|
||||||
iterator findMatch(iterator startAt, TmPacketMinimal* test);
|
iterator findMatch(iterator startAt, TmPacketMinimal* test);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* FRAMEWORK_TMTCPACKET_PACKETMATCHER_PACKETMATCHTREE_H_ */
|
#endif /* FRAMEWORK_TMTCPACKET_PACKETMATCHER_PACKETMATCHTREE_H_ */
|
||||||
|
@ -3,36 +3,36 @@
|
|||||||
|
|
||||||
#include "../../globalfunctions/matching/SerializeableMatcherIF.h"
|
#include "../../globalfunctions/matching/SerializeableMatcherIF.h"
|
||||||
#include "../../serialize/SerializeAdapter.h"
|
#include "../../serialize/SerializeAdapter.h"
|
||||||
#include "../../tmtcpacket/pus/TmPacketMinimal.h"
|
#include "../pus/tm/TmPacketMinimal.h"
|
||||||
|
|
||||||
class ServiceMatcher: public SerializeableMatcherIF<TmPacketMinimal*> {
|
class ServiceMatcher: public SerializeableMatcherIF<TmPacketMinimal*> {
|
||||||
private:
|
private:
|
||||||
uint8_t service;
|
uint8_t service;
|
||||||
public:
|
public:
|
||||||
ServiceMatcher(uint8_t setService) :
|
ServiceMatcher(uint8_t setService) :
|
||||||
service(setService) {
|
service(setService) {
|
||||||
}
|
}
|
||||||
ServiceMatcher(TmPacketMinimal* test) :
|
ServiceMatcher(TmPacketMinimal* test) :
|
||||||
service(test->getService()) {
|
service(test->getService()) {
|
||||||
}
|
}
|
||||||
bool match(TmPacketMinimal* packet) {
|
bool match(TmPacketMinimal* packet) {
|
||||||
if (packet->getService() == service) {
|
if (packet->getService() == service) {
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ReturnValue_t serialize(uint8_t** buffer, size_t* size,
|
ReturnValue_t serialize(uint8_t** buffer, size_t* size,
|
||||||
size_t maxSize, Endianness streamEndianness) const {
|
size_t maxSize, Endianness streamEndianness) const {
|
||||||
return SerializeAdapter::serialize(&service, buffer, size, maxSize, streamEndianness);
|
return SerializeAdapter::serialize(&service, buffer, size, maxSize, streamEndianness);
|
||||||
}
|
}
|
||||||
size_t getSerializedSize() const {
|
size_t getSerializedSize() const {
|
||||||
return SerializeAdapter::getSerializedSize(&service);
|
return SerializeAdapter::getSerializedSize(&service);
|
||||||
}
|
}
|
||||||
ReturnValue_t deSerialize(const uint8_t** buffer, size_t* size,
|
ReturnValue_t deSerialize(const uint8_t** buffer, size_t* size,
|
||||||
Endianness streamEndianness) {
|
Endianness streamEndianness) {
|
||||||
return SerializeAdapter::deSerialize(&service, buffer, size, streamEndianness);
|
return SerializeAdapter::deSerialize(&service, buffer, size, streamEndianness);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,38 +1,38 @@
|
|||||||
#ifndef FRAMEWORK_TMTCPACKET_PACKETMATCHER_SUBSERVICEMATCHER_H_
|
#ifndef FSFW_TMTCPACKET_PACKETMATCHER_SUBSERVICEMATCHER_H_
|
||||||
#define FRAMEWORK_TMTCPACKET_PACKETMATCHER_SUBSERVICEMATCHER_H_
|
#define FSFW_TMTCPACKET_PACKETMATCHER_SUBSERVICEMATCHER_H_
|
||||||
|
|
||||||
#include "../../globalfunctions/matching/SerializeableMatcherIF.h"
|
#include "../../globalfunctions/matching/SerializeableMatcherIF.h"
|
||||||
#include "../../serialize/SerializeAdapter.h"
|
#include "../../serialize/SerializeAdapter.h"
|
||||||
#include "../../tmtcpacket/pus/TmPacketMinimal.h"
|
#include "../pus/tm/TmPacketMinimal.h"
|
||||||
|
|
||||||
class SubServiceMatcher: public SerializeableMatcherIF<TmPacketMinimal*> {
|
class SubServiceMatcher: public SerializeableMatcherIF<TmPacketMinimal*> {
|
||||||
public:
|
public:
|
||||||
SubServiceMatcher(uint8_t subService) :
|
SubServiceMatcher(uint8_t subService) :
|
||||||
subService(subService) {
|
subService(subService) {
|
||||||
}
|
}
|
||||||
SubServiceMatcher(TmPacketMinimal* test) :
|
SubServiceMatcher(TmPacketMinimal* test) :
|
||||||
subService(test->getSubService()) {
|
subService(test->getSubService()) {
|
||||||
}
|
}
|
||||||
bool match(TmPacketMinimal* packet) {
|
bool match(TmPacketMinimal* packet) {
|
||||||
if (packet->getSubService() == subService) {
|
if (packet->getSubService() == subService) {
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ReturnValue_t serialize(uint8_t** buffer, size_t* size,
|
ReturnValue_t serialize(uint8_t** buffer, size_t* size,
|
||||||
size_t maxSize, Endianness streamEndianness) const {
|
size_t maxSize, Endianness streamEndianness) const {
|
||||||
return SerializeAdapter::serialize(&subService, buffer, size, maxSize, streamEndianness);
|
return SerializeAdapter::serialize(&subService, buffer, size, maxSize, streamEndianness);
|
||||||
}
|
}
|
||||||
size_t getSerializedSize() const {
|
size_t getSerializedSize() const {
|
||||||
return SerializeAdapter::getSerializedSize(&subService);
|
return SerializeAdapter::getSerializedSize(&subService);
|
||||||
}
|
}
|
||||||
ReturnValue_t deSerialize(const uint8_t** buffer, size_t* size,
|
ReturnValue_t deSerialize(const uint8_t** buffer, size_t* size,
|
||||||
Endianness streamEndianness) {
|
Endianness streamEndianness) {
|
||||||
return SerializeAdapter::deSerialize(&subService, buffer, size, streamEndianness);
|
return SerializeAdapter::deSerialize(&subService, buffer, size, streamEndianness);
|
||||||
}
|
}
|
||||||
private:
|
private:
|
||||||
uint8_t subService;
|
uint8_t subService;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,12 +1,2 @@
|
|||||||
target_sources(${LIB_FSFW_NAME}
|
add_subdirectory(tm)
|
||||||
PRIVATE
|
add_subdirectory(tc)
|
||||||
TcPacketBase.cpp
|
|
||||||
TcPacketStored.cpp
|
|
||||||
TmPacketBase.cpp
|
|
||||||
TmPacketMinimal.cpp
|
|
||||||
TmPacketStoredPusA.cpp
|
|
||||||
TmPacketStoredPusC.cpp
|
|
||||||
TmPacketPusA.cpp
|
|
||||||
TmPacketPusC.cpp
|
|
||||||
TmPacketStoredBase.cpp
|
|
||||||
)
|
|
||||||
|
@ -1,88 +0,0 @@
|
|||||||
#include "TcPacketBase.h"
|
|
||||||
|
|
||||||
#include "../../globalfunctions/CRC.h"
|
|
||||||
#include "../../globalfunctions/arrayprinter.h"
|
|
||||||
#include "../../serviceinterface/ServiceInterfaceStream.h"
|
|
||||||
|
|
||||||
#include <cstring>
|
|
||||||
|
|
||||||
TcPacketBase::TcPacketBase(const uint8_t* setData) :
|
|
||||||
SpacePacketBase(setData) {
|
|
||||||
tcData = reinterpret_cast<TcPacketPointer*>(const_cast<uint8_t*>(setData));
|
|
||||||
}
|
|
||||||
|
|
||||||
TcPacketBase::~TcPacketBase() {
|
|
||||||
//Nothing to do.
|
|
||||||
}
|
|
||||||
|
|
||||||
uint8_t TcPacketBase::getService() {
|
|
||||||
return tcData->dataField.service_type;
|
|
||||||
}
|
|
||||||
|
|
||||||
uint8_t TcPacketBase::getSubService() {
|
|
||||||
return tcData->dataField.service_subtype;
|
|
||||||
}
|
|
||||||
|
|
||||||
uint8_t TcPacketBase::getAcknowledgeFlags() {
|
|
||||||
return tcData->dataField.version_type_ack & 0b00001111;
|
|
||||||
}
|
|
||||||
|
|
||||||
const uint8_t* TcPacketBase::getApplicationData() const {
|
|
||||||
return &tcData->appData;
|
|
||||||
}
|
|
||||||
|
|
||||||
uint16_t TcPacketBase::getApplicationDataSize() {
|
|
||||||
return getPacketDataLength() - sizeof(tcData->dataField) - CRC_SIZE + 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
uint16_t TcPacketBase::getErrorControl() {
|
|
||||||
uint16_t size = getApplicationDataSize() + CRC_SIZE;
|
|
||||||
uint8_t* p_to_buffer = &tcData->appData;
|
|
||||||
return (p_to_buffer[size - 2] << 8) + p_to_buffer[size - 1];
|
|
||||||
}
|
|
||||||
|
|
||||||
void TcPacketBase::setErrorControl() {
|
|
||||||
uint32_t full_size = getFullSize();
|
|
||||||
uint16_t crc = CRC::crc16ccitt(getWholeData(), full_size - CRC_SIZE);
|
|
||||||
uint32_t size = getApplicationDataSize();
|
|
||||||
(&tcData->appData)[size] = (crc & 0XFF00) >> 8; // CRCH
|
|
||||||
(&tcData->appData)[size + 1] = (crc) & 0X00FF; // CRCL
|
|
||||||
}
|
|
||||||
|
|
||||||
void TcPacketBase::setData(const uint8_t* pData) {
|
|
||||||
SpacePacketBase::setData(pData);
|
|
||||||
tcData = (TcPacketPointer*) pData;
|
|
||||||
}
|
|
||||||
|
|
||||||
uint8_t TcPacketBase::getSecondaryHeaderFlag() {
|
|
||||||
return (tcData->dataField.version_type_ack & 0b10000000) >> 7;
|
|
||||||
}
|
|
||||||
|
|
||||||
uint8_t TcPacketBase::getPusVersionNumber() {
|
|
||||||
return (tcData->dataField.version_type_ack & 0b01110000) >> 4;
|
|
||||||
}
|
|
||||||
|
|
||||||
void TcPacketBase::print() {
|
|
||||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
|
||||||
sif::debug << "TcPacketBase::print: " << std::endl;
|
|
||||||
#endif
|
|
||||||
arrayprinter::print(getWholeData(), getFullSize());
|
|
||||||
}
|
|
||||||
|
|
||||||
void TcPacketBase::initializeTcPacket(uint16_t apid, uint16_t sequenceCount,
|
|
||||||
uint8_t ack, uint8_t service, uint8_t subservice) {
|
|
||||||
initSpacePacketHeader(true, true, apid, sequenceCount);
|
|
||||||
std::memset(&tcData->dataField, 0, sizeof(tcData->dataField));
|
|
||||||
setPacketDataLength(sizeof(PUSTcDataFieldHeader) + CRC_SIZE - 1);
|
|
||||||
//Data Field Header:
|
|
||||||
//Set CCSDS_secondary_header_flag to 0 and version number to 001
|
|
||||||
tcData->dataField.version_type_ack = 0b00010000;
|
|
||||||
tcData->dataField.version_type_ack |= (ack & 0x0F);
|
|
||||||
tcData->dataField.service_type = service;
|
|
||||||
tcData->dataField.service_subtype = subservice;
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t TcPacketBase::calculateFullPacketLength(size_t appDataLen) {
|
|
||||||
return sizeof(CCSDSPrimaryHeader) + sizeof(PUSTcDataFieldHeader) +
|
|
||||||
appDataLen + TcPacketBase::CRC_SIZE;
|
|
||||||
}
|
|
@ -1,187 +0,0 @@
|
|||||||
#ifndef TMTCPACKET_PUS_TCPACKETBASE_H_
|
|
||||||
#define TMTCPACKET_PUS_TCPACKETBASE_H_
|
|
||||||
|
|
||||||
#include "../../tmtcpacket/SpacePacketBase.h"
|
|
||||||
#include <cstddef>
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This struct defines a byte-wise structured PUS TC Data Field Header.
|
|
||||||
* Any optional fields in the header must be added or removed here.
|
|
||||||
* Currently, the Source Id field is present with one byte.
|
|
||||||
* @ingroup tmtcpackets
|
|
||||||
*/
|
|
||||||
struct PUSTcDataFieldHeader {
|
|
||||||
uint8_t version_type_ack;
|
|
||||||
uint8_t service_type;
|
|
||||||
uint8_t service_subtype;
|
|
||||||
uint8_t source_id;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This struct defines the data structure of a PUS Telecommand Packet when
|
|
||||||
* accessed via a pointer.
|
|
||||||
* @ingroup tmtcpackets
|
|
||||||
*/
|
|
||||||
struct TcPacketPointer {
|
|
||||||
CCSDSPrimaryHeader primary;
|
|
||||||
PUSTcDataFieldHeader dataField;
|
|
||||||
uint8_t appData;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This class is the basic data handler for any ECSS PUS Telecommand packet.
|
|
||||||
*
|
|
||||||
* In addition to #SpacePacketBase, the class provides methods to handle
|
|
||||||
* the standardized entries of the PUS TC Packet Data Field Header.
|
|
||||||
* It does not contain the packet data itself but a pointer to the
|
|
||||||
* data must be set on instantiation. An invalid pointer may cause
|
|
||||||
* damage, as no getter method checks data validity. Anyway, a NULL
|
|
||||||
* check can be performed by making use of the getWholeData method.
|
|
||||||
* @ingroup tmtcpackets
|
|
||||||
*/
|
|
||||||
class TcPacketBase : public SpacePacketBase {
|
|
||||||
public:
|
|
||||||
static const uint16_t TC_PACKET_MIN_SIZE = (sizeof(CCSDSPrimaryHeader) +
|
|
||||||
sizeof(PUSTcDataFieldHeader) + 2);
|
|
||||||
|
|
||||||
enum AckField {
|
|
||||||
//! No acknowledgements are expected.
|
|
||||||
ACK_NONE = 0b0000,
|
|
||||||
//! Acknowledgements on acceptance are expected.
|
|
||||||
ACK_ACCEPTANCE = 0b0001,
|
|
||||||
//! Acknowledgements on start are expected.
|
|
||||||
ACK_START = 0b0010,
|
|
||||||
//! Acknowledgements on step are expected.
|
|
||||||
ACK_STEP = 0b0100,
|
|
||||||
//! Acknowledfgement on completion are expected.
|
|
||||||
ACK_COMPLETION = 0b1000
|
|
||||||
};
|
|
||||||
|
|
||||||
static constexpr uint8_t ACK_ALL = ACK_ACCEPTANCE | ACK_START | ACK_STEP |
|
|
||||||
ACK_COMPLETION;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 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 setData The position where the packet data lies.
|
|
||||||
*/
|
|
||||||
TcPacketBase( const uint8_t* setData );
|
|
||||||
/**
|
|
||||||
* This is the empty default destructor.
|
|
||||||
*/
|
|
||||||
virtual ~TcPacketBase();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This command returns the CCSDS Secondary Header Flag.
|
|
||||||
* It shall always be zero for PUS Packets. This is the
|
|
||||||
* highest bit of the first byte of the Data Field Header.
|
|
||||||
* @return the CCSDS Secondary Header Flag
|
|
||||||
*/
|
|
||||||
uint8_t getSecondaryHeaderFlag();
|
|
||||||
/**
|
|
||||||
* This command returns the TC Packet PUS Version Number.
|
|
||||||
* The version number of ECSS PUS 2003 is 1.
|
|
||||||
* It consists of the second to fourth highest bits of the
|
|
||||||
* first byte.
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
uint8_t getPusVersionNumber();
|
|
||||||
/**
|
|
||||||
* This is a getter for the packet's Ack field, which are the lowest four
|
|
||||||
* bits of the first byte of the Data Field Header.
|
|
||||||
*
|
|
||||||
* It is packed in a uint8_t variable.
|
|
||||||
* @return The packet's PUS Ack field.
|
|
||||||
*/
|
|
||||||
uint8_t getAcknowledgeFlags();
|
|
||||||
/**
|
|
||||||
* This is a getter for the packet's PUS Service ID, which is the second
|
|
||||||
* byte of the Data Field Header.
|
|
||||||
* @return The packet's PUS Service ID.
|
|
||||||
*/
|
|
||||||
uint8_t getService();
|
|
||||||
/**
|
|
||||||
* This is a getter for the packet's PUS Service Subtype, which is the
|
|
||||||
* third byte of the Data Field Header.
|
|
||||||
* @return The packet's PUS Service Subtype.
|
|
||||||
*/
|
|
||||||
uint8_t getSubService();
|
|
||||||
/**
|
|
||||||
* This is a getter for a pointer to the packet's Application data.
|
|
||||||
*
|
|
||||||
* These are the bytes that follow after the Data Field Header. They form
|
|
||||||
* the packet's application data.
|
|
||||||
* @return A pointer to the PUS Application Data.
|
|
||||||
*/
|
|
||||||
const uint8_t* getApplicationData() const;
|
|
||||||
/**
|
|
||||||
* This method calculates the size of the PUS Application 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 Application Data (without Error Control
|
|
||||||
* field)
|
|
||||||
*/
|
|
||||||
uint16_t getApplicationDataSize();
|
|
||||||
/**
|
|
||||||
* This getter returns the Error Control Field of the packet.
|
|
||||||
*
|
|
||||||
* The field is placed after any possible Application Data. If no
|
|
||||||
* Application Data is present there's still an Error Control field. It is
|
|
||||||
* supposed to be a 16bit-CRC.
|
|
||||||
* @return The PUS Error Control
|
|
||||||
*/
|
|
||||||
uint16_t getErrorControl();
|
|
||||||
/**
|
|
||||||
* With this method, the Error Control Field is updated to match the
|
|
||||||
* current content of the packet.
|
|
||||||
*/
|
|
||||||
void setErrorControl();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This is a debugging helper method that prints the whole packet content
|
|
||||||
* to the screen.
|
|
||||||
*/
|
|
||||||
void print();
|
|
||||||
/**
|
|
||||||
* Calculate full packet length from application data length.
|
|
||||||
* @param appDataLen
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
static size_t calculateFullPacketLength(size_t appDataLen);
|
|
||||||
|
|
||||||
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.
|
|
||||||
*/
|
|
||||||
TcPacketPointer* tcData;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Initializes the Tc Packet header.
|
|
||||||
* @param apid APID used.
|
|
||||||
* @param sequenceCount Sequence Count in the primary header.
|
|
||||||
* @param ack Which acknowledeges are expected from the receiver.
|
|
||||||
* @param service PUS Service
|
|
||||||
* @param subservice PUS Subservice
|
|
||||||
*/
|
|
||||||
void initializeTcPacket(uint16_t apid, uint16_t sequenceCount, uint8_t ack,
|
|
||||||
uint8_t service, uint8_t subservice);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 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 Telecommand Packet.
|
|
||||||
*/
|
|
||||||
void setData( const uint8_t* pData );
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
#endif /* TMTCPACKET_PUS_TCPACKETBASE_H_ */
|
|
@ -1,124 +0,0 @@
|
|||||||
#include "TcPacketStored.h"
|
|
||||||
|
|
||||||
#include "../../objectmanager/ObjectManager.h"
|
|
||||||
#include "../../serviceinterface/ServiceInterface.h"
|
|
||||||
|
|
||||||
#include <cstring>
|
|
||||||
|
|
||||||
StorageManagerIF* TcPacketStored::store = nullptr;
|
|
||||||
|
|
||||||
TcPacketStored::TcPacketStored(store_address_t setAddress) :
|
|
||||||
TcPacketBase(nullptr), storeAddress(setAddress) {
|
|
||||||
setStoreAddress(storeAddress);
|
|
||||||
}
|
|
||||||
|
|
||||||
TcPacketStored::TcPacketStored(uint16_t apid, uint8_t service,
|
|
||||||
uint8_t subservice, uint8_t sequenceCount, const uint8_t* data,
|
|
||||||
size_t size, uint8_t ack) :
|
|
||||||
TcPacketBase(nullptr) {
|
|
||||||
this->storeAddress.raw = StorageManagerIF::INVALID_ADDRESS;
|
|
||||||
if (not this->checkAndSetStore()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
uint8_t* pData = nullptr;
|
|
||||||
ReturnValue_t returnValue = this->store->getFreeElement(&this->storeAddress,
|
|
||||||
(TC_PACKET_MIN_SIZE + size), &pData);
|
|
||||||
if (returnValue != this->store->RETURN_OK) {
|
|
||||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
|
||||||
sif::warning << "TcPacketStored: Could not get free element from store!"
|
|
||||||
<< std::endl;
|
|
||||||
#endif
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
this->setData(pData);
|
|
||||||
initializeTcPacket(apid, sequenceCount, ack, service, subservice);
|
|
||||||
memcpy(&tcData->appData, data, size);
|
|
||||||
this->setPacketDataLength(
|
|
||||||
size + sizeof(PUSTcDataFieldHeader) + CRC_SIZE - 1);
|
|
||||||
this->setErrorControl();
|
|
||||||
}
|
|
||||||
|
|
||||||
ReturnValue_t TcPacketStored::getData(const uint8_t ** dataPtr,
|
|
||||||
size_t* dataSize) {
|
|
||||||
auto result = this->store->getData(storeAddress, dataPtr, dataSize);
|
|
||||||
if(result != HasReturnvaluesIF::RETURN_OK) {
|
|
||||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
|
||||||
sif::warning << "TcPacketStored: Could not get data!" << std::endl;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
TcPacketStored::TcPacketStored(): TcPacketBase(nullptr) {
|
|
||||||
this->storeAddress.raw = StorageManagerIF::INVALID_ADDRESS;
|
|
||||||
this->checkAndSetStore();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
ReturnValue_t TcPacketStored::deletePacket() {
|
|
||||||
ReturnValue_t result = this->store->deleteData(this->storeAddress);
|
|
||||||
this->storeAddress.raw = StorageManagerIF::INVALID_ADDRESS;
|
|
||||||
this->setData(nullptr);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool TcPacketStored::checkAndSetStore() {
|
|
||||||
if (this->store == nullptr) {
|
|
||||||
this->store = ObjectManager::instance()->get<StorageManagerIF>(objects::TC_STORE);
|
|
||||||
if (this->store == nullptr) {
|
|
||||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
|
||||||
sif::error << "TcPacketStored::TcPacketStored: TC Store not found!"
|
|
||||||
<< std::endl;
|
|
||||||
#endif
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
void TcPacketStored::setStoreAddress(store_address_t setAddress) {
|
|
||||||
this->storeAddress = setAddress;
|
|
||||||
const uint8_t* tempData = nullptr;
|
|
||||||
size_t temp_size;
|
|
||||||
ReturnValue_t status = StorageManagerIF::RETURN_FAILED;
|
|
||||||
if (this->checkAndSetStore()) {
|
|
||||||
status = this->store->getData(this->storeAddress, &tempData,
|
|
||||||
&temp_size);
|
|
||||||
}
|
|
||||||
if (status == StorageManagerIF::RETURN_OK) {
|
|
||||||
this->setData(tempData);
|
|
||||||
} else {
|
|
||||||
this->setData(nullptr);
|
|
||||||
this->storeAddress.raw = StorageManagerIF::INVALID_ADDRESS;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
store_address_t TcPacketStored::getStoreAddress() {
|
|
||||||
return this->storeAddress;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool TcPacketStored::isSizeCorrect() {
|
|
||||||
const uint8_t* temp_data = nullptr;
|
|
||||||
size_t temp_size;
|
|
||||||
ReturnValue_t status = this->store->getData(this->storeAddress, &temp_data,
|
|
||||||
&temp_size);
|
|
||||||
if (status == StorageManagerIF::RETURN_OK) {
|
|
||||||
if (this->getFullSize() == temp_size) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
TcPacketStored::TcPacketStored(const uint8_t* data, uint32_t size) :
|
|
||||||
TcPacketBase(data) {
|
|
||||||
if (getFullSize() != size) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (this->checkAndSetStore()) {
|
|
||||||
ReturnValue_t status = store->addData(&storeAddress, data, size);
|
|
||||||
if (status != HasReturnvaluesIF::RETURN_OK) {
|
|
||||||
this->setData(nullptr);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,117 +0,0 @@
|
|||||||
#ifndef TMTCPACKET_PUS_TCPACKETSTORED_H_
|
|
||||||
#define TMTCPACKET_PUS_TCPACKETSTORED_H_
|
|
||||||
|
|
||||||
#include "TcPacketBase.h"
|
|
||||||
#include "../../storagemanager/StorageManagerIF.h"
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This class generates a ECSS PUS Telecommand 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 TcPacketStored : public TcPacketBase {
|
|
||||||
public:
|
|
||||||
/**
|
|
||||||
* This is a default constructor which does not set the data pointer.
|
|
||||||
* However, it does try to set the packet store.
|
|
||||||
*/
|
|
||||||
TcPacketStored();
|
|
||||||
/**
|
|
||||||
* With this constructor, the class instance is linked to an existing
|
|
||||||
* packet in the packet store.
|
|
||||||
* The packet content is neither checked nor changed with this call. If
|
|
||||||
* the packet could not be found, the data pointer is set to NULL.
|
|
||||||
*/
|
|
||||||
TcPacketStored( store_address_t setAddress );
|
|
||||||
/**
|
|
||||||
* With this constructor, new space is allocated in the packet store and
|
|
||||||
* a new PUS Telecommand Packet is created there.
|
|
||||||
* Packet Application Data passed in data is copied into the packet.
|
|
||||||
* @param apid Sets the packet's APID field.
|
|
||||||
* @param service Sets the packet's Service ID field.
|
|
||||||
* This specifies the destination service.
|
|
||||||
* @param subservice Sets the packet's Service Subtype field.
|
|
||||||
* This specifies the destination sub-service.
|
|
||||||
* @param sequence_count Sets the packet's Source Sequence Count field.
|
|
||||||
* @param data The data to be copied to the Application Data Field.
|
|
||||||
* @param size The amount of data to be copied.
|
|
||||||
* @param ack Set's the packet's Ack field, which specifies
|
|
||||||
* number of verification packets returned
|
|
||||||
* for this command.
|
|
||||||
*/
|
|
||||||
TcPacketStored(uint16_t apid, uint8_t service, uint8_t subservice,
|
|
||||||
uint8_t sequence_count = 0, const uint8_t* data = nullptr,
|
|
||||||
size_t size = 0, uint8_t ack = TcPacketBase::ACK_ALL);
|
|
||||||
/**
|
|
||||||
* Another constructor to create a TcPacket from a raw packet stream.
|
|
||||||
* Takes the data and adds it unchecked to the TcStore.
|
|
||||||
* @param data Pointer to the complete TC Space Packet.
|
|
||||||
* @param Size size of the packet.
|
|
||||||
*/
|
|
||||||
TcPacketStored( const uint8_t* data, uint32_t size);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Getter function for the raw data.
|
|
||||||
* @param dataPtr [out] Pointer to the data pointer to set
|
|
||||||
* @param dataSize [out] Address of size to set.
|
|
||||||
* @return -@c RETURN_OK if data was retrieved successfully.
|
|
||||||
*/
|
|
||||||
ReturnValue_t getData(const uint8_t ** dataPtr,
|
|
||||||
size_t* dataSize);
|
|
||||||
/**
|
|
||||||
* 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.
|
|
||||||
* @return returncode from deleting the data.
|
|
||||||
*/
|
|
||||||
ReturnValue_t 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 );
|
|
||||||
/**
|
|
||||||
* This method performs a size check.
|
|
||||||
* It reads the stored size and compares it with the size entered in the
|
|
||||||
* packet header. This class is the optimal place for such a check as it
|
|
||||||
* has access to both the header data and the store.
|
|
||||||
* @return true if size is correct, false if packet is not registered in
|
|
||||||
* store or size is incorrect.
|
|
||||||
*/
|
|
||||||
bool isSizeCorrect();
|
|
||||||
|
|
||||||
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::TC_STORE.
|
|
||||||
*/
|
|
||||||
static StorageManagerIF* store;
|
|
||||||
/**
|
|
||||||
* 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();
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
#endif /* TMTCPACKET_PUS_TCPACKETSTORED_H_ */
|
|
7
tmtcpacket/pus/tc.h
Normal file
7
tmtcpacket/pus/tc.h
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
#ifndef FSFW_TMTCPACKET_PUS_TC_H_
|
||||||
|
#define FSFW_TMTCPACKET_PUS_TC_H_
|
||||||
|
|
||||||
|
#include "tc/TcPacketStoredPus.h"
|
||||||
|
#include "tc/TcPacketPus.h"
|
||||||
|
|
||||||
|
#endif /* FSFW_TMTCPACKET_PUS_TC_H_ */
|
6
tmtcpacket/pus/tc/CMakeLists.txt
Normal file
6
tmtcpacket/pus/tc/CMakeLists.txt
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
target_sources(${LIB_FSFW_NAME} PRIVATE
|
||||||
|
TcPacketBase.cpp
|
||||||
|
TcPacketPus.cpp
|
||||||
|
TcPacketStoredBase.cpp
|
||||||
|
TcPacketStoredPus.cpp
|
||||||
|
)
|
20
tmtcpacket/pus/tc/TcPacketBase.cpp
Normal file
20
tmtcpacket/pus/tc/TcPacketBase.cpp
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
#include "TcPacketBase.h"
|
||||||
|
|
||||||
|
#include "../../../globalfunctions/CRC.h"
|
||||||
|
#include "../../../globalfunctions/arrayprinter.h"
|
||||||
|
#include "../../../serviceinterface/ServiceInterface.h"
|
||||||
|
|
||||||
|
#include <cstring>
|
||||||
|
|
||||||
|
TcPacketBase::TcPacketBase(const uint8_t* setData): SpacePacketBase(setData) {}
|
||||||
|
|
||||||
|
TcPacketBase::~TcPacketBase() {}
|
||||||
|
|
||||||
|
void TcPacketBase::print() {
|
||||||
|
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||||
|
sif::info << "TcPacketBase::print:" << std::endl;
|
||||||
|
#else
|
||||||
|
sif::printInfo("TcPacketBase::print:\n");
|
||||||
|
#endif
|
||||||
|
arrayprinter::print(getWholeData(), getFullSize());
|
||||||
|
}
|
150
tmtcpacket/pus/tc/TcPacketBase.h
Normal file
150
tmtcpacket/pus/tc/TcPacketBase.h
Normal file
@ -0,0 +1,150 @@
|
|||||||
|
#ifndef TMTCPACKET_PUS_TCPACKETBASE_H_
|
||||||
|
#define TMTCPACKET_PUS_TCPACKETBASE_H_
|
||||||
|
|
||||||
|
#include "../../../tmtcpacket/SpacePacketBase.h"
|
||||||
|
#include <cstddef>
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This class is the basic data handler for any ECSS PUS Telecommand packet.
|
||||||
|
*
|
||||||
|
* In addition to #SpacePacketBase, the class provides methods to handle
|
||||||
|
* the standardized entries of the PUS TC Packet Data Field Header.
|
||||||
|
* It does not contain the packet data itself but a pointer to the
|
||||||
|
* data must be set on instantiation. An invalid pointer may cause
|
||||||
|
* damage, as no getter method checks data validity. Anyway, a NULL
|
||||||
|
* check can be performed by making use of the getWholeData method.
|
||||||
|
* @ingroup tmtcpackets
|
||||||
|
*/
|
||||||
|
class TcPacketBase : public SpacePacketBase {
|
||||||
|
friend class TcPacketStoredBase;
|
||||||
|
public:
|
||||||
|
|
||||||
|
enum AckField {
|
||||||
|
//! No acknowledgements are expected.
|
||||||
|
ACK_NONE = 0b0000,
|
||||||
|
//! Acknowledgements on acceptance are expected.
|
||||||
|
ACK_ACCEPTANCE = 0b0001,
|
||||||
|
//! Acknowledgements on start are expected.
|
||||||
|
ACK_START = 0b0010,
|
||||||
|
//! Acknowledgements on step are expected.
|
||||||
|
ACK_STEP = 0b0100,
|
||||||
|
//! Acknowledfgement on completion are expected.
|
||||||
|
ACK_COMPLETION = 0b1000
|
||||||
|
};
|
||||||
|
|
||||||
|
static constexpr uint8_t ACK_ALL = ACK_ACCEPTANCE | ACK_START | ACK_STEP |
|
||||||
|
ACK_COMPLETION;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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 setData The position where the packet data lies.
|
||||||
|
*/
|
||||||
|
TcPacketBase( const uint8_t* setData );
|
||||||
|
/**
|
||||||
|
* This is the empty default destructor.
|
||||||
|
*/
|
||||||
|
virtual ~TcPacketBase();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This command returns the CCSDS Secondary Header Flag.
|
||||||
|
* It shall always be zero for PUS Packets. This is the
|
||||||
|
* highest bit of the first byte of the Data Field Header.
|
||||||
|
* @return the CCSDS Secondary Header Flag
|
||||||
|
*/
|
||||||
|
virtual uint8_t getSecondaryHeaderFlag() const = 0;
|
||||||
|
/**
|
||||||
|
* This command returns the TC Packet PUS Version Number.
|
||||||
|
* The version number of ECSS PUS 2003 is 1.
|
||||||
|
* It consists of the second to fourth highest bits of the
|
||||||
|
* first byte.
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
virtual uint8_t getPusVersionNumber() const = 0;
|
||||||
|
/**
|
||||||
|
* This is a getter for the packet's Ack field, which are the lowest four
|
||||||
|
* bits of the first byte of the Data Field Header.
|
||||||
|
*
|
||||||
|
* It is packed in a uint8_t variable.
|
||||||
|
* @return The packet's PUS Ack field.
|
||||||
|
*/
|
||||||
|
virtual uint8_t getAcknowledgeFlags() const = 0;
|
||||||
|
/**
|
||||||
|
* 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() const = 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() const = 0;
|
||||||
|
/**
|
||||||
|
* The source ID can be used to have an additional identifier, e.g. for different ground
|
||||||
|
* station.
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
virtual uint16_t getSourceId() const = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This is a getter for a pointer to the packet's Application data.
|
||||||
|
*
|
||||||
|
* These are the bytes that follow after the Data Field Header. They form
|
||||||
|
* the packet's application data.
|
||||||
|
* @return A pointer to the PUS Application Data.
|
||||||
|
*/
|
||||||
|
virtual const uint8_t* getApplicationData() const = 0;
|
||||||
|
/**
|
||||||
|
* This method calculates the size of the PUS Application 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 Application Data (without Error Control
|
||||||
|
* field)
|
||||||
|
*/
|
||||||
|
virtual uint16_t getApplicationDataSize() const = 0;
|
||||||
|
/**
|
||||||
|
* This getter returns the Error Control Field of the packet.
|
||||||
|
*
|
||||||
|
* The field is placed after any possible Application Data. If no
|
||||||
|
* Application Data is present there's still an Error Control field. It is
|
||||||
|
* supposed to be a 16bit-CRC.
|
||||||
|
* @return The PUS Error Control
|
||||||
|
*/
|
||||||
|
virtual uint16_t getErrorControl() const = 0;
|
||||||
|
/**
|
||||||
|
* With this method, the Error Control Field is updated to match the
|
||||||
|
* current content of the packet.
|
||||||
|
*/
|
||||||
|
virtual void setErrorControl() = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Calculate full packet length from application data length.
|
||||||
|
* @param appDataLen
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
virtual size_t calculateFullPacketLength(size_t appDataLen) const = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This is a debugging helper method that prints the whole packet content
|
||||||
|
* to the screen.
|
||||||
|
*/
|
||||||
|
void print();
|
||||||
|
protected:
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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 Telecommand Packet.
|
||||||
|
*/
|
||||||
|
void setData( const uint8_t* pData ) = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
#endif /* TMTCPACKET_PUS_TCPACKETBASE_H_ */
|
92
tmtcpacket/pus/tc/TcPacketPus.cpp
Normal file
92
tmtcpacket/pus/tc/TcPacketPus.cpp
Normal file
@ -0,0 +1,92 @@
|
|||||||
|
#include "TcPacketPus.h"
|
||||||
|
#include "../../../globalfunctions/CRC.h"
|
||||||
|
|
||||||
|
#include <cstring>
|
||||||
|
|
||||||
|
TcPacketPus::TcPacketPus(const uint8_t *setData): TcPacketBase(setData) {
|
||||||
|
tcData = reinterpret_cast<TcPacketPointer*>(const_cast<uint8_t*>(setData));
|
||||||
|
}
|
||||||
|
|
||||||
|
void TcPacketPus::initializeTcPacket(uint16_t apid, uint16_t sequenceCount,
|
||||||
|
uint8_t ack, uint8_t service, uint8_t subservice) {
|
||||||
|
initSpacePacketHeader(true, true, apid, sequenceCount);
|
||||||
|
std::memset(&tcData->dataField, 0, sizeof(tcData->dataField));
|
||||||
|
setPacketDataLength(sizeof(PUSTcDataFieldHeader) + CRC_SIZE - 1);
|
||||||
|
// Data Field Header:
|
||||||
|
// Set CCSDS_secondary_header_flag to 0 and version number to 001
|
||||||
|
tcData->dataField.versionTypeAck = 0b00010000;
|
||||||
|
tcData->dataField.versionTypeAck |= (ack & 0x0F);
|
||||||
|
tcData->dataField.serviceType = service;
|
||||||
|
tcData->dataField.serviceSubtype = subservice;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t TcPacketPus::getService() const {
|
||||||
|
return tcData->dataField.serviceType;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t TcPacketPus::getSubService() const {
|
||||||
|
return tcData->dataField.serviceSubtype;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t TcPacketPus::getAcknowledgeFlags() const {
|
||||||
|
return tcData->dataField.versionTypeAck & 0b00001111;
|
||||||
|
}
|
||||||
|
|
||||||
|
const uint8_t* TcPacketPus::getApplicationData() const {
|
||||||
|
return &tcData->appData;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint16_t TcPacketPus::getApplicationDataSize() const {
|
||||||
|
return getPacketDataLength() - sizeof(tcData->dataField) - CRC_SIZE + 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint16_t TcPacketPus::getErrorControl() const {
|
||||||
|
uint16_t size = getApplicationDataSize() + CRC_SIZE;
|
||||||
|
uint8_t* p_to_buffer = &tcData->appData;
|
||||||
|
return (p_to_buffer[size - 2] << 8) + p_to_buffer[size - 1];
|
||||||
|
}
|
||||||
|
|
||||||
|
void TcPacketPus::setErrorControl() {
|
||||||
|
uint32_t full_size = getFullSize();
|
||||||
|
uint16_t crc = CRC::crc16ccitt(getWholeData(), full_size - CRC_SIZE);
|
||||||
|
uint32_t size = getApplicationDataSize();
|
||||||
|
(&tcData->appData)[size] = (crc & 0XFF00) >> 8; // CRCH
|
||||||
|
(&tcData->appData)[size + 1] = (crc) & 0X00FF; // CRCL
|
||||||
|
}
|
||||||
|
|
||||||
|
void TcPacketPus::setData(const uint8_t* pData) {
|
||||||
|
SpacePacketBase::setData(pData);
|
||||||
|
// This function is const-correct, but it was decided to keep the pointer non-const
|
||||||
|
// for convenience. Therefore, cast aways constness here and then cast to packet type.
|
||||||
|
tcData = reinterpret_cast<TcPacketPointer*>(const_cast<uint8_t*>(pData));
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t TcPacketPus::getSecondaryHeaderFlag() const {
|
||||||
|
#if FSFW_USE_PUS_C_TELECOMMANDS == 1
|
||||||
|
// Does not exist for PUS C
|
||||||
|
return 0;
|
||||||
|
#else
|
||||||
|
return (tcData->dataField.versionTypeAck & 0b10000000) >> 7;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t TcPacketPus::getPusVersionNumber() const {
|
||||||
|
#if FSFW_USE_PUS_C_TELECOMMANDS == 1
|
||||||
|
return (tcData->dataField.versionTypeAck & 0b11110000) >> 4;
|
||||||
|
#else
|
||||||
|
return (tcData->dataField.versionTypeAck & 0b01110000) >> 4;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
uint16_t TcPacketPus::getSourceId() const {
|
||||||
|
#if FSFW_USE_PUS_C_TELECOMMANDS == 1
|
||||||
|
return (tcData->dataField.sourceIdH << 8) | tcData->dataField.sourceIdL;
|
||||||
|
#else
|
||||||
|
return tcData->dataField.sourceId;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t TcPacketPus::calculateFullPacketLength(size_t appDataLen) const {
|
||||||
|
return sizeof(CCSDSPrimaryHeader) + sizeof(PUSTcDataFieldHeader) +
|
||||||
|
appDataLen + TcPacketBase::CRC_SIZE;
|
||||||
|
}
|
90
tmtcpacket/pus/tc/TcPacketPus.h
Normal file
90
tmtcpacket/pus/tc/TcPacketPus.h
Normal file
@ -0,0 +1,90 @@
|
|||||||
|
#ifndef FSFW_TMTCPACKET_PUS_TCPACKETPUSA_H_
|
||||||
|
#define FSFW_TMTCPACKET_PUS_TCPACKETPUSA_H_
|
||||||
|
|
||||||
|
#include "../../../FSFW.h"
|
||||||
|
#include "../../ccsds_header.h"
|
||||||
|
#include "TcPacketBase.h"
|
||||||
|
|
||||||
|
#include <cstdint>
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This struct defines a byte-wise structured PUS TC A Data Field Header.
|
||||||
|
* Any optional fields in the header must be added or removed here.
|
||||||
|
* Currently, the Source Id field is present with one byte.
|
||||||
|
* @ingroup tmtcpackets
|
||||||
|
*/
|
||||||
|
struct PUSTcDataFieldHeader {
|
||||||
|
uint8_t versionTypeAck;
|
||||||
|
uint8_t serviceType;
|
||||||
|
uint8_t serviceSubtype;
|
||||||
|
#if FSFW_USE_PUS_C_TELECOMMANDS == 1
|
||||||
|
uint8_t sourceIdH;
|
||||||
|
uint8_t sourceIdL;
|
||||||
|
#else
|
||||||
|
uint8_t sourceId;
|
||||||
|
#endif
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This struct defines the data structure of a PUS Telecommand A packet when
|
||||||
|
* accessed via a pointer.
|
||||||
|
* @ingroup tmtcpackets
|
||||||
|
*/
|
||||||
|
struct TcPacketPointer {
|
||||||
|
CCSDSPrimaryHeader primary;
|
||||||
|
PUSTcDataFieldHeader dataField;
|
||||||
|
uint8_t appData;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
class TcPacketPus: public TcPacketBase {
|
||||||
|
public:
|
||||||
|
static const uint16_t TC_PACKET_MIN_SIZE = (sizeof(CCSDSPrimaryHeader) +
|
||||||
|
sizeof(PUSTcDataFieldHeader) + 2);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initialize a PUS A telecommand packet which already exists. You can also
|
||||||
|
* create an empty (invalid) object by passing nullptr as the data pointer
|
||||||
|
* @param setData
|
||||||
|
*/
|
||||||
|
TcPacketPus(const uint8_t* setData);
|
||||||
|
|
||||||
|
// Base class overrides
|
||||||
|
uint8_t getSecondaryHeaderFlag() const override;
|
||||||
|
uint8_t getPusVersionNumber() const override;
|
||||||
|
uint8_t getAcknowledgeFlags() const override;
|
||||||
|
uint8_t getService() const override;
|
||||||
|
uint8_t getSubService() const override;
|
||||||
|
uint16_t getSourceId() const override;
|
||||||
|
const uint8_t* getApplicationData() const override;
|
||||||
|
uint16_t getApplicationDataSize() const override;
|
||||||
|
uint16_t getErrorControl() const override;
|
||||||
|
void setErrorControl() override;
|
||||||
|
size_t calculateFullPacketLength(size_t appDataLen) const override;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
|
||||||
|
void setData(const uint8_t* pData) override;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initializes the Tc Packet header.
|
||||||
|
* @param apid APID used.
|
||||||
|
* @param sequenceCount Sequence Count in the primary header.
|
||||||
|
* @param ack Which acknowledeges are expected from the receiver.
|
||||||
|
* @param service PUS Service
|
||||||
|
* @param subservice PUS Subservice
|
||||||
|
*/
|
||||||
|
void initializeTcPacket(uint16_t apid, uint16_t sequenceCount, uint8_t ack,
|
||||||
|
uint8_t service, uint8_t subservice);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
TcPacketPointer* tcData = nullptr;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
#endif /* FSFW_TMTCPACKET_PUS_TCPACKETPUSA_H_ */
|
72
tmtcpacket/pus/tc/TcPacketStoredBase.cpp
Normal file
72
tmtcpacket/pus/tc/TcPacketStoredBase.cpp
Normal file
@ -0,0 +1,72 @@
|
|||||||
|
#include "TcPacketStoredBase.h"
|
||||||
|
|
||||||
|
#include "../../../objectmanager/ObjectManager.h"
|
||||||
|
#include "../../../serviceinterface/ServiceInterface.h"
|
||||||
|
#include "../../../objectmanager/frameworkObjects.h"
|
||||||
|
|
||||||
|
#include <cstring>
|
||||||
|
|
||||||
|
StorageManagerIF* TcPacketStoredBase::store = nullptr;
|
||||||
|
|
||||||
|
TcPacketStoredBase::TcPacketStoredBase() {
|
||||||
|
this->storeAddress.raw = StorageManagerIF::INVALID_ADDRESS;
|
||||||
|
this->checkAndSetStore();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
TcPacketStoredBase::~TcPacketStoredBase() {
|
||||||
|
}
|
||||||
|
|
||||||
|
ReturnValue_t TcPacketStoredBase::getData(const uint8_t ** dataPtr,
|
||||||
|
size_t* dataSize) {
|
||||||
|
auto result = this->store->getData(storeAddress, dataPtr, dataSize);
|
||||||
|
if(result != HasReturnvaluesIF::RETURN_OK) {
|
||||||
|
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||||
|
sif::warning << "TcPacketStoredBase: Could not get data!" << std::endl;
|
||||||
|
#else
|
||||||
|
sif::printWarning("TcPacketStoredBase: Could not get data!\n");
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
bool TcPacketStoredBase::checkAndSetStore() {
|
||||||
|
if (this->store == nullptr) {
|
||||||
|
this->store = ObjectManager::instance()->get<StorageManagerIF>(objects::TC_STORE);
|
||||||
|
if (this->store == nullptr) {
|
||||||
|
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||||
|
sif::error << "TcPacketStoredBase::TcPacketStoredBase: TC Store not found!"
|
||||||
|
<< std::endl;
|
||||||
|
#endif
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void TcPacketStoredBase::setStoreAddress(store_address_t setAddress) {
|
||||||
|
this->storeAddress = setAddress;
|
||||||
|
const uint8_t* tempData = nullptr;
|
||||||
|
size_t tempSize;
|
||||||
|
ReturnValue_t status = StorageManagerIF::RETURN_FAILED;
|
||||||
|
if (this->checkAndSetStore()) {
|
||||||
|
status = this->store->getData(this->storeAddress, &tempData, &tempSize);
|
||||||
|
}
|
||||||
|
TcPacketBase* tcPacketBase = this->getPacketBase();
|
||||||
|
if(tcPacketBase == nullptr) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (status == StorageManagerIF::RETURN_OK) {
|
||||||
|
tcPacketBase->setData(tempData);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
tcPacketBase->setData(nullptr);
|
||||||
|
this->storeAddress.raw = StorageManagerIF::INVALID_ADDRESS;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
store_address_t TcPacketStoredBase::getStoreAddress() {
|
||||||
|
return this->storeAddress;
|
||||||
|
}
|
90
tmtcpacket/pus/tc/TcPacketStoredBase.h
Normal file
90
tmtcpacket/pus/tc/TcPacketStoredBase.h
Normal file
@ -0,0 +1,90 @@
|
|||||||
|
#ifndef TMTCPACKET_PUS_TCPACKETSTORED_H_
|
||||||
|
#define TMTCPACKET_PUS_TCPACKETSTORED_H_
|
||||||
|
|
||||||
|
#include "TcPacketStoredIF.h"
|
||||||
|
#include "../../../storagemanager/StorageManagerIF.h"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This class generates a ECSS PUS Telecommand 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 TcPacketStoredBase: public TcPacketStoredIF {
|
||||||
|
public:
|
||||||
|
/**
|
||||||
|
* This is a default constructor which does not set the data pointer to initialize
|
||||||
|
* with an empty cached store address
|
||||||
|
*/
|
||||||
|
TcPacketStoredBase();
|
||||||
|
/**
|
||||||
|
* Constructor to set to an existing store address.
|
||||||
|
* @param setAddress
|
||||||
|
*/
|
||||||
|
TcPacketStoredBase(store_address_t setAddress);
|
||||||
|
/**
|
||||||
|
* Another constructor to create a TcPacket from a raw packet stream.
|
||||||
|
* Takes the data and adds it unchecked to the TcStore.
|
||||||
|
* @param data Pointer to the complete TC Space Packet.
|
||||||
|
* @param Size size of the packet.
|
||||||
|
*/
|
||||||
|
TcPacketStoredBase(const uint8_t* data, uint32_t size);
|
||||||
|
|
||||||
|
virtual~ TcPacketStoredBase();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Getter function for the raw data.
|
||||||
|
* @param dataPtr [out] Pointer to the data pointer to set
|
||||||
|
* @param dataSize [out] Address of size to set.
|
||||||
|
* @return -@c RETURN_OK if data was retrieved successfully.
|
||||||
|
*/
|
||||||
|
ReturnValue_t getData(const uint8_t ** dataPtr, size_t* dataSize) override;
|
||||||
|
|
||||||
|
void setStoreAddress(store_address_t setAddress) override;
|
||||||
|
store_address_t getStoreAddress() override;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* With this call, the packet is deleted.
|
||||||
|
* It removes itself from the store and sets its data pointer to NULL.
|
||||||
|
* @return returncode from deleting the data.
|
||||||
|
*/
|
||||||
|
virtual ReturnValue_t deletePacket() = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method performs a size check.
|
||||||
|
* It reads the stored size and compares it with the size entered in the
|
||||||
|
* packet header. This class is the optimal place for such a check as it
|
||||||
|
* has access to both the header data and the store.
|
||||||
|
* @return true if size is correct, false if packet is not registered in
|
||||||
|
* store or size is incorrect.
|
||||||
|
*/
|
||||||
|
virtual bool isSizeCorrect() = 0;
|
||||||
|
|
||||||
|
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::TC_STORE.
|
||||||
|
*/
|
||||||
|
static StorageManagerIF* store;
|
||||||
|
/**
|
||||||
|
* 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();
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
#endif /* TMTCPACKET_PUS_TcPacketStoredBase_H_ */
|
38
tmtcpacket/pus/tc/TcPacketStoredIF.h
Normal file
38
tmtcpacket/pus/tc/TcPacketStoredIF.h
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
#ifndef FSFW_TMTCPACKET_PUS_TCPACKETSTOREDIF_H_
|
||||||
|
#define FSFW_TMTCPACKET_PUS_TCPACKETSTOREDIF_H_
|
||||||
|
|
||||||
|
#include "TcPacketBase.h"
|
||||||
|
#include "../../../storagemanager/storeAddress.h"
|
||||||
|
#include "../../../returnvalues/HasReturnvaluesIF.h"
|
||||||
|
|
||||||
|
class TcPacketStoredIF {
|
||||||
|
public:
|
||||||
|
virtual~TcPacketStoredIF() {};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* With this call, the stored packet can be set to another packet in a 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.
|
||||||
|
*/
|
||||||
|
virtual void setStoreAddress(store_address_t setAddress) = 0;
|
||||||
|
|
||||||
|
virtual store_address_t getStoreAddress() = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Getter function for the raw data.
|
||||||
|
* @param dataPtr [out] Pointer to the data pointer to set
|
||||||
|
* @param dataSize [out] Address of size to set.
|
||||||
|
* @return -@c RETURN_OK if data was retrieved successfully.
|
||||||
|
*/
|
||||||
|
virtual ReturnValue_t getData(const uint8_t ** dataPtr, size_t* dataSize) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get packet base pointer which can be used to get access to PUS packet fields
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
virtual TcPacketBase* getPacketBase() = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#endif /* FSFW_TMTCPACKET_PUS_TCPACKETSTOREDIF_H_ */
|
77
tmtcpacket/pus/tc/TcPacketStoredPus.cpp
Normal file
77
tmtcpacket/pus/tc/TcPacketStoredPus.cpp
Normal file
@ -0,0 +1,77 @@
|
|||||||
|
#include "TcPacketStoredPus.h"
|
||||||
|
|
||||||
|
#include <cstring>
|
||||||
|
|
||||||
|
TcPacketStoredPus::TcPacketStoredPus(uint16_t apid, uint8_t service,
|
||||||
|
uint8_t subservice, uint8_t sequenceCount, const uint8_t* data,
|
||||||
|
size_t size, uint8_t ack) :
|
||||||
|
TcPacketPus(nullptr) {
|
||||||
|
this->storeAddress.raw = StorageManagerIF::INVALID_ADDRESS;
|
||||||
|
if (not this->checkAndSetStore()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
uint8_t* pData = nullptr;
|
||||||
|
ReturnValue_t returnValue = this->store->getFreeElement(&this->storeAddress,
|
||||||
|
(TC_PACKET_MIN_SIZE + size), &pData);
|
||||||
|
if (returnValue != this->store->RETURN_OK) {
|
||||||
|
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||||
|
sif::warning << "TcPacketStoredBase: Could not get free element from store!"
|
||||||
|
<< std::endl;
|
||||||
|
#endif
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this->setData(pData);
|
||||||
|
initializeTcPacket(apid, sequenceCount, ack, service, subservice);
|
||||||
|
std::memcpy(&tcData->appData, data, size);
|
||||||
|
this->setPacketDataLength(
|
||||||
|
size + sizeof(PUSTcDataFieldHeader) + CRC_SIZE - 1);
|
||||||
|
this->setErrorControl();
|
||||||
|
}
|
||||||
|
|
||||||
|
TcPacketStoredPus::TcPacketStoredPus(): TcPacketStoredBase(), TcPacketPus(nullptr) {
|
||||||
|
}
|
||||||
|
|
||||||
|
TcPacketStoredPus::TcPacketStoredPus(store_address_t setAddress): TcPacketPus(nullptr) {
|
||||||
|
TcPacketStoredBase::setStoreAddress(setAddress);
|
||||||
|
}
|
||||||
|
|
||||||
|
TcPacketStoredPus::TcPacketStoredPus(const uint8_t* data, size_t size): TcPacketPus(data) {
|
||||||
|
if (this->getFullSize() != size) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (this->checkAndSetStore()) {
|
||||||
|
ReturnValue_t status = store->addData(&storeAddress, data, size);
|
||||||
|
if (status != HasReturnvaluesIF::RETURN_OK) {
|
||||||
|
this->setData(nullptr);
|
||||||
|
}
|
||||||
|
const uint8_t* storePtr = nullptr;
|
||||||
|
// Repoint base data pointer to the data in the store.
|
||||||
|
store->getData(storeAddress, &storePtr, &size);
|
||||||
|
this->setData(storePtr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ReturnValue_t TcPacketStoredPus::deletePacket() {
|
||||||
|
ReturnValue_t result = this->store->deleteData(this->storeAddress);
|
||||||
|
this->storeAddress.raw = StorageManagerIF::INVALID_ADDRESS;
|
||||||
|
this->setData(nullptr);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
TcPacketBase* TcPacketStoredPus::getPacketBase() {
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool TcPacketStoredPus::isSizeCorrect() {
|
||||||
|
const uint8_t* temp_data = nullptr;
|
||||||
|
size_t temp_size;
|
||||||
|
ReturnValue_t status = this->store->getData(this->storeAddress, &temp_data,
|
||||||
|
&temp_size);
|
||||||
|
if (status == StorageManagerIF::RETURN_OK) {
|
||||||
|
if (this->getFullSize() == temp_size) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
53
tmtcpacket/pus/tc/TcPacketStoredPus.h
Normal file
53
tmtcpacket/pus/tc/TcPacketStoredPus.h
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
#ifndef FSFW_TMTCPACKET_PUS_TCPACKETSTOREDPUSA_H_
|
||||||
|
#define FSFW_TMTCPACKET_PUS_TCPACKETSTOREDPUSA_H_
|
||||||
|
|
||||||
|
#include "TcPacketStoredBase.h"
|
||||||
|
#include "TcPacketPus.h"
|
||||||
|
|
||||||
|
class TcPacketStoredPus:
|
||||||
|
public TcPacketStoredBase,
|
||||||
|
public TcPacketPus {
|
||||||
|
public:
|
||||||
|
/**
|
||||||
|
* With this constructor, new space is allocated in the packet store and
|
||||||
|
* a new PUS Telecommand Packet is created there.
|
||||||
|
* Packet Application Data passed in data is copied into the packet.
|
||||||
|
* @param apid Sets the packet's APID field.
|
||||||
|
* @param service Sets the packet's Service ID field.
|
||||||
|
* This specifies the destination service.
|
||||||
|
* @param subservice Sets the packet's Service Subtype field.
|
||||||
|
* This specifies the destination sub-service.
|
||||||
|
* @param sequence_count Sets the packet's Source Sequence Count field.
|
||||||
|
* @param data The data to be copied to the Application Data Field.
|
||||||
|
* @param size The amount of data to be copied.
|
||||||
|
* @param ack Set's the packet's Ack field, which specifies
|
||||||
|
* number of verification packets returned
|
||||||
|
* for this command.
|
||||||
|
*/
|
||||||
|
TcPacketStoredPus(uint16_t apid, uint8_t service, uint8_t subservice,
|
||||||
|
uint8_t sequence_count = 0, const uint8_t* data = nullptr,
|
||||||
|
size_t size = 0, uint8_t ack = TcPacketBase::ACK_ALL);
|
||||||
|
/**
|
||||||
|
* Create stored packet with existing data.
|
||||||
|
* @param data
|
||||||
|
* @param size
|
||||||
|
*/
|
||||||
|
TcPacketStoredPus(const uint8_t* data, size_t size);
|
||||||
|
/**
|
||||||
|
* Create stored packet from existing packet in store
|
||||||
|
* @param setAddress
|
||||||
|
*/
|
||||||
|
TcPacketStoredPus(store_address_t setAddress);
|
||||||
|
TcPacketStoredPus();
|
||||||
|
|
||||||
|
ReturnValue_t deletePacket() override;
|
||||||
|
TcPacketBase* getPacketBase() override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
bool isSizeCorrect() override;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#endif /* FSFW_TMTCPACKET_PUS_TCPACKETSTOREDPUSA_H_ */
|
16
tmtcpacket/pus/tm.h
Normal file
16
tmtcpacket/pus/tm.h
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
#ifndef FSFW_TMTCPACKET_PUS_TM_H_
|
||||||
|
#define FSFW_TMTCPACKET_PUS_TM_H_
|
||||||
|
|
||||||
|
#include "../../FSFW.h"
|
||||||
|
|
||||||
|
#if FSFW_USE_PUS_C_TELEMETRY == 1
|
||||||
|
#include "tm/TmPacketPusC.h"
|
||||||
|
#include "tm/TmPacketStoredPusC.h"
|
||||||
|
#else
|
||||||
|
#include "tm/TmPacketPusA.h"
|
||||||
|
#include "tm/TmPacketStoredPusA.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "tm/TmPacketMinimal.h"
|
||||||
|
|
||||||
|
#endif /* FSFW_TMTCPACKET_PUS_TM_H_ */
|
9
tmtcpacket/pus/tm/CMakeLists.txt
Normal file
9
tmtcpacket/pus/tm/CMakeLists.txt
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
target_sources(${LIB_FSFW_NAME} PRIVATE
|
||||||
|
TmPacketStoredPusA.cpp
|
||||||
|
TmPacketStoredPusC.cpp
|
||||||
|
TmPacketPusA.cpp
|
||||||
|
TmPacketPusC.cpp
|
||||||
|
TmPacketStoredBase.cpp
|
||||||
|
TmPacketBase.cpp
|
||||||
|
TmPacketMinimal.cpp
|
||||||
|
)
|
@ -1,19 +1,17 @@
|
|||||||
#include "TmPacketBase.h"
|
#include "TmPacketBase.h"
|
||||||
|
|
||||||
#include "../../globalfunctions/CRC.h"
|
#include "../../../globalfunctions/CRC.h"
|
||||||
#include "../../globalfunctions/arrayprinter.h"
|
#include "../../../globalfunctions/arrayprinter.h"
|
||||||
#include "../../objectmanager/ObjectManager.h"
|
#include "../../../objectmanager/ObjectManager.h"
|
||||||
#include "../../serviceinterface/ServiceInterface.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 = objects::NO_OBJECT;
|
object_id_t TmPacketBase::timeStamperId = objects::NO_OBJECT;
|
||||||
|
|
||||||
TmPacketBase::TmPacketBase(uint8_t* setData):
|
TmPacketBase::TmPacketBase(uint8_t* setData): SpacePacketBase(setData) {}
|
||||||
SpacePacketBase(setData) {
|
|
||||||
}
|
|
||||||
|
|
||||||
TmPacketBase::~TmPacketBase() {
|
TmPacketBase::~TmPacketBase() {
|
||||||
//Nothing to do.
|
//Nothing to do.
|
||||||
@ -44,13 +42,6 @@ ReturnValue_t TmPacketBase::getPacketTime(timeval* timestamp) const {
|
|||||||
&tempSize, getTimestampSize());
|
&tempSize, getTimestampSize());
|
||||||
}
|
}
|
||||||
|
|
||||||
void TmPacketBase::print() {
|
|
||||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
|
||||||
sif::debug << "TmPacketBase::print: " << std::endl;
|
|
||||||
#endif
|
|
||||||
arrayprinter::print(getWholeData(), getFullSize());
|
|
||||||
}
|
|
||||||
|
|
||||||
bool TmPacketBase::checkAndSetStamper() {
|
bool TmPacketBase::checkAndSetStamper() {
|
||||||
if (timeStamper == NULL) {
|
if (timeStamper == NULL) {
|
||||||
timeStamper = ObjectManager::instance()->get<TimeStamperIF>(timeStamperId);
|
timeStamper = ObjectManager::instance()->get<TimeStamperIF>(timeStamperId);
|
||||||
@ -66,3 +57,11 @@ bool TmPacketBase::checkAndSetStamper() {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TmPacketBase::print() {
|
||||||
|
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||||
|
sif::info << "TmPacketBase::print:" << std::endl;
|
||||||
|
#else
|
||||||
|
sif::printInfo("TmPacketBase::print:\n");
|
||||||
|
#endif
|
||||||
|
arrayprinter::print(getWholeData(), getFullSize());
|
||||||
|
}
|
@ -1,10 +1,10 @@
|
|||||||
#ifndef TMTCPACKET_PUS_TMPACKETBASE_H_
|
#ifndef TMTCPACKET_PUS_TMPACKETBASE_H_
|
||||||
#define TMTCPACKET_PUS_TMPACKETBASE_H_
|
#define TMTCPACKET_PUS_TMPACKETBASE_H_
|
||||||
|
|
||||||
#include "../SpacePacketBase.h"
|
#include "../../SpacePacketBase.h"
|
||||||
#include "../../timemanager/TimeStamperIF.h"
|
#include "../../../timemanager/TimeStamperIF.h"
|
||||||
#include "../../timemanager/Clock.h"
|
#include "../../../timemanager/Clock.h"
|
||||||
#include "../../objectmanager/SystemObjectIF.h"
|
#include "../../../objectmanager/SystemObjectIF.h"
|
||||||
|
|
||||||
namespace Factory{
|
namespace Factory{
|
||||||
void setStaticFrameworkObjectIds();
|
void setStaticFrameworkObjectIds();
|
@ -1,7 +1,8 @@
|
|||||||
#include "TmPacketMinimal.h"
|
#include "TmPacketMinimal.h"
|
||||||
#include <stddef.h>
|
#include "../PacketTimestampInterpreterIF.h"
|
||||||
#include <time.h>
|
|
||||||
#include "PacketTimestampInterpreterIF.h"
|
#include <cstddef>
|
||||||
|
#include <ctime>
|
||||||
|
|
||||||
TmPacketMinimal::TmPacketMinimal(const uint8_t* set_data) : SpacePacketBase( set_data ) {
|
TmPacketMinimal::TmPacketMinimal(const uint8_t* set_data) : SpacePacketBase( set_data ) {
|
||||||
this->tm_data = (TmPacketMinimalPointer*)set_data;
|
this->tm_data = (TmPacketMinimalPointer*)set_data;
|
@ -2,8 +2,8 @@
|
|||||||
#define FRAMEWORK_TMTCPACKET_PUS_TMPACKETMINIMAL_H_
|
#define FRAMEWORK_TMTCPACKET_PUS_TMPACKETMINIMAL_H_
|
||||||
|
|
||||||
|
|
||||||
#include "../../tmtcpacket/SpacePacketBase.h"
|
#include "../../SpacePacketBase.h"
|
||||||
#include "../../returnvalues/HasReturnvaluesIF.h"
|
#include "../../../returnvalues/HasReturnvaluesIF.h"
|
||||||
|
|
||||||
struct timeval;
|
struct timeval;
|
||||||
class PacketTimestampInterpreterIF;
|
class PacketTimestampInterpreterIF;
|
@ -1,11 +1,11 @@
|
|||||||
#include "TmPacketPusA.h"
|
#include "TmPacketPusA.h"
|
||||||
#include "TmPacketBase.h"
|
#include "TmPacketBase.h"
|
||||||
|
|
||||||
#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/ServiceInterfaceStream.h"
|
||||||
#include "../../timemanager/CCSDSTime.h"
|
#include "../../../timemanager/CCSDSTime.h"
|
||||||
|
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
|
@ -2,10 +2,10 @@
|
|||||||
#define FSFW_TMTCPACKET_PUS_TMPACKETPUSA_H_
|
#define FSFW_TMTCPACKET_PUS_TMPACKETPUSA_H_
|
||||||
|
|
||||||
#include "TmPacketBase.h"
|
#include "TmPacketBase.h"
|
||||||
#include "../SpacePacketBase.h"
|
#include "../../SpacePacketBase.h"
|
||||||
#include "../../timemanager/TimeStamperIF.h"
|
#include "../../../timemanager/TimeStamperIF.h"
|
||||||
#include "../../timemanager/Clock.h"
|
#include "../../../timemanager/Clock.h"
|
||||||
#include "../../objectmanager/SystemObjectIF.h"
|
#include "../../../objectmanager/SystemObjectIF.h"
|
||||||
|
|
||||||
namespace Factory{
|
namespace Factory{
|
||||||
void setStaticFrameworkObjectIds();
|
void setStaticFrameworkObjectIds();
|
||||||
@ -23,7 +23,7 @@ struct PUSTmDataFieldHeaderPusA {
|
|||||||
uint8_t service_type;
|
uint8_t service_type;
|
||||||
uint8_t service_subtype;
|
uint8_t service_subtype;
|
||||||
uint8_t subcounter;
|
uint8_t subcounter;
|
||||||
// uint8_t destination;
|
// uint8_t destination;
|
||||||
uint8_t time[TimeStamperIF::MISSION_TIMESTAMP_SIZE];
|
uint8_t time[TimeStamperIF::MISSION_TIMESTAMP_SIZE];
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -51,8 +51,7 @@ public:
|
|||||||
static const uint32_t TM_PACKET_MIN_SIZE = (sizeof(CCSDSPrimaryHeader) +
|
static const uint32_t TM_PACKET_MIN_SIZE = (sizeof(CCSDSPrimaryHeader) +
|
||||||
sizeof(PUSTmDataFieldHeaderPusA) + 2);
|
sizeof(PUSTmDataFieldHeaderPusA) + 2);
|
||||||
//! Maximum size of a TM Packet in this mission.
|
//! 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 = fsfwconfig::FSFW_MAX_TM_PACKET_SIZE;
|
||||||
static const uint32_t MISSION_TM_PACKET_MAX_SIZE = 2048;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is the default constructor.
|
* This is the default constructor.
|
@ -1,11 +1,11 @@
|
|||||||
#include "TmPacketPusC.h"
|
#include "TmPacketPusC.h"
|
||||||
#include "TmPacketBase.h"
|
#include "TmPacketBase.h"
|
||||||
|
|
||||||
#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/ServiceInterfaceStream.h"
|
||||||
#include "../../timemanager/CCSDSTime.h"
|
#include "../../../timemanager/CCSDSTime.h"
|
||||||
|
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
|
@ -2,10 +2,10 @@
|
|||||||
#define FSFW_TMTCPACKET_PUS_TMPACKETPUSC_H_
|
#define FSFW_TMTCPACKET_PUS_TMPACKETPUSC_H_
|
||||||
|
|
||||||
#include "TmPacketBase.h"
|
#include "TmPacketBase.h"
|
||||||
#include "../SpacePacketBase.h"
|
#include "../../SpacePacketBase.h"
|
||||||
#include "../../timemanager/TimeStamperIF.h"
|
#include "../../../timemanager/TimeStamperIF.h"
|
||||||
#include "../../timemanager/Clock.h"
|
#include "../../../timemanager/Clock.h"
|
||||||
#include "../../objectmanager/SystemObjectIF.h"
|
#include "../../../objectmanager/SystemObjectIF.h"
|
||||||
|
|
||||||
namespace Factory{
|
namespace Factory{
|
||||||
void setStaticFrameworkObjectIds();
|
void setStaticFrameworkObjectIds();
|
||||||
@ -53,8 +53,7 @@ public:
|
|||||||
static const uint32_t TM_PACKET_MIN_SIZE = (sizeof(CCSDSPrimaryHeader) +
|
static const uint32_t TM_PACKET_MIN_SIZE = (sizeof(CCSDSPrimaryHeader) +
|
||||||
sizeof(PUSTmDataFieldHeaderPusC) + 2);
|
sizeof(PUSTmDataFieldHeaderPusC) + 2);
|
||||||
//! Maximum size of a TM Packet in this mission.
|
//! 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 = fsfwconfig::FSFW_MAX_TM_PACKET_SIZE;
|
||||||
static const uint32_t MISSION_TM_PACKET_MAX_SIZE = 2048;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is the default constructor.
|
* This is the default constructor.
|
@ -1,8 +1,8 @@
|
|||||||
#include "TmPacketStoredBase.h"
|
#include "TmPacketStoredBase.h"
|
||||||
|
|
||||||
#include "../../objectmanager/ObjectManager.h"
|
#include "../../../objectmanager/ObjectManager.h"
|
||||||
#include "../../serviceinterface/ServiceInterface.h"
|
#include "../../../serviceinterface/ServiceInterface.h"
|
||||||
#include "../../tmtcservices/TmTcMessage.h"
|
#include "../../../tmtcservices/TmTcMessage.h"
|
||||||
|
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
|
@ -1,15 +1,15 @@
|
|||||||
#ifndef FSFW_TMTCPACKET_PUS_TMPACKETSTOREDBASE_H_
|
#ifndef FSFW_TMTCPACKET_PUS_TMPACKETSTOREDBASE_H_
|
||||||
#define FSFW_TMTCPACKET_PUS_TMPACKETSTOREDBASE_H_
|
#define FSFW_TMTCPACKET_PUS_TMPACKETSTOREDBASE_H_
|
||||||
|
|
||||||
|
#include "../../../FSFW.h"
|
||||||
#include "TmPacketBase.h"
|
#include "TmPacketBase.h"
|
||||||
#include "TmPacketStoredBase.h"
|
#include "TmPacketStoredBase.h"
|
||||||
#include <FSFWConfig.h>
|
#include "TmPacketPusA.h"
|
||||||
|
|
||||||
#include "../../tmtcpacket/pus/TmPacketPusA.h"
|
#include "../../../serialize/SerializeIF.h"
|
||||||
#include "../../serialize/SerializeIF.h"
|
#include "../../../storagemanager/StorageManagerIF.h"
|
||||||
#include "../../storagemanager/StorageManagerIF.h"
|
#include "../../../internalError/InternalErrorReporterIF.h"
|
||||||
#include "../../internalError/InternalErrorReporterIF.h"
|
#include "../../../ipc/MessageQueueSenderIF.h"
|
||||||
#include "../../ipc/MessageQueueSenderIF.h"
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class generates a ECSS PUS Telemetry packet within a given
|
* This class generates a ECSS PUS Telemetry packet within a given
|
@ -1,7 +1,7 @@
|
|||||||
#include "TmPacketStoredPusA.h"
|
#include "TmPacketStoredPusA.h"
|
||||||
|
|
||||||
#include "../../serviceinterface/ServiceInterface.h"
|
#include "../../../serviceinterface/ServiceInterface.h"
|
||||||
#include "../../tmtcservices/TmTcMessage.h"
|
#include "../../../tmtcservices/TmTcMessage.h"
|
||||||
|
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
|
@ -1,7 +1,7 @@
|
|||||||
#include "TmPacketStoredPusC.h"
|
#include "TmPacketStoredPusC.h"
|
||||||
|
|
||||||
#include "../../serviceinterface/ServiceInterface.h"
|
#include "../../../serviceinterface/ServiceInterface.h"
|
||||||
#include "../../tmtcservices/TmTcMessage.h"
|
#include "../../../tmtcservices/TmTcMessage.h"
|
||||||
|
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
|
@ -1,8 +1,8 @@
|
|||||||
#ifndef FSFW_TMTCPACKET_PUS_TMPACKETSTOREDPUSC_H_
|
#ifndef FSFW_TMTCPACKET_PUS_TMPACKETSTOREDPUSC_H_
|
||||||
#define FSFW_TMTCPACKET_PUS_TMPACKETSTOREDPUSC_H_
|
#define FSFW_TMTCPACKET_PUS_TMPACKETSTOREDPUSC_H_
|
||||||
|
|
||||||
#include <fsfw/tmtcpacket/pus/TmPacketPusC.h>
|
#include "TmPacketPusC.h"
|
||||||
#include <fsfw/tmtcpacket/pus/TmPacketStoredBase.h>
|
#include "TmPacketStoredBase.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class generates a ECSS PUS C Telemetry packet within a given
|
* This class generates a ECSS PUS C Telemetry packet within a given
|
@ -6,8 +6,8 @@
|
|||||||
#include "../tcdistribution/PUSDistributorIF.h"
|
#include "../tcdistribution/PUSDistributorIF.h"
|
||||||
#include "../objectmanager/ObjectManager.h"
|
#include "../objectmanager/ObjectManager.h"
|
||||||
#include "../ipc/QueueFactory.h"
|
#include "../ipc/QueueFactory.h"
|
||||||
#include "../tmtcpacket/pus/TcPacketStored.h"
|
#include "../tmtcpacket/pus/tc.h"
|
||||||
#include "../tmtcpacket/pus/TmPacketStored.h"
|
#include "../tmtcpacket/pus/tm.h"
|
||||||
#include "../serviceinterface/ServiceInterface.h"
|
#include "../serviceinterface/ServiceInterface.h"
|
||||||
|
|
||||||
object_id_t CommandingServiceBase::defaultPacketSource = objects::NO_OBJECT;
|
object_id_t CommandingServiceBase::defaultPacketSource = objects::NO_OBJECT;
|
||||||
@ -246,7 +246,7 @@ void CommandingServiceBase::handleRequestQueue() {
|
|||||||
TmTcMessage message;
|
TmTcMessage message;
|
||||||
ReturnValue_t result;
|
ReturnValue_t result;
|
||||||
store_address_t address;
|
store_address_t address;
|
||||||
TcPacketStored packet;
|
TcPacketStoredPus packet;
|
||||||
MessageQueueId_t queue;
|
MessageQueueId_t queue;
|
||||||
object_id_t objectId;
|
object_id_t objectId;
|
||||||
for (result = requestQueue->receiveMessage(&message); result == RETURN_OK;
|
for (result = requestQueue->receiveMessage(&message); result == RETURN_OK;
|
||||||
@ -259,6 +259,7 @@ void CommandingServiceBase::handleRequestQueue() {
|
|||||||
rejectPacket(tc_verification::START_FAILURE, &packet, INVALID_SUBSERVICE);
|
rejectPacket(tc_verification::START_FAILURE, &packet, INVALID_SUBSERVICE);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
result = getMessageQueueAndObject(packet.getSubService(),
|
result = getMessageQueueAndObject(packet.getSubService(),
|
||||||
packet.getApplicationData(), packet.getApplicationDataSize(),
|
packet.getApplicationData(), packet.getApplicationDataSize(),
|
||||||
&queue, &objectId);
|
&queue, &objectId);
|
||||||
@ -351,14 +352,18 @@ ReturnValue_t CommandingServiceBase::sendTmPacket(uint8_t subservice,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void CommandingServiceBase::startExecution(TcPacketStored *storedPacket,
|
void CommandingServiceBase::startExecution(TcPacketStoredBase *storedPacket,
|
||||||
CommandMapIter iter) {
|
CommandMapIter iter) {
|
||||||
ReturnValue_t result = RETURN_OK;
|
ReturnValue_t result = RETURN_OK;
|
||||||
CommandMessage command;
|
CommandMessage command;
|
||||||
iter->second.subservice = storedPacket->getSubService();
|
TcPacketBase* tcPacketBase = storedPacket->getPacketBase();
|
||||||
|
if(tcPacketBase == nullptr) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
iter->second.subservice = tcPacketBase->getSubService();
|
||||||
result = prepareCommand(&command, iter->second.subservice,
|
result = prepareCommand(&command, iter->second.subservice,
|
||||||
storedPacket->getApplicationData(),
|
tcPacketBase->getApplicationData(),
|
||||||
storedPacket->getApplicationDataSize(), &iter->second.state,
|
tcPacketBase->getApplicationDataSize(), &iter->second.state,
|
||||||
iter->second.objectId);
|
iter->second.objectId);
|
||||||
|
|
||||||
ReturnValue_t sendResult = RETURN_OK;
|
ReturnValue_t sendResult = RETURN_OK;
|
||||||
@ -371,12 +376,12 @@ void CommandingServiceBase::startExecution(TcPacketStored *storedPacket,
|
|||||||
if (sendResult == RETURN_OK) {
|
if (sendResult == RETURN_OK) {
|
||||||
Clock::getUptime(&iter->second.uptimeOfStart);
|
Clock::getUptime(&iter->second.uptimeOfStart);
|
||||||
iter->second.step = 0;
|
iter->second.step = 0;
|
||||||
iter->second.subservice = storedPacket->getSubService();
|
iter->second.subservice = tcPacketBase->getSubService();
|
||||||
iter->second.command = command.getCommand();
|
iter->second.command = command.getCommand();
|
||||||
iter->second.tcInfo.ackFlags = storedPacket->getAcknowledgeFlags();
|
iter->second.tcInfo.ackFlags = tcPacketBase->getAcknowledgeFlags();
|
||||||
iter->second.tcInfo.tcPacketId = storedPacket->getPacketId();
|
iter->second.tcInfo.tcPacketId = tcPacketBase->getPacketId();
|
||||||
iter->second.tcInfo.tcSequenceControl =
|
iter->second.tcInfo.tcSequenceControl =
|
||||||
storedPacket->getPacketSequenceControl();
|
tcPacketBase->getPacketSequenceControl();
|
||||||
acceptPacket(tc_verification::START_SUCCESS, storedPacket);
|
acceptPacket(tc_verification::START_SUCCESS, storedPacket);
|
||||||
} else {
|
} else {
|
||||||
command.clearCommandMessage();
|
command.clearCommandMessage();
|
||||||
@ -392,7 +397,7 @@ void CommandingServiceBase::startExecution(TcPacketStored *storedPacket,
|
|||||||
}
|
}
|
||||||
if (sendResult == RETURN_OK) {
|
if (sendResult == RETURN_OK) {
|
||||||
verificationReporter.sendSuccessReport(tc_verification::START_SUCCESS,
|
verificationReporter.sendSuccessReport(tc_verification::START_SUCCESS,
|
||||||
storedPacket);
|
storedPacket->getPacketBase());
|
||||||
acceptPacket(tc_verification::COMPLETION_SUCCESS, storedPacket);
|
acceptPacket(tc_verification::COMPLETION_SUCCESS, storedPacket);
|
||||||
checkAndExecuteFifo(iter);
|
checkAndExecuteFifo(iter);
|
||||||
} else {
|
} else {
|
||||||
@ -409,16 +414,16 @@ void CommandingServiceBase::startExecution(TcPacketStored *storedPacket,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void CommandingServiceBase::rejectPacket(uint8_t report_id,
|
void CommandingServiceBase::rejectPacket(uint8_t reportId,
|
||||||
TcPacketStored* packet, ReturnValue_t error_code) {
|
TcPacketStoredBase* packet, ReturnValue_t errorCode) {
|
||||||
verificationReporter.sendFailureReport(report_id, packet, error_code);
|
verificationReporter.sendFailureReport(reportId, packet->getPacketBase(), errorCode);
|
||||||
packet->deletePacket();
|
packet->deletePacket();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void CommandingServiceBase::acceptPacket(uint8_t reportId,
|
void CommandingServiceBase::acceptPacket(uint8_t reportId,
|
||||||
TcPacketStored* packet) {
|
TcPacketStoredBase* packet) {
|
||||||
verificationReporter.sendSuccessReport(reportId, packet);
|
verificationReporter.sendSuccessReport(reportId, packet->getPacketBase());
|
||||||
packet->deletePacket();
|
packet->deletePacket();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -428,7 +433,7 @@ void CommandingServiceBase::checkAndExecuteFifo(CommandMapIter& iter) {
|
|||||||
if (iter->second.fifo.retrieve(&address) != RETURN_OK) {
|
if (iter->second.fifo.retrieve(&address) != RETURN_OK) {
|
||||||
commandMap.erase(&iter);
|
commandMap.erase(&iter);
|
||||||
} else {
|
} else {
|
||||||
TcPacketStored newPacket(address);
|
TcPacketStoredPus newPacket(address);
|
||||||
startExecution(&newPacket, iter);
|
startExecution(&newPacket, iter);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -16,6 +16,7 @@
|
|||||||
#include <FSFWConfig.h>
|
#include <FSFWConfig.h>
|
||||||
|
|
||||||
class TcPacketStored;
|
class TcPacketStored;
|
||||||
|
class TcPacketStoredBase;
|
||||||
|
|
||||||
namespace Factory{
|
namespace Factory{
|
||||||
void setStaticFrameworkObjectIds();
|
void setStaticFrameworkObjectIds();
|
||||||
@ -351,12 +352,12 @@ private:
|
|||||||
*/
|
*/
|
||||||
void handleRequestQueue();
|
void handleRequestQueue();
|
||||||
|
|
||||||
void rejectPacket(uint8_t reportId, TcPacketStored* packet,
|
void rejectPacket(uint8_t reportId, TcPacketStoredBase* packet,
|
||||||
ReturnValue_t errorCode);
|
ReturnValue_t errorCode);
|
||||||
|
|
||||||
void acceptPacket(uint8_t reportId, TcPacketStored* packet);
|
void acceptPacket(uint8_t reportId, TcPacketStoredBase* packet);
|
||||||
|
|
||||||
void startExecution(TcPacketStored *storedPacket, CommandMapIter iter);
|
void startExecution(TcPacketStoredBase *storedPacket, CommandMapIter iter);
|
||||||
|
|
||||||
void handleCommandMessage(CommandMessage* reply);
|
void handleCommandMessage(CommandMessage* reply);
|
||||||
void handleReplyHandlerResult(ReturnValue_t result, CommandMapIter iter,
|
void handleReplyHandlerResult(ReturnValue_t result, CommandMapIter iter,
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
#include "../objectmanager/SystemObject.h"
|
#include "../objectmanager/SystemObject.h"
|
||||||
#include "../returnvalues/HasReturnvaluesIF.h"
|
#include "../returnvalues/HasReturnvaluesIF.h"
|
||||||
#include "../tasks/ExecutableObjectIF.h"
|
#include "../tasks/ExecutableObjectIF.h"
|
||||||
#include "../tmtcpacket/pus/TcPacketStored.h"
|
#include "../tmtcpacket/pus/tc.h"
|
||||||
#include "../ipc/MessageQueueIF.h"
|
#include "../ipc/MessageQueueIF.h"
|
||||||
|
|
||||||
namespace Factory{
|
namespace Factory{
|
||||||
@ -141,7 +141,7 @@ protected:
|
|||||||
* The current Telecommand to be processed.
|
* The current Telecommand to be processed.
|
||||||
* It is deleted after handleRequest was executed.
|
* It is deleted after handleRequest was executed.
|
||||||
*/
|
*/
|
||||||
TcPacketStored currentPacket;
|
TcPacketStoredPus currentPacket;
|
||||||
|
|
||||||
static object_id_t packetSource;
|
static object_id_t packetSource;
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
#include "VerificationCodes.h"
|
#include "VerificationCodes.h"
|
||||||
|
|
||||||
#include "../ipc/MessageQueueMessage.h"
|
#include "../ipc/MessageQueueMessage.h"
|
||||||
#include "../tmtcpacket/pus/TcPacketBase.h"
|
#include "../tmtcpacket/pus/tc/TcPacketBase.h"
|
||||||
#include "../returnvalues/HasReturnvaluesIF.h"
|
#include "../returnvalues/HasReturnvaluesIF.h"
|
||||||
|
|
||||||
class PusVerificationMessage: public MessageQueueMessage {
|
class PusVerificationMessage: public MessageQueueMessage {
|
||||||
|
@ -17,14 +17,17 @@ VerificationReporter::VerificationReporter() :
|
|||||||
VerificationReporter::~VerificationReporter() {}
|
VerificationReporter::~VerificationReporter() {}
|
||||||
|
|
||||||
void VerificationReporter::sendSuccessReport(uint8_t set_report_id,
|
void VerificationReporter::sendSuccessReport(uint8_t set_report_id,
|
||||||
TcPacketBase* current_packet, uint8_t set_step) {
|
TcPacketBase* currentPacket, uint8_t set_step) {
|
||||||
if (acknowledgeQueue == MessageQueueIF::NO_QUEUE) {
|
if (acknowledgeQueue == MessageQueueIF::NO_QUEUE) {
|
||||||
this->initialize();
|
this->initialize();
|
||||||
}
|
}
|
||||||
|
if(currentPacket == nullptr) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
PusVerificationMessage message(set_report_id,
|
PusVerificationMessage message(set_report_id,
|
||||||
current_packet->getAcknowledgeFlags(),
|
currentPacket->getAcknowledgeFlags(),
|
||||||
current_packet->getPacketId(),
|
currentPacket->getPacketId(),
|
||||||
current_packet->getPacketSequenceControl(), 0, set_step);
|
currentPacket->getPacketSequenceControl(), 0, set_step);
|
||||||
ReturnValue_t status = MessageQueueSenderIF::sendMessage(acknowledgeQueue,
|
ReturnValue_t status = MessageQueueSenderIF::sendMessage(acknowledgeQueue,
|
||||||
&message);
|
&message);
|
||||||
if (status != HasReturnvaluesIF::RETURN_OK) {
|
if (status != HasReturnvaluesIF::RETURN_OK) {
|
||||||
@ -56,15 +59,18 @@ void VerificationReporter::sendSuccessReport(uint8_t set_report_id,
|
|||||||
}
|
}
|
||||||
|
|
||||||
void VerificationReporter::sendFailureReport(uint8_t report_id,
|
void VerificationReporter::sendFailureReport(uint8_t report_id,
|
||||||
TcPacketBase* current_packet, ReturnValue_t error_code, uint8_t step,
|
TcPacketBase* currentPacket, ReturnValue_t error_code, uint8_t step,
|
||||||
uint32_t parameter1, uint32_t parameter2) {
|
uint32_t parameter1, uint32_t parameter2) {
|
||||||
if (acknowledgeQueue == MessageQueueIF::NO_QUEUE) {
|
if (acknowledgeQueue == MessageQueueIF::NO_QUEUE) {
|
||||||
this->initialize();
|
this->initialize();
|
||||||
}
|
}
|
||||||
|
if(currentPacket == nullptr) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
PusVerificationMessage message(report_id,
|
PusVerificationMessage message(report_id,
|
||||||
current_packet->getAcknowledgeFlags(),
|
currentPacket->getAcknowledgeFlags(),
|
||||||
current_packet->getPacketId(),
|
currentPacket->getPacketId(),
|
||||||
current_packet->getPacketSequenceControl(), error_code, step,
|
currentPacket->getPacketSequenceControl(), error_code, step,
|
||||||
parameter1, parameter2);
|
parameter1, parameter2);
|
||||||
ReturnValue_t status = MessageQueueSenderIF::sendMessage(acknowledgeQueue,
|
ReturnValue_t status = MessageQueueSenderIF::sendMessage(acknowledgeQueue,
|
||||||
&message);
|
&message);
|
||||||
|
Loading…
Reference in New Issue
Block a user