Merge pull request 'meier/startracker' (#120) from meier/startracker into develop
All checks were successful
EIVE/eive-obsw/pipeline/head This commit looks good

Reviewed-on: #120
Reviewed-by: Robin Müller <muellerr@irs.uni-stuttgart.de>
This commit is contained in:
Robin Müller 2022-01-10 09:38:42 +01:00
commit 470e834b80
17 changed files with 1832 additions and 163 deletions

View File

@ -127,8 +127,18 @@ void Q7STestTask::testDummyParams() {
param.writeJsonFile();
param.print();
int test = param.getValue<int>(DummyParameter::DUMMY_KEY_PARAM_1);
std::string test2 = param.getValue<std::string>(DummyParameter::DUMMY_KEY_PARAM_2);
int test = 0;
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 2 (\"blirb\" expected): " << test2 << std::endl;
}

View File

@ -127,12 +127,15 @@ void initmission::initTasks() {
initmission::printAddObjectError("FILE_SYSTEM_TASK", objects::FILE_SYSTEM_HANDLER);
}
#if OBSW_ADD_STAR_TRACKER == 1
PeriodicTaskIF* strImgLoaderTask = factory->createPeriodicTask(
"FILE_SYSTEM_TASK", 20, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.2, missedDeadlineFunc);
result = strImgLoaderTask->addComponent(objects::STR_HELPER);
if(result != HasReturnvaluesIF::RETURN_OK) {
initmission::printAddObjectError("FILE_SYSTEM_TASK", objects::STR_HELPER);
}
#endif /* OBSW_ADD_STAR_TRACKER == 1 */
#endif /* BOARD_TE0720 */
#if OBSW_TEST_CCSDS_BRIDGE == 1
@ -194,7 +197,9 @@ void initmission::initTasks() {
#if BOARD_TE0720 == 0
fsTask->startTask();
#if OBSW_ADD_STAR_TRACKER == 1
strImgLoaderTask->startTask();
#endif /* OBSW_ADD_STAR_TRACKER == 1 */
#endif
sif::info << "Tasks started.." << std::endl;

View File

@ -59,7 +59,6 @@ enum PoolIds: lp_id_t {
TIME_TEMPERATURE_SET,
MCU_TEMPERATURE,
CMOS_TEMPERATURE,
TICKS_SOLUTION_SET,
TIME_SOLUTION_SET,
CALI_QW,
@ -83,7 +82,6 @@ enum PoolIds: lp_id_t {
TRUST_WORTHY,
STABLE_COUNT,
SOLUTION_STRATEGY,
TICKS_HISTOGRAM_SET,
TIME_HISTOGRAM_SET,
HISTOGRAM_BINA0,
@ -122,7 +120,6 @@ enum PoolIds: lp_id_t {
HISTOGRAM_BIND6,
HISTOGRAM_BIND7,
HISTOGRAM_BIND8,
TICKS_CONTRAST_SET,
TIME_CONTRAST_SET,
CONTRAST_BINA0,
@ -160,7 +157,46 @@ enum PoolIds: lp_id_t {
CONTRAST_BIND5,
CONTRAST_BIND6,
CONTRAST_BIND7,
CONTRAST_BIND8
CONTRAST_BIND8,
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;
@ -197,11 +233,18 @@ static const DeviceCommandId_t CHECKSUM = 50;
static const DeviceCommandId_t READ = 51;
static const DeviceCommandId_t WRITE = 52;
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 RESET_ERROR = 56;
static const DeviceCommandId_t CHANGE_DOWNLOAD_FILE = 57;
static const DeviceCommandId_t SET_JSON_FILE_NAME = 58;
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 CHANGE_FPGA_DOWNLOAD_FILE = 64;
static const DeviceCommandId_t UPLOAD_FPGA_IMAGE = 65;
static const DeviceCommandId_t FPGA_ACTION = 66;
static const DeviceCommandId_t NONE = 0xFFFFFFFF;
static const uint32_t VERSION_SET_ID = REQ_VERSION;
@ -212,6 +255,11 @@ static const uint32_t TIME_SET_ID = REQ_TIME;
static const uint32_t SOLUTION_SET_ID = REQ_SOLUTION;
static const uint32_t HISTOGRAM_SET_ID = REQ_HISTOGRAM;
static const uint32_t CONTRAST_SET_ID = REQ_CONTRAST;
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 */
static const size_t MAX_FRAME_SIZE = 1200;
@ -224,6 +272,11 @@ static const uint8_t TIME_SET_ENTRIES = 4;
static const uint8_t SOLUTION_SET_ENTRIES = 23;
static const uint8_t HISTOGRAM_SET_ENTRIES = 38;
static const uint8_t CONTRAST_SET_ENTRIES = 38;
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
namespace ID {
@ -244,6 +297,7 @@ namespace ID {
static const uint8_t REBOOT = 7;
static const uint8_t UPLOAD_IMAGE = 10;
static const uint8_t POWER = 11;
static const uint8_t SET_TIME = 14;
static const uint8_t SUBSCRIBE = 18;
static const uint8_t SOLUTION = 24;
static const uint8_t TEMPERATURE = 25;
@ -257,6 +311,12 @@ namespace ID {
static const uint8_t UNLOCK = 6;
static const uint8_t TAKE_IMAGE = 15;
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;
static const uint8_t FPGA_ACTION = 22;
}
namespace Program {
@ -281,7 +341,7 @@ public:
StaticLocalDataSet(sid_t(objectId, TEMPERATURE_SET_ID)) {
}
// Ticks is time reference generated by interanl counter of the star tracker
// Ticks is time reference generated by internal counter of the star tracker
lp_var_t<uint32_t> ticks = lp_var_t<uint32_t>(sid.objectId,
PoolIds::TICKS_TEMPERATURE_SET, this);
/** Unix time in microseconds */
@ -321,7 +381,6 @@ public:
StaticLocalDataSet(sid_t(objectId, VERSION_SET_ID)) {
}
// Ticks is time reference generated by interanl counter of the star tracker
lp_var_t<uint32_t> ticks = lp_var_t<uint32_t>(sid.objectId,
PoolIds::TICKS_VERSION_SET, this);
/** Unix time in microseconds */
@ -845,6 +904,307 @@ public:
sif::info << "ContrastSet::printSet: BinD8: " << this->binD8 << std::endl;
}
};
}
/**
* @brief Helper Class to extract information from bytestream.
*/
class ChecksumReply {
public:
/**
* @brief Constructor
*
* @param datafield Pointer to datafield in reply buffer
*
*/
ChecksumReply(const uint8_t* datafield) {
ReturnValue_t result = HasReturnvaluesIF::RETURN_OK;
region = *(datafield);
const uint8_t* addressData = datafield + ADDRESS_OFFSET;
size_t size = sizeof(address);
result = SerializeAdapter::deSerialize(&address, &addressData, &size,
SerializeIF::Endianness::LITTLE);
if (result != HasReturnvaluesIF::RETURN_OK) {
sif::debug << "ChecksumReply::ChecksumReply: Failed to deserialize address"
<< std::endl;
}
const uint8_t* lengthData = datafield + LENGTH_OFFSET;
size = sizeof(length);
result = SerializeAdapter::deSerialize(&length, &lengthData, &size,
SerializeIF::Endianness::LITTLE);
if (result != HasReturnvaluesIF::RETURN_OK) {
sif::debug << "ChecksumReply::ChecksumReply: Failed to deserialize length"
<< std::endl;
}
const uint8_t* checksumData = datafield + CHECKSUM_OFFSET;
size = sizeof(checksum);
result = SerializeAdapter::deSerialize(&checksum, &checksumData, &size,
SerializeIF::Endianness::LITTLE);
if (result != HasReturnvaluesIF::RETURN_OK) {
sif::debug << "ChecksumReply::ChecksumReply: Failed to deserialize checksum"
<< std::endl;
}
}
uint8_t getRegion() {
return region;
}
uint32_t getAddress() {
return address;
}
uint32_t getLength() {
return length;
}
uint32_t getChecksum() {
return checksum;
}
void printChecksum() {
sif::info << "ChecksumReply::printChecksum: 0x" << std::hex << checksum << std::endl;
}
private:
static const uint8_t ADDRESS_OFFSET = 1;
static const uint8_t LENGTH_OFFSET = 5;
static const uint8_t CHECKSUM_OFFSET = 9;
uint8_t region = 0;
uint32_t address = 0;
uint32_t length = 0;
uint32_t checksum = 0;
};
class EraseReply {
public:
EraseReply(const uint8_t* datafield) {
region = *datafield;
}
uint8_t getRegion() {
return region;
}
private:
uint8_t region = 0;
};
class ChecksumSet:
public StaticLocalDataSet<CHECKSUM_SET_ENTRIES> {
public:
// Size of dataset
static const size_t SIZE = 156;
ChecksumSet(HasLocalDataPoolIF* owner):
StaticLocalDataSet(owner, CHECKSUM_SET_ID) {
}
ChecksumSet(object_id_t objectId):
StaticLocalDataSet(sid_t(objectId, CHECKSUM_SET_ID)) {
}
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_ */

View File

@ -1,23 +1,25 @@
#include <fstream>
#include "StarTrackerHandler.h"
#include "OBSWConfig.h"
#include "StarTrackerJsonCommands.h"
#include <fsfw/globalfunctions/CRC.h>
#include <fsfw/ipc/QueueFactory.h>
#include <mission/memory/NVMParameterBase.h>
extern "C" {
#include <thirdparty/arcsec_star_tracker/client/generated/telemetry.h>
#include <thirdparty/arcsec_star_tracker/client/generated/actionreq.h>
#include "common/misc.h"
}
using json = nlohmann::json;
StarTrackerHandler::StarTrackerHandler(object_id_t objectId, object_id_t comIF,
CookieIF * comCookie, StrHelper* strHelper) :
DeviceHandlerBase(objectId, comIF, comCookie), temperatureSet(this), versionSet(this), powerSet(
this), interfaceSet(this), timeSet(this), solutionSet(this), histogramSet(this),
contrastSet(this), strHelper(strHelper) {
this), interfaceSet(this), timeSet(this), solutionSet(this), histogramSet(this), contrastSet(
this), checksumSet(this), downloadCentroidSet(this), downloadMatchedStar(this),
downloadDbImage(this), downloadBlobPixel(this), strHelper(
strHelper) {
if (comCookie == nullptr) {
sif::error << "StarTrackerHandler: Invalid com cookie" << std::endl;
}
@ -51,7 +53,7 @@ ReturnValue_t StarTrackerHandler::initialize() {
}
result = manager->subscribeToEventRange(eventQueue->getId(),
event::getEventId(StrHelper::IMAGE_UPLOAD_FAILED),
event::getEventId(StrHelper::FLASH_READ_FAILED));
event::getEventId(StrHelper::FPGA_UPLOAD_FAILED));
if (result != RETURN_OK) {
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::warning << "StarTrackerHandler::initialize: Failed to subscribe to events from "
@ -105,7 +107,7 @@ ReturnValue_t StarTrackerHandler::executeAction(ActionId_t actionId, MessageQueu
if (result != RETURN_OK) {
return result;
}
if (size > MAX_PATH_SIZE) {
if (size > MAX_PATH_SIZE + MAX_FILE_NAME) {
return FILE_PATH_TOO_LONG;
}
result = strHelper->startImageUpload(
@ -145,6 +147,18 @@ ReturnValue_t StarTrackerHandler::executeAction(ActionId_t actionId, MessageQueu
strHelperExecuting = true;
return EXECUTION_FINISHED;
}
case(StarTracker::READ): {
result = DeviceHandlerBase::acceptExternalDeviceCommands();
if (result != RETURN_OK) {
return result;
}
result = executeReadCommand(data, size);
if (result != RETURN_OK) {
return result;
}
strHelperExecuting = true;
return EXECUTION_FINISHED;
}
case(StarTracker::CHANGE_DOWNLOAD_FILE): {
if (size > MAX_FILE_NAME) {
return FILENAME_TOO_LONG;
@ -153,6 +167,51 @@ ReturnValue_t StarTrackerHandler::executeAction(ActionId_t actionId, MessageQueu
std::string(reinterpret_cast<const char*>(data), size));
return EXECUTION_FINISHED;
}
case(StarTracker::CHANGE_FPGA_DOWNLOAD_FILE): {
if (size > MAX_FILE_NAME) {
return FILENAME_TOO_LONG;
}
strHelper->setDownloadFpgaImage(std::string(reinterpret_cast<const char*>(data), size));
return EXECUTION_FINISHED;
}
case(StarTracker::SET_READ_FILENAME): {
if (size > MAX_FILE_NAME) {
return FILENAME_TOO_LONG;
}
strHelper->setDownloadImageName(
std::string(reinterpret_cast<const char*>(data), size));
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;
}
case(StarTracker::UPLOAD_FPGA_IMAGE): {
result = DeviceHandlerBase::acceptExternalDeviceCommands();
if (result != RETURN_OK) {
return result;
}
if (size > MAX_PATH_SIZE + MAX_FILE_NAME) {
return FILE_PATH_TOO_LONG;
}
result = strHelper->startFpgaUpload(std::string(reinterpret_cast<const char*>(data), size));
if (result != RETURN_OK) {
return result;
}
strHelperExecuting = true;
return EXECUTION_FINISHED;
}
default:
break;
}
@ -396,6 +455,46 @@ ReturnValue_t StarTrackerHandler::buildCommandFromCommand(DeviceCommandId_t devi
result = prepareParamCommand(commandData, commandDataLen, tracking);
return result;
}
case (StarTracker::ERASE): {
result = prepareEraseCommand(commandData, commandDataLen);
return result;
}
case (StarTracker::UNLOCK): {
result = prepareUnlockCommand(commandData, commandDataLen);
return result;
}
case (StarTracker::CHECKSUM): {
result = prepareChecksumCommand(commandData, commandDataLen);
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;
}
case (StarTracker::FPGA_ACTION): {
result = prepareFpgaActionCommand(commandData, commandDataLen);
return result;
}
default:
return DeviceHandlerIF::COMMAND_NOT_IMPLEMENTED;
}
@ -454,6 +553,26 @@ void StarTrackerHandler::fillCommandAndReplyMap() {
StarTracker::MAX_FRAME_SIZE * 2 + 2);
this->insertInCommandAndReplyMap(StarTracker::RESET_ERROR, 3, nullptr,
StarTracker::MAX_FRAME_SIZE * 2 + 2);
this->insertInCommandAndReplyMap(StarTracker::ERASE, 3, nullptr,
StarTracker::MAX_FRAME_SIZE * 2 + 2);
this->insertInCommandAndReplyMap(StarTracker::UNLOCK, 3, nullptr,
StarTracker::MAX_FRAME_SIZE * 2 + 2);
this->insertInCommandAndReplyMap(StarTracker::CHECKSUM, 3, nullptr,
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);
this->insertInCommandAndReplyMap(StarTracker::FPGA_ACTION, 3, nullptr,
StarTracker::MAX_FRAME_SIZE * 2 + 2);
}
ReturnValue_t StarTrackerHandler::scanForReply(const uint8_t *start, size_t remainingSize,
@ -522,16 +641,41 @@ ReturnValue_t StarTrackerHandler::interpretDeviceReply(DeviceCommandId_t id, con
result = handlePingReply();
break;
}
case (StarTracker::BOOT): {
case (StarTracker::BOOT):
case (StarTracker::TAKE_IMAGE):
case (StarTracker::RESET_ERROR):
case (StarTracker::UNLOCK):
case (StarTracker::SET_TIME):
case (StarTracker::FPGA_ACTION): {
result = handleActionReply();
break;
}
case (StarTracker::RESET_ERROR): {
result = handleActionReply();
case (StarTracker::DOWNLOAD_CENTROID): {
result = handleActionReplySet(downloadCentroidSet, StarTracker::DownloadCentroidSet::SIZE);
break;
}
case (StarTracker::TAKE_IMAGE): {
result = handleActionReply();
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): {
result = handleEraseReply();
break;
}
case (StarTracker::CHECKSUM): {
result = handleChecksumReply();
break;
}
case (StarTracker::REQ_VERSION): {
@ -754,7 +898,42 @@ ReturnValue_t StarTrackerHandler::initializeLocalDataPool(localpool::DataPool& l
localDataPoolMap.emplace(StarTracker::CONTRAST_BIND6, 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::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;
}
@ -809,6 +988,46 @@ ReturnValue_t StarTrackerHandler::scanForActionReply(DeviceCommandId_t *foundId)
*foundId = StarTracker::RESET_ERROR;
break;
}
case (StarTracker::ID::ERASE): {
*foundId = StarTracker::ERASE;
break;
}
case (StarTracker::ID::UNLOCK): {
*foundId = StarTracker::UNLOCK;
break;
}
case (StarTracker::ID::CHECKSUM): {
*foundId = StarTracker::CHECKSUM;
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;
}
case (StarTracker::ID::FPGA_ACTION): {
*foundId = StarTracker::FPGA_ACTION;
break;
}
default:
sif::warning << "StarTrackerHandler::scanForParameterReply: Unknown parameter reply id"
<< std::endl;
@ -945,7 +1164,7 @@ ReturnValue_t StarTrackerHandler::executeWriteCommand(const uint8_t* commandData
size_t size = sizeof(address);
const uint8_t* addressPtr = commandData + WriteCmd::ADDRESS_OFFSET;
result = SerializeAdapter::deSerialize(&address, addressPtr, &size,
SerializeIF::Endianness::LITTLE);
SerializeIF::Endianness::BIG);
if (result != RETURN_OK) {
sif::debug << "StarTrackerHandler::executeWriteCommand: Deserialization of address failed"
<< std::endl;
@ -966,6 +1185,89 @@ ReturnValue_t StarTrackerHandler::executeWriteCommand(const uint8_t* commandData
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,
size_t commandDataLen) {
ReturnValue_t result = RETURN_OK;
if (commandDataLen < ReadCmd::MIN_LENGTH) {
sif::warning << "StarTrackerHandler::executeReadCommand: Command too short" << std::endl;
return COMMAND_TOO_SHORT;
}
uint8_t region = *(commandData);
uint32_t address;
size_t size = sizeof(address);
const uint8_t* addressPtr = commandData + ReadCmd::ADDRESS_OFFSET;
result = SerializeAdapter::deSerialize(&address, addressPtr, &size,
SerializeIF::Endianness::BIG);
if (result != RETURN_OK) {
sif::debug << "StarTrackerHandler::executeReadCommand: Deserialization of address failed"
<< std::endl;
return result;
}
uint32_t length;
size = sizeof(length);
const uint8_t* lengthPtr = commandData + ReadCmd::LENGTH_OFFSET;
result = SerializeAdapter::deSerialize(&length, lengthPtr, &size,
SerializeIF::Endianness::BIG);
if (result != RETURN_OK) {
sif::debug << "StarTrackerHandler::executeReadCommand: Deserialization of length failed"
<< std::endl;
return result;
}
if (commandDataLen - sizeof(address) - sizeof(region) - sizeof(length) > MAX_PATH_SIZE) {
sif::warning << "StarTrackerHandler::executeReadCommand: Received command with invalid"
<< " path and filename" << std::endl;
return FILE_PATH_TOO_LONG;
}
const uint8_t* filePtr = commandData + ReadCmd::FILE_OFFSET;
std::string fullname = std::string(reinterpret_cast<const char*>(filePtr),
commandDataLen - sizeof(address) - sizeof(region) - sizeof(length));
result = strHelper->startFlashRead(fullname, region, address, length);
if (result != RETURN_OK) {
return result;
}
return result;
}
void StarTrackerHandler::prepareBootCommand() {
uint32_t length = 0;
struct BootActionRequest bootRequest = {BOOT_REGION_ID};
@ -975,6 +1277,215 @@ void StarTrackerHandler::prepareBootCommand() {
rawPacketLen = dataLinkLayer.getEncodedLength();
}
ReturnValue_t StarTrackerHandler::prepareEraseCommand(const uint8_t* commandData,
size_t commandDataLen) {
ReturnValue_t result = RETURN_OK;
if (commandDataLen != EraseCmd::LENGTH) {
return INVALID_LENGTH;
}
uint32_t length = 0;
struct EraseActionRequest req;
req.region = *commandData;
arc_pack_erase_action_req(&req, commandBuffer, &length);
dataLinkLayer.encodeFrame(commandBuffer, length);
rawPacket = dataLinkLayer.getEncodedFrame();
rawPacketLen = dataLinkLayer.getEncodedLength();
eraseCmd.rememberRegion = req.region;
return result;
}
ReturnValue_t StarTrackerHandler::prepareUnlockCommand(const uint8_t* commandData,
size_t commandDataLen) {
ReturnValue_t result = RETURN_OK;
uint32_t length = 0;
struct UnlockActionRequest req;
req.region = *commandData;
size_t size = sizeof(req.code);
const uint8_t* codePtr = commandData + UnlockCmd::CODE_OFFSET;
result = SerializeAdapter::deSerialize(&req.code, &codePtr, &size,
SerializeIF::Endianness::BIG);
if (result != RETURN_OK) {
return result;
}
arc_pack_unlock_action_req(&req, commandBuffer, &length);
dataLinkLayer.encodeFrame(commandBuffer, length);
rawPacket = dataLinkLayer.getEncodedFrame();
rawPacketLen = dataLinkLayer.getEncodedLength();
return result;
}
ReturnValue_t StarTrackerHandler::prepareChecksumCommand(const uint8_t* commandData,
size_t commandDataLen) {
struct ChecksumActionRequest req;
ReturnValue_t result = RETURN_OK;
if (commandDataLen != ChecksumCmd::LENGTH) {
sif::warning << "StarTrackerHandler::prepareChecksumCommand: Invalid length" << std::endl;
return INVALID_LENGTH;
}
req.region = *(commandData);
size_t size = sizeof(req.address);
const uint8_t* addressPtr = commandData + ChecksumCmd::ADDRESS_OFFSET;
result = SerializeAdapter::deSerialize(&req.address, addressPtr, &size,
SerializeIF::Endianness::BIG);
if (result != RETURN_OK) {
sif::debug << "StarTrackerHandler::prepareChecksumCommand: Deserialization of address "
<< "failed" << std::endl;
return result;
}
size = sizeof(req.length);
const uint8_t* lengthPtr = commandData + ChecksumCmd::LENGTH_OFFSET;
result = SerializeAdapter::deSerialize(&req.length, lengthPtr, &size,
SerializeIF::Endianness::BIG);
if (result != RETURN_OK) {
sif::debug << "StarTrackerHandler::prepareChecksumCommand: Deserialization of length failed"
<< std::endl;
return result;
}
uint32_t rawCmdLength = 0;
arc_pack_checksum_action_req(&req, commandBuffer, &rawCmdLength);
dataLinkLayer.encodeFrame(commandBuffer, rawCmdLength);
rawPacket = dataLinkLayer.getEncodedFrame();
rawPacketLen = dataLinkLayer.getEncodedLength();
checksumCmd.rememberRegion = req.region;
checksumCmd.rememberAddress = req.address;
checksumCmd.rememberLength = req.length;
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() {
uint32_t length = 0;
arc_tm_pack_time_req(commandBuffer, &length);
@ -1122,6 +1633,73 @@ ReturnValue_t StarTrackerHandler::prepareParamCommand(const uint8_t* commandData
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::prepareFpgaActionCommand(const uint8_t* commandData,
size_t commandDataLen) {
if (commandDataLen != FpgaActionCmd::LENGTH) {
return INVALID_LENGTH;
}
struct FPGAActionActionRequest req;
req.id = *commandData;
if (req.id != FpgaActionCmd::ID) {
return INVALID_ID;
}
uint32_t length = 0;
arc_pack_fpgaaction_action_req(&req, commandBuffer, &length);
dataLinkLayer.encodeFrame(commandBuffer, length);
rawPacket = dataLinkLayer.getEncodedFrame();
rawPacketLen = dataLinkLayer.getEncodedLength();
return RETURN_OK;
}
ReturnValue_t StarTrackerHandler::handleSetParamReply() {
const uint8_t* reply = dataLinkLayer.getReply();
uint8_t status = *(reply + STATUS_OFFSET);
@ -1145,7 +1723,7 @@ ReturnValue_t StarTrackerHandler::handleActionReply() {
uint8_t status = *(reply + STATUS_OFFSET);
if (status != StarTracker::STATUS_OK) {
sif::warning << "StarTrackerHandler::handleActionReply: Failed to execute action "
<< " command with action ID "
<< "command with action ID "
<< static_cast<unsigned int>(*(reply + ACTION_ID_OFFSET))
<< " and status "<< static_cast<unsigned int>(status) << std::endl;
return ACTION_FAILED;
@ -1153,6 +1731,63 @@ ReturnValue_t StarTrackerHandler::handleActionReply() {
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 result = RETURN_OK;
result = handleActionReply();
if (result != RETURN_OK) {
return result;
}
const uint8_t* replyData = dataLinkLayer.getReply() + ACTION_DATA_OFFSET;
StarTracker::EraseReply eraseReply(replyData);
if (eraseReply.getRegion() != eraseCmd.rememberRegion) {
sif::warning << "StarTrackerHandler::handleEraseReply: Region mismatch" << std::endl;
return REGION_MISMATCH;
}
return result;
}
ReturnValue_t StarTrackerHandler::handleChecksumReply() {
ReturnValue_t result = RETURN_OK;
result = handleActionReply();
if (result != RETURN_OK) {
return result;
}
const uint8_t* replyData = dataLinkLayer.getReply() + ACTION_DATA_OFFSET;
StarTracker::ChecksumReply checksumReply(replyData);
if (checksumReply.getRegion() != checksumCmd.rememberRegion) {
sif::warning << "StarTrackerHandler::handleChecksumReply: Region mismatch" << std::endl;
return REGION_MISMATCH;
}
if (checksumReply.getAddress() != checksumCmd.rememberAddress) {
sif::warning << "StarTrackerHandler::handleChecksumReply: Address mismatch" << std::endl;
return ADDRESS_MISMATCH;
}
if (checksumReply.getLength() != checksumCmd.rememberLength) {
sif::warning << "StarTrackerHandler::handleChecksumReply: Length mismatch" << std::endl;
return LENGTH_MISSMATCH;
}
PoolReadGuard rg(&checksumSet);
checksumSet.checksum = checksumReply.getChecksum();
handleDeviceTM(&checksumSet, StarTracker::CHECKSUM);
#if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_STARTRACKER == 1
checksumReply.printChecksum();
#endif /* OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_STARTRACKER == 1 */
return RETURN_OK;
}
ReturnValue_t StarTrackerHandler::handlePingReply() {
ReturnValue_t result = RETURN_OK;
uint32_t pingId = 0;
@ -1207,7 +1842,7 @@ ReturnValue_t StarTrackerHandler::handleTm(LocalPoolDataSetBase& dataset, size_t
if(status != StarTracker::STATUS_OK) {
sif::warning << "StarTrackerHandler::handleTm: Reply error: "
<< static_cast<unsigned int>(status) << std::endl;
return TM_REPLY_ERROR;
return REPLY_ERROR;
}
result = dataset.read(TIMEOUT_TYPE, MUTEX_TIMEOUT);
if (result != RETURN_OK) {
@ -1232,6 +1867,37 @@ ReturnValue_t StarTrackerHandler::handleTm(LocalPoolDataSetBase& dataset, size_t
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) {
switch(*parameterId) {
case (StarTracker::ID::LIMITS): {

View File

@ -111,12 +111,28 @@ private:
static const ReturnValue_t FILENAME_TOO_LONG = MAKE_RETURN_CODE(0xAC);
//! [EXPORT] : [COMMENT] Received version reply with invalid program ID
static const ReturnValue_t INVALID_PROGRAM = MAKE_RETURN_CODE(0xAD);
//! [EXPORT] : [COMMENT] Status field of tm reply signals error
static const ReturnValue_t TM_REPLY_ERROR = MAKE_RETURN_CODE(0xAE);
//! [EXPORT] : [COMMENT] Status field reply signals error
static const ReturnValue_t REPLY_ERROR = MAKE_RETURN_CODE(0xAE);
//! [EXPORT] : [COMMENT] Status field of contrast reply signals error
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)
static const ReturnValue_t COMMAND_TOO_SHORT = MAKE_RETURN_CODE(0xAF);
//! [EXPORT] : [COMMENT] Received command with invalid length (too few or too many parameters)
static const ReturnValue_t INVALID_LENGTH = MAKE_RETURN_CODE(0xB0);
//! [EXPORT] : [COMMENT] Region mismatch between send and received data
static const ReturnValue_t REGION_MISMATCH = MAKE_RETURN_CODE(0xB1);
//! [EXPORT] : [COMMENT] Address mismatch between send and received data
static const ReturnValue_t ADDRESS_MISMATCH = MAKE_RETURN_CODE(0xB2);
//! [EXPORT] : [COMMENT] Length field mismatch between send and received data
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);
//! [EXPORT] : [COMMENT] Received FPGA action command with invalid ID
static const ReturnValue_t INVALID_ID = MAKE_RETURN_CODE(0xB7);
static const size_t MAX_PATH_SIZE = 50;
static const size_t MAX_FILE_NAME = 30;
@ -147,6 +163,86 @@ private:
static const size_t MIN_LENGTH = 7;
};
class ReadCmd {
public:
static const uint8_t ADDRESS_OFFSET = 1;
static const uint8_t LENGTH_OFFSET = 5;
static const uint8_t FILE_OFFSET = 9;
// Minimum length of a read command (region, address, length and filename)
static const size_t MIN_LENGTH = 11;
};
class EraseCmd {
public:
static const uint8_t LENGTH = 1;
uint8_t rememberRegion = 0;
};
EraseCmd eraseCmd;
class UnlockCmd {
public:
static const uint8_t CODE_OFFSET = 1;
};
class ChecksumCmd {
public:
static const uint8_t ADDRESS_OFFSET = 1;
static const uint8_t LENGTH_OFFSET = 5;
// Length of checksum command
static const size_t LENGTH = 9;
uint8_t rememberRegion = 0;
uint32_t rememberAddress = 0;
uint32_t rememberLength = 0;
};
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;
};
class FpgaActionCmd {
public:
static const uint8_t LENGTH = 1;
static const uint8_t ID = 3;
};
MessageQueueIF* eventQueue = nullptr;
ArcsecDatalinkLayer dataLinkLayer;
@ -159,6 +255,11 @@ private:
StarTracker::SolutionSet solutionSet;
StarTracker::HistogramSet histogramSet;
StarTracker::ContrastSet contrastSet;
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
StrHelper* strHelper = nullptr;
@ -245,12 +346,61 @@ private:
*/
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
* flash-read-procedure
*
* @param commandData Pointer to received command data
* @param commandDataLen Size of received command data
*
* @return RETURN_OK if start of execution was successful, otherwise error return value
*/
ReturnValue_t executeReadCommand(const uint8_t* commandData, size_t commandDataLen);
/**
* @brief Fills command buffer with data to boot image (works only when star tracker is
* in bootloader mode).
*/
void prepareBootCommand();
/**
* @brief Fills command buffer with command to erase a flash region
*/
ReturnValue_t prepareEraseCommand(const uint8_t* commandData, size_t commandDataLen);
/**
* @brief Fills command buffer with command to unlock flash region
*/
ReturnValue_t prepareUnlockCommand(const uint8_t* commandData, size_t commandDataLen);
/**
* @brief Fills command buffer with command to get the checksum of a flash part
*/
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.
*/
@ -319,11 +469,54 @@ private:
ReturnValue_t prepareParamCommand(const uint8_t* commandData, size_t commandDataLen,
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 With this command the FPGA update will be applied to the star tracker
*/
ReturnValue_t prepareFpgaActionCommand(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
*/
ReturnValue_t handleActionReply();
/**
* @brief Handles reply to upload centroid command
*/
ReturnValue_t handleUploadCentroidReply();
/**
* @brief Handles reply to erase command
*/
ReturnValue_t handleEraseReply();
/**
* @brief Handles reply to checksum command
*/
ReturnValue_t handleChecksumReply();
/**
* @brief Handles all set parameter replies
*/

View File

@ -63,6 +63,39 @@ ReturnValue_t StrHelper::performOperation(uint8_t operationCode) {
internalState = InternalState::IDLE;
break;
}
case InternalState::FLASH_READ: {
result = performFlashRead();
if (result == RETURN_OK){
triggerEvent(FLASH_READ_SUCCESSFUL);
}
else {
triggerEvent(FLASH_READ_FAILED);
}
internalState = InternalState::IDLE;
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;
}
case InternalState::UPLOAD_FPGA_IMAGE: {
result = performFpgaUpload();
if (result == RETURN_OK){
triggerEvent(FPGA_UPLOAD_SUCCESSFUL);
}
else {
triggerEvent(FPGA_UPLOAD_FAILED);
}
internalState = InternalState::IDLE;
break;
}
default:
sif::debug << "StrHelper::performOperation: Invalid state" << std::endl;
break;
@ -83,30 +116,30 @@ void StrHelper::setComCookie(CookieIF* comCookie_) {
comCookie = comCookie_;
}
ReturnValue_t StrHelper::startImageUpload(std::string uploadImage_) {
ReturnValue_t result = checkPath(uploadImage_);
ReturnValue_t StrHelper::startImageUpload(std::string fullname) {
ReturnValue_t result = checkPath(fullname);
if (result != RETURN_OK) {
return result;
}
uploadImage = uploadImage_;
if(not std::filesystem::exists(uploadImage)) {
uploadImage.uploadFile = fullname;
if(not std::filesystem::exists(fullname)) {
return FILE_NOT_EXISTS;
}
internalState = InternalState::UPLOAD_IMAGE;
internalState = InternalState::UPLOAD_FPGA_IMAGE;
semaphore.release();
terminate = false;
return RETURN_OK;
}
ReturnValue_t StrHelper::startImageDownload(std::string downloadPath_) {
ReturnValue_t result = checkPath(downloadPath_);
ReturnValue_t StrHelper::startImageDownload(std::string path) {
ReturnValue_t result = checkPath(path);
if (result != RETURN_OK) {
return result;
}
if(not std::filesystem::exists(downloadPath_)) {
if(not std::filesystem::exists(path)) {
return PATH_NOT_EXISTS;
}
downloadPath = downloadPath_;
downloadImage.path = path;
internalState = InternalState::DOWNLOAD_IMAGE;
terminate = false;
semaphore.release();
@ -117,39 +150,87 @@ void StrHelper::stopProcess() {
terminate = true;
}
void StrHelper::setDownloadImageName(std::string image) {
downloadImage = image;
void StrHelper::setDownloadImageName(std::string filename) {
downloadImage.filename = filename;
}
ReturnValue_t StrHelper::startFlashWrite(std::string flashWriteFile_, uint8_t region,
uint32_t flashWriteAddress) {
ReturnValue_t result = checkPath(flashWriteFile_);
void StrHelper::setFlashReadFilename(std::string filename) {
flashRead.filename = filename;
}
void StrHelper::setDownloadFpgaImage(std::string filename) {
fpgaDownload.fileName = filename;
}
ReturnValue_t StrHelper::startFlashWrite(std::string fullname, uint8_t region,
uint32_t address) {
ReturnValue_t result = checkPath(fullname);
if (result != RETURN_OK) {
return result;
}
flashWriteFile = flashWriteFile_;
if(not std::filesystem::exists(flashWriteFile)) {
flashWrite.fullname = fullname;
if(not std::filesystem::exists(flashWrite.fullname)) {
return FILE_NOT_EXISTS;
}
flashWrite.address = address;
flashWrite.region = region;
internalState = InternalState::FLASH_WRITE;
semaphore.release();
terminate = false;
return RETURN_OK;
}
ReturnValue_t StrHelper::startFlashRead(std::string path, uint8_t region,
uint32_t address, uint32_t length) {
ReturnValue_t result = checkPath(path);
if (result != RETURN_OK) {
return result;
}
flashRead.path = path;
if(not std::filesystem::exists(flashRead.path)) {
return FILE_NOT_EXISTS;
}
flashRead.address = address;
flashRead.region = region;
flashRead.size = length;
internalState = InternalState::FLASH_READ;
semaphore.release();
terminate = false;
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::startFpgaUpload(std::string uploadFile) {
fpgaUpload.uploadFile = uploadFile;
internalState = InternalState::UPLOAD_FPGA_IMAGE;
semaphore.release();
terminate = false;
return RETURN_OK;
}
ReturnValue_t StrHelper::performImageDownload() {
ReturnValue_t result;
struct DownloadActionRequest downloadReq;
uint32_t size = 0;
uint32_t retries = 0;
Timestamp timestamp;
std::string image = downloadPath + "/" + timestamp.str() + downloadImage ;
std::string image = downloadImage.path + "/" + timestamp.str() + downloadImage.filename ;
std::ofstream file(image, std::ios_base::app | std::ios_base::out);
if(not std::filesystem::exists(image)) {
return FILE_CREATION_FAILED;
}
downloadReq.position = 0;
while(downloadReq.position < LAST_POSITION) {
while(downloadReq.position < ImageDownload::LAST_POSITION) {
if (terminate) {
return RETURN_OK;
}
@ -164,7 +245,7 @@ ReturnValue_t StrHelper::performImageDownload() {
file.close();
return result;
}
result = checkReply();
result = checkActionReply();
if (result != RETURN_OK) {
if (retries < CONFIG_MAX_DOWNLOAD_RETRIES) {
uartComIF->flushUartRxBuffer(comCookie);
@ -184,7 +265,7 @@ ReturnValue_t StrHelper::performImageDownload() {
file.close();
return result;
}
file.write(reinterpret_cast<const char*>(datalinkLayer.getReply() + DATA_OFFSET),
file.write(reinterpret_cast<const char*>(datalinkLayer.getReply() + IMAGE_DATA_OFFSET),
IMAGE_DATA_SIZE);
downloadReq.position++;
retries = 0;
@ -200,12 +281,12 @@ ReturnValue_t StrHelper::performImageUpload() {
struct UploadActionRequest uploadReq;
uploadReq.position = 0;
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));
internalState = InternalState::IDLE;
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
file.seekg(0, file.end);
// tellg returns position of character in input stream
@ -221,7 +302,7 @@ ReturnValue_t StrHelper::performImageUpload() {
if (result != RETURN_OK) {
return RETURN_FAILED;
}
result = checkReply();
result = checkActionReply();
if (result != RETURN_OK) {
return result;
}
@ -238,7 +319,7 @@ ReturnValue_t StrHelper::performImageUpload() {
if (result != RETURN_OK) {
return RETURN_FAILED;
}
result = checkReply();
result = checkActionReply();
if (result != RETURN_OK) {
return result;
}
@ -251,17 +332,17 @@ ReturnValue_t StrHelper::performFlashWrite() {
uint32_t remainingBytes = 0;
uint32_t fileSize = 0;
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));
internalState = InternalState::IDLE;
return RETURN_FAILED;
}
std::ifstream file(flashWriteFile, std::ifstream::binary);
std::ifstream file(flashWrite.fullname, std::ifstream::binary);
file.seekg(0, file.end);
fileSize = file.tellg();
remainingBytes = fileSize;
req.region = flashWriteRegion;
req.address = flashWriteAddress;
req.region = flashWrite.region;
req.address = flashWrite.address;
req.length = MAX_FLASH_DATA;
while(remainingBytes >= MAX_FLASH_DATA) {
if (terminate) {
@ -274,7 +355,7 @@ ReturnValue_t StrHelper::performFlashWrite() {
if (result != RETURN_OK) {
return RETURN_FAILED;
}
result = checkFlashWriteReply(req);
result = checkFlashActionReply(req.region, req.address, req.length);
if (result != RETURN_OK) {
return result;
}
@ -288,13 +369,170 @@ ReturnValue_t StrHelper::performFlashWrite() {
if (result != RETURN_OK) {
return RETURN_FAILED;
}
result = checkFlashWriteReply(req);
result = checkFlashActionReply(req.region, req.address, req.length);
if (result != RETURN_OK) {
return result;
}
return RETURN_OK;
}
ReturnValue_t StrHelper::performFlashRead() {
ReturnValue_t result;
struct ReadActionRequest req;
uint32_t bytesRead = 0;
uint32_t size = 0;
uint32_t retries = 0;
Timestamp timestamp;
std::string fullname = flashRead.path + "/" + timestamp.str() + flashRead.filename ;
std::ofstream file(fullname, std::ios_base::app | std::ios_base::out);
if (not std::filesystem::exists(fullname)) {
return FILE_CREATION_FAILED;
}
req.region = flashRead.region;
while(bytesRead < flashRead.size) {
if (terminate) {
return RETURN_OK;
}
if ((flashRead.size - bytesRead) < MAX_FLASH_DATA) {
req.length = flashRead.size - bytesRead;
}
else {
req.length = MAX_FLASH_DATA;
}
req.address = flashRead.address + bytesRead;
arc_pack_read_action_req(&req, commandBuffer, &size);
result = sendAndRead(size, req.address);
if (result != RETURN_OK) {
if (retries < CONFIG_MAX_DOWNLOAD_RETRIES) {
uartComIF->flushUartRxBuffer(comCookie);
retries++;
continue;
}
file.close();
return result;
}
result = checkActionReply();
if (result != RETURN_OK) {
if (retries < CONFIG_MAX_DOWNLOAD_RETRIES) {
uartComIF->flushUartRxBuffer(comCookie);
retries++;
continue;
}
file.close();
return result;
}
result = checkFlashActionReply(req.region, req.address, 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() + FLASH_READ_DATA_OFFSET),
req.length);
bytesRead += req.length;
retries = 0;
}
file.close();
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 = checkFpgaActionReply(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::performFpgaUpload() {
ReturnValue_t result = RETURN_OK;
uint32_t commandSize = 0;
uint32_t bytesUploaded = 0;
uint32_t fileSize = 0;
struct UploadFPGAImageActionRequest req;
if (not std::filesystem::exists(fpgaUpload.uploadFile)) {
triggerEvent(STR_HELPER_FILE_NOT_EXISTS, static_cast<uint32_t>(internalState));
internalState = InternalState::IDLE;
return RETURN_FAILED;
}
std::ifstream file(flashWrite.fullname, std::ifstream::binary);
file.seekg(0, file.end);
fileSize = file.tellg();
req.pos = 0;
while(bytesUploaded <= fileSize) {
if (terminate) {
return RETURN_OK;
}
if (fileSize - bytesUploaded > FpgaUpload::MAX_DATA) {
req.length = FpgaUpload::MAX_DATA;
}
else {
req.length = fileSize - bytesUploaded;
}
file.seekg(bytesUploaded, file.beg);
file.read(reinterpret_cast<char*>(req.data), req.length);
arc_pack_uploadfpgaimage_action_req(&req, commandBuffer, &commandSize);
result = sendAndRead(commandSize, req.pos);
if (result != RETURN_OK) {
return RETURN_FAILED;
}
result = checkFpgaActionReply(req.pos, req.length);
if (result != RETURN_OK) {
return result;
}
bytesUploaded += req.length;
}
return RETURN_OK;
}
ReturnValue_t StrHelper::sendAndRead(size_t size, uint32_t parameter) {
ReturnValue_t result = RETURN_OK;
ReturnValue_t decResult = RETURN_OK;
@ -351,19 +589,18 @@ ReturnValue_t StrHelper::sendAndRead(size_t size, uint32_t parameter) {
return RETURN_OK;
}
ReturnValue_t StrHelper::checkReply() {
ReturnValue_t StrHelper::checkActionReply() {
uint8_t type = datalinkLayer.getReplyFrameType();
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;
triggerEvent(INVALID_TYPE_ID);
return RETURN_FAILED;
return INVALID_TYPE_ID;
}
uint8_t status = datalinkLayer.getStatusField();
if (status != ArcsecDatalinkLayer::STATUS_OK) {
triggerEvent(STATUS_ERROR);
sif::warning << "StrHelper::checkReply: Status failure" << std::endl;
return RETURN_FAILED;
sif::warning << "StrHelper::checkActionReply: Status failure: "
<< static_cast<unsigned int>(status) << std::endl;
return STATUS_ERROR;
}
return RETURN_OK;
}
@ -378,8 +615,13 @@ ReturnValue_t StrHelper::checkReplyPosition(uint32_t expectedPosition) {
return RETURN_OK;
}
ReturnValue_t StrHelper::checkFlashWriteReply(struct WriteActionRequest& req) {
ReturnValue_t StrHelper::checkFlashActionReply(uint8_t region_, uint32_t address_,
uint16_t length_) {
ReturnValue_t result = RETURN_OK;
result = checkActionReply();
if (result != RETURN_OK) {
return result;
}
const uint8_t* data = datalinkLayer.getReply();
uint8_t region = *(data + REGION_OFFSET);
uint32_t address;
@ -388,8 +630,9 @@ ReturnValue_t StrHelper::checkFlashWriteReply(struct WriteActionRequest& req) {
result = SerializeAdapter::deSerialize(&address, &addressData, &size,
SerializeIF::Endianness::LITTLE);
if (result != RETURN_OK) {
sif::warning << "StrHelper::checkFlashWriteReply: Deserialization of address failed"
sif::warning << "StrHelper::checkFlashActionReply: Deserialization of address failed"
<< std::endl;
return result;
}
uint16_t length;
size = sizeof(length);
@ -397,21 +640,50 @@ ReturnValue_t StrHelper::checkFlashWriteReply(struct WriteActionRequest& req) {
result = SerializeAdapter::deSerialize(&length, lengthData, &size,
SerializeIF::Endianness::LITTLE);
if (result != RETURN_OK) {
sif::warning << "StrHelper::checkFlashWriteReply: Deserialization of length failed"
sif::warning << "StrHelper::checkFlashActionReply: Deserialization of length failed"
<< std::endl;
}
if (region != req.region) {
if (region != region_) {
return REGION_MISMATCH;
}
if (address != req.address) {
if (address != address_) {
return ADDRESS_MISMATCH;
}
if (region != req.length) {
if (length != length_) {
return LENGTH_MISMATCH;
}
return RETURN_OK;
}
ReturnValue_t StrHelper::checkFpgaActionReply(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() + ACTION_DATA_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::checkFpgaActionReply: 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::checkFpgaActionReply: Deserialization of length failed"
<< std::endl;
return result;
}
return result;
}
ReturnValue_t StrHelper::checkPath(std::string name) {
if (name.substr(0, sizeof(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);
//! [EXPORT] : [COMMENT] Image download failed
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);
//! [EXPORT] : [COMMENT] Image download was successful
static const Event IMAGE_DOWNLOAD_SUCCESSFUL = MAKE_EVENT(3, severity::LOW);
@ -40,39 +40,43 @@ public:
static const Event FLASH_WRITE_FAILED = MAKE_EVENT(6, severity::LOW);
//! [EXPORT] : [COMMENT] Flash read procedure failed
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
//!P1: Return code of failed communication interface read call
//!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
//!P1: Return code of failed communication interface read call
//!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)
//!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);
//! [EXPORT] : [COMMENT] Received reply with invalid type ID
static const Event INVALID_TYPE_ID = MAKE_EVENT(11, severity::LOW);
//! [EXPORT] : [COMMENT] Status field in reply signals error
static const Event STATUS_ERROR = MAKE_EVENT(12, severity::LOW);
static const Event STR_HELPER_NO_REPLY = MAKE_EVENT(14, severity::LOW);
//! [EXPORT] : [COMMENT] Error during decoding of received reply occurred
//P1: Return value of decoding function
//P2: Position of upload/download packet, or address of flash write/read request
static const Event STR_HELPER_DEC_ERROR = MAKE_EVENT(13, severity::LOW);
static const Event STR_HELPER_DEC_ERROR = MAKE_EVENT(15, severity::LOW);
//! [EXPORT] : [COMMENT] Position mismatch
//! P1: The expected position and thus the position for which the image upload/download failed
static const Event POSITION_MISMATCH = MAKE_EVENT(14, severity::LOW);
static const Event POSITION_MISMATCH = MAKE_EVENT(16, severity::LOW);
//! [EXPORT] : [COMMENT] Specified file does not exist
//!P1: Internal state of str helper
static const Event STR_HELPER_FILE_NOT_EXISTS = MAKE_EVENT(15, severity::LOW);
static const Event STR_HELPER_FILE_NOT_EXISTS = MAKE_EVENT(17, severity::LOW);
//! [EXPORT] : [COMMENT] Sending packet to star tracker failed
//!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
static const Event STR_HELPER_SENDING_PACKET_FAILED = MAKE_EVENT(16, severity::LOW);
static const Event STR_HELPER_SENDING_PACKET_FAILED = MAKE_EVENT(18, severity::LOW);
//! [EXPORT] : [COMMENT] Communication interface requesting reply failed
//!P1: Return code of failed request
//!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(17, severity::LOW);
static const Event STR_HELPER_REQUESTING_MSG_FAILED = MAKE_EVENT(19, severity::LOW);
StrHelper(object_id_t objectId);
virtual ~StrHelper();
@ -86,27 +90,54 @@ public:
/**
* @brief Starts sequence to upload image to star tracker
*
* @param image Name including absolute path if to image to upload. Must be previously
* transferred to the OBC with the CFDP protocoll.
* @param uploadImage_ Name including absolute path of the image to upload. Must be previously
* transferred to the OBC with the CFDP protocol.
*/
ReturnValue_t startImageUpload(std::string uploadImage_);
/**
* @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 downloadPath_);
ReturnValue_t startImageDownload(std::string path);
/**
* @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 flashWriteAddress Start address of flash write procedure
* @param address Start address of flash write procedure
*/
ReturnValue_t startFlashWrite(std::string flashWriteFile_, uint8_t region,
uint32_t flashWriteAddress);
ReturnValue_t startFlashWrite(std::string fullname, uint8_t region, uint32_t address);
/**
* @brief Starts the flash read procedure
*
* @param path Path where file with read flash data will be created
* @param region Region ID of flash region to read from
* @param address Start address of flash section to read
* @param length Number of bytes to read from flash
*/
ReturnValue_t startFlashRead(std::string path, uint8_t region, 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 Starts upload of new image to FPGA
*
* @param uploadFile Full name of file containing FPGA image data
*/
ReturnValue_t startFpgaUpload(std::string uploadFile);
/**
* @brief Can be used to interrupt a running data transfer.
@ -116,7 +147,17 @@ public:
/**
* @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
*/
void setFlashReadFilename(std::string filename);
/**
* @brief Set download FPGA image name
*/
void setDownloadFpgaImage(std::string filename);
private:
@ -136,16 +177,48 @@ private:
static const ReturnValue_t ADDRESS_MISMATCH = MAKE_RETURN_CODE(0xA5);
//! [EXPORT] : [COMMENT] Length in flash write/read reply does not match expected length
static const ReturnValue_t LENGTH_MISMATCH = MAKE_RETURN_CODE(0xA6);
//! [EXPORT] : [COMMENT] Status field in reply signals error
static const ReturnValue_t STATUS_ERROR = MAKE_RETURN_CODE(0xA7);
//! [EXPORT] : [COMMENT] Reply has invalid type ID (should be of action reply type)
static const ReturnValue_t INVALID_TYPE_ID = MAKE_RETURN_CODE(0xA8);
// Size of one image part which can be sent per action request
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 DATA_OFFSET = 10;
// 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;
class FpgaUpload {
public:
static const uint32_t MAX_DATA = 1024;
// Full name of file to upload
std::string uploadFile;
};
FpgaUpload fpgaUpload;
static const uint32_t MAX_POLLS = 10000;
static const uint8_t ACTION_DATA_OFFSET = 2;
static const uint8_t POS_OFFSET = 2;
static const uint8_t DATA_OFFSET = 5;
static const uint8_t IMAGE_DATA_OFFSET = 5;
static const uint8_t FLASH_READ_DATA_OFFSET = 8;
static const uint8_t REGION_OFFSET = 2;
static const uint8_t ADDRESS_OFFSET = 3;
static const uint8_t LENGTH_OFFSET = 7;
@ -158,7 +231,9 @@ private:
UPLOAD_IMAGE,
DOWNLOAD_IMAGE,
FLASH_WRITE,
FLASH_READ
FLASH_READ,
DOWNLOAD_FPGA_IMAGE,
UPLOAD_FPGA_IMAGE
};
InternalState internalState = InternalState::IDLE;
@ -167,24 +242,49 @@ private:
BinarySemaphore semaphore;
// Name including absolute path of image to upload
std::string uploadImage;
// Path where the downloaded image will be stored
std::string downloadPath;
// File which contains data to write when executing the flash write command
std::string flashWriteFile;
// Path where the file containing the read data will be stored
std::string flashReadFilePath = "";
class UploadImage {
public:
// Name including absolute path of image to upload
std::string uploadFile;
};
UploadImage uploadImage;
// Default name of downloaded image, can be changed via command
std::string downloadImage = "image";
// Default name of file containing the data read from flash, can be changed via command
std::string flashReadImage = "flashread";
// Will be set with the flash write command
uint8_t flashWriteRegion = 0;
// Will be set with the flash write command and specifies the start address where to write the
// flash data to
uint32_t flashWriteAddress = 0;
class DownloadImage {
public:
// Path where the downloaded image will be stored
std::string path;
// Default name of downloaded image, can be changed via command
std::string filename = "image.bin";
};
DownloadImage downloadImage;
class FlashWrite {
public:
// File which contains data to write when executing the flash write command
std::string fullname;
// Will be set with the flash write command
uint8_t region = 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;
@ -225,6 +325,24 @@ private:
*/
ReturnValue_t performFlashWrite();
/**
* @brief Sends a sequence of commands to the star tracker to read larger parts from the
* flash memory.
*/
ReturnValue_t performFlashRead();
/**
* @brief Performs the download of the FPGA image which requires to be slip over multiple
* action requests.
*/
ReturnValue_t performFpgaDownload();
/**
* @brief Performs upload of new FPGA image. Upload sequence split over multiple commands
* because one command can only transport 1024 bytes of image data.
*/
ReturnValue_t performFpgaUpload();
/**
* @brief Sends packet to the star tracker and reads reply by using the communication
* interface
@ -237,11 +355,11 @@ private:
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
*/
ReturnValue_t checkReply();
ReturnValue_t checkActionReply();
/**
* @brief Checks the position field in a star tracker upload/download reply.
@ -253,12 +371,20 @@ private:
ReturnValue_t checkReplyPosition(uint32_t expectedPosition);
/**
* @brief Checks the region, address and length value of a flash write reply.
* @brief Checks the region, address and length value of a flash write or read reply.
*
* @return RETURN_OK if values match expected values, otherwise appropriate error return
* value.
*/
ReturnValue_t checkFlashWriteReply(struct WriteActionRequest& req);
ReturnValue_t checkFlashActionReply(uint8_t region_, uint32_t address_, uint16_t length_);
/**
* @brief Checks the reply to the fpga download and upload request
*
* @param expectedPosition The expected position value in the reply
* @param expectedLength The expected length field in the reply
*/
ReturnValue_t checkFpgaActionReply(uint32_t expectedPosition, uint32_t expectedLength);
/**
* @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
CCSDS_HANDLER, //CCSDS
ARCSEC_JSON_BASE, //JSONBASE
NVM_PARAM_BASE, //NVMB
COMMON_CLASS_ID_END // [EXPORT] : [END]
};

2
fsfw

@ -1 +1 @@
Subproject commit 2506af27ed84585c64df2679b0c6a3c969f31941
Subproject commit b98c85d33fd79853e674f75dadd0a082a962aee4

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
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
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
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
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
12008;STR_HELPER_READING_REPLY_FAILED;LOW;;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
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
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
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
12013;STR_HELPER_DEC_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
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
12016;STR_HELPER_SENDING_PACKET_FAILED;LOW;;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
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;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;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;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;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_COM_ERROR;LOW;;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_DEC_ERROR;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_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
* Generated on: 2021-12-21 17:08:50
* Generated on: 2021-12-29 20:24:08
*/
#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_WRITE_FAILED_STRING = "FLASH_WRITE_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_COM_ERROR_STRING = "STR_HELPER_COM_ERROR";
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 *POSITION_MISMATCH_STRING = "POSITION_MISMATCH";
const char *STR_HELPER_FILE_NOT_EXISTS_STRING = "STR_HELPER_FILE_NOT_EXISTS";
@ -403,24 +405,28 @@ const char * translateEvents(Event event) {
case(12007):
return FLASH_READ_FAILED_STRING;
case(12008):
return STR_HELPER_READING_REPLY_FAILED_STRING;
return FPGA_DOWNLOAD_SUCCESSFUL_STRING;
case(12009):
return STR_HELPER_COM_ERROR_STRING;
return FPGA_DOWNLOAD_FAILED_STRING;
case(12010):
return STR_HELPER_NO_REPLY_STRING;
return FPGA_UPLOAD_SUCCESSFUL_STRING;
case(12011):
return INVALID_TYPE_ID_STRING;
return FPGA_UPLOAD_FAILED_STRING;
case(12012):
return STATUS_ERROR_STRING;
return STR_HELPER_READING_REPLY_FAILED_STRING;
case(12013):
return STR_HELPER_DEC_ERROR_STRING;
return STR_HELPER_COM_ERROR_STRING;
case(12014):
return POSITION_MISMATCH_STRING;
return STR_HELPER_NO_REPLY_STRING;
case(12015):
return STR_HELPER_FILE_NOT_EXISTS_STRING;
return STR_HELPER_DEC_ERROR_STRING;
case(12016):
return STR_HELPER_SENDING_PACKET_FAILED_STRING;
return POSITION_MISMATCH_STRING;
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;
default:
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
* Generated on: 2021-12-21 17:08:50
* Generated on: 2021-12-29 20:24:08
*/
#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_WRITE_FAILED_STRING = "FLASH_WRITE_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_COM_ERROR_STRING = "STR_HELPER_COM_ERROR";
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 *POSITION_MISMATCH_STRING = "POSITION_MISMATCH";
const char *STR_HELPER_FILE_NOT_EXISTS_STRING = "STR_HELPER_FILE_NOT_EXISTS";
@ -403,24 +405,28 @@ const char * translateEvents(Event event) {
case(12007):
return FLASH_READ_FAILED_STRING;
case(12008):
return STR_HELPER_READING_REPLY_FAILED_STRING;
return FPGA_DOWNLOAD_SUCCESSFUL_STRING;
case(12009):
return STR_HELPER_COM_ERROR_STRING;
return FPGA_DOWNLOAD_FAILED_STRING;
case(12010):
return STR_HELPER_NO_REPLY_STRING;
return FPGA_UPLOAD_SUCCESSFUL_STRING;
case(12011):
return INVALID_TYPE_ID_STRING;
return FPGA_UPLOAD_FAILED_STRING;
case(12012):
return STATUS_ERROR_STRING;
return STR_HELPER_READING_REPLY_FAILED_STRING;
case(12013):
return STR_HELPER_DEC_ERROR_STRING;
return STR_HELPER_COM_ERROR_STRING;
case(12014):
return POSITION_MISMATCH_STRING;
return STR_HELPER_NO_REPLY_STRING;
case(12015):
return STR_HELPER_FILE_NOT_EXISTS_STRING;
return STR_HELPER_DEC_ERROR_STRING;
case(12016):
return STR_HELPER_SENDING_PACKET_FAILED_STRING;
return POSITION_MISMATCH_STRING;
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;
default:
return "UNKNOWN_EVENT";

View File

@ -7,7 +7,7 @@
#include <string>
#include <filesystem>
class NVMParameterBase {
class NVMParameterBase : public HasReturnvaluesIF {
public:
virtual~ NVMParameterBase() {}
@ -34,12 +34,18 @@ public:
ReturnValue_t setValue(std::string key, T value);
template<typename T>
T getValue(std::string key) const;
ReturnValue_t getValue(std::string key, T* value) const;
void printKeys() const;
void print() const;
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;
std::vector<std::string> keys;
std::string fullName;
@ -62,8 +68,12 @@ inline ReturnValue_t NVMParameterBase::setValue(std::string key, T value) {
}
template<typename T>
inline T NVMParameterBase::getValue(std::string key) const {
return json[key];
inline ReturnValue_t NVMParameterBase::getValue(std::string key, T* value) const {
if (!json.contains(key)) {
return KEY_NOT_EXISTS;
}
*value = json[key];
return RETURN_OK;
}
#endif /* BSP_Q7S_CORE_NVMPARAMS_NVMPARAMIF_H_ */

View File

@ -12,8 +12,17 @@ Timestamp::~Timestamp() {
}
std::string Timestamp::str() {
return std::to_string(time.year) + "-" + std::to_string(time.month) + "-"
+ std::to_string(time.day) + "--" + std::to_string(time.hour) + "-"
+ std::to_string(time.minute) + "-" + std::to_string(time.second) + "-";
timestamp << std::to_string(time.year) << "-"
<< std::setw(2) << std::setfill('0')
<< std::to_string(time.month) << "-"
<< std::setw(2) << std::setfill('0')
<< std::to_string(time.day) << "--"
<< std::setw(2) << std::setfill('0')
<< std::to_string(time.hour) << "-"
<< std::setw(2) << std::setfill('0')
<< std::to_string(time.minute) << "-"
<< std::setw(2) << std::setfill('0')
<< std::to_string(time.second) << "--";
return timestamp.str();
}

View File

@ -2,6 +2,8 @@
#define MISSION_UTILITY_TIMESTAMP_H_
#include <string>
#include <sstream>
#include <iomanip>
#include "fsfw/timemanager/Clock.h"
#include "fsfw/returnvalues/HasReturnvaluesIF.h"
@ -21,6 +23,7 @@ public:
std::string str();
private:
std::stringstream timestamp;
Clock::TimeOfDay_t time;
};

@ -1 +1 @@
Subproject commit 2d10c6b85ea4cab4f4baf1918c51d54eee4202c2
Subproject commit f596c53315f1f81facb28faec3150612a5ad2ca0

2
tmtc

@ -1 +1 @@
Subproject commit 242c0e48a9bbcb1039dec6a2b6abba52e826870e
Subproject commit 734dc5aef88d9fef4ad59817b6ea315db954205c