v1.9.0 #175

Merged
muellerr merged 623 commits from develop into main 2022-03-08 10:32:41 +01:00
3 changed files with 92 additions and 77 deletions
Showing only changes of commit ac51ad7a4f - Show all commits

View File

@ -116,13 +116,13 @@ void StrHelper::setComCookie(CookieIF* comCookie_) {
comCookie = comCookie_; comCookie = comCookie_;
} }
ReturnValue_t StrHelper::startImageUpload(std::string uploadImage_) { ReturnValue_t StrHelper::startImageUpload(std::string fullname) {
ReturnValue_t result = checkPath(uploadImage_); ReturnValue_t result = checkPath(fullname);
if (result != RETURN_OK) { if (result != RETURN_OK) {
return result; return result;
} }
uploadImage = uploadImage_; uploadImage.uploadFile = fullname;
if(not std::filesystem::exists(uploadImage)) { if(not std::filesystem::exists(fullname)) {
return FILE_NOT_EXISTS; return FILE_NOT_EXISTS;
} }
internalState = InternalState::UPLOAD_FPGA_IMAGE; internalState = InternalState::UPLOAD_FPGA_IMAGE;
@ -131,15 +131,15 @@ ReturnValue_t StrHelper::startImageUpload(std::string uploadImage_) {
return RETURN_OK; return RETURN_OK;
} }
ReturnValue_t StrHelper::startImageDownload(std::string downloadImagePath_) { ReturnValue_t StrHelper::startImageDownload(std::string path) {
ReturnValue_t result = checkPath(downloadImagePath_); ReturnValue_t result = checkPath(path);
if (result != RETURN_OK) { if (result != RETURN_OK) {
return result; return result;
} }
if(not std::filesystem::exists(downloadImagePath_)) { if(not std::filesystem::exists(path)) {
return PATH_NOT_EXISTS; return PATH_NOT_EXISTS;
} }
downloadImagePath = downloadImagePath_; downloadImage.path = path;
internalState = InternalState::DOWNLOAD_IMAGE; internalState = InternalState::DOWNLOAD_IMAGE;
terminate = false; terminate = false;
semaphore.release(); semaphore.release();
@ -150,49 +150,49 @@ void StrHelper::stopProcess() {
terminate = true; terminate = true;
} }
void StrHelper::setDownloadImageName(std::string image) { void StrHelper::setDownloadImageName(std::string filename) {
downloadImage = image; downloadImage.filename = filename;
} }
void StrHelper::setFlashReadFilename(std::string filename) { void StrHelper::setFlashReadFilename(std::string filename) {
flashReadFile = filename; flashRead.filename = filename;
} }
void StrHelper::setDownloadFpgaImage(std::string filename) { void StrHelper::setDownloadFpgaImage(std::string filename) {
fpgaDownload.fileName = filename; fpgaDownload.fileName = filename;
} }
ReturnValue_t StrHelper::startFlashWrite(std::string flashWriteFile_, uint8_t region, ReturnValue_t StrHelper::startFlashWrite(std::string fullname, uint8_t region,
uint32_t address) { uint32_t address) {
ReturnValue_t result = checkPath(flashWriteFile_); ReturnValue_t result = checkPath(fullname);
if (result != RETURN_OK) { if (result != RETURN_OK) {
return result; return result;
} }
flashWriteFile = flashWriteFile_; flashWrite.fullname = fullname;
if(not std::filesystem::exists(flashWriteFile)) { if(not std::filesystem::exists(flashWrite.fullname)) {
return FILE_NOT_EXISTS; return FILE_NOT_EXISTS;
} }
flashWriteAddress = address; flashWrite.address = address;
flashWriteRegion = region; flashWrite.region = region;
internalState = InternalState::FLASH_WRITE; internalState = InternalState::FLASH_WRITE;
semaphore.release(); semaphore.release();
terminate = false; terminate = false;
return RETURN_OK; return RETURN_OK;
} }
ReturnValue_t StrHelper::startFlashRead(std::string flashReadPath_, uint8_t region, ReturnValue_t StrHelper::startFlashRead(std::string path, uint8_t region,
uint32_t address, uint32_t length) { uint32_t address, uint32_t length) {
ReturnValue_t result = checkPath(flashReadPath_); ReturnValue_t result = checkPath(path);
if (result != RETURN_OK) { if (result != RETURN_OK) {
return result; return result;
} }
flashReadPath = flashReadPath_; flashRead.path = path;
if(not std::filesystem::exists(flashReadPath)) { if(not std::filesystem::exists(flashRead.path)) {
return FILE_NOT_EXISTS; return FILE_NOT_EXISTS;
} }
flashReadAddress = address; flashRead.address = address;
flashReadRegion = region; flashRead.region = region;
flashReadSize = length; flashRead.size = length;
internalState = InternalState::FLASH_READ; internalState = InternalState::FLASH_READ;
semaphore.release(); semaphore.release();
terminate = false; terminate = false;
@ -224,7 +224,7 @@ ReturnValue_t StrHelper::performImageDownload() {
uint32_t size = 0; uint32_t size = 0;
uint32_t retries = 0; uint32_t retries = 0;
Timestamp timestamp; Timestamp timestamp;
std::string image = downloadImagePath + "/" + timestamp.str() + downloadImage ; std::string image = downloadImage.path + "/" + timestamp.str() + downloadImage.filename ;
std::ofstream file(image, std::ios_base::app | std::ios_base::out); std::ofstream file(image, std::ios_base::app | std::ios_base::out);
if(not std::filesystem::exists(image)) { if(not std::filesystem::exists(image)) {
return FILE_CREATION_FAILED; return FILE_CREATION_FAILED;
@ -281,12 +281,12 @@ ReturnValue_t StrHelper::performImageUpload() {
struct UploadActionRequest uploadReq; struct UploadActionRequest uploadReq;
uploadReq.position = 0; uploadReq.position = 0;
std::memset(&uploadReq.data, 0, sizeof(uploadReq.data)); std::memset(&uploadReq.data, 0, sizeof(uploadReq.data));
if (not std::filesystem::exists(uploadImage)) { if (not std::filesystem::exists(uploadImage.uploadFile)) {
triggerEvent(STR_HELPER_FILE_NOT_EXISTS, static_cast<uint32_t>(internalState)); triggerEvent(STR_HELPER_FILE_NOT_EXISTS, static_cast<uint32_t>(internalState));
internalState = InternalState::IDLE; internalState = InternalState::IDLE;
return RETURN_FAILED; return RETURN_FAILED;
} }
std::ifstream file(uploadImage, std::ifstream::binary); std::ifstream file(uploadImage.uploadFile, 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
@ -332,17 +332,17 @@ ReturnValue_t StrHelper::performFlashWrite() {
uint32_t remainingBytes = 0; uint32_t remainingBytes = 0;
uint32_t fileSize = 0; uint32_t fileSize = 0;
struct WriteActionRequest req; struct WriteActionRequest req;
if (not std::filesystem::exists(flashWriteFile)) { if (not std::filesystem::exists(flashWrite.fullname)) {
triggerEvent(STR_HELPER_FILE_NOT_EXISTS, static_cast<uint32_t>(internalState)); triggerEvent(STR_HELPER_FILE_NOT_EXISTS, static_cast<uint32_t>(internalState));
internalState = InternalState::IDLE; internalState = InternalState::IDLE;
return RETURN_FAILED; return RETURN_FAILED;
} }
std::ifstream file(flashWriteFile, std::ifstream::binary); std::ifstream file(flashWrite.fullname, std::ifstream::binary);
file.seekg(0, file.end); file.seekg(0, file.end);
fileSize = file.tellg(); fileSize = file.tellg();
remainingBytes = fileSize; remainingBytes = fileSize;
req.region = flashWriteRegion; req.region = flashWrite.region;
req.address = flashWriteAddress; req.address = flashWrite.address;
req.length = MAX_FLASH_DATA; req.length = MAX_FLASH_DATA;
while(remainingBytes >= MAX_FLASH_DATA) { while(remainingBytes >= MAX_FLASH_DATA) {
if (terminate) { if (terminate) {
@ -383,23 +383,23 @@ ReturnValue_t StrHelper::performFlashRead() {
uint32_t size = 0; uint32_t size = 0;
uint32_t retries = 0; uint32_t retries = 0;
Timestamp timestamp; Timestamp timestamp;
std::string fullname = flashReadPath + "/" + timestamp.str() + flashReadFile ; std::string fullname = flashRead.path + "/" + timestamp.str() + flashRead.filename ;
std::ofstream file(fullname, std::ios_base::app | std::ios_base::out); std::ofstream file(fullname, std::ios_base::app | std::ios_base::out);
if (not std::filesystem::exists(fullname)) { if (not std::filesystem::exists(fullname)) {
return FILE_CREATION_FAILED; return FILE_CREATION_FAILED;
} }
req.region = flashReadRegion; req.region = flashRead.region;
while(bytesRead < flashReadSize) { while(bytesRead < flashRead.size) {
if (terminate) { if (terminate) {
return RETURN_OK; return RETURN_OK;
} }
if ((flashReadSize - bytesRead) < MAX_FLASH_DATA) { if ((flashRead.size - bytesRead) < MAX_FLASH_DATA) {
req.length = flashReadSize - bytesRead; req.length = flashRead.size - bytesRead;
} }
else { else {
req.length = MAX_FLASH_DATA; req.length = MAX_FLASH_DATA;
} }
req.address = flashReadAddress + bytesRead; req.address = flashRead.address + bytesRead;
arc_pack_read_action_req(&req, commandBuffer, &size); arc_pack_read_action_req(&req, commandBuffer, &size);
result = sendAndRead(size, req.address); result = sendAndRead(size, req.address);
if (result != RETURN_OK) { if (result != RETURN_OK) {
@ -503,7 +503,7 @@ ReturnValue_t StrHelper::performFpgaUpload() {
internalState = InternalState::IDLE; internalState = InternalState::IDLE;
return RETURN_FAILED; return RETURN_FAILED;
} }
std::ifstream file(flashWriteFile, std::ifstream::binary); std::ifstream file(flashWrite.fullname, std::ifstream::binary);
file.seekg(0, file.end); file.seekg(0, file.end);
fileSize = file.tellg(); fileSize = file.tellg();
req.pos = 0; req.pos = 0;

View File

@ -90,38 +90,37 @@ public:
/** /**
* @brief Starts sequence to upload image to star tracker * @brief Starts sequence to upload image to star tracker
* *
* @param image Name including absolute path if to image to upload. Must be previously * @param uploadImage_ Name including absolute path of the image to upload. Must be previously
* transferred to the OBC with the CFDP protocoll. * transferred to the OBC with the CFDP protocol.
*/ */
ReturnValue_t startImageUpload(std::string uploadImage_); ReturnValue_t startImageUpload(std::string uploadImage_);
/** /**
* @brief Calling this function initiates the download of an image from the star tracker. * @brief Calling this function initiates the download of an image from the star tracker.
* *
* @param Name of the image which will be created * @param path Path where downloaded image will be stored
*/ */
ReturnValue_t startImageDownload(std::string downloadImagePath_); ReturnValue_t startImageDownload(std::string path);
/** /**
* @brief Starts the flash write procedure * @brief Starts the flash write procedure
* *
* @param flashWriteFile_ Full name including absolute path of file to write to flash * @param fullname Full name including absolute path of file to write to flash
* @param region Region ID of flash region to write to * @param region Region ID of flash region to write to
* @param address Start address of flash write procedure * @param address Start address of flash write procedure
*/ */
ReturnValue_t startFlashWrite(std::string flashWriteFile_, uint8_t region, ReturnValue_t startFlashWrite(std::string fullname, uint8_t region, uint32_t address);
uint32_t address);
/** /**
* @brief Starts the flash read procedure * @brief Starts the flash read procedure
* *
* @param flashWriteFile_ Full name including absolute path of file to write to flash * @param path Path where file with read flash data will be created
* @param region Region ID of flash region to read from * @param region Region ID of flash region to read from
* @param flashWriteAddress Start address of flash section to read * @param address Start address of flash section to read
* @param length Number of bytes to read from flash * @param length Number of bytes to read from flash
*/ */
ReturnValue_t startFlashRead(std::string flashReadPath_, uint8_t region, ReturnValue_t startFlashRead(std::string path, uint8_t region, uint32_t address,
uint32_t address, uint32_t length); uint32_t length);
/** /**
* @brief Starts the download of the FPGA image * @brief Starts the download of the FPGA image
@ -148,7 +147,7 @@ public:
/** /**
* @brief Changes the dafault name of downloaded images * @brief Changes the dafault name of downloaded images
*/ */
void setDownloadImageName(std::string image); void setDownloadImageName(std::string filename);
/** /**
* @brief Sets the name of the file which will be created to store the data read from flash * @brief Sets the name of the file which will be created to store the data read from flash
@ -204,7 +203,6 @@ private:
// Name of file containing downloaded FPGA image // Name of file containing downloaded FPGA image
std::string fileName = "fpgaimage.bin"; std::string fileName = "fpgaimage.bin";
}; };
FpgaDownload fpgaDownload; FpgaDownload fpgaDownload;
class FpgaUpload { class FpgaUpload {
@ -213,7 +211,6 @@ private:
// Full name of file to upload // Full name of file to upload
std::string uploadFile; std::string uploadFile;
}; };
FpgaUpload fpgaUpload; FpgaUpload fpgaUpload;
static const uint32_t MAX_POLLS = 10000; static const uint32_t MAX_POLLS = 10000;
@ -245,31 +242,49 @@ private:
BinarySemaphore semaphore; BinarySemaphore semaphore;
// Name including absolute path of image to upload class UploadImage {
std::string uploadImage; public:
// Path where the downloaded image will be stored // Name including absolute path of image to upload
std::string downloadImagePath; std::string uploadFile;
// File which contains data to write when executing the flash write command };
std::string flashWriteFile; UploadImage uploadImage;
// Path where the file containing the read data will be stored
std::string flashReadPath = "";
// Default name of downloaded image, can be changed via command class DownloadImage {
std::string downloadImage = "image.bin"; public:
// Default name of file containing the data read from flash, can be changed via command // Path where the downloaded image will be stored
std::string flashReadFile = "flashread.bin"; std::string path;
// Will be set with the flash write command // Default name of downloaded image, can be changed via command
uint8_t flashWriteRegion = 0; std::string filename = "image.bin";
// Will be set with the flash write command and specifies the start address where to write the };
// flash data to DownloadImage downloadImage;
uint32_t flashWriteAddress = 0;
// Will be set with the flash read command class FlashWrite {
uint8_t flashReadRegion = 0; public:
// Will be set with the flash read command and specifies the start address of the flash section // File which contains data to write when executing the flash write command
// to read std::string fullname;
uint32_t flashReadAddress = 0; // Will be set with the flash write command
// Number of bytes to read from flash uint8_t region = 0;
uint32_t flashReadSize = 0; // Will be set with the flash write command and specifies the start address where to write the
// flash data to
uint32_t address = 0;
};
FlashWrite flashWrite;
class FlashRead {
public:
// Path where the file containing the read data will be stored
std::string path = "";
// Default name of file containing the data read from flash, can be changed via command
std::string filename = "flashread.bin";
// Will be set with the flash read command
uint8_t region = 0;
// Will be set with the flash read command and specifies the start address of the flash section
// to read
uint32_t address = 0;
// Number of bytes to read from flash
uint32_t size = 0;
};
FlashRead flashRead;
SdCardManager* sdcMan = nullptr; SdCardManager* sdcMan = nullptr;

2
tmtc

@ -1 +1 @@
Subproject commit e3950bbbcca825b07c40b16658127210a9fe5fe2 Subproject commit 418ecb815b00d5d2081b8d55a480f4c13a0f7139