thats a lot of rewriting..
Some checks failed
EIVE/eive-obsw/pipeline/head There was a failure building this commit
Some checks failed
EIVE/eive-obsw/pipeline/head There was a failure building this commit
This commit is contained in:
parent
859ced185d
commit
f071b7eba4
@ -256,6 +256,7 @@ 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;
|
||||
@ -274,41 +275,70 @@ static const uint32_t ERASE_MEMORY = 60000;
|
||||
static const uint32_t UPDATE_STATUS_REPORT = 70000;
|
||||
} // namespace recv_timeout
|
||||
|
||||
struct SpBaseParams {
|
||||
SpBaseParams(SpacePacketCreator& creator, uint8_t* buf, size_t maxSize):
|
||||
creator(creator), buf(buf), maxSize(maxSize) {}
|
||||
|
||||
|
||||
void setPayloadLen(size_t payloadLen_) {
|
||||
payloadLen = payloadLen_;
|
||||
}
|
||||
|
||||
SpacePacketCreator& creator;
|
||||
uint8_t* buf;
|
||||
size_t maxSize;
|
||||
size_t payloadLen = 0;
|
||||
|
||||
};
|
||||
|
||||
class SpacePacketBase {
|
||||
public:
|
||||
SpacePacketBase(SpacePacketCreator& creator, uint8_t* buf, size_t payloadLen, size_t maxSize)
|
||||
: creator(creator), buf(buf), payloadLen(payloadLen), maxSize(maxSize) {
|
||||
creator.setDataLen(payloadLen - 1);
|
||||
creator.setPacketType(ccsds::PacketType::TC);
|
||||
payloadStart = buf + ccsds::HEADER_LEN;
|
||||
SpacePacketBase(SpBaseParams params)
|
||||
: spParams(params) {
|
||||
payloadStart = spParams.buf + ccsds::HEADER_LEN;
|
||||
updateFields();
|
||||
}
|
||||
|
||||
void updateFields() {
|
||||
spParams.creator.setDataLen(spParams.payloadLen - 1);
|
||||
spParams.creator.setPacketType(ccsds::PacketType::TC);
|
||||
}
|
||||
|
||||
ReturnValue_t checkPayloadLen() {
|
||||
if(ccsds::HEADER_LEN + payloadLen > maxSize) {
|
||||
if(ccsds::HEADER_LEN + spParams.payloadLen > spParams.maxSize) {
|
||||
return SerializeIF::BUFFER_TOO_SHORT;
|
||||
}
|
||||
|
||||
return result::OK;
|
||||
}
|
||||
|
||||
ReturnValue_t serialize() {
|
||||
ReturnValue_t serializeHeader() {
|
||||
updateFields();
|
||||
size_t serLen = 0;
|
||||
return creator.serializeBe(buf, serLen, maxSize);
|
||||
return spParams.creator.serializeBe(spParams.buf, serLen, spParams.maxSize);
|
||||
}
|
||||
|
||||
ReturnValue_t checkSizeAndSerialize() {
|
||||
ReturnValue_t checkSizeAndSerializeHeader() {
|
||||
ReturnValue_t result = checkPayloadLen();
|
||||
if(result != result::OK) {
|
||||
return result;
|
||||
}
|
||||
return serialize();
|
||||
return serializeHeader();
|
||||
}
|
||||
|
||||
ReturnValue_t calcCrc() {
|
||||
/* Calculate crc */
|
||||
uint16_t crc = CRC::crc16ccitt(spParams.buf, ccsds::HEADER_LEN + spParams.payloadLen - 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:
|
||||
SpacePacketCreator& creator;
|
||||
uint8_t* buf;
|
||||
size_t payloadLen;
|
||||
SpBaseParams spParams;
|
||||
uint8_t* payloadStart;
|
||||
size_t maxSize;
|
||||
};
|
||||
|
||||
/**
|
||||
@ -323,35 +353,21 @@ class ApidOnlyPacket: public SpacePacketBase {
|
||||
*
|
||||
* @note Sequence count of empty packet is always 1.
|
||||
*/
|
||||
ApidOnlyPacket(uint16_t apid, SpacePacketCreator& creator, uint8_t* buf, size_t maxSize)
|
||||
: SpacePacketBase(creator, buf, LENGTH_EMPTY_TC, maxSize) {
|
||||
creator.setApid(apid);
|
||||
|
||||
ApidOnlyPacket(SpBaseParams params, uint16_t apid)
|
||||
: SpacePacketBase(params) {
|
||||
spParams.setPayloadLen(LENGTH_EMPTY_TC);
|
||||
spParams.creator.setApid(apid);
|
||||
}
|
||||
|
||||
ReturnValue_t buildPacket() {
|
||||
ReturnValue_t result = checkSizeAndSerialize();
|
||||
if(result != result::OK) {
|
||||
return result;
|
||||
auto res = checkSizeAndSerializeHeader();
|
||||
if(res != result::OK) {
|
||||
return res;
|
||||
}
|
||||
calcCrc();
|
||||
return result::OK;
|
||||
return calcCrc();
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
/**
|
||||
* @brief CRC calculation which involves only the header in an empty packet
|
||||
*/
|
||||
void calcCrc() {
|
||||
/* Calculate crc */
|
||||
uint16_t crc = CRC::crc16ccitt(buf, ccsds::HEADER_LEN);
|
||||
|
||||
/* Add crc to packet data field of space packet */
|
||||
size_t serializedSize = 0;
|
||||
SerializeAdapter::serialize<uint16_t>(&crc, &payloadStart, &serializedSize, sizeof(crc),
|
||||
SerializeIF::Endianness::BIG);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
@ -373,28 +389,24 @@ class MPSoCBootSelect : public SpacePacketBase {
|
||||
*
|
||||
* @note Selection of partitions is currently not supported.
|
||||
*/
|
||||
MPSoCBootSelect(SpacePacketCreator& creator, uint8_t* buf, size_t maxSize)
|
||||
: SpacePacketBase(creator, buf, DATA_FIELD_LENGTH - 1, maxSize) {
|
||||
creator.setApid(APID_SEL_MPSOC_BOOT_IMAGE);
|
||||
creator.setSeqCount(DEFAULT_SEQUENCE_COUNT);
|
||||
MPSoCBootSelect(SpBaseParams params)
|
||||
: SpacePacketBase(params) {
|
||||
spParams.setPayloadLen(DATA_FIELD_LENGTH);
|
||||
spParams.creator.setApid(APID_SEL_MPSOC_BOOT_IMAGE);
|
||||
spParams.creator.setSeqCount(DEFAULT_SEQUENCE_COUNT);
|
||||
}
|
||||
|
||||
ReturnValue_t buildPacket(uint8_t mem_ = 0, uint8_t bp0_ = 0, uint8_t bp1_ = 0, uint8_t bp2_ = 0) {
|
||||
mem = mem_;
|
||||
bp0 = bp0_;
|
||||
bp1 = bp1_;
|
||||
bp2 = bp2_;
|
||||
auto res = checkSizeAndSerialize();
|
||||
ReturnValue_t buildPacket(uint8_t mem = 0, uint8_t bp0 = 0, uint8_t bp1 = 0, uint8_t bp2 = 0) {
|
||||
auto res = checkSizeAndSerializeHeader();
|
||||
if(res != result::OK) {
|
||||
return res;
|
||||
}
|
||||
initPacket();
|
||||
return res;
|
||||
initPacket(mem, bp0, bp1, bp2);
|
||||
return calcCrc();
|
||||
}
|
||||
|
||||
private:
|
||||
static const uint16_t DATA_FIELD_LENGTH = 6;
|
||||
static const uint16_t DEFAULT_SEQUENCE_COUNT = 1;
|
||||
|
||||
static const uint8_t MEM_OFFSET = 0;
|
||||
static const uint8_t BP0_OFFSET = 1;
|
||||
@ -402,24 +414,11 @@ class MPSoCBootSelect : public SpacePacketBase {
|
||||
static const uint8_t BP2_OFFSET = 3;
|
||||
static const uint16_t CRC_OFFSET = DATA_FIELD_LENGTH - 2;
|
||||
|
||||
uint8_t mem = 0;
|
||||
uint8_t bp0 = 0;
|
||||
uint8_t bp1 = 0;
|
||||
uint8_t bp2 = 0;
|
||||
|
||||
void initPacket() {
|
||||
void initPacket(uint8_t mem = 0, uint8_t bp0 = 0, uint8_t bp1 = 0, uint8_t bp2 = 0) {
|
||||
std::memcpy(payloadStart + MEM_OFFSET, &mem, sizeof(mem));
|
||||
std::memcpy(payloadStart + BP0_OFFSET, &bp0, sizeof(bp0));
|
||||
std::memcpy(payloadStart + BP1_OFFSET, &bp1, sizeof(bp1));
|
||||
std::memcpy(payloadStart + BP2_OFFSET, &bp2, sizeof(bp2));
|
||||
/* Calculate crc */
|
||||
uint16_t crc = CRC::crc16ccitt(buf, ccsds::HEADER_LEN + DATA_FIELD_LENGTH - 2);
|
||||
|
||||
/* Add crc to packet data field of space packet */
|
||||
size_t serializedSize = 0;
|
||||
uint8_t* crcPos = payloadStart + CRC_OFFSET;
|
||||
SerializeAdapter::serialize<uint16_t>(&crc, &crcPos, &serializedSize, sizeof(crc),
|
||||
SerializeIF::Endianness::BIG);
|
||||
}
|
||||
};
|
||||
|
||||
@ -427,7 +426,7 @@ class MPSoCBootSelect : public SpacePacketBase {
|
||||
* @brief This class creates the command to enable or disable the NVMs connected to the
|
||||
* supervisor.
|
||||
*/
|
||||
class EnableNvms : public SpacePacketCreator {
|
||||
class EnableNvms : public SpacePacketBase {
|
||||
public:
|
||||
/**
|
||||
* @brief Constructor
|
||||
@ -437,55 +436,63 @@ class EnableNvms : public SpacePacketCreator {
|
||||
* @param bp1 Partition pin 1
|
||||
* @param bp2 Partition pin 2
|
||||
*/
|
||||
EnableNvms(uint8_t nvm01, uint8_t nvm3)
|
||||
: SpacePacket(DATA_FIELD_LENGTH - 1, true, APID_ENABLE_NVMS, DEFAULT_SEQUENCE_COUNT),
|
||||
nvm01(nvm01),
|
||||
nvm3(nvm3) {
|
||||
initPacket();
|
||||
EnableNvms(SpBaseParams params)
|
||||
: SpacePacketBase(params) {
|
||||
spParams.setPayloadLen(DATA_FIELD_LENGTH);
|
||||
spParams.creator.setApid(APID_ENABLE_NVMS);
|
||||
spParams.creator.setSeqCount(DEFAULT_SEQUENCE_COUNT);
|
||||
}
|
||||
|
||||
ReturnValue_t buildPacket(uint8_t nvm01, uint8_t nvm3) {
|
||||
auto res = checkSizeAndSerializeHeader();
|
||||
if(res != result::OK) {
|
||||
return res;
|
||||
}
|
||||
initPacket(nvm01, nvm3);
|
||||
return calcCrc();
|
||||
}
|
||||
|
||||
|
||||
private:
|
||||
static const uint16_t DEFAULT_SEQUENCE_COUNT = 1;
|
||||
static const uint8_t DATA_FIELD_LENGTH = 4;
|
||||
static const uint8_t CRC_OFFSET = 2;
|
||||
uint8_t nvm01 = 0;
|
||||
uint8_t nvm3 = 0;
|
||||
|
||||
void initPacket() {
|
||||
*(this->localData.fields.buffer) = nvm01;
|
||||
*(this->localData.fields.buffer + 1) = nvm3;
|
||||
|
||||
/* Calculate crc */
|
||||
uint16_t crc = CRC::crc16ccitt(this->localData.byteStream,
|
||||
sizeof(CCSDSPrimaryHeader) + DATA_FIELD_LENGTH - 2);
|
||||
|
||||
/* Add crc to packet data field of space packet */
|
||||
size_t serializedSize = 0;
|
||||
uint8_t* crcPos = this->localData.fields.buffer + CRC_OFFSET;
|
||||
SerializeAdapter::serialize<uint16_t>(&crc, &crcPos, &serializedSize, sizeof(crc),
|
||||
SerializeIF::Endianness::BIG);
|
||||
void initPacket(uint8_t nvm01, uint8_t nvm3) {
|
||||
payloadStart[0] = nvm01;
|
||||
payloadStart[1] = nvm3;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief This class generates the space packet to update the time of the PLOC supervisor.
|
||||
*/
|
||||
class SetTimeRef : public SpacePacketCreator {
|
||||
class SetTimeRef : public SpacePacketBase {
|
||||
public:
|
||||
SetTimeRef(Clock::TimeOfDay_t* time)
|
||||
: SpacePacket(DATA_FIELD_LENGTH - 1, true, APID_SET_TIME_REF, DEFAULT_SEQUENCE_COUNT) {
|
||||
SetTimeRef(SpBaseParams params)
|
||||
: SpacePacketBase(params) {
|
||||
spParams.setPayloadLen(DATA_FIELD_LENGTH);
|
||||
spParams.creator.setApid(APID_SET_TIME_REF);
|
||||
spParams.creator.setSeqCount(DEFAULT_SEQUENCE_COUNT);
|
||||
|
||||
}
|
||||
|
||||
ReturnValue_t buildPacket(Clock::TimeOfDay_t* time) {
|
||||
auto res = checkSizeAndSerializeHeader();
|
||||
if(res != result::OK) {
|
||||
return res;
|
||||
}
|
||||
initPacket(time);
|
||||
return calcCrc();
|
||||
}
|
||||
|
||||
private:
|
||||
static const uint16_t DATA_FIELD_LENGTH = 10;
|
||||
static const uint16_t DEFAULT_SEQUENCE_COUNT = 1;
|
||||
static const uint16_t CRC_OFFSET = DATA_FIELD_LENGTH - 2;
|
||||
static const uint16_t SYNC = 0x8000;
|
||||
|
||||
void initPacket(Clock::TimeOfDay_t* time) {
|
||||
size_t serializedSize = 0;
|
||||
uint8_t* dataFieldPtr = this->localData.fields.buffer;
|
||||
uint8_t* dataFieldPtr = payloadStart;
|
||||
uint16_t milliseconds = static_cast<uint16_t>(time->usecond / 1000) | SYNC;
|
||||
SerializeAdapter::serialize<uint16_t>(&milliseconds, &dataFieldPtr, &serializedSize,
|
||||
sizeof(milliseconds), SerializeIF::Endianness::BIG);
|
||||
@ -513,65 +520,72 @@ class SetTimeRef : public SpacePacketCreator {
|
||||
serializedSize = 0;
|
||||
SerializeAdapter::serialize<uint8_t>(&year, &dataFieldPtr, &serializedSize, sizeof(time->year),
|
||||
SerializeIF::Endianness::BIG);
|
||||
serializedSize = 0;
|
||||
/* Calculate crc */
|
||||
uint16_t crc = CRC::crc16ccitt(this->localData.byteStream,
|
||||
sizeof(CCSDSPrimaryHeader) + DATA_FIELD_LENGTH - 2);
|
||||
SerializeAdapter::serialize<uint16_t>(&crc, &dataFieldPtr, &serializedSize, sizeof(crc),
|
||||
SerializeIF::Endianness::BIG);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief This class can be used to generate the set boot timout command.
|
||||
*/
|
||||
class SetBootTimeout : public SpacePacketCreator {
|
||||
class SetBootTimeout : public SpacePacketBase {
|
||||
public:
|
||||
/**
|
||||
* @brief Constructor
|
||||
*
|
||||
* @param timeout The boot timeout in milliseconds.
|
||||
*/
|
||||
SetBootTimeout(uint32_t timeout)
|
||||
: SpacePacket(DATA_FIELD_LENGTH - 1, true, APID_SET_BOOT_TIMEOUT, 1), timeout(timeout) {
|
||||
initPacket();
|
||||
SetBootTimeout(SpBaseParams params)
|
||||
: SpacePacketBase(params) {
|
||||
spParams.setPayloadLen(DATA_FIELD_LENGTH);
|
||||
spParams.creator.setApid(APID_SET_BOOT_TIMEOUT);
|
||||
spParams.creator.setSeqCount(DEFAULT_SEQUENCE_COUNT);
|
||||
|
||||
}
|
||||
|
||||
ReturnValue_t buildPacket(uint32_t timeout) {
|
||||
auto res = checkSizeAndSerializeHeader();
|
||||
if(res != result::OK) {
|
||||
return res;
|
||||
}
|
||||
initPacket(timeout);
|
||||
return calcCrc();
|
||||
}
|
||||
|
||||
private:
|
||||
uint32_t timeout = 0;
|
||||
|
||||
/** boot timeout value (uint32_t) and crc (uint16_t) */
|
||||
static const uint16_t DATA_FIELD_LENGTH = 6;
|
||||
|
||||
void initPacket() {
|
||||
void initPacket(uint32_t timeout) {
|
||||
size_t serializedSize = 0;
|
||||
uint8_t* dataFieldPtr = this->localData.fields.buffer;
|
||||
uint8_t* dataFieldPtr = payloadStart;
|
||||
SerializeAdapter::serialize<uint32_t>(&timeout, &dataFieldPtr, &serializedSize, sizeof(timeout),
|
||||
SerializeIF::Endianness::BIG);
|
||||
/* Calculate crc */
|
||||
uint16_t crc = CRC::crc16ccitt(this->localData.byteStream,
|
||||
sizeof(CCSDSPrimaryHeader) + DATA_FIELD_LENGTH - 2);
|
||||
/* Add crc to packet data field of space packet */
|
||||
serializedSize = 0;
|
||||
SerializeAdapter::serialize<uint16_t>(&crc, &dataFieldPtr, &serializedSize, sizeof(crc),
|
||||
SerializeIF::Endianness::BIG);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief This class can be used to generate the space packet to set the maximum boot tries.
|
||||
*/
|
||||
class SetRestartTries : public SpacePacketCreator {
|
||||
class SetRestartTries : public SpacePacketBase {
|
||||
public:
|
||||
/**
|
||||
* @brief Constructor
|
||||
*
|
||||
* @param restartTries Maximum restart tries to set.
|
||||
*/
|
||||
SetRestartTries(uint8_t restartTries)
|
||||
: SpacePacket(DATA_FIELD_LENGTH - 1, true, APID_SET_MAX_RESTART_TRIES, 1),
|
||||
restartTries(restartTries) {
|
||||
initPacket();
|
||||
SetRestartTries(SpBaseParams params)
|
||||
: SpacePacketBase(params) {
|
||||
spParams.setPayloadLen(DATA_FIELD_LENGTH);
|
||||
spParams.creator.setApid(APID_SET_MAX_RESTART_TRIES);
|
||||
spParams.creator.setSeqCount(DEFAULT_SEQUENCE_COUNT);
|
||||
}
|
||||
|
||||
ReturnValue_t buildPacket(uint8_t restartTries) {
|
||||
auto res = checkSizeAndSerializeHeader();
|
||||
if(res != result::OK) {
|
||||
return res;
|
||||
}
|
||||
initPacket(restartTries);
|
||||
return calcCrc();
|
||||
}
|
||||
|
||||
private:
|
||||
@ -580,15 +594,8 @@ class SetRestartTries : public SpacePacketCreator {
|
||||
/** Restart tries value (uint8_t) and crc (uint16_t) */
|
||||
static const uint16_t DATA_FIELD_LENGTH = 3;
|
||||
|
||||
void initPacket() {
|
||||
uint8_t* dataFieldPtr = this->localData.fields.buffer;
|
||||
*dataFieldPtr = restartTries;
|
||||
uint16_t crc = CRC::crc16ccitt(this->localData.byteStream,
|
||||
sizeof(CCSDSPrimaryHeader) + DATA_FIELD_LENGTH - 2);
|
||||
size_t serializedSize = 0;
|
||||
uint8_t* crcPtr = dataFieldPtr + 1;
|
||||
SerializeAdapter::serialize<uint16_t>(&crc, &crcPtr, &serializedSize, sizeof(crc),
|
||||
SerializeIF::Endianness::BIG);
|
||||
void initPacket(uint8_t restartTries) {
|
||||
payloadStart[0] = restartTries;
|
||||
}
|
||||
};
|
||||
|
||||
@ -597,30 +604,33 @@ class SetRestartTries : public SpacePacketCreator {
|
||||
* of housekeeping data. Normally, this will be disabled by default. However, adding this
|
||||
* command can be useful for debugging.
|
||||
*/
|
||||
class DisablePeriodicHkTransmission : public SpacePacket {
|
||||
class DisablePeriodicHkTransmission : public SpacePacketBase {
|
||||
public:
|
||||
/**
|
||||
* @brief Constructor
|
||||
*/
|
||||
DisablePeriodicHkTransmission() : SpacePacket(DATA_FIELD_LENGTH - 1, true, APID_DISABLE_HK, 1) {
|
||||
DisablePeriodicHkTransmission(SpBaseParams params): SpacePacketBase(params) {
|
||||
spParams.setPayloadLen(DATA_FIELD_LENGTH);
|
||||
spParams.creator.setApid(APID_DISABLE_HK);
|
||||
spParams.creator.setSeqCount(DEFAULT_SEQUENCE_COUNT);
|
||||
}
|
||||
|
||||
ReturnValue_t buildPacket() {
|
||||
auto res = checkSizeAndSerializeHeader();
|
||||
if(res != result::OK) {
|
||||
return res;
|
||||
}
|
||||
initPacket();
|
||||
return calcCrc();
|
||||
}
|
||||
|
||||
private:
|
||||
uint8_t disableHk = 0;
|
||||
|
||||
/** Restart tries value (uint8_t) and crc (uint16_t) */
|
||||
static const uint16_t DATA_FIELD_LENGTH = 3;
|
||||
|
||||
void initPacket() {
|
||||
uint8_t* dataFieldPtr = this->localData.fields.buffer;
|
||||
*dataFieldPtr = disableHk;
|
||||
uint16_t crc = CRC::crc16ccitt(this->localData.byteStream,
|
||||
sizeof(CCSDSPrimaryHeader) + DATA_FIELD_LENGTH - 2);
|
||||
size_t serializedSize = 0;
|
||||
uint8_t* crcPtr = dataFieldPtr + 1;
|
||||
SerializeAdapter::serialize<uint16_t>(&crc, &crcPtr, &serializedSize, sizeof(crc),
|
||||
SerializeIF::Endianness::BIG);
|
||||
payloadStart[0] = false;
|
||||
}
|
||||
};
|
||||
|
||||
@ -629,7 +639,7 @@ class DisablePeriodicHkTransmission : public SpacePacket {
|
||||
*
|
||||
* @details There are 7 different latchup alerts.
|
||||
*/
|
||||
class LatchupAlert : public SpacePacket {
|
||||
class LatchupAlert : public SpacePacketBase {
|
||||
public:
|
||||
/**
|
||||
* @brief Constructor
|
||||
@ -638,40 +648,40 @@ class LatchupAlert : public SpacePacket {
|
||||
* @param latchupId Identifies the latchup to enable/disable (0 - 0.85V, 1 - 1.8V, 2 - MISC,
|
||||
* 3 - 3.3V, 4 - NVM_4XO, 5 - MISSION, 6 - SAFECOTS)
|
||||
*/
|
||||
LatchupAlert(bool state, uint8_t latchupId)
|
||||
: SpacePacket(DATA_FIELD_LENGTH - 1, true), latchupId(latchupId) {
|
||||
if (state) {
|
||||
this->setAPID(APID_ENABLE_LATCHUP_ALERT);
|
||||
} else {
|
||||
this->setAPID(APID_DISABLE_LATCHUP_ALERT);
|
||||
LatchupAlert(SpBaseParams params)
|
||||
: SpacePacketBase(params) {
|
||||
spParams.setPayloadLen(DATA_FIELD_LENGTH);
|
||||
spParams.creator.setSeqCount(DEFAULT_SEQUENCE_COUNT);
|
||||
|
||||
}
|
||||
this->setPacketSequenceCount(DEFAULT_SEQUENCE_COUNT);
|
||||
initPacket();
|
||||
|
||||
ReturnValue_t buildPacket(bool state, uint8_t latchupId) {
|
||||
if (state) {
|
||||
spParams.creator.setApid(APID_ENABLE_LATCHUP_ALERT);
|
||||
} else {
|
||||
spParams.creator.setApid(APID_DISABLE_LATCHUP_ALERT);
|
||||
}
|
||||
auto res = checkSizeAndSerializeHeader();
|
||||
if(res != result::OK) {
|
||||
return res;
|
||||
}
|
||||
initPacket(latchupId);
|
||||
return calcCrc();
|
||||
}
|
||||
|
||||
private:
|
||||
static const uint16_t DATA_FIELD_LENGTH = 3;
|
||||
static const uint16_t DEFAULT_SEQUENCE_COUNT = 1;
|
||||
|
||||
static const uint16_t CRC_OFFSET = DATA_FIELD_LENGTH - 2;
|
||||
|
||||
uint8_t latchupId = 0;
|
||||
|
||||
void initPacket() {
|
||||
size_t serializedSize = 0;
|
||||
uint8_t* data_field_ptr = this->localData.fields.buffer;
|
||||
SerializeAdapter::serialize<uint8_t>(&latchupId, &data_field_ptr, &serializedSize,
|
||||
sizeof(latchupId), SerializeIF::Endianness::BIG);
|
||||
serializedSize = 0;
|
||||
uint16_t crc = CRC::crc16ccitt(this->localData.byteStream,
|
||||
sizeof(CCSDSPrimaryHeader) + DATA_FIELD_LENGTH - 2);
|
||||
uint8_t* crcPos = this->localData.fields.buffer + CRC_OFFSET;
|
||||
SerializeAdapter::serialize<uint16_t>(&crc, &crcPos, &serializedSize, sizeof(crc),
|
||||
SerializeIF::Endianness::BIG);
|
||||
void initPacket(uint8_t latchupId) {
|
||||
payloadStart[0] = latchupId;
|
||||
}
|
||||
};
|
||||
|
||||
class SetAlertlimit : public SpacePacket {
|
||||
class SetAlertlimit : public SpacePacketBase {
|
||||
public:
|
||||
/**
|
||||
* @brief Constructor
|
||||
@ -680,74 +690,78 @@ class SetAlertlimit : public SpacePacket {
|
||||
* 3 - 3.3V, 4 - NVM_4XO, 5 - MISSION, 6 - SAFECOTS)
|
||||
* @param dutycycle
|
||||
*/
|
||||
SetAlertlimit(uint8_t latchupId, uint32_t dutycycle)
|
||||
: SpacePacket(DATA_FIELD_LENGTH - 1, true, APID_SET_ALERT_LIMIT, DEFAULT_SEQUENCE_COUNT),
|
||||
latchupId(latchupId),
|
||||
dutycycle(dutycycle) {
|
||||
initPacket();
|
||||
SetAlertlimit(SpBaseParams params)
|
||||
: SpacePacketBase(params) {
|
||||
spParams.setPayloadLen(DATA_FIELD_LENGTH);
|
||||
spParams.creator.setApid(APID_SET_ALERT_LIMIT);
|
||||
spParams.creator.setSeqCount(DEFAULT_SEQUENCE_COUNT);
|
||||
|
||||
}
|
||||
|
||||
ReturnValue_t buildPacket(uint8_t latchupId, uint32_t dutycycle) {
|
||||
auto res = checkSizeAndSerializeHeader();
|
||||
if(res != result::OK) {
|
||||
return res;
|
||||
}
|
||||
res = initPacket(latchupId, dutycycle);
|
||||
if(res != result::OK) {
|
||||
return res;
|
||||
}
|
||||
return calcCrc();
|
||||
}
|
||||
|
||||
private:
|
||||
static const uint16_t DATA_FIELD_LENGTH = 7;
|
||||
static const uint16_t DEFAULT_SEQUENCE_COUNT = 1;
|
||||
|
||||
static const uint16_t CRC_OFFSET = DATA_FIELD_LENGTH - 2;
|
||||
|
||||
uint8_t latchupId = 0;
|
||||
uint32_t dutycycle = 0;
|
||||
|
||||
void initPacket() {
|
||||
size_t serializedSize = 0;
|
||||
uint8_t* dataFieldPtr = this->localData.fields.buffer;
|
||||
SerializeAdapter::serialize<uint8_t>(&latchupId, &dataFieldPtr, &serializedSize,
|
||||
sizeof(latchupId), SerializeIF::Endianness::BIG);
|
||||
serializedSize = 0;
|
||||
SerializeAdapter::serialize<uint32_t>(&dutycycle, &dataFieldPtr, &serializedSize,
|
||||
ReturnValue_t initPacket(uint8_t latchupId, uint32_t dutycycle) {
|
||||
payloadStart[0] = latchupId;
|
||||
size_t serLen = 0;
|
||||
return SerializeAdapter::serialize<uint32_t>(&dutycycle, payloadStart + 1, &serLen,
|
||||
sizeof(dutycycle), SerializeIF::Endianness::BIG);
|
||||
serializedSize = 0;
|
||||
uint16_t crc = CRC::crc16ccitt(this->localData.byteStream,
|
||||
sizeof(CCSDSPrimaryHeader) + DATA_FIELD_LENGTH - 2);
|
||||
uint8_t* crcPos = this->localData.fields.buffer + CRC_OFFSET;
|
||||
SerializeAdapter::serialize<uint16_t>(&crc, &crcPos, &serializedSize, sizeof(crc),
|
||||
SerializeIF::Endianness::BIG);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief This class packages the space packet to enable or disable ADC channels.
|
||||
*/
|
||||
class SetAdcEnabledChannels : public SpacePacket {
|
||||
class SetAdcEnabledChannels : public SpacePacketBase {
|
||||
public:
|
||||
/**
|
||||
* @brief Constructor
|
||||
*
|
||||
* @param ch Defines channels to be enabled or disabled.
|
||||
*/
|
||||
SetAdcEnabledChannels(uint16_t ch)
|
||||
: SpacePacket(DATA_FIELD_LENGTH - 1, true, APID_SET_ADC_ENABLED_CHANNELS,
|
||||
DEFAULT_SEQUENCE_COUNT),
|
||||
ch(ch) {
|
||||
initPacket();
|
||||
SetAdcEnabledChannels(SpBaseParams params)
|
||||
: SpacePacketBase(params) {
|
||||
spParams.setPayloadLen(DATA_FIELD_LENGTH);
|
||||
spParams.creator.setApid(APID_SET_ADC_ENABLED_CHANNELS);
|
||||
spParams.creator.setSeqCount(DEFAULT_SEQUENCE_COUNT);
|
||||
}
|
||||
|
||||
ReturnValue_t buildPacket(uint16_t ch) {
|
||||
auto res = checkSizeAndSerializeHeader();
|
||||
if(res != result::OK) {
|
||||
return res;
|
||||
}
|
||||
res = initPacket(ch);
|
||||
if(res != result::OK) {
|
||||
return res;
|
||||
}
|
||||
return calcCrc();
|
||||
}
|
||||
|
||||
private:
|
||||
static const uint16_t DATA_FIELD_LENGTH = 4;
|
||||
static const uint16_t DEFAULT_SEQUENCE_COUNT = 1;
|
||||
|
||||
static const uint16_t CRC_OFFSET = DATA_FIELD_LENGTH - 2;
|
||||
|
||||
uint16_t ch = 0;
|
||||
|
||||
void initPacket() {
|
||||
void initPacket(uint16_t ch) {
|
||||
size_t serializedSize = 0;
|
||||
uint8_t* dataFieldPtr = this->localData.fields.buffer;
|
||||
SerializeAdapter::serialize<uint16_t>(&ch, &dataFieldPtr, &serializedSize, sizeof(ch),
|
||||
SerializeIF::Endianness::BIG);
|
||||
serializedSize = 0;
|
||||
uint16_t crc = CRC::crc16ccitt(this->localData.byteStream,
|
||||
sizeof(CCSDSPrimaryHeader) + DATA_FIELD_LENGTH - 2);
|
||||
uint8_t* crcPos = this->localData.fields.buffer + CRC_OFFSET;
|
||||
SerializeAdapter::serialize<uint16_t>(&crc, &crcPos, &serializedSize, sizeof(crc),
|
||||
SerializeAdapter::serialize(&ch, &payloadStart, &serializedSize, sizeof(ch),
|
||||
SerializeIF::Endianness::BIG);
|
||||
}
|
||||
};
|
||||
@ -756,7 +770,7 @@ class SetAdcEnabledChannels : public SpacePacket {
|
||||
* @brief This class packages the space packet to configures the window size and striding step of
|
||||
* the moving average filter applied to the ADC readings.
|
||||
*/
|
||||
class SetAdcWindowAndStride : public SpacePacket {
|
||||
class SetAdcWindowAndStride : public SpacePacketBase {
|
||||
public:
|
||||
/**
|
||||
* @brief Constructor
|
||||
@ -764,94 +778,107 @@ class SetAdcWindowAndStride : public SpacePacket {
|
||||
* @param windowSize
|
||||
* @param stridingStepSize
|
||||
*/
|
||||
SetAdcWindowAndStride(uint16_t windowSize, uint16_t stridingStepSize)
|
||||
: SpacePacket(DATA_FIELD_LENGTH - 1, true, APID_SET_ADC_WINDOW_AND_STRIDE,
|
||||
DEFAULT_SEQUENCE_COUNT),
|
||||
windowSize(windowSize),
|
||||
stridingStepSize(stridingStepSize) {
|
||||
initPacket();
|
||||
SetAdcWindowAndStride(SpBaseParams params): SpacePacketBase(params) {
|
||||
spParams.setPayloadLen(DATA_FIELD_LENGTH);
|
||||
spParams.creator.setApid(APID_SET_ADC_WINDOW_AND_STRIDE);
|
||||
spParams.creator.setSeqCount(DEFAULT_SEQUENCE_COUNT);
|
||||
}
|
||||
|
||||
ReturnValue_t buildPacket(uint16_t windowSize, uint16_t stridingStepSize) {
|
||||
auto res = checkSizeAndSerializeHeader();
|
||||
if(res != result::OK) {
|
||||
return res;
|
||||
}
|
||||
res = initPacket(windowSize, stridingStepSize);
|
||||
if(res != result::OK) {
|
||||
return res;
|
||||
}
|
||||
return calcCrc();
|
||||
}
|
||||
|
||||
private:
|
||||
static const uint16_t DATA_FIELD_LENGTH = 6;
|
||||
static const uint16_t DEFAULT_SEQUENCE_COUNT = 1;
|
||||
|
||||
static const uint16_t CRC_OFFSET = DATA_FIELD_LENGTH - 2;
|
||||
|
||||
uint16_t windowSize = 0;
|
||||
uint16_t stridingStepSize = 0;
|
||||
|
||||
void initPacket() {
|
||||
void initPacket(uint16_t windowSize, uint16_t stridingStepSize) {
|
||||
size_t serializedSize = 0;
|
||||
uint8_t* dataFieldPtr = this->localData.fields.buffer;
|
||||
SerializeAdapter::serialize<uint16_t>(&windowSize, &dataFieldPtr, &serializedSize,
|
||||
uint8_t* data = payloadStart;
|
||||
SerializeAdapter::serialize(&windowSize, &data, &serializedSize,
|
||||
sizeof(windowSize), SerializeIF::Endianness::BIG);
|
||||
serializedSize = 0;
|
||||
SerializeAdapter::serialize<uint16_t>(&stridingStepSize, &dataFieldPtr, &serializedSize,
|
||||
SerializeAdapter::serialize(&stridingStepSize, &data, &serializedSize,
|
||||
sizeof(stridingStepSize), SerializeIF::Endianness::BIG);
|
||||
serializedSize = 0;
|
||||
uint16_t crc = CRC::crc16ccitt(this->localData.byteStream,
|
||||
sizeof(CCSDSPrimaryHeader) + DATA_FIELD_LENGTH - 2);
|
||||
uint8_t* crcPos = this->localData.fields.buffer + CRC_OFFSET;
|
||||
SerializeAdapter::serialize<uint16_t>(&crc, &crcPos, &serializedSize, sizeof(crc),
|
||||
SerializeIF::Endianness::BIG);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief This class packages the space packet to set the ADC trigger threshold.
|
||||
*/
|
||||
class SetAdcThreshold : public SpacePacket {
|
||||
class SetAdcThreshold : public SpacePacketBase {
|
||||
public:
|
||||
/**
|
||||
* @brief Constructor
|
||||
*
|
||||
* @param threshold
|
||||
*/
|
||||
SetAdcThreshold(uint32_t threshold)
|
||||
: SpacePacket(DATA_FIELD_LENGTH - 1, true, APID_SET_ADC_THRESHOLD, DEFAULT_SEQUENCE_COUNT),
|
||||
threshold(threshold) {
|
||||
initPacket();
|
||||
SetAdcThreshold(SpBaseParams params): SpacePacketBase(params) {
|
||||
spParams.setPayloadLen(DATA_FIELD_LENGTH);
|
||||
spParams.creator.setApid(APID_SET_ADC_THRESHOLD);
|
||||
spParams.creator.setSeqCount(DEFAULT_SEQUENCE_COUNT);
|
||||
}
|
||||
|
||||
ReturnValue_t buildPacket(uint32_t threshold) {
|
||||
auto res = checkSizeAndSerializeHeader();
|
||||
if(res != result::OK) {
|
||||
return res;
|
||||
}
|
||||
res = initPacket(threshold);
|
||||
if(res != result::OK) {
|
||||
return res;
|
||||
}
|
||||
return calcCrc();
|
||||
}
|
||||
private:
|
||||
static const uint16_t DATA_FIELD_LENGTH = 6;
|
||||
static const uint16_t DEFAULT_SEQUENCE_COUNT = 1;
|
||||
|
||||
static const uint16_t CRC_OFFSET = DATA_FIELD_LENGTH - 2;
|
||||
|
||||
uint32_t threshold = 0;
|
||||
|
||||
void initPacket() {
|
||||
void initPacket(uint32_t threshold) {
|
||||
size_t serializedSize = 0;
|
||||
uint8_t* dataFieldPtr = this->localData.fields.buffer;
|
||||
SerializeAdapter::serialize<uint32_t>(&threshold, &dataFieldPtr, &serializedSize,
|
||||
SerializeAdapter::serialize(&threshold, payloadStart, &serializedSize,
|
||||
sizeof(threshold), SerializeIF::Endianness::BIG);
|
||||
serializedSize = 0;
|
||||
uint16_t crc = CRC::crc16ccitt(this->localData.byteStream,
|
||||
sizeof(CCSDSPrimaryHeader) + DATA_FIELD_LENGTH - 2);
|
||||
uint8_t* crcPos = this->localData.fields.buffer + CRC_OFFSET;
|
||||
SerializeAdapter::serialize<uint16_t>(&crc, &crcPos, &serializedSize, sizeof(crc),
|
||||
SerializeIF::Endianness::BIG);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief This class packages the space packet to run auto EM tests.
|
||||
*/
|
||||
class RunAutoEmTests : public SpacePacket {
|
||||
class RunAutoEmTests : public SpacePacketBase {
|
||||
public:
|
||||
/**
|
||||
* @brief Constructor
|
||||
*
|
||||
* @param test 1 - complete EM test, 2 - Short test (only memory readback NVM0,1,3)
|
||||
*/
|
||||
RunAutoEmTests(uint8_t test)
|
||||
: SpacePacket(DATA_FIELD_LENGTH - 1, true, APID_RUN_AUTO_EM_TESTS, DEFAULT_SEQUENCE_COUNT),
|
||||
test(test) {
|
||||
initPacket();
|
||||
RunAutoEmTests(SpBaseParams params) : SpacePacketBase(params) {
|
||||
spParams.setPayloadLen(DATA_FIELD_LENGTH);
|
||||
spParams.creator.setApid(APID_RUN_AUTO_EM_TESTS);
|
||||
spParams.creator.setSeqCount(DEFAULT_SEQUENCE_COUNT);
|
||||
}
|
||||
|
||||
ReturnValue_t buildPacket(uint8_t test) {
|
||||
auto res = checkSizeAndSerializeHeader();
|
||||
if(res != result::OK) {
|
||||
return res;
|
||||
}
|
||||
res = initPacket(test);
|
||||
if(res != result::OK) {
|
||||
return res;
|
||||
}
|
||||
return calcCrc();
|
||||
}
|
||||
private:
|
||||
static const uint16_t DATA_FIELD_LENGTH = 3;
|
||||
static const uint16_t DEFAULT_SEQUENCE_COUNT = 1;
|
||||
@ -860,17 +887,8 @@ class RunAutoEmTests : public SpacePacket {
|
||||
|
||||
uint8_t test = 0;
|
||||
|
||||
void initPacket() {
|
||||
size_t serializedSize = 0;
|
||||
uint8_t* dataFieldPtr = this->localData.fields.buffer;
|
||||
SerializeAdapter::serialize<uint8_t>(&test, &dataFieldPtr, &serializedSize, sizeof(test),
|
||||
SerializeIF::Endianness::BIG);
|
||||
serializedSize = 0;
|
||||
uint16_t crc = CRC::crc16ccitt(this->localData.byteStream,
|
||||
sizeof(CCSDSPrimaryHeader) + DATA_FIELD_LENGTH - 2);
|
||||
uint8_t* crcPos = this->localData.fields.buffer + CRC_OFFSET;
|
||||
SerializeAdapter::serialize<uint16_t>(&crc, &crcPos, &serializedSize, sizeof(crc),
|
||||
SerializeIF::Endianness::BIG);
|
||||
void initPacket(uint8_t test) {
|
||||
payloadStart[0] = test;
|
||||
}
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user