change PLOC/MPSOC code to using new SP code
Some checks failed
EIVE/eive-obsw/pipeline/head There was a failure building this commit

This commit is contained in:
Robin Müller 2022-08-15 17:25:16 +02:00
parent f071b7eba4
commit 0c371623c6
No known key found for this signature in database
GPG Key ID: 71B58F8A3CDFA9AC
20 changed files with 946 additions and 801 deletions

View File

@ -1,8 +1,8 @@
#include "commonConfig.h"
#include "fsfw/tmtcpacket/SpacePacket.h"
#include "fsfw/tmtcpacket/ccsds/defs.h"
#include "tmtc/apid.h"
const fsfw::Version common::OBSW_VERSION{OBSW_VERSION_MAJOR, OBSW_VERSION_MINOR,
OBSW_VERSION_REVISION, OBSW_VERSION_CST_GIT_SHA1};
const uint16_t common::PUS_PACKET_ID = spacepacket::getTcSpacePacketIdFromApid(apid::EIVE_OBSW);
const uint16_t common::PUS_PACKET_ID = ccsds::getTcSpacePacketIdFromApid(apid::EIVE_OBSW);

2
fsfw

@ -1 +1 @@
Subproject commit 007f958a0b787a572bf1bd98b348c3a632799bf7
Subproject commit 4d82d0e4c15091aceafc8279790517702d5941f4

View File

@ -6,7 +6,7 @@
#include "eive/definitions.h"
#include "fsfw/globalfunctions/CRC.h"
#include "fsfw/serialize/SerializeAdapter.h"
#include "fsfw/tmtcpacket/SpacePacket.h"
#include "mission/devices/devicedefinitions/SpBase.h"
namespace mpsoc {
@ -73,6 +73,8 @@ static const char NULL_TERMINATOR = '\0';
static const uint8_t MIN_SPACE_PACKET_LENGTH = 7;
static const uint8_t SPACE_PACKET_HEADER_SIZE = 6;
static constexpr size_t CRC_SIZE = 2;
/**
* The size of payload data which will be forwarded to the requesting object. e.g. PUS Service
* 8.
@ -88,8 +90,12 @@ static const size_t MAX_FILENAME_SIZE = 256;
static const uint16_t LENGTH_TC_MEM_WRITE = 12;
static const uint16_t LENGTH_TC_MEM_READ = 8;
static const size_t MAX_REPLY_SIZE = SpacePacket::PACKET_MAX_SIZE * 3;
static const size_t MAX_COMMAND_SIZE = SpacePacket::PACKET_MAX_SIZE;
/**
* TODO: Might be a good idea to document where this is coming from
*/
static constexpr size_t SP_MAX_SIZE = 1024;
static const size_t MAX_REPLY_SIZE = SP_MAX_SIZE * 3;
static const size_t MAX_COMMAND_SIZE = SP_MAX_SIZE;
static const size_t MAX_DATA_SIZE = 1016;
/**
@ -130,8 +136,10 @@ static const uint16_t RESERVED_4 = 0x5F4;
/**
* @brief Abstract base class for TC space packet of MPSoC.
*/
class TcBase : public SpacePacket, public MPSoCReturnValuesIF {
class TcBase : public SpacePacketBase, public MPSoCReturnValuesIF {
public:
virtual ~TcBase() = default;
// Initial length field of space packet. Will always be updated when packet is created.
static const uint16_t INIT_LENGTH = 1;
@ -141,8 +149,12 @@ class TcBase : public SpacePacket, public MPSoCReturnValuesIF {
* @param sequenceCount Sequence count of space packet which will be incremented with each
* sent and received packets.
*/
TcBase(uint16_t apid, uint16_t sequenceCount)
: SpacePacket(INIT_LENGTH, true, apid, sequenceCount) {}
TcBase(SpBaseParams params, uint16_t apid, uint16_t sequenceCount)
: SpacePacketBase(params, apid, sequenceCount) {
spParams.setDataFieldLen(INIT_LENGTH);
}
ReturnValue_t buildPacket() { return buildPacket(nullptr, 0); }
/**
* @brief Function to initialize the space packet
@ -152,17 +164,22 @@ class TcBase : public SpacePacket, public MPSoCReturnValuesIF {
*
* @return RETURN_OK if packet creation was successful, otherwise error return value
*/
virtual ReturnValue_t createPacket(const uint8_t* commandData, size_t commandDataLen) {
ReturnValue_t result = HasReturnvaluesIF::RETURN_OK;
result = initPacket(commandData, commandDataLen);
if (result != HasReturnvaluesIF::RETURN_OK) {
return result;
ReturnValue_t buildPacket(const uint8_t* commandData, size_t commandDataLen) {
payloadStart = spParams.buf + ccsds::HEADER_LEN;
ReturnValue_t res;
if (commandData != nullptr and commandDataLen > 0) {
res = initPacket(commandData, commandDataLen);
if (res != result::OK) {
return res;
}
result = addCrc();
if (result != HasReturnvaluesIF::RETURN_OK) {
return result;
}
return result;
updateFields();
res = checkSizeAndSerializeHeader();
if (res != result::OK) {
return res;
}
return calcCrc();
}
protected:
@ -175,23 +192,6 @@ class TcBase : public SpacePacket, public MPSoCReturnValuesIF {
virtual ReturnValue_t initPacket(const uint8_t* commandData, size_t commandDataLen) {
return HasReturnvaluesIF::RETURN_OK;
}
/**
* @brief Calculates and adds the CRC
*/
ReturnValue_t addCrc() {
ReturnValue_t result = HasReturnvaluesIF::RETURN_OK;
size_t serializedSize = 0;
uint32_t full_size = getFullSize();
uint16_t crc = CRC::crc16ccitt(getWholeData(), full_size - CRC_SIZE);
result = SerializeAdapter::serialize<uint16_t>(
&crc, this->localData.byteStream + full_size - CRC_SIZE, &serializedSize, sizeof(crc),
SerializeIF::Endianness::BIG);
if (result != HasReturnvaluesIF::RETURN_OK) {
sif::debug << "TcBase::addCrc: Failed to serialize crc field" << std::endl;
}
return result;
}
};
/**
@ -224,22 +224,22 @@ class TcMemRead : public TcBase {
/**
* @brief Constructor
*/
TcMemRead(uint16_t sequenceCount) : TcBase(apid::TC_MEM_READ, sequenceCount) {
this->setPacketDataLength(PACKET_LENGTH);
TcMemRead(SpBaseParams params, uint16_t sequenceCount)
: TcBase(params, apid::TC_MEM_READ, sequenceCount) {
spParams.setPayloadLen(COMMAND_LENGTH);
}
uint16_t getMemLen() const { return memLen; }
protected:
ReturnValue_t initPacket(const uint8_t* commandData, size_t commandDataLen) {
ReturnValue_t initPacket(const uint8_t* commandData, size_t commandDataLen) override {
ReturnValue_t result = HasReturnvaluesIF::RETURN_OK;
result = lengthCheck(commandDataLen);
if (result != HasReturnvaluesIF::RETURN_OK) {
return result;
}
std::memcpy(this->localData.fields.buffer, commandData, MEM_ADDRESS_SIZE);
std::memcpy(this->localData.fields.buffer + MEM_ADDRESS_SIZE, commandData + MEM_ADDRESS_SIZE,
MEM_LEN_SIZE);
std::memcpy(payloadStart, commandData, MEM_ADDRESS_SIZE);
std::memcpy(payloadStart + MEM_ADDRESS_SIZE, commandData + MEM_ADDRESS_SIZE, MEM_LEN_SIZE);
size_t size = sizeof(memLen);
const uint8_t* memLenPtr = commandData + MEM_ADDRESS_SIZE;
result =
@ -247,6 +247,7 @@ class TcMemRead : public TcBase {
if (result != HasReturnvaluesIF::RETURN_OK) {
return result;
}
spParams.setPayloadLen(MEM_ADDRESS_SIZE + MEM_LEN_SIZE);
return result;
}
@ -275,19 +276,21 @@ class TcMemWrite : public TcBase {
/**
* @brief Constructor
*/
TcMemWrite(uint16_t sequenceCount) : TcBase(apid::TC_MEM_WRITE, sequenceCount) {}
TcMemWrite(SpBaseParams params, uint16_t sequenceCount)
: TcBase(params, apid::TC_MEM_WRITE, sequenceCount) {}
protected:
ReturnValue_t initPacket(const uint8_t* commandData, size_t commandDataLen) {
// TODO: Confusing, recheck..
ReturnValue_t initPacket(const uint8_t* commandData, size_t commandDataLen) override {
ReturnValue_t result = HasReturnvaluesIF::RETURN_OK;
result = lengthCheck(commandDataLen);
if (result != HasReturnvaluesIF::RETURN_OK) {
return result;
}
std::memcpy(this->localData.fields.buffer, commandData, commandDataLen);
std::memcpy(payloadStart, commandData, commandDataLen);
uint16_t memLen =
*(commandData + MEM_ADDRESS_SIZE) << 8 | *(commandData + MEM_ADDRESS_SIZE + 1);
this->setPacketDataLength(memLen * 4 + FIX_LENGTH - 1);
spParams.setPayloadLen(FIX_LENGTH + memLen * 4);
return result;
}
@ -309,9 +312,10 @@ class TcMemWrite : public TcBase {
/**
* @brief Class to help creation of flash fopen command.
*/
class FlashFopen : public TcBase {
class FlashFopen : public SpacePacketBase {
public:
FlashFopen(uint16_t sequenceCount) : TcBase(apid::TC_FLASHFOPEN, sequenceCount) {}
FlashFopen(SpBaseParams params, uint16_t sequenceCount)
: SpacePacketBase(params, apid::TC_FLASHFOPEN, sequenceCount) {}
static const char APPEND = 'a';
static const char WRITE = 'w';
@ -321,17 +325,12 @@ class FlashFopen : public TcBase {
accessMode = accessMode_;
ReturnValue_t result = HasReturnvaluesIF::RETURN_OK;
size_t nameSize = filename.size();
std::memcpy(this->getPacketData(), filename.c_str(), nameSize);
*(this->getPacketData() + nameSize) = NULL_TERMINATOR;
std::memcpy(this->getPacketData() + nameSize + sizeof(NULL_TERMINATOR), &accessMode,
sizeof(accessMode));
this->setPacketDataLength(nameSize + sizeof(NULL_TERMINATOR) + sizeof(accessMode) + CRC_SIZE -
1);
result = addCrc();
if (result != HasReturnvaluesIF::RETURN_OK) {
return result;
}
return result;
std::memcpy(payloadStart, filename.c_str(), nameSize);
*(spParams.buf + nameSize) = NULL_TERMINATOR;
std::memcpy(payloadStart + nameSize + sizeof(NULL_TERMINATOR), &accessMode, sizeof(accessMode));
spParams.setPayloadLen(nameSize + sizeof(NULL_TERMINATOR) + sizeof(accessMode));
updateFields();
return calcCrc();
}
private:
@ -343,28 +342,25 @@ class FlashFopen : public TcBase {
*/
class FlashFclose : public TcBase {
public:
FlashFclose(uint16_t sequenceCount) : TcBase(apid::TC_FLASHFCLOSE, sequenceCount) {}
FlashFclose(SpBaseParams params, uint16_t sequenceCount)
: TcBase(params, apid::TC_FLASHFCLOSE, sequenceCount) {}
ReturnValue_t createPacket(std::string filename) {
ReturnValue_t result = HasReturnvaluesIF::RETURN_OK;
size_t nameSize = filename.size();
std::memcpy(this->getPacketData(), filename.c_str(), nameSize);
*(this->getPacketData() + nameSize) = NULL_TERMINATOR;
this->setPacketDataLength(nameSize + sizeof(NULL_TERMINATOR) + CRC_SIZE - 1);
result = addCrc();
if (result != HasReturnvaluesIF::RETURN_OK) {
return result;
}
return result;
std::memcpy(payloadStart, filename.c_str(), nameSize);
*(payloadStart + nameSize) = NULL_TERMINATOR;
spParams.setPayloadLen(nameSize + sizeof(NULL_TERMINATOR));
return calcCrc();
}
};
/**
* @brief Class to build flash write space packet.
*/
class TcFlashWrite : public TcBase {
class TcFlashWrite : public SpacePacketBase {
public:
TcFlashWrite(uint16_t sequenceCount) : TcBase(apid::TC_FLASHWRITE, sequenceCount) {}
TcFlashWrite(SpBaseParams params, uint16_t sequenceCount)
: SpacePacketBase(params, apid::TC_FLASHWRITE, sequenceCount) {}
ReturnValue_t createPacket(const uint8_t* writeData, uint32_t writeLen_) {
ReturnValue_t result = HasReturnvaluesIF::RETURN_OK;
@ -374,19 +370,19 @@ class TcFlashWrite : public TcBase {
return HasReturnvaluesIF::RETURN_FAILED;
}
size_t serializedSize = 0;
result =
SerializeAdapter::serialize<uint32_t>(&writeLen, this->getPacketData(), &serializedSize,
sizeof(writeLen), SerializeIF::Endianness::BIG);
result = SerializeAdapter::serialize(&writeLen, payloadStart, &serializedSize, sizeof(writeLen),
SerializeIF::Endianness::BIG);
if (result != HasReturnvaluesIF::RETURN_OK) {
return result;
}
std::memcpy(this->getPacketData() + sizeof(writeLen), writeData, writeLen);
this->setPacketDataLength(static_cast<uint16_t>(writeLen + CRC_SIZE - 1));
result = addCrc();
if (result != HasReturnvaluesIF::RETURN_OK) {
return result;
std::memcpy(payloadStart + sizeof(writeLen), writeData, writeLen);
spParams.setPayloadLen(static_cast<uint16_t>(writeLen) + 4);
updateFields();
auto res = checkSizeAndSerializeHeader();
if (res != result::OK) {
return res;
}
return HasReturnvaluesIF::RETURN_OK;
return calcCrc();
}
private:
@ -396,21 +392,23 @@ class TcFlashWrite : public TcBase {
/**
* @brief Class to help creation of flash delete command.
*/
class TcFlashDelete : public TcBase {
class TcFlashDelete : public SpacePacketBase {
public:
TcFlashDelete(uint16_t sequenceCount) : TcBase(apid::TC_FLASHDELETE, sequenceCount) {}
TcFlashDelete(SpBaseParams params, uint16_t sequenceCount)
: SpacePacketBase(params, apid::TC_FLASHDELETE, sequenceCount) {}
ReturnValue_t createPacket(std::string filename) {
ReturnValue_t buildPacket(std::string filename) {
ReturnValue_t result = HasReturnvaluesIF::RETURN_OK;
size_t nameSize = filename.size();
std::memcpy(this->getPacketData(), filename.c_str(), nameSize);
*(this->getPacketData() + nameSize) = NULL_TERMINATOR;
this->setPacketDataLength(nameSize + sizeof(NULL_TERMINATOR) + CRC_SIZE - 1);
result = addCrc();
if (result != HasReturnvaluesIF::RETURN_OK) {
return result;
std::memcpy(payloadStart, filename.c_str(), nameSize);
*(payloadStart + nameSize) = NULL_TERMINATOR;
spParams.setPayloadLen(nameSize + sizeof(NULL_TERMINATOR));
updateFields();
auto res = checkSizeAndSerializeHeader();
if (res != result::OK) {
return res;
}
return result;
return calcCrc();
}
};
@ -419,17 +417,8 @@ class TcFlashDelete : public TcBase {
*/
class TcReplayStop : public TcBase {
public:
TcReplayStop(uint16_t sequenceCount) : TcBase(apid::TC_REPLAY_STOP, sequenceCount) {}
ReturnValue_t createPacket() {
ReturnValue_t result = HasReturnvaluesIF::RETURN_OK;
result = addCrc();
if (result != HasReturnvaluesIF::RETURN_OK) {
return result;
}
this->setPacketDataLength(static_cast<uint16_t>(CRC_SIZE - 1));
return HasReturnvaluesIF::RETURN_OK;
}
TcReplayStop(SpBaseParams params, uint16_t sequenceCount)
: TcBase(params, apid::TC_REPLAY_STOP, sequenceCount) {}
};
/**
@ -440,10 +429,11 @@ class TcReplayStart : public TcBase {
/**
* @brief Constructor
*/
TcReplayStart(uint16_t sequenceCount) : TcBase(apid::TC_REPLAY_START, sequenceCount) {}
TcReplayStart(SpBaseParams params, uint16_t sequenceCount)
: TcBase(params, apid::TC_REPLAY_START, sequenceCount) {}
protected:
ReturnValue_t initPacket(const uint8_t* commandData, size_t commandDataLen) {
ReturnValue_t initPacket(const uint8_t* commandData, size_t commandDataLen) override {
ReturnValue_t result = HasReturnvaluesIF::RETURN_OK;
result = lengthCheck(commandDataLen);
if (result != HasReturnvaluesIF::RETURN_OK) {
@ -453,8 +443,8 @@ class TcReplayStart : public TcBase {
if (result != HasReturnvaluesIF::RETURN_OK) {
return result;
}
std::memcpy(this->localData.fields.buffer, commandData, commandDataLen);
this->setPacketDataLength(commandDataLen + CRC_SIZE - 1);
std::memcpy(payloadStart, commandData, commandDataLen);
spParams.setPayloadLen(commandDataLen);
return result;
}
@ -488,10 +478,11 @@ class TcDownlinkPwrOn : public TcBase {
/**
* @brief Constructor
*/
TcDownlinkPwrOn(uint16_t sequenceCount) : TcBase(apid::TC_DOWNLINK_PWR_ON, sequenceCount) {}
TcDownlinkPwrOn(SpBaseParams params, uint16_t sequenceCount)
: TcBase(params, apid::TC_DOWNLINK_PWR_ON, sequenceCount) {}
protected:
ReturnValue_t initPacket(const uint8_t* commandData, size_t commandDataLen) {
ReturnValue_t initPacket(const uint8_t* commandData, size_t commandDataLen) override {
ReturnValue_t result = HasReturnvaluesIF::RETURN_OK;
result = lengthCheck(commandDataLen);
if (result != HasReturnvaluesIF::RETURN_OK) {
@ -505,10 +496,9 @@ class TcDownlinkPwrOn : public TcBase {
if (result != HasReturnvaluesIF::RETURN_OK) {
return result;
}
std::memcpy(this->localData.fields.buffer, commandData, commandDataLen);
std::memcpy(this->localData.fields.buffer + commandDataLen, &MAX_AMPLITUDE,
sizeof(MAX_AMPLITUDE));
this->setPacketDataLength(commandDataLen + sizeof(MAX_AMPLITUDE) + CRC_SIZE - 1);
std::memcpy(payloadStart, commandData, commandDataLen);
std::memcpy(payloadStart + commandDataLen, &MAX_AMPLITUDE, sizeof(MAX_AMPLITUDE));
spParams.setPayloadLen(commandDataLen + sizeof(MAX_AMPLITUDE));
return result;
}
@ -555,17 +545,8 @@ class TcDownlinkPwrOn : public TcBase {
*/
class TcDownlinkPwrOff : public TcBase {
public:
TcDownlinkPwrOff(uint16_t sequenceCount) : TcBase(apid::TC_DOWNLINK_PWR_OFF, sequenceCount) {}
ReturnValue_t createPacket() {
ReturnValue_t result = HasReturnvaluesIF::RETURN_OK;
result = addCrc();
if (result != HasReturnvaluesIF::RETURN_OK) {
return result;
}
this->setPacketDataLength(static_cast<uint16_t>(CRC_SIZE - 1));
return HasReturnvaluesIF::RETURN_OK;
}
TcDownlinkPwrOff(SpBaseParams params, uint16_t sequenceCount)
: TcBase(params, apid::TC_DOWNLINK_PWR_OFF, sequenceCount) {}
};
/**
@ -576,19 +557,19 @@ class TcReplayWriteSeq : public TcBase {
/**
* @brief Constructor
*/
TcReplayWriteSeq(uint16_t sequenceCount)
: TcBase(apid::TC_REPLAY_WRITE_SEQUENCE, sequenceCount) {}
TcReplayWriteSeq(SpBaseParams params, uint16_t sequenceCount)
: TcBase(params, apid::TC_REPLAY_WRITE_SEQUENCE, sequenceCount) {}
protected:
ReturnValue_t initPacket(const uint8_t* commandData, size_t commandDataLen) {
ReturnValue_t initPacket(const uint8_t* commandData, size_t commandDataLen) override {
ReturnValue_t result = HasReturnvaluesIF::RETURN_OK;
result = lengthCheck(commandDataLen);
if (result != HasReturnvaluesIF::RETURN_OK) {
return result;
}
std::memcpy(this->localData.fields.buffer, commandData, commandDataLen);
*(this->localData.fields.buffer + commandDataLen) = NULL_TERMINATOR;
this->setPacketDataLength(commandDataLen + sizeof(NULL_TERMINATOR) + CRC_SIZE - 1);
std::memcpy(payloadStart, commandData, commandDataLen);
*(payloadStart + commandDataLen) = NULL_TERMINATOR;
spParams.setPayloadLen(commandDataLen + sizeof(NULL_TERMINATOR));
return result;
}
@ -643,17 +624,8 @@ class FlashWritePusCmd : public MPSoCReturnValuesIF {
*/
class TcModeReplay : public TcBase {
public:
TcModeReplay(uint16_t sequenceCount) : TcBase(apid::TC_MODE_REPLAY, sequenceCount) {}
ReturnValue_t createPacket() {
ReturnValue_t result = HasReturnvaluesIF::RETURN_OK;
result = addCrc();
if (result != HasReturnvaluesIF::RETURN_OK) {
return result;
}
this->setPacketDataLength(static_cast<uint16_t>(CRC_SIZE - 1));
return HasReturnvaluesIF::RETURN_OK;
}
TcModeReplay(SpBaseParams params, uint16_t sequenceCount)
: TcBase(params, apid::TC_MODE_REPLAY, sequenceCount) {}
};
/**
@ -661,36 +633,27 @@ class TcModeReplay : public TcBase {
*/
class TcModeIdle : public TcBase {
public:
TcModeIdle(uint16_t sequenceCount) : TcBase(apid::TC_MODE_IDLE, sequenceCount) {}
ReturnValue_t createPacket() {
ReturnValue_t result = HasReturnvaluesIF::RETURN_OK;
result = addCrc();
if (result != HasReturnvaluesIF::RETURN_OK) {
return result;
}
this->setPacketDataLength(static_cast<uint16_t>(CRC_SIZE - 1));
return HasReturnvaluesIF::RETURN_OK;
}
TcModeIdle(SpBaseParams params, uint16_t sequenceCount)
: TcBase(params, apid::TC_MODE_IDLE, sequenceCount) {}
};
class TcCamcmdSend : public TcBase {
public:
TcCamcmdSend(uint16_t sequenceCount) : TcBase(apid::TC_CAM_CMD_SEND, sequenceCount) {}
TcCamcmdSend(SpBaseParams params, uint16_t sequenceCount)
: TcBase(params, apid::TC_CAM_CMD_SEND, sequenceCount) {}
protected:
ReturnValue_t initPacket(const uint8_t* commandData, size_t commandDataLen) {
ReturnValue_t initPacket(const uint8_t* commandData, size_t commandDataLen) override {
if (commandDataLen > MAX_DATA_LENGTH) {
return INVALID_LENGTH;
}
uint16_t dataLen = static_cast<uint16_t>(commandDataLen + sizeof(CARRIAGE_RETURN));
size_t size = sizeof(dataLen);
SerializeAdapter::serialize(&dataLen, this->getPacketData(), &size, sizeof(dataLen),
SerializeAdapter::serialize(&dataLen, payloadStart, &size, sizeof(dataLen),
SerializeIF::Endianness::BIG);
std::memcpy(this->getPacketData() + sizeof(dataLen), commandData, commandDataLen);
*(this->getPacketData() + sizeof(dataLen) + commandDataLen) = CARRIAGE_RETURN;
uint16_t trueLength = sizeof(dataLen) + commandDataLen + sizeof(CARRIAGE_RETURN) + CRC_SIZE;
this->setPacketDataLength(trueLength - 1);
std::memcpy(payloadStart + sizeof(dataLen), commandData, commandDataLen);
*(payloadStart + sizeof(dataLen) + commandDataLen) = CARRIAGE_RETURN;
spParams.setPayloadLen(sizeof(dataLen) + commandDataLen + sizeof(CARRIAGE_RETURN));
return HasReturnvaluesIF::RETURN_OK;
}

File diff suppressed because it is too large Load Diff

View File

@ -206,6 +206,9 @@ ReturnValue_t PlocMPSoCHandler::buildTransitionDeviceCommand(DeviceCommandId_t*
ReturnValue_t PlocMPSoCHandler::buildCommandFromCommand(DeviceCommandId_t deviceCommand,
const uint8_t* commandData,
size_t commandDataLen) {
spParams.buf = commandBuffer;
spParams.maxSize = sizeof(commandBuffer);
ReturnValue_t result = RETURN_OK;
switch (deviceCommand) {
case (mpsoc::TC_MEM_WRITE): {
@ -286,16 +289,23 @@ void PlocMPSoCHandler::fillCommandAndReplyMap() {
this->insertInReplyMap(mpsoc::ACK_REPORT, 3, nullptr, mpsoc::SIZE_ACK_REPORT);
this->insertInReplyMap(mpsoc::EXE_REPORT, 3, nullptr, mpsoc::SIZE_EXE_REPORT);
this->insertInReplyMap(mpsoc::TM_MEMORY_READ_REPORT, 2, nullptr, mpsoc::SIZE_TM_MEM_READ_REPORT);
this->insertInReplyMap(mpsoc::TM_CAM_CMD_RPT, 2, nullptr, SpacePacket::PACKET_MAX_SIZE);
this->insertInReplyMap(mpsoc::TM_CAM_CMD_RPT, 2, nullptr, mpsoc::SP_MAX_SIZE);
}
ReturnValue_t PlocMPSoCHandler::scanForReply(const uint8_t* start, size_t remainingSize,
DeviceCommandId_t* foundId, size_t* foundLen) {
ReturnValue_t result = RETURN_OK;
SpacePacket spacePacket;
std::memcpy(spacePacket.getWholeData(), start, remainingSize);
uint16_t apid = spacePacket.getAPID();
SpacePacketReader spacePacket;
spacePacket.setReadOnlyData(start, remainingSize);
if (spacePacket.isNull()) {
return RETURN_FAILED;
}
auto res = spacePacket.checkSize();
if (res != RETURN_OK) {
return res;
}
uint16_t apid = spacePacket.getApid();
switch (apid) {
case (mpsoc::apid::ACK_SUCCESS):
@ -311,7 +321,7 @@ ReturnValue_t PlocMPSoCHandler::scanForReply(const uint8_t* start, size_t remain
*foundId = mpsoc::TM_MEMORY_READ_REPORT;
break;
case (mpsoc::apid::TM_CAM_CMD_RPT):
*foundLen = spacePacket.getFullSize();
*foundLen = spacePacket.getFullPacketLen();
tmCamCmdRpt.rememberSpacePacketSize = *foundLen;
*foundId = mpsoc::TM_CAM_CMD_RPT;
break;
@ -394,13 +404,13 @@ ReturnValue_t PlocMPSoCHandler::prepareTcMemWrite(const uint8_t* commandData,
size_t commandDataLen) {
ReturnValue_t result = RETURN_OK;
sequenceCount++;
mpsoc::TcMemWrite tcMemWrite(sequenceCount);
result = tcMemWrite.createPacket(commandData, commandDataLen);
mpsoc::TcMemWrite tcMemWrite(spParams, sequenceCount);
result = tcMemWrite.buildPacket(commandData, commandDataLen);
if (result != RETURN_OK) {
sequenceCount--;
return result;
}
copyToCommandBuffer(&tcMemWrite);
finishTcPrep();
return RETURN_OK;
}
@ -408,13 +418,13 @@ ReturnValue_t PlocMPSoCHandler::prepareTcMemRead(const uint8_t* commandData,
size_t commandDataLen) {
ReturnValue_t result = RETURN_OK;
sequenceCount++;
mpsoc::TcMemRead tcMemRead(sequenceCount);
result = tcMemRead.createPacket(commandData, commandDataLen);
mpsoc::TcMemRead tcMemRead(spParams, sequenceCount);
result = tcMemRead.buildPacket(commandData, commandDataLen);
if (result != RETURN_OK) {
sequenceCount--;
return result;
}
copyToCommandBuffer(&tcMemRead);
finishTcPrep();
tmMemReadReport.rememberRequestedSize = tcMemRead.getMemLen() * 4 + TmMemReadReport::FIX_SIZE;
return RETURN_OK;
}
@ -426,14 +436,14 @@ ReturnValue_t PlocMPSoCHandler::prepareTcFlashDelete(const uint8_t* commandData,
}
ReturnValue_t result = RETURN_OK;
sequenceCount++;
mpsoc::TcFlashDelete tcFlashDelete(sequenceCount);
result = tcFlashDelete.createPacket(
mpsoc::TcFlashDelete tcFlashDelete(spParams, sequenceCount);
result = tcFlashDelete.buildPacket(
std::string(reinterpret_cast<const char*>(commandData), commandDataLen));
if (result != RETURN_OK) {
sequenceCount--;
return result;
}
copyToCommandBuffer(&tcFlashDelete);
finishTcPrep();
return RETURN_OK;
}
@ -441,26 +451,26 @@ ReturnValue_t PlocMPSoCHandler::prepareTcReplayStart(const uint8_t* commandData,
size_t commandDataLen) {
ReturnValue_t result = RETURN_OK;
sequenceCount++;
mpsoc::TcReplayStart tcReplayStart(sequenceCount);
result = tcReplayStart.createPacket(commandData, commandDataLen);
mpsoc::TcReplayStart tcReplayStart(spParams, sequenceCount);
result = tcReplayStart.buildPacket(commandData, commandDataLen);
if (result != RETURN_OK) {
sequenceCount--;
return result;
}
copyToCommandBuffer(&tcReplayStart);
finishTcPrep();
return RETURN_OK;
}
ReturnValue_t PlocMPSoCHandler::prepareTcReplayStop() {
ReturnValue_t result = RETURN_OK;
sequenceCount++;
mpsoc::TcReplayStop tcReplayStop(sequenceCount);
result = tcReplayStop.createPacket();
mpsoc::TcReplayStop tcReplayStop(spParams, sequenceCount);
result = tcReplayStop.buildPacket();
if (result != RETURN_OK) {
sequenceCount--;
return result;
}
copyToCommandBuffer(&tcReplayStop);
finishTcPrep();
return RETURN_OK;
}
@ -468,26 +478,26 @@ ReturnValue_t PlocMPSoCHandler::prepareTcDownlinkPwrOn(const uint8_t* commandDat
size_t commandDataLen) {
ReturnValue_t result = RETURN_OK;
sequenceCount++;
mpsoc::TcDownlinkPwrOn tcDownlinkPwrOn(sequenceCount);
result = tcDownlinkPwrOn.createPacket(commandData, commandDataLen);
mpsoc::TcDownlinkPwrOn tcDownlinkPwrOn(spParams, sequenceCount);
result = tcDownlinkPwrOn.buildPacket(commandData, commandDataLen);
if (result != RETURN_OK) {
sequenceCount--;
return result;
}
copyToCommandBuffer(&tcDownlinkPwrOn);
finishTcPrep();
return RETURN_OK;
}
ReturnValue_t PlocMPSoCHandler::prepareTcDownlinkPwrOff() {
ReturnValue_t result = RETURN_OK;
sequenceCount++;
mpsoc::TcDownlinkPwrOff tcDownlinkPwrOff(sequenceCount);
result = tcDownlinkPwrOff.createPacket();
mpsoc::TcDownlinkPwrOff tcDownlinkPwrOff(spParams, sequenceCount);
result = tcDownlinkPwrOff.buildPacket();
if (result != RETURN_OK) {
sequenceCount--;
return result;
}
copyToCommandBuffer(&tcDownlinkPwrOff);
finishTcPrep();
return RETURN_OK;
}
@ -495,45 +505,39 @@ ReturnValue_t PlocMPSoCHandler::prepareTcReplayWriteSequence(const uint8_t* comm
size_t commandDataLen) {
ReturnValue_t result = RETURN_OK;
sequenceCount++;
mpsoc::TcReplayWriteSeq tcReplayWriteSeq(sequenceCount);
result = tcReplayWriteSeq.createPacket(commandData, commandDataLen);
mpsoc::TcReplayWriteSeq tcReplayWriteSeq(spParams, sequenceCount);
result = tcReplayWriteSeq.buildPacket(commandData, commandDataLen);
if (result != RETURN_OK) {
sequenceCount--;
return result;
}
copyToCommandBuffer(&tcReplayWriteSeq);
finishTcPrep();
return RETURN_OK;
}
ReturnValue_t PlocMPSoCHandler::prepareTcModeReplay() {
ReturnValue_t result = RETURN_OK;
sequenceCount++;
mpsoc::TcModeReplay tcModeReplay(sequenceCount);
result = tcModeReplay.createPacket();
mpsoc::TcModeReplay tcModeReplay(spParams, sequenceCount);
result = tcModeReplay.buildPacket();
if (result != RETURN_OK) {
sequenceCount--;
return result;
}
memcpy(commandBuffer, tcModeReplay.getWholeData(), tcModeReplay.getFullSize());
rawPacket = commandBuffer;
rawPacketLen = tcModeReplay.getFullSize();
nextReplyId = mpsoc::ACK_REPORT;
finishTcPrep();
return RETURN_OK;
}
ReturnValue_t PlocMPSoCHandler::prepareTcModeIdle() {
ReturnValue_t result = RETURN_OK;
sequenceCount++;
mpsoc::TcModeIdle tcModeIdle(sequenceCount);
result = tcModeIdle.createPacket();
mpsoc::TcModeIdle tcModeIdle(spParams, sequenceCount);
result = tcModeIdle.buildPacket();
if (result != RETURN_OK) {
sequenceCount--;
return result;
}
memcpy(commandBuffer, tcModeIdle.getWholeData(), tcModeIdle.getFullSize());
rawPacket = commandBuffer;
rawPacketLen = tcModeIdle.getFullSize();
nextReplyId = mpsoc::ACK_REPORT;
finishTcPrep();
return RETURN_OK;
}
@ -541,26 +545,18 @@ ReturnValue_t PlocMPSoCHandler::prepareTcCamCmdSend(const uint8_t* commandData,
size_t commandDataLen) {
ReturnValue_t result = RETURN_OK;
sequenceCount++;
mpsoc::TcCamcmdSend tcCamCmdSend(sequenceCount);
result = tcCamCmdSend.createPacket(commandData, commandDataLen);
mpsoc::TcCamcmdSend tcCamCmdSend(spParams, sequenceCount);
result = tcCamCmdSend.buildPacket(commandData, commandDataLen);
if (result != RETURN_OK) {
sequenceCount--;
return result;
}
copyToCommandBuffer(&tcCamCmdSend);
finishTcPrep();
nextReplyId = mpsoc::TM_CAM_CMD_RPT;
return RETURN_OK;
}
void PlocMPSoCHandler::copyToCommandBuffer(mpsoc::TcBase* tc) {
if (tc == nullptr) {
sif::debug << "PlocMPSoCHandler::copyToCommandBuffer: Invalid TC" << std::endl;
}
memcpy(commandBuffer, tc->getWholeData(), tc->getFullSize());
rawPacket = commandBuffer;
rawPacketLen = tc->getFullSize();
nextReplyId = mpsoc::ACK_REPORT;
}
void PlocMPSoCHandler::finishTcPrep() { nextReplyId = mpsoc::ACK_REPORT; }
ReturnValue_t PlocMPSoCHandler::verifyPacket(const uint8_t* start, size_t foundLen) {
uint16_t receivedCrc = *(start + foundLen - 2) << 8 | *(start + foundLen - 1);
@ -818,7 +814,7 @@ size_t PlocMPSoCHandler::getNextReplyLength(DeviceCommandId_t commandId) {
case mpsoc::TM_CAM_CMD_RPT:
// Read acknowledgment, camera and execution report in one go because length of camera
// report is not fixed
replyLen = SpacePacket::PACKET_MAX_SIZE;
replyLen = mpsoc::SP_MAX_SIZE;
break;
default: {
replyLen = iter->second.replyLen;

View File

@ -8,7 +8,6 @@
#include "fsfw/action/CommandsActionsIF.h"
#include "fsfw/devicehandlers/DeviceHandlerBase.h"
#include "fsfw/ipc/QueueFactory.h"
#include "fsfw/tmtcpacket/SpacePacket.h"
#include "fsfw/tmtcservices/SourceSequenceCounter.h"
#include "fsfw_hal/linux/gpio/Gpio.h"
#include "fsfw_hal/linux/uart/UartComIF.h"
@ -111,8 +110,7 @@ class PlocMPSoCHandler : public DeviceHandlerBase, public CommandsActionsIF {
// Initiate the sequence count with the maximum value. It is incremented before
// a packet is sent, so the first value will be 0 accordingly using
// the wrap around of the counter.
SourceSequenceCounter sequenceCount =
SourceSequenceCounter(SpacePacketBase::LIMIT_SEQUENCE_COUNT - 1);
SourceSequenceCounter sequenceCount = SourceSequenceCounter(ccsds::LIMIT_SEQUENCE_COUNT - 1);
uint8_t commandBuffer[mpsoc::MAX_COMMAND_SIZE];
@ -148,11 +146,14 @@ class PlocMPSoCHandler : public DeviceHandlerBase, public CommandsActionsIF {
struct TelemetryBuffer {
uint16_t length = 0;
uint8_t buffer[SpacePacket::PACKET_MAX_SIZE];
uint8_t buffer[mpsoc::SP_MAX_SIZE];
};
TelemetryBuffer tmBuffer;
SpacePacketCreator creator;
SpBaseParams spParams = SpBaseParams(creator);
enum class PowerState { OFF, BOOTING, SHUTDOWN, ON };
PowerState powerState = PowerState::OFF;
@ -172,10 +173,7 @@ class PlocMPSoCHandler : public DeviceHandlerBase, public CommandsActionsIF {
ReturnValue_t prepareTcReplayWriteSequence(const uint8_t* commandData, size_t commandDataLen);
ReturnValue_t prepareTcCamCmdSend(const uint8_t* commandData, size_t commandDataLen);
ReturnValue_t prepareTcModeIdle();
/**
* @brief Copies space packet into command buffer
*/
void copyToCommandBuffer(mpsoc::TcBase* tc);
void finishTcPrep();
/**
* @brief This function checks the crc of the received PLOC reply.

View File

@ -13,7 +13,6 @@
#include "fsfw/objectmanager/SystemObject.h"
#include "fsfw/returnvalues/HasReturnvaluesIF.h"
#include "fsfw/tasks/ExecutableObjectIF.h"
#include "fsfw/tmtcpacket/SpacePacket.h"
#include "linux/fsfwconfig/objects/systemObjectList.h"
/**

View File

@ -28,6 +28,11 @@ PlocSupervisorHandler::PlocSupervisorHandler(object_id_t objectId, object_id_t u
if (comCookie == NULL) {
sif::error << "PlocSupervisorHandler: Invalid com cookie" << std::endl;
}
if (supvHelper == nullptr) {
sif::error << "PlocSupervisorHandler: Invalid PlocSupvHelper object" << std::endl;
}
spParams.buf = commandBuffer;
spParams.maxSize = sizeof(commandBuffer);
eventQueue = QueueFactory::instance()->createMessageQueue(EventMessage::EVENT_MESSAGE_SIZE * 5);
}
@ -154,6 +159,7 @@ void PlocSupervisorHandler::doStartUp() {
uartIsolatorSwitch.pullHigh();
startupState = StartupState::SET_TIME;
}
break;
}
case StartupState::SET_TIME_EXECUTING:
break;
@ -194,6 +200,8 @@ ReturnValue_t PlocSupervisorHandler::buildCommandFromCommand(DeviceCommandId_t d
size_t commandDataLen) {
using namespace supv;
ReturnValue_t result = RETURN_FAILED;
spParams.buf = commandBuffer;
spParams.maxSize = sizeof(commandBuffer);
switch (deviceCommand) {
case GET_HK_REPORT: {
prepareEmptyCmd(APID_GET_HK_REPORT);
@ -314,21 +322,30 @@ ReturnValue_t PlocSupervisorHandler::buildCommandFromCommand(DeviceCommandId_t d
break;
}
case FACTORY_RESET_CLEAR_ALL: {
FactoryReset packet(FactoryReset::Op::CLEAR_ALL);
packetToOutBuffer(packet.getWholeData(), packet.getFullSize());
result = RETURN_OK;
FactoryReset packet(spParams);
result = packet.buildPacket(FactoryReset::Op::CLEAR_ALL);
if (result != RETURN_OK) {
break;
}
finishTcPrep();
break;
}
case FACTORY_RESET_CLEAR_MIRROR: {
FactoryReset packet(FactoryReset::Op::MIRROR_ENTRIES);
packetToOutBuffer(packet.getWholeData(), packet.getFullSize());
result = RETURN_OK;
FactoryReset packet(spParams);
result = packet.buildPacket(FactoryReset::Op::MIRROR_ENTRIES);
if (result != RETURN_OK) {
break;
}
finishTcPrep();
break;
}
case FACTORY_RESET_CLEAR_CIRCULAR: {
FactoryReset packet(FactoryReset::Op::CIRCULAR_ENTRIES);
packetToOutBuffer(packet.getWholeData(), packet.getFullSize());
result = RETURN_OK;
FactoryReset packet(spParams);
result = packet.buildPacket(FactoryReset::Op::CIRCULAR_ENTRIES);
if (result != RETURN_OK) {
break;
}
finishTcPrep();
break;
}
case START_MPSOC_QUIET: {
@ -347,34 +364,49 @@ ReturnValue_t PlocSupervisorHandler::buildCommandFromCommand(DeviceCommandId_t d
break;
}
case ENABLE_AUTO_TM: {
EnableAutoTm packet;
packetToOutBuffer(packet.getWholeData(), packet.getFullSize());
result = RETURN_OK;
EnableAutoTm packet(spParams);
result = packet.buildPacket();
if (result != RETURN_OK) {
break;
}
finishTcPrep();
break;
}
case DISABLE_AUTO_TM: {
DisableAutoTm packet;
packetToOutBuffer(packet.getWholeData(), packet.getFullSize());
result = RETURN_OK;
DisableAutoTm packet(spParams);
result = packet.buildPacket();
if (result != RETURN_OK) {
break;
}
finishTcPrep();
break;
}
case LOGGING_REQUEST_COUNTERS: {
RequestLoggingData packet(RequestLoggingData::Sa::REQUEST_COUNTERS);
packetToOutBuffer(packet.getWholeData(), packet.getFullSize());
result = RETURN_OK;
RequestLoggingData packet(spParams);
result = packet.buildPacket(RequestLoggingData::Sa::REQUEST_COUNTERS);
if (result != RETURN_OK) {
break;
}
finishTcPrep();
break;
}
case LOGGING_CLEAR_COUNTERS: {
RequestLoggingData packet(RequestLoggingData::Sa::CLEAR_COUNTERS);
packetToOutBuffer(packet.getWholeData(), packet.getFullSize());
result = RETURN_OK;
RequestLoggingData packet(spParams);
result = packet.buildPacket(RequestLoggingData::Sa::CLEAR_COUNTERS);
if (result != RETURN_OK) {
break;
}
finishTcPrep();
break;
}
case LOGGING_SET_TOPIC: {
uint8_t tpc = *(commandData);
RequestLoggingData packet(RequestLoggingData::Sa::SET_LOGGING_TOPIC, tpc);
packetToOutBuffer(packet.getWholeData(), packet.getFullSize());
result = RETURN_OK;
RequestLoggingData packet(spParams);
result = packet.buildPacket(RequestLoggingData::Sa::SET_LOGGING_TOPIC, tpc);
if (result != RETURN_OK) {
break;
}
finishTcPrep();
break;
}
case RESET_PL: {
@ -1354,15 +1386,25 @@ void PlocSupervisorHandler::handleDeviceTM(const uint8_t* data, size_t dataSize,
}
}
void PlocSupervisorHandler::prepareEmptyCmd(uint16_t apid) {
supv::ApidOnlyPacket packet(apid);
packetToOutBuffer(packet.getWholeData(), packet.getFullSize());
ReturnValue_t PlocSupervisorHandler::prepareEmptyCmd(uint16_t apid) {
supv::ApidOnlyPacket packet(spParams, apid);
ReturnValue_t result = packet.buildPacket();
if (result != RETURN_OK) {
return result;
}
finishTcPrep();
return RETURN_OK;
}
void PlocSupervisorHandler::prepareSelBootImageCmd(const uint8_t* commandData) {
supv::MPSoCBootSelect packet(*commandData, *(commandData + 1), *(commandData + 2),
*(commandData + 3));
packetToOutBuffer(packet.getWholeData(), packet.getFullSize());
ReturnValue_t PlocSupervisorHandler::prepareSelBootImageCmd(const uint8_t* commandData) {
supv::MPSoCBootSelect packet(spParams);
ReturnValue_t result =
packet.buildPacket(*commandData, *(commandData + 1), *(commandData + 2), *(commandData + 3));
if (result != RETURN_OK) {
return result;
}
finishTcPrep();
return RETURN_OK;
}
ReturnValue_t PlocSupervisorHandler::prepareSetTimeRefCmd() {
@ -1373,27 +1415,46 @@ ReturnValue_t PlocSupervisorHandler::prepareSetTimeRefCmd() {
<< std::endl;
return SupvReturnValuesIF::GET_TIME_FAILURE;
}
supv::SetTimeRef packet(&time);
packetToOutBuffer(packet.getWholeData(), packet.getFullSize());
supv::SetTimeRef packet(spParams);
result = packet.buildPacket(&time);
if (result != RETURN_OK) {
return result;
}
finishTcPrep();
return RETURN_OK;
}
void PlocSupervisorHandler::prepareDisableHk() {
supv::DisablePeriodicHkTransmission packet;
packetToOutBuffer(packet.getWholeData(), packet.getFullSize());
ReturnValue_t PlocSupervisorHandler::prepareDisableHk() {
supv::DisablePeriodicHkTransmission packet(spParams);
ReturnValue_t result = packet.buildPacket();
if (result != RETURN_OK) {
return result;
}
finishTcPrep();
return RETURN_OK;
}
void PlocSupervisorHandler::prepareSetBootTimeoutCmd(const uint8_t* commandData) {
ReturnValue_t PlocSupervisorHandler::prepareSetBootTimeoutCmd(const uint8_t* commandData) {
supv::SetBootTimeout packet(spParams);
uint32_t timeout = *(commandData) << 24 | *(commandData + 1) << 16 | *(commandData + 2) << 8 |
*(commandData + 3);
supv::SetBootTimeout packet(timeout);
packetToOutBuffer(packet.getWholeData(), packet.getFullSize());
ReturnValue_t result = packet.buildPacket(timeout);
if (result != RETURN_OK) {
return result;
}
finishTcPrep();
return RETURN_OK;
}
void PlocSupervisorHandler::prepareRestartTriesCmd(const uint8_t* commandData) {
ReturnValue_t PlocSupervisorHandler::prepareRestartTriesCmd(const uint8_t* commandData) {
uint8_t restartTries = *(commandData);
supv::SetRestartTries packet(restartTries);
packetToOutBuffer(packet.getWholeData(), packet.getFullSize());
supv::SetRestartTries packet(spParams);
ReturnValue_t result = packet.buildPacket(restartTries);
if (result != RETURN_OK) {
return result;
}
finishTcPrep();
return RETURN_OK;
}
ReturnValue_t PlocSupervisorHandler::prepareLatchupConfigCmd(const uint8_t* commandData,
@ -1405,13 +1466,21 @@ ReturnValue_t PlocSupervisorHandler::prepareLatchupConfigCmd(const uint8_t* comm
}
switch (deviceCommand) {
case (supv::ENABLE_LATCHUP_ALERT): {
supv::LatchupAlert packet(true, latchupId);
packetToOutBuffer(packet.getWholeData(), packet.getFullSize());
supv::LatchupAlert packet(spParams);
result = packet.buildPacket(true, latchupId);
if (result != RETURN_OK) {
return result;
}
finishTcPrep();
break;
}
case (supv::DISABLE_LATCHUP_ALERT): {
supv::LatchupAlert packet(false, latchupId);
packetToOutBuffer(packet.getWholeData(), packet.getFullSize());
supv::LatchupAlert packet(spParams);
result = packet.buildPacket(false, latchupId);
if (result != RETURN_OK) {
return result;
}
finishTcPrep();
break;
}
default: {
@ -1433,31 +1502,50 @@ ReturnValue_t PlocSupervisorHandler::prepareSetAlertLimitCmd(const uint8_t* comm
if (latchupId > 6) {
return SupvReturnValuesIF::INVALID_LATCHUP_ID;
}
supv::SetAlertlimit packet(latchupId, dutycycle);
packetToOutBuffer(packet.getWholeData(), packet.getFullSize());
supv::SetAlertlimit packet(spParams);
ReturnValue_t result = packet.buildPacket(latchupId, dutycycle);
if (result != RETURN_OK) {
return result;
}
finishTcPrep();
return RETURN_OK;
}
void PlocSupervisorHandler::prepareSetAdcEnabledChannelsCmd(const uint8_t* commandData) {
ReturnValue_t PlocSupervisorHandler::prepareSetAdcEnabledChannelsCmd(const uint8_t* commandData) {
uint16_t ch = *(commandData) << 8 | *(commandData + 1);
supv::SetAdcEnabledChannels packet(ch);
packetToOutBuffer(packet.getWholeData(), packet.getFullSize());
supv::SetAdcEnabledChannels packet(spParams);
ReturnValue_t result = packet.buildPacket(ch);
if (result != RETURN_OK) {
return result;
}
finishTcPrep();
return RETURN_OK;
}
void PlocSupervisorHandler::prepareSetAdcWindowAndStrideCmd(const uint8_t* commandData) {
ReturnValue_t PlocSupervisorHandler::prepareSetAdcWindowAndStrideCmd(const uint8_t* commandData) {
uint8_t offset = 0;
uint16_t windowSize = *(commandData + offset) << 8 | *(commandData + offset + 1);
offset += 2;
uint16_t stridingStepSize = *(commandData + offset) << 8 | *(commandData + offset + 1);
supv::SetAdcWindowAndStride packet(windowSize, stridingStepSize);
packetToOutBuffer(packet.getWholeData(), packet.getFullSize());
supv::SetAdcWindowAndStride packet(spParams);
ReturnValue_t result = packet.buildPacket(windowSize, stridingStepSize);
if (result != RETURN_OK) {
return result;
}
finishTcPrep();
return RETURN_OK;
}
void PlocSupervisorHandler::prepareSetAdcThresholdCmd(const uint8_t* commandData) {
ReturnValue_t PlocSupervisorHandler::prepareSetAdcThresholdCmd(const uint8_t* commandData) {
uint32_t threshold = *(commandData) << 24 | *(commandData + 1) << 16 | *(commandData + 2) << 8 |
*(commandData + 3);
supv::SetAdcThreshold packet(threshold);
packetToOutBuffer(packet.getWholeData(), packet.getFullSize());
supv::SetAdcThreshold packet(spParams);
ReturnValue_t result = packet.buildPacket(threshold);
if (result != RETURN_OK) {
return result;
}
finishTcPrep();
return RETURN_OK;
}
ReturnValue_t PlocSupervisorHandler::prepareRunAutoEmTest(const uint8_t* commandData) {
@ -1465,8 +1553,12 @@ ReturnValue_t PlocSupervisorHandler::prepareRunAutoEmTest(const uint8_t* command
if (test != 1 && test != 2) {
return SupvReturnValuesIF::INVALID_TEST_PARAM;
}
supv::RunAutoEmTests packet(test);
packetToOutBuffer(packet.getWholeData(), packet.getFullSize());
supv::RunAutoEmTests packet(spParams);
ReturnValue_t result = packet.buildPacket(test);
if (result != RETURN_OK) {
return result;
}
finishTcPrep();
return RETURN_OK;
}
@ -1479,8 +1571,12 @@ ReturnValue_t PlocSupervisorHandler::prepareWipeMramCmd(const uint8_t* commandDa
if ((stop - start) <= 0) {
return SupvReturnValuesIF::INVALID_MRAM_ADDRESSES;
}
supv::MramCmd packet(start, stop, supv::MramCmd::MramAction::WIPE);
packetToOutBuffer(packet.getWholeData(), packet.getFullSize());
supv::MramCmd packet(spParams);
ReturnValue_t result = packet.buildPacket(start, stop, supv::MramCmd::MramAction::WIPE);
if (result != RETURN_OK) {
return result;
}
finishTcPrep();
return RETURN_OK;
}
@ -1490,42 +1586,52 @@ ReturnValue_t PlocSupervisorHandler::prepareDumpMramCmd(const uint8_t* commandDa
size_t size = sizeof(start) + sizeof(stop);
SerializeAdapter::deSerialize(&start, &commandData, &size, SerializeIF::Endianness::BIG);
SerializeAdapter::deSerialize(&stop, &commandData, &size, SerializeIF::Endianness::BIG);
supv::MramCmd packet(start, stop, supv::MramCmd::MramAction::DUMP);
packetToOutBuffer(packet.getWholeData(), packet.getFullSize());
if ((stop - start) <= 0) {
return SupvReturnValuesIF::INVALID_MRAM_ADDRESSES;
}
supv::MramCmd packet(spParams);
ReturnValue_t result = packet.buildPacket(start, stop, supv::MramCmd::MramAction::DUMP);
if (result != RETURN_OK) {
return result;
}
expectedMramDumpPackets = (stop - start) / supv::MAX_DATA_CAPACITY;
if ((stop - start) % supv::MAX_DATA_CAPACITY) {
expectedMramDumpPackets++;
}
receivedMramDumpPackets = 0;
finishTcPrep();
return RETURN_OK;
}
void PlocSupervisorHandler::prepareSetGpioCmd(const uint8_t* commandData) {
ReturnValue_t PlocSupervisorHandler::prepareSetGpioCmd(const uint8_t* commandData) {
uint8_t port = *commandData;
uint8_t pin = *(commandData + 1);
uint8_t val = *(commandData + 2);
supv::SetGpio packet(port, pin, val);
packetToOutBuffer(packet.getWholeData(), packet.getFullSize());
supv::SetGpio packet(spParams);
ReturnValue_t result = packet.buildPacket(port, pin, val);
if (result != RETURN_OK) {
return result;
}
finishTcPrep();
return RETURN_OK;
}
void PlocSupervisorHandler::prepareReadGpioCmd(const uint8_t* commandData) {
ReturnValue_t PlocSupervisorHandler::prepareReadGpioCmd(const uint8_t* commandData) {
uint8_t port = *commandData;
uint8_t pin = *(commandData + 1);
supv::ReadGpio packet(port, pin);
packetToOutBuffer(packet.getWholeData(), packet.getFullSize());
supv::ReadGpio packet(spParams);
ReturnValue_t result = packet.buildPacket(port, pin);
if (result != RETURN_OK) {
return result;
}
finishTcPrep();
return RETURN_OK;
}
void PlocSupervisorHandler::packetToOutBuffer(uint8_t* packetData, size_t fullSize) {
memcpy(commandBuffer, packetData, fullSize);
rawPacket = commandBuffer;
rawPacketLen = fullSize;
nextReplyId = supv::ACK_REPORT;
}
void PlocSupervisorHandler::finishTcPrep() { nextReplyId = supv::ACK_REPORT; }
void PlocSupervisorHandler::prepareSetShutdownTimeoutCmd(const uint8_t* commandData) {
ReturnValue_t PlocSupervisorHandler::prepareSetShutdownTimeoutCmd(const uint8_t* commandData) {
uint32_t timeout = 0;
ReturnValue_t result = RETURN_OK;
size_t size = sizeof(timeout);
@ -1536,8 +1642,13 @@ void PlocSupervisorHandler::prepareSetShutdownTimeoutCmd(const uint8_t* commandD
<< "PlocSupervisorHandler::prepareSetShutdownTimeoutCmd: Failed to deserialize timeout"
<< std::endl;
}
supv::SetShutdownTimeout packet(timeout);
packetToOutBuffer(packet.getWholeData(), packet.getFullSize());
supv::SetShutdownTimeout packet(spParams);
result = packet.buildPacket(timeout);
if (result != RETURN_OK) {
return result;
}
finishTcPrep();
return RETURN_OK;
}
ReturnValue_t PlocSupervisorHandler::prepareLoggingRequest(const uint8_t* commandData,
@ -1545,8 +1656,12 @@ ReturnValue_t PlocSupervisorHandler::prepareLoggingRequest(const uint8_t* comman
using namespace supv;
RequestLoggingData::Sa sa = static_cast<RequestLoggingData::Sa>(*commandData);
uint8_t tpc = *(commandData + 1);
RequestLoggingData packet(sa, tpc);
packetToOutBuffer(packet.getWholeData(), packet.getFullSize());
RequestLoggingData packet(spParams);
ReturnValue_t result = packet.buildPacket(sa, tpc);
if (result != RETURN_OK) {
return result;
}
finishTcPrep();
return RETURN_OK;
}
@ -1554,8 +1669,12 @@ ReturnValue_t PlocSupervisorHandler::prepareEnableNvmsCommand(const uint8_t* com
using namespace supv;
uint8_t nvm01 = *(commandData);
uint8_t nvm3 = *(commandData + 1);
EnableNvms packet(nvm01, nvm3);
packetToOutBuffer(packet.getWholeData(), packet.getFullSize());
EnableNvms packet(spParams);
ReturnValue_t result = packet.buildPacket(nvm01, nvm3);
if (result != RETURN_OK) {
return result;
}
finishTcPrep();
return RETURN_OK;
}
@ -1743,8 +1862,8 @@ void PlocSupervisorHandler::increaseExpectedMramReplies(DeviceCommandId_t id) {
return;
}
uint8_t sequenceFlags = spacePacketBuffer[2] >> 6;
if (sequenceFlags != static_cast<uint8_t>(supv::SequenceFlags::LAST_PKT) &&
(sequenceFlags != static_cast<uint8_t>(supv::SequenceFlags::STANDALONE_PKT))) {
if (sequenceFlags != static_cast<uint8_t>(ccsds::SequenceFlags::LAST_SEGMENT) &&
(sequenceFlags != static_cast<uint8_t>(ccsds::SequenceFlags::UNSEGMENTED))) {
// Command expects at least one MRAM packet more and the execution report
info->expectedReplies = 2;
mramReplyInfo->countdown->resetTimer();
@ -1770,8 +1889,8 @@ ReturnValue_t PlocSupervisorHandler::handleMramDumpFile(DeviceCommandId_t id) {
uint16_t packetLen = readSpacePacketLength(spacePacketBuffer);
uint8_t sequenceFlags = readSequenceFlags(spacePacketBuffer);
if (id == supv::FIRST_MRAM_DUMP) {
if (sequenceFlags == static_cast<uint8_t>(supv::SequenceFlags::FIRST_PKT) ||
(sequenceFlags == static_cast<uint8_t>(supv::SequenceFlags::STANDALONE_PKT))) {
if (sequenceFlags == static_cast<uint8_t>(ccsds::SequenceFlags::FIRST_SEGMENT) ||
(sequenceFlags == static_cast<uint8_t>(ccsds::SequenceFlags::UNSEGMENTED))) {
result = createMramDumpFile();
if (result != RETURN_OK) {
return result;

View File

@ -100,6 +100,8 @@ class PlocSupervisorHandler : public DeviceHandlerBase {
StartupState startupState = StartupState::OFF;
uint8_t commandBuffer[supv::MAX_COMMAND_SIZE];
SpacePacketCreator creator;
SpBaseParams spParams = SpBaseParams(creator);
/**
* This variable is used to store the id of the next reply to receive. This is necessary
@ -233,14 +235,14 @@ class PlocSupervisorHandler : public DeviceHandlerBase {
* @brief This function prepares a space packet which does not transport any data in the
* packet data field apart from the crc.
*/
void prepareEmptyCmd(uint16_t apid);
ReturnValue_t prepareEmptyCmd(uint16_t apid);
/**
* @brief This function initializes the space packet to select the boot image of the MPSoC.
*/
void prepareSelBootImageCmd(const uint8_t* commandData);
ReturnValue_t prepareSelBootImageCmd(const uint8_t* commandData);
void prepareDisableHk();
ReturnValue_t prepareDisableHk();
/**
* @brief This function fills the commandBuffer with the data to update the time of the
@ -252,9 +254,9 @@ class PlocSupervisorHandler : public DeviceHandlerBase {
* @brief This function fills the commandBuffer with the data to change the boot timeout
* value in the PLOC supervisor.
*/
void prepareSetBootTimeoutCmd(const uint8_t* commandData);
ReturnValue_t prepareSetBootTimeoutCmd(const uint8_t* commandData);
void prepareRestartTriesCmd(const uint8_t* commandData);
ReturnValue_t prepareRestartTriesCmd(const uint8_t* commandData);
/**
* @brief This function fills the command buffer with the packet to enable or disable the
@ -271,21 +273,21 @@ class PlocSupervisorHandler : public DeviceHandlerBase {
ReturnValue_t prepareLatchupConfigCmd(const uint8_t* commandData,
DeviceCommandId_t deviceCommand);
ReturnValue_t prepareSetAlertLimitCmd(const uint8_t* commandData);
void prepareSetAdcEnabledChannelsCmd(const uint8_t* commandData);
void prepareSetAdcWindowAndStrideCmd(const uint8_t* commandData);
void prepareSetAdcThresholdCmd(const uint8_t* commandData);
ReturnValue_t prepareSetAdcEnabledChannelsCmd(const uint8_t* commandData);
ReturnValue_t prepareSetAdcWindowAndStrideCmd(const uint8_t* commandData);
ReturnValue_t prepareSetAdcThresholdCmd(const uint8_t* commandData);
ReturnValue_t prepareRunAutoEmTest(const uint8_t* commandData);
ReturnValue_t prepareWipeMramCmd(const uint8_t* commandData);
ReturnValue_t prepareDumpMramCmd(const uint8_t* commandData);
void prepareSetGpioCmd(const uint8_t* commandData);
void prepareReadGpioCmd(const uint8_t* commandData);
ReturnValue_t prepareSetGpioCmd(const uint8_t* commandData);
ReturnValue_t prepareReadGpioCmd(const uint8_t* commandData);
ReturnValue_t prepareLoggingRequest(const uint8_t* commandData, size_t commandDataLen);
ReturnValue_t prepareEnableNvmsCommand(const uint8_t* commandData);
/**
* @brief Copies the content of a space packet to the command buffer.
*/
void packetToOutBuffer(uint8_t* packetData, size_t fullSize);
void finishTcPrep();
/**
* @brief In case an acknowledgment failure reply has been received this function disables
@ -363,7 +365,7 @@ class PlocSupervisorHandler : public DeviceHandlerBase {
ReturnValue_t createMramDumpFile();
ReturnValue_t getTimeStampString(std::string& timeStamp);
void prepareSetShutdownTimeoutCmd(const uint8_t* commandData);
ReturnValue_t prepareSetShutdownTimeoutCmd(const uint8_t* commandData);
ReturnValue_t extractUpdateCommand(const uint8_t* commandData, size_t size, std::string* file,
uint8_t* memoryId, uint32_t* startAddress);

View File

@ -16,7 +16,10 @@
#include "mission/utility/ProgressPrinter.h"
#include "mission/utility/Timestamp.h"
PlocSupvHelper::PlocSupvHelper(object_id_t objectId) : SystemObject(objectId) {}
PlocSupvHelper::PlocSupvHelper(object_id_t objectId) : SystemObject(objectId) {
spParams.buf = commandBuffer;
spParams.maxSize = sizeof(commandBuffer);
}
PlocSupvHelper::~PlocSupvHelper() {}
@ -210,7 +213,7 @@ ReturnValue_t PlocSupvHelper::writeUpdatePackets() {
uint8_t tempData[supv::WriteMemory::CHUNK_MAX];
std::ifstream file(update.file, std::ifstream::binary);
uint16_t dataLength = 0;
supv::SequenceFlags seqFlags;
ccsds::SequenceFlags seqFlags;
while (update.remainingSize > 0) {
if (terminate) {
terminate = false;
@ -235,14 +238,20 @@ ReturnValue_t PlocSupvHelper::writeUpdatePackets() {
return FILE_CLOSED_ACCIDENTALLY;
}
if (update.bytesWritten == 0) {
seqFlags = supv::SequenceFlags::FIRST_PKT;
seqFlags = ccsds::SequenceFlags::FIRST_SEGMENT;
} else if (update.remainingSize == 0) {
seqFlags = supv::SequenceFlags::LAST_PKT;
seqFlags = ccsds::SequenceFlags::LAST_SEGMENT;
} else {
seqFlags = supv::SequenceFlags::CONTINUED_PKT;
seqFlags = ccsds::SequenceFlags::CONTINUATION;
}
supv::WriteMemory packet(seqFlags, update.sequenceCount++, update.memoryId,
supv::WriteMemory packet(spParams);
result = packet.buildPacket(seqFlags, update.sequenceCount++, update.memoryId,
update.startAddress + update.bytesWritten, dataLength, tempData);
if (result != RETURN_OK) {
update.sequenceCount--;
triggerEvent(WRITE_MEMORY_FAILED, update.packetNum);
return result;
}
result = handlePacketTransmission(packet);
if (result != RETURN_OK) {
update.sequenceCount--;
@ -262,7 +271,11 @@ ReturnValue_t PlocSupvHelper::writeUpdatePackets() {
ReturnValue_t PlocSupvHelper::performEventBufferRequest() {
using namespace supv;
ReturnValue_t result = RETURN_OK;
RequestLoggingData packet(RequestLoggingData::Sa::REQUEST_EVENT_BUFFERS);
RequestLoggingData packet(spParams);
result = packet.buildPacket(RequestLoggingData::Sa::REQUEST_EVENT_BUFFERS);
if (result != RETURN_OK) {
return result;
}
result = sendCommand(packet);
if (result != RETURN_OK) {
return result;
@ -284,7 +297,11 @@ ReturnValue_t PlocSupvHelper::performEventBufferRequest() {
ReturnValue_t PlocSupvHelper::selectMemory() {
ReturnValue_t result = RETURN_OK;
supv::MPSoCBootSelect packet(update.memoryId);
supv::MPSoCBootSelect packet(spParams);
result = packet.buildPacket(update.memoryId);
if (result != RETURN_OK) {
return result;
}
result = handlePacketTransmission(packet);
if (result != RETURN_OK) {
return result;
@ -294,7 +311,8 @@ ReturnValue_t PlocSupvHelper::selectMemory() {
ReturnValue_t PlocSupvHelper::prepareUpdate() {
ReturnValue_t result = RETURN_OK;
supv::ApidOnlyPacket packet(supv::APID_PREPARE_UPDATE);
supv::ApidOnlyPacket packet(spParams, supv::APID_PREPARE_UPDATE);
result = packet.buildPacket();
result = handlePacketTransmission(packet, PREPARE_UPDATE_EXECUTION_REPORT);
if (result != RETURN_OK) {
return result;
@ -304,7 +322,11 @@ ReturnValue_t PlocSupvHelper::prepareUpdate() {
ReturnValue_t PlocSupvHelper::eraseMemory() {
ReturnValue_t result = RETURN_OK;
supv::EraseMemory eraseMemory(update.memoryId, update.startAddress, update.length);
supv::EraseMemory eraseMemory(spParams);
result = eraseMemory.buildPacket(update.memoryId, update.startAddress, update.length);
if (result != RETURN_OK) {
return result;
}
result = handlePacketTransmission(eraseMemory, supv::recv_timeout::ERASE_MEMORY);
if (result != RETURN_OK) {
return result;
@ -312,7 +334,7 @@ ReturnValue_t PlocSupvHelper::eraseMemory() {
return RETURN_OK;
}
ReturnValue_t PlocSupvHelper::handlePacketTransmission(SpacePacket& packet,
ReturnValue_t PlocSupvHelper::handlePacketTransmission(SpacePacketBase& packet,
uint32_t timeoutExecutionReport) {
ReturnValue_t result = RETURN_OK;
result = sendCommand(packet);
@ -330,10 +352,10 @@ ReturnValue_t PlocSupvHelper::handlePacketTransmission(SpacePacket& packet,
return RETURN_OK;
}
ReturnValue_t PlocSupvHelper::sendCommand(SpacePacket& packet) {
ReturnValue_t PlocSupvHelper::sendCommand(SpacePacketBase& packet) {
ReturnValue_t result = RETURN_OK;
rememberApid = packet.getAPID();
result = uartComIF->sendMessage(comCookie, packet.getWholeData(), packet.getFullSize());
rememberApid = packet.getApid();
result = uartComIF->sendMessage(comCookie, packet.getFullPacket(), packet.getFullPacketLen());
if (result != RETURN_OK) {
sif::warning << "PlocSupvHelper::sendCommand: Failed to send command" << std::endl;
triggerEvent(SUPV_SENDING_COMMAND_FAILED, result, static_cast<uint32_t>(internalState));
@ -477,7 +499,11 @@ ReturnValue_t PlocSupvHelper::calcImageCrc() {
ReturnValue_t PlocSupvHelper::handleCheckMemoryCommand() {
ReturnValue_t result = RETURN_OK;
// Verification of update write procedure
supv::CheckMemory packet(update.memoryId, update.startAddress, update.length);
supv::CheckMemory packet(spParams);
result = packet.buildPacket(update.memoryId, update.startAddress, update.length);
if (result != RETURN_OK) {
return result;
}
result = sendCommand(packet);
if (result != RETURN_OK) {
return result;
@ -548,7 +574,7 @@ ReturnValue_t PlocSupvHelper::handleEventBufferReception() {
file.close();
return result;
}
uint16_t apid = tmPacket.getAPID();
uint16_t apid = tmPacket.getApid();
if (apid != supv::APID_MRAM_DUMP_TM) {
sif::warning << "PlocSupvHelper::handleEventBufferReception: Did not expect space packet "
<< "with APID 0x" << std::hex << apid << std::endl;

View File

@ -11,6 +11,7 @@
#include "fsfw/tasks/ExecutableObjectIF.h"
#include "fsfw_hal/linux/uart/UartComIF.h"
#include "linux/devices/devicedefinitions/PlocSupervisorDefinitions.h"
#ifdef XIPHOS_Q7S
#include "bsp_q7s/memory/SdCardManager.h"
#endif
@ -176,6 +177,8 @@ class PlocSupvHelper : public SystemObject, public ExecutableObjectIF, public Ha
SdCardManager* sdcMan = nullptr;
#endif
uint8_t commandBuffer[supv::MAX_COMMAND_SIZE];
SpacePacketCreator creator;
SpBaseParams spParams = SpBaseParams(creator);
bool terminate = false;
@ -195,9 +198,9 @@ class PlocSupvHelper : public SystemObject, public ExecutableObjectIF, public Ha
ReturnValue_t continueUpdate();
ReturnValue_t writeUpdatePackets();
ReturnValue_t performEventBufferRequest();
ReturnValue_t handlePacketTransmission(SpacePacket& packet,
ReturnValue_t handlePacketTransmission(SpacePacketBase& packet,
uint32_t timeoutExecutionReport = 60000);
ReturnValue_t sendCommand(SpacePacket& packet);
ReturnValue_t sendCommand(SpacePacketBase& packet);
/**
* @brief Function which reads form the communication interface
*

View File

@ -1,9 +1,9 @@
#include <fsfw/datapool/PoolReadGuard.h>
#include "AcsController.h"
#include <fsfw/datapool/PoolReadGuard.h>
AcsController::AcsController(object_id_t objectId)
: ExtendedControllerBase(objectId, objects::NO_OBJECT),
mgmData(this) {}
: ExtendedControllerBase(objectId, objects::NO_OBJECT), mgmData(this) {}
ReturnValue_t AcsController::handleCommandMessage(CommandMessage *message) {
return HasReturnvaluesIF::RETURN_OK;

View File

@ -2,8 +2,9 @@
#define MISSION_CONTROLLER_ACSCONTROLLER_H_
#include <commonObjects.h>
#include "controllerdefinitions/AcsCtrlDefinitions.h"
#include <fsfw/controller/ExtendedControllerBase.h>
#include "controllerdefinitions/AcsCtrlDefinitions.h"
#include "fsfw_hal/devicehandlers/MgmLIS3MDLHandler.h"
#include "fsfw_hal/devicehandlers/MgmRM3100Handler.h"
#include "mission/devices/devicedefinitions/IMTQHandlerDefinitions.h"
@ -33,11 +34,16 @@ class AcsController : public ExtendedControllerBase {
// MGMs
acsctrl::MgmData mgmData;
MGMLIS3MDL::MgmPrimaryDataset mgm0Lis3Set = MGMLIS3MDL::MgmPrimaryDataset(objects::MGM_0_LIS3_HANDLER);
RM3100::Rm3100PrimaryDataset mgm1Rm3100Set = RM3100::Rm3100PrimaryDataset(objects::MGM_1_RM3100_HANDLER);
MGMLIS3MDL::MgmPrimaryDataset mgm2Lis3Set = MGMLIS3MDL::MgmPrimaryDataset(objects::MGM_2_LIS3_HANDLER);
RM3100::Rm3100PrimaryDataset mgm3Rm3100Set = RM3100::Rm3100PrimaryDataset(objects::MGM_3_RM3100_HANDLER);
IMTQ::CalibratedMtmMeasurementSet imtqMgmSet = IMTQ::CalibratedMtmMeasurementSet(objects::IMTQ_HANDLER);
MGMLIS3MDL::MgmPrimaryDataset mgm0Lis3Set =
MGMLIS3MDL::MgmPrimaryDataset(objects::MGM_0_LIS3_HANDLER);
RM3100::Rm3100PrimaryDataset mgm1Rm3100Set =
RM3100::Rm3100PrimaryDataset(objects::MGM_1_RM3100_HANDLER);
MGMLIS3MDL::MgmPrimaryDataset mgm2Lis3Set =
MGMLIS3MDL::MgmPrimaryDataset(objects::MGM_2_LIS3_HANDLER);
RM3100::Rm3100PrimaryDataset mgm3Rm3100Set =
RM3100::Rm3100PrimaryDataset(objects::MGM_3_RM3100_HANDLER);
IMTQ::CalibratedMtmMeasurementSet imtqMgmSet =
IMTQ::CalibratedMtmMeasurementSet(objects::IMTQ_HANDLER);
PoolEntry<float> mgm0PoolVec = PoolEntry<float>(3);
PoolEntry<float> mgm1PoolVec = PoolEntry<float>(3);

View File

@ -1,15 +1,14 @@
#ifndef MISSION_CONTROLLER_CONTROLLERDEFINITIONS_ACSCTRLDEFINITIONS_H_
#define MISSION_CONTROLLER_CONTROLLERDEFINITIONS_ACSCTRLDEFINITIONS_H_
#include <fsfw/datapoollocal/localPoolDefinitions.h>
#include <fsfw/datapoollocal/StaticLocalDataSet.h>
#include <fsfw/datapoollocal/localPoolDefinitions.h>
#include <cstdint>
namespace acsctrl {
enum SetIds : uint32_t {
MGM_SENSOR_DATA
};
enum SetIds : uint32_t { MGM_SENSOR_DATA };
enum PoolIds : lp_id_t {
MGM_0_LIS3_UT,
@ -20,7 +19,6 @@ enum PoolIds : lp_id_t {
MGM_IMTQ_CAL_ACT_STATUS
};
static constexpr uint8_t MGM_SET_ENTRIES = 5;
/**
@ -37,12 +35,12 @@ public:
lp_vec_t<float, 3> mgm3Rm3100 = lp_vec_t<float, 3>(sid.objectId, MGM_3_RM3100_UT, this);
// The IMTQ measurements are in integer nT
lp_vec_t<int32_t, 3> imtqCal = lp_vec_t<int32_t, 3>(sid.objectId, MGM_IMTQ_CAL_NT, this);
lp_var_t<uint8_t> actuationCalStatus = lp_var_t<uint8_t>(sid.objectId,
MGM_IMTQ_CAL_ACT_STATUS, this);
private:
lp_var_t<uint8_t> actuationCalStatus =
lp_var_t<uint8_t>(sid.objectId, MGM_IMTQ_CAL_ACT_STATUS, this);
private:
};
}
} // namespace acsctrl
#endif /* MISSION_CONTROLLER_CONTROLLERDEFINITIONS_ACSCTRLDEFINITIONS_H_ */

View File

@ -91,14 +91,17 @@ void ObjectFactory::produceGenericObjects(HealthTableIF** healthTable_) {
pus::PUS_SERVICE_2, 3, 10);
new Service3Housekeeping(objects::PUS_SERVICE_3_HOUSEKEEPING, apid::EIVE_OBSW,
pus::PUS_SERVICE_3);
new Service5EventReporting(PsbParams(objects::PUS_SERVICE_5_EVENT_REPORTING, apid::EIVE_OBSW,
pus::PUS_SERVICE_5), 15, 45);
new Service5EventReporting(
PsbParams(objects::PUS_SERVICE_5_EVENT_REPORTING, apid::EIVE_OBSW, pus::PUS_SERVICE_5), 15,
45);
new Service8FunctionManagement(objects::PUS_SERVICE_8_FUNCTION_MGMT, apid::EIVE_OBSW,
pus::PUS_SERVICE_8, 3, 60);
new Service9TimeManagement(PsbParams(objects::PUS_SERVICE_9_TIME_MGMT, apid::EIVE_OBSW, pus::PUS_SERVICE_9));
new Service9TimeManagement(
PsbParams(objects::PUS_SERVICE_9_TIME_MGMT, apid::EIVE_OBSW, pus::PUS_SERVICE_9));
new Service11TelecommandScheduling<common::OBSW_MAX_SCHEDULED_TCS>(
PsbParams(objects::PUS_SERVICE_11_TC_SCHEDULER, apid::EIVE_OBSW, pus::PUS_SERVICE_11), ccsdsDistrib);
PsbParams(objects::PUS_SERVICE_11_TC_SCHEDULER, apid::EIVE_OBSW, pus::PUS_SERVICE_11),
ccsdsDistrib);
new Service17Test(PsbParams(objects::PUS_SERVICE_17_TEST, apid::EIVE_OBSW, pus::PUS_SERVICE_17));
new Service20ParameterManagement(objects::PUS_SERVICE_20_PARAMETERS, apid::EIVE_OBSW,
pus::PUS_SERVICE_20);

View File

@ -30,8 +30,7 @@ class PCDUHandler : public PowerSwitchIF,
virtual ReturnValue_t initialize() override;
virtual ReturnValue_t performOperation(uint8_t counter) override;
virtual void handleChangedDataset(sid_t sid,
store_address_t storeId = store_address_t::invalid(),
virtual void handleChangedDataset(sid_t sid, store_address_t storeId = store_address_t::invalid(),
bool* clearMessage = nullptr) override;
virtual ReturnValue_t sendSwitchCommand(uint8_t switchNr, ReturnValue_t onOff) override;

View File

@ -0,0 +1,83 @@
#ifndef MISSION_DEVICES_DEVICEDEFINITIONS_SPBASE_H_
#define MISSION_DEVICES_DEVICEDEFINITIONS_SPBASE_H_
#include <fsfw/tmtcpacket/ccsds/SpacePacketCreator.h>
#include <cstdint>
struct SpBaseParams {
SpBaseParams(SpacePacketCreator& creator) : creator(creator) {}
SpBaseParams(SpacePacketCreator& creator, uint8_t* buf, size_t maxSize)
: creator(creator), buf(buf), maxSize(maxSize) {}
void setPayloadLen(size_t payloadLen_) { dataFieldLen = payloadLen_ + 2; }
void setDataFieldLen(size_t dataFieldLen_) { dataFieldLen = dataFieldLen_; }
SpacePacketCreator& creator;
uint8_t* buf = nullptr;
size_t maxSize = 0;
size_t dataFieldLen = 0;
};
class SpacePacketBase {
public:
SpacePacketBase(SpBaseParams params) : spParams(params) { updateFields(); }
SpacePacketBase(SpBaseParams params, uint16_t apid, uint16_t seqCount) : spParams(params) {
spParams.creator.setApid(apid);
spParams.creator.setSeqCount(seqCount);
updateFields();
}
void updateFields() {
payloadStart = spParams.buf + ccsds::HEADER_LEN;
spParams.creator.setDataLen(spParams.dataFieldLen - 1);
spParams.creator.setPacketType(ccsds::PacketType::TC);
}
const uint8_t* getFullPacket() const { return spParams.buf; }
size_t getFullPacketLen() const { return spParams.creator.getFullPacketLen(); }
uint16_t getApid() const { return spParams.creator.getApid(); }
ReturnValue_t checkPayloadLen() {
if (ccsds::HEADER_LEN + spParams.dataFieldLen > spParams.maxSize) {
return SerializeIF::BUFFER_TOO_SHORT;
}
return result::OK;
}
ReturnValue_t serializeHeader() {
updateFields();
size_t serLen = 0;
return spParams.creator.serializeBe(spParams.buf, serLen, spParams.maxSize);
}
ReturnValue_t checkSizeAndSerializeHeader() {
ReturnValue_t result = checkPayloadLen();
if (result != result::OK) {
return result;
}
return serializeHeader();
}
ReturnValue_t calcCrc() {
/* Calculate crc */
uint16_t crc = CRC::crc16ccitt(spParams.buf, ccsds::HEADER_LEN + spParams.dataFieldLen - 2);
/* Add crc to packet data field of space packet */
size_t serializedSize = 0;
return SerializeAdapter::serialize<uint16_t>(&crc, &payloadStart, &serializedSize, sizeof(crc),
SerializeIF::Endianness::BIG);
}
protected:
SpBaseParams spParams;
uint8_t* payloadStart;
};
#endif /* MISSION_DEVICES_DEVICEDEFINITIONS_SPBASE_H_ */

View File

@ -12,7 +12,10 @@ object_id_t TmFunnel::storageDestination = objects::NO_OBJECT;
TmFunnel::TmFunnel(object_id_t objectId, CdsShortTimeStamper& timeReader, uint32_t messageDepth,
uint8_t reportReceptionVc)
: SystemObject(objectId), timeReader(timeReader), messageDepth(messageDepth), reportReceptionVc(reportReceptionVc) {
: SystemObject(objectId),
timeReader(timeReader),
messageDepth(messageDepth),
reportReceptionVc(reportReceptionVc) {
auto mqArgs = MqArgs(objectId, static_cast<void*>(this));
tmQueue = QueueFactory::instance()->createMessageQueue(
messageDepth, MessageQueueMessage::MAX_MESSAGE_SIZE, &mqArgs);
@ -61,7 +64,6 @@ ReturnValue_t TmFunnel::handlePacket(TmTcMessage* message) {
sourceSequenceCount = sourceSequenceCount % ccsds::LIMIT_SEQUENCE_COUNT;
packet.updateErrorControl();
result = tmQueue->sendToDefault(message);
if (result != HasReturnvaluesIF::RETURN_OK) {
tmStore->deleteData(message->getStorageId());

View File

@ -24,7 +24,8 @@ class TmFunnel : public AcceptsTelemetryIF, public ExecutableObjectIF, public Sy
friend void(Factory::setStaticFrameworkObjectIds)();
public:
TmFunnel(object_id_t objectId, CdsShortTimeStamper& timeReader, uint32_t messageDepth = 20, uint8_t reportReceptionVc = 0);
TmFunnel(object_id_t objectId, CdsShortTimeStamper& timeReader, uint32_t messageDepth = 20,
uint8_t reportReceptionVc = 0);
virtual ~TmFunnel();
virtual MessageQueueId_t getReportReceptionQueue(uint8_t virtualChannel = 0) override;