fsfw/pus/servicepackets/Service20Packets.h

142 lines
4.3 KiB
C
Raw Normal View History

2021-01-30 20:29:23 +01:00
#ifndef FSFW_PUS_SERVICEPACKETS_SERVICE20PACKETS_H_
#define FSFW_PUS_SERVICEPACKETS_SERVICE20PACKETS_H_
2021-01-31 20:53:25 +01:00
#include <FSFWConfig.h>
2021-01-30 20:29:23 +01:00
#include <fsfw/parameters/HasParametersIF.h>
#include <fsfw/serialize/SerialBufferAdapter.h>
#include <fsfw/serialize/SerializeElement.h>
#include <fsfw/serialize/SerialLinkedListAdapter.h>
2021-01-31 20:53:25 +01:00
#include <fsfw/serviceinterface/ServiceInterface.h>
2021-01-30 20:29:23 +01:00
/**
2021-01-31 20:53:25 +01:00
* @brief This class encapsulates the packets sent to the PUS service 20 or sent by the
* PUS service 20
2021-01-30 20:29:23 +01:00
* @details
2021-01-31 20:53:25 +01:00
* This command can be used to handle both load and dump commands as well.
2021-01-30 20:29:23 +01:00
* @author
*/
class ParameterCommand: public SerialLinkedListAdapter<SerializeIF> { //!< [EXPORT] : [SUBSERVICE] 128, 129, 130
public:
2021-01-31 20:53:25 +01:00
/**
* This constructor is used for load replies. The data is expected in the correct formast
* in the store pointer.
* @param storePointer
* @param parameterDataLen
*/
2021-01-30 20:29:23 +01:00
ParameterCommand(uint8_t* storePointer, size_t parameterDataLen):
parameterBuffer(storePointer, parameterDataLen) {
2021-01-31 20:53:25 +01:00
#if FSFW_VERBOSE_LEVEL >= 1
2021-06-13 17:58:44 +02:00
if(parameterDataLen == 0) {
2021-01-31 20:53:25 +01:00
#if FSFW_CPP_OSTREAM_ENABLED == 1
2021-06-13 17:58:44 +02:00
sif::warning << "ParameterCommand: Parameter data length is 0" << std::endl;
2021-01-31 20:53:25 +01:00
#else
2021-06-13 17:58:44 +02:00
sif::printWarning("ParameterCommand: Parameter data length is 0!\n");
2021-01-31 20:53:25 +01:00
#endif
}
#endif /* FSFW_VERBOSE_LEVEL >= 1 */
setLoadLinks();
2021-01-30 20:29:23 +01:00
}
2021-01-31 20:53:25 +01:00
/**
* 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
*/
2021-01-30 20:29:23 +01:00
ParameterCommand(object_id_t objectId, ParameterId_t parameterId,
const uint8_t* parameterBuffer, size_t parameterBufferSize):
objectId(objectId), parameterId(parameterId),
parameterBuffer(parameterBuffer, parameterBufferSize) {
2021-01-31 20:53:25 +01:00
setDumpReplyLinks();
2021-01-30 20:29:23 +01:00
}
ParameterId_t getParameterId() const {
return parameterId.entry;
}
const uint8_t* getParameterBuffer() {
return parameterBuffer.entry.getConstBuffer();
}
size_t getParameterBufferLen() const {
return parameterBuffer.getSerializedSize();
}
2021-01-31 20:53:25 +01:00
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;
}
2021-01-30 20:29:23 +01:00
uint8_t getPtc() const {
return ccsdsType.entry >> 8 & 0xff;
}
uint8_t getPfc() const {
return ccsdsType.entry & 0xff;
}
uint8_t getRows() const {
return rows.entry;
}
uint8_t getColumns() const {
return columns.entry;
}
private:
2021-01-31 20:53:25 +01:00
void setLoadLinks() {
2021-01-30 20:29:23 +01:00
setStart(&objectId);
objectId.setNext(&parameterId);
parameterId.setNext(&ccsdsType);
ccsdsType.setNext(&rows);
rows.setNext(&columns);
columns.setNext(&parameterBuffer);
}
2021-01-31 20:53:25 +01:00
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);
}
2021-01-30 20:29:23 +01:00
SerializeElement<object_id_t> objectId = 0;
SerializeElement<ParameterId_t> parameterId = 0;
//! [EXPORT] : [COMMENT] Type consisting of one byte PTC and one byte PFC.
SerializeElement<uint16_t> ccsdsType = 0;
SerializeElement<uint8_t> rows = 0;
2021-01-31 18:27:21 +01:00
SerializeElement<uint8_t> columns = 0;
2021-01-30 20:29:23 +01:00
SerializeElement<SerialBufferAdapter<uint8_t>> parameterBuffer;
};
class ParameterLoadCommand: public ParameterCommand {
public:
ParameterLoadCommand(uint8_t* parameterPacket, size_t parameterDataLen):
2021-01-31 19:13:40 +01:00
ParameterCommand(parameterPacket, parameterDataLen) {}
2021-01-30 20:29:23 +01:00
};
class ParameterDumpReply: public ParameterCommand {
public:
ParameterDumpReply(object_id_t objectId, ParameterId_t parameterId,
const uint8_t* parameterBuffer, size_t parameterBufferSize):
2021-01-31 19:13:40 +01:00
ParameterCommand(objectId, parameterId, parameterBuffer, parameterBufferSize) {}
2021-01-30 20:29:23 +01:00
};
#endif /* FSFW_PUS_SERVICEPACKETS_SERVICE20PACKETS_H_ */