v1.14.0 #304
@ -256,6 +256,7 @@ enum PoolIds : lp_id_t {
|
|||||||
ADC_ENG_15
|
ADC_ENG_15
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static constexpr uint16_t DEFAULT_SEQUENCE_COUNT = 1;
|
||||||
static const uint8_t HK_SET_ENTRIES = 13;
|
static const uint8_t HK_SET_ENTRIES = 13;
|
||||||
static const uint8_t BOOT_REPORT_SET_ENTRIES = 10;
|
static const uint8_t BOOT_REPORT_SET_ENTRIES = 10;
|
||||||
static const uint8_t LATCHUP_RPT_SET_ENTRIES = 16;
|
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;
|
static const uint32_t UPDATE_STATUS_REPORT = 70000;
|
||||||
} // namespace recv_timeout
|
} // 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 {
|
class SpacePacketBase {
|
||||||
public:
|
public:
|
||||||
SpacePacketBase(SpacePacketCreator& creator, uint8_t* buf, size_t payloadLen, size_t maxSize)
|
SpacePacketBase(SpBaseParams params)
|
||||||
: creator(creator), buf(buf), payloadLen(payloadLen), maxSize(maxSize) {
|
: spParams(params) {
|
||||||
creator.setDataLen(payloadLen - 1);
|
payloadStart = spParams.buf + ccsds::HEADER_LEN;
|
||||||
creator.setPacketType(ccsds::PacketType::TC);
|
updateFields();
|
||||||
payloadStart = buf + ccsds::HEADER_LEN;
|
}
|
||||||
|
|
||||||
|
void updateFields() {
|
||||||
|
spParams.creator.setDataLen(spParams.payloadLen - 1);
|
||||||
|
spParams.creator.setPacketType(ccsds::PacketType::TC);
|
||||||
}
|
}
|
||||||
|
|
||||||
ReturnValue_t checkPayloadLen() {
|
ReturnValue_t checkPayloadLen() {
|
||||||
if(ccsds::HEADER_LEN + payloadLen > maxSize) {
|
if(ccsds::HEADER_LEN + spParams.payloadLen > spParams.maxSize) {
|
||||||
return SerializeIF::BUFFER_TOO_SHORT;
|
return SerializeIF::BUFFER_TOO_SHORT;
|
||||||
}
|
}
|
||||||
|
|
||||||
return result::OK;
|
return result::OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
ReturnValue_t serialize() {
|
ReturnValue_t serializeHeader() {
|
||||||
|
updateFields();
|
||||||
size_t serLen = 0;
|
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();
|
ReturnValue_t result = checkPayloadLen();
|
||||||
if(result != result::OK) {
|
if(result != result::OK) {
|
||||||
return result;
|
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:
|
protected:
|
||||||
SpacePacketCreator& creator;
|
SpBaseParams spParams;
|
||||||
uint8_t* buf;
|
|
||||||
size_t payloadLen;
|
|
||||||
uint8_t* payloadStart;
|
uint8_t* payloadStart;
|
||||||
size_t maxSize;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -323,35 +353,21 @@ class ApidOnlyPacket: public SpacePacketBase {
|
|||||||
*
|
*
|
||||||
* @note Sequence count of empty packet is always 1.
|
* @note Sequence count of empty packet is always 1.
|
||||||
*/
|
*/
|
||||||
ApidOnlyPacket(uint16_t apid, SpacePacketCreator& creator, uint8_t* buf, size_t maxSize)
|
ApidOnlyPacket(SpBaseParams params, uint16_t apid)
|
||||||
: SpacePacketBase(creator, buf, LENGTH_EMPTY_TC, maxSize) {
|
: SpacePacketBase(params) {
|
||||||
creator.setApid(apid);
|
spParams.setPayloadLen(LENGTH_EMPTY_TC);
|
||||||
|
spParams.creator.setApid(apid);
|
||||||
}
|
}
|
||||||
|
|
||||||
ReturnValue_t buildPacket() {
|
ReturnValue_t buildPacket() {
|
||||||
ReturnValue_t result = checkSizeAndSerialize();
|
auto res = checkSizeAndSerializeHeader();
|
||||||
if(result != result::OK) {
|
if(res != result::OK) {
|
||||||
return result;
|
return res;
|
||||||
}
|
}
|
||||||
calcCrc();
|
return calcCrc();
|
||||||
return result::OK;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
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.
|
* @note Selection of partitions is currently not supported.
|
||||||
*/
|
*/
|
||||||
MPSoCBootSelect(SpacePacketCreator& creator, uint8_t* buf, size_t maxSize)
|
MPSoCBootSelect(SpBaseParams params)
|
||||||
: SpacePacketBase(creator, buf, DATA_FIELD_LENGTH - 1, maxSize) {
|
: SpacePacketBase(params) {
|
||||||
creator.setApid(APID_SEL_MPSOC_BOOT_IMAGE);
|
spParams.setPayloadLen(DATA_FIELD_LENGTH);
|
||||||
creator.setSeqCount(DEFAULT_SEQUENCE_COUNT);
|
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) {
|
ReturnValue_t buildPacket(uint8_t mem = 0, uint8_t bp0 = 0, uint8_t bp1 = 0, uint8_t bp2 = 0) {
|
||||||
mem = mem_;
|
auto res = checkSizeAndSerializeHeader();
|
||||||
bp0 = bp0_;
|
|
||||||
bp1 = bp1_;
|
|
||||||
bp2 = bp2_;
|
|
||||||
auto res = checkSizeAndSerialize();
|
|
||||||
if(res != result::OK) {
|
if(res != result::OK) {
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
initPacket();
|
initPacket(mem, bp0, bp1, bp2);
|
||||||
return res;
|
return calcCrc();
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static const uint16_t DATA_FIELD_LENGTH = 6;
|
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 MEM_OFFSET = 0;
|
||||||
static const uint8_t BP0_OFFSET = 1;
|
static const uint8_t BP0_OFFSET = 1;
|
||||||
@ -402,24 +414,11 @@ class MPSoCBootSelect : public SpacePacketBase {
|
|||||||
static const uint8_t BP2_OFFSET = 3;
|
static const uint8_t BP2_OFFSET = 3;
|
||||||
static const uint16_t CRC_OFFSET = DATA_FIELD_LENGTH - 2;
|
static const uint16_t CRC_OFFSET = DATA_FIELD_LENGTH - 2;
|
||||||
|
|
||||||
uint8_t mem = 0;
|
void initPacket(uint8_t mem = 0, uint8_t bp0 = 0, uint8_t bp1 = 0, uint8_t bp2 = 0) {
|
||||||
uint8_t bp0 = 0;
|
|
||||||
uint8_t bp1 = 0;
|
|
||||||
uint8_t bp2 = 0;
|
|
||||||
|
|
||||||
void initPacket() {
|
|
||||||
std::memcpy(payloadStart + MEM_OFFSET, &mem, sizeof(mem));
|
std::memcpy(payloadStart + MEM_OFFSET, &mem, sizeof(mem));
|
||||||
std::memcpy(payloadStart + BP0_OFFSET, &bp0, sizeof(bp0));
|
std::memcpy(payloadStart + BP0_OFFSET, &bp0, sizeof(bp0));
|
||||||
std::memcpy(payloadStart + BP1_OFFSET, &bp1, sizeof(bp1));
|
std::memcpy(payloadStart + BP1_OFFSET, &bp1, sizeof(bp1));
|
||||||
std::memcpy(payloadStart + BP2_OFFSET, &bp2, sizeof(bp2));
|
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
|
* @brief This class creates the command to enable or disable the NVMs connected to the
|
||||||
* supervisor.
|
* supervisor.
|
||||||
*/
|
*/
|
||||||
class EnableNvms : public SpacePacketCreator {
|
class EnableNvms : public SpacePacketBase {
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
* @brief Constructor
|
* @brief Constructor
|
||||||
@ -437,55 +436,63 @@ class EnableNvms : public SpacePacketCreator {
|
|||||||
* @param bp1 Partition pin 1
|
* @param bp1 Partition pin 1
|
||||||
* @param bp2 Partition pin 2
|
* @param bp2 Partition pin 2
|
||||||
*/
|
*/
|
||||||
EnableNvms(uint8_t nvm01, uint8_t nvm3)
|
EnableNvms(SpBaseParams params)
|
||||||
: SpacePacket(DATA_FIELD_LENGTH - 1, true, APID_ENABLE_NVMS, DEFAULT_SEQUENCE_COUNT),
|
: SpacePacketBase(params) {
|
||||||
nvm01(nvm01),
|
spParams.setPayloadLen(DATA_FIELD_LENGTH);
|
||||||
nvm3(nvm3) {
|
spParams.creator.setApid(APID_ENABLE_NVMS);
|
||||||
initPacket();
|
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:
|
private:
|
||||||
static const uint16_t DEFAULT_SEQUENCE_COUNT = 1;
|
|
||||||
static const uint8_t DATA_FIELD_LENGTH = 4;
|
static const uint8_t DATA_FIELD_LENGTH = 4;
|
||||||
static const uint8_t CRC_OFFSET = 2;
|
static const uint8_t CRC_OFFSET = 2;
|
||||||
uint8_t nvm01 = 0;
|
|
||||||
uint8_t nvm3 = 0;
|
|
||||||
|
|
||||||
void initPacket() {
|
void initPacket(uint8_t nvm01, uint8_t nvm3) {
|
||||||
*(this->localData.fields.buffer) = nvm01;
|
payloadStart[0] = nvm01;
|
||||||
*(this->localData.fields.buffer + 1) = nvm3;
|
payloadStart[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);
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief This class generates the space packet to update the time of the PLOC supervisor.
|
* @brief This class generates the space packet to update the time of the PLOC supervisor.
|
||||||
*/
|
*/
|
||||||
class SetTimeRef : public SpacePacketCreator {
|
class SetTimeRef : public SpacePacketBase {
|
||||||
public:
|
public:
|
||||||
SetTimeRef(Clock::TimeOfDay_t* time)
|
SetTimeRef(SpBaseParams params)
|
||||||
: SpacePacket(DATA_FIELD_LENGTH - 1, true, APID_SET_TIME_REF, DEFAULT_SEQUENCE_COUNT) {
|
: 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);
|
initPacket(time);
|
||||||
|
return calcCrc();
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static const uint16_t DATA_FIELD_LENGTH = 10;
|
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 CRC_OFFSET = DATA_FIELD_LENGTH - 2;
|
||||||
static const uint16_t SYNC = 0x8000;
|
static const uint16_t SYNC = 0x8000;
|
||||||
|
|
||||||
void initPacket(Clock::TimeOfDay_t* time) {
|
void initPacket(Clock::TimeOfDay_t* time) {
|
||||||
size_t serializedSize = 0;
|
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;
|
uint16_t milliseconds = static_cast<uint16_t>(time->usecond / 1000) | SYNC;
|
||||||
SerializeAdapter::serialize<uint16_t>(&milliseconds, &dataFieldPtr, &serializedSize,
|
SerializeAdapter::serialize<uint16_t>(&milliseconds, &dataFieldPtr, &serializedSize,
|
||||||
sizeof(milliseconds), SerializeIF::Endianness::BIG);
|
sizeof(milliseconds), SerializeIF::Endianness::BIG);
|
||||||
@ -513,65 +520,72 @@ class SetTimeRef : public SpacePacketCreator {
|
|||||||
serializedSize = 0;
|
serializedSize = 0;
|
||||||
SerializeAdapter::serialize<uint8_t>(&year, &dataFieldPtr, &serializedSize, sizeof(time->year),
|
SerializeAdapter::serialize<uint8_t>(&year, &dataFieldPtr, &serializedSize, sizeof(time->year),
|
||||||
SerializeIF::Endianness::BIG);
|
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.
|
* @brief This class can be used to generate the set boot timout command.
|
||||||
*/
|
*/
|
||||||
class SetBootTimeout : public SpacePacketCreator {
|
class SetBootTimeout : public SpacePacketBase {
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
* @brief Constructor
|
* @brief Constructor
|
||||||
*
|
*
|
||||||
* @param timeout The boot timeout in milliseconds.
|
* @param timeout The boot timeout in milliseconds.
|
||||||
*/
|
*/
|
||||||
SetBootTimeout(uint32_t timeout)
|
SetBootTimeout(SpBaseParams params)
|
||||||
: SpacePacket(DATA_FIELD_LENGTH - 1, true, APID_SET_BOOT_TIMEOUT, 1), timeout(timeout) {
|
: SpacePacketBase(params) {
|
||||||
initPacket();
|
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:
|
private:
|
||||||
uint32_t timeout = 0;
|
|
||||||
|
|
||||||
/** boot timeout value (uint32_t) and crc (uint16_t) */
|
/** boot timeout value (uint32_t) and crc (uint16_t) */
|
||||||
static const uint16_t DATA_FIELD_LENGTH = 6;
|
static const uint16_t DATA_FIELD_LENGTH = 6;
|
||||||
|
|
||||||
void initPacket() {
|
void initPacket(uint32_t timeout) {
|
||||||
size_t serializedSize = 0;
|
size_t serializedSize = 0;
|
||||||
uint8_t* dataFieldPtr = this->localData.fields.buffer;
|
uint8_t* dataFieldPtr = payloadStart;
|
||||||
SerializeAdapter::serialize<uint32_t>(&timeout, &dataFieldPtr, &serializedSize, sizeof(timeout),
|
SerializeAdapter::serialize<uint32_t>(&timeout, &dataFieldPtr, &serializedSize, sizeof(timeout),
|
||||||
SerializeIF::Endianness::BIG);
|
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.
|
* @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:
|
public:
|
||||||
/**
|
/**
|
||||||
* @brief Constructor
|
* @brief Constructor
|
||||||
*
|
*
|
||||||
* @param restartTries Maximum restart tries to set.
|
* @param restartTries Maximum restart tries to set.
|
||||||
*/
|
*/
|
||||||
SetRestartTries(uint8_t restartTries)
|
SetRestartTries(SpBaseParams params)
|
||||||
: SpacePacket(DATA_FIELD_LENGTH - 1, true, APID_SET_MAX_RESTART_TRIES, 1),
|
: SpacePacketBase(params) {
|
||||||
restartTries(restartTries) {
|
spParams.setPayloadLen(DATA_FIELD_LENGTH);
|
||||||
initPacket();
|
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:
|
private:
|
||||||
@ -580,15 +594,8 @@ class SetRestartTries : public SpacePacketCreator {
|
|||||||
/** Restart tries value (uint8_t) and crc (uint16_t) */
|
/** Restart tries value (uint8_t) and crc (uint16_t) */
|
||||||
static const uint16_t DATA_FIELD_LENGTH = 3;
|
static const uint16_t DATA_FIELD_LENGTH = 3;
|
||||||
|
|
||||||
void initPacket() {
|
void initPacket(uint8_t restartTries) {
|
||||||
uint8_t* dataFieldPtr = this->localData.fields.buffer;
|
payloadStart[0] = restartTries;
|
||||||
*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);
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -597,30 +604,33 @@ class SetRestartTries : public SpacePacketCreator {
|
|||||||
* of housekeeping data. Normally, this will be disabled by default. However, adding this
|
* of housekeeping data. Normally, this will be disabled by default. However, adding this
|
||||||
* command can be useful for debugging.
|
* command can be useful for debugging.
|
||||||
*/
|
*/
|
||||||
class DisablePeriodicHkTransmission : public SpacePacket {
|
class DisablePeriodicHkTransmission : public SpacePacketBase {
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
* @brief Constructor
|
* @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();
|
initPacket();
|
||||||
|
return calcCrc();
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
uint8_t disableHk = 0;
|
|
||||||
|
|
||||||
/** Restart tries value (uint8_t) and crc (uint16_t) */
|
/** Restart tries value (uint8_t) and crc (uint16_t) */
|
||||||
static const uint16_t DATA_FIELD_LENGTH = 3;
|
static const uint16_t DATA_FIELD_LENGTH = 3;
|
||||||
|
|
||||||
void initPacket() {
|
void initPacket() {
|
||||||
uint8_t* dataFieldPtr = this->localData.fields.buffer;
|
payloadStart[0] = false;
|
||||||
*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);
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -629,7 +639,7 @@ class DisablePeriodicHkTransmission : public SpacePacket {
|
|||||||
*
|
*
|
||||||
* @details There are 7 different latchup alerts.
|
* @details There are 7 different latchup alerts.
|
||||||
*/
|
*/
|
||||||
class LatchupAlert : public SpacePacket {
|
class LatchupAlert : public SpacePacketBase {
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
* @brief Constructor
|
* @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,
|
* @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)
|
* 3 - 3.3V, 4 - NVM_4XO, 5 - MISSION, 6 - SAFECOTS)
|
||||||
*/
|
*/
|
||||||
LatchupAlert(bool state, uint8_t latchupId)
|
LatchupAlert(SpBaseParams params)
|
||||||
: SpacePacket(DATA_FIELD_LENGTH - 1, true), latchupId(latchupId) {
|
: SpacePacketBase(params) {
|
||||||
|
spParams.setPayloadLen(DATA_FIELD_LENGTH);
|
||||||
|
spParams.creator.setSeqCount(DEFAULT_SEQUENCE_COUNT);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
ReturnValue_t buildPacket(bool state, uint8_t latchupId) {
|
||||||
if (state) {
|
if (state) {
|
||||||
this->setAPID(APID_ENABLE_LATCHUP_ALERT);
|
spParams.creator.setApid(APID_ENABLE_LATCHUP_ALERT);
|
||||||
} else {
|
} else {
|
||||||
this->setAPID(APID_DISABLE_LATCHUP_ALERT);
|
spParams.creator.setApid(APID_DISABLE_LATCHUP_ALERT);
|
||||||
}
|
}
|
||||||
this->setPacketSequenceCount(DEFAULT_SEQUENCE_COUNT);
|
auto res = checkSizeAndSerializeHeader();
|
||||||
initPacket();
|
if(res != result::OK) {
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
initPacket(latchupId);
|
||||||
|
return calcCrc();
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static const uint16_t DATA_FIELD_LENGTH = 3;
|
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;
|
static const uint16_t CRC_OFFSET = DATA_FIELD_LENGTH - 2;
|
||||||
|
|
||||||
uint8_t latchupId = 0;
|
uint8_t latchupId = 0;
|
||||||
|
|
||||||
void initPacket() {
|
void initPacket(uint8_t latchupId) {
|
||||||
size_t serializedSize = 0;
|
payloadStart[0] = latchupId;
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
class SetAlertlimit : public SpacePacket {
|
class SetAlertlimit : public SpacePacketBase {
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
* @brief Constructor
|
* @brief Constructor
|
||||||
@ -680,74 +690,78 @@ class SetAlertlimit : public SpacePacket {
|
|||||||
* 3 - 3.3V, 4 - NVM_4XO, 5 - MISSION, 6 - SAFECOTS)
|
* 3 - 3.3V, 4 - NVM_4XO, 5 - MISSION, 6 - SAFECOTS)
|
||||||
* @param dutycycle
|
* @param dutycycle
|
||||||
*/
|
*/
|
||||||
SetAlertlimit(uint8_t latchupId, uint32_t dutycycle)
|
SetAlertlimit(SpBaseParams params)
|
||||||
: SpacePacket(DATA_FIELD_LENGTH - 1, true, APID_SET_ALERT_LIMIT, DEFAULT_SEQUENCE_COUNT),
|
: SpacePacketBase(params) {
|
||||||
latchupId(latchupId),
|
spParams.setPayloadLen(DATA_FIELD_LENGTH);
|
||||||
dutycycle(dutycycle) {
|
spParams.creator.setApid(APID_SET_ALERT_LIMIT);
|
||||||
initPacket();
|
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:
|
private:
|
||||||
static const uint16_t DATA_FIELD_LENGTH = 7;
|
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;
|
static const uint16_t CRC_OFFSET = DATA_FIELD_LENGTH - 2;
|
||||||
|
|
||||||
uint8_t latchupId = 0;
|
uint8_t latchupId = 0;
|
||||||
uint32_t dutycycle = 0;
|
uint32_t dutycycle = 0;
|
||||||
|
|
||||||
void initPacket() {
|
ReturnValue_t initPacket(uint8_t latchupId, uint32_t dutycycle) {
|
||||||
size_t serializedSize = 0;
|
payloadStart[0] = latchupId;
|
||||||
uint8_t* dataFieldPtr = this->localData.fields.buffer;
|
size_t serLen = 0;
|
||||||
SerializeAdapter::serialize<uint8_t>(&latchupId, &dataFieldPtr, &serializedSize,
|
return SerializeAdapter::serialize<uint32_t>(&dutycycle, payloadStart + 1, &serLen,
|
||||||
sizeof(latchupId), SerializeIF::Endianness::BIG);
|
|
||||||
serializedSize = 0;
|
|
||||||
SerializeAdapter::serialize<uint32_t>(&dutycycle, &dataFieldPtr, &serializedSize,
|
|
||||||
sizeof(dutycycle), SerializeIF::Endianness::BIG);
|
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.
|
* @brief This class packages the space packet to enable or disable ADC channels.
|
||||||
*/
|
*/
|
||||||
class SetAdcEnabledChannels : public SpacePacket {
|
class SetAdcEnabledChannels : public SpacePacketBase {
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
* @brief Constructor
|
* @brief Constructor
|
||||||
*
|
*
|
||||||
* @param ch Defines channels to be enabled or disabled.
|
* @param ch Defines channels to be enabled or disabled.
|
||||||
*/
|
*/
|
||||||
SetAdcEnabledChannels(uint16_t ch)
|
SetAdcEnabledChannels(SpBaseParams params)
|
||||||
: SpacePacket(DATA_FIELD_LENGTH - 1, true, APID_SET_ADC_ENABLED_CHANNELS,
|
: SpacePacketBase(params) {
|
||||||
DEFAULT_SEQUENCE_COUNT),
|
spParams.setPayloadLen(DATA_FIELD_LENGTH);
|
||||||
ch(ch) {
|
spParams.creator.setApid(APID_SET_ADC_ENABLED_CHANNELS);
|
||||||
initPacket();
|
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:
|
private:
|
||||||
static const uint16_t DATA_FIELD_LENGTH = 4;
|
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;
|
static const uint16_t CRC_OFFSET = DATA_FIELD_LENGTH - 2;
|
||||||
|
|
||||||
uint16_t ch = 0;
|
void initPacket(uint16_t ch) {
|
||||||
|
|
||||||
void initPacket() {
|
|
||||||
size_t serializedSize = 0;
|
size_t serializedSize = 0;
|
||||||
uint8_t* dataFieldPtr = this->localData.fields.buffer;
|
SerializeAdapter::serialize(&ch, &payloadStart, &serializedSize, sizeof(ch),
|
||||||
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),
|
|
||||||
SerializeIF::Endianness::BIG);
|
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
|
* @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.
|
* the moving average filter applied to the ADC readings.
|
||||||
*/
|
*/
|
||||||
class SetAdcWindowAndStride : public SpacePacket {
|
class SetAdcWindowAndStride : public SpacePacketBase {
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
* @brief Constructor
|
* @brief Constructor
|
||||||
@ -764,94 +778,107 @@ class SetAdcWindowAndStride : public SpacePacket {
|
|||||||
* @param windowSize
|
* @param windowSize
|
||||||
* @param stridingStepSize
|
* @param stridingStepSize
|
||||||
*/
|
*/
|
||||||
SetAdcWindowAndStride(uint16_t windowSize, uint16_t stridingStepSize)
|
SetAdcWindowAndStride(SpBaseParams params): SpacePacketBase(params) {
|
||||||
: SpacePacket(DATA_FIELD_LENGTH - 1, true, APID_SET_ADC_WINDOW_AND_STRIDE,
|
spParams.setPayloadLen(DATA_FIELD_LENGTH);
|
||||||
DEFAULT_SEQUENCE_COUNT),
|
spParams.creator.setApid(APID_SET_ADC_WINDOW_AND_STRIDE);
|
||||||
windowSize(windowSize),
|
spParams.creator.setSeqCount(DEFAULT_SEQUENCE_COUNT);
|
||||||
stridingStepSize(stridingStepSize) {
|
|
||||||
initPacket();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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:
|
private:
|
||||||
static const uint16_t DATA_FIELD_LENGTH = 6;
|
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;
|
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;
|
size_t serializedSize = 0;
|
||||||
uint8_t* dataFieldPtr = this->localData.fields.buffer;
|
uint8_t* data = payloadStart;
|
||||||
SerializeAdapter::serialize<uint16_t>(&windowSize, &dataFieldPtr, &serializedSize,
|
SerializeAdapter::serialize(&windowSize, &data, &serializedSize,
|
||||||
sizeof(windowSize), SerializeIF::Endianness::BIG);
|
sizeof(windowSize), SerializeIF::Endianness::BIG);
|
||||||
serializedSize = 0;
|
SerializeAdapter::serialize(&stridingStepSize, &data, &serializedSize,
|
||||||
SerializeAdapter::serialize<uint16_t>(&stridingStepSize, &dataFieldPtr, &serializedSize,
|
|
||||||
sizeof(stridingStepSize), SerializeIF::Endianness::BIG);
|
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.
|
* @brief This class packages the space packet to set the ADC trigger threshold.
|
||||||
*/
|
*/
|
||||||
class SetAdcThreshold : public SpacePacket {
|
class SetAdcThreshold : public SpacePacketBase {
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
* @brief Constructor
|
* @brief Constructor
|
||||||
*
|
*
|
||||||
* @param threshold
|
* @param threshold
|
||||||
*/
|
*/
|
||||||
SetAdcThreshold(uint32_t threshold)
|
SetAdcThreshold(SpBaseParams params): SpacePacketBase(params) {
|
||||||
: SpacePacket(DATA_FIELD_LENGTH - 1, true, APID_SET_ADC_THRESHOLD, DEFAULT_SEQUENCE_COUNT),
|
spParams.setPayloadLen(DATA_FIELD_LENGTH);
|
||||||
threshold(threshold) {
|
spParams.creator.setApid(APID_SET_ADC_THRESHOLD);
|
||||||
initPacket();
|
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:
|
private:
|
||||||
static const uint16_t DATA_FIELD_LENGTH = 6;
|
static const uint16_t DATA_FIELD_LENGTH = 6;
|
||||||
static const uint16_t DEFAULT_SEQUENCE_COUNT = 1;
|
static const uint16_t DEFAULT_SEQUENCE_COUNT = 1;
|
||||||
|
|
||||||
static const uint16_t CRC_OFFSET = DATA_FIELD_LENGTH - 2;
|
static const uint16_t CRC_OFFSET = DATA_FIELD_LENGTH - 2;
|
||||||
|
|
||||||
uint32_t threshold = 0;
|
void initPacket(uint32_t threshold) {
|
||||||
|
|
||||||
void initPacket() {
|
|
||||||
size_t serializedSize = 0;
|
size_t serializedSize = 0;
|
||||||
uint8_t* dataFieldPtr = this->localData.fields.buffer;
|
SerializeAdapter::serialize(&threshold, payloadStart, &serializedSize,
|
||||||
SerializeAdapter::serialize<uint32_t>(&threshold, &dataFieldPtr, &serializedSize,
|
|
||||||
sizeof(threshold), SerializeIF::Endianness::BIG);
|
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.
|
* @brief This class packages the space packet to run auto EM tests.
|
||||||
*/
|
*/
|
||||||
class RunAutoEmTests : public SpacePacket {
|
class RunAutoEmTests : public SpacePacketBase {
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
* @brief Constructor
|
* @brief Constructor
|
||||||
*
|
*
|
||||||
* @param test 1 - complete EM test, 2 - Short test (only memory readback NVM0,1,3)
|
* @param test 1 - complete EM test, 2 - Short test (only memory readback NVM0,1,3)
|
||||||
*/
|
*/
|
||||||
RunAutoEmTests(uint8_t test)
|
RunAutoEmTests(SpBaseParams params) : SpacePacketBase(params) {
|
||||||
: SpacePacket(DATA_FIELD_LENGTH - 1, true, APID_RUN_AUTO_EM_TESTS, DEFAULT_SEQUENCE_COUNT),
|
spParams.setPayloadLen(DATA_FIELD_LENGTH);
|
||||||
test(test) {
|
spParams.creator.setApid(APID_RUN_AUTO_EM_TESTS);
|
||||||
initPacket();
|
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:
|
private:
|
||||||
static const uint16_t DATA_FIELD_LENGTH = 3;
|
static const uint16_t DATA_FIELD_LENGTH = 3;
|
||||||
static const uint16_t DEFAULT_SEQUENCE_COUNT = 1;
|
static const uint16_t DEFAULT_SEQUENCE_COUNT = 1;
|
||||||
@ -860,17 +887,8 @@ class RunAutoEmTests : public SpacePacket {
|
|||||||
|
|
||||||
uint8_t test = 0;
|
uint8_t test = 0;
|
||||||
|
|
||||||
void initPacket() {
|
void initPacket(uint8_t test) {
|
||||||
size_t serializedSize = 0;
|
payloadStart[0] = test;
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user