fpga download image command
Some checks failed
EIVE/eive-obsw/pipeline/pr-develop There was a failure building this commit

This commit is contained in:
Jakob Meier 2021-12-29 20:33:20 +01:00
parent 8d160572c7
commit e26ffb6afd
11 changed files with 1031 additions and 86 deletions

View File

@ -127,8 +127,18 @@ void Q7STestTask::testDummyParams() {
param.writeJsonFile(); param.writeJsonFile();
param.print(); param.print();
int test = param.getValue<int>(DummyParameter::DUMMY_KEY_PARAM_1); int test = 0;
std::string test2 = param.getValue<std::string>(DummyParameter::DUMMY_KEY_PARAM_2); result = param.getValue<int>(DummyParameter::DUMMY_KEY_PARAM_1, &test);
if (result != HasReturnvaluesIF::RETURN_OK) {
sif::warning << "Q7STestTask::testDummyParams: Key " << DummyParameter::DUMMY_KEY_PARAM_1
<< " does not exist" << std::endl;
}
std::string test2;
result = param.getValue<std::string>(DummyParameter::DUMMY_KEY_PARAM_2, &test2);
if (result != HasReturnvaluesIF::RETURN_OK) {
sif::warning << "Q7STestTask::testDummyParams: Key " << DummyParameter::DUMMY_KEY_PARAM_1
<< " does not exist" << std::endl;
}
sif::info << "Test value (3 expected): " << test << std::endl; sif::info << "Test value (3 expected): " << test << std::endl;
sif::info << "Test value 2 (\"blirb\" expected): " << test2 << std::endl; sif::info << "Test value 2 (\"blirb\" expected): " << test2 << std::endl;
} }

View File

@ -158,7 +158,45 @@ enum PoolIds: lp_id_t {
CONTRAST_BIND6, CONTRAST_BIND6,
CONTRAST_BIND7, CONTRAST_BIND7,
CONTRAST_BIND8, CONTRAST_BIND8,
CHKSUM CHKSUM,
DWL_ID,
DWL_PIXX,
DWL_PIXY,
DWL_X_UNCORRECTED,
DWL_Y_UNCORRECTED,
DWL_X_CORRECTED,
DWL_Y_CORRECTED,
DWL_MAGNITUDE,
DWL_CXA,
DWL_CYA,
DWL_QUALITY,
MATCHEDSTR_ID,
MATCHEDSTR_CAMFPX,
MATCHEDSTR_CAMFPY,
MATCHEDSTR_CAMCARTX,
MATCHEDSTR_CAMCARTY,
MATCHEDSTR_CAMCARTZ,
MATCHEDSTR_CAMMAGNITUDE,
MATCHEDSTR_DBFPX,
MATCHEDSTR_DBFPY,
MATCHEDSTR_DBCARTX,
MATCHEDSTR_DBCARTY,
MATCHEDSTR_DBCARTZ,
MATCHEDSTR_DBMAGNITUDE,
MATCHEDSTR_CATALOGID,
DBIMAGE_ID,
DBIMAGE_PIXX,
DBIMAGE_PIXY,
DBIMAGE_X,
DBIMAGE_Y,
DBIMAGE_MAGNITUDE,
BLOBPIX_ID,
BLOBPIX_X,
BLOBPIX_Y,
BLOBPIX_TOT_VAL,
BLOBPIX_IN_USE,
BLOBPIX_BRIGHT_NEIGHBOURS,
BLOBPIX_REGION
}; };
static const DeviceCommandId_t PING_REQUEST = 0; static const DeviceCommandId_t PING_REQUEST = 0;
@ -195,12 +233,15 @@ static const DeviceCommandId_t CHECKSUM = 50;
static const DeviceCommandId_t READ = 51; static const DeviceCommandId_t READ = 51;
static const DeviceCommandId_t WRITE = 52; static const DeviceCommandId_t WRITE = 52;
static const DeviceCommandId_t DOWNLOAD_MATCHED_STAR = 53; static const DeviceCommandId_t DOWNLOAD_MATCHED_STAR = 53;
static const DeviceCommandId_t DOWNLOAD_DB_IMAGE = 54;
static const DeviceCommandId_t STOP_IMAGE_LOADER = 55; static const DeviceCommandId_t STOP_IMAGE_LOADER = 55;
static const DeviceCommandId_t RESET_ERROR = 56; static const DeviceCommandId_t RESET_ERROR = 56;
static const DeviceCommandId_t CHANGE_DOWNLOAD_FILE = 57; static const DeviceCommandId_t CHANGE_DOWNLOAD_FILE = 57;
static const DeviceCommandId_t SET_JSON_FILE_NAME = 58; static const DeviceCommandId_t SET_JSON_FILE_NAME = 58;
static const DeviceCommandId_t SET_READ_FILENAME = 59; static const DeviceCommandId_t SET_READ_FILENAME = 59;
static const DeviceCommandId_t SET_TIME = 60;
static const DeviceCommandId_t DOWNLOAD_DBIMAGE = 61;
static const DeviceCommandId_t DOWNLOAD_BLOBPIXEL = 62;
static const DeviceCommandId_t DOWNLOAD_FPGA_IMAGE = 63;
static const DeviceCommandId_t NONE = 0xFFFFFFFF; static const DeviceCommandId_t NONE = 0xFFFFFFFF;
static const uint32_t VERSION_SET_ID = REQ_VERSION; static const uint32_t VERSION_SET_ID = REQ_VERSION;
@ -212,6 +253,10 @@ static const uint32_t SOLUTION_SET_ID = REQ_SOLUTION;
static const uint32_t HISTOGRAM_SET_ID = REQ_HISTOGRAM; static const uint32_t HISTOGRAM_SET_ID = REQ_HISTOGRAM;
static const uint32_t CONTRAST_SET_ID = REQ_CONTRAST; static const uint32_t CONTRAST_SET_ID = REQ_CONTRAST;
static const uint32_t CHECKSUM_SET_ID = CHECKSUM; static const uint32_t CHECKSUM_SET_ID = CHECKSUM;
static const uint32_t DOWNLOADCENTROID_SET_ID = DOWNLOAD_CENTROID;
static const uint32_t DOWNLOAD_MATCHED_STAR_SET_ID = DOWNLOAD_MATCHED_STAR;
static const uint32_t DOWNLOAD_DBIMAGE_SET_ID = DOWNLOAD_DBIMAGE;
static const uint32_t DOWNLOAD_BLOBPIXEL_SET_ID = DOWNLOAD_BLOBPIXEL;
/** Max size of unencoded frame */ /** Max size of unencoded frame */
static const size_t MAX_FRAME_SIZE = 1200; static const size_t MAX_FRAME_SIZE = 1200;
@ -225,6 +270,10 @@ static const uint8_t SOLUTION_SET_ENTRIES = 23;
static const uint8_t HISTOGRAM_SET_ENTRIES = 38; static const uint8_t HISTOGRAM_SET_ENTRIES = 38;
static const uint8_t CONTRAST_SET_ENTRIES = 38; static const uint8_t CONTRAST_SET_ENTRIES = 38;
static const uint8_t CHECKSUM_SET_ENTRIES = 1; static const uint8_t CHECKSUM_SET_ENTRIES = 1;
static const uint8_t DOWNLOAD_CENTROID_SET_ENTRIES = 11;
static const uint8_t DOWNLOAD_MATCHED_STAR_SET_ENTRIES = 14;
static const uint8_t DOWNLOAD_DBIMAGE_SET_ENTRIES = 6;
static const uint8_t DOWNLOAD_BLOBPIXEL_SET_ENTRIES = 7;
// Action, parameter and telemetry IDs // Action, parameter and telemetry IDs
namespace ID { namespace ID {
@ -245,6 +294,7 @@ namespace ID {
static const uint8_t REBOOT = 7; static const uint8_t REBOOT = 7;
static const uint8_t UPLOAD_IMAGE = 10; static const uint8_t UPLOAD_IMAGE = 10;
static const uint8_t POWER = 11; static const uint8_t POWER = 11;
static const uint8_t SET_TIME = 14;
static const uint8_t SUBSCRIBE = 18; static const uint8_t SUBSCRIBE = 18;
static const uint8_t SOLUTION = 24; static const uint8_t SOLUTION = 24;
static const uint8_t TEMPERATURE = 25; static const uint8_t TEMPERATURE = 25;
@ -258,6 +308,11 @@ namespace ID {
static const uint8_t UNLOCK = 6; static const uint8_t UNLOCK = 6;
static const uint8_t TAKE_IMAGE = 15; static const uint8_t TAKE_IMAGE = 15;
static const uint8_t ERROR_RESET = 12; static const uint8_t ERROR_RESET = 12;
static const uint8_t DOWNLOAD_CENTROID = 16;
static const uint8_t UPLOAD_CENTROID = 17;
static const uint8_t DOWNLOAD_MATCHED_STAR = 18;
static const uint8_t DOWNLOAD_DBIMAGE = 19;
static const uint8_t DOWNLOAD_BLOBPIXEL = 24;
} }
namespace Program { namespace Program {
@ -951,6 +1006,202 @@ public:
lp_var_t<uint32_t> checksum = lp_var_t<uint32_t>(sid.objectId, PoolIds::CHKSUM, this); lp_var_t<uint32_t> checksum = lp_var_t<uint32_t>(sid.objectId, PoolIds::CHKSUM, this);
}; };
}
/**
* @brief Dataset to store download centroid response
*/
class DownloadCentroidSet:
public StaticLocalDataSet<DOWNLOAD_CENTROID_SET_ENTRIES> {
public:
// Size of dataset
static const size_t SIZE = 34;
DownloadCentroidSet(HasLocalDataPoolIF* owner):
StaticLocalDataSet(owner, DOWNLOADCENTROID_SET_ID) {
}
DownloadCentroidSet(object_id_t objectId):
StaticLocalDataSet(sid_t(objectId, DOWNLOADCENTROID_SET_ID)) {
}
lp_var_t<uint8_t> id = lp_var_t<uint8_t>(sid.objectId, PoolIds::DWL_ID, this);
lp_var_t<float> pixx = lp_var_t<float>(sid.objectId, PoolIds::DWL_PIXX, this);
lp_var_t<float> pixy = lp_var_t<float>(sid.objectId, PoolIds::DWL_PIXY, this);
lp_var_t<float> xUncorrected = lp_var_t<float>(sid.objectId, PoolIds::DWL_X_UNCORRECTED, this);
lp_var_t<float> yUncorrected = lp_var_t<float>(sid.objectId, PoolIds::DWL_Y_UNCORRECTED, this);
lp_var_t<float> xCorrected = lp_var_t<float>(sid.objectId, PoolIds::DWL_X_CORRECTED, this);
lp_var_t<float> yCorrected = lp_var_t<float>(sid.objectId, PoolIds::DWL_Y_CORRECTED, this);
lp_var_t<uint8_t> magnitude = lp_var_t<uint8_t>(sid.objectId, PoolIds::DWL_MAGNITUDE, this);
lp_var_t<float> cxa = lp_var_t<float>(sid.objectId, PoolIds::DWL_CXA, this);
lp_var_t<float> cya = lp_var_t<float>(sid.objectId, PoolIds::DWL_CYA, this);
lp_var_t<float> quality = lp_var_t<float>(sid.objectId, PoolIds::DWL_QUALITY, this);
void printSet() {
PoolReadGuard rg(this);
sif::info << "ContrastSet::printSet: id: " << static_cast<unsigned int>(this->id.value)
<< std::endl;
sif::info << "ContrastSet::printSet: pixx: " << this->pixx << std::endl;
sif::info << "ContrastSet::printSet: pixy: " << this->pixy << std::endl;
sif::info << "ContrastSet::printSet: xUncorrected: " << this->xUncorrected << std::endl;
sif::info << "ContrastSet::printSet: yUncorrected: " << this->yUncorrected << std::endl;
sif::info << "ContrastSet::printSet: xCorrected: " << this->xCorrected << std::endl;
sif::info << "ContrastSet::printSet: yCorrected: " << this->yCorrected << std::endl;
sif::info << "ContrastSet::printSet: magnitude: " << this->magnitude << std::endl;
sif::info << "ContrastSet::printSet: cxa: " << this->cxa << std::endl;
sif::info << "ContrastSet::printSet: cya: " << this->cya << std::endl;
sif::info << "ContrastSet::printSet: quality: " << this->quality << std::endl;
}
};
namespace UploadCentroidKeys {
static const char id[] = "id";
static const char pixx[] = "pixx";
static const char pixy[] = "pixy";
static const char x_uncorrected[] = "x_uncorrected";
static const char y_uncorrected[] = "y_uncorrected";
static const char x_corrected[] = "x_corrected";
static const char y_corrected[] = "y_corrected";
static const char magnitude[] = "magnitude";
static const char cxa[] = "cxa";
static const char cya[] = "cya";
static const char quality[] = "quality";
};
/**
* @brief Dataset to store matched star information
*/
class DownloadMatchedStar :
public StaticLocalDataSet<DOWNLOAD_MATCHED_STAR_SET_ENTRIES> {
public:
// Size of dataset
static const size_t SIZE = 53;
DownloadMatchedStar(HasLocalDataPoolIF* owner):
StaticLocalDataSet(owner, DOWNLOAD_MATCHED_STAR_SET_ID) {
}
DownloadMatchedStar(object_id_t objectId):
StaticLocalDataSet(sid_t(objectId, DOWNLOAD_MATCHED_STAR_SET_ID)) {
}
lp_var_t<uint8_t> id = lp_var_t<uint8_t>(sid.objectId, PoolIds::MATCHEDSTR_ID, this);
lp_var_t<float> camfpx = lp_var_t<float>(sid.objectId, PoolIds::MATCHEDSTR_CAMFPX, this);
lp_var_t<float> camfpy = lp_var_t<float>(sid.objectId, PoolIds::MATCHEDSTR_CAMFPY, this);
lp_var_t<float> camcartx = lp_var_t<float>(sid.objectId, PoolIds::MATCHEDSTR_CAMCARTX, this);
lp_var_t<float> camcarty = lp_var_t<float>(sid.objectId, PoolIds::MATCHEDSTR_CAMCARTY, this);
lp_var_t<float> camcartz = lp_var_t<float>(sid.objectId, PoolIds::MATCHEDSTR_CAMCARTZ, this);
lp_var_t<float> cammagnitude = lp_var_t<float>(sid.objectId, PoolIds::MATCHEDSTR_CAMMAGNITUDE,
this);
lp_var_t<float> dbfpx = lp_var_t<float>(sid.objectId, PoolIds::MATCHEDSTR_DBFPX, this);
lp_var_t<float> dbfpy = lp_var_t<float>(sid.objectId, PoolIds::MATCHEDSTR_DBFPY, this);
lp_var_t<float> dbcartx = lp_var_t<float>(sid.objectId, PoolIds::MATCHEDSTR_DBCARTX, this);
lp_var_t<float> dbcarty = lp_var_t<float>(sid.objectId, PoolIds::MATCHEDSTR_DBCARTY, this);
lp_var_t<float> dbcartz = lp_var_t<float>(sid.objectId, PoolIds::MATCHEDSTR_DBCARTZ, this);
lp_var_t<float> dbmagnitude = lp_var_t<float>(sid.objectId, PoolIds::MATCHEDSTR_DBMAGNITUDE,
this);
lp_var_t<uint32_t> catalogid = lp_var_t<uint32_t>(sid.objectId, PoolIds::MATCHEDSTR_CATALOGID,
this);
void printSet() {
PoolReadGuard rg(this);
sif::info << "DownloadMatchedStar::printSet: id: "
<< static_cast<unsigned int>(this->id.value) << std::endl;
sif::info << "DownloadMatchedStar::printSet: camfpx: " << this->camfpx << std::endl;
sif::info << "DownloadMatchedStar::printSet: camfpy: " << this->camfpy << std::endl;
sif::info << "DownloadMatchedStar::printSet: camcartx: " << this->camcartx << std::endl;
sif::info << "DownloadMatchedStar::printSet: camcarty: " << this->camcarty << std::endl;
sif::info << "DownloadMatchedStar::printSet: camcartz: " << this->camcartz << std::endl;
sif::info << "DownloadMatchedStar::printSet: cammagnitude: " << this->cammagnitude
<< std::endl;
sif::info << "DownloadMatchedStar::printSet: dbfpx: " << this->dbfpx << std::endl;
sif::info << "DownloadMatchedStar::printSet: dbfpy: " << this->dbfpy << std::endl;
sif::info << "DownloadMatchedStar::printSet: dbcartx: " << this->dbcartx << std::endl;
sif::info << "DownloadMatchedStar::printSet: dbcarty: " << this->dbcarty << std::endl;
sif::info << "DownloadMatchedStar::printSet: dbcartz: " << this->dbcartz << std::endl;
sif::info << "DownloadMatchedStar::printSet: dbmagnitude: " << this->dbmagnitude
<< std::endl;
sif::info << "DownloadMatchedStar::printSet: catalogid: " << this->catalogid << std::endl;
}
};
/**
* @brief Dataset to store the response to the DownloadDBImage request
*/
class DownloadDBImage :
public StaticLocalDataSet<DOWNLOAD_DBIMAGE_SET_ENTRIES> {
public:
// Size of dataset
static const size_t SIZE = 21;
DownloadDBImage(HasLocalDataPoolIF* owner):
StaticLocalDataSet(owner, DOWNLOAD_DBIMAGE_SET_ID) {
}
DownloadDBImage(object_id_t objectId):
StaticLocalDataSet(sid_t(objectId, DOWNLOAD_DBIMAGE_SET_ID)) {
}
lp_var_t<uint8_t> id = lp_var_t<uint8_t>(sid.objectId, PoolIds::DBIMAGE_ID, this);
lp_var_t<float> pixx = lp_var_t<float>(sid.objectId, PoolIds::DBIMAGE_PIXX, this);
lp_var_t<float> pixy = lp_var_t<float>(sid.objectId, PoolIds::DBIMAGE_PIXY, this);
lp_var_t<float> x = lp_var_t<float>(sid.objectId, PoolIds::DBIMAGE_X, this);
lp_var_t<float> y = lp_var_t<float>(sid.objectId, PoolIds::DBIMAGE_Y, this);
lp_var_t<float> magnitude = lp_var_t<float>(sid.objectId, PoolIds::DBIMAGE_MAGNITUDE, this);
void printSet() {
PoolReadGuard rg(this);
sif::info << "DownloadDBImage::printSet: id: "
<< static_cast<unsigned int>(this->id.value) << std::endl;
sif::info << "DownloadDBImage::printSet: pixx: " << this->pixx << std::endl;
sif::info << "DownloadDBImage::printSet: pixy: " << this->pixy << std::endl;
sif::info << "DownloadDBImage::printSet: x: " << this->x << std::endl;
sif::info << "DownloadDBImage::printSet: y: " << this->y << std::endl;
sif::info << "DownloadDBImage::printSet: magnitude: " << this->magnitude << std::endl;
}
};
/**
* @brief Dataset to store the response to the download blob pixel action request
*/
class DownloadBlobPixel: public StaticLocalDataSet<DOWNLOAD_BLOBPIXEL_SET_ENTRIES> {
public:
// Size of dataset
static const size_t SIZE = 22;
DownloadBlobPixel(HasLocalDataPoolIF* owner) :
StaticLocalDataSet(owner, DOWNLOAD_BLOBPIXEL_SET_ID) {
}
DownloadBlobPixel(object_id_t objectId) :
StaticLocalDataSet(sid_t(objectId, DOWNLOAD_BLOBPIXEL_SET_ENTRIES)) {
}
lp_var_t<uint8_t> id = lp_var_t<uint8_t>(sid.objectId, PoolIds::BLOBPIX_ID, this);
lp_var_t<uint32_t> x = lp_var_t<uint32_t>(sid.objectId, PoolIds::BLOBPIX_X, this);
lp_var_t<uint32_t> y = lp_var_t<uint32_t>(sid.objectId, PoolIds::BLOBPIX_Y, this);
lp_var_t<uint32_t> totalValue = lp_var_t<uint32_t>(sid.objectId, PoolIds::BLOBPIX_TOT_VAL, this);
lp_var_t<uint8_t> inUse = lp_var_t<uint8_t>(sid.objectId, PoolIds::BLOBPIX_IN_USE, this);
lp_var_t<uint32_t> brightNeighbours = lp_var_t<uint32_t>(sid.objectId,
PoolIds::BLOBPIX_BRIGHT_NEIGHBOURS, this);
lp_var_t<uint32_t> region = lp_var_t<uint32_t>(sid.objectId, PoolIds::BLOBPIX_REGION, this);
void printSet() {
PoolReadGuard rg(this);
sif::info << "DownloadBlobPixel::printSet: id: "
<< static_cast<unsigned int>(this->id.value) << std::endl;
sif::info << "DownloadBlobPixel::printSet: x: " << this->x << std::endl;
sif::info << "DownloadBlobPixel::printSet: y: " << this->y << std::endl;
sif::info << "DownloadBlobPixel::printSet: totalValue: " << this->totalValue << std::endl;
sif::info << "DownloadBlobPixel::printSet: inUse: "
<< static_cast<unsigned int>(this->inUse.value) << std::endl;
sif::info << "DownloadBlobPixel::printSet: brightNeighbours: " << this->brightNeighbours
<< std::endl;
sif::info << "DownloadBlobPixel::printSet: region: " << this->region << std::endl;
}
};
}
#endif /* MISSION_STARTRACKER_DEFINITIONS_H_ */ #endif /* MISSION_STARTRACKER_DEFINITIONS_H_ */

View File

@ -1,23 +1,25 @@
#include <fstream> #include <fstream>
#include "StarTrackerHandler.h" #include "StarTrackerHandler.h"
#include "OBSWConfig.h" #include "OBSWConfig.h"
#include "StarTrackerJsonCommands.h" #include "StarTrackerJsonCommands.h"
#include <fsfw/globalfunctions/CRC.h> #include <fsfw/globalfunctions/CRC.h>
#include <fsfw/ipc/QueueFactory.h> #include <fsfw/ipc/QueueFactory.h>
#include <mission/Memory/NVMParameterBase.h>
extern "C" { extern "C" {
#include <thirdparty/arcsec_star_tracker/client/generated/telemetry.h> #include <thirdparty/arcsec_star_tracker/client/generated/telemetry.h>
#include <thirdparty/arcsec_star_tracker/client/generated/actionreq.h> #include <thirdparty/arcsec_star_tracker/client/generated/actionreq.h>
#include "common/misc.h" #include "common/misc.h"
} }
using json = nlohmann::json;
StarTrackerHandler::StarTrackerHandler(object_id_t objectId, object_id_t comIF, StarTrackerHandler::StarTrackerHandler(object_id_t objectId, object_id_t comIF,
CookieIF * comCookie, StrHelper* strHelper) : CookieIF * comCookie, StrHelper* strHelper) :
DeviceHandlerBase(objectId, comIF, comCookie), temperatureSet(this), versionSet(this), powerSet( DeviceHandlerBase(objectId, comIF, comCookie), temperatureSet(this), versionSet(this), powerSet(
this), interfaceSet(this), timeSet(this), solutionSet(this), histogramSet(this), this), interfaceSet(this), timeSet(this), solutionSet(this), histogramSet(this), contrastSet(
contrastSet(this), checksumSet(this), strHelper(strHelper) { this), checksumSet(this), downloadCentroidSet(this), downloadMatchedStar(this),
downloadDbImage(this), downloadBlobPixel(this), strHelper(
strHelper) {
if (comCookie == nullptr) { if (comCookie == nullptr) {
sif::error << "StarTrackerHandler: Invalid com cookie" << std::endl; sif::error << "StarTrackerHandler: Invalid com cookie" << std::endl;
} }
@ -51,7 +53,7 @@ ReturnValue_t StarTrackerHandler::initialize() {
} }
result = manager->subscribeToEventRange(eventQueue->getId(), result = manager->subscribeToEventRange(eventQueue->getId(),
event::getEventId(StrHelper::IMAGE_UPLOAD_FAILED), event::getEventId(StrHelper::IMAGE_UPLOAD_FAILED),
event::getEventId(StrHelper::FLASH_READ_FAILED)); event::getEventId(StrHelper::FPGA_UPLOAD_FAILED));
if (result != RETURN_OK) { if (result != RETURN_OK) {
#if FSFW_CPP_OSTREAM_ENABLED == 1 #if FSFW_CPP_OSTREAM_ENABLED == 1
sif::warning << "StarTrackerHandler::initialize: Failed to subscribe to events from " sif::warning << "StarTrackerHandler::initialize: Failed to subscribe to events from "
@ -173,6 +175,21 @@ ReturnValue_t StarTrackerHandler::executeAction(ActionId_t actionId, MessageQueu
std::string(reinterpret_cast<const char*>(data), size)); std::string(reinterpret_cast<const char*>(data), size));
return EXECUTION_FINISHED; return EXECUTION_FINISHED;
} }
case(StarTracker::DOWNLOAD_FPGA_IMAGE): {
result = DeviceHandlerBase::acceptExternalDeviceCommands();
if (result != RETURN_OK) {
return result;
}
if (size > MAX_PATH_SIZE) {
return FILE_PATH_TOO_LONG;
}
result = executeFpgaDownloadCommand(data, size);
if (result != RETURN_OK) {
return result;
}
strHelperExecuting = true;
return EXECUTION_FINISHED;
}
default: default:
break; break;
} }
@ -428,6 +445,30 @@ ReturnValue_t StarTrackerHandler::buildCommandFromCommand(DeviceCommandId_t devi
result = prepareChecksumCommand(commandData, commandDataLen); result = prepareChecksumCommand(commandData, commandDataLen);
return result; return result;
} }
case (StarTracker::SET_TIME): {
result = prepareSetTimeCommand(commandData, commandDataLen);
return result;
}
case (StarTracker::DOWNLOAD_CENTROID): {
result = prepareDownloadCentroidCommand(commandData, commandDataLen);
return result;
}
case (StarTracker::UPLOAD_CENTROID): {
result = prepareUploadCentroidCommand(commandData, commandDataLen);
return result;
}
case (StarTracker::DOWNLOAD_MATCHED_STAR): {
result = prepareDownloadMatchedStarCommand(commandData, commandDataLen);
return result;
}
case (StarTracker::DOWNLOAD_DBIMAGE): {
result = prepareDownloadDbImageCommand(commandData, commandDataLen);
return result;
}
case (StarTracker::DOWNLOAD_BLOBPIXEL): {
result = prepareDownloadBlobPixelCommand(commandData, commandDataLen);
return result;
}
default: default:
return DeviceHandlerIF::COMMAND_NOT_IMPLEMENTED; return DeviceHandlerIF::COMMAND_NOT_IMPLEMENTED;
} }
@ -492,6 +533,18 @@ void StarTrackerHandler::fillCommandAndReplyMap() {
StarTracker::MAX_FRAME_SIZE * 2 + 2); StarTracker::MAX_FRAME_SIZE * 2 + 2);
this->insertInCommandAndReplyMap(StarTracker::CHECKSUM, 3, nullptr, this->insertInCommandAndReplyMap(StarTracker::CHECKSUM, 3, nullptr,
StarTracker::MAX_FRAME_SIZE * 2 + 2); StarTracker::MAX_FRAME_SIZE * 2 + 2);
this->insertInCommandAndReplyMap(StarTracker::SET_TIME, 3, nullptr,
StarTracker::MAX_FRAME_SIZE * 2 + 2);
this->insertInCommandAndReplyMap(StarTracker::DOWNLOAD_CENTROID, 3, nullptr,
StarTracker::MAX_FRAME_SIZE * 2 + 2);
this->insertInCommandAndReplyMap(StarTracker::UPLOAD_CENTROID, 3, nullptr,
StarTracker::MAX_FRAME_SIZE * 2 + 2);
this->insertInCommandAndReplyMap(StarTracker::DOWNLOAD_MATCHED_STAR, 3, &downloadMatchedStar,
StarTracker::MAX_FRAME_SIZE * 2 + 2);
this->insertInCommandAndReplyMap(StarTracker::DOWNLOAD_DBIMAGE, 3, &downloadDbImage,
StarTracker::MAX_FRAME_SIZE * 2 + 2);
this->insertInCommandAndReplyMap(StarTracker::DOWNLOAD_BLOBPIXEL, 3, &downloadBlobPixel,
StarTracker::MAX_FRAME_SIZE * 2 + 2);
} }
ReturnValue_t StarTrackerHandler::scanForReply(const uint8_t *start, size_t remainingSize, ReturnValue_t StarTrackerHandler::scanForReply(const uint8_t *start, size_t remainingSize,
@ -563,10 +616,31 @@ ReturnValue_t StarTrackerHandler::interpretDeviceReply(DeviceCommandId_t id, con
case (StarTracker::BOOT): case (StarTracker::BOOT):
case (StarTracker::TAKE_IMAGE): case (StarTracker::TAKE_IMAGE):
case (StarTracker::RESET_ERROR): case (StarTracker::RESET_ERROR):
case (StarTracker::UNLOCK): { case (StarTracker::UNLOCK):
case (StarTracker::SET_TIME): {
result = handleActionReply(); result = handleActionReply();
break; break;
} }
case (StarTracker::DOWNLOAD_CENTROID): {
result = handleActionReplySet(downloadCentroidSet, StarTracker::DownloadCentroidSet::SIZE);
break;
}
case (StarTracker::DOWNLOAD_MATCHED_STAR): {
result = handleActionReplySet(downloadMatchedStar, StarTracker::DownloadMatchedStar::SIZE);
break;
}
case (StarTracker::DOWNLOAD_DBIMAGE): {
result = handleActionReplySet(downloadDbImage, StarTracker::DownloadDBImage::SIZE);
break;
}
case (StarTracker::DOWNLOAD_BLOBPIXEL): {
result = handleActionReplySet(downloadBlobPixel, StarTracker::DownloadBlobPixel::SIZE);
break;
}
case (StarTracker::UPLOAD_CENTROID): {
result = handleUploadCentroidReply();
break;
}
case (StarTracker::ERASE): { case (StarTracker::ERASE): {
result = handleEraseReply(); result = handleEraseReply();
break; break;
@ -796,6 +870,41 @@ ReturnValue_t StarTrackerHandler::initializeLocalDataPool(localpool::DataPool& l
localDataPoolMap.emplace(StarTracker::CONTRAST_BIND7, new PoolEntry<uint32_t>( { 0 })); localDataPoolMap.emplace(StarTracker::CONTRAST_BIND7, new PoolEntry<uint32_t>( { 0 }));
localDataPoolMap.emplace(StarTracker::CONTRAST_BIND8, new PoolEntry<uint32_t>( { 0 })); localDataPoolMap.emplace(StarTracker::CONTRAST_BIND8, new PoolEntry<uint32_t>( { 0 }));
localDataPoolMap.emplace(StarTracker::CHKSUM, new PoolEntry<uint32_t>( { 0 })); localDataPoolMap.emplace(StarTracker::CHKSUM, new PoolEntry<uint32_t>( { 0 }));
localDataPoolMap.emplace(StarTracker::DWL_ID, new PoolEntry<uint8_t>( { 0 }));
localDataPoolMap.emplace(StarTracker::DWL_PIXX, new PoolEntry<float>( { 0 }));
localDataPoolMap.emplace(StarTracker::DWL_PIXY, new PoolEntry<float>( { 0 }));
localDataPoolMap.emplace(StarTracker::DWL_X_UNCORRECTED, new PoolEntry<float>( { 0 }));
localDataPoolMap.emplace(StarTracker::DWL_Y_UNCORRECTED, new PoolEntry<float>( { 0 }));
localDataPoolMap.emplace(StarTracker::DWL_X_CORRECTED, new PoolEntry<float>( { 0 }));
localDataPoolMap.emplace(StarTracker::DWL_Y_CORRECTED, new PoolEntry<float>( { 0 }));
localDataPoolMap.emplace(StarTracker::DWL_MAGNITUDE, new PoolEntry<uint8_t>( { 0 }));
localDataPoolMap.emplace(StarTracker::DWL_CXA, new PoolEntry<float>( { 0 }));
localDataPoolMap.emplace(StarTracker::DWL_CYA, new PoolEntry<float>( { 0 }));
localDataPoolMap.emplace(StarTracker::DWL_QUALITY, new PoolEntry<float>( { 0 }));
localDataPoolMap.emplace(StarTracker::MATCHEDSTR_ID, new PoolEntry<uint8_t>( { 0 }));
localDataPoolMap.emplace(StarTracker::MATCHEDSTR_CAMFPX, new PoolEntry<float>( { 0 }));
localDataPoolMap.emplace(StarTracker::MATCHEDSTR_CAMFPY, new PoolEntry<float>( { 0 }));
localDataPoolMap.emplace(StarTracker::MATCHEDSTR_CAMCARTX, new PoolEntry<float>( { 0 }));
localDataPoolMap.emplace(StarTracker::MATCHEDSTR_CAMCARTY, new PoolEntry<float>( { 0 }));
localDataPoolMap.emplace(StarTracker::MATCHEDSTR_CAMCARTZ, new PoolEntry<float>( { 0 }));
localDataPoolMap.emplace(StarTracker::MATCHEDSTR_CAMMAGNITUDE, new PoolEntry<float>( { 0 }));
localDataPoolMap.emplace(StarTracker::MATCHEDSTR_DBFPX, new PoolEntry<float>( { 0 }));
localDataPoolMap.emplace(StarTracker::MATCHEDSTR_DBFPY, new PoolEntry<float>( { 0 }));
localDataPoolMap.emplace(StarTracker::MATCHEDSTR_DBCARTX, new PoolEntry<float>( { 0 }));
localDataPoolMap.emplace(StarTracker::MATCHEDSTR_DBCARTY, new PoolEntry<float>( { 0 }));
localDataPoolMap.emplace(StarTracker::MATCHEDSTR_DBCARTZ, new PoolEntry<float>( { 0 }));
localDataPoolMap.emplace(StarTracker::MATCHEDSTR_DBMAGNITUDE, new PoolEntry<float>( { 0 }));
localDataPoolMap.emplace(StarTracker::MATCHEDSTR_CATALOGID, new PoolEntry<uint32_t>( { 0 }));
localDataPoolMap.emplace(StarTracker::BLOBPIX_ID, new PoolEntry<uint8_t>( { 0 }));
localDataPoolMap.emplace(StarTracker::BLOBPIX_X, new PoolEntry<uint32_t>( { 0 }));
localDataPoolMap.emplace(StarTracker::BLOBPIX_Y, new PoolEntry<uint32_t>( { 0 }));
localDataPoolMap.emplace(StarTracker::BLOBPIX_TOT_VAL, new PoolEntry<uint32_t>( { 0 }));
localDataPoolMap.emplace(StarTracker::BLOBPIX_IN_USE, new PoolEntry<uint8_t>( { 0 }));
localDataPoolMap.emplace(StarTracker::BLOBPIX_BRIGHT_NEIGHBOURS, new PoolEntry<uint32_t>( { 0 }));
localDataPoolMap.emplace(StarTracker::BLOBPIX_REGION, new PoolEntry<uint32_t>( { 0 }));
return RETURN_OK; return RETURN_OK;
} }
@ -862,6 +971,30 @@ ReturnValue_t StarTrackerHandler::scanForActionReply(DeviceCommandId_t *foundId)
*foundId = StarTracker::CHECKSUM; *foundId = StarTracker::CHECKSUM;
break; break;
} }
case (StarTracker::ID::SET_TIME): {
*foundId = StarTracker::SET_TIME;
break;
}
case (StarTracker::ID::DOWNLOAD_CENTROID): {
*foundId = StarTracker::DOWNLOAD_CENTROID;
break;
}
case (StarTracker::ID::UPLOAD_CENTROID): {
*foundId = StarTracker::UPLOAD_CENTROID;
break;
}
case (StarTracker::ID::DOWNLOAD_MATCHED_STAR): {
*foundId = StarTracker::DOWNLOAD_MATCHED_STAR;
break;
}
case (StarTracker::ID::DOWNLOAD_DBIMAGE): {
*foundId = StarTracker::DOWNLOAD_DBIMAGE;
break;
}
case (StarTracker::ID::DOWNLOAD_BLOBPIXEL): {
*foundId = StarTracker::DOWNLOAD_BLOBPIXEL;
break;
}
default: default:
sif::warning << "StarTrackerHandler::scanForParameterReply: Unknown parameter reply id" sif::warning << "StarTrackerHandler::scanForParameterReply: Unknown parameter reply id"
<< std::endl; << std::endl;
@ -1019,6 +1152,46 @@ ReturnValue_t StarTrackerHandler::executeWriteCommand(const uint8_t* commandData
return result; return result;
} }
ReturnValue_t StarTrackerHandler::executeFpgaDownloadCommand(const uint8_t* commandData,
size_t commandDataLen) {
ReturnValue_t result = RETURN_OK;
if (commandDataLen < FpgaDownloadCmd::MIN_LENGTH) {
sif::warning << "StarTrackerHandler::executeFpgaDownloadCommand: Command too short"
<< std::endl;
return COMMAND_TOO_SHORT;
}
uint32_t position;
size_t size = sizeof(position);
result = SerializeAdapter::deSerialize(&position, &commandData, &size,
SerializeIF::Endianness::BIG);
if (result != RETURN_OK) {
sif::debug << "StarTrackerHandler::executeWriteCommand: Deserialization of position failed"
<< std::endl;
return result;
}
uint32_t length;
size = sizeof(length);
result = SerializeAdapter::deSerialize(&length, &commandData, &size,
SerializeIF::Endianness::BIG);
if (result != RETURN_OK) {
sif::debug << "StarTrackerHandler::executeWriteCommand: Deserialization of length failed"
<< std::endl;
return result;
}
if (commandDataLen - sizeof(position) - sizeof(length) > MAX_PATH_SIZE) {
sif::warning << "StarTrackerHandler::executeFpgaDownloadCommand: Received command with "
" invalid path and filename" << std::endl;
return FILE_PATH_TOO_LONG;
}
std::string fullname = std::string(reinterpret_cast<const char*>(commandData),
commandDataLen - sizeof(position) - sizeof(length));
result = strHelper->startFpgaDownload(fullname, position, length);
if (result != RETURN_OK) {
return result;
}
return result;
}
ReturnValue_t StarTrackerHandler::executeReadCommand(const uint8_t* commandData, ReturnValue_t StarTrackerHandler::executeReadCommand(const uint8_t* commandData,
size_t commandDataLen) { size_t commandDataLen) {
ReturnValue_t result = RETURN_OK; ReturnValue_t result = RETURN_OK;
@ -1146,6 +1319,140 @@ ReturnValue_t StarTrackerHandler::prepareChecksumCommand(const uint8_t* commandD
return result; return result;
} }
ReturnValue_t StarTrackerHandler::prepareSetTimeCommand(const uint8_t* commandData,
size_t commandDataLen) {
ReturnValue_t result = RETURN_OK;
struct SetTimeActionRequest req;
if (commandDataLen != SetTimeCmd::LENGTH) {
sif::warning << "StarTrackerHandler::prepareSetTimeCommand: Invalid length" << std::endl;
return INVALID_LENGTH;
}
size_t size = sizeof(req.unixTime);
result = SerializeAdapter::deSerialize(&req.unixTime, commandData, &size,
SerializeIF::Endianness::BIG);
if (result != RETURN_OK) {
sif::debug << "StarTrackerHandler::prepareSetTimeCommand: Deserialization failed"
<< std::endl;
return result;
}
uint32_t length = 0;
arc_pack_settime_action_req(&req, commandBuffer, &length);
dataLinkLayer.encodeFrame(commandBuffer, length);
rawPacket = dataLinkLayer.getEncodedFrame();
rawPacketLen = dataLinkLayer.getEncodedLength();
return result;
}
ReturnValue_t StarTrackerHandler::prepareDownloadCentroidCommand(const uint8_t* commandData,
size_t commandDataLen) {
ReturnValue_t result = RETURN_OK;
struct DownloadCentroidActionRequest req;
if (commandDataLen != DownloadCentroidCmd::LENGTH) {
sif::warning << "StarTrackerHandler::prepareDownloadCentroidCommand: Invalid length"
<< std::endl;
return INVALID_LENGTH;
}
req.id = *commandData;
uint32_t length = 0;
arc_pack_downloadcentroid_action_req(&req, commandBuffer, &length);
dataLinkLayer.encodeFrame(commandBuffer, length);
rawPacket = dataLinkLayer.getEncodedFrame();
rawPacketLen = dataLinkLayer.getEncodedLength();
return result;
}
ReturnValue_t StarTrackerHandler::prepareUploadCentroidCommand(const uint8_t* commandData,
size_t commandDataLen) {
if (commandDataLen > MAX_PATH_SIZE) {
return FILE_PATH_TOO_LONG;
}
ReturnValue_t result = RETURN_OK;
struct UploadCentroidActionRequest req;
std::string jsonFileName = std::string(reinterpret_cast<const char*>(commandData),
commandDataLen);
NVMParameterBase j(jsonFileName);
result = j.readJsonFile();
if (result != RETURN_OK) {
sif::warning << "StarTrackerHandler::prepareUploadCentroidCommand: " << jsonFileName
<< " does not exist" << std::endl;
return result;
}
result = j.getValue(StarTracker::UploadCentroidKeys::id, &req.id);
if (result != RETURN_OK) {
sif::warning << "StarTrackerHandler::prepareUploadCentroidCommand: The key "
<< StarTracker::UploadCentroidKeys::id << " does not exist" << std::endl;
return result;
}
result = j.getValue(StarTracker::UploadCentroidKeys::pixx, &req.pixx);
if (result != RETURN_OK) {
sif::warning << "StarTrackerHandler::prepareUploadCentroidCommand: The key "
<< StarTracker::UploadCentroidKeys::pixx << " does not exist" << std::endl;
return result;
}
result = j.getValue(StarTracker::UploadCentroidKeys::pixy, &req.pixy);
if (result != RETURN_OK) {
sif::warning << "StarTrackerHandler::prepareUploadCentroidCommand: The key "
<< StarTracker::UploadCentroidKeys::pixy << " does not exist" << std::endl;
return result;
}
result = j.getValue(StarTracker::UploadCentroidKeys::x_uncorrected, &req.x_uncorrected);
if (result != RETURN_OK) {
sif::warning << "StarTrackerHandler::prepareUploadCentroidCommand: The key "
<< StarTracker::UploadCentroidKeys::x_uncorrected << " does not exist" << std::endl;
return result;
}
result = j.getValue(StarTracker::UploadCentroidKeys::y_uncorrected, &req.y_uncorrected);
if (result != RETURN_OK) {
sif::warning << "StarTrackerHandler::prepareUploadCentroidCommand: The key "
<< StarTracker::UploadCentroidKeys::y_uncorrected << " does not exist" << std::endl;
return result;
}
result = j.getValue(StarTracker::UploadCentroidKeys::x_corrected, &req.x_corrected);
if (result != RETURN_OK) {
sif::warning << "StarTrackerHandler::prepareUploadCentroidCommand: The key "
<< StarTracker::UploadCentroidKeys::x_corrected << " does not exist" << std::endl;
return result;
}
result = j.getValue(StarTracker::UploadCentroidKeys::y_corrected, &req.y_corrected);
if (result != RETURN_OK) {
sif::warning << "StarTrackerHandler::prepareUploadCentroidCommand: The key "
<< StarTracker::UploadCentroidKeys::y_corrected << " does not exist" << std::endl;
return result;
}
result = j.getValue(StarTracker::UploadCentroidKeys::magnitude, &req.magnitude);
if (result != RETURN_OK) {
sif::warning << "StarTrackerHandler::prepareUploadCentroidCommand: The key "
<< StarTracker::UploadCentroidKeys::magnitude << " does not exist" << std::endl;
return result;
}
result = j.getValue(StarTracker::UploadCentroidKeys::cxa, &req.cxa);
if (result != RETURN_OK) {
sif::warning << "StarTrackerHandler::prepareUploadCentroidCommand: The key "
<< StarTracker::UploadCentroidKeys::cxa << " does not exist" << std::endl;
return result;
}
result = j.getValue(StarTracker::UploadCentroidKeys::cya, &req.cya);
if (result != RETURN_OK) {
sif::warning << "StarTrackerHandler::prepareUploadCentroidCommand: The key "
<< StarTracker::UploadCentroidKeys::cya << " does not exist" << std::endl;
return result;
}
result = j.getValue(StarTracker::UploadCentroidKeys::quality, &req.quality);
if (result != RETURN_OK) {
sif::warning << "StarTrackerHandler::prepareUploadCentroidCommand: The key "
<< StarTracker::UploadCentroidKeys::quality << " does not exist" << std::endl;
return result;
}
uint32_t length = 0;
arc_pack_uploadcentroid_action_req(&req, commandBuffer, &length);
dataLinkLayer.encodeFrame(commandBuffer, length);
rawPacket = dataLinkLayer.getEncodedFrame();
rawPacketLen = dataLinkLayer.getEncodedLength();
uploadCentroid.rememberId = req.id;
return result;
}
void StarTrackerHandler::prepareTimeRequest() { void StarTrackerHandler::prepareTimeRequest() {
uint32_t length = 0; uint32_t length = 0;
arc_tm_pack_time_req(commandBuffer, &length); arc_tm_pack_time_req(commandBuffer, &length);
@ -1293,6 +1600,55 @@ ReturnValue_t StarTrackerHandler::prepareParamCommand(const uint8_t* commandData
return RETURN_OK; return RETURN_OK;
} }
ReturnValue_t StarTrackerHandler::prepareDownloadMatchedStarCommand(const uint8_t* commandData,
size_t commandDataLen) {
if (commandDataLen != DownloadMatchedStarCmd::LENGTH) {
return INVALID_LENGTH;
}
struct DownloadMatchedStarActionRequest req;
req.id = *commandData;
uint32_t length = 0;
arc_pack_downloadmatchedstar_action_req(&req, commandBuffer, &length);
dataLinkLayer.encodeFrame(commandBuffer, length);
rawPacket = dataLinkLayer.getEncodedFrame();
rawPacketLen = dataLinkLayer.getEncodedLength();
return RETURN_OK;
}
ReturnValue_t StarTrackerHandler::prepareDownloadDbImageCommand(const uint8_t* commandData,
size_t commandDataLen) {
if (commandDataLen != DownloadDbImageCmd::LENGTH) {
return INVALID_LENGTH;
}
struct DownloadDBImageActionRequest req;
req.id = *commandData;
uint32_t length = 0;
arc_pack_downloaddbimage_action_req(&req, commandBuffer, &length);
dataLinkLayer.encodeFrame(commandBuffer, length);
rawPacket = dataLinkLayer.getEncodedFrame();
rawPacketLen = dataLinkLayer.getEncodedLength();
return RETURN_OK;
}
ReturnValue_t StarTrackerHandler::prepareDownloadBlobPixelCommand(const uint8_t* commandData,
size_t commandDataLen) {
if (commandDataLen != DownloadBlobPixCmd::LENGTH) {
return INVALID_LENGTH;
}
struct DownloadBlobPixelActionRequest req;
req.id = *commandData;
req.type = *(commandData + 1);
if ((req.type != DownloadBlobPixCmd::NORMAL) && (req.type != DownloadBlobPixCmd::FAST)) {
return INVALID_TYPE;
}
uint32_t length = 0;
arc_pack_downloadblobpixel_action_req(&req, commandBuffer, &length);
dataLinkLayer.encodeFrame(commandBuffer, length);
rawPacket = dataLinkLayer.getEncodedFrame();
rawPacketLen = dataLinkLayer.getEncodedLength();
return RETURN_OK;
}
ReturnValue_t StarTrackerHandler::handleSetParamReply() { ReturnValue_t StarTrackerHandler::handleSetParamReply() {
const uint8_t* reply = dataLinkLayer.getReply(); const uint8_t* reply = dataLinkLayer.getReply();
uint8_t status = *(reply + STATUS_OFFSET); uint8_t status = *(reply + STATUS_OFFSET);
@ -1316,7 +1672,7 @@ ReturnValue_t StarTrackerHandler::handleActionReply() {
uint8_t status = *(reply + STATUS_OFFSET); uint8_t status = *(reply + STATUS_OFFSET);
if (status != StarTracker::STATUS_OK) { if (status != StarTracker::STATUS_OK) {
sif::warning << "StarTrackerHandler::handleActionReply: Failed to execute action " sif::warning << "StarTrackerHandler::handleActionReply: Failed to execute action "
<< " command with action ID " << "command with action ID "
<< static_cast<unsigned int>(*(reply + ACTION_ID_OFFSET)) << static_cast<unsigned int>(*(reply + ACTION_ID_OFFSET))
<< " and status "<< static_cast<unsigned int>(status) << std::endl; << " and status "<< static_cast<unsigned int>(status) << std::endl;
return ACTION_FAILED; return ACTION_FAILED;
@ -1324,6 +1680,19 @@ ReturnValue_t StarTrackerHandler::handleActionReply() {
return RETURN_OK; return RETURN_OK;
} }
ReturnValue_t StarTrackerHandler::handleUploadCentroidReply() {
ReturnValue_t result = RETURN_OK;
result = handleActionReply();
if (result != RETURN_OK) {
return result;
}
const uint8_t* reply = dataLinkLayer.getReply();
if (*(reply + ACTION_DATA_OFFSET) != uploadCentroid.rememberId) {
return UPLOAD_CENTROID_ID_MISMATCH;
}
return RETURN_OK;
}
ReturnValue_t StarTrackerHandler::handleEraseReply() { ReturnValue_t StarTrackerHandler::handleEraseReply() {
ReturnValue_t result = RETURN_OK; ReturnValue_t result = RETURN_OK;
result = handleActionReply(); result = handleActionReply();
@ -1422,7 +1791,7 @@ ReturnValue_t StarTrackerHandler::handleTm(LocalPoolDataSetBase& dataset, size_t
if(status != StarTracker::STATUS_OK) { if(status != StarTracker::STATUS_OK) {
sif::warning << "StarTrackerHandler::handleTm: Reply error: " sif::warning << "StarTrackerHandler::handleTm: Reply error: "
<< static_cast<unsigned int>(status) << std::endl; << static_cast<unsigned int>(status) << std::endl;
return TM_REPLY_ERROR; return REPLY_ERROR;
} }
result = dataset.read(TIMEOUT_TYPE, MUTEX_TIMEOUT); result = dataset.read(TIMEOUT_TYPE, MUTEX_TIMEOUT);
if (result != RETURN_OK) { if (result != RETURN_OK) {
@ -1447,6 +1816,37 @@ ReturnValue_t StarTrackerHandler::handleTm(LocalPoolDataSetBase& dataset, size_t
return result; return result;
} }
ReturnValue_t StarTrackerHandler::handleActionReplySet(LocalPoolDataSetBase& dataset, size_t size) {
ReturnValue_t result = RETURN_OK;
uint8_t status = *(dataLinkLayer.getReply() + STATUS_OFFSET);
if(status != StarTracker::STATUS_OK) {
sif::warning << "StarTrackerHandler::handleActionReplySet: Reply error: "
<< static_cast<unsigned int>(status) << std::endl;
return REPLY_ERROR;
}
result = dataset.read(TIMEOUT_TYPE, MUTEX_TIMEOUT);
if (result != RETURN_OK) {
return result;
}
const uint8_t* reply = dataLinkLayer.getReply() + ACTION_DATA_OFFSET;
dataset.setValidityBufferGeneration(false);
result = dataset.deSerialize(&reply, &size, SerializeIF::Endianness::LITTLE);
if (result != RETURN_OK) {
sif::warning << "StarTrackerHandler::handleActionReplySet Deserialization failed"
<< std::endl;
}
dataset.setValidityBufferGeneration(true);
dataset.setValidity(true, true);
result = dataset.commit(TIMEOUT_TYPE, MUTEX_TIMEOUT);
if (result != RETURN_OK) {
return result;
}
#if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_STARTRACKER == 1
dataset.printSet();
#endif
return result;
}
void StarTrackerHandler::handleStartup(const uint8_t* parameterId) { void StarTrackerHandler::handleStartup(const uint8_t* parameterId) {
switch(*parameterId) { switch(*parameterId) {
case (StarTracker::ID::LIMITS): { case (StarTracker::ID::LIMITS): {

View File

@ -111,8 +111,8 @@ private:
static const ReturnValue_t FILENAME_TOO_LONG = MAKE_RETURN_CODE(0xAC); static const ReturnValue_t FILENAME_TOO_LONG = MAKE_RETURN_CODE(0xAC);
//! [EXPORT] : [COMMENT] Received version reply with invalid program ID //! [EXPORT] : [COMMENT] Received version reply with invalid program ID
static const ReturnValue_t INVALID_PROGRAM = MAKE_RETURN_CODE(0xAD); static const ReturnValue_t INVALID_PROGRAM = MAKE_RETURN_CODE(0xAD);
//! [EXPORT] : [COMMENT] Status field of tm reply signals error //! [EXPORT] : [COMMENT] Status field reply signals error
static const ReturnValue_t TM_REPLY_ERROR = MAKE_RETURN_CODE(0xAE); static const ReturnValue_t REPLY_ERROR = MAKE_RETURN_CODE(0xAE);
//! [EXPORT] : [COMMENT] Status field of contrast reply signals error //! [EXPORT] : [COMMENT] Status field of contrast reply signals error
static const ReturnValue_t CONTRAST_REQ_FAILED = MAKE_RETURN_CODE(0xAE); static const ReturnValue_t CONTRAST_REQ_FAILED = MAKE_RETURN_CODE(0xAE);
//! [EXPORT] : [COMMENT] Received command which is too short (some data is missing for proper execution) //! [EXPORT] : [COMMENT] Received command which is too short (some data is missing for proper execution)
@ -125,6 +125,12 @@ private:
static const ReturnValue_t ADDRESS_MISMATCH = MAKE_RETURN_CODE(0xB2); static const ReturnValue_t ADDRESS_MISMATCH = MAKE_RETURN_CODE(0xB2);
//! [EXPORT] : [COMMENT] Length field mismatch between send and received data //! [EXPORT] : [COMMENT] Length field mismatch between send and received data
static const ReturnValue_t lENGTH_MISMATCH = MAKE_RETURN_CODE(0xB3); static const ReturnValue_t lENGTH_MISMATCH = MAKE_RETURN_CODE(0xB3);
//! [EXPORT] : [COMMENT] Specified file does not exist
static const ReturnValue_t FILE_NOT_EXISTS = MAKE_RETURN_CODE(0xB4);
//! [EXPORT] : [COMMENT] Reply to upload centroid does not match commanded centroid id
static const ReturnValue_t UPLOAD_CENTROID_ID_MISMATCH = MAKE_RETURN_CODE(0xB5);
//! [EXPORT] : [COMMENT] Download blob pixel command has invalid type field
static const ReturnValue_t INVALID_TYPE = MAKE_RETURN_CODE(0xB6);
static const size_t MAX_PATH_SIZE = 50; static const size_t MAX_PATH_SIZE = 50;
static const size_t MAX_FILE_NAME = 30; static const size_t MAX_FILE_NAME = 30;
@ -190,6 +196,45 @@ private:
ChecksumCmd checksumCmd; ChecksumCmd checksumCmd;
class SetTimeCmd {
public:
static const uint8_t LENGTH = 8;
};
class DownloadCentroidCmd {
public:
static const uint8_t LENGTH = 1;
};
class UploadCentroid {
public:
uint8_t rememberId = 0;
};
UploadCentroid uploadCentroid;
class DownloadMatchedStarCmd {
public:
static const uint8_t LENGTH = 1;
};
class DownloadDbImageCmd {
public:
static const uint8_t LENGTH = 1;
};
class DownloadBlobPixCmd {
public:
static const uint8_t LENGTH = 2;
static const uint8_t NORMAL = 0;
static const uint8_t FAST = 1;
};
class FpgaDownloadCmd {
public:
static const uint8_t MIN_LENGTH = 10;
};
MessageQueueIF* eventQueue = nullptr; MessageQueueIF* eventQueue = nullptr;
ArcsecDatalinkLayer dataLinkLayer; ArcsecDatalinkLayer dataLinkLayer;
@ -203,6 +248,10 @@ private:
StarTracker::HistogramSet histogramSet; StarTracker::HistogramSet histogramSet;
StarTracker::ContrastSet contrastSet; StarTracker::ContrastSet contrastSet;
StarTracker::ChecksumSet checksumSet; StarTracker::ChecksumSet checksumSet;
StarTracker::DownloadCentroidSet downloadCentroidSet;
StarTracker::DownloadMatchedStar downloadMatchedStar;
StarTracker::DownloadDBImage downloadDbImage;
StarTracker::DownloadBlobPixel downloadBlobPixel;
// Pointer to object responsible for uploading and downloading images to/from the star tracker // Pointer to object responsible for uploading and downloading images to/from the star tracker
StrHelper* strHelper = nullptr; StrHelper* strHelper = nullptr;
@ -289,6 +338,14 @@ private:
*/ */
ReturnValue_t executeWriteCommand(const uint8_t* commandData, size_t commandDataLen); ReturnValue_t executeWriteCommand(const uint8_t* commandData, size_t commandDataLen);
/**
* @brief Starts the execution of the fpga download command
*
* @param commandData Pointer to buffer with command data
* @param commandDataLen Size of received command
*/
ReturnValue_t executeFpgaDownloadCommand(const uint8_t* commandData, size_t commandDataLen);
/** /**
* @brief Extracts information for flash-read-command from TC data and starts execution of * @brief Extracts information for flash-read-command from TC data and starts execution of
* flash-read-procedure * flash-read-procedure
@ -321,6 +378,21 @@ private:
*/ */
ReturnValue_t prepareChecksumCommand(const uint8_t* commandData, size_t commandDataLen); ReturnValue_t prepareChecksumCommand(const uint8_t* commandData, size_t commandDataLen);
/**
* @brief Fills command buffer with command to set the unix time
*/
ReturnValue_t prepareSetTimeCommand(const uint8_t* commandData, size_t commandDataLen);
/**
* @brief Fills command buffer with command to request a centroid
*/
ReturnValue_t prepareDownloadCentroidCommand(const uint8_t* commandData, size_t commandDataLen);
/**
* @brief Fills command buffer with command to upload a centroid for testing purpose
*/
ReturnValue_t prepareUploadCentroidCommand(const uint8_t* commandData, size_t commandDataLen);
/** /**
* @brief Fills the command buffer with the command to take an image. * @brief Fills the command buffer with the command to take an image.
*/ */
@ -389,11 +461,39 @@ private:
ReturnValue_t prepareParamCommand(const uint8_t* commandData, size_t commandDataLen, ReturnValue_t prepareParamCommand(const uint8_t* commandData, size_t commandDataLen,
ArcsecJsonParamBase& paramSet); ArcsecJsonParamBase& paramSet);
/**
* @brief Fills command buffer with data to request matched star.
*/
ReturnValue_t prepareDownloadMatchedStarCommand(const uint8_t* commandData,
size_t commandDataLen);
/**
* @brief Fills command buffer with data to request matched star coordinates.
*/
ReturnValue_t prepareDownloadDbImageCommand(const uint8_t* commandData,
size_t commandDataLen);
/**
* @brief Fills command buffer with data to request output of the blob filter algorithm.
*/
ReturnValue_t prepareDownloadBlobPixelCommand(const uint8_t* commandData,
size_t commandDataLen);
/**
* @brief Handles action replies with datasets.
*/
ReturnValue_t handleActionReplySet(LocalPoolDataSetBase& dataset, size_t size);
/** /**
* @brief Default function to handle action replies * @brief Default function to handle action replies
*/ */
ReturnValue_t handleActionReply(); ReturnValue_t handleActionReply();
/**
* @brief Handles reply to upload centroid command
*/
ReturnValue_t handleUploadCentroidReply();
/** /**
* @brief Handles reply to erase command * @brief Handles reply to erase command
*/ */

View File

@ -74,6 +74,17 @@ ReturnValue_t StrHelper::performOperation(uint8_t operationCode) {
internalState = InternalState::IDLE; internalState = InternalState::IDLE;
break; break;
} }
case InternalState::DOWNLOAD_FPGA_IMAGE: {
result = performFpgaDownload();
if (result == RETURN_OK){
triggerEvent(FPGA_DOWNLOAD_SUCCESSFUL);
}
else {
triggerEvent(FPGA_DOWNLOAD_FAILED);
}
internalState = InternalState::IDLE;
break;
}
default: default:
sif::debug << "StrHelper::performOperation: Invalid state" << std::endl; sif::debug << "StrHelper::performOperation: Invalid state" << std::endl;
break; break;
@ -109,15 +120,15 @@ ReturnValue_t StrHelper::startImageUpload(std::string uploadImage_) {
return RETURN_OK; return RETURN_OK;
} }
ReturnValue_t StrHelper::startImageDownload(std::string downloadPath_) { ReturnValue_t StrHelper::startImageDownload(std::string downloadImagePath_) {
ReturnValue_t result = checkPath(downloadPath_); ReturnValue_t result = checkPath(downloadImagePath_);
if (result != RETURN_OK) { if (result != RETURN_OK) {
return result; return result;
} }
if(not std::filesystem::exists(downloadPath_)) { if(not std::filesystem::exists(downloadImagePath_)) {
return PATH_NOT_EXISTS; return PATH_NOT_EXISTS;
} }
downloadPath = downloadPath_; downloadImagePath = downloadImagePath_;
internalState = InternalState::DOWNLOAD_IMAGE; internalState = InternalState::DOWNLOAD_IMAGE;
terminate = false; terminate = false;
semaphore.release(); semaphore.release();
@ -173,19 +184,30 @@ ReturnValue_t StrHelper::startFlashRead(std::string flashReadPath_, uint8_t regi
return RETURN_OK; return RETURN_OK;
} }
ReturnValue_t StrHelper::startFpgaDownload(std::string path, uint32_t startPosition,
uint32_t length) {
fpgaDownload.path = path;
fpgaDownload.startPosition = startPosition;
fpgaDownload.length = length;
internalState = InternalState::DOWNLOAD_FPGA_IMAGE;
semaphore.release();
terminate = false;
return RETURN_OK;
}
ReturnValue_t StrHelper::performImageDownload() { ReturnValue_t StrHelper::performImageDownload() {
ReturnValue_t result; ReturnValue_t result;
struct DownloadActionRequest downloadReq; struct DownloadActionRequest downloadReq;
uint32_t size = 0; uint32_t size = 0;
uint32_t retries = 0; uint32_t retries = 0;
Timestamp timestamp; Timestamp timestamp;
std::string image = downloadPath + "/" + timestamp.str() + downloadImage ; std::string image = downloadImagePath + "/" + timestamp.str() + downloadImage ;
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;
} }
downloadReq.position = 0; downloadReq.position = 0;
while(downloadReq.position < LAST_POSITION) { while(downloadReq.position < ImageDownload::LAST_POSITION) {
if (terminate) { if (terminate) {
return RETURN_OK; return RETURN_OK;
} }
@ -200,7 +222,7 @@ ReturnValue_t StrHelper::performImageDownload() {
file.close(); file.close();
return result; return result;
} }
result = checkReply(); result = checkActionReply();
if (result != RETURN_OK) { if (result != RETURN_OK) {
if (retries < CONFIG_MAX_DOWNLOAD_RETRIES) { if (retries < CONFIG_MAX_DOWNLOAD_RETRIES) {
uartComIF->flushUartRxBuffer(comCookie); uartComIF->flushUartRxBuffer(comCookie);
@ -257,7 +279,7 @@ ReturnValue_t StrHelper::performImageUpload() {
if (result != RETURN_OK) { if (result != RETURN_OK) {
return RETURN_FAILED; return RETURN_FAILED;
} }
result = checkReply(); result = checkActionReply();
if (result != RETURN_OK) { if (result != RETURN_OK) {
return result; return result;
} }
@ -274,7 +296,7 @@ ReturnValue_t StrHelper::performImageUpload() {
if (result != RETURN_OK) { if (result != RETURN_OK) {
return RETURN_FAILED; return RETURN_FAILED;
} }
result = checkReply(); result = checkActionReply();
if (result != RETURN_OK) { if (result != RETURN_OK) {
return result; return result;
} }
@ -366,7 +388,7 @@ ReturnValue_t StrHelper::performFlashRead() {
file.close(); file.close();
return result; return result;
} }
result = checkReply(); result = checkActionReply();
if (result != RETURN_OK) { if (result != RETURN_OK) {
if (retries < CONFIG_MAX_DOWNLOAD_RETRIES) { if (retries < CONFIG_MAX_DOWNLOAD_RETRIES) {
uartComIF->flushUartRxBuffer(comCookie); uartComIF->flushUartRxBuffer(comCookie);
@ -395,6 +417,58 @@ ReturnValue_t StrHelper::performFlashRead() {
return RETURN_OK; return RETURN_OK;
} }
ReturnValue_t StrHelper::performFpgaDownload() {
ReturnValue_t result;
struct DownloadFPGAImageActionRequest req;
uint32_t size = 0;
uint32_t retries = 0;
Timestamp timestamp;
std::string image = fpgaDownload.path + "/" + timestamp.str() + fpgaDownload.fileName;
std::ofstream file(image, std::ios_base::app | std::ios_base::out);
if(not std::filesystem::exists(image)) {
return FILE_CREATION_FAILED;
}
req.pos = fpgaDownload.startPosition;
while(req.pos < fpgaDownload.length) {
if (terminate) {
return RETURN_OK;
}
if (fpgaDownload.length - req.pos >= FpgaDownload::MAX_DATA) {
req.length = FpgaDownload::MAX_DATA;
}
else {
req.length = fpgaDownload.length - req.pos;
}
arc_pack_downloadfpgaimage_action_req(&req, commandBuffer, &size);
result = sendAndRead(size, req.pos);
if (result != RETURN_OK) {
if (retries < CONFIG_MAX_DOWNLOAD_RETRIES) {
uartComIF->flushUartRxBuffer(comCookie);
retries++;
continue;
}
file.close();
return result;
}
result = checkFpgaDownloadReply(req.pos, req.length);
if (result != RETURN_OK) {
if (retries < CONFIG_MAX_DOWNLOAD_RETRIES) {
uartComIF->flushUartRxBuffer(comCookie);
retries++;
continue;
}
file.close();
return result;
}
file.write(reinterpret_cast<const char*>(datalinkLayer.getReply() + FpgaDownload::DATA_OFFSET),
req.length);
req.pos += req.length;
retries = 0;
}
file.close();
return RETURN_OK;
}
ReturnValue_t StrHelper::sendAndRead(size_t size, uint32_t parameter) { ReturnValue_t StrHelper::sendAndRead(size_t size, uint32_t parameter) {
ReturnValue_t result = RETURN_OK; ReturnValue_t result = RETURN_OK;
ReturnValue_t decResult = RETURN_OK; ReturnValue_t decResult = RETURN_OK;
@ -451,16 +525,16 @@ ReturnValue_t StrHelper::sendAndRead(size_t size, uint32_t parameter) {
return RETURN_OK; return RETURN_OK;
} }
ReturnValue_t StrHelper::checkReply() { ReturnValue_t StrHelper::checkActionReply() {
uint8_t type = datalinkLayer.getReplyFrameType(); uint8_t type = datalinkLayer.getReplyFrameType();
if (type != TMTC_ACTIONREPLY) { if (type != TMTC_ACTIONREPLY) {
sif::warning << "StrHelper::checkReply: Received reply with invalid type ID" sif::warning << "StrHelper::checkActionReply: Received reply with invalid type ID"
<< std::endl; << std::endl;
return INVALID_TYPE_ID; return INVALID_TYPE_ID;
} }
uint8_t status = datalinkLayer.getStatusField(); uint8_t status = datalinkLayer.getStatusField();
if (status != ArcsecDatalinkLayer::STATUS_OK) { if (status != ArcsecDatalinkLayer::STATUS_OK) {
sif::warning << "StrHelper::checkReply: Status failure: " sif::warning << "StrHelper::checkActionReply: Status failure: "
<< static_cast<unsigned int>(status) << std::endl; << static_cast<unsigned int>(status) << std::endl;
return STATUS_ERROR; return STATUS_ERROR;
} }
@ -480,7 +554,7 @@ ReturnValue_t StrHelper::checkReplyPosition(uint32_t expectedPosition) {
ReturnValue_t StrHelper::checkFlashActionReply(uint8_t region_, uint32_t address_, ReturnValue_t StrHelper::checkFlashActionReply(uint8_t region_, uint32_t address_,
uint16_t length_) { uint16_t length_) {
ReturnValue_t result = RETURN_OK; ReturnValue_t result = RETURN_OK;
result = checkReply(); result = checkActionReply();
if (result != RETURN_OK) { if (result != RETURN_OK) {
return result; return result;
} }
@ -494,6 +568,7 @@ ReturnValue_t StrHelper::checkFlashActionReply(uint8_t region_, uint32_t address
if (result != RETURN_OK) { if (result != RETURN_OK) {
sif::warning << "StrHelper::checkFlashActionReply: Deserialization of address failed" sif::warning << "StrHelper::checkFlashActionReply: Deserialization of address failed"
<< std::endl; << std::endl;
return result;
} }
uint16_t length; uint16_t length;
size = sizeof(length); size = sizeof(length);
@ -516,6 +591,35 @@ ReturnValue_t StrHelper::checkFlashActionReply(uint8_t region_, uint32_t address
return RETURN_OK; return RETURN_OK;
} }
ReturnValue_t StrHelper::checkFpgaDownloadReply(uint32_t expectedPosition,
uint32_t expectedLength) {
ReturnValue_t result = RETURN_OK;
result = checkActionReply();
if (result != RETURN_OK) {
return result;
}
const uint8_t* data = datalinkLayer.getReply() + FpgaDownload::POSITION_OFFSET;
uint32_t position;
size_t size = sizeof(position);
result = SerializeAdapter::deSerialize(&position, &data, &size,
SerializeIF::Endianness::LITTLE);
if (result != RETURN_OK) {
sif::warning << "StrHelper::checkFpgaDownloadReply: Deserialization of position failed"
<< std::endl;
return result;
}
uint32_t length;
size = sizeof(length);
result = SerializeAdapter::deSerialize(&length, &data, &size,
SerializeIF::Endianness::LITTLE);
if (result != RETURN_OK) {
sif::warning << "StrHelper::checkFpgaDownloadReply: Deserialization of length failed"
<< std::endl;
return result;
}
return RETURN_OK;
}
ReturnValue_t StrHelper::checkPath(std::string name) { ReturnValue_t StrHelper::checkPath(std::string name) {
if (name.substr(0, sizeof(SdCardManager::SD_0_MOUNT_POINT)) if (name.substr(0, sizeof(SdCardManager::SD_0_MOUNT_POINT))
== std::string(SdCardManager::SD_0_MOUNT_POINT)) { == std::string(SdCardManager::SD_0_MOUNT_POINT)) {

View File

@ -28,7 +28,7 @@ public:
static const Event IMAGE_UPLOAD_FAILED = MAKE_EVENT(0, severity::LOW); static const Event IMAGE_UPLOAD_FAILED = MAKE_EVENT(0, severity::LOW);
//! [EXPORT] : [COMMENT] Image download failed //! [EXPORT] : [COMMENT] Image download failed
static const Event IMAGE_DOWNLOAD_FAILED = MAKE_EVENT(1, severity::LOW); static const Event IMAGE_DOWNLOAD_FAILED = MAKE_EVENT(1, severity::LOW);
//! [EXPORT] : [COMMENT] Uploading image to star tracker was successful //! [EXPORT] : [COMMENT] Uploading image to star tracker was successfulop
static const Event IMAGE_UPLOAD_SUCCESSFUL = MAKE_EVENT(2, severity::LOW); static const Event IMAGE_UPLOAD_SUCCESSFUL = MAKE_EVENT(2, severity::LOW);
//! [EXPORT] : [COMMENT] Image download was successful //! [EXPORT] : [COMMENT] Image download was successful
static const Event IMAGE_DOWNLOAD_SUCCESSFUL = MAKE_EVENT(3, severity::LOW); static const Event IMAGE_DOWNLOAD_SUCCESSFUL = MAKE_EVENT(3, severity::LOW);
@ -40,35 +40,43 @@ public:
static const Event FLASH_WRITE_FAILED = MAKE_EVENT(6, severity::LOW); static const Event FLASH_WRITE_FAILED = MAKE_EVENT(6, severity::LOW);
//! [EXPORT] : [COMMENT] Flash read procedure failed //! [EXPORT] : [COMMENT] Flash read procedure failed
static const Event FLASH_READ_FAILED = MAKE_EVENT(7, severity::LOW); static const Event FLASH_READ_FAILED = MAKE_EVENT(7, severity::LOW);
//! [EXPORT] : [COMMENT] Download of FPGA image successful
static const Event FPGA_DOWNLOAD_SUCCESSFUL = MAKE_EVENT(8, severity::LOW);
//! [EXPORT] : [COMMENT] Download of FPGA image failed
static const Event FPGA_DOWNLOAD_FAILED = MAKE_EVENT(9, severity::LOW);
//! [EXPORT] : [COMMENT] Upload of FPGA image successful
static const Event FPGA_UPLOAD_SUCCESSFUL = MAKE_EVENT(10, severity::LOW);
//! [EXPORT] : [COMMENT] Upload of FPGA image failed
static const Event FPGA_UPLOAD_FAILED = MAKE_EVENT(11, severity::LOW);
//! [EXPORT] : [COMMENT] Failed to read communication interface reply data //! [EXPORT] : [COMMENT] Failed to read communication interface reply data
//!P1: Return code of failed communication interface read call //!P1: Return code of failed communication interface read call
//!P1: Upload/download position for which the read call failed //!P1: Upload/download position for which the read call failed
static const Event STR_HELPER_READING_REPLY_FAILED = MAKE_EVENT(8, severity::LOW); static const Event STR_HELPER_READING_REPLY_FAILED = MAKE_EVENT(12, severity::LOW);
//! [EXPORT] : [COMMENT] Unexpected stop of decoding sequence //! [EXPORT] : [COMMENT] Unexpected stop of decoding sequence
//!P1: Return code of failed communication interface read call //!P1: Return code of failed communication interface read call
//!P1: Upload/download position for which the read call failed //!P1: Upload/download position for which the read call failed
static const Event STR_HELPER_COM_ERROR = MAKE_EVENT(9, severity::LOW); static const Event STR_HELPER_COM_ERROR = MAKE_EVENT(13, severity::LOW);
//! [EXPORT] : [COMMENT] Star tracker did not send replies (maybe device is powered off) //! [EXPORT] : [COMMENT] Star tracker did not send replies (maybe device is powered off)
//!P1: Position of upload or download packet for which no reply was sent //!P1: Position of upload or download packet for which no reply was sent
static const Event STR_HELPER_NO_REPLY = MAKE_EVENT(10, severity::LOW); static const Event STR_HELPER_NO_REPLY = MAKE_EVENT(14, severity::LOW);
//! [EXPORT] : [COMMENT] Error during decoding of received reply occurred //! [EXPORT] : [COMMENT] Error during decoding of received reply occurred
//P1: Return value of decoding function //P1: Return value of decoding function
//P2: Position of upload/download packet, or address of flash write/read request //P2: Position of upload/download packet, or address of flash write/read request
static const Event STR_HELPER_DEC_ERROR = MAKE_EVENT(11, severity::LOW); static const Event STR_HELPER_DEC_ERROR = MAKE_EVENT(15, severity::LOW);
//! [EXPORT] : [COMMENT] Position mismatch //! [EXPORT] : [COMMENT] Position mismatch
//! P1: The expected position and thus the position for which the image upload/download failed //! P1: The expected position and thus the position for which the image upload/download failed
static const Event POSITION_MISMATCH = MAKE_EVENT(12, severity::LOW); static const Event POSITION_MISMATCH = MAKE_EVENT(16, severity::LOW);
//! [EXPORT] : [COMMENT] Specified file does not exist //! [EXPORT] : [COMMENT] Specified file does not exist
//!P1: Internal state of str helper //!P1: Internal state of str helper
static const Event STR_HELPER_FILE_NOT_EXISTS = MAKE_EVENT(13, severity::LOW); static const Event STR_HELPER_FILE_NOT_EXISTS = MAKE_EVENT(17, severity::LOW);
//! [EXPORT] : [COMMENT] Sending packet to star tracker failed //! [EXPORT] : [COMMENT] Sending packet to star tracker failed
//!P1: Return code of communication interface sendMessage function //!P1: Return code of communication interface sendMessage function
//!P2: Position of upload/download packet, or address of flash write/read request for which sending failed //!P2: Position of upload/download packet, or address of flash write/read request for which sending failed
static const Event STR_HELPER_SENDING_PACKET_FAILED = MAKE_EVENT(14, severity::LOW); static const Event STR_HELPER_SENDING_PACKET_FAILED = MAKE_EVENT(18, severity::LOW);
//! [EXPORT] : [COMMENT] Communication interface requesting reply failed //! [EXPORT] : [COMMENT] Communication interface requesting reply failed
//!P1: Return code of failed request //!P1: Return code of failed request
//!P1: Upload/download position, or address of flash write/read request for which transmission failed //!P1: Upload/download position, or address of flash write/read request for which transmission failed
static const Event STR_HELPER_REQUESTING_MSG_FAILED = MAKE_EVENT(15, severity::LOW); static const Event STR_HELPER_REQUESTING_MSG_FAILED = MAKE_EVENT(19, severity::LOW);
StrHelper(object_id_t objectId); StrHelper(object_id_t objectId);
virtual ~StrHelper(); virtual ~StrHelper();
@ -92,7 +100,7 @@ public:
* *
* @param Name of the image which will be created * @param Name of the image which will be created
*/ */
ReturnValue_t startImageDownload(std::string downloadPath_); ReturnValue_t startImageDownload(std::string downloadImagePath_);
/** /**
* @brief Starts the flash write procedure * @brief Starts the flash write procedure
@ -115,6 +123,16 @@ public:
ReturnValue_t startFlashRead(std::string flashReadPath_, uint8_t region, ReturnValue_t startFlashRead(std::string flashReadPath_, uint8_t region,
uint32_t address, uint32_t length); uint32_t address, uint32_t length);
/**
* @brief Starts the download of the FPGA image
*
* @param path The path where the file with the downloaded data will be created
* @param startPosition Offset in fpga image to read from
* @param length Number of bytes to dwonload from the FPGA image
*
*/
ReturnValue_t startFpgaDownload(std::string path, uint32_t startPosition, uint32_t length);
/** /**
* @brief Can be used to interrupt a running data transfer. * @brief Can be used to interrupt a running data transfer.
*/ */
@ -156,7 +174,28 @@ private:
// Size of one image part which can be sent per action request // Size of one image part which can be sent per action request
static const size_t SIZE_IMAGE_PART = 1024; static const size_t SIZE_IMAGE_PART = 1024;
static const uint32_t LAST_POSITION = 4095; class ImageDownload {
public:
static const uint32_t LAST_POSITION = 4095;
};
class FpgaDownload {
public:
static const uint16_t MAX_DATA = 1024;
static const uint8_t POSITION_OFFSET = 3;
static const uint8_t LENGTH_OFFSET = 7;
static const uint8_t DATA_OFFSET = 11;
// Start position of fpga image part to download
uint32_t startPosition = 0;
// Length of image part to download
uint32_t length = 0;
// Path where downloaded FPGA image will be stored
std::string path;
// Name of file containing downloaded FPGA image
std::string fileName = "fpgaimage.bin";
};
FpgaDownload fpgaDownload;
static const uint32_t MAX_POLLS = 10000; static const uint32_t MAX_POLLS = 10000;
@ -175,7 +214,9 @@ private:
UPLOAD_IMAGE, UPLOAD_IMAGE,
DOWNLOAD_IMAGE, DOWNLOAD_IMAGE,
FLASH_WRITE, FLASH_WRITE,
FLASH_READ FLASH_READ,
DOWNLOAD_FPGA_IMAGE,
UPLOAD_FPGA_IMAGE
}; };
InternalState internalState = InternalState::IDLE; InternalState internalState = InternalState::IDLE;
@ -187,7 +228,7 @@ private:
// Name including absolute path of image to upload // Name including absolute path of image to upload
std::string uploadImage; std::string uploadImage;
// Path where the downloaded image will be stored // Path where the downloaded image will be stored
std::string downloadPath; std::string downloadImagePath;
// File which contains data to write when executing the flash write command // File which contains data to write when executing the flash write command
std::string flashWriteFile; std::string flashWriteFile;
// Path where the file containing the read data will be stored // Path where the file containing the read data will be stored
@ -255,6 +296,12 @@ private:
*/ */
ReturnValue_t performFlashRead(); ReturnValue_t performFlashRead();
/**
* @brief Performs the download of the FPGA image which requires to be slip over multiple
* action requests.
*/
ReturnValue_t performFpgaDownload();
/** /**
* @brief Sends packet to the star tracker and reads reply by using the communication * @brief Sends packet to the star tracker and reads reply by using the communication
* interface * interface
@ -267,11 +314,11 @@ private:
ReturnValue_t sendAndRead(size_t size, uint32_t parameter); ReturnValue_t sendAndRead(size_t size, uint32_t parameter);
/** /**
* @brief Checks the reply header (type id and status fields) * @brief Checks the header (type id and status fields) of the action reply
* *
* @return RETURN_OK if reply confirms success of packet transfer, otherwise REUTRN_FAILED * @return RETURN_OK if reply confirms success of packet transfer, otherwise REUTRN_FAILED
*/ */
ReturnValue_t checkReply(); ReturnValue_t checkActionReply();
/** /**
* @brief Checks the position field in a star tracker upload/download reply. * @brief Checks the position field in a star tracker upload/download reply.
@ -290,6 +337,14 @@ private:
*/ */
ReturnValue_t checkFlashActionReply(uint8_t region_, uint32_t address_, uint16_t length_); ReturnValue_t checkFlashActionReply(uint8_t region_, uint32_t address_, uint16_t length_);
/**
* @brief Checks the reply to the fpga download request
*
* @param expectedPosition The expected position value in the reply
* @param expectedLength The expected length field in the reply
*/
ReturnValue_t checkFpgaDownloadReply(uint32_t expectedPosition, uint32_t expectedLength);
/** /**
* @brief Checks if a path points to an sd card and whether the SD card is monuted. * @brief Checks if a path points to an sd card and whether the SD card is monuted.
* *

View File

@ -25,6 +25,7 @@ enum commonClassIds: uint8_t {
PDEC_HANDLER, //PDEC PDEC_HANDLER, //PDEC
CCSDS_HANDLER, //CCSDS CCSDS_HANDLER, //CCSDS
ARCSEC_JSON_BASE, //JSONBASE ARCSEC_JSON_BASE, //JSONBASE
NVM_PARAM_BASE, //NVMB
COMMON_CLASS_ID_END // [EXPORT] : [END] COMMON_CLASS_ID_END // [EXPORT] : [END]
}; };

View File

@ -120,19 +120,21 @@
11904;BIT_LOCK_PDEC;INFO;Bit lock detected (data valid);C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/linux/obc/PdecHandler.h 11904;BIT_LOCK_PDEC;INFO;Bit lock detected (data valid);C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/linux/obc/PdecHandler.h
12000;IMAGE_UPLOAD_FAILED;LOW;Image upload failed;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/devices/startracker/StrHelper.h 12000;IMAGE_UPLOAD_FAILED;LOW;Image upload failed;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/devices/startracker/StrHelper.h
12001;IMAGE_DOWNLOAD_FAILED;LOW;Image download failed;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/devices/startracker/StrHelper.h 12001;IMAGE_DOWNLOAD_FAILED;LOW;Image download failed;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/devices/startracker/StrHelper.h
12002;IMAGE_UPLOAD_SUCCESSFUL;LOW;Uploading image to star tracker was successful;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/devices/startracker/StrHelper.h 12002;IMAGE_UPLOAD_SUCCESSFUL;LOW;Uploading image to star tracker was successfulop;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/devices/startracker/StrHelper.h
12003;IMAGE_DOWNLOAD_SUCCESSFUL;LOW;Image download was successful;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/devices/startracker/StrHelper.h 12003;IMAGE_DOWNLOAD_SUCCESSFUL;LOW;Image download was successful;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/devices/startracker/StrHelper.h
12004;FLASH_WRITE_SUCCESSFUL;LOW;Finished flash write procedure successfully;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/devices/startracker/StrHelper.h 12004;FLASH_WRITE_SUCCESSFUL;LOW;Finished flash write procedure successfully;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/devices/startracker/StrHelper.h
12005;FLASH_READ_SUCCESSFUL;LOW;Finished flash read procedure successfully;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/devices/startracker/StrHelper.h 12005;FLASH_READ_SUCCESSFUL;LOW;Finished flash read procedure successfully;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/devices/startracker/StrHelper.h
12006;FLASH_WRITE_FAILED;LOW;Flash write procedure failed;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/devices/startracker/StrHelper.h 12006;FLASH_WRITE_FAILED;LOW;Flash write procedure failed;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/devices/startracker/StrHelper.h
12007;FLASH_READ_FAILED;LOW;Flash read procedure failed;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/devices/startracker/StrHelper.h 12007;FLASH_READ_FAILED;LOW;Flash read procedure failed;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/devices/startracker/StrHelper.h
12008;STR_HELPER_READING_REPLY_FAILED;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/devices/startracker/StrHelper.h 12008;FPGA_DOWNLOAD_SUCCESSFUL;LOW;Download of FPGA image successful;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/devices/startracker/StrHelper.h
12009;STR_HELPER_COM_ERROR;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/devices/startracker/StrHelper.h 12009;FPGA_DOWNLOAD_FAILED;LOW;Download of FPGA image failed;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/devices/startracker/StrHelper.h
12010;STR_HELPER_NO_REPLY;LOW;Star tracker did not send replies (maybe device is powered off)P1: Position of upload or download packet for which no reply was sent;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/devices/startracker/StrHelper.h 12010;FPGA_UPLOAD_SUCCESSFUL;LOW;Upload of FPGA image successful;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/devices/startracker/StrHelper.h
12011;INVALID_TYPE_ID;LOW;Received reply with invalid type ID;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/devices/startracker/StrHelper.h 12011;FPGA_UPLOAD_FAILED;LOW;Upload of FPGA image failed;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/devices/startracker/StrHelper.h
12012;STATUS_ERROR;LOW;Status field in reply signals error;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/devices/startracker/StrHelper.h 12012;STR_HELPER_READING_REPLY_FAILED;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/devices/startracker/StrHelper.h
12013;STR_HELPER_DEC_ERROR;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/devices/startracker/StrHelper.h 12013;STR_HELPER_COM_ERROR;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/devices/startracker/StrHelper.h
12014;POSITION_MISMATCH;LOW;Position mismatch P1: The expected position and thus the position for which the image upload/download failed;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/devices/startracker/StrHelper.h 12014;STR_HELPER_NO_REPLY;LOW;Star tracker did not send replies (maybe device is powered off)P1: Position of upload or download packet for which no reply was sent;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/devices/startracker/StrHelper.h
12015;STR_HELPER_FILE_NOT_EXISTS;LOW;Specified file does not existP1: Internal state of str helper;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/devices/startracker/StrHelper.h 12015;STR_HELPER_DEC_ERROR;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/devices/startracker/StrHelper.h
12016;STR_HELPER_SENDING_PACKET_FAILED;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/devices/startracker/StrHelper.h 12016;POSITION_MISMATCH;LOW;Position mismatch P1: The expected position and thus the position for which the image upload/download failed;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/devices/startracker/StrHelper.h
12017;STR_HELPER_REQUESTING_MSG_FAILED;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/devices/startracker/StrHelper.h 12017;STR_HELPER_FILE_NOT_EXISTS;LOW;Specified file does not existP1: Internal state of str helper;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/devices/startracker/StrHelper.h
12018;STR_HELPER_SENDING_PACKET_FAILED;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/devices/startracker/StrHelper.h
12019;STR_HELPER_REQUESTING_MSG_FAILED;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/devices/startracker/StrHelper.h

1 2200 STORE_SEND_WRITE_FAILED LOW C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/tmstorage/TmStoreBackendIF.h
120 11904 BIT_LOCK_PDEC INFO Bit lock detected (data valid) C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/linux/obc/PdecHandler.h
121 12000 IMAGE_UPLOAD_FAILED LOW Image upload failed C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/devices/startracker/StrHelper.h
122 12001 IMAGE_DOWNLOAD_FAILED LOW Image download failed C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/devices/startracker/StrHelper.h
123 12002 IMAGE_UPLOAD_SUCCESSFUL LOW Uploading image to star tracker was successful Uploading image to star tracker was successfulop C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/devices/startracker/StrHelper.h
124 12003 IMAGE_DOWNLOAD_SUCCESSFUL LOW Image download was successful C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/devices/startracker/StrHelper.h
125 12004 FLASH_WRITE_SUCCESSFUL LOW Finished flash write procedure successfully C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/devices/startracker/StrHelper.h
126 12005 FLASH_READ_SUCCESSFUL LOW Finished flash read procedure successfully C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/devices/startracker/StrHelper.h
127 12006 FLASH_WRITE_FAILED LOW Flash write procedure failed C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/devices/startracker/StrHelper.h
128 12007 FLASH_READ_FAILED LOW Flash read procedure failed C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/devices/startracker/StrHelper.h
129 12008 STR_HELPER_READING_REPLY_FAILED FPGA_DOWNLOAD_SUCCESSFUL LOW Download of FPGA image successful C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/devices/startracker/StrHelper.h
130 12009 STR_HELPER_COM_ERROR FPGA_DOWNLOAD_FAILED LOW Download of FPGA image failed C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/devices/startracker/StrHelper.h
131 12010 STR_HELPER_NO_REPLY FPGA_UPLOAD_SUCCESSFUL LOW Star tracker did not send replies (maybe device is powered off)P1: Position of upload or download packet for which no reply was sent Upload of FPGA image successful C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/devices/startracker/StrHelper.h
132 12011 INVALID_TYPE_ID FPGA_UPLOAD_FAILED LOW Received reply with invalid type ID Upload of FPGA image failed C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/devices/startracker/StrHelper.h
133 12012 STATUS_ERROR STR_HELPER_READING_REPLY_FAILED LOW Status field in reply signals error C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/devices/startracker/StrHelper.h
134 12013 STR_HELPER_DEC_ERROR STR_HELPER_COM_ERROR LOW C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/devices/startracker/StrHelper.h
135 12014 POSITION_MISMATCH STR_HELPER_NO_REPLY LOW Position mismatch P1: The expected position and thus the position for which the image upload/download failed Star tracker did not send replies (maybe device is powered off)P1: Position of upload or download packet for which no reply was sent C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/devices/startracker/StrHelper.h
136 12015 STR_HELPER_FILE_NOT_EXISTS STR_HELPER_DEC_ERROR LOW Specified file does not existP1: Internal state of str helper C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/devices/startracker/StrHelper.h
137 12016 STR_HELPER_SENDING_PACKET_FAILED POSITION_MISMATCH LOW Position mismatch P1: The expected position and thus the position for which the image upload/download failed C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/devices/startracker/StrHelper.h
138 12017 STR_HELPER_REQUESTING_MSG_FAILED STR_HELPER_FILE_NOT_EXISTS LOW Specified file does not existP1: Internal state of str helper C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/devices/startracker/StrHelper.h
139 12018 STR_HELPER_SENDING_PACKET_FAILED LOW C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/devices/startracker/StrHelper.h
140 12019 STR_HELPER_REQUESTING_MSG_FAILED LOW C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/devices/startracker/StrHelper.h

View File

@ -1,7 +1,7 @@
/** /**
* @brief Auto-generated event translation file. Contains 138 translations. * @brief Auto-generated event translation file. Contains 140 translations.
* @details * @details
* Generated on: 2021-12-21 17:08:50 * Generated on: 2021-12-29 20:24:08
*/ */
#include "translateEvents.h" #include "translateEvents.h"
@ -133,11 +133,13 @@ const char *FLASH_WRITE_SUCCESSFUL_STRING = "FLASH_WRITE_SUCCESSFUL";
const char *FLASH_READ_SUCCESSFUL_STRING = "FLASH_READ_SUCCESSFUL"; const char *FLASH_READ_SUCCESSFUL_STRING = "FLASH_READ_SUCCESSFUL";
const char *FLASH_WRITE_FAILED_STRING = "FLASH_WRITE_FAILED"; const char *FLASH_WRITE_FAILED_STRING = "FLASH_WRITE_FAILED";
const char *FLASH_READ_FAILED_STRING = "FLASH_READ_FAILED"; const char *FLASH_READ_FAILED_STRING = "FLASH_READ_FAILED";
const char *FPGA_DOWNLOAD_SUCCESSFUL_STRING = "FPGA_DOWNLOAD_SUCCESSFUL";
const char *FPGA_DOWNLOAD_FAILED_STRING = "FPGA_DOWNLOAD_FAILED";
const char *FPGA_UPLOAD_SUCCESSFUL_STRING = "FPGA_UPLOAD_SUCCESSFUL";
const char *FPGA_UPLOAD_FAILED_STRING = "FPGA_UPLOAD_FAILED";
const char *STR_HELPER_READING_REPLY_FAILED_STRING = "STR_HELPER_READING_REPLY_FAILED"; const char *STR_HELPER_READING_REPLY_FAILED_STRING = "STR_HELPER_READING_REPLY_FAILED";
const char *STR_HELPER_COM_ERROR_STRING = "STR_HELPER_COM_ERROR"; const char *STR_HELPER_COM_ERROR_STRING = "STR_HELPER_COM_ERROR";
const char *STR_HELPER_NO_REPLY_STRING = "STR_HELPER_NO_REPLY"; const char *STR_HELPER_NO_REPLY_STRING = "STR_HELPER_NO_REPLY";
const char *INVALID_TYPE_ID_STRING = "INVALID_TYPE_ID";
const char *STATUS_ERROR_STRING = "STATUS_ERROR";
const char *STR_HELPER_DEC_ERROR_STRING = "STR_HELPER_DEC_ERROR"; const char *STR_HELPER_DEC_ERROR_STRING = "STR_HELPER_DEC_ERROR";
const char *POSITION_MISMATCH_STRING = "POSITION_MISMATCH"; const char *POSITION_MISMATCH_STRING = "POSITION_MISMATCH";
const char *STR_HELPER_FILE_NOT_EXISTS_STRING = "STR_HELPER_FILE_NOT_EXISTS"; const char *STR_HELPER_FILE_NOT_EXISTS_STRING = "STR_HELPER_FILE_NOT_EXISTS";
@ -403,24 +405,28 @@ const char * translateEvents(Event event) {
case(12007): case(12007):
return FLASH_READ_FAILED_STRING; return FLASH_READ_FAILED_STRING;
case(12008): case(12008):
return STR_HELPER_READING_REPLY_FAILED_STRING; return FPGA_DOWNLOAD_SUCCESSFUL_STRING;
case(12009): case(12009):
return STR_HELPER_COM_ERROR_STRING; return FPGA_DOWNLOAD_FAILED_STRING;
case(12010): case(12010):
return STR_HELPER_NO_REPLY_STRING; return FPGA_UPLOAD_SUCCESSFUL_STRING;
case(12011): case(12011):
return INVALID_TYPE_ID_STRING; return FPGA_UPLOAD_FAILED_STRING;
case(12012): case(12012):
return STATUS_ERROR_STRING; return STR_HELPER_READING_REPLY_FAILED_STRING;
case(12013): case(12013):
return STR_HELPER_DEC_ERROR_STRING; return STR_HELPER_COM_ERROR_STRING;
case(12014): case(12014):
return POSITION_MISMATCH_STRING; return STR_HELPER_NO_REPLY_STRING;
case(12015): case(12015):
return STR_HELPER_FILE_NOT_EXISTS_STRING; return STR_HELPER_DEC_ERROR_STRING;
case(12016): case(12016):
return STR_HELPER_SENDING_PACKET_FAILED_STRING; return POSITION_MISMATCH_STRING;
case(12017): case(12017):
return STR_HELPER_FILE_NOT_EXISTS_STRING;
case(12018):
return STR_HELPER_SENDING_PACKET_FAILED_STRING;
case(12019):
return STR_HELPER_REQUESTING_MSG_FAILED_STRING; return STR_HELPER_REQUESTING_MSG_FAILED_STRING;
default: default:
return "UNKNOWN_EVENT"; return "UNKNOWN_EVENT";

View File

@ -1,7 +1,7 @@
/** /**
* @brief Auto-generated event translation file. Contains 138 translations. * @brief Auto-generated event translation file. Contains 140 translations.
* @details * @details
* Generated on: 2021-12-21 17:08:50 * Generated on: 2021-12-29 20:24:08
*/ */
#include "translateEvents.h" #include "translateEvents.h"
@ -133,11 +133,13 @@ const char *FLASH_WRITE_SUCCESSFUL_STRING = "FLASH_WRITE_SUCCESSFUL";
const char *FLASH_READ_SUCCESSFUL_STRING = "FLASH_READ_SUCCESSFUL"; const char *FLASH_READ_SUCCESSFUL_STRING = "FLASH_READ_SUCCESSFUL";
const char *FLASH_WRITE_FAILED_STRING = "FLASH_WRITE_FAILED"; const char *FLASH_WRITE_FAILED_STRING = "FLASH_WRITE_FAILED";
const char *FLASH_READ_FAILED_STRING = "FLASH_READ_FAILED"; const char *FLASH_READ_FAILED_STRING = "FLASH_READ_FAILED";
const char *FPGA_DOWNLOAD_SUCCESSFUL_STRING = "FPGA_DOWNLOAD_SUCCESSFUL";
const char *FPGA_DOWNLOAD_FAILED_STRING = "FPGA_DOWNLOAD_FAILED";
const char *FPGA_UPLOAD_SUCCESSFUL_STRING = "FPGA_UPLOAD_SUCCESSFUL";
const char *FPGA_UPLOAD_FAILED_STRING = "FPGA_UPLOAD_FAILED";
const char *STR_HELPER_READING_REPLY_FAILED_STRING = "STR_HELPER_READING_REPLY_FAILED"; const char *STR_HELPER_READING_REPLY_FAILED_STRING = "STR_HELPER_READING_REPLY_FAILED";
const char *STR_HELPER_COM_ERROR_STRING = "STR_HELPER_COM_ERROR"; const char *STR_HELPER_COM_ERROR_STRING = "STR_HELPER_COM_ERROR";
const char *STR_HELPER_NO_REPLY_STRING = "STR_HELPER_NO_REPLY"; const char *STR_HELPER_NO_REPLY_STRING = "STR_HELPER_NO_REPLY";
const char *INVALID_TYPE_ID_STRING = "INVALID_TYPE_ID";
const char *STATUS_ERROR_STRING = "STATUS_ERROR";
const char *STR_HELPER_DEC_ERROR_STRING = "STR_HELPER_DEC_ERROR"; const char *STR_HELPER_DEC_ERROR_STRING = "STR_HELPER_DEC_ERROR";
const char *POSITION_MISMATCH_STRING = "POSITION_MISMATCH"; const char *POSITION_MISMATCH_STRING = "POSITION_MISMATCH";
const char *STR_HELPER_FILE_NOT_EXISTS_STRING = "STR_HELPER_FILE_NOT_EXISTS"; const char *STR_HELPER_FILE_NOT_EXISTS_STRING = "STR_HELPER_FILE_NOT_EXISTS";
@ -403,24 +405,28 @@ const char * translateEvents(Event event) {
case(12007): case(12007):
return FLASH_READ_FAILED_STRING; return FLASH_READ_FAILED_STRING;
case(12008): case(12008):
return STR_HELPER_READING_REPLY_FAILED_STRING; return FPGA_DOWNLOAD_SUCCESSFUL_STRING;
case(12009): case(12009):
return STR_HELPER_COM_ERROR_STRING; return FPGA_DOWNLOAD_FAILED_STRING;
case(12010): case(12010):
return STR_HELPER_NO_REPLY_STRING; return FPGA_UPLOAD_SUCCESSFUL_STRING;
case(12011): case(12011):
return INVALID_TYPE_ID_STRING; return FPGA_UPLOAD_FAILED_STRING;
case(12012): case(12012):
return STATUS_ERROR_STRING; return STR_HELPER_READING_REPLY_FAILED_STRING;
case(12013): case(12013):
return STR_HELPER_DEC_ERROR_STRING; return STR_HELPER_COM_ERROR_STRING;
case(12014): case(12014):
return POSITION_MISMATCH_STRING; return STR_HELPER_NO_REPLY_STRING;
case(12015): case(12015):
return STR_HELPER_FILE_NOT_EXISTS_STRING; return STR_HELPER_DEC_ERROR_STRING;
case(12016): case(12016):
return STR_HELPER_SENDING_PACKET_FAILED_STRING; return POSITION_MISMATCH_STRING;
case(12017): case(12017):
return STR_HELPER_FILE_NOT_EXISTS_STRING;
case(12018):
return STR_HELPER_SENDING_PACKET_FAILED_STRING;
case(12019):
return STR_HELPER_REQUESTING_MSG_FAILED_STRING; return STR_HELPER_REQUESTING_MSG_FAILED_STRING;
default: default:
return "UNKNOWN_EVENT"; return "UNKNOWN_EVENT";

View File

@ -7,7 +7,7 @@
#include <string> #include <string>
#include <filesystem> #include <filesystem>
class NVMParameterBase { class NVMParameterBase : public HasReturnvaluesIF {
public: public:
virtual~ NVMParameterBase() {} virtual~ NVMParameterBase() {}
@ -34,12 +34,18 @@ public:
ReturnValue_t setValue(std::string key, T value); ReturnValue_t setValue(std::string key, T value);
template<typename T> template<typename T>
T getValue(std::string key) const; ReturnValue_t getValue(std::string key, T* value) const;
void printKeys() const; void printKeys() const;
void print() const; void print() const;
private: private:
static const uint8_t INTERFACE_ID = CLASS_ID::NVM_PARAM_BASE;
//! [EXPORT] : [COMMENT] Specified key does not exist in json file
static const ReturnValue_t KEY_NOT_EXISTS = MAKE_RETURN_CODE(0xA0);
nlohmann::json json; nlohmann::json json;
std::vector<std::string> keys; std::vector<std::string> keys;
std::string fullName; std::string fullName;
@ -62,8 +68,12 @@ inline ReturnValue_t NVMParameterBase::setValue(std::string key, T value) {
} }
template<typename T> template<typename T>
inline T NVMParameterBase::getValue(std::string key) const { inline ReturnValue_t NVMParameterBase::getValue(std::string key, T* value) const {
return json[key]; if (!json.contains(key)) {
return KEY_NOT_EXISTS;
}
*value = json[key];
return RETURN_OK;
} }
#endif /* BSP_Q7S_CORE_NVMPARAMS_NVMPARAMIF_H_ */ #endif /* BSP_Q7S_CORE_NVMPARAMS_NVMPARAMIF_H_ */