v1.14.0 #304
@ -135,7 +135,13 @@ ReturnValue_t PlocSupvHelper::performUpdate(std::string file, uint8_t memoryId,
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
update.file = file;
|
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.memoryId = memoryId;
|
||||||
update.startAddress = startAddress;
|
update.startAddress = startAddress;
|
||||||
update.progressPercent = 0;
|
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,
|
ReturnValue_t PlocSupvHelper::performMemCheck(std::string file, uint8_t memoryId,
|
||||||
uint32_t startAddress) {
|
uint32_t startAddress) {
|
||||||
update.file = file;
|
update.file = file;
|
||||||
|
update.fullFileSize = getFileSize(file);
|
||||||
return performMemCheck(memoryId, startAddress, getFileSize(update.file), true);
|
return performMemCheck(memoryId, startAddress, getFileSize(update.file), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -268,20 +275,20 @@ ReturnValue_t PlocSupvHelper::updateOperation() {
|
|||||||
ReturnValue_t PlocSupvHelper::writeUpdatePackets() {
|
ReturnValue_t PlocSupvHelper::writeUpdatePackets() {
|
||||||
ReturnValue_t result = RETURN_OK;
|
ReturnValue_t result = RETURN_OK;
|
||||||
#if OBSW_DEBUG_PLOC_SUPERVISOR == 1
|
#if OBSW_DEBUG_PLOC_SUPERVISOR == 1
|
||||||
ProgressPrinter progressPrinter("Supervisor update", update.length,
|
ProgressPrinter progressPrinter("Supervisor update", update.fullFileSize,
|
||||||
ProgressPrinter::HALF_PERCENT);
|
ProgressPrinter::HALF_PERCENT);
|
||||||
#endif /* OBSW_DEBUG_PLOC_SUPERVISOR == 1 */
|
#endif /* OBSW_DEBUG_PLOC_SUPERVISOR == 1 */
|
||||||
uint8_t tempData[supv::WriteMemory::CHUNK_MAX + 1]{};
|
uint8_t tempData[supv::WriteMemory::CHUNK_MAX + 1]{};
|
||||||
std::ifstream file(update.file, std::ifstream::binary);
|
std::ifstream file(update.file, std::ifstream::binary);
|
||||||
uint16_t dataLength = 0;
|
uint16_t dataLength = 0;
|
||||||
ccsds::SequenceFlags seqFlags;
|
ccsds::SequenceFlags seqFlags;
|
||||||
while (update.bytesWritten < update.length) {
|
while (update.bytesWritten < update.fullFileSize) {
|
||||||
if (terminate) {
|
if (terminate) {
|
||||||
terminate = false;
|
terminate = false;
|
||||||
triggerEvent(TERMINATED_UPDATE_PROCEDURE);
|
triggerEvent(TERMINATED_UPDATE_PROCEDURE);
|
||||||
return PROCESS_TERMINATED;
|
return PROCESS_TERMINATED;
|
||||||
}
|
}
|
||||||
size_t remainingSize = update.length - update.bytesWritten;
|
size_t remainingSize = update.fullFileSize - update.bytesWritten;
|
||||||
bool lastSegment = false;
|
bool lastSegment = false;
|
||||||
if (remainingSize > supv::WriteMemory::CHUNK_MAX) {
|
if (remainingSize > supv::WriteMemory::CHUNK_MAX) {
|
||||||
dataLength = supv::WriteMemory::CHUNK_MAX;
|
dataLength = supv::WriteMemory::CHUNK_MAX;
|
||||||
@ -309,7 +316,7 @@ ReturnValue_t PlocSupvHelper::writeUpdatePackets() {
|
|||||||
seqFlags = ccsds::SequenceFlags::CONTINUATION;
|
seqFlags = ccsds::SequenceFlags::CONTINUATION;
|
||||||
}
|
}
|
||||||
resetSpParams();
|
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);
|
uint8_t progPercent = std::floor(progress * 100);
|
||||||
if (progPercent > update.progressPercent) {
|
if (progPercent > update.progressPercent) {
|
||||||
update.progressPercent = progPercent;
|
update.progressPercent = progPercent;
|
||||||
@ -410,7 +417,8 @@ ReturnValue_t PlocSupvHelper::eraseMemory() {
|
|||||||
ReturnValue_t result = RETURN_OK;
|
ReturnValue_t result = RETURN_OK;
|
||||||
resetSpParams();
|
resetSpParams();
|
||||||
supv::EraseMemory eraseMemory(spParams);
|
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) {
|
if (result != RETURN_OK) {
|
||||||
return result;
|
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 PlocSupvHelper::calcImageCrc() {
|
||||||
ReturnValue_t result = RETURN_OK;
|
ReturnValue_t result = RETURN_OK;
|
||||||
if (update.length == 0) {
|
if (update.fullFileSize == 0) {
|
||||||
return HasReturnvaluesIF::RETURN_FAILED;
|
return HasReturnvaluesIF::RETURN_FAILED;
|
||||||
}
|
}
|
||||||
#ifdef XIPHOS_Q7S
|
#ifdef XIPHOS_Q7S
|
||||||
@ -593,17 +601,19 @@ ReturnValue_t PlocSupvHelper::calcImageCrc() {
|
|||||||
|
|
||||||
auto crc16Calcer = etl::crc16_ccitt();
|
auto crc16Calcer = etl::crc16_ccitt();
|
||||||
std::ifstream file(update.file, std::ifstream::binary);
|
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
|
#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);
|
ProgressPrinter::ONE_PERCENT);
|
||||||
#endif /* OBSW_DEBUG_PLOC_SUPERVISOR == 1 */
|
#endif /* OBSW_DEBUG_PLOC_SUPERVISOR == 1 */
|
||||||
uint32_t byteCount = 0;
|
uint32_t byteCount = 0;
|
||||||
while (byteCount < update.length) {
|
|
||||||
size_t bytesToRead = 1024;
|
size_t bytesToRead = 1024;
|
||||||
size_t remLen = update.length - byteCount;
|
while (byteCount < update.fullFileSize) {
|
||||||
|
size_t remLen = update.fullFileSize - byteCount;
|
||||||
if (remLen < 1024) {
|
if (remLen < 1024) {
|
||||||
bytesToRead = remLen;
|
bytesToRead = remLen;
|
||||||
|
} else {
|
||||||
|
bytesToRead = 1024;
|
||||||
}
|
}
|
||||||
file.seekg(byteCount, file.beg);
|
file.seekg(byteCount, file.beg);
|
||||||
file.read(reinterpret_cast<char*>(crcBuf.data()), bytesToRead);
|
file.read(reinterpret_cast<char*>(crcBuf.data()), bytesToRead);
|
||||||
@ -617,7 +627,6 @@ ReturnValue_t PlocSupvHelper::calcImageCrc() {
|
|||||||
#if OBSW_DEBUG_PLOC_SUPERVISOR == 1
|
#if OBSW_DEBUG_PLOC_SUPERVISOR == 1
|
||||||
progress.print(byteCount);
|
progress.print(byteCount);
|
||||||
#endif /* OBSW_DEBUG_PLOC_SUPERVISOR == 1 */
|
#endif /* OBSW_DEBUG_PLOC_SUPERVISOR == 1 */
|
||||||
file.close();
|
|
||||||
update.crc = crc16Calcer.value();
|
update.crc = crc16Calcer.value();
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@ -630,7 +639,7 @@ ReturnValue_t PlocSupvHelper::handleCheckMemoryCommand() {
|
|||||||
supv::UpdateStatusReport updateStatusReport(tmBuf.data(), tmBuf.size());
|
supv::UpdateStatusReport updateStatusReport(tmBuf.data(), tmBuf.size());
|
||||||
// Verification of update write procedure
|
// Verification of update write procedure
|
||||||
supv::CheckMemory packet(spParams);
|
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) {
|
if (result != RETURN_OK) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -167,6 +167,8 @@ class PlocSupvHelper : public SystemObject, public ExecutableObjectIF, public Ha
|
|||||||
uint32_t startAddress;
|
uint32_t startAddress;
|
||||||
// Absolute name of file containing update data
|
// Absolute name of file containing update data
|
||||||
std::string file;
|
std::string file;
|
||||||
|
// Length of full file
|
||||||
|
size_t fullFileSize;
|
||||||
// Size of update
|
// Size of update
|
||||||
uint32_t length;
|
uint32_t length;
|
||||||
uint32_t crc;
|
uint32_t crc;
|
||||||
|
2
tmtc
2
tmtc
@ -1 +1 @@
|
|||||||
Subproject commit 613759562ed855f692936bad5b25e8e2570dca52
|
Subproject commit aec55035d7602226a2e61845565c94b5ed8f561c
|
Loading…
Reference in New Issue
Block a user