moved store failure to separate function
This commit is contained in:
parent
ecdbf98ca4
commit
155432663b
@ -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();
|
||||
|
||||
void checkAndReportLostTm();
|
||||
|
||||
void handleStoreFailure(const char* const packetType, ReturnValue_t result,
|
||||
size_t sizeToReserve);
|
||||
};
|
||||
|
||||
|
||||
|
@ -5,24 +5,25 @@
|
||||
|
||||
#include <cstring>
|
||||
|
||||
TmPacketStoredPusA::TmPacketStoredPusA(store_address_t setAddress) :
|
||||
TmPacketStoredPusA::TmPacketStoredPusA(store_address_t setAddress):
|
||||
TmPacketStoredBase(setAddress), TmPacketPusA(nullptr){
|
||||
}
|
||||
|
||||
TmPacketStoredPusA::TmPacketStoredPusA(uint16_t apid, uint8_t service,
|
||||
uint8_t subservice, uint8_t packetSubcounter, const uint8_t *data,
|
||||
uint32_t size, const uint8_t *headerData, uint32_t headerSize) :
|
||||
uint32_t size, const uint8_t *headerData, uint32_t headerSize):
|
||||
TmPacketPusA(nullptr) {
|
||||
storeAddress.raw = StorageManagerIF::INVALID_ADDRESS;
|
||||
if (not TmPacketStoredBase::checkAndSetStore()) {
|
||||
return;
|
||||
}
|
||||
uint8_t *pData = nullptr;
|
||||
size_t sizeToReserve = getPacketMinimumSize() + size + headerSize;
|
||||
ReturnValue_t returnValue = store->getFreeElement(&storeAddress,
|
||||
(getPacketMinimumSize() + size + headerSize), &pData);
|
||||
sizeToReserve, &pData);
|
||||
|
||||
if (returnValue != store->RETURN_OK) {
|
||||
TmPacketStoredBase::checkAndReportLostTm();
|
||||
handleStoreFailure("A", returnValue, sizeToReserve);
|
||||
return;
|
||||
}
|
||||
setData(pData);
|
||||
@ -53,34 +54,7 @@ TmPacketStoredPusA::TmPacketStoredPusA(uint16_t apid, uint8_t service,
|
||||
ReturnValue_t returnValue = store->getFreeElement(&storeAddress,
|
||||
sizeToReserve, &pData);
|
||||
if (returnValue != store->RETURN_OK) {
|
||||
TmPacketStoredBase::checkAndReportLostTm();
|
||||
#if FSFW_VERBOSE_LEVEL >= 1
|
||||
switch(returnValue) {
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
case(StorageManagerIF::DATA_STORAGE_FULL): {
|
||||
sif::warning << "TmPacketStoredPusA::TmPacketStoredPusC: Store full for packet with "
|
||||
"size " << sizeToReserve << std::endl;
|
||||
break;
|
||||
}
|
||||
case(StorageManagerIF::DATA_TOO_LARGE): {
|
||||
sif::warning << "TmPacketStoredPusA::TmPacketStoredPusC: Data with size " <<
|
||||
sizeToReserve << " too large" << std::endl;
|
||||
break;
|
||||
}
|
||||
#else
|
||||
case(StorageManagerIF::DATA_STORAGE_FULL): {
|
||||
sif::printWarning("TmPacketStoredPusA::TmPacketStoredPusC: Store full for packet with "
|
||||
"size %d\n", sizeToReserve);
|
||||
break;
|
||||
}
|
||||
case(StorageManagerIF::DATA_TOO_LARGE): {
|
||||
sif::printWarning("TmPacketStoredPusA::TmPacketStoredPusC: Data with size "
|
||||
"%d too large\n", sizeToReserve);
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
handleStoreFailure("A", returnValue, sizeToReserve);
|
||||
return;
|
||||
}
|
||||
setData(pData);
|
||||
|
@ -15,7 +15,7 @@
|
||||
* packets in a store with the help of a storeAddress.
|
||||
* @ingroup tmtcpackets
|
||||
*/
|
||||
class TmPacketStoredPusA :
|
||||
class TmPacketStoredPusA:
|
||||
public TmPacketStoredBase,
|
||||
public TmPacketPusA {
|
||||
public:
|
||||
|
@ -19,11 +19,12 @@ TmPacketStoredPusC::TmPacketStoredPusC(uint16_t apid, uint8_t service,
|
||||
return;
|
||||
}
|
||||
uint8_t *pData = nullptr;
|
||||
size_t sizeToReserve = getPacketMinimumSize() + size + headerSize;
|
||||
ReturnValue_t returnValue = store->getFreeElement(&storeAddress,
|
||||
(getPacketMinimumSize() + size + headerSize), &pData);
|
||||
sizeToReserve, &pData);
|
||||
|
||||
if (returnValue != store->RETURN_OK) {
|
||||
TmPacketStoredBase::checkAndReportLostTm();
|
||||
handleStoreFailure("C", returnValue, sizeToReserve);
|
||||
return;
|
||||
}
|
||||
setData(pData);
|
||||
@ -53,34 +54,7 @@ TmPacketStoredPusC::TmPacketStoredPusC(uint16_t apid, uint8_t service,
|
||||
size_t sizeToReserve = getPacketMinimumSize() + sourceDataSize;
|
||||
ReturnValue_t returnValue = store->getFreeElement(&storeAddress, sizeToReserve, &pData);
|
||||
if (returnValue != store->RETURN_OK) {
|
||||
#if FSFW_VERBOSE_LEVEL >= 1
|
||||
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();
|
||||
handleStoreFailure("C", returnValue, sizeToReserve);
|
||||
return;
|
||||
}
|
||||
setData(pData);
|
||||
|
Loading…
Reference in New Issue
Block a user