From 5a210e19e1232ac0ebf82b4177474723dc6e30c6 Mon Sep 17 00:00:00 2001 From: Jakob Meier Date: Mon, 17 Jan 2022 15:28:53 +0100 Subject: [PATCH] request limits, camera and blob parameters --- .../startracker/StarTrackerDefinitions.h | 145 +++++++++++++++++- .../startracker/StarTrackerHandler.cpp | 87 ++++++++++- .../devices/startracker/StarTrackerHandler.h | 12 ++ tmtc | 2 +- 4 files changed, 235 insertions(+), 11 deletions(-) diff --git a/bsp_q7s/devices/startracker/StarTrackerDefinitions.h b/bsp_q7s/devices/startracker/StarTrackerDefinitions.h index 8a58149e..1f20c606 100644 --- a/bsp_q7s/devices/startracker/StarTrackerDefinitions.h +++ b/bsp_q7s/devices/startracker/StarTrackerDefinitions.h @@ -211,7 +211,33 @@ enum PoolIds: lp_id_t { CAM_REG3, CAM_VAL3, CAM_REG4, - CAM_VAL4 + CAM_VAL4, + LIMITS_ACTION, + LIMITS_FPGA18CURRENT, + LIMITS_FPGA25CURRENT, + LIMITS_FPGA10CURRENT, + LIMITS_MCUCURRENT, + LIMITS_CMOS21CURRENT, + LIMITS_CMOSPIXCURRENT, + LIMITS_CMOS33CURRENT, + LIMITS_CMOSVRESCURRENT, + LIMITS_CMOSTEMPERATURE, + LIMITS_MCUTEMPERATURE, + BLOB_MODE, + BLOB_MIN_VALUE, + BLOB_MIN_DISTANCE, + BLOB_NEIGHBOUR_DISTANCE, + BLOB_NEIGHBOUR_BRIGHTPIXELS, + BLOB_MIN_TOTAL_VALUE, + BLOB_MAX_TOTAL_VALUE, + BLOB_MIN_BRIGHT_NEIGHBOURS, + BLOB_MAX_BRIGHT_NEIGHBOURS, + BLOB_MAX_PIXELSTOCONSIDER, + BLOB_SIGNAL_THRESHOLD, + BLOB_DARK_THRESHOLD, + BLOB_ENABLE_HISTOGRAM, + BLOB_ENABLE_CONTRAST, + BLOB_BIN_MODE }; static const DeviceCommandId_t PING_REQUEST = 0; @@ -260,7 +286,9 @@ 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 REQ_CAMERA_PARAMS = 67; +static const DeviceCommandId_t REQ_CAMERA = 67; +static const DeviceCommandId_t REQ_LIMITS = 68; +static const DeviceCommandId_t REQ_BLOB_PARAMS = 69; static const DeviceCommandId_t NONE = 0xFFFFFFFF; static const uint32_t VERSION_SET_ID = REQ_VERSION; @@ -276,7 +304,9 @@ 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; -static const uint32_t CAMERA_SET_ID = REQ_CAMERA_PARAMS; +static const uint32_t CAMERA_SET_ID = REQ_CAMERA; +static const uint32_t LIMITS_SET_ID = REQ_LIMITS; +static const uint32_t BLOB_SET_ID = REQ_BLOB_PARAMS; /** Max size of unencoded frame */ static const size_t MAX_FRAME_SIZE = 1200; @@ -295,6 +325,8 @@ 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; static const uint8_t CAMERA_SET_ENTRIES = 15; +static const uint8_t LIMITS_SET_ENTRIES = 11; +static const uint8_t BLOB_SET_ENTRIES = 15; // Action, parameter and telemetry IDs namespace ID { @@ -1289,5 +1321,112 @@ public: << static_cast(this->val4.value) << std::endl; } }; + +/** + * @brief Will store the requested limits + */ +class LimitsSet: public StaticLocalDataSet { +public: + + // Size of dataset + static const size_t SIZE = 41; + + LimitsSet(HasLocalDataPoolIF* owner) : + StaticLocalDataSet(owner, LIMITS_SET_ID) { + } + + LimitsSet(object_id_t objectId) : + StaticLocalDataSet(sid_t(objectId, LIMITS_SET_ID)) { + } + + lp_var_t action = lp_var_t(sid.objectId, PoolIds::LIMITS_ACTION, this); + lp_var_t fpga18current = lp_var_t(sid.objectId, PoolIds::LIMITS_FPGA18CURRENT, this); + lp_var_t fpga25current = lp_var_t(sid.objectId, PoolIds::LIMITS_FPGA25CURRENT, this); + lp_var_t fpga10current = lp_var_t(sid.objectId, PoolIds::LIMITS_FPGA10CURRENT, this); + lp_var_t mcuCurrent = lp_var_t(sid.objectId, PoolIds::LIMITS_MCUCURRENT, this); + lp_var_t cmos21current = lp_var_t(sid.objectId, PoolIds::LIMITS_CMOS21CURRENT, this); + lp_var_t cmosPixCurrent = lp_var_t(sid.objectId, PoolIds::LIMITS_CMOSPIXCURRENT, this); + lp_var_t cmos33current = lp_var_t(sid.objectId, PoolIds::LIMITS_CMOS33CURRENT, this); + lp_var_t cmosVresCurrent = lp_var_t(sid.objectId, PoolIds::LIMITS_CMOSVRESCURRENT, this); + lp_var_t cmosTemperature = lp_var_t(sid.objectId, PoolIds::LIMITS_CMOSTEMPERATURE, this); + + void printSet() { + PoolReadGuard rg(this); + sif::info << "CameraSet::printSet: action: " << static_cast(this->action.value) + << std::endl; + sif::info << "CameraSet::printSet: FPGA18Current: " << this->fpga18current << std::endl; + sif::info << "CameraSet::printSet: FPGA25Current: " << this->fpga25current << std::endl; + sif::info << "CameraSet::printSet: FPGA10Current: " << this->fpga10current << std::endl; + sif::info << "CameraSet::printSet: MCUCurrent: " << this->mcuCurrent << std::endl; + sif::info << "CameraSet::printSet: CMOS21Current: " << this->cmos21current << std::endl; + sif::info << "CameraSet::printSet: CMOSPixCurrent: " << this->cmosPixCurrent << std::endl; + sif::info << "CameraSet::printSet: CMOS33Current: " << this->cmos33current << std::endl; + sif::info << "CameraSet::printSet: CMOSVResCurrent: " << this->cmosVresCurrent << std::endl; + sif::info << "CameraSet::printSet: CMOSTemperature: " << this->cmosTemperature << std::endl; + } +}; + +/** + * @brief Will store the request of the blob parameters. + */ +class BlobSet: public StaticLocalDataSet { +public: + + // Size of dataset + static const size_t SIZE = 22; + + BlobSet(HasLocalDataPoolIF* owner) : + StaticLocalDataSet(owner, BLOB_SET_ID) { + } + + BlobSet(object_id_t objectId) : + StaticLocalDataSet(sid_t(objectId, BLOB_SET_ID)) { + } + + lp_var_t mode = lp_var_t(sid.objectId, PoolIds::BLOB_MODE, this); + lp_var_t minValue = lp_var_t(sid.objectId, PoolIds::BLOB_MIN_VALUE, this); + lp_var_t minDistance = lp_var_t(sid.objectId, PoolIds::BLOB_MIN_DISTANCE, this); + lp_var_t neighbourDistance = lp_var_t(sid.objectId, PoolIds::BLOB_NEIGHBOUR_DISTANCE, this); + lp_var_t neighbourBrightPixels = lp_var_t(sid.objectId, PoolIds::BLOB_NEIGHBOUR_BRIGHTPIXELS, this); + lp_var_t minTotalValue = lp_var_t(sid.objectId, PoolIds::BLOB_MIN_TOTAL_VALUE, this); + lp_var_t maxTotalValue = lp_var_t(sid.objectId, PoolIds::BLOB_MAX_TOTAL_VALUE, this); + lp_var_t minBrightNeighbours = lp_var_t(sid.objectId, PoolIds::BLOB_MIN_BRIGHT_NEIGHBOURS, this); + lp_var_t maxBrightNeighbours = lp_var_t(sid.objectId, PoolIds::BLOB_MAX_BRIGHT_NEIGHBOURS, this); + lp_var_t maxPixelsToConsider = lp_var_t(sid.objectId, PoolIds::BLOB_MAX_PIXELSTOCONSIDER, this); + lp_var_t signalThreshold = lp_var_t(sid.objectId, PoolIds::BLOB_SIGNAL_THRESHOLD, this); + lp_var_t darkThreshold = lp_var_t(sid.objectId, PoolIds::BLOB_DARK_THRESHOLD, this); + lp_var_t enableContrast = lp_var_t(sid.objectId, PoolIds::BLOB_ENABLE_CONTRAST, this); + lp_var_t enableBinMode = lp_var_t(sid.objectId, PoolIds::BLOB_BIN_MODE, this); + + void printSet() { + PoolReadGuard rg(this); + sif::info << "BlobSet::printSet: mode: " << static_cast(this->mode.value) + << std::endl; + sif::info << "BlobSet::printSet: minValue: " + << static_cast(this->minValue.value) << std::endl; + sif::info << "BlobSet::printSet: minDistance: " + << static_cast(this->minDistance.value) << std::endl; + sif::info << "BlobSet::printSet: neighboutDistance: " + << static_cast(this->neighbourDistance.value) << std::endl; + sif::info << "BlobSet::printSet: neighboutBrightPixels: " + << static_cast(this->neighbourBrightPixels.value) << std::endl; + sif::info << "BlobSet::printSet: minTotalValue: " << this->minTotalValue << std::endl; + sif::info << "BlobSet::printSet: maxTotalValue: " << this->maxTotalValue << std::endl; + sif::info << "BlobSet::printSet: minBrightNeighbours: " << this->minBrightNeighbours + << std::endl; + sif::info << "BlobSet::printSet: maxBrightNeighbours: " << this->maxBrightNeighbours + << std::endl; + sif::info << "BlobSet::printSet: maxPixelsToConsider: " << this->maxPixelsToConsider + << std::endl; + sif::info << "BlobSet::printSet: signalThreshold: " + << static_cast(this->signalThreshold.value) << std::endl; + sif::info << "BlobSet::printSet: darkThreshold: " + << static_cast(this->darkThreshold.value) << std::endl; + sif::info << "BlobSet::printSet: enableContrast: " + << static_cast(this->enableContrast.value) << std::endl; + sif::info << "BlobSet::printSet: enableBinMode: " + << static_cast(this->enableBinMode.value) << std::endl; + } +}; } #endif /* MISSION_STARTRACKER_DEFINITIONS_H_ */ diff --git a/bsp_q7s/devices/startracker/StarTrackerHandler.cpp b/bsp_q7s/devices/startracker/StarTrackerHandler.cpp index efb54ff8..34575133 100644 --- a/bsp_q7s/devices/startracker/StarTrackerHandler.cpp +++ b/bsp_q7s/devices/startracker/StarTrackerHandler.cpp @@ -18,8 +18,8 @@ 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), checksumSet(this), downloadCentroidSet(this), downloadMatchedStar(this), - downloadDbImage(this), downloadBlobPixel(this), cameraSet(this), strHelper( + this), checksumSet(this), downloadCentroidSet(this), downloadMatchedStar(this), downloadDbImage( + this), downloadBlobPixel(this), cameraSet(this), limitsSet(this), blobSet(this), strHelper( strHelper) { if (comCookie == nullptr) { sif::error << "StarTrackerHandler: Invalid com cookie" << std::endl; @@ -496,10 +496,18 @@ ReturnValue_t StarTrackerHandler::buildCommandFromCommand(DeviceCommandId_t devi result = prepareFpgaActionCommand(commandData, commandDataLen); return result; } - case (StarTracker::REQ_CAMERA_PARAMS): { + case (StarTracker::REQ_CAMERA): { result = prepareRequestCameraParams(); return result; } + case (StarTracker::REQ_LIMITS): { + result = prepareRequestLimitsParams(); + return result; + } + case (StarTracker::REQ_BLOB_PARAMS): { + result = prepareRequestBlobParams(); + return result; + } default: return DeviceHandlerIF::COMMAND_NOT_IMPLEMENTED; } @@ -578,7 +586,11 @@ void StarTrackerHandler::fillCommandAndReplyMap() { StarTracker::MAX_FRAME_SIZE * 2 + 2); this->insertInCommandAndReplyMap(StarTracker::FPGA_ACTION, 3, nullptr, StarTracker::MAX_FRAME_SIZE * 2 + 2); - this->insertInCommandAndReplyMap(StarTracker::REQ_CAMERA_PARAMS, 3, nullptr, + this->insertInCommandAndReplyMap(StarTracker::REQ_CAMERA, 3, nullptr, + StarTracker::MAX_FRAME_SIZE * 2 + 2); + this->insertInCommandAndReplyMap(StarTracker::REQ_LIMITS, 3, nullptr, + StarTracker::MAX_FRAME_SIZE * 2 + 2); + this->insertInCommandAndReplyMap(StarTracker::REQ_BLOB_PARAMS, 3, nullptr, StarTracker::MAX_FRAME_SIZE * 2 + 2); } @@ -738,10 +750,18 @@ ReturnValue_t StarTrackerHandler::interpretDeviceReply(DeviceCommandId_t id, con result = handleSetParamReply(); break; } - case (StarTracker::REQ_CAMERA_PARAMS): { + case (StarTracker::REQ_CAMERA): { handleParamRequest(cameraSet, StarTracker::CameraSet::SIZE); break; } + case (StarTracker::REQ_LIMITS): { + handleParamRequest(limitsSet, StarTracker::LimitsSet::SIZE); + break; + } + case (StarTracker::REQ_BLOB_PARAMS): { + handleParamRequest(blobSet, StarTracker::BlobSet::SIZE); + break; + } default: { sif::debug << "StarTrackerHandler::interpretDeviceReply: Unknown device reply id:" << id << std::endl; @@ -966,6 +986,34 @@ ReturnValue_t StarTrackerHandler::initializeLocalDataPool(localpool::DataPool& l localDataPoolMap.emplace(StarTracker::CAM_VAL3, new PoolEntry( { 0 })); localDataPoolMap.emplace(StarTracker::CAM_REG4, new PoolEntry( { 0 })); localDataPoolMap.emplace(StarTracker::CAM_VAL4, new PoolEntry( { 0 })); + + localDataPoolMap.emplace(StarTracker::LIMITS_ACTION, new PoolEntry( { 0 })); + localDataPoolMap.emplace(StarTracker::LIMITS_FPGA18CURRENT, new PoolEntry( { 0 })); + localDataPoolMap.emplace(StarTracker::LIMITS_FPGA25CURRENT, new PoolEntry( { 0 })); + localDataPoolMap.emplace(StarTracker::LIMITS_FPGA10CURRENT, new PoolEntry( { 0 })); + localDataPoolMap.emplace(StarTracker::LIMITS_MCUCURRENT, new PoolEntry( { 0 })); + localDataPoolMap.emplace(StarTracker::LIMITS_CMOS21CURRENT, new PoolEntry( { 0 })); + localDataPoolMap.emplace(StarTracker::LIMITS_CMOSPIXCURRENT, new PoolEntry( { 0 })); + localDataPoolMap.emplace(StarTracker::LIMITS_CMOS33CURRENT, new PoolEntry( { 0 })); + localDataPoolMap.emplace(StarTracker::LIMITS_CMOSVRESCURRENT, new PoolEntry( { 0 })); + localDataPoolMap.emplace(StarTracker::LIMITS_CMOSTEMPERATURE, new PoolEntry( { 0 })); + + localDataPoolMap.emplace(StarTracker::BLOB_MODE, new PoolEntry( { 0 })); + localDataPoolMap.emplace(StarTracker::BLOB_MIN_VALUE, new PoolEntry( { 0 })); + localDataPoolMap.emplace(StarTracker::BLOB_MIN_DISTANCE, new PoolEntry( { 0 })); + localDataPoolMap.emplace(StarTracker::BLOB_NEIGHBOUR_DISTANCE, new PoolEntry( { 0 })); + localDataPoolMap.emplace(StarTracker::BLOB_NEIGHBOUR_BRIGHTPIXELS, new PoolEntry( { 0 })); + localDataPoolMap.emplace(StarTracker::BLOB_NEIGHBOUR_BRIGHTPIXELS, new PoolEntry( { 0 })); + localDataPoolMap.emplace(StarTracker::BLOB_MIN_TOTAL_VALUE, new PoolEntry( { 0 })); + localDataPoolMap.emplace(StarTracker::BLOB_MAX_TOTAL_VALUE, new PoolEntry( { 0 })); + localDataPoolMap.emplace(StarTracker::BLOB_MIN_BRIGHT_NEIGHBOURS, new PoolEntry( { 0 })); + localDataPoolMap.emplace(StarTracker::BLOB_MAX_BRIGHT_NEIGHBOURS, new PoolEntry( { 0 })); + localDataPoolMap.emplace(StarTracker::BLOB_MAX_PIXELSTOCONSIDER, new PoolEntry( { 0 })); + localDataPoolMap.emplace(StarTracker::BLOB_SIGNAL_THRESHOLD, new PoolEntry( { 0 })); + localDataPoolMap.emplace(StarTracker::BLOB_DARK_THRESHOLD, new PoolEntry( { 0 })); + localDataPoolMap.emplace(StarTracker::BLOB_ENABLE_HISTOGRAM, new PoolEntry( { 0 })); + localDataPoolMap.emplace(StarTracker::BLOB_ENABLE_CONTRAST, new PoolEntry( { 0 })); + localDataPoolMap.emplace(StarTracker::BLOB_BIN_MODE, new PoolEntry( { 0 })); return RETURN_OK; } @@ -1127,7 +1175,15 @@ ReturnValue_t StarTrackerHandler::scanForGetParameterReply(DeviceCommandId_t *fo const uint8_t* reply = dataLinkLayer.getReply(); switch (*reply) { case (StarTracker::ID::CAMERA): { - *foundId = StarTracker::REQ_CAMERA_PARAMS; + *foundId = StarTracker::REQ_CAMERA; + break; + } + case (StarTracker::ID::LIMITS): { + *foundId = StarTracker::REQ_LIMITS; + break; + } + case (StarTracker::ID::BLOB): { + *foundId = StarTracker::REQ_BLOB_PARAMS; break; } default: { @@ -1749,7 +1805,6 @@ ReturnValue_t StarTrackerHandler::prepareFpgaActionCommand(const uint8_t* comman } ReturnValue_t StarTrackerHandler::prepareRequestCameraParams() { - struct Camera req; uint32_t length = 0; arc_pack_camera_parameter_req(commandBuffer, &length); dataLinkLayer.encodeFrame(commandBuffer, length); @@ -1758,6 +1813,24 @@ ReturnValue_t StarTrackerHandler::prepareRequestCameraParams() { return RETURN_OK; } +ReturnValue_t StarTrackerHandler::prepareRequestLimitsParams() { + uint32_t length = 0; + arc_pack_limits_parameter_req(commandBuffer, &length); + dataLinkLayer.encodeFrame(commandBuffer, length); + rawPacket = dataLinkLayer.getEncodedFrame(); + rawPacketLen = dataLinkLayer.getEncodedLength(); + return RETURN_OK; +} + +ReturnValue_t StarTrackerHandler::prepareRequestBlobParams() { + uint32_t length = 0; + arc_pack_blob_parameter_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); diff --git a/bsp_q7s/devices/startracker/StarTrackerHandler.h b/bsp_q7s/devices/startracker/StarTrackerHandler.h index 0461af27..2a7c7501 100644 --- a/bsp_q7s/devices/startracker/StarTrackerHandler.h +++ b/bsp_q7s/devices/startracker/StarTrackerHandler.h @@ -262,6 +262,8 @@ private: StarTracker::DownloadDBImage downloadDbImage; StarTracker::DownloadBlobPixel downloadBlobPixel; StarTracker::CameraSet cameraSet; + StarTracker::LimitsSet limitsSet; + StarTracker::BlobSet blobSet; // Pointer to object responsible for uploading and downloading images to/from the star tracker StrHelper* strHelper = nullptr; @@ -500,6 +502,16 @@ private: */ ReturnValue_t prepareRequestCameraParams(); + /** + * @brief Will fill the command buffer with the command to request the set limits. + */ + ReturnValue_t prepareRequestLimitsParams(); + + /** + * @brief Will fill the command buffer with the command to request the set blob parameters. + */ + ReturnValue_t prepareRequestBlobParams(); + /** * @brief Handles action replies with datasets. */ diff --git a/tmtc b/tmtc index 6270d90f..672f2339 160000 --- a/tmtc +++ b/tmtc @@ -1 +1 @@ -Subproject commit 6270d90f98b4ec694b6d543ce9a9ddd49ba743f9 +Subproject commit 672f2339d7504c83d953cc4eecca6057ff920909