ploc supervisor wip
This commit is contained in:
@ -62,12 +62,24 @@ ReturnValue_t PlocSupervisorHandler::buildCommandFromCommand(
|
||||
prepareSelBootImageCmd(commandData);
|
||||
return RETURN_OK;
|
||||
}
|
||||
case(PLOC_SPV::RESET_MPSOC): {
|
||||
prepareEmptyCmd(PLOC_SPV::APID_RESET_MPSOC);
|
||||
return RETURN_OK;
|
||||
}
|
||||
case(PLOC_SPV::SET_TIME_REF): {
|
||||
return prepareSetTimeRefCmd();
|
||||
}
|
||||
case(PLOC_SPV::SET_BOOT_TIMEOUT): {
|
||||
prepareSetBootTimeoutCmd(commandData);
|
||||
return RETURN_OK;
|
||||
}
|
||||
case(PLOC_SPV::SET_MAX_RESTART_TRIES): {
|
||||
prepareRestartTriesCmd(commandData);
|
||||
return RETURN_OK;
|
||||
}
|
||||
case(PLOC_SPV::DISABLE_PERIOIC_HK_TRANSMISSION): {
|
||||
prepareDisableHk();
|
||||
return RETURN_OK;
|
||||
}
|
||||
default:
|
||||
sif::debug << "PlocSupervisorHandler::buildCommandFromCommand: Command not implemented"
|
||||
@ -87,6 +99,7 @@ void PlocSupervisorHandler::fillCommandAndReplyMap() {
|
||||
this->insertInCommandMap(PLOC_SPV::SET_MAX_RESTART_TRIES);
|
||||
this->insertInCommandMap(PLOC_SPV::RESET_MPSOC);
|
||||
this->insertInCommandMap(PLOC_SPV::SET_TIME_REF);
|
||||
this->insertInCommandMap(PLOC_SPV::DISABLE_PERIOIC_HK_TRANSMISSION);
|
||||
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, nullptr, PLOC_SPV::SIZE_HK_REPORT);
|
||||
@ -299,29 +312,12 @@ ReturnValue_t PlocSupervisorHandler::handleHkReport(const uint8_t* data) {
|
||||
}
|
||||
|
||||
uint16_t offset = PLOC_SPV::DATA_FIELD_OFFSET;
|
||||
hkset.numTms = *(data + offset) << 24 | *(data + offset + 1) << 16 | *(data + offset + 2) << 8
|
||||
| *(data + offset + 3);
|
||||
offset += 4;
|
||||
hkset.tempPs = *(data + offset) << 24 | *(data + offset + 1) << 16 | *(data + offset + 2) << 8
|
||||
| *(data + offset + 3);
|
||||
offset += 4;
|
||||
hkset.tempPl = *(data + offset) << 24 | *(data + offset + 1) << 16 | *(data + offset + 2) << 8
|
||||
| *(data + offset + 3);
|
||||
offset += 4;
|
||||
hkset.socState = *(data + offset) << 24 | *(data + offset + 1) << 16 | *(data + offset + 2) << 8
|
||||
| *(data + offset + 3);
|
||||
offset += 4;
|
||||
hkset.nvm0_1_state = *(data + offset);
|
||||
offset += 1;
|
||||
hkset.nvm3_state = *(data + offset);
|
||||
offset += 1;
|
||||
hkset.missionIoState = *(data + offset);
|
||||
offset += 1;
|
||||
hkset.fmcState = *(data + offset);
|
||||
offset += 1;
|
||||
hkset.numTcs = *(data + offset) << 24 | *(data + offset + 1) << 16 | *(data + offset + 2) << 8
|
||||
| *(data + offset + 3);
|
||||
offset += 4;
|
||||
hkset.tempSup = *(data + offset) << 24 | *(data + offset + 1) << 16 | *(data + offset + 2) << 8
|
||||
| *(data + offset + 3);
|
||||
offset += 4;
|
||||
@ -334,13 +330,35 @@ ReturnValue_t PlocSupervisorHandler::handleHkReport(const uint8_t* data) {
|
||||
hkset.availableHeap = *(data + offset) << 24 | *(data + offset + 1) << 16 | *(data + offset + 2) << 8
|
||||
| *(data + offset + 3);
|
||||
offset += 4;
|
||||
hkset.numTcs = *(data + offset) << 24 | *(data + offset + 1) << 16 | *(data + offset + 2) << 8
|
||||
| *(data + offset + 3);
|
||||
offset += 4;
|
||||
hkset.numTms = *(data + offset) << 24 | *(data + offset + 1) << 16 | *(data + offset + 2) << 8
|
||||
| *(data + offset + 3);
|
||||
offset += 4;
|
||||
hkset.socState = *(data + offset) << 24 | *(data + offset + 1) << 16 | *(data + offset + 2) << 8
|
||||
| *(data + offset + 3);
|
||||
offset += 4;
|
||||
hkset.nvm0_1_state = *(data + offset);
|
||||
offset += 1;
|
||||
hkset.nvm3_state = *(data + offset);
|
||||
offset += 1;
|
||||
hkset.missionIoState = *(data + offset);
|
||||
offset += 1;
|
||||
hkset.fmcState = *(data + offset);
|
||||
offset += 1;
|
||||
|
||||
nextReplyId = PLOC_SPV::EXE_REPORT;
|
||||
|
||||
#if OBSW_VERBOSE_LEVEL >= 1 && PLOC_MPSOC_DEBUG == 1
|
||||
sif::info << "PlocSupervisorHandler::handleHkReport: num_tms: " << hkset.numTms << std::endl;
|
||||
#if OBSW_VERBOSE_LEVEL >= 1 && PLOC_SUPERVISOR_DEBUG == 1
|
||||
sif::info << "PlocSupervisorHandler::handleHkReport: temp_ps: " << hkset.tempPs << std::endl;
|
||||
sif::info << "PlocSupervisorHandler::handleHkReport: temp_pl: " << hkset.tempPl << std::endl;
|
||||
sif::info << "PlocSupervisorHandler::handleHkReport: temp_sup: " << hkset.tempSup << std::endl;
|
||||
sif::info << "PlocSupervisorHandler::handleHkReport: uptime: " << hkset.uptime << std::endl;
|
||||
sif::info << "PlocSupervisorHandler::handleHkReport: cpu_load: " << hkset.cpuLoad << std::endl;
|
||||
sif::info << "PlocSupervisorHandler::handleHkReport: available_heap: " << hkset.availableHeap << std::endl;
|
||||
sif::info << "PlocSupervisorHandler::handleHkReport: num_tcs: " << hkset.numTcs << std::endl;
|
||||
sif::info << "PlocSupervisorHandler::handleHkReport: num_tms: " << hkset.numTms << std::endl;
|
||||
sif::info << "PlocSupervisorHandler::handleHkReport: soc_state: " << hkset.socState << std::endl;
|
||||
sif::info << "PlocSupervisorHandler::handleHkReport: nvm0_1_state: "
|
||||
<< static_cast<unsigned int>(hkset.nvm0_1_state.value) << std::endl;
|
||||
@ -350,11 +368,7 @@ ReturnValue_t PlocSupervisorHandler::handleHkReport(const uint8_t* data) {
|
||||
<< static_cast<unsigned int>(hkset.missionIoState.value) << std::endl;
|
||||
sif::info << "PlocSupervisorHandler::handleHkReport: fmc_state: "
|
||||
<< static_cast<unsigned int>(hkset.fmcState.value) << std::endl;
|
||||
sif::info << "PlocSupervisorHandler::handleHkReport: num_tcs: " << hkset.numTcs << std::endl;
|
||||
sif::info << "PlocSupervisorHandler::handleHkReport: temp_sup: " << hkset.tempSup << std::endl;
|
||||
sif::info << "PlocSupervisorHandler::handleHkReport: uptime: " << hkset.uptime << std::endl;
|
||||
sif::info << "PlocSupervisorHandler::handleHkReport: cpu_load: " << hkset.cpuLoad << std::endl;
|
||||
sif::info << "PlocSupervisorHandler::handleHkReport: available_heap: " << hkset.availableHeap << std::endl;
|
||||
|
||||
#endif
|
||||
|
||||
return result;
|
||||
@ -509,6 +523,14 @@ ReturnValue_t PlocSupervisorHandler::prepareSetTimeRefCmd() {
|
||||
return RETURN_OK;
|
||||
}
|
||||
|
||||
void PlocSupervisorHandler::prepareDisableHk() {
|
||||
PLOC_SPV::DisablePeriodicHkTransmission packet;
|
||||
memcpy(commandBuffer, packet.getWholeData(), packet.getFullSize());
|
||||
rawPacket = commandBuffer;
|
||||
rawPacketLen = packet.getFullSize();
|
||||
nextReplyId = PLOC_SPV::ACK_REPORT;
|
||||
}
|
||||
|
||||
void PlocSupervisorHandler::prepareSetBootTimeoutCmd(const uint8_t * commandData) {
|
||||
uint32_t timeout = *(commandData) << 24 | *(commandData + 1) << 16 | *(commandData + 2) << 8
|
||||
| *(commandData + 3);
|
||||
@ -519,6 +541,15 @@ void PlocSupervisorHandler::prepareSetBootTimeoutCmd(const uint8_t * commandData
|
||||
nextReplyId = PLOC_SPV::ACK_REPORT;
|
||||
}
|
||||
|
||||
void PlocSupervisorHandler::prepareRestartTriesCmd(const uint8_t * commandData) {
|
||||
uint8_t restartTries = *(commandData);
|
||||
PLOC_SPV::SetRestartTries packet(restartTries);
|
||||
memcpy(commandBuffer, packet.getWholeData(), packet.getFullSize());
|
||||
rawPacket = commandBuffer;
|
||||
rawPacketLen = packet.getFullSize();
|
||||
nextReplyId = PLOC_SPV::ACK_REPORT;
|
||||
}
|
||||
|
||||
void PlocSupervisorHandler::disableAllReplies() {
|
||||
|
||||
DeviceReplyMap::iterator iter;
|
||||
|
@ -164,6 +164,8 @@ private:
|
||||
*/
|
||||
void prepareSelBootImageCmd(const uint8_t * commandData);
|
||||
|
||||
void prepareDisableHk();
|
||||
|
||||
/**
|
||||
* @brief This function fills the commandBuffer with the data to update the time of the
|
||||
* PLOC supervisor.
|
||||
@ -176,6 +178,8 @@ private:
|
||||
*/
|
||||
void prepareSetBootTimeoutCmd(const uint8_t * commandData);
|
||||
|
||||
void prepareRestartTriesCmd(const uint8_t * commandData);
|
||||
|
||||
/**
|
||||
* @brief In case an acknowledgment failure reply has been received this function disables
|
||||
* all previously enabled commands and resets the exepected replies variable of an
|
||||
|
@ -19,6 +19,7 @@ static const DeviceCommandId_t SET_BOOT_TIMEOUT = 6;
|
||||
static const DeviceCommandId_t SET_MAX_RESTART_TRIES = 7;
|
||||
static const DeviceCommandId_t RESET_MPSOC = 8;
|
||||
static const DeviceCommandId_t SET_TIME_REF = 9;
|
||||
static const DeviceCommandId_t DISABLE_PERIOIC_HK_TRANSMISSION = 10;
|
||||
|
||||
/** Reply IDs */
|
||||
static const DeviceCommandId_t ACK_REPORT = 50;
|
||||
@ -64,6 +65,7 @@ static const uint16_t APID_UPDATE_VERIFY = 0xB2;
|
||||
static const uint16_t APID_WTD_ENABLE = 0xC0;
|
||||
static const uint16_t APID_WTD_CONFIG_TIMEOUT = 0xC1;
|
||||
static const uint16_t APID_SET_TIME_REF = 0xC2;
|
||||
static const uint16_t APID_DISABLE_HK = 0xC3;
|
||||
|
||||
static const uint16_t APID_GET_HK_REPORT = 0xC6;
|
||||
|
||||
@ -289,6 +291,77 @@ private:
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief This class can be used to generate the space packet to set the maximum boot tries.
|
||||
*/
|
||||
class SetRestartTries: public SpacePacket {
|
||||
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();
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
uint8_t restartTries = 0;
|
||||
|
||||
/** Restart tries value (uint8_t) and crc (uint16_t) */
|
||||
static const uint16_t DATA_FIELD_LENGTH = 3;
|
||||
|
||||
void initPacket() {
|
||||
uint8_t* data_field_ptr = this->localData.fields.buffer;
|
||||
*data_field_ptr = restartTries;
|
||||
uint16_t crc = CRC::crc16ccitt(this->localData.byteStream,
|
||||
sizeof(CCSDSPrimaryHeader) + DATA_FIELD_LENGTH - 2);
|
||||
size_t serializedSize = 0;
|
||||
uint8_t* crcPtr = data_field_ptr + 1;
|
||||
SerializeAdapter::serialize<uint16_t>(&crc, &crcPtr, &serializedSize, sizeof(crc),
|
||||
SerializeIF::Endianness::BIG);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief With this class the space packet can be generated to disable to periodic transmission
|
||||
* of housekeeping data. Normally, this will be disabled by default. However, adding this
|
||||
* command can be useful for debugging.
|
||||
*/
|
||||
class DisablePeriodicHkTransmission: public SpacePacket {
|
||||
public:
|
||||
|
||||
/**
|
||||
* @brief Constructor
|
||||
*/
|
||||
DisablePeriodicHkTransmission() :
|
||||
SpacePacket(DATA_FIELD_LENGTH - 1, true, APID_DISABLE_HK, 1) {
|
||||
initPacket();
|
||||
}
|
||||
|
||||
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* data_field_ptr = this->localData.fields.buffer;
|
||||
*data_field_ptr = disableHk;
|
||||
uint16_t crc = CRC::crc16ccitt(this->localData.byteStream,
|
||||
sizeof(CCSDSPrimaryHeader) + DATA_FIELD_LENGTH - 2);
|
||||
size_t serializedSize = 0;
|
||||
uint8_t* crcPtr = data_field_ptr + 1;
|
||||
SerializeAdapter::serialize<uint16_t>(&crc, &crcPtr, &serializedSize, sizeof(crc),
|
||||
SerializeIF::Endianness::BIG);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief This dataset to store the housekeeping data of the supervisor.
|
||||
*/
|
||||
|
Reference in New Issue
Block a user