This commit is contained in:
@ -140,7 +140,6 @@ ReturnValue_t PlocMpsocSpecialComHelper::performFlashWrite() {
|
||||
size_t bytesRead = 0;
|
||||
while (remainingSize > 0) {
|
||||
if (terminate) {
|
||||
flashfclose();
|
||||
return returnvalue::OK;
|
||||
}
|
||||
if (remainingSize > mpsoc::SP_MAX_DATA_SIZE) {
|
||||
@ -149,7 +148,6 @@ ReturnValue_t PlocMpsocSpecialComHelper::performFlashWrite() {
|
||||
dataLength = remainingSize;
|
||||
}
|
||||
if (file.bad() or not file.is_open()) {
|
||||
flashfclose();
|
||||
return FILE_WRITE_ERROR;
|
||||
}
|
||||
file.seekg(bytesRead, file.beg);
|
||||
@ -159,18 +157,15 @@ ReturnValue_t PlocMpsocSpecialComHelper::performFlashWrite() {
|
||||
mpsoc::TcFlashWrite tc(spParams, *sequenceCount);
|
||||
result = tc.setPayload(fileBuf.data(), dataLength);
|
||||
if (result != returnvalue::OK) {
|
||||
flashfclose();
|
||||
return result;
|
||||
}
|
||||
result = tc.finishPacket();
|
||||
if (result != returnvalue::OK) {
|
||||
flashfclose();
|
||||
return result;
|
||||
}
|
||||
(*sequenceCount)++;
|
||||
result = handlePacketTransmissionNoReply(tc);
|
||||
if (result != returnvalue::OK) {
|
||||
flashfclose();
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@ -198,8 +193,6 @@ ReturnValue_t PlocMpsocSpecialComHelper::performFlashRead() {
|
||||
while (readSoFar < flashReadAndWrite.totalReadSize) {
|
||||
if (terminate) {
|
||||
std::filesystem::remove(flashReadAndWrite.obcFile, e);
|
||||
// TODO: Might not be needed
|
||||
// flashfclose();
|
||||
return returnvalue::OK;
|
||||
}
|
||||
nextReadSize = mpsoc::MAX_FLASH_READ_DATA_SIZE;
|
||||
@ -209,35 +202,31 @@ ReturnValue_t PlocMpsocSpecialComHelper::performFlashRead() {
|
||||
sif::debug << "reading " << nextReadSize << " bytes from offset " << readSoFar << std::endl;
|
||||
if (ofile.bad() or not ofile.is_open()) {
|
||||
std::filesystem::remove(flashReadAndWrite.obcFile, e);
|
||||
// TODO: Might not be needed
|
||||
// flashfclose();
|
||||
return FILE_READ_ERROR;
|
||||
}
|
||||
mpsoc::TcFlashRead flashReadRequest(spParams, *sequenceCount);
|
||||
result = flashReadRequest.setPayload(nextReadSize);
|
||||
if (result != returnvalue::OK) {
|
||||
std::filesystem::remove(flashReadAndWrite.obcFile, e);
|
||||
// TODO: Might not be needed
|
||||
// flashfclose();
|
||||
return result;
|
||||
}
|
||||
result = flashReadRequest.finishPacket();
|
||||
if (result != returnvalue::OK) {
|
||||
std::filesystem::remove(flashReadAndWrite.obcFile, e);
|
||||
// TODO: Might not be needed
|
||||
// flashfclose();
|
||||
return result;
|
||||
}
|
||||
(*sequenceCount)++;
|
||||
result = handlePacketTransmissionFlashRead(flashReadRequest, ofile, nextReadSize);
|
||||
if (result != returnvalue::OK) {
|
||||
std::filesystem::remove(flashReadAndWrite.obcFile, e);
|
||||
// TODO: Might not be needed
|
||||
// flashfclose();
|
||||
return result;
|
||||
}
|
||||
readSoFar += nextReadSize;
|
||||
}
|
||||
result = flashfclose();
|
||||
if (result != returnvalue::OK) {
|
||||
return result;
|
||||
}
|
||||
sif::debug << "read file done" << std::endl;
|
||||
return result;
|
||||
}
|
||||
@ -299,10 +288,6 @@ ReturnValue_t PlocMpsocSpecialComHelper::handlePacketTransmissionFlashRead(mpsoc
|
||||
if (result != returnvalue::OK) {
|
||||
return result;
|
||||
}
|
||||
result = handleTmReception();
|
||||
if (result != returnvalue::OK) {
|
||||
return result;
|
||||
}
|
||||
return handleExe();
|
||||
} else if (spReader.getApid() == mpsoc::apid::EXE_FAILURE) {
|
||||
handleExeFailure();
|
||||
@ -346,14 +331,13 @@ ReturnValue_t PlocMpsocSpecialComHelper::handleAck() {
|
||||
if (result != returnvalue::OK) {
|
||||
return result;
|
||||
}
|
||||
SpTmReader tmPacket(tmBuf.data(), tmBuf.size());
|
||||
result = checkReceivedTm();
|
||||
if (result != returnvalue::OK) {
|
||||
return result;
|
||||
}
|
||||
uint16_t apid = tmPacket.getApid();
|
||||
uint16_t apid = spReader.getApid();
|
||||
if (apid != mpsoc::apid::ACK_SUCCESS) {
|
||||
handleAckApidFailure(tmPacket);
|
||||
handleAckApidFailure(spReader);
|
||||
return returnvalue::FAILED;
|
||||
}
|
||||
return returnvalue::OK;
|
||||
@ -464,14 +448,15 @@ ReturnValue_t PlocMpsocSpecialComHelper::handleFlashReadReply(std::ofstream& ofi
|
||||
const uint8_t* packetData = spReader.getPacketData();
|
||||
size_t deserDummy = spReader.getPacketDataLen() - mpsoc::CRC_SIZE;
|
||||
uint32_t receivedReadLen = 0;
|
||||
std::string receivedShortName = std::string(reinterpret_cast<const char*>(packetData), 12);
|
||||
if (receivedShortName != flashReadAndWrite.mpsocFile.substr(0, 12)) {
|
||||
sif::warning << "PLOC MPSoC Flash Read: Missmatch between request file name and "
|
||||
"received file name"
|
||||
<< std::endl;
|
||||
triggerEvent(MPSOC_FLASH_READ_PACKET_ERROR, FlashReadErrorType::FLASH_READ_FILENAME_ERROR);
|
||||
return returnvalue::FAILED;
|
||||
}
|
||||
// I think this is buggy..
|
||||
// std::string receivedShortName = std::string(reinterpret_cast<const char*>(packetData), 12);
|
||||
// if (receivedShortName != flashReadAndWrite.mpsocFile.substr(0, 11)) {
|
||||
// sif::warning << "PLOC MPSoC Flash Read: Missmatch between request file name and "
|
||||
// "received file name"
|
||||
// << std::endl;
|
||||
// triggerEvent(MPSOC_FLASH_READ_PACKET_ERROR, FlashReadErrorType::FLASH_READ_FILENAME_ERROR);
|
||||
// return returnvalue::FAILED;
|
||||
// }
|
||||
packetData += 12;
|
||||
result = SerializeAdapter::deSerialize(&receivedReadLen, &packetData, &deserDummy,
|
||||
SerializeIF::Endianness::NETWORK);
|
||||
|
Reference in New Issue
Block a user