WIP: somethings wrong.. #19
@ -6,10 +6,11 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <framework/datapool/PoolRawAccessHelper.h>
|
#include <framework/datapool/PoolRawAccessHelper.h>
|
||||||
|
#include <framework/datapool/DataSet.h>
|
||||||
|
|
||||||
PoolRawAccessHelper::PoolRawAccessHelper(DataSet *dataSet_,
|
PoolRawAccessHelper::PoolRawAccessHelper(uint8_t * poolIdBuffer_,
|
||||||
const uint8_t * poolIdBuffer_, uint8_t numberOfParameters_):
|
uint8_t numberOfParameters_):
|
||||||
dataSet(dataSet_), poolIdBuffer(poolIdBuffer_),
|
poolIdBuffer(poolIdBuffer_),
|
||||||
numberOfParameters(numberOfParameters_), validBufferIndex(0), validBufferIndexBit(1){
|
numberOfParameters(numberOfParameters_), validBufferIndex(0), validBufferIndexBit(1){
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -19,52 +20,61 @@ PoolRawAccessHelper::~PoolRawAccessHelper() {
|
|||||||
ReturnValue_t PoolRawAccessHelper::serialize(uint8_t **buffer, uint32_t *size,
|
ReturnValue_t PoolRawAccessHelper::serialize(uint8_t **buffer, uint32_t *size,
|
||||||
const uint32_t max_size, bool bigEndian) {
|
const uint32_t max_size, bool bigEndian) {
|
||||||
ReturnValue_t result;
|
ReturnValue_t result;
|
||||||
const uint8_t ** pPoolIdBuffer = &poolIdBuffer;
|
|
||||||
int32_t remainingParametersSize = numberOfParameters * 4;
|
int32_t remainingParametersSize = numberOfParameters * 4;
|
||||||
for(uint8_t count=0; count < numberOfParameters; count++) {
|
for(uint8_t count=0; count < numberOfParameters; count++) {
|
||||||
result = serializeCurrentPoolEntryIntoBuffer(pPoolIdBuffer,buffer,
|
result = serializeCurrentPoolEntryIntoBuffer(buffer,
|
||||||
&remainingParametersSize,size,max_size, bigEndian, false);
|
&remainingParametersSize,size,max_size, bigEndian, false);
|
||||||
if(result != RETURN_OK) {
|
if(result != RETURN_OK) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return RETURN_OK;
|
if(remainingParametersSize != 0) {
|
||||||
|
debug << "Pool Raw Access: Remaining parameters size not 0 !" << std::endl;
|
||||||
|
result = RETURN_FAILED;
|
||||||
|
}
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
ReturnValue_t PoolRawAccessHelper::serializeWithValidityMask(uint8_t **buffer,
|
ReturnValue_t PoolRawAccessHelper::serializeWithValidityMask(uint8_t **buffer,
|
||||||
uint32_t *size, const uint32_t max_size, bool bigEndian) {
|
uint32_t *size, const uint32_t max_size, bool bigEndian) {
|
||||||
ReturnValue_t result;
|
ReturnValue_t result;
|
||||||
const uint8_t ** pPoolIdBuffer = &poolIdBuffer;
|
|
||||||
int32_t remainingParametersSize = numberOfParameters * 4;
|
int32_t remainingParametersSize = numberOfParameters * 4;
|
||||||
uint8_t validityMaskSize = numberOfParameters/8;
|
uint8_t validityMaskSize = numberOfParameters/8;
|
||||||
uint8_t validityMask[validityMaskSize];
|
uint8_t validityMask[validityMaskSize];
|
||||||
memset(validityMask,0, validityMaskSize);
|
memset(validityMask,0, validityMaskSize);
|
||||||
for(uint8_t count=0; count < numberOfParameters; count++) {
|
for(uint8_t count = 0; count < numberOfParameters; count++) {
|
||||||
result = serializeCurrentPoolEntryIntoBuffer(pPoolIdBuffer,buffer,
|
result = serializeCurrentPoolEntryIntoBuffer(buffer,
|
||||||
&remainingParametersSize,size,max_size, bigEndian,true,validityMask);
|
&remainingParametersSize,size,max_size, bigEndian,true,validityMask);
|
||||||
if (result != RETURN_OK) {
|
if (result != RETURN_OK) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if(remainingParametersSize != 0) {
|
||||||
|
debug << "Pool Raw Access: Remaining parameters size not 0 !" << std::endl;
|
||||||
|
result = RETURN_FAILED;
|
||||||
|
}
|
||||||
memcpy(*buffer + *size, validityMask, validityMaskSize);
|
memcpy(*buffer + *size, validityMask, validityMaskSize);
|
||||||
*size += validityMaskSize;
|
*size += validityMaskSize;
|
||||||
validBufferIndex = 1;
|
validBufferIndex = 1;
|
||||||
validBufferIndexBit = 0;
|
validBufferIndexBit = 0;
|
||||||
return RETURN_OK;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
ReturnValue_t PoolRawAccessHelper::serializeCurrentPoolEntryIntoBuffer(const uint8_t ** pPoolIdBuffer,
|
ReturnValue_t PoolRawAccessHelper::serializeCurrentPoolEntryIntoBuffer(uint8_t ** buffer,
|
||||||
uint8_t ** buffer, int32_t * remainingParameters, uint32_t * hkDataSize,
|
int32_t * remainingParameters, uint32_t * hkDataSize,
|
||||||
const uint32_t max_size, bool bigEndian, bool withValidMask, uint8_t * validityMask) {
|
const uint32_t max_size, bool bigEndian, bool withValidMask, uint8_t * validityMask) {
|
||||||
uint32_t currentPoolId;
|
uint32_t currentPoolId;
|
||||||
|
DataSet currentDataSet = DataSet();
|
||||||
// Deserialize current pool ID from pool ID buffer
|
// Deserialize current pool ID from pool ID buffer
|
||||||
ReturnValue_t result = AutoSerializeAdapter::deSerialize(¤tPoolId,
|
ReturnValue_t result = AutoSerializeAdapter::deSerialize(¤tPoolId,
|
||||||
pPoolIdBuffer,remainingParameters,true);
|
&poolIdBuffer,remainingParameters,true);
|
||||||
if(result != RETURN_OK) {
|
if(result != RETURN_OK) {
|
||||||
debug << std::hex << "Pool Raw Access Helper: Error deSeralizing pool IDs" << std::dec << std::endl;
|
debug << std::hex << "Pool Raw Access Helper: Error deSeralizing pool IDs" << std::dec << std::endl;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
PoolRawAccess currentPoolRawAccess(currentPoolId,0,dataSet,PoolVariableIF::VAR_READ);
|
|
||||||
|
// info << "Pool Raw Access Helper: Handling Pool ID: " << std::hex << currentPoolId << std::endl;
|
||||||
|
PoolRawAccess currentPoolRawAccess(currentPoolId,0,¤tDataSet,PoolVariableIF::VAR_READ);
|
||||||
|
|
||||||
// set valid mask bit if necessary
|
// set valid mask bit if necessary
|
||||||
if(withValidMask) {
|
if(withValidMask) {
|
||||||
@ -79,12 +89,12 @@ ReturnValue_t PoolRawAccessHelper::serializeCurrentPoolEntryIntoBuffer(const uin
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
result = dataSet->read();
|
result = currentDataSet.read();
|
||||||
if (result != RETURN_OK) {
|
if (result != RETURN_OK) {
|
||||||
debug << std::hex << "Pool Raw Access Helper: Error read raw dataset" << std::dec << std::endl;
|
debug << std::hex << "Pool Raw Access Helper: Error read raw dataset" << std::dec << std::endl;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
result = dataSet->serialize(buffer, hkDataSize,
|
result = currentDataSet.serialize(buffer, hkDataSize,
|
||||||
max_size, bigEndian);
|
max_size, bigEndian);
|
||||||
if (result != RETURN_OK) {
|
if (result != RETURN_OK) {
|
||||||
debug << "Pool Raw Access Helper: Error serializing pool data into send buffer" << std::endl;
|
debug << "Pool Raw Access Helper: Error serializing pool data into send buffer" << std::endl;
|
||||||
|
@ -28,8 +28,7 @@ public:
|
|||||||
* @param poolIdBuffer_ A buffer of uint32_t pool IDs
|
* @param poolIdBuffer_ A buffer of uint32_t pool IDs
|
||||||
* @param numberOfParameters_ The number of parameters / pool IDs
|
* @param numberOfParameters_ The number of parameters / pool IDs
|
||||||
*/
|
*/
|
||||||
PoolRawAccessHelper(DataSet * dataSet_, const uint8_t * poolIdBuffer_,
|
PoolRawAccessHelper(uint8_t * poolIdBuffer_, uint8_t numberOfParameters_);
|
||||||
uint8_t numberOfParameters_);
|
|
||||||
virtual ~PoolRawAccessHelper();
|
virtual ~PoolRawAccessHelper();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -60,7 +59,7 @@ public:
|
|||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
DataSet * dataSet;
|
// DataSet * dataSet;
|
||||||
const uint8_t * poolIdBuffer;
|
const uint8_t * poolIdBuffer;
|
||||||
uint8_t numberOfParameters;
|
uint8_t numberOfParameters;
|
||||||
|
|
||||||
@ -79,7 +78,7 @@ private:
|
|||||||
* @param validityMask Can be supplied and will be set if @c withValidMask is set to true
|
* @param validityMask Can be supplied and will be set if @c withValidMask is set to true
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
ReturnValue_t serializeCurrentPoolEntryIntoBuffer(const uint8_t ** pPoolIdBuffer,uint8_t ** buffer,
|
ReturnValue_t serializeCurrentPoolEntryIntoBuffer(uint8_t ** buffer,
|
||||||
int32_t * remainingParameters, uint32_t * hkDataSize,const uint32_t max_size,
|
int32_t * remainingParameters, uint32_t * hkDataSize,const uint32_t max_size,
|
||||||
bool bigEndian, bool withValidMask = false, uint8_t * validityMask = NULL);
|
bool bigEndian, bool withValidMask = false, uint8_t * validityMask = NULL);
|
||||||
|
|
||||||
|
@ -89,23 +89,24 @@ MessageQueueId_t MessageQueue::getDefaultDestination() const {
|
|||||||
bool MessageQueue::isDefaultDestinationSet() const {
|
bool MessageQueue::isDefaultDestinationSet() const {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
ReturnValue_t MessageQueue::sendMessageFromMessageQueue(MessageQueueId_t sendTo,
|
ReturnValue_t MessageQueue::sendMessageFromMessageQueue(MessageQueueId_t sendTo,
|
||||||
MessageQueueMessage *message, MessageQueueId_t sentFrom,
|
MessageQueueMessage *message, MessageQueueId_t sentFrom,
|
||||||
bool ignoreFault) {
|
bool ignoreFault) {
|
||||||
message->setSender(sentFrom);
|
message->setSender(sentFrom);
|
||||||
|
|
||||||
BaseType_t result = xQueueSendToBack(reinterpret_cast<void*>(sendTo),reinterpret_cast<const void*>(message->getBuffer()), 0);
|
BaseType_t result = xQueueSendToBack(reinterpret_cast<void*>(sendTo),reinterpret_cast<const void*>(message->getBuffer()), 0);
|
||||||
if (result != pdPASS) {
|
if (result != pdPASS) {
|
||||||
if (!ignoreFault) {
|
if (!ignoreFault) {
|
||||||
InternalErrorReporterIF* internalErrorReporter = objectManager->get<InternalErrorReporterIF>(
|
InternalErrorReporterIF* internalErrorReporter = objectManager->get<InternalErrorReporterIF>(
|
||||||
objects::INTERNAL_ERROR_REPORTER);
|
objects::INTERNAL_ERROR_REPORTER);
|
||||||
if (internalErrorReporter != NULL) {
|
if (internalErrorReporter != NULL) {
|
||||||
internalErrorReporter->queueMessageNotSent();
|
internalErrorReporter->queueMessageNotSent();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return MessageQueueIF::FULL;
|
|
||||||
}
|
}
|
||||||
return HasReturnvaluesIF::RETURN_OK;
|
return MessageQueueIF::FULL;
|
||||||
|
}
|
||||||
|
return HasReturnvaluesIF::RETURN_OK;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
/**
|
/**
|
||||||
* @brief This adapter provides an interface to use the SerializeIF functions
|
* @brief This adapter provides an interface to use the SerializeIF functions
|
||||||
* with arbitrary template objects to facilitate and simplify the serialization of classes
|
* with arbitrary template objects to facilitate and simplify the serialization of classes
|
||||||
* with different multiple different data types into buffers vice-versa.
|
* with different multiple different data types into buffers and vice-versa.
|
||||||
* @details
|
* @details
|
||||||
* Examples:
|
* Examples:
|
||||||
* A report class is converted into a TM buffer. The report class implements a serialize functions and calls
|
* A report class is converted into a TM buffer. The report class implements a serialize functions and calls
|
||||||
@ -20,27 +20,31 @@
|
|||||||
*
|
*
|
||||||
* The AutoSerializeAdapter functions can also be used as an alternative to memcpy
|
* The AutoSerializeAdapter functions can also be used as an alternative to memcpy
|
||||||
* to retrieve data out of a buffer directly into a class variable with data type T while being able to specify endianness.
|
* to retrieve data out of a buffer directly into a class variable with data type T while being able to specify endianness.
|
||||||
* The boolean bigEndian specifies the endiness of the data to serialize or deSerialize.
|
* The boolean bigEndian specifies whether an endian swap is performed on the data before
|
||||||
|
* serialization or deserialization.
|
||||||
*
|
*
|
||||||
* If the target architecture is little endian (ARM), any data types created might
|
* If the target architecture is little endian (ARM), any data types created might
|
||||||
* have the wrong endiness if they are to be used for the FSFW.
|
* have the wrong endiness if they are to be used for the FSFW.
|
||||||
* there are three ways to retrieve data out of a buffer to be used in the FSFW to use regular aligned (big endian) data.
|
* There are three ways to retrieve data out of a buffer to be used in the FSFW
|
||||||
|
* to use regular aligned (big endian) data.
|
||||||
* This can also be applied to uint32_t and uint64_t:
|
* This can also be applied to uint32_t and uint64_t:
|
||||||
*
|
*
|
||||||
* 1. Use the AutoSerializeAdapter::deSerialize function with bool bigEndian = true:
|
* 1. Use the AutoSerializeAdapter::deSerialize function
|
||||||
* The pointer *buffer will be incremented automatically by the typeSize of data,
|
* The pointer *buffer will be incremented automatically by the typeSize of the object,
|
||||||
* so this function can be called on &buffer without adjusting pointer position
|
* so this function can be called on &buffer repeatedly without adjusting pointer position.
|
||||||
|
* Set bigEndian parameter to true to perform endian swapping.
|
||||||
*
|
*
|
||||||
* uint16_t data;
|
* uint16_t data;
|
||||||
* int32_t dataLen = sizeof(data);
|
* int32_t dataLen = sizeof(data);
|
||||||
* ReturnValue_t result = AutoSerializeAdapter::deSerialize(&data,&buffer,&dataLen,true);
|
* ReturnValue_t result = AutoSerializeAdapter::deSerialize(&data,&buffer,&dataLen,true);
|
||||||
*
|
*
|
||||||
* 2. Perform a bitshift operation:
|
* 2. Perform a bitshift operation. Perform endian swapping if necessary:
|
||||||
*
|
*
|
||||||
* uint16_t data;
|
* uint16_t data;
|
||||||
* data = buffer[targetByte1] >> 8 | buffer[targetByte2];
|
* data = buffer[targetByte1] << 8 | buffer[targetByte2];
|
||||||
|
* data = EndianSwapper::swap(data);
|
||||||
*
|
*
|
||||||
* 3. Memcpy can be used when data is little-endian. Otherwise, endian-swapper has to be used.
|
* 3. Memcpy can be used when data is little-endian. Perform endian-swapping if necessary.
|
||||||
*
|
*
|
||||||
* uint16_t data;
|
* uint16_t data;
|
||||||
* memcpy(&data,buffer + positionOfTargetByte1,sizeof(data));
|
* memcpy(&data,buffer + positionOfTargetByte1,sizeof(data));
|
||||||
@ -79,7 +83,7 @@ public:
|
|||||||
/**
|
/**
|
||||||
* Deserialize buffer into object
|
* Deserialize buffer into object
|
||||||
* @param object [out] Object to be deserialized with buffer data
|
* @param object [out] Object to be deserialized with buffer data
|
||||||
* @param buffer buffer containing the data
|
* @param buffer buffer containing the data. Non-Const pointer to non-const pointer to const buffer.
|
||||||
* @param size int32_t type to allow value to be values smaller than 0, needed for range/size checking
|
* @param size int32_t type to allow value to be values smaller than 0, needed for range/size checking
|
||||||
* @param bigEndian Specify endianness
|
* @param bigEndian Specify endianness
|
||||||
* @return
|
* @return
|
||||||
|
@ -22,6 +22,7 @@ TmPacketStored::TmPacketStored(uint16_t apid, uint8_t service,
|
|||||||
(TmPacketBase::TM_PACKET_MIN_SIZE + size + headerSize), &pData);
|
(TmPacketBase::TM_PACKET_MIN_SIZE + size + headerSize), &pData);
|
||||||
|
|
||||||
if (returnValue != store->RETURN_OK) {
|
if (returnValue != store->RETURN_OK) {
|
||||||
|
debug << "TM Packet Stored: Issue getting free storage" << std::endl;
|
||||||
checkAndReportLostTm();
|
checkAndReportLostTm();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user