select nvm command
This commit is contained in:
@ -964,6 +964,91 @@ private:
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief This class packages the space packet to select between NVM 0 and NVM 1.
|
||||
*/
|
||||
class SelectNvm: public SpacePacket {
|
||||
public:
|
||||
|
||||
/**
|
||||
* @brief Constructor
|
||||
*
|
||||
* @param mem 0 - select NVM0, 1 - select NVM1.
|
||||
*/
|
||||
SelectNvm(uint8_t mem) :
|
||||
SpacePacket(DATA_FIELD_LENGTH - 1, true, APID_SELECT_NVM,
|
||||
DEFAULT_SEQUENCE_COUNT), mem(mem) {
|
||||
initPacket();
|
||||
}
|
||||
|
||||
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 mem = 0;
|
||||
|
||||
void initPacket() {
|
||||
size_t serializedSize = 0;
|
||||
uint8_t* data_field_ptr = this->localData.fields.buffer;
|
||||
SerializeAdapter::serialize<uint8_t>(&mem, &data_field_ptr, &serializedSize,
|
||||
sizeof(mem), 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 power the NVMs on or off.
|
||||
*/
|
||||
class EnableNvms: public SpacePacket {
|
||||
public:
|
||||
|
||||
/**
|
||||
* @brief Constructor
|
||||
*
|
||||
* @param n01 Set to one to power NVM0 and NVM1 on. 0 powers off memory.
|
||||
* @param n3 Set to one to power NVM3 on. 0 powers off the memory.
|
||||
*/
|
||||
EnableNvms(uint8_t n01, uint8_t n3) :
|
||||
SpacePacket(DATA_FIELD_LENGTH - 1, true, APID_ENABLE_NVMS,
|
||||
DEFAULT_SEQUENCE_COUNT), n01(n01), n3(n3) {
|
||||
initPacket();
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
uint8_t n01 = 0;
|
||||
uint8_t n3 = 0;
|
||||
|
||||
void initPacket() {
|
||||
size_t serializedSize = 0;
|
||||
uint8_t* data_field_ptr = this->localData.fields.buffer;
|
||||
SerializeAdapter::serialize<uint8_t>(&n01, &data_field_ptr, &serializedSize,
|
||||
sizeof(n01), SerializeIF::Endianness::BIG);
|
||||
serializedSize = 0;
|
||||
SerializeAdapter::serialize<uint8_t>(&n3, &data_field_ptr, &serializedSize,
|
||||
sizeof(n3), 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 dataset stores the boot status report of the supervisor.
|
||||
*/
|
||||
|
Reference in New Issue
Block a user