restructured flash write command
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@ -8,6 +8,7 @@
|
||||
#include "fsfw/tmtcservices/SourceSequenceCounter.h"
|
||||
#include "linux/devices/devicedefinitions/PlocMPSoCDefinitions.h"
|
||||
#include "PlocMPSoCHelper.h"
|
||||
#include "linux/devices/devicedefinitions/MPSoCReturnValuesIF.h"
|
||||
|
||||
/**
|
||||
* @brief This is the device handler for the MPSoC of the payload computer.
|
||||
@ -25,23 +26,6 @@
|
||||
class PlocMPSoCHandler: public DeviceHandlerBase {
|
||||
public:
|
||||
|
||||
static const uint8_t INTERFACE_ID = CLASS_ID::PLOC_MPSOC_HANDLER;
|
||||
|
||||
//! [EXPORT] : [COMMENT] Space Packet received from PLOC has invalid CRC
|
||||
static const ReturnValue_t CRC_FAILURE = MAKE_RETURN_CODE(0xA0);
|
||||
//! [EXPORT] : [COMMENT] Received ACK failure reply from PLOC
|
||||
static const ReturnValue_t RECEIVED_ACK_FAILURE = MAKE_RETURN_CODE(0xA1);
|
||||
//! [EXPORT] : [COMMENT] Received execution failure reply from PLOC
|
||||
static const ReturnValue_t RECEIVED_EXE_FAILURE = MAKE_RETURN_CODE(0xA2);
|
||||
//! [EXPORT] : [COMMENT] Received space packet with invalid APID from PLOC
|
||||
static const ReturnValue_t INVALID_APID = MAKE_RETURN_CODE(0xA3);
|
||||
//! [EXPORT] : [COMMENT] Received command with invalid length
|
||||
static const ReturnValue_t INVALID_LENGTH = MAKE_RETURN_CODE(0xA4);
|
||||
//! [EXPORT] : [COMMENT] Received command with invalid filename
|
||||
static const ReturnValue_t FILENAME_TOO_LONG = MAKE_RETURN_CODE(0xA5);
|
||||
//! [EXPORT] : [COMMENT] MPSoC helper is currently executing a command
|
||||
static const ReturnValue_t MPSOC_HELPER_EXECUTING = MAKE_RETURN_CODE(0xA6);
|
||||
|
||||
PlocMPSoCHandler(object_id_t objectId, object_id_t uartComIFid, CookieIF * comCookie,
|
||||
PlocMPSoCHelper* plocMPSoCHelper);
|
||||
virtual ~PlocMPSoCHandler();
|
||||
|
@ -3,6 +3,7 @@
|
||||
#include <filesystem>
|
||||
#include <fstream>
|
||||
|
||||
#include "OBSWConfig.h"
|
||||
#ifdef XIPHOS_Q7S
|
||||
#include "bsp_q7s/memory/FileSystemHelper.h"
|
||||
#endif
|
||||
@ -65,7 +66,7 @@ void PlocMPSoCHelper::setSequenceCount(SourceSequenceCounter* sequenceCount_) {
|
||||
sequenceCount = sequenceCount_;
|
||||
}
|
||||
|
||||
ReturnValue_t PlocMPSoCHelper::startFlashWrite(std::string file) {
|
||||
ReturnValue_t PlocMPSoCHelper::startFlashWrite(std::string obcFile, std::string mpsocFile) {
|
||||
#ifdef XIPHOS_Q7S
|
||||
ReturnValue_t result = FilesystemHelper::checkPath(file);
|
||||
if (result != RETURN_OK) {
|
||||
@ -76,7 +77,16 @@ ReturnValue_t PlocMPSoCHelper::startFlashWrite(std::string file) {
|
||||
return result;
|
||||
}
|
||||
#endif
|
||||
flashWrite.file = file;
|
||||
#ifdef TE0720_1CFA
|
||||
if (not std::filesystem::exists(obcFile)) {
|
||||
sif::warning << "PlocMPSoCHelper::startFlashWrite: File " << obcFile << "does not exist"
|
||||
<< std::endl;
|
||||
return RETURN_FAILED;
|
||||
}
|
||||
#endif
|
||||
|
||||
flashWrite.obcFile = obcFile;
|
||||
flashWrite.mpsocFile = mpsocFile;
|
||||
internalState = InternalState::FLASH_WRITE;
|
||||
semaphore.release();
|
||||
terminate = false;
|
||||
@ -92,7 +102,7 @@ ReturnValue_t PlocMPSoCHelper::performFlashWrite() {
|
||||
return result;
|
||||
}
|
||||
uint8_t tempData[mpsoc::MAX_DATA_SIZE];
|
||||
std::ifstream file(flashWrite.file, std::ifstream::binary);
|
||||
std::ifstream file(flashWrite.obcFile, std::ifstream::binary);
|
||||
// Set position of next character to end of file input stream
|
||||
file.seekg(0, file.end);
|
||||
// tellg returns position of character in input stream
|
||||
@ -135,7 +145,7 @@ ReturnValue_t PlocMPSoCHelper::flashfopen() {
|
||||
ReturnValue_t result = RETURN_OK;
|
||||
(*sequenceCount)++;
|
||||
mpsoc::FlashFopen flashFopen(*sequenceCount);
|
||||
result = flashFopen.createPacket(flashWrite.file, mpsoc::FlashFopen::APPEND);
|
||||
result = flashFopen.createPacket(flashWrite.mpsocFile, mpsoc::FlashFopen::APPEND);
|
||||
if (result != RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
@ -150,7 +160,7 @@ ReturnValue_t PlocMPSoCHelper::flashfclose() {
|
||||
ReturnValue_t result = RETURN_OK;
|
||||
(*sequenceCount)++;
|
||||
mpsoc::FlashFclose flashFclose(*sequenceCount);
|
||||
result = flashFclose.createPacket(flashWrite.file);
|
||||
result = flashFclose.createPacket(flashWrite.mpsocFile);
|
||||
if (result != RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
|
@ -79,11 +79,12 @@ public:
|
||||
/**
|
||||
* @brief Starts flash write sequence
|
||||
*
|
||||
* @param file File with data to write
|
||||
* @param obcFile File where to read from the data
|
||||
* @param mpsocFile The file of the MPSoC where should be written to
|
||||
*
|
||||
* @return RETURN_OK if successful, otherwise error return value
|
||||
*/
|
||||
ReturnValue_t startFlashWrite(std::string file);
|
||||
ReturnValue_t startFlashWrite(std::string obcFile, std::string mpsocFile);
|
||||
|
||||
/**
|
||||
* @brief Can be used to interrupt a running data transfer.
|
||||
@ -104,7 +105,8 @@ private:
|
||||
static const int RETRIES = 3;
|
||||
|
||||
struct FlashWrite {
|
||||
std::string file;
|
||||
std::string obcFile;
|
||||
std::string mpsocFile;
|
||||
};
|
||||
|
||||
struct FlashWrite flashWrite;
|
||||
|
Reference in New Issue
Block a user