v1.14.0 #304

Merged
muellerr merged 366 commits from develop into main 2022-10-10 17:46:38 +02:00
3 changed files with 26 additions and 15 deletions
Showing only changes of commit 1aeebcc0ee - Show all commits

View File

@ -135,7 +135,13 @@ ReturnValue_t PlocSupvHelper::performUpdate(std::string file, uint8_t memoryId,
}
#endif
update.file = file;
update.length = getFileSize(update.file);
update.fullFileSize = getFileSize(update.file);
if (startBytesWritten > update.fullFileSize) {
sif::warning << "Invalid start bytes counter " << startBytesWritten
<< ", smaller than full file length" << update.fullFileSize << std::endl;
return HasReturnvaluesIF::RETURN_FAILED;
}
update.length = update.fullFileSize - startBytesWritten;
update.memoryId = memoryId;
update.startAddress = startAddress;
update.progressPercent = 0;
@ -152,6 +158,7 @@ ReturnValue_t PlocSupvHelper::performUpdate(std::string file, uint8_t memoryId,
ReturnValue_t PlocSupvHelper::performMemCheck(std::string file, uint8_t memoryId,
uint32_t startAddress) {
update.file = file;
update.fullFileSize = getFileSize(file);
return performMemCheck(memoryId, startAddress, getFileSize(update.file), true);
}
@ -268,20 +275,20 @@ ReturnValue_t PlocSupvHelper::updateOperation() {
ReturnValue_t PlocSupvHelper::writeUpdatePackets() {
ReturnValue_t result = RETURN_OK;
#if OBSW_DEBUG_PLOC_SUPERVISOR == 1
ProgressPrinter progressPrinter("Supervisor update", update.length,
ProgressPrinter progressPrinter("Supervisor update", update.fullFileSize,
ProgressPrinter::HALF_PERCENT);
#endif /* OBSW_DEBUG_PLOC_SUPERVISOR == 1 */
uint8_t tempData[supv::WriteMemory::CHUNK_MAX + 1]{};
std::ifstream file(update.file, std::ifstream::binary);
uint16_t dataLength = 0;
ccsds::SequenceFlags seqFlags;
while (update.bytesWritten < update.length) {
while (update.bytesWritten < update.fullFileSize) {
if (terminate) {
terminate = false;
triggerEvent(TERMINATED_UPDATE_PROCEDURE);
return PROCESS_TERMINATED;
}
size_t remainingSize = update.length - update.bytesWritten;
size_t remainingSize = update.fullFileSize - update.bytesWritten;
bool lastSegment = false;
if (remainingSize > supv::WriteMemory::CHUNK_MAX) {
dataLength = supv::WriteMemory::CHUNK_MAX;
@ -309,7 +316,7 @@ ReturnValue_t PlocSupvHelper::writeUpdatePackets() {
seqFlags = ccsds::SequenceFlags::CONTINUATION;
}
resetSpParams();
float progress = static_cast<float>(update.bytesWritten) / update.length;
float progress = static_cast<float>(update.bytesWritten) / update.fullFileSize;
uint8_t progPercent = std::floor(progress * 100);
if (progPercent > update.progressPercent) {
update.progressPercent = progPercent;
@ -410,7 +417,8 @@ ReturnValue_t PlocSupvHelper::eraseMemory() {
ReturnValue_t result = RETURN_OK;
resetSpParams();
supv::EraseMemory eraseMemory(spParams);
result = eraseMemory.buildPacket(update.memoryId, update.startAddress, update.length);
result = eraseMemory.buildPacket(update.memoryId, update.startAddress + update.bytesWritten,
update.length);
if (result != RETURN_OK) {
return result;
}
@ -579,7 +587,7 @@ ReturnValue_t PlocSupvHelper::receive(uint8_t* data, size_t* readBytes, size_t r
ReturnValue_t PlocSupvHelper::calcImageCrc() {
ReturnValue_t result = RETURN_OK;
if (update.length == 0) {
if (update.fullFileSize == 0) {
return HasReturnvaluesIF::RETURN_FAILED;
}
#ifdef XIPHOS_Q7S
@ -593,17 +601,19 @@ ReturnValue_t PlocSupvHelper::calcImageCrc() {
auto crc16Calcer = etl::crc16_ccitt();
std::ifstream file(update.file, std::ifstream::binary);
std::array<uint8_t, 1025> crcBuf;
std::array<uint8_t, 1025> crcBuf{};
#if OBSW_DEBUG_PLOC_SUPERVISOR == 1
ProgressPrinter progress("Supervisor update crc calculation", update.length,
ProgressPrinter progress("Supervisor update crc calculation", update.fullFileSize,
ProgressPrinter::ONE_PERCENT);
#endif /* OBSW_DEBUG_PLOC_SUPERVISOR == 1 */
uint32_t byteCount = 0;
while (byteCount < update.length) {
size_t bytesToRead = 1024;
size_t remLen = update.length - byteCount;
while (byteCount < update.fullFileSize) {
size_t remLen = update.fullFileSize - byteCount;
if (remLen < 1024) {
bytesToRead = remLen;
} else {
bytesToRead = 1024;
}
file.seekg(byteCount, file.beg);
file.read(reinterpret_cast<char*>(crcBuf.data()), bytesToRead);
@ -617,7 +627,6 @@ ReturnValue_t PlocSupvHelper::calcImageCrc() {
#if OBSW_DEBUG_PLOC_SUPERVISOR == 1
progress.print(byteCount);
#endif /* OBSW_DEBUG_PLOC_SUPERVISOR == 1 */
file.close();
update.crc = crc16Calcer.value();
return result;
}
@ -630,7 +639,7 @@ ReturnValue_t PlocSupvHelper::handleCheckMemoryCommand() {
supv::UpdateStatusReport updateStatusReport(tmBuf.data(), tmBuf.size());
// Verification of update write procedure
supv::CheckMemory packet(spParams);
result = packet.buildPacket(update.memoryId, update.startAddress, update.length);
result = packet.buildPacket(update.memoryId, update.startAddress, update.fullFileSize);
if (result != RETURN_OK) {
return result;
}

View File

@ -167,6 +167,8 @@ class PlocSupvHelper : public SystemObject, public ExecutableObjectIF, public Ha
uint32_t startAddress;
// Absolute name of file containing update data
std::string file;
// Length of full file
size_t fullFileSize;
// Size of update
uint32_t length;
uint32_t crc;

2
tmtc

@ -1 +1 @@
Subproject commit 613759562ed855f692936bad5b25e8e2570dca52
Subproject commit aec55035d7602226a2e61845565c94b5ed8f561c