Merge branch 'main' into sus-fdir-reduce-events
All checks were successful
EIVE/eive-obsw/pipeline/pr-main This commit looks good

This commit is contained in:
Robin Müller 2023-10-27 14:05:05 +02:00
commit 3c55a07404
9 changed files with 929 additions and 112 deletions

View File

@ -18,6 +18,11 @@ will consitute of a breaking change warranting a new major release:
## Added
- STR: Added new TM sets: Blob, Blobs, MatchedCentroids, Contrast, AutoBlob, Centroid, Centroids
- STR: Added new mechanism where the secondary TM which is polled can now be a set instead of
being temperature only. An API is exposed which allows to add a data set to that set of secondary
telemetry, reset it back to temperature only, and read the whole set. This allows more debugging
capability.
- CFDP source handler, which allows file downlink using the standardized
CFDP interface.
- Proper back pressure handling for the CFDP handler, where the `LiveTmTask` is able to throttle
@ -41,6 +46,10 @@ will consitute of a breaking change warranting a new major release:
## Changed
- Swapped RTD 9 (PLOC HPA Sensor) and RTD 11 (PLOC MPA Sensor) chip select definitions. It is
strongly suspected the cables for those devices were swapped during integration. This is probably
the easiest way to fix the issue without the need to tweak ground or other OBSW or controller
code.
- Added a 3 second delay in the EIVE system between commanding all PL components except the SUPV,
and the SUPV itself OFF when the power level becomes low or critical.
- SUS FDIR should now trigger less events. The finish event is now only triggered once the

View File

@ -54,6 +54,9 @@ enum I2cAddress : address_t {
};
enum spiAddresses : address_t {
RTD_IC_0,
RTD_IC_1,
RTD_IC_2,
RTD_IC_3,
RTD_IC_4,
RTD_IC_5,
@ -67,9 +70,6 @@ enum spiAddresses : address_t {
RTD_IC_13,
RTD_IC_14,
RTD_IC_15,
RTD_IC_16,
RTD_IC_17,
RTD_IC_18,
RW1,
RW2,
RW3,

View File

@ -37,6 +37,9 @@ enum gpioId_t {
TEST_ID_0,
TEST_ID_1,
RTD_IC_0,
RTD_IC_1,
RTD_IC_2,
RTD_IC_3,
RTD_IC_4,
RTD_IC_5,
@ -50,9 +53,6 @@ enum gpioId_t {
RTD_IC_13,
RTD_IC_14,
RTD_IC_15,
RTD_IC_16,
RTD_IC_17,
RTD_IC_18,
CS_SUS_0,
CS_SUS_1,

View File

@ -206,74 +206,78 @@ void ObjectFactory::createRtdComponents(std::string spiDev, GpioIF* gpioComIF,
GpioCallback* gpioRtdIc0 = new GpioCallback("Chip select RTD IC0", Direction::OUT, Levels::HIGH,
&gpioCallbacks::spiCsDecoderCallback, gpioComIF);
rtdGpioCookie->addGpio(gpioIds::RTD_IC_3, gpioRtdIc0);
rtdGpioCookie->addGpio(gpioIds::RTD_IC_0, gpioRtdIc0);
GpioCallback* gpioRtdIc1 = new GpioCallback("Chip select RTD IC1", Direction::OUT, Levels::HIGH,
&gpioCallbacks::spiCsDecoderCallback, gpioComIF);
rtdGpioCookie->addGpio(gpioIds::RTD_IC_4, gpioRtdIc1);
rtdGpioCookie->addGpio(gpioIds::RTD_IC_1, gpioRtdIc1);
GpioCallback* gpioRtdIc2 = new GpioCallback("Chip select RTD IC2", Direction::OUT, Levels::HIGH,
&gpioCallbacks::spiCsDecoderCallback, gpioComIF);
rtdGpioCookie->addGpio(gpioIds::RTD_IC_5, gpioRtdIc2);
rtdGpioCookie->addGpio(gpioIds::RTD_IC_2, gpioRtdIc2);
GpioCallback* gpioRtdIc3 = new GpioCallback("Chip select RTD IC3", Direction::OUT, Levels::HIGH,
&gpioCallbacks::spiCsDecoderCallback, gpioComIF);
rtdGpioCookie->addGpio(gpioIds::RTD_IC_6, gpioRtdIc3);
rtdGpioCookie->addGpio(gpioIds::RTD_IC_3, gpioRtdIc3);
GpioCallback* gpioRtdIc4 = new GpioCallback("Chip select RTD IC4", Direction::OUT, Levels::HIGH,
&gpioCallbacks::spiCsDecoderCallback, gpioComIF);
rtdGpioCookie->addGpio(gpioIds::RTD_IC_7, gpioRtdIc4);
rtdGpioCookie->addGpio(gpioIds::RTD_IC_4, gpioRtdIc4);
GpioCallback* gpioRtdIc5 = new GpioCallback("Chip select RTD IC5", Direction::OUT, Levels::HIGH,
&gpioCallbacks::spiCsDecoderCallback, gpioComIF);
rtdGpioCookie->addGpio(gpioIds::RTD_IC_8, gpioRtdIc5);
rtdGpioCookie->addGpio(gpioIds::RTD_IC_5, gpioRtdIc5);
GpioCallback* gpioRtdIc6 = new GpioCallback("Chip select RTD IC6", Direction::OUT, Levels::HIGH,
&gpioCallbacks::spiCsDecoderCallback, gpioComIF);
rtdGpioCookie->addGpio(gpioIds::RTD_IC_9, gpioRtdIc6);
rtdGpioCookie->addGpio(gpioIds::RTD_IC_6, gpioRtdIc6);
GpioCallback* gpioRtdIc7 = new GpioCallback("Chip select RTD IC7", Direction::OUT, Levels::HIGH,
&gpioCallbacks::spiCsDecoderCallback, gpioComIF);
rtdGpioCookie->addGpio(gpioIds::RTD_IC_10, gpioRtdIc7);
rtdGpioCookie->addGpio(gpioIds::RTD_IC_7, gpioRtdIc7);
GpioCallback* gpioRtdIc8 = new GpioCallback("Chip select RTD IC8", Direction::OUT, Levels::HIGH,
&gpioCallbacks::spiCsDecoderCallback, gpioComIF);
rtdGpioCookie->addGpio(gpioIds::RTD_IC_11, gpioRtdIc8);
rtdGpioCookie->addGpio(gpioIds::RTD_IC_8, gpioRtdIc8);
GpioCallback* gpioRtdIc9 = new GpioCallback("Chip select RTD IC9", Direction::OUT, Levels::HIGH,
&gpioCallbacks::spiCsDecoderCallback, gpioComIF);
rtdGpioCookie->addGpio(gpioIds::RTD_IC_12, gpioRtdIc9);
rtdGpioCookie->addGpio(gpioIds::RTD_IC_9, gpioRtdIc9);
GpioCallback* gpioRtdIc10 = new GpioCallback("Chip select RTD IC10", Direction::OUT, Levels::HIGH,
&gpioCallbacks::spiCsDecoderCallback, gpioComIF);
rtdGpioCookie->addGpio(gpioIds::RTD_IC_13, gpioRtdIc10);
rtdGpioCookie->addGpio(gpioIds::RTD_IC_10, gpioRtdIc10);
GpioCallback* gpioRtdIc11 = new GpioCallback("Chip select RTD IC11", Direction::OUT, Levels::HIGH,
&gpioCallbacks::spiCsDecoderCallback, gpioComIF);
rtdGpioCookie->addGpio(gpioIds::RTD_IC_14, gpioRtdIc11);
rtdGpioCookie->addGpio(gpioIds::RTD_IC_11, gpioRtdIc11);
GpioCallback* gpioRtdIc12 = new GpioCallback("Chip select RTD IC12", Direction::OUT, Levels::HIGH,
&gpioCallbacks::spiCsDecoderCallback, gpioComIF);
rtdGpioCookie->addGpio(gpioIds::RTD_IC_15, gpioRtdIc12);
rtdGpioCookie->addGpio(gpioIds::RTD_IC_12, gpioRtdIc12);
GpioCallback* gpioRtdIc13 = new GpioCallback("Chip select RTD IC13", Direction::OUT, Levels::HIGH,
&gpioCallbacks::spiCsDecoderCallback, gpioComIF);
rtdGpioCookie->addGpio(gpioIds::RTD_IC_16, gpioRtdIc13);
rtdGpioCookie->addGpio(gpioIds::RTD_IC_13, gpioRtdIc13);
GpioCallback* gpioRtdIc14 = new GpioCallback("Chip select RTD IC14", Direction::OUT, Levels::HIGH,
&gpioCallbacks::spiCsDecoderCallback, gpioComIF);
rtdGpioCookie->addGpio(gpioIds::RTD_IC_17, gpioRtdIc14);
rtdGpioCookie->addGpio(gpioIds::RTD_IC_14, gpioRtdIc14);
GpioCallback* gpioRtdIc15 = new GpioCallback("Chip select RTD IC15", Direction::OUT, Levels::HIGH,
&gpioCallbacks::spiCsDecoderCallback, gpioComIF);
rtdGpioCookie->addGpio(gpioIds::RTD_IC_18, gpioRtdIc15);
rtdGpioCookie->addGpio(gpioIds::RTD_IC_15, gpioRtdIc15);
gpioChecker(gpioComIF->addGpios(rtdGpioCookie), "RTDs");
#if OBSW_ADD_RTD_DEVICES == 1
using namespace EiveMax31855;
// ! NOTE !
// The chip selects for device 9 and 11 are swapped here. It is strongly suspected the cables
// for those devices were swapped during integration. This is probably the easiest way to
// fix the issue.
std::array<std::pair<address_t, gpioId_t>, NUM_RTDS> cookieArgs = {{
{addresses::RTD_IC_0, gpioIds::RTD_IC_0},
{addresses::RTD_IC_1, gpioIds::RTD_IC_1},
{addresses::RTD_IC_2, gpioIds::RTD_IC_2},
{addresses::RTD_IC_3, gpioIds::RTD_IC_3},
{addresses::RTD_IC_4, gpioIds::RTD_IC_4},
{addresses::RTD_IC_5, gpioIds::RTD_IC_5},
{addresses::RTD_IC_6, gpioIds::RTD_IC_6},
{addresses::RTD_IC_7, gpioIds::RTD_IC_7},
{addresses::RTD_IC_8, gpioIds::RTD_IC_8},
{addresses::RTD_IC_9, gpioIds::RTD_IC_9},
{addresses::RTD_IC_10, gpioIds::RTD_IC_10},
{addresses::RTD_IC_11, gpioIds::RTD_IC_11},
{addresses::RTD_IC_10, gpioIds::RTD_IC_10},
{addresses::RTD_IC_9, gpioIds::RTD_IC_9},
{addresses::RTD_IC_12, gpioIds::RTD_IC_12},
{addresses::RTD_IC_13, gpioIds::RTD_IC_13},
{addresses::RTD_IC_14, gpioIds::RTD_IC_14},
{addresses::RTD_IC_15, gpioIds::RTD_IC_15},
{addresses::RTD_IC_16, gpioIds::RTD_IC_16},
{addresses::RTD_IC_17, gpioIds::RTD_IC_17},
{addresses::RTD_IC_18, gpioIds::RTD_IC_18},
}};
// HSPD: Heatspreader

View File

@ -21,6 +21,18 @@ void gpioCallbacks::spiCsDecoderCallback(gpioId_t gpioId, gpio::GpioOperation gp
if (value == gpio::Levels::HIGH) {
switch (gpioId) {
case (gpioIds::RTD_IC_0): {
disableDecoderTcsIc1(gpioIF);
break;
}
case (gpioIds::RTD_IC_1): {
disableDecoderTcsIc1(gpioIF);
break;
}
case (gpioIds::RTD_IC_2): {
disableDecoderTcsIc1(gpioIF);
break;
}
case (gpioIds::RTD_IC_3): {
disableDecoderTcsIc1(gpioIF);
break;
@ -42,15 +54,15 @@ void gpioCallbacks::spiCsDecoderCallback(gpioId_t gpioId, gpio::GpioOperation gp
break;
}
case (gpioIds::RTD_IC_8): {
disableDecoderTcsIc1(gpioIF);
disableDecoderTcsIc2(gpioIF);
break;
}
case (gpioIds::RTD_IC_9): {
disableDecoderTcsIc1(gpioIF);
disableDecoderTcsIc2(gpioIF);
break;
}
case (gpioIds::RTD_IC_10): {
disableDecoderTcsIc1(gpioIF);
disableDecoderTcsIc2(gpioIF);
break;
}
case (gpioIds::RTD_IC_11): {
@ -73,18 +85,6 @@ void gpioCallbacks::spiCsDecoderCallback(gpioId_t gpioId, gpio::GpioOperation gp
disableDecoderTcsIc2(gpioIF);
break;
}
case (gpioIds::RTD_IC_16): {
disableDecoderTcsIc2(gpioIF);
break;
}
case (gpioIds::RTD_IC_17): {
disableDecoderTcsIc2(gpioIF);
break;
}
case (gpioIds::RTD_IC_18): {
disableDecoderTcsIc2(gpioIF);
break;
}
case (gpioIds::CS_SUS_0): {
disableDecoderInterfaceBoardIc1(gpioIF);
break;
@ -154,82 +154,82 @@ void gpioCallbacks::spiCsDecoderCallback(gpioId_t gpioId, gpio::GpioOperation gp
}
} else if (value == gpio::Levels::LOW) {
switch (gpioId) {
case (gpioIds::RTD_IC_3): {
case (gpioIds::RTD_IC_0): {
selectY7(gpioIF);
enableDecoderTcsIc1(gpioIF);
break;
}
case (gpioIds::RTD_IC_1): {
selectY6(gpioIF);
enableDecoderTcsIc1(gpioIF);
break;
}
case (gpioIds::RTD_IC_2): {
selectY5(gpioIF);
enableDecoderTcsIc1(gpioIF);
break;
}
case (gpioIds::RTD_IC_3): {
selectY4(gpioIF);
enableDecoderTcsIc1(gpioIF);
break;
}
case (gpioIds::RTD_IC_4): {
selectY6(gpioIF);
selectY3(gpioIF);
enableDecoderTcsIc1(gpioIF);
break;
}
case (gpioIds::RTD_IC_5): {
selectY5(gpioIF);
selectY2(gpioIF);
enableDecoderTcsIc1(gpioIF);
break;
}
case (gpioIds::RTD_IC_6): {
selectY4(gpioIF);
selectY1(gpioIF);
enableDecoderTcsIc1(gpioIF);
break;
}
case (gpioIds::RTD_IC_7): {
selectY3(gpioIF);
enableDecoderTcsIc1(gpioIF);
break;
}
case (gpioIds::RTD_IC_8): {
selectY2(gpioIF);
enableDecoderTcsIc1(gpioIF);
break;
}
case (gpioIds::RTD_IC_9): {
selectY1(gpioIF);
enableDecoderTcsIc1(gpioIF);
break;
}
case (gpioIds::RTD_IC_10): {
selectY0(gpioIF);
enableDecoderTcsIc1(gpioIF);
break;
}
case (gpioIds::RTD_IC_11): {
case (gpioIds::RTD_IC_8): {
selectY7(gpioIF);
enableDecoderTcsIc2(gpioIF);
break;
}
case (gpioIds::RTD_IC_12): {
case (gpioIds::RTD_IC_9): {
selectY6(gpioIF);
enableDecoderTcsIc2(gpioIF);
break;
}
case (gpioIds::RTD_IC_13): {
case (gpioIds::RTD_IC_10): {
selectY5(gpioIF);
enableDecoderTcsIc2(gpioIF);
break;
}
case (gpioIds::RTD_IC_14): {
case (gpioIds::RTD_IC_11): {
selectY4(gpioIF);
enableDecoderTcsIc2(gpioIF);
break;
}
case (gpioIds::RTD_IC_15): {
case (gpioIds::RTD_IC_12): {
selectY3(gpioIF);
enableDecoderTcsIc2(gpioIF);
break;
}
case (gpioIds::RTD_IC_16): {
case (gpioIds::RTD_IC_13): {
selectY2(gpioIF);
enableDecoderTcsIc2(gpioIF);
break;
}
case (gpioIds::RTD_IC_17): {
case (gpioIds::RTD_IC_14): {
selectY1(gpioIF);
enableDecoderTcsIc2(gpioIF);
break;
}
case (gpioIds::RTD_IC_18): {
case (gpioIds::RTD_IC_15): {
selectY0(gpioIF);
enableDecoderTcsIc2(gpioIF);
break;

View File

@ -49,6 +49,13 @@ StarTrackerHandler::StarTrackerHandler(object_id_t objectId, object_id_t comIF,
subscriptionSet(this),
logSubscriptionSet(this),
debugCameraSet(this),
autoBlobSet(this),
matchedCentroidsSet(this),
blobSet(this),
blobsSet(this),
centroidSet(this),
centroidsSet(this),
contrastSet(this),
strHelper(strHelper),
paramJsonFile(jsonFileStr),
powerSwitch(powerSwitch) {
@ -59,6 +66,8 @@ StarTrackerHandler::StarTrackerHandler(object_id_t objectId, object_id_t comIF,
sif::error << "StarTrackerHandler: Invalid str image loader" << std::endl;
}
eventQueue = QueueFactory::instance()->createMessageQueue(EventMessage::EVENT_MESSAGE_SIZE * 5);
additionalRequestedTm.emplace(startracker::REQ_TEMPERATURE);
currentSecondaryTmIter = additionalRequestedTm.begin();
}
StarTrackerHandler::~StarTrackerHandler() {}
@ -165,6 +174,35 @@ ReturnValue_t StarTrackerHandler::executeAction(ActionId_t actionId, MessageQueu
ReturnValue_t result = returnvalue::OK;
switch (actionId) {
case (startracker::ADD_SECONDARY_TM_TO_NORMAL_MODE): {
if (size < 4) {
return HasActionsIF::INVALID_PARAMETERS;
}
DeviceCommandId_t idToAdd;
result =
SerializeAdapter::deSerialize(&idToAdd, data, &size, SerializeIF::Endianness::NETWORK);
if (result != returnvalue::OK) {
return result;
}
addSecondaryTmForNormalMode(idToAdd);
return EXECUTION_FINISHED;
}
case (startracker::RESET_SECONDARY_TM_SET): {
resetSecondaryTmSet();
return EXECUTION_FINISHED;
}
case (startracker::READ_SECONDARY_TM_SET): {
std::vector<uint8_t> dataVec(additionalRequestedTm.size() * 4);
unsigned idx = 0;
size_t serLen = 0;
for (const auto& cmd : additionalRequestedTm) {
SerializeAdapter::serialize(&cmd, dataVec.data() + idx * 4, &serLen, dataVec.size(),
SerializeIF::Endianness::NETWORK);
idx++;
}
actionHelper.reportData(commandedBy, actionId, dataVec.data(), dataVec.size());
return EXECUTION_FINISHED;
}
case (startracker::STOP_IMAGE_LOADER): {
strHelper->stopProcess();
return EXECUTION_FINISHED;
@ -306,13 +344,20 @@ ReturnValue_t StarTrackerHandler::buildNormalDeviceCommand(DeviceCommandId_t* id
return NOTHING_TO_SEND;
}
switch (normalState) {
case NormalState::TEMPERATURE_REQUEST:
*id = startracker::REQ_TEMPERATURE;
case NormalState::SECONDARY_REQUEST:
if (additionalRequestedTm.size() == 0) {
break;
}
*id = *currentSecondaryTmIter;
currentSecondaryTmIter++;
if (currentSecondaryTmIter == additionalRequestedTm.end()) {
currentSecondaryTmIter = additionalRequestedTm.begin();
}
normalState = NormalState::SOLUTION_REQUEST;
break;
case NormalState::SOLUTION_REQUEST:
*id = startracker::REQ_SOLUTION;
normalState = NormalState::TEMPERATURE_REQUEST;
normalState = NormalState::SECONDARY_REQUEST;
break;
default:
sif::debug << "StarTrackerHandler::buildNormalDeviceCommand: Invalid normal step"
@ -472,6 +517,18 @@ ReturnValue_t StarTrackerHandler::buildCommandFromCommand(DeviceCommandId_t devi
prepareTimeRequest();
return returnvalue::OK;
}
case (startracker::REQ_CENTROID): {
prepareRequestCentroidTm();
return returnvalue::OK;
}
case (startracker::REQ_CENTROIDS): {
prepareRequestCentroidsTm();
return returnvalue::OK;
}
case (startracker::REQ_CONTRAST): {
prepareRequestContrastTm();
return returnvalue::OK;
}
case (startracker::BOOT): {
prepareBootCommand();
return returnvalue::OK;
@ -607,6 +664,22 @@ ReturnValue_t StarTrackerHandler::buildCommandFromCommand(DeviceCommandId_t devi
result = prepareRequestLisaParams();
return result;
}
case (startracker::REQ_MATCHED_CENTROIDS): {
result = prepareRequestMatchedCentroidsTm();
return result;
}
case (startracker::REQ_BLOB): {
result = prepareRequestBlobTm();
return result;
}
case (startracker::REQ_BLOBS): {
result = prepareRequestBlobsTm();
return result;
}
case (startracker::REQ_AUTO_BLOB): {
result = prepareRequestAutoBlobTm();
return returnvalue::OK;
}
case (startracker::REQ_MATCHING): {
result = prepareRequestMatchingParams();
return result;
@ -729,6 +802,20 @@ void StarTrackerHandler::fillCommandAndReplyMap() {
startracker::MAX_FRAME_SIZE * 2 + 2);
this->insertInCommandAndReplyMap(startracker::REQ_DEBUG_CAMERA, 3, &debugCameraSet,
startracker::MAX_FRAME_SIZE * 2 + 2);
this->insertInCommandAndReplyMap(startracker::REQ_AUTO_BLOB, 3, &autoBlobSet,
startracker::MAX_FRAME_SIZE * 2 + 2);
this->insertInCommandAndReplyMap(startracker::REQ_MATCHED_CENTROIDS, 3, &matchedCentroidsSet,
startracker::MAX_FRAME_SIZE * 2 + 2);
this->insertInCommandAndReplyMap(startracker::REQ_BLOB, 3, &blobSet,
startracker::MAX_FRAME_SIZE * 2 + 2);
this->insertInCommandAndReplyMap(startracker::REQ_BLOBS, 3, &blobsSet,
startracker::MAX_FRAME_SIZE * 2 + 2);
this->insertInCommandAndReplyMap(startracker::REQ_CENTROID, 3, &centroidSet,
startracker::MAX_FRAME_SIZE * 2 + 2);
this->insertInCommandAndReplyMap(startracker::REQ_CENTROIDS, 3, &centroidsSet,
startracker::MAX_FRAME_SIZE * 2 + 2);
this->insertInCommandAndReplyMap(startracker::REQ_CONTRAST, 3, &contrastSet,
startracker::MAX_FRAME_SIZE * 2 + 2);
}
ReturnValue_t StarTrackerHandler::isModeCombinationValid(Mode_t mode, Submode_t submode) {
@ -860,6 +947,74 @@ void StarTrackerHandler::setUpJsonCfgs(JsonConfigs& cfgs, const char* paramJsonF
JCFG_DONE = true;
}
ReturnValue_t StarTrackerHandler::statusFieldCheck(const uint8_t* rawFrame) {
uint8_t status = startracker::getStatusField(rawFrame);
if (status != startracker::STATUS_OK) {
sif::warning << "StarTrackerHandler::handleTm: Reply error: "
<< static_cast<unsigned int>(status) << std::endl;
return REPLY_ERROR;
}
return returnvalue::OK;
}
void StarTrackerHandler::addSecondaryTmForNormalMode(DeviceCommandId_t cmd) {
additionalRequestedTm.emplace(cmd);
}
void StarTrackerHandler::resetSecondaryTmSet() {
additionalRequestedTm.clear();
additionalRequestedTm.emplace(startracker::REQ_TEMPERATURE);
currentSecondaryTmIter = additionalRequestedTm.begin();
{
PoolReadGuard pg(&autoBlobSet);
if (pg.getReadResult() == returnvalue::OK) {
autoBlobSet.setValidity(false, true);
}
}
{
PoolReadGuard pg(&matchedCentroidsSet);
if (pg.getReadResult() == returnvalue::OK) {
matchedCentroidsSet.setValidity(false, true);
}
}
{
PoolReadGuard pg(&blobSet);
if (pg.getReadResult() == returnvalue::OK) {
blobSet.setValidity(false, true);
}
}
{
PoolReadGuard pg(&blobsSet);
if (pg.getReadResult() == returnvalue::OK) {
blobsSet.setValidity(false, true);
}
}
{
PoolReadGuard pg(&centroidSet);
if (pg.getReadResult() == returnvalue::OK) {
centroidSet.setValidity(false, true);
}
}
{
PoolReadGuard pg(&contrastSet);
if (pg.getReadResult() == returnvalue::OK) {
contrastSet.setValidity(false, true);
}
}
{
PoolReadGuard pg(&centroidsSet);
if (pg.getReadResult() == returnvalue::OK) {
centroidsSet.setValidity(false, true);
}
}
{
PoolReadGuard pg(&histogramSet);
if (pg.getReadResult() == returnvalue::OK) {
histogramSet.setValidity(false, true);
}
}
}
void StarTrackerHandler::bootBootloader() {
if (internalState == InternalState::IDLE) {
internalState = InternalState::BOOT_BOOTLOADER;
@ -896,24 +1051,24 @@ ReturnValue_t StarTrackerHandler::scanForReply(const uint8_t* start, size_t rema
}
case TMTC_ACTIONREPLY: {
*foundLen = remainingSize;
fullPacketLen = remainingSize;
return scanForActionReply(startracker::getId(start), foundId);
break;
}
case TMTC_SETPARAMREPLY: {
*foundLen = remainingSize;
fullPacketLen = remainingSize;
return scanForSetParameterReply(startracker::getId(start), foundId);
break;
}
case TMTC_PARAMREPLY: {
*foundLen = remainingSize;
fullPacketLen = remainingSize;
return scanForGetParameterReply(startracker::getId(start), foundId);
break;
}
case TMTC_TELEMETRYREPLYA:
case TMTC_TELEMETRYREPLY: {
*foundLen = remainingSize;
fullPacketLen = remainingSize;
return scanForTmReply(startracker::getId(start), foundId);
break;
}
default: {
sif::debug << "StarTrackerHandler::scanForReply: Reply has invalid type id" << std::endl;
@ -933,7 +1088,7 @@ ReturnValue_t StarTrackerHandler::interpretDeviceReply(DeviceCommandId_t id,
break;
}
case (startracker::REQ_TIME): {
result = handleTm(packet, timeSet, startracker::TimeSet::SIZE, "REQ_TIME");
result = handleTm(packet, timeSet, "REQ_TIME");
break;
}
case (startracker::PING_REQUEST): {
@ -948,7 +1103,7 @@ ReturnValue_t StarTrackerHandler::interpretDeviceReply(DeviceCommandId_t id,
break;
}
case (startracker::REQ_VERSION): {
result = handleTm(packet, versionSet, startracker::VersionSet::SIZE, "REQ_VERSION");
result = handleTm(packet, versionSet, "REQ_VERSION");
if (result != returnvalue::OK) {
return result;
}
@ -959,23 +1114,51 @@ ReturnValue_t StarTrackerHandler::interpretDeviceReply(DeviceCommandId_t id,
break;
}
case (startracker::REQ_INTERFACE): {
result = handleTm(packet, interfaceSet, startracker::InterfaceSet::SIZE, "REQ_INTERFACE");
result = handleTm(packet, interfaceSet, "REQ_INTERFACE");
break;
}
case (startracker::REQ_POWER): {
result = handleTm(packet, powerSet, startracker::PowerSet::SIZE, "REQ_POWER");
result = handleTm(packet, powerSet, "REQ_POWER");
break;
}
case (startracker::REQ_SOLUTION): {
result = handleTm(packet, solutionSet, startracker::SolutionSet::SIZE, "REQ_SOLUTION");
result = handleTm(packet, solutionSet, "REQ_SOLUTION");
break;
}
case (startracker::REQ_CONTRAST): {
result = handleTm(packet, contrastSet, "REQ_CONTRAST");
break;
}
case (startracker::REQ_AUTO_BLOB): {
result = handleAutoBlobTm(packet);
break;
}
case (startracker::REQ_MATCHED_CENTROIDS): {
result = handleMatchedCentroidTm(packet);
break;
}
case (startracker::REQ_BLOB): {
result = handleBlobTm(packet);
break;
}
case (startracker::REQ_BLOBS): {
result = handleBlobsTm(packet);
break;
}
case (startracker::REQ_CENTROID): {
result = handleCentroidTm(packet);
break;
}
case (startracker::REQ_CENTROIDS): {
result = handleCentroidsTm(packet);
break;
}
case (startracker::REQ_TEMPERATURE): {
result = handleTm(packet, temperatureSet, startracker::TemperatureSet::SIZE, "REQ_TEMP");
result = handleTm(packet, temperatureSet, "REQ_TEMP");
break;
}
case (startracker::REQ_HISTOGRAM): {
result = handleTm(packet, histogramSet, startracker::HistogramSet::SIZE, "REQ_HISTO");
result = handleTm(packet, histogramSet, "REQ_HISTO");
break;
}
case (startracker::SUBSCRIPTION):
@ -1329,6 +1512,56 @@ ReturnValue_t StarTrackerHandler::initializeLocalDataPool(localpool::DataPool& l
localDataPoolMap.emplace(startracker::CHKSUM, new PoolEntry<uint32_t>({0}));
localDataPoolMap.emplace(startracker::TICKS_AUTO_BLOB, new PoolEntry<uint32_t>());
localDataPoolMap.emplace(startracker::TIME_AUTO_BLOB, new PoolEntry<uint64_t>());
localDataPoolMap.emplace(startracker::AUTO_BLOB_THRESHOLD, new PoolEntry<float>());
localDataPoolMap.emplace(startracker::PoolIds::NUM_MATCHED_CENTROIDS, new PoolEntry<uint8_t>());
localDataPoolMap.emplace(startracker::PoolIds::MATCHED_CENTROIDS_STAR_IDS,
new PoolEntry<uint32_t>(16));
localDataPoolMap.emplace(startracker::PoolIds::MATCHED_CENTROIDS_X_COORDS,
new PoolEntry<float>(16));
localDataPoolMap.emplace(startracker::PoolIds::MATCHED_CENTROIDS_Y_COORDS,
new PoolEntry<float>(16));
localDataPoolMap.emplace(startracker::PoolIds::MATCHED_CENTROIDS_X_ERRORS,
new PoolEntry<float>(16));
localDataPoolMap.emplace(startracker::PoolIds::MATCHED_CENTROIDS_Y_ERRORS,
new PoolEntry<float>(16));
localDataPoolMap.emplace(startracker::PoolIds::TICKS_MATCHED_CENTROIDS,
new PoolEntry<uint32_t>());
localDataPoolMap.emplace(startracker::PoolIds::TIME_MATCHED_CENTROIDS, new PoolEntry<uint64_t>());
localDataPoolMap.emplace(startracker::PoolIds::BLOB_TICKS, new PoolEntry<uint32_t>());
localDataPoolMap.emplace(startracker::PoolIds::BLOB_TIME, new PoolEntry<uint64_t>());
localDataPoolMap.emplace(startracker::PoolIds::BLOB_COUNT, new PoolEntry<uint32_t>());
localDataPoolMap.emplace(startracker::PoolIds::BLOBS_TICKS, new PoolEntry<uint32_t>());
localDataPoolMap.emplace(startracker::PoolIds::BLOBS_TIME, new PoolEntry<uint64_t>());
localDataPoolMap.emplace(startracker::PoolIds::BLOBS_COUNT, new PoolEntry<uint16_t>());
localDataPoolMap.emplace(startracker::PoolIds::BLOBS_COUNT_USED, new PoolEntry<uint16_t>());
localDataPoolMap.emplace(startracker::PoolIds::BLOBS_NR_4LINES_SKIPPED,
new PoolEntry<uint16_t>());
localDataPoolMap.emplace(startracker::PoolIds::BLOBS_X_COORDS, new PoolEntry<uint16_t>(8));
localDataPoolMap.emplace(startracker::PoolIds::BLOBS_Y_COORDS, new PoolEntry<uint16_t>(8));
localDataPoolMap.emplace(startracker::PoolIds::CENTROID_TICKS, new PoolEntry<uint32_t>());
localDataPoolMap.emplace(startracker::PoolIds::CENTROID_TIME, new PoolEntry<uint64_t>());
localDataPoolMap.emplace(startracker::PoolIds::CENTROID_COUNT, new PoolEntry<uint32_t>());
localDataPoolMap.emplace(startracker::PoolIds::CENTROIDS_TICKS, new PoolEntry<uint32_t>());
localDataPoolMap.emplace(startracker::PoolIds::CENTROIDS_TIME, new PoolEntry<uint64_t>());
localDataPoolMap.emplace(startracker::PoolIds::CENTROIDS_COUNT, new PoolEntry<uint16_t>());
localDataPoolMap.emplace(startracker::PoolIds::CENTROIDS_X_COORDS, new PoolEntry<float>(16));
localDataPoolMap.emplace(startracker::PoolIds::CENTROIDS_Y_COORDS, new PoolEntry<float>(16));
localDataPoolMap.emplace(startracker::PoolIds::CENTROIDS_MAGNITUDES, new PoolEntry<uint8_t>(16));
localDataPoolMap.emplace(startracker::PoolIds::CONTRAST_TICKS, new PoolEntry<uint32_t>());
localDataPoolMap.emplace(startracker::PoolIds::CONTRAST_TIME, new PoolEntry<uint64_t>());
localDataPoolMap.emplace(startracker::PoolIds::CONTRAST_A, new PoolEntry<uint32_t>(9));
localDataPoolMap.emplace(startracker::PoolIds::CONTRAST_B, new PoolEntry<uint32_t>(9));
localDataPoolMap.emplace(startracker::PoolIds::CONTRAST_C, new PoolEntry<uint32_t>(9));
localDataPoolMap.emplace(startracker::PoolIds::CONTRAST_D, new PoolEntry<uint32_t>(9));
poolManager.subscribeForDiagPeriodicPacket(
subdp::DiagnosticsHkPeriodicParams(temperatureSet.getSid(), false, 10.0));
poolManager.subscribeForRegularPeriodicPacket(
@ -1343,6 +1576,20 @@ ReturnValue_t StarTrackerHandler::initializeLocalDataPool(localpool::DataPool& l
subdp::RegularHkPeriodicParams(histogramSet.getSid(), false, 10.0));
poolManager.subscribeForRegularPeriodicPacket(
subdp::RegularHkPeriodicParams(lisaSet.getSid(), false, 10.0));
poolManager.subscribeForRegularPeriodicPacket(
subdp::RegularHkPeriodicParams(autoBlobSet.getSid(), false, 10.0));
poolManager.subscribeForRegularPeriodicPacket(
subdp::RegularHkPeriodicParams(matchedCentroidsSet.getSid(), false, 10.0));
poolManager.subscribeForRegularPeriodicPacket(
subdp::RegularHkPeriodicParams(blobSet.getSid(), false, 10.0));
poolManager.subscribeForRegularPeriodicPacket(
subdp::RegularHkPeriodicParams(blobsSet.getSid(), false, 10.0));
poolManager.subscribeForRegularPeriodicPacket(
subdp::RegularHkPeriodicParams(centroidSet.getSid(), false, 10.0));
poolManager.subscribeForRegularPeriodicPacket(
subdp::RegularHkPeriodicParams(centroidsSet.getSid(), false, 10.0));
poolManager.subscribeForRegularPeriodicPacket(
subdp::RegularHkPeriodicParams(contrastSet.getSid(), false, 10.0));
return returnvalue::OK;
}
@ -1584,8 +1831,36 @@ ReturnValue_t StarTrackerHandler::scanForTmReply(uint8_t replyId, DeviceCommandI
*foundId = startracker::REQ_SOLUTION;
break;
}
case (startracker::ID::BLOB): {
*foundId = startracker::REQ_BLOB;
break;
}
case (startracker::ID::BLOBS): {
*foundId = startracker::REQ_BLOBS;
break;
}
case (startracker::ID::CENTROID): {
*foundId = startracker::REQ_CENTROID;
break;
}
case (startracker::ID::CENTROIDS): {
*foundId = startracker::REQ_CENTROIDS;
break;
}
case (startracker::ID::AUTO_BLOB): {
*foundId = startracker::REQ_AUTO_BLOB;
break;
}
case (startracker::ID::MATCHED_CENTROIDS): {
*foundId = startracker::REQ_MATCHED_CENTROIDS;
break;
}
case (startracker::ID::CONTRAST): {
*foundId = startracker::REQ_CONTRAST;
break;
}
default: {
sif::debug << "StarTrackerHandler::scanForTmReply: Reply contains invalid reply id: "
sif::debug << "StarTrackerHandler::scanForTmReply: Reply contains invalid reply ID: "
<< static_cast<unsigned int>(replyId) << std::endl;
return returnvalue::FAILED;
break;
@ -1760,6 +2035,62 @@ void StarTrackerHandler::prepareHistogramRequest() {
rawPacketLen = length;
}
ReturnValue_t StarTrackerHandler::prepareRequestAutoBlobTm() {
uint32_t length = 0;
arc_tm_pack_autoblob_req(commandBuffer, &length);
rawPacket = commandBuffer;
rawPacketLen = length;
return returnvalue::OK;
}
ReturnValue_t StarTrackerHandler::prepareRequestMatchedCentroidsTm() {
uint32_t length = 0;
arc_tm_pack_matchedcentroids_req(commandBuffer, &length);
rawPacket = commandBuffer;
rawPacketLen = length;
return returnvalue::OK;
}
ReturnValue_t StarTrackerHandler::prepareRequestBlobTm() {
uint32_t length = 0;
arc_tm_pack_blob_req(commandBuffer, &length);
rawPacket = commandBuffer;
rawPacketLen = length;
return returnvalue::OK;
}
ReturnValue_t StarTrackerHandler::prepareRequestBlobsTm() {
uint32_t length = 0;
arc_tm_pack_blobs_req(commandBuffer, &length);
rawPacket = commandBuffer;
rawPacketLen = length;
return returnvalue::OK;
}
ReturnValue_t StarTrackerHandler::prepareRequestCentroidTm() {
uint32_t length = 0;
arc_tm_pack_centroid_req(commandBuffer, &length);
rawPacket = commandBuffer;
rawPacketLen = length;
return returnvalue::OK;
}
ReturnValue_t StarTrackerHandler::prepareRequestCentroidsTm() {
uint32_t length = 0;
arc_tm_pack_centroids_req(commandBuffer, &length);
rawPacket = commandBuffer;
rawPacketLen = length;
return returnvalue::OK;
}
ReturnValue_t StarTrackerHandler::prepareRequestContrastTm() {
uint32_t length = 0;
arc_tm_pack_contrast_req(commandBuffer, &length);
rawPacket = commandBuffer;
rawPacketLen = length;
return returnvalue::OK;
}
ReturnValue_t StarTrackerHandler::prepareParamCommand(const uint8_t* commandData,
size_t commandDataLen,
ArcsecJsonParamBase& paramSet,
@ -2038,13 +2369,10 @@ ReturnValue_t StarTrackerHandler::checkProgram() {
}
ReturnValue_t StarTrackerHandler::handleTm(const uint8_t* rawFrame, LocalPoolDataSetBase& dataset,
size_t size, const char* context) {
ReturnValue_t result = returnvalue::OK;
uint8_t status = startracker::getStatusField(rawFrame);
if (status != startracker::STATUS_OK) {
sif::warning << "StarTrackerHandler::handleTm: Reply error: "
<< static_cast<unsigned int>(status) << std::endl;
return REPLY_ERROR;
const char* context) {
ReturnValue_t result = statusFieldCheck(rawFrame);
if (result != returnvalue::OK) {
return result;
}
result = dataset.read(TIMEOUT_TYPE, MUTEX_TIMEOUT);
if (result != returnvalue::OK) {
@ -2052,10 +2380,11 @@ ReturnValue_t StarTrackerHandler::handleTm(const uint8_t* rawFrame, LocalPoolDat
}
const uint8_t* reply = rawFrame + TICKS_OFFSET;
dataset.setValidityBufferGeneration(false);
result = dataset.deSerialize(&reply, &size, SerializeIF::Endianness::LITTLE);
size_t sizeLeft = fullPacketLen;
result = dataset.deSerialize(&reply, &sizeLeft, SerializeIF::Endianness::LITTLE);
if (result != returnvalue::OK) {
sif::warning << "StarTrackerHandler::handleTm: Deserialization failed for " << context
<< std::endl;
sif::warning << "StarTrackerHandler::handleTm: Deserialization failed for " << context << ": 0x"
<< std::hex << std::setw(4) << result << std::dec << std::endl;
}
dataset.setValidityBufferGeneration(true);
dataset.setValidity(true, true);
@ -2069,6 +2398,262 @@ ReturnValue_t StarTrackerHandler::handleTm(const uint8_t* rawFrame, LocalPoolDat
return result;
}
ReturnValue_t StarTrackerHandler::handleAutoBlobTm(const uint8_t* rawFrame) {
ReturnValue_t result = statusFieldCheck(rawFrame);
if (result != returnvalue::OK) {
return result;
}
rawFrame += TICKS_OFFSET;
size_t remainingLen = fullPacketLen;
PoolReadGuard pg(&autoBlobSet);
result = pg.getReadResult();
if (result != returnvalue::OK) {
return result;
}
result = SerializeAdapter::deSerialize(&autoBlobSet.ticks, &rawFrame, &remainingLen,
SerializeIF::Endianness::LITTLE);
if (result != returnvalue::OK) {
return result;
}
result = SerializeAdapter::deSerialize(&autoBlobSet.timeUs, &rawFrame, &remainingLen,
SerializeIF::Endianness::LITTLE);
if (result != returnvalue::OK) {
return result;
}
result = SerializeAdapter::deSerialize(&autoBlobSet.threshold, &rawFrame, &remainingLen,
SerializeIF::Endianness::LITTLE);
if (result != returnvalue::OK) {
return result;
}
autoBlobSet.setValidity(true, true);
return returnvalue::OK;
}
ReturnValue_t StarTrackerHandler::handleMatchedCentroidTm(const uint8_t* rawFrame) {
ReturnValue_t result = statusFieldCheck(rawFrame);
if (result != returnvalue::OK) {
return result;
}
rawFrame += TICKS_OFFSET;
size_t remainingLen = fullPacketLen;
PoolReadGuard pg(&matchedCentroidsSet);
result = pg.getReadResult();
if (result != returnvalue::OK) {
return result;
}
result = SerializeAdapter::deSerialize(&matchedCentroidsSet.ticks, &rawFrame, &remainingLen,
SerializeIF::Endianness::LITTLE);
if (result != returnvalue::OK) {
return result;
}
result = SerializeAdapter::deSerialize(&matchedCentroidsSet.timeUs, &rawFrame, &remainingLen,
SerializeIF::Endianness::LITTLE);
if (result != returnvalue::OK) {
return result;
}
result = SerializeAdapter::deSerialize(&matchedCentroidsSet.numberOfMatchedCentroids, &rawFrame,
&remainingLen, SerializeIF::Endianness::LITTLE);
if (result != returnvalue::OK) {
return result;
}
// Yeah, we serialize it like that because I can't model anything with that local datapool crap.
for (unsigned idx = 0; idx < 16; idx++) {
result = SerializeAdapter::deSerialize(&matchedCentroidsSet.starIds[idx], &rawFrame,
&remainingLen, SerializeIF::Endianness::LITTLE);
if (result != returnvalue::OK) {
return result;
}
result = SerializeAdapter::deSerialize(&matchedCentroidsSet.xCoords[idx], &rawFrame,
&remainingLen, SerializeIF::Endianness::LITTLE);
if (result != returnvalue::OK) {
return result;
}
result = SerializeAdapter::deSerialize(&matchedCentroidsSet.yCoords[idx], &rawFrame,
&remainingLen, SerializeIF::Endianness::LITTLE);
if (result != returnvalue::OK) {
return result;
}
result = SerializeAdapter::deSerialize(&matchedCentroidsSet.xErrors[idx], &rawFrame,
&remainingLen, SerializeIF::Endianness::LITTLE);
if (result != returnvalue::OK) {
return result;
}
result = SerializeAdapter::deSerialize(&matchedCentroidsSet.yErrors[idx], &rawFrame,
&remainingLen, SerializeIF::Endianness::LITTLE);
if (result != returnvalue::OK) {
return result;
}
}
matchedCentroidsSet.setValidity(true, true);
return returnvalue::OK;
}
ReturnValue_t StarTrackerHandler::handleBlobTm(const uint8_t* rawFrame) {
ReturnValue_t result = statusFieldCheck(rawFrame);
if (result != returnvalue::OK) {
return result;
}
rawFrame += TICKS_OFFSET;
size_t remainingLen = fullPacketLen;
PoolReadGuard pg(&blobsSet);
result = pg.getReadResult();
if (result != returnvalue::OK) {
return result;
}
result = SerializeAdapter::deSerialize(&blobSet.ticks, &rawFrame, &remainingLen,
SerializeIF::Endianness::LITTLE);
if (result != returnvalue::OK) {
return result;
}
result = SerializeAdapter::deSerialize(&blobSet.timeUs, &rawFrame, &remainingLen,
SerializeIF::Endianness::LITTLE);
if (result != returnvalue::OK) {
return result;
}
result = SerializeAdapter::deSerialize(&blobSet.blobCount, &rawFrame, &remainingLen,
SerializeIF::Endianness::LITTLE);
if (result != returnvalue::OK) {
return result;
}
blobSet.setValidity(true, true);
return returnvalue::OK;
}
ReturnValue_t StarTrackerHandler::handleBlobsTm(const uint8_t* rawFrame) {
ReturnValue_t result = statusFieldCheck(rawFrame);
if (result != returnvalue::OK) {
return result;
}
rawFrame += TICKS_OFFSET;
size_t remainingLen = fullPacketLen;
PoolReadGuard pg(&blobsSet);
result = pg.getReadResult();
if (result != returnvalue::OK) {
return result;
}
result = SerializeAdapter::deSerialize(&blobsSet.ticks, &rawFrame, &remainingLen,
SerializeIF::Endianness::LITTLE);
if (result != returnvalue::OK) {
return result;
}
result = SerializeAdapter::deSerialize(&blobsSet.timeUs, &rawFrame, &remainingLen,
SerializeIF::Endianness::LITTLE);
if (result != returnvalue::OK) {
return result;
}
result = SerializeAdapter::deSerialize(&blobsSet.blobsCount, &rawFrame, &remainingLen,
SerializeIF::Endianness::LITTLE);
if (result != returnvalue::OK) {
return result;
}
result = SerializeAdapter::deSerialize(&blobsSet.blobsCountUsed, &rawFrame, &remainingLen,
SerializeIF::Endianness::LITTLE);
if (result != returnvalue::OK) {
return result;
}
result = SerializeAdapter::deSerialize(&blobsSet.nr4LinesSkipped, &rawFrame, &remainingLen,
SerializeIF::Endianness::LITTLE);
if (result != returnvalue::OK) {
return result;
}
for (unsigned idx = 0; idx < 8; idx++) {
result = SerializeAdapter::deSerialize(&blobsSet.xCoords[idx], &rawFrame, &remainingLen,
SerializeIF::Endianness::LITTLE);
if (result != returnvalue::OK) {
return result;
}
result = SerializeAdapter::deSerialize(&blobsSet.yCoords[idx], &rawFrame, &remainingLen,
SerializeIF::Endianness::LITTLE);
if (result != returnvalue::OK) {
return result;
}
}
blobsSet.setValidity(true, true);
return returnvalue::OK;
}
ReturnValue_t StarTrackerHandler::handleCentroidTm(const uint8_t* rawFrame) {
ReturnValue_t result = statusFieldCheck(rawFrame);
if (result != returnvalue::OK) {
return result;
}
rawFrame += TICKS_OFFSET;
size_t remainingLen = fullPacketLen;
PoolReadGuard pg(&centroidsSet);
result = pg.getReadResult();
if (result != returnvalue::OK) {
return result;
}
result = SerializeAdapter::deSerialize(&centroidSet.ticks, &rawFrame, &remainingLen,
SerializeIF::Endianness::LITTLE);
if (result != returnvalue::OK) {
return result;
}
result = SerializeAdapter::deSerialize(&centroidSet.timeUs, &rawFrame, &remainingLen,
SerializeIF::Endianness::LITTLE);
if (result != returnvalue::OK) {
return result;
}
result = SerializeAdapter::deSerialize(&centroidSet.centroidCount, &rawFrame, &remainingLen,
SerializeIF::Endianness::LITTLE);
if (result != returnvalue::OK) {
return result;
}
centroidSet.setValidity(true, true);
return returnvalue::OK;
}
ReturnValue_t StarTrackerHandler::handleCentroidsTm(const uint8_t* rawFrame) {
ReturnValue_t result = statusFieldCheck(rawFrame);
if (result != returnvalue::OK) {
return result;
}
rawFrame += TICKS_OFFSET;
size_t remainingLen = fullPacketLen;
PoolReadGuard pg(&centroidsSet);
result = pg.getReadResult();
if (result != returnvalue::OK) {
return result;
}
result = SerializeAdapter::deSerialize(&centroidsSet.ticksCentroidsTm, &rawFrame, &remainingLen,
SerializeIF::Endianness::LITTLE);
if (result != returnvalue::OK) {
return result;
}
result = SerializeAdapter::deSerialize(&centroidsSet.timeUsCentroidsTm, &rawFrame, &remainingLen,
SerializeIF::Endianness::LITTLE);
if (result != returnvalue::OK) {
return result;
}
result = SerializeAdapter::deSerialize(&centroidsSet.centroidsCount, &rawFrame, &remainingLen,
SerializeIF::Endianness::LITTLE);
if (result != returnvalue::OK) {
return result;
}
for (unsigned idx = 0; idx < 16; idx++) {
result = SerializeAdapter::deSerialize(&centroidsSet.centroidsXCoords[idx], &rawFrame,
&remainingLen, SerializeIF::Endianness::LITTLE);
if (result != returnvalue::OK) {
return result;
}
result = SerializeAdapter::deSerialize(&centroidsSet.centroidsYCoords[idx], &rawFrame,
&remainingLen, SerializeIF::Endianness::LITTLE);
if (result != returnvalue::OK) {
return result;
}
result = SerializeAdapter::deSerialize(&centroidsSet.centroidsMagnitudes[idx], &rawFrame,
&remainingLen, SerializeIF::Endianness::LITTLE);
if (result != returnvalue::OK) {
return result;
}
}
centroidsSet.setValidity(true, true);
return returnvalue::OK;
}
ReturnValue_t StarTrackerHandler::handleActionReplySet(const uint8_t* rawFrame,
LocalPoolDataSetBase& dataset, size_t size) {
ReturnValue_t result = returnvalue::OK;
@ -2204,10 +2789,17 @@ ReturnValue_t StarTrackerHandler::checkCommand(ActionId_t actionId) {
case startracker::REQ_SUBSCRIPTION:
case startracker::REQ_LOG_SUBSCRIPTION:
case startracker::REQ_DEBUG_CAMERA:
case startracker::REQ_MATCHED_CENTROIDS:
case startracker::REQ_BLOB:
case startracker::REQ_BLOBS:
case startracker::REQ_CENTROID:
case startracker::REQ_CENTROIDS:
case startracker::REQ_CONTRAST: {
if (getMode() == MODE_ON and getSubmode() != startracker::Program::FIRMWARE) {
return STARTRACKER_NOT_RUNNING_FIRMWARE;
}
break;
}
case startracker::FIRMWARE_UPDATE:
case startracker::FLASH_READ:
if (getMode() != MODE_ON or getSubmode() != startracker::Program::BOOTLOADER) {

View File

@ -8,6 +8,7 @@
#include <mission/acs/str/strJsonCommands.h>
#include <thirdparty/sagittactl/wire/common/genericstructs.h>
#include <set>
#include <thread>
#include "OBSWConfig.h"
@ -151,6 +152,7 @@ class StarTrackerHandler : public DeviceHandlerBase {
static const uint8_t PARAMS_OFFSET = 2;
static const uint8_t TICKS_OFFSET = 3;
static const uint8_t TIME_OFFSET = 7;
static const uint8_t TM_PARAM_OFFSET = 15;
static const uint8_t PARAMETER_ID_OFFSET = 1;
static const uint8_t ACTION_ID_OFFSET = 1;
static const uint8_t ACTION_DATA_OFFSET = 3;
@ -204,6 +206,13 @@ class StarTrackerHandler : public DeviceHandlerBase {
startracker::SubscriptionSet subscriptionSet;
startracker::LogSubscriptionSet logSubscriptionSet;
startracker::DebugCameraSet debugCameraSet;
startracker::AutoBlobSet autoBlobSet;
startracker::MatchedCentroidsSet matchedCentroidsSet;
startracker::BlobSet blobSet;
startracker::BlobsSet blobsSet;
startracker::CentroidSet centroidSet;
startracker::CentroidsSet centroidsSet;
startracker::ContrastSet contrastSet;
// Pointer to object responsible for uploading and downloading images to/from the star tracker
StrComHandler* strHelper = nullptr;
@ -239,9 +248,9 @@ class StarTrackerHandler : public DeviceHandlerBase {
std::string paramJsonFile;
enum class NormalState { TEMPERATURE_REQUEST, SOLUTION_REQUEST };
enum class NormalState { SECONDARY_REQUEST, SOLUTION_REQUEST };
NormalState normalState = NormalState::TEMPERATURE_REQUEST;
NormalState normalState = NormalState::SECONDARY_REQUEST;
enum class StartupState {
IDLE,
@ -297,6 +306,11 @@ class StarTrackerHandler : public DeviceHandlerBase {
const power::Switch_t powerSwitch = power::NO_SWITCH;
size_t fullPacketLen = 0;
std::set<DeviceCommandId_t> additionalRequestedTm{};
std::set<DeviceCommandId_t>::iterator currentSecondaryTmIter;
/**
* @brief Handles internal state
*/
@ -345,6 +359,18 @@ class StarTrackerHandler : public DeviceHandlerBase {
*/
ReturnValue_t executeFlashReadCommand(const uint8_t* commandData, size_t commandDataLen);
/**
* Add a TM request to the list of telemetry which will be polled in the secondary step of
* the device communication.
* @param cmd
*/
void addSecondaryTmForNormalMode(DeviceCommandId_t cmd);
/**
* Reset the secondary set, which will only contain a TEMPERATURE set request after the reset.
*/
void resetSecondaryTmSet();
/**
* @brief Fills command buffer with data to boot image (works only when star tracker is
* in bootloader mode).
@ -429,6 +455,13 @@ class StarTrackerHandler : public DeviceHandlerBase {
ReturnValue_t prepareRequestCentroidingParams();
ReturnValue_t prepareRequestLisaParams();
ReturnValue_t prepareRequestMatchingParams();
ReturnValue_t prepareRequestAutoBlobTm();
ReturnValue_t prepareRequestMatchedCentroidsTm();
ReturnValue_t prepareRequestBlobTm();
ReturnValue_t prepareRequestBlobsTm();
ReturnValue_t prepareRequestCentroidTm();
ReturnValue_t prepareRequestCentroidsTm();
ReturnValue_t prepareRequestContrastTm();
ReturnValue_t prepareRequestTrackingParams();
ReturnValue_t prepareRequestValidationParams();
ReturnValue_t prepareRequestAlgoParams();
@ -477,6 +510,7 @@ class StarTrackerHandler : public DeviceHandlerBase {
*/
void handleStartup(uint8_t tmType, uint8_t parameterId);
ReturnValue_t statusFieldCheck(const uint8_t* rawFrame);
/**
* @brief Handles telemtry replies and fills the appropriate dataset
*
@ -485,9 +519,16 @@ class StarTrackerHandler : public DeviceHandlerBase {
*
* @return returnvalue::OK if successful, otherwise error return value
*/
ReturnValue_t handleTm(const uint8_t* rawFrame, LocalPoolDataSetBase& dataset, size_t size,
ReturnValue_t handleTm(const uint8_t* rawFrame, LocalPoolDataSetBase& dataset,
const char* context);
ReturnValue_t handleAutoBlobTm(const uint8_t* rawFrame);
ReturnValue_t handleMatchedCentroidTm(const uint8_t* rawFrame);
ReturnValue_t handleBlobTm(const uint8_t* rawFrame);
ReturnValue_t handleBlobsTm(const uint8_t* rawFrame);
ReturnValue_t handleCentroidTm(const uint8_t* rawFrame);
ReturnValue_t handleCentroidsTm(const uint8_t* rawFrame);
/**
* @brief Checks if star tracker is in valid mode for executing the received command.
*

View File

@ -272,7 +272,50 @@ enum PoolIds : lp_id_t {
LOG_SUBSCRIPTION_LEVEL2,
LOG_SUBSCRIPTION_MODULE2,
DEBUG_CAMERA_TIMING,
DEBUG_CAMERA_TEST
DEBUG_CAMERA_TEST,
TICKS_AUTO_BLOB,
TIME_AUTO_BLOB,
AUTO_BLOB_THRESHOLD,
TICKS_MATCHED_CENTROIDS,
TIME_MATCHED_CENTROIDS,
NUM_MATCHED_CENTROIDS,
MATCHED_CENTROIDS_STAR_IDS,
MATCHED_CENTROIDS_X_COORDS,
MATCHED_CENTROIDS_Y_COORDS,
MATCHED_CENTROIDS_X_ERRORS,
MATCHED_CENTROIDS_Y_ERRORS,
BLOB_TICKS,
BLOB_TIME,
BLOB_COUNT,
BLOBS_TICKS,
BLOBS_TIME,
BLOBS_COUNT,
BLOBS_COUNT_USED,
BLOBS_NR_4LINES_SKIPPED,
BLOBS_X_COORDS,
BLOBS_Y_COORDS,
CENTROID_TICKS,
CENTROID_TIME,
CENTROID_COUNT,
CENTROIDS_TICKS,
CENTROIDS_TIME,
CENTROIDS_COUNT,
CENTROIDS_X_COORDS,
CENTROIDS_Y_COORDS,
CENTROIDS_MAGNITUDES,
CONTRAST_TICKS,
CONTRAST_TIME,
CONTRAST_A,
CONTRAST_B,
CONTRAST_C,
CONTRAST_D,
};
static const DeviceCommandId_t PING_REQUEST = 0;
@ -291,6 +334,7 @@ static const DeviceCommandId_t IMAGE_PROCESSOR = 19;
static const DeviceCommandId_t REQ_SOLUTION = 24;
static const DeviceCommandId_t REQ_TEMPERATURE = 25;
static const DeviceCommandId_t REQ_HISTOGRAM = 28;
static constexpr DeviceCommandId_t REQ_CONTRAST = 29;
static const DeviceCommandId_t LIMITS = 40;
static const DeviceCommandId_t MOUNTING = 41;
static const DeviceCommandId_t CAMERA = 42;
@ -328,6 +372,15 @@ static const DeviceCommandId_t DISABLE_TIMESTAMP_GENERATION = 85;
static const DeviceCommandId_t ENABLE_TIMESTAMP_GENERATION = 86;
static constexpr DeviceCommandId_t SET_TIME_FROM_SYS_TIME = 87;
static constexpr DeviceCommandId_t AUTO_THRESHOLD = 88;
static constexpr DeviceCommandId_t REQ_AUTO_BLOB = 89;
static constexpr DeviceCommandId_t REQ_MATCHED_CENTROIDS = 90;
static constexpr DeviceCommandId_t REQ_BLOB = 91;
static constexpr DeviceCommandId_t REQ_BLOBS = 92;
static constexpr DeviceCommandId_t REQ_CENTROID = 93;
static constexpr DeviceCommandId_t REQ_CENTROIDS = 94;
static constexpr DeviceCommandId_t ADD_SECONDARY_TM_TO_NORMAL_MODE = 95;
static constexpr DeviceCommandId_t RESET_SECONDARY_TM_SET = 96;
static constexpr DeviceCommandId_t READ_SECONDARY_TM_SET = 97;
static const DeviceCommandId_t NONE = 0xFFFFFFFF;
static const uint32_t VERSION_SET_ID = REQ_VERSION;
@ -352,6 +405,13 @@ static const uint32_t ALGO_SET_ID = REQ_ALGO;
static const uint32_t SUBSCRIPTION_SET_ID = REQ_SUBSCRIPTION;
static const uint32_t LOG_SUBSCRIPTION_SET_ID = REQ_LOG_SUBSCRIPTION;
static const uint32_t DEBUG_CAMERA_SET_ID = REQ_DEBUG_CAMERA;
static const uint32_t AUTO_BLOB_SET_ID = REQ_AUTO_BLOB;
static const uint32_t MATCHED_CENTROIDS_SET_ID = REQ_MATCHED_CENTROIDS;
static const uint32_t BLOB_SET_ID = REQ_BLOB;
static const uint32_t BLOBS_SET_ID = REQ_BLOBS;
static const uint32_t CENTROID_SET_ID = REQ_CENTROID;
static const uint32_t CENTROIDS_SET_ID = REQ_CENTROIDS;
static const uint32_t CONTRAST_SET_ID = REQ_CONTRAST;
/** Max size of unencoded frame */
static const size_t MAX_FRAME_SIZE = 1200;
@ -412,6 +472,12 @@ static const uint8_t LOG_LEVEL = 3;
static const uint8_t LOG_SUBSCRIPTION = 19;
static const uint8_t DEBUG_CAMERA = 20;
static const uint8_t AUTO_THRESHOLD = 23;
static constexpr uint8_t BLOB = 25;
static constexpr uint8_t BLOBS = 36;
static constexpr uint8_t CENTROID = 26;
static constexpr uint8_t CENTROIDS = 37;
static constexpr uint8_t AUTO_BLOB = 39;
static constexpr uint8_t MATCHED_CENTROIDS = 40;
} // namespace ID
namespace Program {
@ -474,8 +540,6 @@ static const uint32_t FLASH_REGION_SIZE = 0x20000;
*/
class TemperatureSet : public StaticLocalDataSet<TEMPERATURE_SET_ENTRIES> {
public:
static const size_t SIZE = 24;
TemperatureSet(HasLocalDataPoolIF* owner) : StaticLocalDataSet(owner, TEMPERATURE_SET_ID) {}
TemperatureSet(object_id_t objectId) : StaticLocalDataSet(sid_t(objectId, TEMPERATURE_SET_ID)) {}
@ -505,8 +569,6 @@ class TemperatureSet : public StaticLocalDataSet<TEMPERATURE_SET_ENTRIES> {
*/
class VersionSet : public StaticLocalDataSet<VERSION_SET_ENTRIES> {
public:
static const size_t SIZE = 15;
VersionSet(HasLocalDataPoolIF* owner) : StaticLocalDataSet(owner, VERSION_SET_ID) {}
VersionSet(object_id_t objectId) : StaticLocalDataSet(sid_t(objectId, VERSION_SET_ID)) {}
@ -536,8 +598,6 @@ class VersionSet : public StaticLocalDataSet<VERSION_SET_ENTRIES> {
*/
class InterfaceSet : public StaticLocalDataSet<INTERFACE_SET_ENTRIES> {
public:
static const size_t SIZE = 20;
InterfaceSet(HasLocalDataPoolIF* owner) : StaticLocalDataSet(owner, REQ_INTERFACE) {}
InterfaceSet(object_id_t objectId) : StaticLocalDataSet(sid_t(objectId, REQ_INTERFACE)) {}
@ -565,8 +625,6 @@ class InterfaceSet : public StaticLocalDataSet<INTERFACE_SET_ENTRIES> {
*/
class PowerSet : public StaticLocalDataSet<POWER_SET_ENTRIES> {
public:
static const size_t SIZE = 76;
PowerSet(HasLocalDataPoolIF* owner) : StaticLocalDataSet(owner, REQ_INTERFACE) {}
PowerSet(object_id_t objectId) : StaticLocalDataSet(sid_t(objectId, REQ_INTERFACE)) {}
@ -630,8 +688,6 @@ class PowerSet : public StaticLocalDataSet<POWER_SET_ENTRIES> {
*/
class TimeSet : public StaticLocalDataSet<TIME_SET_ENTRIES> {
public:
static const size_t SIZE = 24;
TimeSet(HasLocalDataPoolIF* owner) : StaticLocalDataSet(owner, TIME_SET_ID) {}
TimeSet(object_id_t objectId) : StaticLocalDataSet(sid_t(objectId, TIME_SET_ID)) {}
@ -658,15 +714,13 @@ class TimeSet : public StaticLocalDataSet<TIME_SET_ENTRIES> {
*/
class SolutionSet : public StaticLocalDataSet<SOLUTION_SET_ENTRIES> {
public:
static const size_t SIZE = 79;
SolutionSet(HasLocalDataPoolIF* owner) : StaticLocalDataSet(owner, SOLUTION_SET_ID) {}
SolutionSet(object_id_t objectId) : StaticLocalDataSet(sid_t(objectId, SOLUTION_SET_ID)) {}
// Ticks timestamp
lp_var_t<uint32_t> ticks = lp_var_t<uint32_t>(sid.objectId, PoolIds::TICKS_SOLUTION_SET, this);
/// Unix time stamp
// Unix time stamp
lp_var_t<uint64_t> timeUs = lp_var_t<uint64_t>(sid.objectId, PoolIds::TIME_SOLUTION_SET, this);
// Calibrated quaternion (takes into account the mounting quaternion), typically same as
// track q values
@ -1381,6 +1435,123 @@ class ValidationSet : public StaticLocalDataSet<VALIDATION_SET_ENTRIES> {
}
};
class AutoBlobSet : public StaticLocalDataSet<3> {
public:
AutoBlobSet(HasLocalDataPoolIF* owner) : StaticLocalDataSet(owner, AUTO_BLOB_SET_ID) {}
// Ticks timestamp
lp_var_t<uint32_t> ticks = lp_var_t<uint32_t>(sid.objectId, PoolIds::TICKS_AUTO_BLOB, this);
// Unix time stamp
lp_var_t<uint64_t> timeUs = lp_var_t<uint64_t>(sid.objectId, PoolIds::TIME_AUTO_BLOB, this);
lp_var_t<float> threshold = lp_var_t<float>(sid.objectId, PoolIds::AUTO_BLOB_THRESHOLD, this);
private:
};
class MatchedCentroidsSet : public StaticLocalDataSet<20> {
public:
MatchedCentroidsSet(HasLocalDataPoolIF* owner)
: StaticLocalDataSet(owner, MATCHED_CENTROIDS_SET_ID) {}
MatchedCentroidsSet(object_id_t objectId)
: StaticLocalDataSet(sid_t(objectId, MATCHED_CENTROIDS_SET_ID)) {}
// Ticks timestamp
lp_var_t<uint32_t> ticks =
lp_var_t<uint32_t>(sid.objectId, PoolIds::TICKS_MATCHED_CENTROIDS, this);
// Unix time stamp
lp_var_t<uint64_t> timeUs =
lp_var_t<uint64_t>(sid.objectId, PoolIds::TIME_MATCHED_CENTROIDS, this);
lp_var_t<uint8_t> numberOfMatchedCentroids =
lp_var_t<uint8_t>(sid.objectId, PoolIds::NUM_MATCHED_CENTROIDS, this);
lp_vec_t<uint32_t, 16> starIds =
lp_vec_t<uint32_t, 16>(sid.objectId, PoolIds::MATCHED_CENTROIDS_STAR_IDS, this);
lp_vec_t<float, 16> xCoords =
lp_vec_t<float, 16>(sid.objectId, PoolIds::MATCHED_CENTROIDS_X_COORDS, this);
lp_vec_t<float, 16> yCoords =
lp_vec_t<float, 16>(sid.objectId, PoolIds::MATCHED_CENTROIDS_Y_COORDS, this);
lp_vec_t<float, 16> xErrors =
lp_vec_t<float, 16>(sid.objectId, PoolIds::MATCHED_CENTROIDS_X_ERRORS, this);
lp_vec_t<float, 16> yErrors =
lp_vec_t<float, 16>(sid.objectId, PoolIds::MATCHED_CENTROIDS_Y_ERRORS, this);
private:
};
class BlobSet : public StaticLocalDataSet<5> {
public:
BlobSet(HasLocalDataPoolIF* owner) : StaticLocalDataSet(owner, BLOB_SET_ID) {}
// The blob count received from the Blob Telemetry Set (ID 25)
// Ticks timestamp
lp_var_t<uint32_t> ticks = lp_var_t<uint32_t>(sid.objectId, PoolIds::BLOB_TICKS, this);
// Unix time stamp
lp_var_t<uint64_t> timeUs = lp_var_t<uint64_t>(sid.objectId, PoolIds::BLOB_TIME, this);
lp_var_t<uint32_t> blobCount = lp_var_t<uint32_t>(sid.objectId, PoolIds::BLOB_COUNT, this);
};
class BlobsSet : public StaticLocalDataSet<10> {
public:
BlobsSet(HasLocalDataPoolIF* owner) : StaticLocalDataSet(owner, BLOBS_SET_ID) {}
// Ticks timestamp
lp_var_t<uint32_t> ticks = lp_var_t<uint32_t>(sid.objectId, PoolIds::BLOBS_TICKS, this);
// Unix time stamp
lp_var_t<uint64_t> timeUs = lp_var_t<uint64_t>(sid.objectId, PoolIds::BLOBS_TIME, this);
lp_var_t<uint16_t> blobsCount = lp_var_t<uint16_t>(sid.objectId, PoolIds::BLOBS_COUNT, this);
lp_var_t<uint16_t> blobsCountUsed =
lp_var_t<uint16_t>(sid.objectId, PoolIds::BLOBS_COUNT_USED, this);
lp_var_t<uint16_t> nr4LinesSkipped =
lp_var_t<uint16_t>(sid.objectId, PoolIds::BLOBS_NR_4LINES_SKIPPED, this);
lp_vec_t<uint16_t, 8> xCoords =
lp_vec_t<uint16_t, 8>(sid.objectId, PoolIds::BLOBS_X_COORDS, this);
lp_vec_t<uint16_t, 8> yCoords =
lp_vec_t<uint16_t, 8>(sid.objectId, PoolIds::BLOBS_Y_COORDS, this);
};
class CentroidSet : public StaticLocalDataSet<5> {
public:
CentroidSet(HasLocalDataPoolIF* owner) : StaticLocalDataSet(owner, CENTROID_SET_ID) {}
// Data received from the Centroid Telemetry Set (ID 26)
// Ticks timestamp
lp_var_t<uint32_t> ticks = lp_var_t<uint32_t>(sid.objectId, PoolIds::CENTROID_TICKS, this);
// Unix time stamp
lp_var_t<uint64_t> timeUs = lp_var_t<uint64_t>(sid.objectId, PoolIds::CENTROID_TIME, this);
// The centroid count received from the Centroid Telemetry Set (ID 26)
lp_var_t<uint32_t> centroidCount =
lp_var_t<uint32_t>(sid.objectId, PoolIds::CENTROID_COUNT, this);
};
class CentroidsSet : public StaticLocalDataSet<10> {
public:
CentroidsSet(HasLocalDataPoolIF* owner) : StaticLocalDataSet(owner, CENTROIDS_SET_ID) {}
// Data received from the Centroids Telemetry Set (ID 37)
lp_var_t<uint32_t> ticksCentroidsTm =
lp_var_t<uint32_t>(sid.objectId, PoolIds::CENTROIDS_TICKS, this);
// Unix time stamp
lp_var_t<uint64_t> timeUsCentroidsTm =
lp_var_t<uint64_t>(sid.objectId, PoolIds::CENTROIDS_TIME, this);
lp_var_t<uint16_t> centroidsCount =
lp_var_t<uint16_t>(sid.objectId, PoolIds::CENTROIDS_COUNT, this);
lp_vec_t<float, 16> centroidsXCoords =
lp_vec_t<float, 16>(sid.objectId, PoolIds::CENTROIDS_X_COORDS, this);
lp_vec_t<float, 16> centroidsYCoords =
lp_vec_t<float, 16>(sid.objectId, PoolIds::CENTROIDS_Y_COORDS, this);
lp_vec_t<uint8_t, 16> centroidsMagnitudes =
lp_vec_t<uint8_t, 16>(sid.objectId, PoolIds::CENTROIDS_MAGNITUDES, this);
};
class ContrastSet : public StaticLocalDataSet<8> {
public:
ContrastSet(HasLocalDataPoolIF* owner) : StaticLocalDataSet(owner, CONTRAST_SET_ID) {}
// Data received from the Centroids Telemetry Set (ID 29)
lp_var_t<uint32_t> ticks = lp_var_t<uint32_t>(sid.objectId, PoolIds::CONTRAST_TICKS, this);
// Unix time stamp
lp_var_t<uint64_t> timeUs = lp_var_t<uint64_t>(sid.objectId, PoolIds::CONTRAST_TIME, this);
lp_vec_t<uint32_t, 9> contrastA = lp_vec_t<uint32_t, 9>(sid.objectId, PoolIds::CONTRAST_A, this);
lp_vec_t<uint32_t, 9> contrastB = lp_vec_t<uint32_t, 9>(sid.objectId, PoolIds::CONTRAST_B, this);
lp_vec_t<uint32_t, 9> contrastC = lp_vec_t<uint32_t, 9>(sid.objectId, PoolIds::CONTRAST_C, this);
lp_vec_t<uint32_t, 9> contrastD = lp_vec_t<uint32_t, 9>(sid.objectId, PoolIds::CONTRAST_D, this);
};
/**
* @brief Will store the requested algo parameters
*/

2
tmtc

@ -1 +1 @@
Subproject commit 43d6b986953a815c7c020cf73a957f1678c76549
Subproject commit 0aaf63215b5fe010a5447e5d64e1b4150d543847