new command to only perform mem check
All checks were successful
EIVE/eive-obsw/pipeline/pr-develop This commit looks good
All checks were successful
EIVE/eive-obsw/pipeline/pr-develop This commit looks good
This commit is contained in:
@ -57,6 +57,13 @@ ReturnValue_t PlocSupvHelper::performOperation(uint8_t operationCode) {
|
||||
internalState = InternalState::IDLE;
|
||||
break;
|
||||
}
|
||||
case InternalState::CHECK_MEMORY: {
|
||||
sif::info << "PlocSupvHelper::performUpdate: Memory Check" << std::endl;
|
||||
result = handleCheckMemoryCommand();
|
||||
triggerEvent(SUPV_MEM_CHECK_STATUS, result);
|
||||
internalState = InternalState::IDLE;
|
||||
break;
|
||||
}
|
||||
case InternalState::CONTINUE_UPDATE: {
|
||||
result = continueUpdate();
|
||||
if (result == RETURN_OK) {
|
||||
@ -143,6 +150,17 @@ ReturnValue_t PlocSupvHelper::performUpdate(std::string file, uint8_t memoryId,
|
||||
return result;
|
||||
}
|
||||
|
||||
ReturnValue_t PlocSupvHelper::performMemCheck(uint8_t memoryId, uint32_t startAddress,
|
||||
size_t sizeToCheck) {
|
||||
update.memoryId = memoryId;
|
||||
update.startAddress = startAddress;
|
||||
update.length = sizeToCheck;
|
||||
internalState = InternalState::CHECK_MEMORY;
|
||||
uartComIF->flushUartTxAndRxBuf(comCookie);
|
||||
semaphore.release();
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
||||
void PlocSupvHelper::initiateUpdateContinuation() {
|
||||
internalState = InternalState::CONTINUE_UPDATE;
|
||||
semaphore.release();
|
||||
@ -260,19 +278,22 @@ ReturnValue_t PlocSupvHelper::writeUpdatePackets() {
|
||||
update.progressPercent = progPercent;
|
||||
if (progPercent % 5 == 0) {
|
||||
// Useful to allow restarting the update
|
||||
triggerEvent(SUPV_UPDATE_PROGRESS, update.bytesWritten, update.sequenceCount);
|
||||
triggerEvent(SUPV_UPDATE_PROGRESS, buildProgParams1(progPercent, update.sequenceCount),
|
||||
update.bytesWritten);
|
||||
}
|
||||
}
|
||||
supv::WriteMemory packet(spParams);
|
||||
result = packet.buildPacket(seqFlags, update.sequenceCount, update.memoryId,
|
||||
update.startAddress + update.bytesWritten, dataLength, tempData);
|
||||
if (result != RETURN_OK) {
|
||||
triggerEvent(WRITE_MEMORY_FAILED, update.bytesWritten, update.sequenceCount);
|
||||
triggerEvent(WRITE_MEMORY_FAILED, buildProgParams1(progPercent, update.sequenceCount),
|
||||
update.bytesWritten);
|
||||
return result;
|
||||
}
|
||||
result = handlePacketTransmission(packet);
|
||||
if (result != RETURN_OK) {
|
||||
triggerEvent(WRITE_MEMORY_FAILED, update.bytesWritten, update.sequenceCount);
|
||||
triggerEvent(WRITE_MEMORY_FAILED, buildProgParams1(progPercent, update.sequenceCount),
|
||||
update.bytesWritten);
|
||||
return result;
|
||||
}
|
||||
update.sequenceCount++;
|
||||
@ -286,6 +307,10 @@ ReturnValue_t PlocSupvHelper::writeUpdatePackets() {
|
||||
return result;
|
||||
}
|
||||
|
||||
uint32_t PlocSupvHelper::buildProgParams1(uint8_t percent, uint16_t seqCount) {
|
||||
return (static_cast<uint32_t>(percent) << 24) | static_cast<uint32_t>(seqCount);
|
||||
}
|
||||
|
||||
ReturnValue_t PlocSupvHelper::performEventBufferRequest() {
|
||||
using namespace supv;
|
||||
ReturnValue_t result = RETURN_OK;
|
||||
@ -352,7 +377,7 @@ ReturnValue_t PlocSupvHelper::eraseMemory() {
|
||||
if (result != RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
result = handlePacketTransmission(eraseMemory, supv::recv_timeout::ERASE_MEMORY);
|
||||
result = handlePacketTransmission(eraseMemory, supv::recv_timeout::ERASE_MEMORY_TIMEOUT);
|
||||
if (result != RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
@ -419,7 +444,7 @@ ReturnValue_t PlocSupvHelper::handleAck() {
|
||||
ReturnValue_t PlocSupvHelper::handleExe(uint32_t timeout) {
|
||||
ReturnValue_t result = RETURN_OK;
|
||||
|
||||
result = handleTmReception(supv::SIZE_EXE_REPORT, timeout);
|
||||
result = handleTmReception(supv::SIZE_EXE_REPORT, tmBuf.data(), timeout);
|
||||
if (result != RETURN_OK) {
|
||||
triggerEvent(EXE_RECEPTION_FAILURE, result, static_cast<uint32_t>(rememberApid));
|
||||
sif::warning << "PlocSupvHelper::handleExe: Error in reception of execution report"
|
||||
@ -443,13 +468,17 @@ ReturnValue_t PlocSupvHelper::handleExe(uint32_t timeout) {
|
||||
return RETURN_OK;
|
||||
}
|
||||
|
||||
ReturnValue_t PlocSupvHelper::handleTmReception(size_t remainingBytes, uint32_t timeout) {
|
||||
ReturnValue_t PlocSupvHelper::handleTmReception(size_t remainingBytes, uint8_t* readBuf,
|
||||
uint32_t timeout) {
|
||||
ReturnValue_t result = RETURN_OK;
|
||||
size_t readBytes = 0;
|
||||
size_t currentBytes = 0;
|
||||
Countdown countdown(timeout);
|
||||
if (readBuf == nullptr) {
|
||||
readBuf = tmBuf.data();
|
||||
}
|
||||
while (!countdown.hasTimedOut()) {
|
||||
result = receive(tmBuf.data() + readBytes, ¤tBytes, remainingBytes);
|
||||
result = receive(readBuf + readBytes, ¤tBytes, remainingBytes);
|
||||
if (result != RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
@ -461,7 +490,7 @@ ReturnValue_t PlocSupvHelper::handleTmReception(size_t remainingBytes, uint32_t
|
||||
}
|
||||
if (remainingBytes != 0) {
|
||||
sif::warning << "PlocSupvHelper::handleTmReception: Failed to read " << std::dec
|
||||
<< remainingBytes << " bytes" << std::endl;
|
||||
<< remainingBytes << " remaining bytes" << std::endl;
|
||||
return RETURN_FAILED;
|
||||
}
|
||||
return result;
|
||||
@ -549,6 +578,9 @@ ReturnValue_t PlocSupvHelper::calcImageCrc() {
|
||||
ReturnValue_t PlocSupvHelper::handleCheckMemoryCommand() {
|
||||
ReturnValue_t result = RETURN_OK;
|
||||
resetSpParams();
|
||||
// Will hold status report for later processing
|
||||
std::array<uint8_t, 32> statusReportBuf{};
|
||||
supv::UpdateStatusReport updateStatusReport(statusReportBuf.data(), statusReportBuf.size());
|
||||
// Verification of update write procedure
|
||||
supv::CheckMemory packet(spParams);
|
||||
result = packet.buildPacket(update.memoryId, update.startAddress, update.length);
|
||||
@ -564,42 +596,35 @@ ReturnValue_t PlocSupvHelper::handleCheckMemoryCommand() {
|
||||
return result;
|
||||
}
|
||||
|
||||
// Will hold status report for later processing
|
||||
std::array<uint8_t, 32> statusReportBuf{};
|
||||
{
|
||||
supv::UpdateStatusReport updateStatusReport(tmBuf.data(), tmBuf.size());
|
||||
result = handleTmReception(static_cast<size_t>(updateStatusReport.getNominalSize()),
|
||||
supv::recv_timeout::UPDATE_STATUS_REPORT);
|
||||
if (result != RETURN_OK) {
|
||||
sif::warning
|
||||
<< "PlocSupvHelper::handleCheckMemoryCommand: Failed to receive update status report"
|
||||
<< std::endl;
|
||||
return result;
|
||||
}
|
||||
result = updateStatusReport.checkCrc();
|
||||
if (result != RETURN_OK) {
|
||||
sif::warning << "PlocSupvHelper::handleTmReception: CRC check failed" << std::endl;
|
||||
return result;
|
||||
}
|
||||
// We need to copy this into another buffer. Otherwise, it will be overwritten
|
||||
// when reading the execution report.
|
||||
std::memcpy(statusReportBuf.data(), tmBuf.data(), updateStatusReport.getNominalSize());
|
||||
result =
|
||||
handleTmReception(static_cast<size_t>(updateStatusReport.getNominalSize()),
|
||||
statusReportBuf.data(), supv::recv_timeout::UPDATE_STATUS_REPORT_TIMEOUT);
|
||||
if (result != RETURN_OK) {
|
||||
sif::warning
|
||||
<< "PlocSupvHelper::handleCheckMemoryCommand: Failed to receive update status report"
|
||||
<< std::endl;
|
||||
return result;
|
||||
}
|
||||
result = updateStatusReport.checkCrc();
|
||||
if (result != RETURN_OK) {
|
||||
sif::warning << "PlocSupvHelper::handleTmReception: CRC check failed" << std::endl;
|
||||
return result;
|
||||
}
|
||||
|
||||
result = handleExe(CRC_EXECUTION_TIMEOUT);
|
||||
if (result != RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
|
||||
// Now process the status report
|
||||
supv::UpdateStatusReport statusReportCopy(statusReportBuf.data(), statusReportBuf.size());
|
||||
result = statusReportCopy.parseDataField();
|
||||
result = updateStatusReport.parseDataField();
|
||||
if (result != RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
result = statusReportCopy.verifycrc(update.crc);
|
||||
result = updateStatusReport.verifycrc(update.crc);
|
||||
if (result != RETURN_OK) {
|
||||
sif::warning << "PlocSupvHelper::handleCheckMemoryCommand: CRC failure. Expected CRC 0x"
|
||||
<< std::hex << update.crc << " but received CRC 0x" << statusReportCopy.getCrc()
|
||||
<< std::hex << update.crc << " but received CRC 0x" << updateStatusReport.getCrc()
|
||||
<< std::endl;
|
||||
return result;
|
||||
}
|
||||
|
Reference in New Issue
Block a user