no payload packet impl
This commit is contained in:
parent
32865d1834
commit
23025eec7a
@ -153,7 +153,7 @@ class TcBase : public ploc::SpTcBase, public MPSoCReturnValuesIF {
|
||||
*/
|
||||
TcBase(ploc::SpTcParams params, uint16_t apid, uint16_t sequenceCount)
|
||||
: ploc::SpTcBase(params, apid, sequenceCount) {
|
||||
spParams.setFullPacketLen(INIT_LENGTH);
|
||||
spParams.setFullPayloadLen(INIT_LENGTH);
|
||||
}
|
||||
|
||||
ReturnValue_t buildPacket() { return buildPacket(nullptr, 0); }
|
||||
@ -181,7 +181,7 @@ class TcBase : public ploc::SpTcBase, public MPSoCReturnValuesIF {
|
||||
if (res != returnvalue::OK) {
|
||||
return res;
|
||||
}
|
||||
return calcCrc();
|
||||
return calcAndSetCrc();
|
||||
}
|
||||
|
||||
protected:
|
||||
@ -206,7 +206,7 @@ class TcMemRead : public TcBase {
|
||||
*/
|
||||
TcMemRead(ploc::SpTcParams params, uint16_t sequenceCount)
|
||||
: TcBase(params, apid::TC_MEM_READ, sequenceCount) {
|
||||
spParams.setFullPacketLen(COMMAND_LENGTH + CRC_SIZE);
|
||||
spParams.setFullPayloadLen(COMMAND_LENGTH + CRC_SIZE);
|
||||
}
|
||||
|
||||
uint16_t getMemLen() const { return memLen; }
|
||||
@ -267,7 +267,7 @@ class TcMemWrite : public TcBase {
|
||||
}
|
||||
uint16_t memLen =
|
||||
*(commandData + MEM_ADDRESS_SIZE) << 8 | *(commandData + MEM_ADDRESS_SIZE + 1);
|
||||
spParams.setFullPacketLen(MIN_FIXED_PAYLOAD_LENGTH + memLen * 4 + CRC_SIZE);
|
||||
spParams.setFullPayloadLen(MIN_FIXED_PAYLOAD_LENGTH + memLen * 4 + CRC_SIZE);
|
||||
result = checkPayloadLen();
|
||||
if (result != returnvalue::OK) {
|
||||
return result;
|
||||
@ -313,7 +313,7 @@ class FlashFopen : public ploc::SpTcBase {
|
||||
ReturnValue_t createPacket(std::string filename, char accessMode_) {
|
||||
accessMode = accessMode_;
|
||||
size_t nameSize = filename.size();
|
||||
spParams.setFullPacketLen(nameSize + sizeof(NULL_TERMINATOR) + sizeof(accessMode) + CRC_SIZE);
|
||||
spParams.setFullPayloadLen(nameSize + sizeof(NULL_TERMINATOR) + sizeof(accessMode) + CRC_SIZE);
|
||||
ReturnValue_t result = checkPayloadLen();
|
||||
if (result != returnvalue::OK) {
|
||||
return result;
|
||||
@ -322,7 +322,7 @@ class FlashFopen : public ploc::SpTcBase {
|
||||
*(spParams.buf + nameSize) = NULL_TERMINATOR;
|
||||
std::memcpy(payloadStart + nameSize + sizeof(NULL_TERMINATOR), &accessMode, sizeof(accessMode));
|
||||
updateSpFields();
|
||||
return calcCrc();
|
||||
return calcAndSetCrc();
|
||||
}
|
||||
|
||||
private:
|
||||
@ -339,14 +339,14 @@ class FlashFclose : public ploc::SpTcBase {
|
||||
|
||||
ReturnValue_t createPacket(std::string filename) {
|
||||
size_t nameSize = filename.size();
|
||||
spParams.setFullPacketLen(nameSize + sizeof(NULL_TERMINATOR) + CRC_SIZE);
|
||||
spParams.setFullPayloadLen(nameSize + sizeof(NULL_TERMINATOR) + CRC_SIZE);
|
||||
ReturnValue_t result = checkPayloadLen();
|
||||
if (result != returnvalue::OK) {
|
||||
return result;
|
||||
}
|
||||
std::memcpy(payloadStart, filename.c_str(), nameSize);
|
||||
*(payloadStart + nameSize) = NULL_TERMINATOR;
|
||||
return calcCrc();
|
||||
return calcAndSetCrc();
|
||||
}
|
||||
};
|
||||
|
||||
@ -365,7 +365,7 @@ class TcFlashWrite : public ploc::SpTcBase {
|
||||
sif::debug << "FlashWrite::createPacket: Command data too big" << std::endl;
|
||||
return returnvalue::FAILED;
|
||||
}
|
||||
spParams.setFullPacketLen(static_cast<uint16_t>(writeLen) + 4 + CRC_SIZE);
|
||||
spParams.setFullPayloadLen(static_cast<uint16_t>(writeLen) + 4 + CRC_SIZE);
|
||||
result = checkPayloadLen();
|
||||
if (result != returnvalue::OK) {
|
||||
return result;
|
||||
@ -382,7 +382,7 @@ class TcFlashWrite : public ploc::SpTcBase {
|
||||
if (res != returnvalue::OK) {
|
||||
return res;
|
||||
}
|
||||
return calcCrc();
|
||||
return calcAndSetCrc();
|
||||
}
|
||||
|
||||
private:
|
||||
@ -399,7 +399,7 @@ class TcFlashDelete : public ploc::SpTcBase {
|
||||
|
||||
ReturnValue_t buildPacket(std::string filename) {
|
||||
size_t nameSize = filename.size();
|
||||
spParams.setFullPacketLen(nameSize + sizeof(NULL_TERMINATOR) + CRC_SIZE);
|
||||
spParams.setFullPayloadLen(nameSize + sizeof(NULL_TERMINATOR) + CRC_SIZE);
|
||||
auto res = checkPayloadLen();
|
||||
if (res != returnvalue::OK) {
|
||||
return res;
|
||||
@ -412,7 +412,7 @@ class TcFlashDelete : public ploc::SpTcBase {
|
||||
if (res != returnvalue::OK) {
|
||||
return res;
|
||||
}
|
||||
return calcCrc();
|
||||
return calcAndSetCrc();
|
||||
}
|
||||
};
|
||||
|
||||
@ -439,7 +439,7 @@ class TcReplayStart : public TcBase {
|
||||
protected:
|
||||
ReturnValue_t initPacket(const uint8_t* commandData, size_t commandDataLen) override {
|
||||
ReturnValue_t result = returnvalue::OK;
|
||||
spParams.setFullPacketLen(commandDataLen + CRC_SIZE);
|
||||
spParams.setFullPayloadLen(commandDataLen + CRC_SIZE);
|
||||
result = lengthCheck(commandDataLen);
|
||||
if (result != returnvalue::OK) {
|
||||
return result;
|
||||
@ -500,7 +500,7 @@ class TcDownlinkPwrOn : public TcBase {
|
||||
if (result != returnvalue::OK) {
|
||||
return result;
|
||||
}
|
||||
spParams.setFullPacketLen(commandDataLen + sizeof(MAX_AMPLITUDE) + CRC_SIZE);
|
||||
spParams.setFullPayloadLen(commandDataLen + sizeof(MAX_AMPLITUDE) + CRC_SIZE);
|
||||
result = checkPayloadLen();
|
||||
if (result != returnvalue::OK) {
|
||||
return result;
|
||||
@ -571,7 +571,7 @@ class TcReplayWriteSeq : public TcBase {
|
||||
protected:
|
||||
ReturnValue_t initPacket(const uint8_t* commandData, size_t commandDataLen) override {
|
||||
ReturnValue_t result = returnvalue::OK;
|
||||
spParams.setFullPacketLen(commandDataLen + sizeof(NULL_TERMINATOR) + CRC_SIZE);
|
||||
spParams.setFullPayloadLen(commandDataLen + sizeof(NULL_TERMINATOR) + CRC_SIZE);
|
||||
result = lengthCheck(commandDataLen);
|
||||
if (result != returnvalue::OK) {
|
||||
return result;
|
||||
@ -657,8 +657,8 @@ class TcCamcmdSend : public TcBase {
|
||||
return INVALID_LENGTH;
|
||||
}
|
||||
uint16_t dataLen = static_cast<uint16_t>(commandDataLen + sizeof(CARRIAGE_RETURN));
|
||||
spParams.setFullPacketLen(sizeof(dataLen) + commandDataLen + sizeof(CARRIAGE_RETURN) +
|
||||
CRC_SIZE);
|
||||
spParams.setFullPayloadLen(sizeof(dataLen) + commandDataLen + sizeof(CARRIAGE_RETURN) +
|
||||
CRC_SIZE);
|
||||
auto res = checkPayloadLen();
|
||||
if (res != returnvalue::OK) {
|
||||
return res;
|
||||
|
@ -13,6 +13,8 @@
|
||||
#include "linux/devices/devicedefinitions/SupvReturnValuesIF.h"
|
||||
#include "mission/devices/devicedefinitions/SpBase.h"
|
||||
|
||||
using namespace returnvalue;
|
||||
|
||||
namespace supv {
|
||||
|
||||
typedef struct {
|
||||
@ -218,14 +220,28 @@ static const uint16_t APID_GET_HK_REPORT = 0xC6;
|
||||
static const uint16_t APID_MASK = 0x3FF;
|
||||
static const uint16_t SEQUENCE_COUNT_MASK = 0xFFF;
|
||||
|
||||
/** Offset from first byte in Space packet to first byte of data field */
|
||||
static const uint8_t DATA_FIELD_OFFSET = 6;
|
||||
static constexpr uint16_t DEFAULT_SEQUENCE_COUNT = 1;
|
||||
static const uint8_t HK_SET_ENTRIES = 13;
|
||||
static const uint8_t BOOT_REPORT_SET_ENTRIES = 10;
|
||||
static const uint8_t LATCHUP_RPT_SET_ENTRIES = 16;
|
||||
static const uint8_t LOGGING_RPT_SET_ENTRIES = 16;
|
||||
static const uint8_t ADC_RPT_SET_ENTRIES = 32;
|
||||
|
||||
/**
|
||||
* Space packet length for fixed size packets. This is the size of the whole packet data
|
||||
* field. For the length field in the space packet this size will be substracted by one.
|
||||
*/
|
||||
static const uint16_t LENGTH_EMPTY_TC = 2; // Only CRC will be transported with the data field
|
||||
static const uint32_t HK_SET_ID = HK_REPORT;
|
||||
static const uint32_t BOOT_REPORT_SET_ID = BOOT_STATUS_REPORT;
|
||||
static const uint32_t LATCHUP_RPT_ID = LATCHUP_REPORT;
|
||||
static const uint32_t LOGGING_RPT_ID = LOGGING_REPORT;
|
||||
static const uint32_t ADC_REPORT_SET_ID = ADC_REPORT;
|
||||
|
||||
namespace recv_timeout {
|
||||
// Erase memory can require up to 60 seconds for execution
|
||||
static const uint32_t ERASE_MEMORY = 60000;
|
||||
static const uint32_t UPDATE_STATUS_REPORT = 70000;
|
||||
} // namespace recv_timeout
|
||||
|
||||
static constexpr size_t TIMESTAMP_LEN = 7;
|
||||
static constexpr size_t SECONDARY_HEADER_LEN = TIMESTAMP_LEN + 1;
|
||||
static constexpr size_t CRC_LEN = 2;
|
||||
|
||||
/** This is the maximum length of a space packet as defined by the TAS ICD */
|
||||
static const size_t MAX_COMMAND_SIZE = 1024;
|
||||
@ -233,6 +249,10 @@ static const size_t MAX_DATA_CAPACITY = 1016;
|
||||
/** This is the maximum size of a space packet for the supervisor */
|
||||
static const size_t MAX_PACKET_SIZE = 1024;
|
||||
|
||||
static constexpr size_t MIN_PAYLOAD_LEN = SECONDARY_HEADER_LEN + CRC_LEN;
|
||||
static constexpr size_t MIN_TC_LEN = ccsds::HEADER_LEN + MIN_PAYLOAD_LEN;
|
||||
static constexpr size_t PAYLOAD_OFFSET = ccsds::HEADER_LEN + SECONDARY_HEADER_LEN;
|
||||
|
||||
struct UpdateParams {
|
||||
std::string file;
|
||||
uint8_t memId;
|
||||
@ -335,29 +355,6 @@ enum PoolIds : lp_id_t {
|
||||
ADC_ENG_15
|
||||
};
|
||||
|
||||
static constexpr uint16_t DEFAULT_SEQUENCE_COUNT = 1;
|
||||
static const uint8_t HK_SET_ENTRIES = 13;
|
||||
static const uint8_t BOOT_REPORT_SET_ENTRIES = 10;
|
||||
static const uint8_t LATCHUP_RPT_SET_ENTRIES = 16;
|
||||
static const uint8_t LOGGING_RPT_SET_ENTRIES = 16;
|
||||
static const uint8_t ADC_RPT_SET_ENTRIES = 32;
|
||||
|
||||
static const uint32_t HK_SET_ID = HK_REPORT;
|
||||
static const uint32_t BOOT_REPORT_SET_ID = BOOT_STATUS_REPORT;
|
||||
static const uint32_t LATCHUP_RPT_ID = LATCHUP_REPORT;
|
||||
static const uint32_t LOGGING_RPT_ID = LOGGING_REPORT;
|
||||
static const uint32_t ADC_REPORT_SET_ID = ADC_REPORT;
|
||||
|
||||
namespace recv_timeout {
|
||||
// Erase memory can require up to 60 seconds for execution
|
||||
static const uint32_t ERASE_MEMORY = 60000;
|
||||
static const uint32_t UPDATE_STATUS_REPORT = 70000;
|
||||
} // namespace recv_timeout
|
||||
|
||||
static constexpr size_t TIMESTAMP_LEN = 7;
|
||||
static constexpr size_t SECONDARY_HEADER_LEN = TIMESTAMP_LEN + 1;
|
||||
static constexpr size_t CRC_LEN = 2;
|
||||
|
||||
struct SupvTcParams : public ploc::SpTcParams {
|
||||
public:
|
||||
SupvTcParams(SpacePacketCreator& creator) : ploc::SpTcParams(creator) {}
|
||||
@ -366,20 +363,49 @@ struct SupvTcParams : public ploc::SpTcParams {
|
||||
: ploc::SpTcParams(creator, buf, maxSize) {}
|
||||
|
||||
void setLenFromPayloadLen(size_t payloadLen) {
|
||||
setFullPacketLen(ccsds::HEADER_LEN + SECONDARY_HEADER_LEN + payloadLen + CRC_LEN);
|
||||
setFullPayloadLen(ccsds::HEADER_LEN + SECONDARY_HEADER_LEN + payloadLen + CRC_LEN);
|
||||
}
|
||||
};
|
||||
|
||||
class SupvTcBase : public ploc::SpTcBase {
|
||||
public:
|
||||
SupvTcBase(SupvTcParams params) : ploc::SpTcBase(params) {}
|
||||
SupvTcBase(SupvTcParams params) : ploc::SpTcBase(params) { setup(); }
|
||||
|
||||
SupvTcBase(SupvTcParams params, uint16_t apid, uint16_t seqCount)
|
||||
: ploc::SpTcBase(params, apid, seqCount) {}
|
||||
SupvTcBase(SupvTcParams params, uint16_t apid, uint8_t serviceId, uint16_t seqCount)
|
||||
: ploc::SpTcBase(params, apid, seqCount), serviceId(serviceId) {
|
||||
if (setup() == OK) {
|
||||
params.buf + supv::PAYLOAD_OFFSET = serviceId;
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
uint8_t serviceId = 0;
|
||||
|
||||
ReturnValue_t setup() {
|
||||
if (spParams.maxSize < MIN_PAYLOAD_LEN) {
|
||||
sif::error << "SupvTcBase::SupvTcBase: Passed buffer is too small" << std::endl;
|
||||
return returnvalue::FAILED;
|
||||
}
|
||||
std::memset(spParams.buf + ccsds::HEADER_LEN, 0, TIMESTAMP_LEN);
|
||||
return returnvalue::OK;
|
||||
}
|
||||
};
|
||||
|
||||
class NoPayloadPacket : public SupvTcBase {
|
||||
public:
|
||||
NoPayloadPacket(SupvTcParams params, uint16_t apid, uint8_t serviceId, uint16_t seqCount)
|
||||
: SupvTcBase(params, apid, serviceId, seqCount) {}
|
||||
|
||||
ReturnValue_t buildPacket() {
|
||||
ReturnValue_t result = checkSizeAndSerializeHeader();
|
||||
if (result != OK) {
|
||||
return result;
|
||||
}
|
||||
return calcAndSetCrc();
|
||||
}
|
||||
|
||||
private:
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief This class creates a space packet containing only the header data and the CRC.
|
||||
*/
|
||||
@ -393,7 +419,7 @@ class ApidOnlyPacket : public ploc::SpTcBase {
|
||||
* @note Sequence count of empty packet is always 1.
|
||||
*/
|
||||
ApidOnlyPacket(ploc::SpTcParams params, uint16_t apid) : ploc::SpTcBase(params) {
|
||||
spParams.setFullPacketLen(LENGTH_EMPTY_TC);
|
||||
spParams.setFullPayloadLen(MIN_TC_LEN);
|
||||
spParams.creator.setApid(apid);
|
||||
}
|
||||
|
||||
@ -402,7 +428,7 @@ class ApidOnlyPacket : public ploc::SpTcBase {
|
||||
if (res != returnvalue::OK) {
|
||||
return res;
|
||||
}
|
||||
return calcCrc();
|
||||
return calcAndSetCrc();
|
||||
}
|
||||
|
||||
private:
|
||||
@ -428,7 +454,7 @@ class MPSoCBootSelect : public ploc::SpTcBase {
|
||||
* @note Selection of partitions is currently not supported.
|
||||
*/
|
||||
MPSoCBootSelect(ploc::SpTcParams params) : ploc::SpTcBase(params) {
|
||||
spParams.setFullPacketLen(DATA_FIELD_LENGTH);
|
||||
spParams.setFullPayloadLen(DATA_FIELD_LENGTH);
|
||||
spParams.creator.setApid(APID_SEL_MPSOC_BOOT_IMAGE);
|
||||
spParams.creator.setSeqCount(DEFAULT_SEQUENCE_COUNT);
|
||||
}
|
||||
@ -439,7 +465,7 @@ class MPSoCBootSelect : public ploc::SpTcBase {
|
||||
return res;
|
||||
}
|
||||
initPacket(mem, bp0, bp1, bp2);
|
||||
return calcCrc();
|
||||
return calcAndSetCrc();
|
||||
}
|
||||
|
||||
private:
|
||||
@ -474,7 +500,7 @@ class EnableNvms : public ploc::SpTcBase {
|
||||
* @param bp2 Partition pin 2
|
||||
*/
|
||||
EnableNvms(ploc::SpTcParams params) : ploc::SpTcBase(params) {
|
||||
spParams.setFullPacketLen(DATA_FIELD_LENGTH);
|
||||
spParams.setFullPayloadLen(DATA_FIELD_LENGTH);
|
||||
spParams.creator.setApid(APID_ENABLE_NVMS);
|
||||
spParams.creator.setSeqCount(DEFAULT_SEQUENCE_COUNT);
|
||||
}
|
||||
@ -485,7 +511,7 @@ class EnableNvms : public ploc::SpTcBase {
|
||||
return res;
|
||||
}
|
||||
initPacket(nvm01, nvm3);
|
||||
return calcCrc();
|
||||
return calcAndSetCrc();
|
||||
}
|
||||
|
||||
private:
|
||||
@ -504,7 +530,7 @@ class EnableNvms : public ploc::SpTcBase {
|
||||
class SetTimeRef : public ploc::SpTcBase {
|
||||
public:
|
||||
SetTimeRef(ploc::SpTcParams params) : ploc::SpTcBase(params) {
|
||||
spParams.setFullPacketLen(DATA_FIELD_LENGTH);
|
||||
spParams.setFullPayloadLen(DATA_FIELD_LENGTH);
|
||||
spParams.creator.setApid(APID_SET_TIME_REF);
|
||||
spParams.creator.setSeqCount(DEFAULT_SEQUENCE_COUNT);
|
||||
}
|
||||
@ -518,7 +544,7 @@ class SetTimeRef : public ploc::SpTcBase {
|
||||
if (res != returnvalue::OK) {
|
||||
return res;
|
||||
}
|
||||
return calcCrc();
|
||||
return calcAndSetCrc();
|
||||
}
|
||||
|
||||
private:
|
||||
@ -583,7 +609,7 @@ class SetBootTimeout : public ploc::SpTcBase {
|
||||
* @param timeout The boot timeout in milliseconds.
|
||||
*/
|
||||
SetBootTimeout(ploc::SpTcParams params) : ploc::SpTcBase(params) {
|
||||
spParams.setFullPacketLen(DATA_FIELD_LENGTH);
|
||||
spParams.setFullPayloadLen(DATA_FIELD_LENGTH);
|
||||
spParams.creator.setApid(APID_SET_BOOT_TIMEOUT);
|
||||
spParams.creator.setSeqCount(DEFAULT_SEQUENCE_COUNT);
|
||||
}
|
||||
@ -594,7 +620,7 @@ class SetBootTimeout : public ploc::SpTcBase {
|
||||
return res;
|
||||
}
|
||||
initPacket(timeout);
|
||||
return calcCrc();
|
||||
return calcAndSetCrc();
|
||||
}
|
||||
|
||||
private:
|
||||
@ -620,7 +646,7 @@ class SetRestartTries : public ploc::SpTcBase {
|
||||
* @param restartTries Maximum restart tries to set.
|
||||
*/
|
||||
SetRestartTries(ploc::SpTcParams params) : ploc::SpTcBase(params) {
|
||||
spParams.setFullPacketLen(DATA_FIELD_LENGTH);
|
||||
spParams.setFullPayloadLen(DATA_FIELD_LENGTH);
|
||||
spParams.creator.setApid(APID_SET_MAX_RESTART_TRIES);
|
||||
spParams.creator.setSeqCount(DEFAULT_SEQUENCE_COUNT);
|
||||
}
|
||||
@ -631,7 +657,7 @@ class SetRestartTries : public ploc::SpTcBase {
|
||||
return res;
|
||||
}
|
||||
initPacket(restartTries);
|
||||
return calcCrc();
|
||||
return calcAndSetCrc();
|
||||
}
|
||||
|
||||
private:
|
||||
@ -654,7 +680,7 @@ class DisablePeriodicHkTransmission : public ploc::SpTcBase {
|
||||
* @brief Constructor
|
||||
*/
|
||||
DisablePeriodicHkTransmission(ploc::SpTcParams params) : ploc::SpTcBase(params) {
|
||||
spParams.setFullPacketLen(DATA_FIELD_LENGTH);
|
||||
spParams.setFullPayloadLen(DATA_FIELD_LENGTH);
|
||||
spParams.creator.setApid(APID_DISABLE_HK);
|
||||
spParams.creator.setSeqCount(DEFAULT_SEQUENCE_COUNT);
|
||||
}
|
||||
@ -665,7 +691,7 @@ class DisablePeriodicHkTransmission : public ploc::SpTcBase {
|
||||
return res;
|
||||
}
|
||||
initPacket();
|
||||
return calcCrc();
|
||||
return calcAndSetCrc();
|
||||
}
|
||||
|
||||
private:
|
||||
@ -690,7 +716,7 @@ class LatchupAlert : public ploc::SpTcBase {
|
||||
* 3 - 3.3V, 4 - NVM_4XO, 5 - MISSION, 6 - SAFECOTS)
|
||||
*/
|
||||
LatchupAlert(ploc::SpTcParams params) : ploc::SpTcBase(params) {
|
||||
spParams.setFullPacketLen(DATA_FIELD_LENGTH);
|
||||
spParams.setFullPayloadLen(DATA_FIELD_LENGTH);
|
||||
spParams.creator.setSeqCount(DEFAULT_SEQUENCE_COUNT);
|
||||
}
|
||||
|
||||
@ -705,7 +731,7 @@ class LatchupAlert : public ploc::SpTcBase {
|
||||
return res;
|
||||
}
|
||||
initPacket(latchupId);
|
||||
return calcCrc();
|
||||
return calcAndSetCrc();
|
||||
}
|
||||
|
||||
private:
|
||||
@ -728,7 +754,7 @@ class SetAlertlimit : public ploc::SpTcBase {
|
||||
* @param dutycycle
|
||||
*/
|
||||
SetAlertlimit(ploc::SpTcParams params) : ploc::SpTcBase(params) {
|
||||
spParams.setFullPacketLen(DATA_FIELD_LENGTH);
|
||||
spParams.setFullPayloadLen(DATA_FIELD_LENGTH);
|
||||
spParams.creator.setApid(APID_SET_ALERT_LIMIT);
|
||||
spParams.creator.setSeqCount(DEFAULT_SEQUENCE_COUNT);
|
||||
}
|
||||
@ -742,7 +768,7 @@ class SetAlertlimit : public ploc::SpTcBase {
|
||||
if (res != returnvalue::OK) {
|
||||
return res;
|
||||
}
|
||||
return calcCrc();
|
||||
return calcAndSetCrc();
|
||||
}
|
||||
|
||||
private:
|
||||
@ -771,7 +797,7 @@ class SetAdcEnabledChannels : public ploc::SpTcBase {
|
||||
* @param ch Defines channels to be enabled or disabled.
|
||||
*/
|
||||
SetAdcEnabledChannels(ploc::SpTcParams params) : ploc::SpTcBase(params) {
|
||||
spParams.setFullPacketLen(DATA_FIELD_LENGTH);
|
||||
spParams.setFullPayloadLen(DATA_FIELD_LENGTH);
|
||||
spParams.creator.setApid(APID_SET_ADC_ENABLED_CHANNELS);
|
||||
spParams.creator.setSeqCount(DEFAULT_SEQUENCE_COUNT);
|
||||
}
|
||||
@ -782,7 +808,7 @@ class SetAdcEnabledChannels : public ploc::SpTcBase {
|
||||
return res;
|
||||
}
|
||||
initPacket(ch);
|
||||
return calcCrc();
|
||||
return calcAndSetCrc();
|
||||
}
|
||||
|
||||
private:
|
||||
@ -810,7 +836,7 @@ class SetAdcWindowAndStride : public ploc::SpTcBase {
|
||||
* @param stridingStepSize
|
||||
*/
|
||||
SetAdcWindowAndStride(ploc::SpTcParams params) : ploc::SpTcBase(params) {
|
||||
spParams.setFullPacketLen(DATA_FIELD_LENGTH);
|
||||
spParams.setFullPayloadLen(DATA_FIELD_LENGTH);
|
||||
spParams.creator.setApid(APID_SET_ADC_WINDOW_AND_STRIDE);
|
||||
spParams.creator.setSeqCount(DEFAULT_SEQUENCE_COUNT);
|
||||
}
|
||||
@ -821,7 +847,7 @@ class SetAdcWindowAndStride : public ploc::SpTcBase {
|
||||
return res;
|
||||
}
|
||||
initPacket(windowSize, stridingStepSize);
|
||||
return calcCrc();
|
||||
return calcAndSetCrc();
|
||||
}
|
||||
|
||||
private:
|
||||
@ -850,7 +876,7 @@ class SetAdcThreshold : public ploc::SpTcBase {
|
||||
* @param threshold
|
||||
*/
|
||||
SetAdcThreshold(ploc::SpTcParams params) : ploc::SpTcBase(params) {
|
||||
spParams.setFullPacketLen(DATA_FIELD_LENGTH);
|
||||
spParams.setFullPayloadLen(DATA_FIELD_LENGTH);
|
||||
spParams.creator.setApid(APID_SET_ADC_THRESHOLD);
|
||||
spParams.creator.setSeqCount(DEFAULT_SEQUENCE_COUNT);
|
||||
}
|
||||
@ -861,7 +887,7 @@ class SetAdcThreshold : public ploc::SpTcBase {
|
||||
return res;
|
||||
}
|
||||
initPacket(threshold);
|
||||
return calcCrc();
|
||||
return calcAndSetCrc();
|
||||
}
|
||||
|
||||
private:
|
||||
@ -888,7 +914,7 @@ class RunAutoEmTests : public ploc::SpTcBase {
|
||||
* @param test 1 - complete EM test, 2 - Short test (only memory readback NVM0,1,3)
|
||||
*/
|
||||
RunAutoEmTests(ploc::SpTcParams params) : ploc::SpTcBase(params) {
|
||||
spParams.setFullPacketLen(DATA_FIELD_LENGTH);
|
||||
spParams.setFullPayloadLen(DATA_FIELD_LENGTH);
|
||||
spParams.creator.setApid(APID_RUN_AUTO_EM_TESTS);
|
||||
spParams.creator.setSeqCount(DEFAULT_SEQUENCE_COUNT);
|
||||
}
|
||||
@ -899,7 +925,7 @@ class RunAutoEmTests : public ploc::SpTcBase {
|
||||
return res;
|
||||
}
|
||||
initPacket(test);
|
||||
return calcCrc();
|
||||
return calcAndSetCrc();
|
||||
}
|
||||
|
||||
private:
|
||||
@ -930,7 +956,7 @@ class MramCmd : public ploc::SpTcBase {
|
||||
* @note The content at the stop address is excluded from the dump or wipe operation.
|
||||
*/
|
||||
MramCmd(ploc::SpTcParams params) : ploc::SpTcBase(params) {
|
||||
spParams.setFullPacketLen(DATA_FIELD_LENGTH);
|
||||
spParams.setFullPayloadLen(DATA_FIELD_LENGTH);
|
||||
spParams.creator.setSeqCount(DEFAULT_SEQUENCE_COUNT);
|
||||
}
|
||||
|
||||
@ -947,7 +973,7 @@ class MramCmd : public ploc::SpTcBase {
|
||||
return res;
|
||||
}
|
||||
initPacket(start, stop);
|
||||
return calcCrc();
|
||||
return calcAndSetCrc();
|
||||
}
|
||||
|
||||
private:
|
||||
@ -984,7 +1010,7 @@ class SetGpio : public ploc::SpTcBase {
|
||||
* @param val
|
||||
*/
|
||||
SetGpio(ploc::SpTcParams params) : ploc::SpTcBase(params) {
|
||||
spParams.setFullPacketLen(DATA_FIELD_LENGTH);
|
||||
spParams.setFullPayloadLen(DATA_FIELD_LENGTH);
|
||||
spParams.creator.setApid(APID_SET_GPIO);
|
||||
spParams.creator.setSeqCount(DEFAULT_SEQUENCE_COUNT);
|
||||
}
|
||||
@ -995,7 +1021,7 @@ class SetGpio : public ploc::SpTcBase {
|
||||
return res;
|
||||
}
|
||||
initPacket(port, pin, val);
|
||||
return calcCrc();
|
||||
return calcAndSetCrc();
|
||||
}
|
||||
|
||||
private:
|
||||
@ -1028,7 +1054,7 @@ class ReadGpio : public ploc::SpTcBase {
|
||||
* @param pin
|
||||
*/
|
||||
ReadGpio(ploc::SpTcParams params) : ploc::SpTcBase(params) {
|
||||
spParams.setFullPacketLen(DATA_FIELD_LENGTH);
|
||||
spParams.setFullPayloadLen(DATA_FIELD_LENGTH);
|
||||
spParams.creator.setApid(APID_READ_GPIO);
|
||||
spParams.creator.setSeqCount(DEFAULT_SEQUENCE_COUNT);
|
||||
}
|
||||
@ -1039,7 +1065,7 @@ class ReadGpio : public ploc::SpTcBase {
|
||||
return res;
|
||||
}
|
||||
initPacket(port, pin);
|
||||
return calcCrc();
|
||||
return calcAndSetCrc();
|
||||
}
|
||||
|
||||
private:
|
||||
@ -1085,7 +1111,7 @@ class FactoryReset : public ploc::SpTcBase {
|
||||
return res;
|
||||
}
|
||||
initPacket(op);
|
||||
return calcCrc();
|
||||
return calcAndSetCrc();
|
||||
}
|
||||
|
||||
private:
|
||||
@ -1105,14 +1131,14 @@ class FactoryReset : public ploc::SpTcBase {
|
||||
default:
|
||||
break;
|
||||
}
|
||||
spParams.setFullPacketLen(packetDataLen);
|
||||
spParams.setFullPayloadLen(packetDataLen);
|
||||
}
|
||||
};
|
||||
|
||||
class SetShutdownTimeout : public ploc::SpTcBase {
|
||||
public:
|
||||
SetShutdownTimeout(ploc::SpTcParams params) : ploc::SpTcBase(params) {
|
||||
spParams.setFullPacketLen(PAYLOAD_LEN + 2);
|
||||
spParams.setFullPayloadLen(PAYLOAD_LEN + 2);
|
||||
spParams.creator.setApid(APID_SET_SHUTDOWN_TIMEOUT);
|
||||
spParams.creator.setSeqCount(DEFAULT_SEQUENCE_COUNT);
|
||||
}
|
||||
@ -1123,7 +1149,7 @@ class SetShutdownTimeout : public ploc::SpTcBase {
|
||||
return res;
|
||||
}
|
||||
initPacket(timeout);
|
||||
return calcCrc();
|
||||
return calcAndSetCrc();
|
||||
}
|
||||
|
||||
private:
|
||||
@ -1151,7 +1177,7 @@ class CheckMemory : public ploc::SpTcBase {
|
||||
* @param length Length in bytes of memory region
|
||||
*/
|
||||
CheckMemory(ploc::SpTcParams params) : ploc::SpTcBase(params) {
|
||||
spParams.setFullPacketLen(PAYLOAD_LENGTH + 2);
|
||||
spParams.setFullPayloadLen(PAYLOAD_LENGTH + 2);
|
||||
spParams.creator.setApid(APID_CHECK_MEMORY);
|
||||
spParams.creator.setSeqCount(DEFAULT_SEQUENCE_COUNT);
|
||||
}
|
||||
@ -1162,7 +1188,7 @@ class CheckMemory : public ploc::SpTcBase {
|
||||
return res;
|
||||
}
|
||||
initPacket(memoryId, startAddress, length);
|
||||
return calcCrc();
|
||||
return calcAndSetCrc();
|
||||
}
|
||||
|
||||
private:
|
||||
@ -1216,7 +1242,7 @@ class WriteMemory : public ploc::SpTcBase {
|
||||
if (res != returnvalue::OK) {
|
||||
return res;
|
||||
}
|
||||
return calcCrc();
|
||||
return calcAndSetCrc();
|
||||
}
|
||||
// Although the space packet has space left for 1010 bytes of data to supervisor can only process
|
||||
// update packets with a maximum of 512 bytes.
|
||||
@ -1230,9 +1256,9 @@ class WriteMemory : public ploc::SpTcBase {
|
||||
uint8_t* updateData) {
|
||||
uint8_t* data = payloadStart;
|
||||
if (updateDataLen % 2 != 0) {
|
||||
spParams.setFullPacketLen(META_DATA_LENGTH + updateDataLen + 1 + 2);
|
||||
spParams.setFullPayloadLen(META_DATA_LENGTH + updateDataLen + 1 + 2);
|
||||
} else {
|
||||
spParams.setFullPacketLen(META_DATA_LENGTH + updateDataLen + 2);
|
||||
spParams.setFullPayloadLen(META_DATA_LENGTH + updateDataLen + 2);
|
||||
}
|
||||
// To avoid crashes in this unexpected case
|
||||
ReturnValue_t result = checkPayloadLen();
|
||||
@ -1264,7 +1290,7 @@ class WriteMemory : public ploc::SpTcBase {
|
||||
class EraseMemory : public ploc::SpTcBase {
|
||||
public:
|
||||
EraseMemory(ploc::SpTcParams params) : ploc::SpTcBase(params) {
|
||||
spParams.setFullPacketLen(PAYLOAD_LENGTH + 2);
|
||||
spParams.setFullPayloadLen(PAYLOAD_LENGTH + 2);
|
||||
spParams.creator.setApid(APID_ERASE_MEMORY);
|
||||
spParams.creator.setSeqCount(DEFAULT_SEQUENCE_COUNT);
|
||||
}
|
||||
@ -1275,7 +1301,7 @@ class EraseMemory : public ploc::SpTcBase {
|
||||
return res;
|
||||
}
|
||||
initPacket(memoryId, startAddress, length);
|
||||
return calcCrc();
|
||||
return calcAndSetCrc();
|
||||
}
|
||||
|
||||
private:
|
||||
@ -1306,7 +1332,7 @@ class EraseMemory : public ploc::SpTcBase {
|
||||
class EnableAutoTm : public ploc::SpTcBase {
|
||||
public:
|
||||
EnableAutoTm(ploc::SpTcParams params) : ploc::SpTcBase(params) {
|
||||
spParams.setFullPacketLen(PAYLOAD_LENGTH + 2);
|
||||
spParams.setFullPayloadLen(PAYLOAD_LENGTH + 2);
|
||||
spParams.creator.setApid(APID_AUTO_TM);
|
||||
spParams.creator.setSeqCount(DEFAULT_SEQUENCE_COUNT);
|
||||
}
|
||||
@ -1317,7 +1343,7 @@ class EnableAutoTm : public ploc::SpTcBase {
|
||||
return res;
|
||||
}
|
||||
payloadStart[0] = ENABLE;
|
||||
return calcCrc();
|
||||
return calcAndSetCrc();
|
||||
}
|
||||
|
||||
private:
|
||||
@ -1331,7 +1357,7 @@ class EnableAutoTm : public ploc::SpTcBase {
|
||||
class DisableAutoTm : public ploc::SpTcBase {
|
||||
public:
|
||||
DisableAutoTm(ploc::SpTcParams params) : ploc::SpTcBase(params) {
|
||||
spParams.setFullPacketLen(PAYLOAD_LENGTH + 2);
|
||||
spParams.setFullPayloadLen(PAYLOAD_LENGTH + 2);
|
||||
spParams.creator.setApid(APID_AUTO_TM);
|
||||
spParams.creator.setSeqCount(DEFAULT_SEQUENCE_COUNT);
|
||||
}
|
||||
@ -1342,7 +1368,7 @@ class DisableAutoTm : public ploc::SpTcBase {
|
||||
return res;
|
||||
}
|
||||
payloadStart[0] = DISABLE;
|
||||
return calcCrc();
|
||||
return calcAndSetCrc();
|
||||
}
|
||||
|
||||
private:
|
||||
@ -1366,7 +1392,7 @@ class RequestLoggingData : public ploc::SpTcBase {
|
||||
};
|
||||
|
||||
RequestLoggingData(ploc::SpTcParams params) : ploc::SpTcBase(params) {
|
||||
spParams.setFullPacketLen(PAYLOAD_LENGTH + 2);
|
||||
spParams.setFullPayloadLen(PAYLOAD_LENGTH + 2);
|
||||
spParams.creator.setApid(APID_REQUEST_LOGGING_DATA);
|
||||
spParams.creator.setSeqCount(DEFAULT_SEQUENCE_COUNT);
|
||||
}
|
||||
@ -1383,7 +1409,7 @@ class RequestLoggingData : public ploc::SpTcBase {
|
||||
}
|
||||
payloadStart[0] = static_cast<uint8_t>(sa);
|
||||
payloadStart[1] = tpc;
|
||||
return calcCrc();
|
||||
return calcAndSetCrc();
|
||||
}
|
||||
|
||||
private:
|
||||
|
@ -1028,7 +1028,7 @@ ReturnValue_t PlocSupervisorHandler::handleHkReport(const uint8_t* data) {
|
||||
return result;
|
||||
}
|
||||
|
||||
uint16_t offset = supv::DATA_FIELD_OFFSET;
|
||||
uint16_t offset = supv::PAYLOAD_OFFSET;
|
||||
hkset.tempPs = *(data + offset) << 24 | *(data + offset + 1) << 16 | *(data + offset + 2) << 8 |
|
||||
*(data + offset + 3);
|
||||
offset += 4;
|
||||
@ -1106,7 +1106,7 @@ ReturnValue_t PlocSupervisorHandler::handleBootStatusReport(const uint8_t* data)
|
||||
return result;
|
||||
}
|
||||
|
||||
uint16_t offset = supv::DATA_FIELD_OFFSET;
|
||||
uint16_t offset = supv::PAYLOAD_OFFSET;
|
||||
bootStatusReport.socState = *(data + offset);
|
||||
offset += 1;
|
||||
bootStatusReport.powerCycles = *(data + offset);
|
||||
@ -1171,7 +1171,7 @@ ReturnValue_t PlocSupervisorHandler::handleLatchupStatusReport(const uint8_t* da
|
||||
return result;
|
||||
}
|
||||
|
||||
uint16_t offset = supv::DATA_FIELD_OFFSET;
|
||||
uint16_t offset = supv::PAYLOAD_OFFSET;
|
||||
latchupStatusReport.id = *(data + offset);
|
||||
offset += 1;
|
||||
latchupStatusReport.cnt0 = *(data + offset) << 8 | *(data + offset + 1);
|
||||
@ -1255,7 +1255,7 @@ ReturnValue_t PlocSupervisorHandler::handleLoggingReport(const uint8_t* data) {
|
||||
return result;
|
||||
}
|
||||
|
||||
const uint8_t* dataField = data + supv::DATA_FIELD_OFFSET + sizeof(supv::RequestLoggingData::Sa);
|
||||
const uint8_t* dataField = data + supv::PAYLOAD_OFFSET + sizeof(supv::RequestLoggingData::Sa);
|
||||
result = loggingReport.read();
|
||||
if (result != returnvalue::OK) {
|
||||
return result;
|
||||
@ -1291,7 +1291,7 @@ ReturnValue_t PlocSupervisorHandler::handleAdcReport(const uint8_t* data) {
|
||||
return result;
|
||||
}
|
||||
|
||||
const uint8_t* dataField = data + supv::DATA_FIELD_OFFSET;
|
||||
const uint8_t* dataField = data + supv::PAYLOAD_OFFSET;
|
||||
result = adcReport.read();
|
||||
if (result != returnvalue::OK) {
|
||||
return result;
|
||||
|
@ -14,12 +14,12 @@ struct SpTcParams {
|
||||
SpTcParams(SpacePacketCreator& creator, uint8_t* buf, size_t maxSize)
|
||||
: creator(creator), buf(buf), maxSize(maxSize) {}
|
||||
|
||||
void setFullPacketLen(size_t fullPacketLen_) { fullPacketLen = fullPacketLen_; }
|
||||
void setFullPayloadLen(size_t fullPayloadLen_) { fullPayloadLen = fullPayloadLen_; }
|
||||
|
||||
SpacePacketCreator& creator;
|
||||
uint8_t* buf = nullptr;
|
||||
size_t maxSize = 0;
|
||||
size_t fullPacketLen = 0;
|
||||
size_t fullPayloadLen = 0;
|
||||
};
|
||||
|
||||
class SpTcBase {
|
||||
@ -37,7 +37,7 @@ class SpTcBase {
|
||||
}
|
||||
|
||||
void updateSpFields() {
|
||||
spParams.creator.setDataLenField(spParams.fullPacketLen - 1);
|
||||
spParams.creator.setDataLenField(spParams.fullPayloadLen - 1);
|
||||
spParams.creator.setPacketType(ccsds::PacketType::TC);
|
||||
}
|
||||
|
||||
@ -48,7 +48,7 @@ class SpTcBase {
|
||||
uint16_t getApid() const { return spParams.creator.getApid(); }
|
||||
|
||||
ReturnValue_t checkPayloadLen() {
|
||||
if (ccsds::HEADER_LEN + spParams.fullPacketLen > spParams.maxSize) {
|
||||
if (ccsds::HEADER_LEN + spParams.fullPayloadLen > spParams.maxSize) {
|
||||
return SerializeIF::BUFFER_TOO_SHORT;
|
||||
}
|
||||
|
||||
@ -69,7 +69,7 @@ class SpTcBase {
|
||||
return serializeHeader();
|
||||
}
|
||||
|
||||
ReturnValue_t calcCrc() {
|
||||
ReturnValue_t calcAndSetCrc() {
|
||||
/* Calculate crc */
|
||||
uint16_t crc = CRC::crc16ccitt(spParams.buf, getFullPacketLen() - 2);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user