PLOC SUPV Update to newer firmware #316
@ -65,7 +65,7 @@ ReturnValue_t PlocSupvHelper::initializeInterface(CookieIF* cookie) {
|
||||
// Use non-canonical mode and clear echo flag
|
||||
tty.c_lflag &= ~(ICANON | ECHO);
|
||||
|
||||
// Non-blocking mode, 0.5 seconds timeout
|
||||
// Blocking mode, 0.5 seconds timeout
|
||||
tty.c_cc[VTIME] = 5;
|
||||
tty.c_cc[VMIN] = 0;
|
||||
|
||||
@ -311,12 +311,7 @@ void PlocSupvHelper::executeFullCheckMemoryCommand() {
|
||||
return;
|
||||
}
|
||||
sif::info << "PLOC SUPV Mem Check: Memory Check" << std::endl;
|
||||
result = handleCheckMemoryCommand();
|
||||
if (result == returnvalue::OK) {
|
||||
triggerEvent(SUPV_MEM_CHECK_OK, result);
|
||||
} else {
|
||||
triggerEvent(SUPV_MEM_CHECK_FAIL, result);
|
||||
}
|
||||
handleCheckMemoryCommand();
|
||||
}
|
||||
|
||||
ReturnValue_t PlocSupvHelper::executeUpdate() {
|
||||
@ -434,6 +429,7 @@ ReturnValue_t PlocSupvHelper::writeUpdatePackets() {
|
||||
#if OBSW_DEBUG_PLOC_SUPERVISOR == 1
|
||||
progressPrinter.print(update.bytesWritten);
|
||||
#endif /* OBSW_DEBUG_PLOC_SUPERVISOR == 1 */
|
||||
TaskFactory::delayTask(1);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@ -552,7 +548,11 @@ ReturnValue_t PlocSupvHelper::handlePacketTransmissionNoReply(supv::TcBase& pack
|
||||
}
|
||||
Countdown countdown(timeoutExecutionReport);
|
||||
bool ackReceived = false;
|
||||
bool packetWasHandled = false;
|
||||
while (true) {
|
||||
while (result != NO_PACKET_FOUND) {
|
||||
result = tryHdlcParsing();
|
||||
}
|
||||
if (not decodedQueue.empty()) {
|
||||
size_t packetLen = 0;
|
||||
decodedQueue.retrieve(&packetLen);
|
||||
@ -569,6 +569,7 @@ ReturnValue_t PlocSupvHelper::handlePacketTransmissionNoReply(supv::TcBase& pack
|
||||
retval = handleAckReception(packet, serviceId, packetLen);
|
||||
if (retval == 1) {
|
||||
ackReceived = true;
|
||||
packetWasHandled = true;
|
||||
} else if (retval == -1) {
|
||||
return returnvalue::FAILED;
|
||||
}
|
||||
@ -580,7 +581,8 @@ ReturnValue_t PlocSupvHelper::handlePacketTransmissionNoReply(supv::TcBase& pack
|
||||
return returnvalue::FAILED;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
}
|
||||
if (not packetWasHandled) {
|
||||
pushIpcData(decodedBuf.data(), packetLen);
|
||||
decodedRingBuf.deleteData(packetLen);
|
||||
}
|
||||
@ -601,7 +603,7 @@ int PlocSupvHelper::handleAckReception(supv::TcBase& tc, uint8_t serviceId, size
|
||||
ReturnValue_t result = ackReport.parse();
|
||||
if (result != returnvalue::OK) {
|
||||
triggerEvent(ACK_RECEPTION_FAILURE);
|
||||
return returnvalue::FAILED;
|
||||
return -1;
|
||||
}
|
||||
if (ackReport.getRefApid() == tc.getApid() and
|
||||
ackReport.getRefServiceId() == tc.getServiceId()) {
|
||||
@ -631,7 +633,7 @@ int PlocSupvHelper::handleExeAckReception(supv::TcBase& tc, uint8_t serviceId, s
|
||||
ReturnValue_t result = exeReport.parse();
|
||||
if (result != returnvalue::OK) {
|
||||
triggerEvent(EXE_RECEPTION_FAILURE);
|
||||
return returnvalue::FAILED;
|
||||
return -1;
|
||||
}
|
||||
if (exeReport.getRefApid() == tc.getApid() and
|
||||
exeReport.getRefServiceId() == tc.getServiceId()) {
|
||||
@ -729,7 +731,12 @@ ReturnValue_t PlocSupvHelper::handleCheckMemoryCommand() {
|
||||
Countdown countdown(timeout::CRC_EXECUTION_TIMEOUT);
|
||||
bool ackReceived = false;
|
||||
bool checkReplyReceived = false;
|
||||
bool packetWasHandled = false;
|
||||
bool exeReceived = false;
|
||||
while (true) {
|
||||
while (result != NO_PACKET_FOUND) {
|
||||
result = tryHdlcParsing();
|
||||
}
|
||||
if (not decodedQueue.empty()) {
|
||||
size_t packetLen = 0;
|
||||
decodedQueue.retrieve(&packetLen);
|
||||
@ -739,19 +746,23 @@ ReturnValue_t PlocSupvHelper::handleCheckMemoryCommand() {
|
||||
if (result != returnvalue::OK) {
|
||||
continue;
|
||||
}
|
||||
packetWasHandled = false;
|
||||
if (tmReader.getApid() == Apid::TMTC_MAN) {
|
||||
uint8_t serviceId = tmReader.getServiceId();
|
||||
int retval = 0;
|
||||
if (not ackReceived) {
|
||||
retval = handleAckReception(packet, serviceId, packetLen);
|
||||
if (retval == 1) {
|
||||
packetWasHandled = true;
|
||||
ackReceived = true;
|
||||
} else if (retval == -1) {
|
||||
return returnvalue::FAILED;
|
||||
}
|
||||
} else if (checkReplyReceived) {
|
||||
} else {
|
||||
retval = handleExeAckReception(packet, serviceId, packetLen);
|
||||
if (retval == 1) {
|
||||
packetWasHandled = true;
|
||||
exeReceived = true;
|
||||
break;
|
||||
} else if (retval == -1) {
|
||||
return returnvalue::FAILED;
|
||||
@ -764,86 +775,40 @@ ReturnValue_t PlocSupvHelper::handleCheckMemoryCommand() {
|
||||
if (result != returnvalue::OK) {
|
||||
return result;
|
||||
}
|
||||
packetWasHandled = true;
|
||||
checkReplyReceived = true;
|
||||
if (update.crcShouldBeChecked) {
|
||||
result = report.verifyCrc(update.crc);
|
||||
if (result != returnvalue::OK) {
|
||||
if (result == returnvalue::OK) {
|
||||
triggerEvent(SUPV_MEM_CHECK_OK, result);
|
||||
return result;
|
||||
} else {
|
||||
sif::warning
|
||||
|
||||
<< "PlocSupvHelper::handleCheckMemoryCommand: CRC failure. Expected CRC 0x"
|
||||
<< std::setfill('0') << std::hex << std::setw(4)
|
||||
<< static_cast<uint16_t>(update.crc) << " but received CRC 0x" << std::setw(4)
|
||||
<< report.getCrc() << std::dec << std::endl;
|
||||
return result;
|
||||
triggerEvent(SUPV_MEM_CHECK_FAIL, result);
|
||||
}
|
||||
}
|
||||
checkReplyReceived = true;
|
||||
}
|
||||
} else {
|
||||
}
|
||||
if (not packetWasHandled) {
|
||||
pushIpcData(decodedBuf.data(), packetLen);
|
||||
decodedRingBuf.deleteData(packetLen);
|
||||
}
|
||||
} else {
|
||||
TaskFactory::delayTask(50);
|
||||
}
|
||||
if (ackReceived and exeReceived and checkReplyReceived) {
|
||||
break;
|
||||
}
|
||||
if (countdown.hasTimedOut()) {
|
||||
return result::NO_REPLY_TIMEOUT;
|
||||
}
|
||||
}
|
||||
return returnvalue::OK;
|
||||
// result = handleAck();
|
||||
// if (result != returnvalue::OK) {
|
||||
// return result;
|
||||
// }
|
||||
//
|
||||
// bool exeAlreadyHandled = false;
|
||||
// uint32_t timeout = std::max(CRC_EXECUTION_TIMEOUT, supv::timeout::UPDATE_STATUS_REPORT);
|
||||
// result = handleTmReception(ccsds::HEADER_LEN, tmBuf.data(), timeout);
|
||||
// ploc::SpTmReader spReader(tmBuf.data(), tmBuf.size());
|
||||
// if (spReader.getApid() == supv::APID_EXE_FAILURE) {
|
||||
// exeAlreadyHandled = true;
|
||||
// result = handleRemainingExeReport(spReader);
|
||||
// } else if (spReader.getApid() == supv::APID_UPDATE_STATUS_REPORT) {
|
||||
// size_t remBytes = spReader.getPacketDataLen() + 1;
|
||||
// result = handleTmReception(remBytes, tmBuf.data() + ccsds::HEADER_LEN,
|
||||
// supv::timeout::UPDATE_STATUS_REPORT);
|
||||
// if (result != returnvalue::OK) {
|
||||
// sif::warning
|
||||
// << "PlocSupvHelper::handleCheckMemoryCommand: Failed to receive update status report"
|
||||
// << std::endl;
|
||||
// return result;
|
||||
// }
|
||||
// result = updateStatusReport.checkCrc();
|
||||
// if (result != returnvalue::OK) {
|
||||
// sif::warning << "PlocSupvHelper::handleCheckMemoryCommand: CRC check failed" << std::endl;
|
||||
// return result;
|
||||
// }
|
||||
// // Copy into other buffer because data will be overwritten when reading execution report
|
||||
// std::memcpy(statusReportBuf.data(), tmBuf.data(), updateStatusReport.getNominalSize());
|
||||
// }
|
||||
//
|
||||
// if (not exeAlreadyHandled) {
|
||||
// result = handleExe(CRC_EXECUTION_TIMEOUT);
|
||||
// if (result != returnvalue::OK) {
|
||||
// return result;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// // Now process the status report
|
||||
// updateStatusReport.setData(statusReportBuf.data(), statusReportBuf.size());
|
||||
// result = updateStatusReport.parseDataField();
|
||||
// if (result != returnvalue::OK) {
|
||||
// return result;
|
||||
// }
|
||||
// if (update.crcShouldBeChecked) {
|
||||
// result = updateStatusReport.verifycrc(update.crc);
|
||||
// if (result != returnvalue::OK) {
|
||||
// sif::warning << "PlocSupvHelper::handleCheckMemoryCommand: CRC failure. Expected CRC 0x"
|
||||
// << std::setfill('0') << std::hex << std::setw(4)
|
||||
// << static_cast<uint16_t>(update.crc) << " but received CRC 0x" <<
|
||||
// std::setw(4)
|
||||
// << updateStatusReport.getCrc() << std::dec << std::endl;
|
||||
// return result;
|
||||
// }
|
||||
// }
|
||||
return result;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user