select nvm command
This commit is contained in:
parent
3d39ddf85c
commit
50ca738d5c
@ -175,6 +175,16 @@ ReturnValue_t PlocSupervisorHandler::buildCommandFromCommand(
|
||||
prepareEmptyCmd(PLOC_SPV::APID_COPY_ADC_DATA_TO_MRAM);
|
||||
result = RETURN_OK;
|
||||
break;
|
||||
}
|
||||
case(PLOC_SPV::ENABLE_NVMS): {
|
||||
prepareEnableNvmsCmd(commandData);
|
||||
result = RETURN_OK;
|
||||
break;
|
||||
}
|
||||
case(PLOC_SPV::SELECT_NVM): {
|
||||
prepareSelectNvmCmd(commandData);
|
||||
result = RETURN_OK;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
sif::debug << "PlocSupervisorHandler::buildCommandFromCommand: Command not implemented"
|
||||
@ -219,6 +229,8 @@ void PlocSupervisorHandler::fillCommandAndReplyMap() {
|
||||
this->insertInCommandMap(PLOC_SPV::SET_ADC_THRESHOLD);
|
||||
this->insertInCommandMap(PLOC_SPV::GET_LATCHUP_STATUS_REPORT);
|
||||
this->insertInCommandMap(PLOC_SPV::COPY_ADC_DATA_TO_MRAM);
|
||||
this->insertInCommandMap(PLOC_SPV::ENABLE_NVMS);
|
||||
this->insertInCommandMap(PLOC_SPV::SELECT_NVM);
|
||||
this->insertInReplyMap(PLOC_SPV::ACK_REPORT, 3, nullptr, PLOC_SPV::SIZE_ACK_REPORT);
|
||||
this->insertInReplyMap(PLOC_SPV::EXE_REPORT, 3, nullptr, PLOC_SPV::SIZE_EXE_REPORT);
|
||||
this->insertInReplyMap(PLOC_SPV::HK_REPORT, 3, &hkset, PLOC_SPV::SIZE_HK_REPORT);
|
||||
@ -1042,6 +1054,19 @@ void PlocSupervisorHandler::prepareSetAdcThresholdCmd(const uint8_t* commandData
|
||||
packetToOutBuffer(packet.getWholeData(), packet.getFullSize());
|
||||
}
|
||||
|
||||
void PlocSupervisorHandler::prepareEnableNvmsCmd(const uint8_t* commandData) {
|
||||
uint8_t n01 = *commandData;
|
||||
uint8_t n3 = *(commandData + 1);
|
||||
PLOC_SPV::EnableNvms packet(n01, n3);
|
||||
packetToOutBuffer(packet.getWholeData(), packet.getFullSize());
|
||||
}
|
||||
|
||||
void PlocSupervisorHandler::prepareSelectNvmCmd(const uint8_t* commandData) {
|
||||
uint8_t mem = *commandData;
|
||||
PLOC_SPV::SelectNvm packet(mem);
|
||||
packetToOutBuffer(packet.getWholeData(), packet.getFullSize());
|
||||
}
|
||||
|
||||
void PlocSupervisorHandler::packetToOutBuffer(uint8_t* packetData, size_t fullSize) {
|
||||
memcpy(commandBuffer, packetData, fullSize);
|
||||
rawPacket = commandBuffer;
|
||||
|
@ -231,6 +231,8 @@ private:
|
||||
void prepareSetAdcEnabledChannelsCmd(const uint8_t* commandData);
|
||||
void prepareSetAdcWindowAndStrideCmd(const uint8_t* commandData);
|
||||
void prepareSetAdcThresholdCmd(const uint8_t* commandData);
|
||||
void prepareEnableNvmsCmd(const uint8_t* commandData);
|
||||
void prepareSelectNvmCmd(const uint8_t* commandData);
|
||||
|
||||
|
||||
/**
|
||||
|
@ -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.
|
||||
*/
|
||||
|
Loading…
x
Reference in New Issue
Block a user