changes in supervisor commands
All checks were successful
EIVE/eive-obsw/pipeline/head This commit looks good

This commit is contained in:
Jakob Meier 2022-04-06 07:10:20 +02:00
parent 146868da21
commit 9837a1b62c
3 changed files with 157 additions and 81 deletions

View File

@ -56,6 +56,10 @@ static const DeviceCommandId_t FACTORY_RESET_CLEAR_MIRROR = 40;
static const DeviceCommandId_t FACTORY_RESET_CLEAR_CIRCULAR = 41;
static const DeviceCommandId_t UPDATE_VERIFY = 42;
static const DeviceCommandId_t CONSECUTIVE_MRAM_DUMP = 43;
static const DeviceCommandId_t PREPARE_UPDATE = 44;
static const DeviceCommandId_t START_MPSOC_QUIET = 45;
static const DeviceCommandId_t SET_SHUTDOWN_TIMEOUT = 46;
static const DeviceCommandId_t FACTORY_FLASH = 47;
/** Reply IDs */
static const DeviceCommandId_t ACK_REPORT = 50;
@ -66,9 +70,9 @@ static const DeviceCommandId_t LATCHUP_REPORT = 54;
static const uint16_t SIZE_ACK_REPORT = 14;
static const uint16_t SIZE_EXE_REPORT = 14;
static const uint16_t SIZE_HK_REPORT = 48;
static const uint16_t SIZE_BOOT_STATUS_REPORT = 22;
static const uint16_t SIZE_LATCHUP_STATUS_REPORT = 55;
static const uint16_t SIZE_HK_REPORT = 52;
static const uint16_t SIZE_BOOT_STATUS_REPORT = 24;
static const uint16_t SIZE_LATCHUP_STATUS_REPORT = 31;
/**
* SpacePacket apids of telemetry packets
@ -99,6 +103,10 @@ static const uint16_t APID_SET_BOOT_TIMEOUT = 0xA4;
static const uint16_t APID_SET_MAX_RESTART_TRIES = 0xA5;
static const uint16_t APID_RESET_MPSOC = 0xA6;
static const uint16_t APID_GET_BOOT_STATUS_RPT = 0xA8;
static const uint16_t APID_PREPARE_UPDATE = 0xA9;
static const uint16_t APID_START_MPSOC_QUIET = 0xAA;
static const uint16_t APID_SET_SHUTDOWN_TIMEOUT = 0xAB;
static const uint16_t APID_FACTORY_FLASH = 0xAC;
static const uint16_t APID_UPDATE_AVAILABLE = 0xB0;
static const uint16_t APID_UPDATE_IMAGE_DATA = 0xB1;
static const uint16_t APID_UPDATE_VERIFY = 0xB2;
@ -182,6 +190,8 @@ enum PoolIds : lp_id_t {
BP0_STATE,
BP1_STATE,
BP2_STATE,
BOOT_STATE,
BOOT_CYCLES,
LATCHUP_ID,
CNT0,
@ -199,7 +209,6 @@ enum PoolIds : lp_id_t {
LATCHUP_RPT_TIME_YEAR,
LATCHUP_RPT_TIME_MSEC,
LATCHUP_RPT_TIME_USEC,
LATCHUP_RPT_TIME_IS_SET,
};
static const uint8_t HK_SET_ENTRIES = 13;
@ -307,38 +316,41 @@ class SetTimeRef : public SpacePacket {
}
private:
static const uint16_t DATA_FIELD_LENGTH = 34;
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* data_field_ptr = this->localData.fields.buffer;
SerializeAdapter::serialize<uint32_t>(&time->second, &data_field_ptr, &serializedSize,
sizeof(time->second), SerializeIF::Endianness::BIG);
serializedSize = 0;
SerializeAdapter::serialize<uint32_t>(&time->minute, &data_field_ptr, &serializedSize,
sizeof(time->minute), SerializeIF::Endianness::BIG);
serializedSize = 0;
SerializeAdapter::serialize<uint32_t>(&time->hour, &data_field_ptr, &serializedSize,
sizeof(time->hour), SerializeIF::Endianness::BIG);
serializedSize = 0;
SerializeAdapter::serialize<uint32_t>(&time->day, &data_field_ptr, &serializedSize,
sizeof(time->day), SerializeIF::Endianness::BIG);
serializedSize = 0;
SerializeAdapter::serialize<uint32_t>(&time->month, &data_field_ptr, &serializedSize,
sizeof(time->month), SerializeIF::Endianness::BIG);
serializedSize = 0;
SerializeAdapter::serialize<uint32_t>(&time->year, &data_field_ptr, &serializedSize,
sizeof(time->year), SerializeIF::Endianness::BIG);
serializedSize = 0;
uint32_t milliseconds = time->usecond / 1000;
SerializeAdapter::serialize<uint32_t>(&milliseconds, &data_field_ptr, &serializedSize,
uint16_t milliseconds = static_cast<uint16_t>(time->usecond / 1000) | SYNC;
SerializeAdapter::serialize<uint16_t>(&milliseconds, &data_field_ptr, &serializedSize,
sizeof(milliseconds), SerializeIF::Endianness::BIG);
uint8_t second = static_cast<uint8_t>(time->second);
serializedSize = 0;
uint32_t isSet = 0xFFFFFFFF;
SerializeAdapter::serialize<uint32_t>(&isSet, &data_field_ptr, &serializedSize, sizeof(isSet),
SerializeIF::Endianness::BIG);
SerializeAdapter::serialize<uint8_t>(&second, &data_field_ptr, &serializedSize,
sizeof(time->second), SerializeIF::Endianness::BIG);
uint8_t minute = static_cast<uint8_t>(time->minute);
serializedSize = 0;
SerializeAdapter::serialize<uint8_t>(&minute, &data_field_ptr, &serializedSize,
sizeof(time->minute), SerializeIF::Endianness::BIG);
uint8_t hour = static_cast<uint8_t>(time->hour);
serializedSize = 0;
SerializeAdapter::serialize<uint8_t>(&hour, &data_field_ptr, &serializedSize,
sizeof(time->hour), SerializeIF::Endianness::BIG);
uint8_t day = static_cast<uint8_t>(time->day);
serializedSize = 0;
SerializeAdapter::serialize<uint8_t>(&day, &data_field_ptr, &serializedSize, sizeof(time->day),
SerializeIF::Endianness::BIG);
uint8_t month = static_cast<uint8_t>(time->month);
serializedSize = 0;
SerializeAdapter::serialize<uint8_t>(&month, &data_field_ptr, &serializedSize,
sizeof(time->month), SerializeIF::Endianness::BIG);
uint8_t year = static_cast<uint8_t>(time->year);
serializedSize = 0;
SerializeAdapter::serialize<uint8_t>(&year, &data_field_ptr, &serializedSize,
sizeof(time->year), SerializeIF::Endianness::BIG);
serializedSize = 0;
/* Calculate crc */
uint16_t crc = CRC::crc16ccitt(this->localData.byteStream,
@ -1359,6 +1371,36 @@ class FactoryReset : public SpacePacket {
}
};
class SetShutdownTimeout : public SpacePacket {
public:
SetShutdownTimeout(uint32_t timeout)
: SpacePacket(0, true, APID_SET_SHUTDOWN_TIMEOUT, DEFAULT_SEQUENCE_COUNT), timeout(timeout) {
initPacket();
}
private:
uint16_t PACKET_LEN = 1; // uint32_t timeout + CRC - 1
static const uint16_t DEFAULT_SEQUENCE_COUNT = 1;
uint32_t timeout = 0;
uint8_t crcOffset = 0;
void initPacket() {
uint8_t* data_field_ptr = this->localData.fields.buffer;
size_t serializedSize = 0;
SerializeAdapter::serialize<uint32_t>(&timeout, data_field_ptr, &serializedSize,
sizeof(timeout), SerializeIF::Endianness::BIG);
this->setPacketDataLength(PACKET_LEN);
serializedSize = 0;
uint16_t crc =
CRC::crc16ccitt(this->localData.byteStream, sizeof(CCSDSPrimaryHeader) + PACKET_LEN - 1);
uint8_t* crcPos = this->localData.fields.buffer + crcOffset;
SerializeAdapter::serialize<uint16_t>(&crc, &crcPos, &serializedSize, sizeof(crc),
SerializeIF::Endianness::BIG);
}
};
class SupvTcSpacePacket : public SpacePacket {
public:
SupvTcSpacePacket(size_t payloadDataLen, uint16_t apid)
@ -1480,6 +1522,8 @@ class BootStatusReport : public StaticLocalDataSet<BOOT_REPORT_SET_ENTRIES> {
lp_var_t<uint8_t> bp0State = lp_var_t<uint8_t>(sid.objectId, PoolIds::BP0_STATE, this);
lp_var_t<uint8_t> bp1State = lp_var_t<uint8_t>(sid.objectId, PoolIds::BP1_STATE, this);
lp_var_t<uint8_t> bp2State = lp_var_t<uint8_t>(sid.objectId, PoolIds::BP2_STATE, this);
lp_var_t<uint8_t> bootState = lp_var_t<uint8_t>(sid.objectId, PoolIds::BOOT_STATE, this);
lp_var_t<uint8_t> bootCycles = lp_var_t<uint8_t>(sid.objectId, PoolIds::BOOT_CYCLES, this);
};
/**
@ -1494,7 +1538,7 @@ class HkSet : public StaticLocalDataSet<HK_SET_ENTRIES> {
lp_var_t<uint32_t> tempPs = lp_var_t<uint32_t>(sid.objectId, PoolIds::TEMP_PS, this);
lp_var_t<uint32_t> tempPl = lp_var_t<uint32_t>(sid.objectId, PoolIds::TEMP_PS, this);
lp_var_t<uint32_t> tempSup = lp_var_t<uint32_t>(sid.objectId, PoolIds::TEMP_SUP, this);
lp_var_t<uint32_t> uptime = lp_var_t<uint32_t>(sid.objectId, PoolIds::UPTIME, this);
lp_var_t<uint64_t> uptime = lp_var_t<uint64_t>(sid.objectId, PoolIds::UPTIME, this);
lp_var_t<uint32_t> cpuLoad = lp_var_t<uint32_t>(sid.objectId, PoolIds::CPULOAD, this);
lp_var_t<uint32_t> availableHeap = lp_var_t<uint32_t>(sid.objectId, PoolIds::AVAILABLEHEAP, this);
lp_var_t<uint32_t> numTcs = lp_var_t<uint32_t>(sid.objectId, PoolIds::NUM_TCS, this);
@ -1524,22 +1568,16 @@ class LatchupStatusReport : public StaticLocalDataSet<LATCHUP_RPT_SET_ENTRIES> {
lp_var_t<uint16_t> cnt4 = lp_var_t<uint16_t>(sid.objectId, PoolIds::CNT4, this);
lp_var_t<uint16_t> cnt5 = lp_var_t<uint16_t>(sid.objectId, PoolIds::CNT5, this);
lp_var_t<uint16_t> cnt6 = lp_var_t<uint16_t>(sid.objectId, PoolIds::CNT6, this);
lp_var_t<uint32_t> timeSec =
lp_var_t<uint32_t>(sid.objectId, PoolIds::LATCHUP_RPT_TIME_SEC, this);
lp_var_t<uint32_t> timeMin =
lp_var_t<uint32_t>(sid.objectId, PoolIds::LATCHUP_RPT_TIME_MIN, this);
lp_var_t<uint32_t> timeHour =
lp_var_t<uint32_t>(sid.objectId, PoolIds::LATCHUP_RPT_TIME_HOUR, this);
lp_var_t<uint32_t> timeDay =
lp_var_t<uint32_t>(sid.objectId, PoolIds::LATCHUP_RPT_TIME_DAY, this);
lp_var_t<uint32_t> timeMon =
lp_var_t<uint32_t>(sid.objectId, PoolIds::LATCHUP_RPT_TIME_MON, this);
lp_var_t<uint32_t> timeYear =
lp_var_t<uint32_t>(sid.objectId, PoolIds::LATCHUP_RPT_TIME_YEAR, this);
lp_var_t<uint32_t> timeMsec =
lp_var_t<uint32_t>(sid.objectId, PoolIds::LATCHUP_RPT_TIME_MSEC, this);
lp_var_t<uint32_t> isSet =
lp_var_t<uint32_t>(sid.objectId, PoolIds::LATCHUP_RPT_TIME_IS_SET, this);
lp_var_t<uint16_t> timeMsec =
lp_var_t<uint16_t>(sid.objectId, PoolIds::LATCHUP_RPT_TIME_MSEC, this);
lp_var_t<uint8_t> timeSec = lp_var_t<uint8_t>(sid.objectId, PoolIds::LATCHUP_RPT_TIME_SEC, this);
lp_var_t<uint8_t> timeMin = lp_var_t<uint8_t>(sid.objectId, PoolIds::LATCHUP_RPT_TIME_MIN, this);
lp_var_t<uint8_t> timeHour =
lp_var_t<uint8_t>(sid.objectId, PoolIds::LATCHUP_RPT_TIME_HOUR, this);
lp_var_t<uint8_t> timeDay = lp_var_t<uint8_t>(sid.objectId, PoolIds::LATCHUP_RPT_TIME_DAY, this);
lp_var_t<uint8_t> timeMon = lp_var_t<uint8_t>(sid.objectId, PoolIds::LATCHUP_RPT_TIME_MON, this);
lp_var_t<uint8_t> timeYear =
lp_var_t<uint8_t>(sid.objectId, PoolIds::LATCHUP_RPT_TIME_YEAR, this);
};
} // namespace supv

View File

@ -259,6 +259,26 @@ ReturnValue_t PlocSupervisorHandler::buildCommandFromCommand(DeviceCommandId_t d
nextReplyId = supv::ACK_REPORT;
result = RETURN_OK;
break;
case (supv::PREPARE_UPDATE): {
prepareEmptyCmd(supv::APID_PREPARE_UPDATE);
result = RETURN_OK;
break;
}
case (supv::START_MPSOC_QUIET): {
prepareEmptyCmd(supv::APID_START_MPSOC_QUIET);
result = RETURN_OK;
break;
}
case (supv::SET_SHUTDOWN_TIMEOUT): {
prepareSetShutdownTimeoutCmd(commandData);
result = RETURN_OK;
break;
}
case (supv::FACTORY_FLASH): {
prepareEmptyCmd(supv::APID_FACTORY_FLASH);
result = RETURN_OK;
break;
}
default:
sif::debug << "PlocSupervisorHandler::buildCommandFromCommand: Command not implemented"
<< std::endl;
@ -317,6 +337,10 @@ void PlocSupervisorHandler::fillCommandAndReplyMap() {
this->insertInCommandMap(supv::FACTORY_RESET_CLEAR_MIRROR);
this->insertInCommandMap(supv::FACTORY_RESET_CLEAR_CIRCULAR);
this->insertInCommandMap(supv::CAN_LOOPBACK_TEST);
this->insertInCommandMap(supv::PREPARE_UPDATE);
this->insertInCommandMap(supv::START_MPSOC_QUIET);
this->insertInCommandMap(supv::SET_SHUTDOWN_TIMEOUT);
this->insertInCommandMap(supv::FACTORY_FLASH);
this->insertInCommandAndReplyMap(supv::FIRST_MRAM_DUMP, 3);
this->insertInCommandAndReplyMap(supv::CONSECUTIVE_MRAM_DUMP, 3);
this->insertInReplyMap(supv::ACK_REPORT, 3, nullptr, supv::SIZE_ACK_REPORT);
@ -445,7 +469,7 @@ ReturnValue_t PlocSupervisorHandler::initializeLocalDataPool(localpool::DataPool
localDataPoolMap.emplace(supv::MISSION_IO_STATE, new PoolEntry<uint8_t>({0}));
localDataPoolMap.emplace(supv::FMC_STATE, new PoolEntry<uint32_t>({0}));
localDataPoolMap.emplace(supv::NUM_TCS, new PoolEntry<uint32_t>({0}));
localDataPoolMap.emplace(supv::UPTIME, new PoolEntry<uint32_t>({0}));
localDataPoolMap.emplace(supv::UPTIME, new PoolEntry<uint64_t>({0}));
localDataPoolMap.emplace(supv::CPULOAD, new PoolEntry<uint32_t>({0}));
localDataPoolMap.emplace(supv::AVAILABLEHEAP, new PoolEntry<uint32_t>({0}));
@ -466,14 +490,13 @@ ReturnValue_t PlocSupervisorHandler::initializeLocalDataPool(localpool::DataPool
localDataPoolMap.emplace(supv::CNT4, new PoolEntry<uint16_t>({0}));
localDataPoolMap.emplace(supv::CNT5, new PoolEntry<uint16_t>({0}));
localDataPoolMap.emplace(supv::CNT6, new PoolEntry<uint16_t>({0}));
localDataPoolMap.emplace(supv::LATCHUP_RPT_TIME_SEC, new PoolEntry<uint32_t>({0}));
localDataPoolMap.emplace(supv::LATCHUP_RPT_TIME_MIN, new PoolEntry<uint32_t>({0}));
localDataPoolMap.emplace(supv::LATCHUP_RPT_TIME_HOUR, new PoolEntry<uint32_t>({0}));
localDataPoolMap.emplace(supv::LATCHUP_RPT_TIME_DAY, new PoolEntry<uint32_t>({0}));
localDataPoolMap.emplace(supv::LATCHUP_RPT_TIME_MON, new PoolEntry<uint32_t>({0}));
localDataPoolMap.emplace(supv::LATCHUP_RPT_TIME_YEAR, new PoolEntry<uint32_t>({0}));
localDataPoolMap.emplace(supv::LATCHUP_RPT_TIME_MSEC, new PoolEntry<uint32_t>({0}));
localDataPoolMap.emplace(supv::LATCHUP_RPT_TIME_IS_SET, new PoolEntry<uint32_t>({0}));
localDataPoolMap.emplace(supv::LATCHUP_RPT_TIME_MSEC, new PoolEntry<uint16_t>({0}));
localDataPoolMap.emplace(supv::LATCHUP_RPT_TIME_SEC, new PoolEntry<uint8_t>({0}));
localDataPoolMap.emplace(supv::LATCHUP_RPT_TIME_MIN, new PoolEntry<uint8_t>({0}));
localDataPoolMap.emplace(supv::LATCHUP_RPT_TIME_HOUR, new PoolEntry<uint8_t>({0}));
localDataPoolMap.emplace(supv::LATCHUP_RPT_TIME_DAY, new PoolEntry<uint8_t>({0}));
localDataPoolMap.emplace(supv::LATCHUP_RPT_TIME_MON, new PoolEntry<uint8_t>({0}));
localDataPoolMap.emplace(supv::LATCHUP_RPT_TIME_YEAR, new PoolEntry<uint8_t>({0}));
return HasReturnvaluesIF::RETURN_OK;
}
@ -575,6 +598,10 @@ ReturnValue_t PlocSupervisorHandler::enableReplyInReplyMap(DeviceCommandMap::ite
case supv::FACTORY_RESET_CLEAR_CIRCULAR:
case supv::REQUEST_LOGGING_DATA:
case supv::DISABLE_PERIOIC_HK_TRANSMISSION:
case supv::PREPARE_UPDATE:
case supv::START_MPSOC_QUIET:
case supv::SET_SHUTDOWN_TIMEOUT:
case supv::FACTORY_FLASH:
enabledReplies = 2;
break;
default:
@ -722,9 +749,10 @@ ReturnValue_t PlocSupervisorHandler::handleHkReport(const uint8_t* data) {
hkset.tempSup = *(data + offset) << 24 | *(data + offset + 1) << 16 | *(data + offset + 2) << 8 |
*(data + offset + 3);
offset += 4;
hkset.uptime = *(data + offset) << 24 | *(data + offset + 1) << 16 | *(data + offset + 2) << 8 |
*(data + offset + 3);
offset += 4;
size_t size = sizeof(hkset.uptime.value);
result = SerializeAdapter::deSerialize(&hkset.uptime, data + offset, &size,
SerializeIF::Endianness::BIG);
offset += 8;
hkset.cpuLoad = *(data + offset) << 24 | *(data + offset + 1) << 16 | *(data + offset + 2) << 8 |
*(data + offset + 3);
offset += 4;
@ -806,6 +834,10 @@ ReturnValue_t PlocSupervisorHandler::handleBootStatusReport(const uint8_t* data)
bootStatusReport.bp1State = *(data + offset);
offset += 1;
bootStatusReport.bp2State = *(data + offset);
offset += 1;
bootStatusReport.bootState = *(data + offset);
offset += 1;
bootStatusReport.bootCycles = *(data + offset);
nextReplyId = supv::EXE_REPORT;
@ -859,30 +891,19 @@ ReturnValue_t PlocSupervisorHandler::handleLatchupStatusReport(const uint8_t* da
offset += 2;
latchupStatusReport.cnt6 = *(data + offset) << 8 | *(data + offset + 1);
offset += 2;
latchupStatusReport.timeSec = *(data + offset) << 24 | *(data + offset + 1) << 16 |
*(data + offset + 2) << 8 | *(data + offset + 3);
offset += 4;
latchupStatusReport.timeMin = *(data + offset) << 24 | *(data + offset + 1) << 16 |
*(data + offset + 2) << 8 | *(data + offset + 3);
offset += 4;
latchupStatusReport.timeHour = *(data + offset) << 24 | *(data + offset + 1) << 16 |
*(data + offset + 2) << 8 | *(data + offset + 3);
offset += 4;
latchupStatusReport.timeDay = *(data + offset) << 24 | *(data + offset + 1) << 16 |
*(data + offset + 2) << 8 | *(data + offset + 3);
offset += 4;
latchupStatusReport.timeMon = *(data + offset) << 24 | *(data + offset + 1) << 16 |
*(data + offset + 2) << 8 | *(data + offset + 3);
offset += 4;
latchupStatusReport.timeYear = *(data + offset) << 24 | *(data + offset + 1) << 16 |
*(data + offset + 2) << 8 | *(data + offset + 3);
offset += 4;
latchupStatusReport.timeMsec = *(data + offset) << 24 | *(data + offset + 1) << 16 |
*(data + offset + 2) << 8 | *(data + offset + 3);
offset += 4;
latchupStatusReport.isSet = *(data + offset) << 24 | *(data + offset + 1) << 16 |
*(data + offset + 2) << 8 | *(data + offset + 3);
offset += 4;
latchupStatusReport.timeMsec = *(data + offset) << 8 | *(data + offset + 1);
offset += 2;
latchupStatusReport.timeSec = *(data + offset);
offset += 1;
latchupStatusReport.timeMin = *(data + offset);
offset += 1;
latchupStatusReport.timeHour = *(data + offset);
offset += 1;
latchupStatusReport.timeDay = *(data + offset);
offset += 1;
latchupStatusReport.timeMon = *(data + offset);
offset += 1;
latchupStatusReport.timeYear = *(data + offset);
nextReplyId = supv::EXE_REPORT;
@ -1267,6 +1288,21 @@ void PlocSupervisorHandler::packetToOutBuffer(uint8_t* packetData, size_t fullSi
nextReplyId = supv::ACK_REPORT;
}
void PlocSupervisorHandler::prepareSetShutdownTimeoutCmd(const uint8_t* commandData) {
uint32_t timeout = 0;
ReturnValue_t result = RETURN_OK;
size_t size = sizeof(timeout);
result =
SerializeAdapter::deSerialize(&timeout, &commandData, &size, SerializeIF::Endianness::BIG);
if (result != RETURN_OK) {
sif::warning
<< "PlocSupervisorHandler::prepareSetShutdownTimeoutCmd: Failed to deserialize timeout"
<< std::endl;
}
supv::SetShutdownTimeout packet(timeout);
packetToOutBuffer(packet.getWholeData(), packet.getFullSize());
}
void PlocSupervisorHandler::disableAllReplies() {
DeviceReplyMap::iterator iter;

View File

@ -348,6 +348,8 @@ class PlocSupervisorHandler : public DeviceHandlerBase {
ReturnValue_t createMramDumpFile();
ReturnValue_t getTimeStampString(std::string& timeStamp);
void prepareSetShutdownTimeoutCmd(const uint8_t* commandData);
};
#endif /* MISSION_DEVICES_PLOCSUPERVISORHANDLER_H_ */