srv20 improvements and bugfixes

This commit is contained in:
Robin Müller 2021-01-31 20:53:25 +01:00
parent 4522668066
commit 5ac3762dc5
4 changed files with 64 additions and 9 deletions

View File

@ -90,7 +90,7 @@ ReturnValue_t ParameterHelper::sendParameter(MessageQueueId_t to, uint32_t id,
const ParameterWrapper* description) {
size_t serializedSize = description->getSerializedSize();
uint8_t *storeElement;
uint8_t *storeElement = nullptr;
store_address_t address;
ReturnValue_t result = storage->getFreeElement(&address, serializedSize,

View File

@ -7,13 +7,13 @@ ParameterWrapper::ParameterWrapper() :
}
ParameterWrapper::ParameterWrapper(Type type, uint8_t rows, uint8_t columns,
void *data) :
void *data):
pointsToStream(false), type(type), rows(rows), columns(columns),
data(data), readonlyData(data) {
}
ParameterWrapper::ParameterWrapper(Type type, uint8_t rows, uint8_t columns,
const void *data) :
const void *data):
pointsToStream(false), type(type), rows(rows), columns(columns),
data(nullptr), readonlyData(data) {
}
@ -42,8 +42,8 @@ ReturnValue_t ParameterWrapper::serialize(uint8_t **buffer, size_t *size,
return result;
}
//serialize uses readonlyData, as it is always valid
if (readonlyData == NULL) {
/* serialize uses readonlyData, as it is always valid */
if (readonlyData == nullptr) {
return NOT_SET;
}
switch (type) {

View File

@ -172,6 +172,7 @@ ReturnValue_t Service20ParameterManagement::handleReply(
if(parameterData.first != HasReturnvaluesIF::RETURN_OK) {
return HasReturnvaluesIF::RETURN_FAILED;
}
ParameterId_t parameterId = ParameterMessage::getParameterId(reply);
ParameterDumpReply parameterReply(objectId, parameterId,
parameterData.second.data(), parameterData.second.size());

View File

@ -1,28 +1,57 @@
#ifndef FSFW_PUS_SERVICEPACKETS_SERVICE20PACKETS_H_
#define FSFW_PUS_SERVICEPACKETS_SERVICE20PACKETS_H_
#include <FSFWConfig.h>
#include <fsfw/parameters/HasParametersIF.h>
#include <fsfw/serialize/SerialBufferAdapter.h>
#include <fsfw/serialize/SerializeElement.h>
#include <fsfw/serialize/SerialLinkedListAdapter.h>
#include <fsfw/serviceinterface/ServiceInterface.h>
/**
* @brief
* @brief This class encapsulates the packets sent to the PUS service 20 or sent by the
* PUS service 20
* @details
* This command can be used to handle both load and dump commands as well.
* @author
*/
class ParameterCommand: public SerialLinkedListAdapter<SerializeIF> { //!< [EXPORT] : [SUBSERVICE] 128, 129, 130
public:
/**
* This constructor is used for load replies. The data is expected in the correct formast
* in the store pointer.
* @param storePointer
* @param parameterDataLen
*/
ParameterCommand(uint8_t* storePointer, size_t parameterDataLen):
parameterBuffer(storePointer, parameterDataLen) {
setLinks();
#if FSFW_VERBOSE_LEVEL >= 1
if(parameterDataLen < sizeof(object_id_t) + sizeof(ParameterId_t) + 4) {
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::warning << "ParameterCommand: Parameter data length is less than 12!"
<< std::endl;
#else
sif::printWarning("ParameterCommand: Parameter data length is less than 12!\n");
#endif
}
#endif /* FSFW_VERBOSE_LEVEL >= 1 */
setLoadLinks();
}
/**
* This constructor is used for dump replies. It is assumed the 4 byte parameter
* information field is located inside the parameter buffer.
* @param objectId
* @param parameterId
* @param parameterBuffer
* @param parameterBufferSize
*/
ParameterCommand(object_id_t objectId, ParameterId_t parameterId,
const uint8_t* parameterBuffer, size_t parameterBufferSize):
objectId(objectId), parameterId(parameterId),
parameterBuffer(parameterBuffer, parameterBufferSize) {
setLinks();
setDumpReplyLinks();
}
ParameterId_t getParameterId() const {
@ -37,6 +66,18 @@ public:
return parameterBuffer.getSerializedSize();
}
uint8_t getDomainId() const {
return (parameterId.entry >> 24) & 0xff;
}
uint8_t getUniqueId() const {
return (parameterId.entry >> 16) & 0xff;
}
uint16_t getLinearIndex() const {
return parameterId.entry & 0xffff;
}
uint8_t getPtc() const {
return ccsdsType.entry >> 8 & 0xff;
}
@ -54,7 +95,7 @@ public:
}
private:
void setLinks() {
void setLoadLinks() {
setStart(&objectId);
objectId.setNext(&parameterId);
parameterId.setNext(&ccsdsType);
@ -63,6 +104,19 @@ private:
columns.setNext(&parameterBuffer);
}
void setDumpReplyLinks() {
/* For a dump reply, the parameter information is contained in the parameter buffer
with the actual parameters */
setStart(&objectId);
objectId.setNext(&parameterId);
parameterId.setNext(&parameterBuffer);
}
void setDumpRequestLinks() {
setStart(&objectId);
objectId.setNext(&parameterId);
}
SerializeElement<object_id_t> objectId = 0;
SerializeElement<ParameterId_t> parameterId = 0;
//! [EXPORT] : [COMMENT] Type consisting of one byte PTC and one byte PFC.