Merge pull request 'FSFW Update' (#22) from mueller/fsfw-update into eive/develop
Reviewed-on: #22
This commit is contained in:
commit
b6e4b1fc72
16
src/fsfw/tmtcpacket/pus/definitions.h
Normal file
16
src/fsfw/tmtcpacket/pus/definitions.h
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
#ifndef FSFW_SRC_FSFW_TMTCPACKET_PUS_TM_DEFINITIONS_H_
|
||||||
|
#define FSFW_SRC_FSFW_TMTCPACKET_PUS_TM_DEFINITIONS_H_
|
||||||
|
|
||||||
|
#include <cstdint>
|
||||||
|
|
||||||
|
namespace pus {
|
||||||
|
|
||||||
|
//! Version numbers according to ECSS-E-ST-70-41C p.439
|
||||||
|
enum PusVersion: uint8_t {
|
||||||
|
PUS_A_VERSION = 1,
|
||||||
|
PUS_C_VERSION = 2
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* FSFW_SRC_FSFW_TMTCPACKET_PUS_TM_DEFINITIONS_H_ */
|
@ -1,4 +1,4 @@
|
|||||||
#include "fsfw/tmtcpacket/pus/tc/TcPacketPus.h"
|
#include "TcPacketPus.h"
|
||||||
#include "fsfw/globalfunctions/CRC.h"
|
#include "fsfw/globalfunctions/CRC.h"
|
||||||
|
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
@ -8,14 +8,13 @@ TcPacketPus::TcPacketPus(const uint8_t *setData): TcPacketBase(setData) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void TcPacketPus::initializeTcPacket(uint16_t apid, uint16_t sequenceCount,
|
void TcPacketPus::initializeTcPacket(uint16_t apid, uint16_t sequenceCount,
|
||||||
uint8_t ack, uint8_t service, uint8_t subservice, uint16_t sourceId) {
|
uint8_t ack, uint8_t service, uint8_t subservice, pus::PusVersion pusVersion,
|
||||||
|
uint16_t sourceId) {
|
||||||
initSpacePacketHeader(true, true, apid, sequenceCount);
|
initSpacePacketHeader(true, true, apid, sequenceCount);
|
||||||
std::memset(&tcData->dataField, 0, sizeof(tcData->dataField));
|
std::memset(&tcData->dataField, 0, sizeof(tcData->dataField));
|
||||||
setPacketDataLength(sizeof(PUSTcDataFieldHeader) + CRC_SIZE - 1);
|
setPacketDataLength(sizeof(PUSTcDataFieldHeader) + CRC_SIZE - 1);
|
||||||
// Data Field Header:
|
// Data Field Header. For PUS A, the first bit (CCSDS Secondary Header Flag) is zero
|
||||||
// Set CCSDS_secondary_header_flag to 0 and version number to 001
|
tcData->dataField.versionTypeAck = pusVersion << 4 | (ack & 0x0F);
|
||||||
tcData->dataField.versionTypeAck = 0b00010000;
|
|
||||||
tcData->dataField.versionTypeAck |= (ack & 0x0F);
|
|
||||||
tcData->dataField.serviceType = service;
|
tcData->dataField.serviceType = service;
|
||||||
tcData->dataField.serviceSubtype = subservice;
|
tcData->dataField.serviceSubtype = subservice;
|
||||||
#if FSFW_USE_PUS_C_TELECOMMANDS == 1
|
#if FSFW_USE_PUS_C_TELECOMMANDS == 1
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
#define FSFW_TMTCPACKET_PUS_TCPACKETPUSA_H_
|
#define FSFW_TMTCPACKET_PUS_TCPACKETPUSA_H_
|
||||||
|
|
||||||
#include "fsfw/FSFW.h"
|
#include "fsfw/FSFW.h"
|
||||||
|
#include "../definitions.h"
|
||||||
#include "fsfw/tmtcpacket/ccsds_header.h"
|
#include "fsfw/tmtcpacket/ccsds_header.h"
|
||||||
#include "TcPacketBase.h"
|
#include "TcPacketBase.h"
|
||||||
|
|
||||||
@ -75,7 +76,8 @@ protected:
|
|||||||
* @param subservice PUS Subservice
|
* @param subservice PUS Subservice
|
||||||
*/
|
*/
|
||||||
void initializeTcPacket(uint16_t apid, uint16_t sequenceCount, uint8_t ack,
|
void initializeTcPacket(uint16_t apid, uint16_t sequenceCount, uint8_t ack,
|
||||||
uint8_t service, uint8_t subservice, uint16_t sourceId = 0);
|
uint8_t service, uint8_t subservice, pus::PusVersion pusVersion,
|
||||||
|
uint16_t sourceId = 0);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A pointer to a structure which defines the data structure of
|
* A pointer to a structure which defines the data structure of
|
||||||
|
@ -23,7 +23,12 @@ TcPacketStoredPus::TcPacketStoredPus(uint16_t apid, uint8_t service,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this->setData(pData);
|
this->setData(pData);
|
||||||
initializeTcPacket(apid, sequenceCount, ack, service, subservice);
|
#if FSFW_USE_PUS_C_TELECOMMANDS == 1
|
||||||
|
pus::PusVersion pusVersion = pus::PusVersion::PUS_C_VERSION;
|
||||||
|
#else
|
||||||
|
pus::PusVersion pusVersion = pus::PusVersion::PUS_A_VERSION;
|
||||||
|
#endif
|
||||||
|
initializeTcPacket(apid, sequenceCount, ack, service, subservice, pusVersion);
|
||||||
std::memcpy(&tcData->appData, data, size);
|
std::memcpy(&tcData->appData, data, size);
|
||||||
this->setPacketDataLength(
|
this->setPacketDataLength(
|
||||||
size + sizeof(PUSTcDataFieldHeader) + CRC_SIZE - 1);
|
size + sizeof(PUSTcDataFieldHeader) + CRC_SIZE - 1);
|
||||||
|
@ -31,8 +31,6 @@ public:
|
|||||||
//! 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.
|
//! TODO: Make this dependant on a config variable.
|
||||||
static const uint32_t MISSION_TM_PACKET_MAX_SIZE = 2048;
|
static const uint32_t MISSION_TM_PACKET_MAX_SIZE = 2048;
|
||||||
//! First four bits of first byte of secondary header
|
|
||||||
static const uint8_t VERSION_NUMBER_BYTE = 0b00010000;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is the default constructor.
|
* This is the default constructor.
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
#include "fsfw/tmtcpacket/pus/tm/TmPacketPusA.h"
|
#include "../definitions.h"
|
||||||
#include "fsfw/tmtcpacket/pus/tm/TmPacketBase.h"
|
#include "TmPacketPusA.h"
|
||||||
|
#include "TmPacketBase.h"
|
||||||
|
|
||||||
#include "fsfw/globalfunctions/CRC.h"
|
#include "fsfw/globalfunctions/CRC.h"
|
||||||
#include "fsfw/globalfunctions/arrayprinter.h"
|
#include "fsfw/globalfunctions/arrayprinter.h"
|
||||||
@ -62,12 +63,7 @@ void TmPacketPusA::initializeTmPacket(uint16_t apid, uint8_t service,
|
|||||||
//First, set to zero.
|
//First, set to zero.
|
||||||
memset(&tmData->data_field, 0, sizeof(tmData->data_field));
|
memset(&tmData->data_field, 0, sizeof(tmData->data_field));
|
||||||
|
|
||||||
// NOTE: In PUS-C, the PUS Version is 2 and specified for the first 4 bits.
|
tmData->data_field.version_type_ack = pus::PusVersion::PUS_A_VERSION << 4;
|
||||||
// The other 4 bits of the first byte are the spacecraft time reference
|
|
||||||
// status. To change to PUS-C, set 0b00100000.
|
|
||||||
// Set CCSDS_secondary header flag to 0, version number to 001 and ack
|
|
||||||
// to 0000
|
|
||||||
tmData->data_field.version_type_ack = 0b00010000;
|
|
||||||
tmData->data_field.service_type = service;
|
tmData->data_field.service_type = service;
|
||||||
tmData->data_field.service_subtype = subservice;
|
tmData->data_field.service_subtype = subservice;
|
||||||
tmData->data_field.subcounter = packetSubcounter;
|
tmData->data_field.subcounter = packetSubcounter;
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
#include "fsfw/tmtcpacket/pus/tm/TmPacketPusC.h"
|
#include "../definitions.h"
|
||||||
#include "fsfw/tmtcpacket/pus/tm/TmPacketBase.h"
|
#include "TmPacketPusC.h"
|
||||||
|
#include "TmPacketBase.h"
|
||||||
|
|
||||||
#include "fsfw/globalfunctions/CRC.h"
|
#include "fsfw/globalfunctions/CRC.h"
|
||||||
#include "fsfw/globalfunctions/arrayprinter.h"
|
#include "fsfw/globalfunctions/arrayprinter.h"
|
||||||
@ -67,7 +68,8 @@ ReturnValue_t TmPacketPusC::initializeTmPacket(uint16_t apid, uint8_t service,
|
|||||||
|
|
||||||
/* Only account for last 4 bytes for time reference field */
|
/* Only account for last 4 bytes for time reference field */
|
||||||
timeRefField &= 0b1111;
|
timeRefField &= 0b1111;
|
||||||
tmData->dataField.versionTimeReferenceField = VERSION_NUMBER_BYTE | timeRefField;
|
tmData->dataField.versionTimeReferenceField =
|
||||||
|
(pus::PusVersion::PUS_C_VERSION << 4) | timeRefField;
|
||||||
tmData->dataField.serviceType = service;
|
tmData->dataField.serviceType = service;
|
||||||
tmData->dataField.serviceSubtype = subservice;
|
tmData->dataField.serviceSubtype = subservice;
|
||||||
tmData->dataField.subcounterMsb = packetSubcounter << 8 & 0xff;
|
tmData->dataField.subcounterMsb = packetSubcounter << 8 & 0xff;
|
||||||
|
@ -91,4 +91,34 @@ void TmPacketStoredBase::checkAndReportLostTm() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TmPacketStoredBase::handleStoreFailure(const char *const packetType, ReturnValue_t result,
|
||||||
|
size_t sizeToReserve) {
|
||||||
|
checkAndReportLostTm();
|
||||||
|
#if FSFW_VERBOSE_LEVEL >= 1
|
||||||
|
switch(result) {
|
||||||
|
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||||
|
case(StorageManagerIF::DATA_STORAGE_FULL): {
|
||||||
|
sif::warning << "TmPacketStoredPus" << packetType << ": " <<
|
||||||
|
"Store full for packet with size" << sizeToReserve << std::endl;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case(StorageManagerIF::DATA_TOO_LARGE): {
|
||||||
|
sif::warning << "TmPacketStoredPus" << packetType << ": Data with size " <<
|
||||||
|
sizeToReserve << " too large" << std::endl;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
case(StorageManagerIF::DATA_STORAGE_FULL): {
|
||||||
|
sif::printWarning("TmPacketStoredPus%s: Store full for packet with "
|
||||||
|
"size %d\n", packetType, sizeToReserve);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case(StorageManagerIF::DATA_TOO_LARGE): {
|
||||||
|
sif::printWarning("TmPacketStoredPus%s: Data with size "
|
||||||
|
"%d too large\n", packetType, sizeToReserve);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -82,6 +82,9 @@ protected:
|
|||||||
bool checkAndSetStore();
|
bool checkAndSetStore();
|
||||||
|
|
||||||
void checkAndReportLostTm();
|
void checkAndReportLostTm();
|
||||||
|
|
||||||
|
void handleStoreFailure(const char* const packetType, ReturnValue_t result,
|
||||||
|
size_t sizeToReserve);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -5,24 +5,25 @@
|
|||||||
|
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
|
||||||
TmPacketStoredPusA::TmPacketStoredPusA(store_address_t setAddress) :
|
TmPacketStoredPusA::TmPacketStoredPusA(store_address_t setAddress):
|
||||||
TmPacketStoredBase(setAddress), TmPacketPusA(nullptr){
|
TmPacketStoredBase(setAddress), TmPacketPusA(nullptr){
|
||||||
}
|
}
|
||||||
|
|
||||||
TmPacketStoredPusA::TmPacketStoredPusA(uint16_t apid, uint8_t service,
|
TmPacketStoredPusA::TmPacketStoredPusA(uint16_t apid, uint8_t service,
|
||||||
uint8_t subservice, uint8_t packetSubcounter, const uint8_t *data,
|
uint8_t subservice, uint8_t packetSubcounter, const uint8_t *data,
|
||||||
uint32_t size, const uint8_t *headerData, uint32_t headerSize) :
|
uint32_t size, const uint8_t *headerData, uint32_t headerSize):
|
||||||
TmPacketPusA(nullptr) {
|
TmPacketPusA(nullptr) {
|
||||||
storeAddress.raw = StorageManagerIF::INVALID_ADDRESS;
|
storeAddress.raw = StorageManagerIF::INVALID_ADDRESS;
|
||||||
if (not TmPacketStoredBase::checkAndSetStore()) {
|
if (not TmPacketStoredBase::checkAndSetStore()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
uint8_t *pData = nullptr;
|
uint8_t *pData = nullptr;
|
||||||
|
size_t sizeToReserve = getPacketMinimumSize() + size + headerSize;
|
||||||
ReturnValue_t returnValue = store->getFreeElement(&storeAddress,
|
ReturnValue_t returnValue = store->getFreeElement(&storeAddress,
|
||||||
(getPacketMinimumSize() + size + headerSize), &pData);
|
sizeToReserve, &pData);
|
||||||
|
|
||||||
if (returnValue != store->RETURN_OK) {
|
if (returnValue != store->RETURN_OK) {
|
||||||
TmPacketStoredBase::checkAndReportLostTm();
|
handleStoreFailure("A", returnValue, sizeToReserve);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
setData(pData);
|
setData(pData);
|
||||||
@ -42,32 +43,33 @@ TmPacketStoredPusA::TmPacketStoredPusA(uint16_t apid, uint8_t service,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
size_t sourceDataSize = 0;
|
size_t sourceDataSize = 0;
|
||||||
if (content != NULL) {
|
if (content != nullptr) {
|
||||||
sourceDataSize += content->getSerializedSize();
|
sourceDataSize += content->getSerializedSize();
|
||||||
}
|
}
|
||||||
if (header != NULL) {
|
if (header != nullptr) {
|
||||||
sourceDataSize += header->getSerializedSize();
|
sourceDataSize += header->getSerializedSize();
|
||||||
}
|
}
|
||||||
uint8_t *p_data = NULL;
|
uint8_t *pData = nullptr;
|
||||||
|
size_t sizeToReserve = getPacketMinimumSize() + sourceDataSize;
|
||||||
ReturnValue_t returnValue = store->getFreeElement(&storeAddress,
|
ReturnValue_t returnValue = store->getFreeElement(&storeAddress,
|
||||||
(getPacketMinimumSize() + sourceDataSize), &p_data);
|
sizeToReserve, &pData);
|
||||||
if (returnValue != store->RETURN_OK) {
|
if (returnValue != store->RETURN_OK) {
|
||||||
TmPacketStoredBase::checkAndReportLostTm();
|
handleStoreFailure("A", returnValue, sizeToReserve);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
setData(p_data);
|
setData(pData);
|
||||||
initializeTmPacket(apid, service, subservice, packetSubcounter);
|
initializeTmPacket(apid, service, subservice, packetSubcounter);
|
||||||
uint8_t *putDataHere = getSourceData();
|
uint8_t *putDataHere = getSourceData();
|
||||||
size_t size = 0;
|
size_t size = 0;
|
||||||
if (header != NULL) {
|
if (header != nullptr) {
|
||||||
header->serialize(&putDataHere, &size, sourceDataSize,
|
header->serialize(&putDataHere, &size, sourceDataSize,
|
||||||
SerializeIF::Endianness::BIG);
|
SerializeIF::Endianness::BIG);
|
||||||
}
|
}
|
||||||
if (content != NULL) {
|
if (content != nullptr) {
|
||||||
content->serialize(&putDataHere, &size, sourceDataSize,
|
content->serialize(&putDataHere, &size, sourceDataSize,
|
||||||
SerializeIF::Endianness::BIG);
|
SerializeIF::Endianness::BIG);
|
||||||
}
|
}
|
||||||
setPacketDataLength(
|
setPacketDataLength(sourceDataSize + sizeof(PUSTmDataFieldHeaderPusA) + CRC_SIZE - 1);
|
||||||
sourceDataSize + sizeof(PUSTmDataFieldHeaderPusA) + CRC_SIZE - 1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t* TmPacketStoredPusA::getAllTmData() {
|
uint8_t* TmPacketStoredPusA::getAllTmData() {
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
* packets in a store with the help of a storeAddress.
|
* packets in a store with the help of a storeAddress.
|
||||||
* @ingroup tmtcpackets
|
* @ingroup tmtcpackets
|
||||||
*/
|
*/
|
||||||
class TmPacketStoredPusA :
|
class TmPacketStoredPusA:
|
||||||
public TmPacketStoredBase,
|
public TmPacketStoredBase,
|
||||||
public TmPacketPusA {
|
public TmPacketPusA {
|
||||||
public:
|
public:
|
||||||
|
@ -19,19 +19,19 @@ TmPacketStoredPusC::TmPacketStoredPusC(uint16_t apid, uint8_t service,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
uint8_t *pData = nullptr;
|
uint8_t *pData = nullptr;
|
||||||
|
size_t sizeToReserve = getPacketMinimumSize() + size + headerSize;
|
||||||
ReturnValue_t returnValue = store->getFreeElement(&storeAddress,
|
ReturnValue_t returnValue = store->getFreeElement(&storeAddress,
|
||||||
(getPacketMinimumSize() + size + headerSize), &pData);
|
sizeToReserve, &pData);
|
||||||
|
|
||||||
if (returnValue != store->RETURN_OK) {
|
if (returnValue != store->RETURN_OK) {
|
||||||
TmPacketStoredBase::checkAndReportLostTm();
|
handleStoreFailure("C", returnValue, sizeToReserve);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
setData(pData);
|
setData(pData);
|
||||||
initializeTmPacket(apid, service, subservice, packetSubcounter, destinationId, timeRefField);
|
initializeTmPacket(apid, service, subservice, packetSubcounter, destinationId, timeRefField);
|
||||||
memcpy(getSourceData(), headerData, headerSize);
|
memcpy(getSourceData(), headerData, headerSize);
|
||||||
memcpy(getSourceData() + headerSize, data, size);
|
memcpy(getSourceData() + headerSize, data, size);
|
||||||
setPacketDataLength(
|
setPacketDataLength(size + headerSize + sizeof(PUSTmDataFieldHeaderPusC) + CRC_SIZE - 1);
|
||||||
size + headerSize + sizeof(PUSTmDataFieldHeaderPusC) + CRC_SIZE - 1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TmPacketStoredPusC::TmPacketStoredPusC(uint16_t apid, uint8_t service,
|
TmPacketStoredPusC::TmPacketStoredPusC(uint16_t apid, uint8_t service,
|
||||||
@ -53,34 +53,7 @@ TmPacketStoredPusC::TmPacketStoredPusC(uint16_t apid, uint8_t service,
|
|||||||
size_t sizeToReserve = getPacketMinimumSize() + sourceDataSize;
|
size_t sizeToReserve = getPacketMinimumSize() + sourceDataSize;
|
||||||
ReturnValue_t returnValue = store->getFreeElement(&storeAddress, sizeToReserve, &pData);
|
ReturnValue_t returnValue = store->getFreeElement(&storeAddress, sizeToReserve, &pData);
|
||||||
if (returnValue != store->RETURN_OK) {
|
if (returnValue != store->RETURN_OK) {
|
||||||
#if FSFW_VERBOSE_LEVEL >= 1
|
handleStoreFailure("C", returnValue, sizeToReserve);
|
||||||
switch(returnValue) {
|
|
||||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
|
||||||
case(StorageManagerIF::DATA_STORAGE_FULL): {
|
|
||||||
sif::warning << "TmPacketStoredPusC::TmPacketStoredPusC: Store full for packet with "
|
|
||||||
"size " << sizeToReserve << std::endl;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case(StorageManagerIF::DATA_TOO_LARGE): {
|
|
||||||
sif::warning << "TmPacketStoredPusC::TmPacketStoredPusC: Data with size " <<
|
|
||||||
sizeToReserve << " too large" << std::endl;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
case(StorageManagerIF::DATA_STORAGE_FULL): {
|
|
||||||
sif::printWarning("TmPacketStoredPusC::TmPacketStoredPusC: Store full for packet with "
|
|
||||||
"size %d\n", sizeToReserve);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case(StorageManagerIF::DATA_TOO_LARGE): {
|
|
||||||
sif::printWarning("TmPacketStoredPusC::TmPacketStoredPusC: Data with size "
|
|
||||||
"%d too large\n", sizeToReserve);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
TmPacketStoredBase::checkAndReportLostTm();
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
setData(pData);
|
setData(pData);
|
||||||
|
Loading…
Reference in New Issue
Block a user