start adding flash read
This commit is contained in:
parent
fa13703394
commit
0a109e552d
@ -207,7 +207,6 @@ void PlocMPSoCHandler::doShutDown() {
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
ReturnValue_t PlocMPSoCHandler::buildNormalDeviceCommand(DeviceCommandId_t* id) {
|
ReturnValue_t PlocMPSoCHandler::buildNormalDeviceCommand(DeviceCommandId_t* id) {
|
||||||
*id = mpsoc::TC_GET_HK_REPORT;
|
*id = mpsoc::TC_GET_HK_REPORT;
|
||||||
return buildCommandFromCommand(*id, nullptr, 0);
|
return buildCommandFromCommand(*id, nullptr, 0);
|
||||||
|
@ -93,8 +93,8 @@ ReturnValue_t PlocMPSoCHelper::startFlashWrite(std::string obcFile, std::string
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
flashWrite.obcFile = obcFile;
|
flashReadAndWrite.obcFile = obcFile;
|
||||||
flashWrite.mpsocFile = mpsocFile;
|
flashReadAndWrite.mpsocFile = mpsocFile;
|
||||||
internalState = InternalState::FLASH_WRITE;
|
internalState = InternalState::FLASH_WRITE;
|
||||||
result = resetHelper();
|
result = resetHelper();
|
||||||
if (result != returnvalue::OK) {
|
if (result != returnvalue::OK) {
|
||||||
@ -116,12 +116,14 @@ void PlocMPSoCHelper::stopProcess() { terminate = true; }
|
|||||||
|
|
||||||
ReturnValue_t PlocMPSoCHelper::performFlashWrite() {
|
ReturnValue_t PlocMPSoCHelper::performFlashWrite() {
|
||||||
ReturnValue_t result = returnvalue::OK;
|
ReturnValue_t result = returnvalue::OK;
|
||||||
|
std::ifstream file(flashReadAndWrite.obcFile, std::ifstream::binary);
|
||||||
|
if (file.bad()) {
|
||||||
|
return returnvalue::FAILED;
|
||||||
|
}
|
||||||
result = flashfopen();
|
result = flashfopen();
|
||||||
if (result != returnvalue::OK) {
|
if (result != returnvalue::OK) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
uint8_t tempData[mpsoc::MAX_DATA_SIZE];
|
|
||||||
std::ifstream file(flashWrite.obcFile, std::ifstream::binary);
|
|
||||||
// Set position of next character to end of file input stream
|
// Set position of next character to end of file input stream
|
||||||
file.seekg(0, file.end);
|
file.seekg(0, file.end);
|
||||||
// tellg returns position of character in input stream
|
// tellg returns position of character in input stream
|
||||||
@ -139,7 +141,7 @@ ReturnValue_t PlocMPSoCHelper::performFlashWrite() {
|
|||||||
}
|
}
|
||||||
if (file.is_open()) {
|
if (file.is_open()) {
|
||||||
file.seekg(bytesRead, file.beg);
|
file.seekg(bytesRead, file.beg);
|
||||||
file.read(reinterpret_cast<char*>(tempData), dataLength);
|
file.read(reinterpret_cast<char*>(fileBuf.data()), dataLength);
|
||||||
bytesRead += dataLength;
|
bytesRead += dataLength;
|
||||||
remainingSize -= dataLength;
|
remainingSize -= dataLength;
|
||||||
} else {
|
} else {
|
||||||
@ -147,7 +149,7 @@ ReturnValue_t PlocMPSoCHelper::performFlashWrite() {
|
|||||||
}
|
}
|
||||||
(*sequenceCount)++;
|
(*sequenceCount)++;
|
||||||
mpsoc::TcFlashWrite tc(spParams, *sequenceCount);
|
mpsoc::TcFlashWrite tc(spParams, *sequenceCount);
|
||||||
result = tc.buildPacket(tempData, dataLength);
|
result = tc.buildPacket(fileBuf.data(), dataLength);
|
||||||
if (result != returnvalue::OK) {
|
if (result != returnvalue::OK) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@ -163,12 +165,24 @@ ReturnValue_t PlocMPSoCHelper::performFlashWrite() {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ReturnValue_t PlocMPSoCHelper::performFlashRead() {
|
||||||
|
std::ofstream ofile(flashReadAndWrite.obcFile);
|
||||||
|
if (ofile.bad()) {
|
||||||
|
return returnvalue::FAILED;
|
||||||
|
}
|
||||||
|
ReturnValue_t result = flashfopen();
|
||||||
|
if (result != returnvalue::OK) {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
ReturnValue_t PlocMPSoCHelper::flashfopen() {
|
ReturnValue_t PlocMPSoCHelper::flashfopen() {
|
||||||
ReturnValue_t result = returnvalue::OK;
|
ReturnValue_t result = returnvalue::OK;
|
||||||
spParams.buf = commandBuffer;
|
spParams.buf = commandBuffer;
|
||||||
(*sequenceCount)++;
|
(*sequenceCount)++;
|
||||||
mpsoc::FlashFopen flashFopen(spParams, *sequenceCount);
|
mpsoc::FlashFopen flashFopen(spParams, *sequenceCount);
|
||||||
result = flashFopen.createPacket(flashWrite.mpsocFile, mpsoc::FlashFopen::APPEND);
|
result = flashFopen.createPacket(flashReadAndWrite.mpsocFile, mpsoc::FlashFopen::APPEND);
|
||||||
if (result != returnvalue::OK) {
|
if (result != returnvalue::OK) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@ -184,7 +198,7 @@ ReturnValue_t PlocMPSoCHelper::flashfclose() {
|
|||||||
spParams.buf = commandBuffer;
|
spParams.buf = commandBuffer;
|
||||||
(*sequenceCount)++;
|
(*sequenceCount)++;
|
||||||
mpsoc::FlashFclose flashFclose(spParams, *sequenceCount);
|
mpsoc::FlashFclose flashFclose(spParams, *sequenceCount);
|
||||||
result = flashFclose.createPacket(flashWrite.mpsocFile);
|
result = flashFclose.createPacket(flashReadAndWrite.mpsocFile);
|
||||||
if (result != returnvalue::OK) {
|
if (result != returnvalue::OK) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -111,13 +111,16 @@ class PlocMPSoCHelper : public SystemObject, public ExecutableObjectIF {
|
|||||||
// buffer
|
// buffer
|
||||||
static const int RETRIES = 10000;
|
static const int RETRIES = 10000;
|
||||||
|
|
||||||
struct FlashWrite {
|
struct FlashInfo {
|
||||||
std::string obcFile;
|
std::string obcFile;
|
||||||
std::string mpsocFile;
|
std::string mpsocFile;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct FlashWrite flashWrite;
|
struct FlashRead : public FlashInfo {
|
||||||
|
size_t readSize = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct FlashRead flashReadAndWrite;
|
||||||
#if OBSW_THREAD_TRACING == 1
|
#if OBSW_THREAD_TRACING == 1
|
||||||
uint32_t opCounter = 0;
|
uint32_t opCounter = 0;
|
||||||
#endif
|
#endif
|
||||||
@ -134,7 +137,8 @@ class PlocMPSoCHelper : public SystemObject, public ExecutableObjectIF {
|
|||||||
SpacePacketCreator creator;
|
SpacePacketCreator creator;
|
||||||
ploc::SpTcParams spParams = ploc::SpTcParams(creator);
|
ploc::SpTcParams spParams = ploc::SpTcParams(creator);
|
||||||
|
|
||||||
std::array<uint8_t, mpsoc::MAX_REPLY_SIZE> tmBuf;
|
std::array<uint8_t, mpsoc::MAX_DATA_SIZE> fileBuf{};
|
||||||
|
std::array<uint8_t, mpsoc::MAX_REPLY_SIZE> tmBuf{};
|
||||||
|
|
||||||
bool terminate = false;
|
bool terminate = false;
|
||||||
|
|
||||||
@ -150,6 +154,7 @@ class PlocMPSoCHelper : public SystemObject, public ExecutableObjectIF {
|
|||||||
|
|
||||||
ReturnValue_t resetHelper();
|
ReturnValue_t resetHelper();
|
||||||
ReturnValue_t performFlashWrite();
|
ReturnValue_t performFlashWrite();
|
||||||
|
ReturnValue_t performFlashRead();
|
||||||
ReturnValue_t flashfopen();
|
ReturnValue_t flashfopen();
|
||||||
ReturnValue_t flashfclose();
|
ReturnValue_t flashfclose();
|
||||||
ReturnValue_t handlePacketTransmission(ploc::SpTcBase& tc);
|
ReturnValue_t handlePacketTransmission(ploc::SpTcBase& tc);
|
||||||
|
Loading…
Reference in New Issue
Block a user