taken over some changes

This commit is contained in:
2020-10-28 19:27:00 +01:00
parent e7210a34f9
commit 90bdb844e7
8 changed files with 243 additions and 252 deletions

View File

@ -1,32 +1,34 @@
#include "TcPacketStored.h"
#include "../../objectmanager/ObjectManagerIF.h"
#include "../../serviceinterface/ServiceInterfaceStream.h"
#include "../../tmtcpacket/pus/TcPacketStored.h"
#include <cstring>
StorageManagerIF* TcPacketStored::store = nullptr;
TcPacketStored::TcPacketStored(store_address_t setAddress) :
TcPacketBase(nullptr), storeAddress(setAddress) {
this->setStoreAddress(this->storeAddress);
setStoreAddress(storeAddress);
}
TcPacketStored::TcPacketStored(uint8_t service, uint8_t subservice,
uint16_t apid, uint8_t sequence_count, const uint8_t* data,
size_t size, uint8_t ack ) :
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 (!this->checkAndSetStore()) {
if (not this->checkAndSetStore()) {
return;
}
uint8_t* p_data = nullptr;
uint8_t* pData = nullptr;
ReturnValue_t returnValue = this->store->getFreeElement(&this->storeAddress,
(TC_PACKET_MIN_SIZE + size), &p_data);
if (returnValue != HasReturnvaluesIF::RETURN_OK) {
sif::warning << "TcPacketStored::TcPacketStored: Could not get "
"free element from store!" << std::endl;
(TC_PACKET_MIN_SIZE + size), &pData);
if (returnValue != this->store->RETURN_OK) {
sif::warning << "TcPacketStored: Could not get free element from store!"
<< std::endl;
return;
}
this->setData(p_data);
initializeTcPacket(apid, sequence_count, ack, service, subservice);
this->setData(pData);
initializeTcPacket(apid, sequenceCount, ack, service, subservice);
memcpy(&tcData->appData, data, size);
this->setPacketDataLength(
size + sizeof(PUSTcDataFieldHeader) + CRC_SIZE - 1);
@ -42,8 +44,7 @@ ReturnValue_t TcPacketStored::getData(const uint8_t ** dataPtr,
return result;
}
TcPacketStored::TcPacketStored() :
TcPacketBase(NULL) {
TcPacketStored::TcPacketStored(): TcPacketBase(nullptr) {
this->storeAddress.raw = StorageManagerIF::INVALID_ADDRESS;
this->checkAndSetStore();
@ -52,7 +53,7 @@ TcPacketStored::TcPacketStored() :
ReturnValue_t TcPacketStored::deletePacket() {
ReturnValue_t result = this->store->deleteData(this->storeAddress);
this->storeAddress.raw = StorageManagerIF::INVALID_ADDRESS;
this->setData( NULL);
this->setData(nullptr);
return result;
}
@ -70,17 +71,17 @@ bool TcPacketStored::checkAndSetStore() {
void TcPacketStored::setStoreAddress(store_address_t setAddress) {
this->storeAddress = setAddress;
const uint8_t* temp_data = NULL;
const uint8_t* tempData = nullptr;
size_t temp_size;
ReturnValue_t status = StorageManagerIF::RETURN_FAILED;
if (this->checkAndSetStore()) {
status = this->store->getData(this->storeAddress, &temp_data,
status = this->store->getData(this->storeAddress, &tempData,
&temp_size);
}
if (status == StorageManagerIF::RETURN_OK) {
this->setData(temp_data);
this->setData(tempData);
} else {
this->setData(NULL);
this->setData(nullptr);
this->storeAddress.raw = StorageManagerIF::INVALID_ADDRESS;
}
}
@ -90,7 +91,7 @@ store_address_t TcPacketStored::getStoreAddress() {
}
bool TcPacketStored::isSizeCorrect() {
const uint8_t* temp_data = NULL;
const uint8_t* temp_data = nullptr;
size_t temp_size;
ReturnValue_t status = this->store->getData(this->storeAddress, &temp_data,
&temp_size);
@ -102,8 +103,6 @@ bool TcPacketStored::isSizeCorrect() {
return false;
}
StorageManagerIF* TcPacketStored::store = NULL;
TcPacketStored::TcPacketStored(const uint8_t* data, uint32_t size) :
TcPacketBase(data) {
if (getFullSize() != size) {
@ -112,7 +111,7 @@ TcPacketStored::TcPacketStored(const uint8_t* data, uint32_t size) :
if (this->checkAndSetStore()) {
ReturnValue_t status = store->addData(&storeAddress, data, size);
if (status != HasReturnvaluesIF::RETURN_OK) {
this->setData(NULL);
this->setData(nullptr);
}
}
}