diff --git a/bsp_q7s/devices/ArcsecDatalinkLayer.cpp b/bsp_q7s/devices/ArcsecDatalinkLayer.cpp new file mode 100644 index 00000000..1f436636 --- /dev/null +++ b/bsp_q7s/devices/ArcsecDatalinkLayer.cpp @@ -0,0 +1,68 @@ +#include "ArcsecDatalinkLayer.h" + +ArcsecDatalinkLayer::ArcsecDatalinkLayer() { + slipInit(); +} + +ArcsecDatalinkLayer::~ArcsecDatalinkLayer() { +} + +void ArcsecDatalinkLayer::slipInit() { + slipInfo.buffer = rxBuffer; + slipInfo.maxlength = StarTracker::MAX_FRAME_SIZE; + slipInfo.length = 0; + slipInfo.unescape_next = 0; + slipInfo.prev_state = SLIP_COMPLETE; +} + +ReturnValue_t ArcsecDatalinkLayer::decodeFrame(const uint8_t* rawData, size_t rawDataSize, + size_t* bytesLeft) { + size_t bytePos = 0; + for (bytePos = 0; bytePos < rawDataSize; bytePos++) { + enum arc_dec_result decResult = arc_transport_decode_body(*(rawData + bytePos), &slipInfo, + decodedFrame, &decFrameSize); + *bytesLeft = rawDataSize - bytePos; + switch (decResult) { + case ARC_DEC_INPROGRESS: { + if (bytePos == rawDataSize - 1) { + return DEC_IN_PROGRESS; + } + continue; + } + case ARC_DEC_ERROR_FRAME_SHORT: + return REPLY_TOO_SHORT; + case ARC_DEC_ERROR_CHECKSUM: + return CRC_FAILURE; + case ARC_DEC_ASYNC: + case ARC_DEC_SYNC: { + // Reset length of SLIP struct for next frame + slipInfo.length = 0; + RETURN_OK; + } + default: + sif::debug << "ArcsecDatalinkLayer::decodeFrame: Unknown result code" << std::endl; + break; + } + } +} + +uint8_t ArcsecDatalinkLayer::getReplyFrameType() { + return decodedFrame[0]; +} + +const uint8_t* ArcsecDatalinkLayer::getReply() { + return &decodedFrame[1]; +} + +void ArcsecDatalinkLayer::encodeFrame(const uint8_t* data, uint32_t length) { + arc_transport_encode_body(commandBuffer, length, encBuffer, &encFrameSize); +} + +uint8_t* ArcsecDatalinkLayer::getEncodedFrame() { + return encBuffer; +} + +uint32_t ArcsecDatalinkLayer::getEncodedLength() { + return encFrameSize; +} + diff --git a/bsp_q7s/devices/ArcsecDatalinkLayer.h b/bsp_q7s/devices/ArcsecDatalinkLayer.h new file mode 100644 index 00000000..bce1f619 --- /dev/null +++ b/bsp_q7s/devices/ArcsecDatalinkLayer.h @@ -0,0 +1,84 @@ +#ifndef BSP_Q7S_DEVICES_ARCSECDATALINKLAYER_H_ +#define BSP_Q7S_DEVICES_ARCSECDATALINKLAYER_H_ + +#include "mission/devices/devicedefinitions/StarTrackerDefinitions.h" +#include "fsfw/returnvalues/HasReturnValuesIF.h" + +extern "C" { + #include "common/misc.h" +} + +/** + * @brief Helper class to handle the datalinklayer of replies from the star tracker of arcsec. + */ +class ArcsecDatalinkLayer: public HasReturnvaluesIF { +public: + + static const uint8_t INTERFACE_ID = CLASS_ID::STR_HANDLER; + + //! [EXPORT] : [COMMENT] More data required to complete frame + static const ReturnValue_t DEC_IN_PROGRESS = MAKE_RETURN_CODE(0xA0); + //! [EXPORT] : [COMMENT] Data too short to represent a valid frame + static const ReturnValue_t REPLY_TOO_SHORT = MAKE_RETURN_CODE(0xA1); + //! [EXPORT] : [COMMENT] Detected CRC failure in received frame + static const ReturnValue_t CRC_FAILURE = MAKE_RETURN_CODE(0xA2); + + ArcsecDatalinkLayer(); + virtual ~ArcsecDatalinkLayer(); + + /** + * @brief Applies decoding to data referenced by rawData pointer + * + * @param rawData Pointer to raw data received from star tracker + * @param rawDataSize Size of raw data stream + * @param remainingBytes Number of bytes left + */ + ReturnValue_t decodeFrame(const uint8_t* rawData, size_t rawDataSize, size_t* bytesLeft); + + /** + * @brief SLIP encodes data pointed to by data pointer. + * + * @param data Pointer to data to encode + * @param length Length of buffer to encode + */ + void encodeFrame(const uint8_t* data, uint32_t length); + + /** + * @brief Returns the frame type field of a decoded frame. + */ + uint8_t getReplyFrameType(); + + /** + * @brief Returns pointer to reply packet. + */ + const uint8_t* getReply(); + + /** + * @brief Returns size of encoded frame + */ + uint32_t getEncodedLength(); + + /** + * @brief Returns pointer to encoded frame + */ + uint8_t* getEncodedFrame(); + +private: + + // Used by arcsec slip decoding function process received data + uint8_t rxBuffer[StarTracker::MAX_FRAME_SIZE]; + // Decoded frame will be copied to this buffer + uint8_t decodedFrame[StarTracker::MAX_FRAME_SIZE]; + // Buffer where encoded frames will be stored + uint8_t encBuffer[StarTracker::MAX_FRAME_SIZE * 2 + 2]; + // Size of decoded frame + uint32_t decFrameSize = 0; + // Size of encoded frame + uint32_t encFrameSize = 0; + + slip_decode_state slipInfo; + + void slipInit(); +}; + +#endif /* BSP_Q7S_DEVICES_ARCSECDATALINKLAYER_H_ */ diff --git a/bsp_q7s/devices/StrImageLoader.cpp b/bsp_q7s/devices/StrImageLoader.cpp index 803fb122..7d4b64eb 100644 --- a/bsp_q7s/devices/StrImageLoader.cpp +++ b/bsp_q7s/devices/StrImageLoader.cpp @@ -17,15 +17,21 @@ ReturnValue_t StrImageLoader::initialize() { } ReturnValue_t StrImageLoader::performOperation(uint8_t operationCode) { + ReturnValue_t result = RETURN_OK; semaphore.acquire(); while(true) { switch(internalState) { - case InternalState::IDLE: + case InternalState::IDLE: { semaphore.acquire(); break; - case InternalState::UPLOAD_IMAGE: - uploadImage(); + } + case InternalState::UPLOAD_IMAGE: { + result = uploadImage(); + if (result == RETURN_OK){ + triggerEvent(IMAGE_UPLOAD_SUCCESSFUL); + } break; + } case InternalState::DOWNLOAD_IMAGE: break; } @@ -42,7 +48,6 @@ void StrImageLoader::setComCookie(CookieIF* comCookie_) { ReturnValue_t StrImageLoader::startImageUpload(std::string image) { - //TODO: Use string part not data pointer // Check if file is stored on SD card and if associated SD card is mounted if (image.substr(0, sizeof(SdCardManager::SD_0_MOUNT_POINT)) == std::string(SdCardManager::SD_0_MOUNT_POINT)) { @@ -70,6 +75,82 @@ ReturnValue_t StrImageLoader::startImageUpload(std::string image) { } ReturnValue_t StrImageLoader::uploadImage() { + ReturnValue_t result = RETURN_OK; + size_t receivedDataLen = 0; + uint8_t *receivedData = nullptr; + size_t bytesLeft = 0; + uint32_t readSize = 0; + uint32_t imageSize = 0; + struct UploadActionRequest uploadReq; + uploadReq.position = 0; + uploadReq.data = {0}; + if (not std::filesystem::exists(uploadImage)) { + triggerEvent(IMAGE_FILE_NOT_EXISTS, uploadReq.position); + state = State::IDLE; + return RETURN_FAILED; + } + + std::ifstream file(uploadImage, std::ifstream::binary); + file.seekg(0, file.end); + imageSize = file.tellg(); + file.seekg(uploadReq.position * SIZE_IMAGE_PART, file.beg); + + while(uploadReq.position * SIZE_IMAGE_PART < imageSize) { + result = + } + + uint32_t remainder = imageSize - uploadReq.position * SIZE_IMAGE_PART; + file.read(reinterpret_cast(uploadReq.data), remainder); + uploadReq.position++; + datalinkLayer.encodeFrame(uploadReq.data, remainder); + result = communicationInterface->sendMessage(comCookie, datalinkLayer.getEncodedFrame(), + datalinkLayer.getEncodedLength()); + if (result = RETURN_OK) { + sif::warning << "StrImageLoader::uploadImage: Failed to send upload packet" << std::endl; + triggerEvent(SENDING_UPLOAD_PACKET_FAILED, result, uploadReq.position); + return RETURN_FAILED; + } + result = ArcsecDatalinkLayer::DEC_IN_PROGRESS; + while(result == ArcsecDatalinkLayer::DEC_IN_PROGRESS) { + result = communicationInterface->requestReceiveMessage(comCookie, StarTracker::MAX_FRAME_SIZE* 2 + 2); + if (result != RETURN_OK) { + sif::warning << "StrImageLoader::uploadImage: Failed to request reply" << std::endl; + triggerEvent(UPLOAD_REQUESTING_MSG_FAILED, result, uploadReq.position); + return RETURN_FAILED; + } + result = communicationInterface->readReceivedMessage(comCookie, receivedData, + receivedDataLen); + if (result != RETURN_OK) { + sif::warning << "StrImageLoader::uploadImage: Failed to read received message" + << std::endl; + triggerEvent(UPLOAD_READING_REPLY_FAILED, result, uploadReq.position); + } + result = datalinkLayer.decodeFrame(receivedData, receivedDataLen, &bytesLeft); + if (bytesLeft != 0) { + // This should never happen + triggerEvent(UPLOAD_COM_ERROR, result, uploadReq.position); + return RETURN_FAILED; + } + } + + if (remainingCommands == 1) { + dataLen = imageSize - file.tellg(); + } + else { + dataLen = SIZE_IMAGE_PART; + } + + size_t size = 0; + size_t maxSize = sizeof(position); + uint8_t* commandBufferPtr = tmpCommandBuffer; + uint8_t** buffer = &commandBufferPtr; + SerializeAdapter::serialize(&position, buffer, &size, maxSize, + SerializeIF::Endianness::BIG); + file.read(reinterpret_cast(uploadReq.data), dataLen); + file.close(); + + arc_pack_upload_action_req() + communicationInterface->requestReceiveMessage(comCookie, ) } diff --git a/bsp_q7s/devices/StrImageLoader.h b/bsp_q7s/devices/StrImageLoader.h index 39013fe6..50cdc266 100644 --- a/bsp_q7s/devices/StrImageLoader.h +++ b/bsp_q7s/devices/StrImageLoader.h @@ -5,6 +5,8 @@ #include "fsfw/osal/linux/BinarySemaphore.h" #include "bsp_q7s/memory/SdCardManager.h" +#include "bsp_q7s/devices/ArcsecDatalinkLayer.h" +#include "fsfw/returnvalues/HasReturnvaluesIF.h" /** * @brief An object of this class runs in a separate task and is responsible for uploading and @@ -12,8 +14,33 @@ * downloading via the star tracker handler takes a lot of time because each upload or * download packet can transport a maximum of 1024 bytes. */ -class StrImageLoader: public SystemObject, public ExecutableObjectIF { +class StrImageLoader: public SystemObject, public ExecutableObjectIF, public HasReturnvaluesIF { public: + + static const uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::STR_IMAGE_LOADER; + + //! [EXPORT] : [COMMENT] Try to upload image but specified image does not exist + static const Event IMAGE_FILE_NOT_EXISTS = MAKE_EVENT(0, severity::LOW); + //! [EXPORT] : [COMMENT] Sending image upload packet to star tracker failed + //!P1: Return code of communication interface sendMessage function + //!P2: Position of upload packet for which the transmission failed + static const Event SENDING_UPLOAD_PACKET_FAILED = MAKE_EVENT(1, severity::LOW); + //! [EXPORT] : [COMMENT] Communication interface requesting reply failed + //!P1: Return code of failed request + //!P1: Upload position for which the request failed + static const Event UPLOAD_REQUESTING_MSG_FAILED = MAKE_EVENT(2, severity::LOW); + //! [EXPORT] : [COMMENT] Uploading image to star tracker was successful + static const Event IMAGE_UPLOAD_SUCCESSFUL = MAKE_EVENT(3, severity::LOW); + //! [EXPORT] : [COMMENT] Failed to read communication interface reply data + //!P1: Return code of failed communication interface read call + //!P1: Upload position for which the read call failed + static const Event UPLOAD_READING_REPLY_FAILED = MAKE_EVENT(3, severity::LOW); + //! [EXPORT] : [COMMENT] Unexpected stop of decoding sequence + //!P1: Return code of failed communication interface read call + //!P1: Upload position for which the read call failed + static const Event UPLOAD_COM_ERROR = MAKE_EVENT(4, severity::LOW); + + StrImageLoader(object_id_t objectId); virtual ~StrImageLoader(); @@ -22,6 +49,14 @@ public: void setComIF(DeviceCommunicationIF* communicationInterface_); void setComCookie(CookieIF* comCookie_); + /** + * @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. + */ + ReturnValue_t startImageUpload(std::string image); + private: static const uint8_t INTERFACE_ID = CLASS_ID::STR_IMG_LOADER; @@ -31,6 +66,9 @@ private: //! [EXPORT] : [COMMENT] Specified file does not exist on filesystem static const ReturnValue_t FILE_NOT_EXISTS = MAKE_RETURN_CODE(0xA1); + // Size of one image part which can be sent per action request + static const size_t SIZE_IMAGE_PART = 1024; + enum class InternalState { IDLE, UPLOAD_IMAGE, @@ -39,6 +77,8 @@ private: InternalState internalState = InternalState::IDLE; + ArcsecDatalinkLayer datalinkLayer; + BinarySemaphore semaphore; // Absolute path and name to image to upload @@ -51,6 +91,13 @@ private: * Must be set by star tracker handler */ DeviceCommunicationIF * communicationInterface = nullptr; + // Communication cookie. Must be set by the star tracker handler + CookieIF* comCookie = nullptr; + + /** + * @brief Performs image uploading + */ + ReturnValue_t uploadImage(); }; #endif /* BSP_Q7S_DEVICES_STRIMAGELOADER_H_ */ diff --git a/common/config/commonObjects.h b/common/config/commonObjects.h index 19445dc1..610052e4 100644 --- a/common/config/commonObjects.h +++ b/common/config/commonObjects.h @@ -91,7 +91,7 @@ enum commonObjects: uint32_t { PLOC_UPDATER = 0x44330000, PLOC_MEMORY_DUMPER = 0x44330001, - STR_IMG_HELPER = 0x44330002 + STR_IMG_LOADER = 0x44330002 }; } diff --git a/common/config/commonSubsystemIds.h b/common/config/commonSubsystemIds.h index a6a0466d..2bb216a5 100644 --- a/common/config/commonSubsystemIds.h +++ b/common/config/commonSubsystemIds.h @@ -18,7 +18,7 @@ enum: uint8_t { PLOC_UPDATER = 117, PLOC_MEMORY_DUMPER = 118, PDEC_HANDLER = 119, - STR_IMAGE_HELPER = 120, + STR_IMAGE_LOADER = 120, COMMON_SUBSYSTEM_ID_END }; } diff --git a/mission/devices/StarTrackerHandler.cpp b/mission/devices/StarTrackerHandler.cpp index f05dec71..dacb8617 100644 --- a/mission/devices/StarTrackerHandler.cpp +++ b/mission/devices/StarTrackerHandler.cpp @@ -20,17 +20,83 @@ StarTrackerHandler::StarTrackerHandler(object_id_t objectId, object_id_t comIF, if (strImageLoader == nullptr) { sif::error << "StarTrackerHandler: Invalid str image loader" << std::endl; } + eventQueue = QueueFactory::instance()->createMessageQueue(EventMessage::EVENT_MESSAGE_SIZE * 5); slipInit(); } StarTrackerHandler::~StarTrackerHandler() { - DeviceHandlerBase::initialize(); +} + +ReturnValue_t StarTrackerHandler::initialize() { + ReturnValue_t result = RETURN_OK; + result = DeviceHandlerBase::initialize(); + if (result != RETURN_OK) { + return result; + } + + EventManagerIF* manager = ObjectManager::instance()->get( + objects::EVENT_MANAGER); + if (manager == nullptr) { +#if FSFW_CPP_OSTREAM_ENABLED == 1 + sif::error << "StarTrackerHandler::initialize: Invalid event manager" << std::endl; +#endif + return ObjectManagerIF::CHILD_INIT_FAILED;; + } + result = manager->registerListener(eventQueue->getId()); + if (result != HasReturnvaluesIF::RETURN_OK) { + return result; + } + result = manager->subscribeToAllEventsFrom(eventQueue->getId(), objects::STR_IMG_LOADER); + if (result != RETURN_OK) { +#if FSFW_CPP_OSTREAM_ENABLED == 1 + sif::warning << "StarTrackerHandler::initialize: Failed to subscribe to events form image" + " loader" << std::endl; +#endif + return ObjectManagerIF::CHILD_INIT_FAILED; + } + strImageLoader->setComIF(communicationInterface); strImageLoader->setComCookie(comCookie); } -ReturnValue_t StarTrackerHandler::initialize() { +ReturnValue_t StarTrackerHandler::executeAction(ActionId_t actionId, MessageQueueId_t commandedBy, + const uint8_t* data, size_t size) { + if (imageLoaderExecuting == true) { + return IMAGE_LOADER_EXECUTING; + } + // Intercept image loader commands which do not follow the common DHB communication flow + switch(actionId) { + case(StarTracker::UPLOAD_IMAGE): { + strImageLoader->startImageUpload(); + imageLoaderExecuting = true; + return EXECUTION_FINISHED; + } + case(StarTracker::DOWNLOAD_IMAGE): { + strImageLoader->startImageDownload(); + imageLoaderExecuting = true; + return EXECUTION_FINISHED; + } + default: + break; + } + return DeviceHandlerBase::executeAction(); +} + +void StarTrackerHandler::performOperationHook() { + EventMessage event; + for (ReturnValue_t result = eventQueue->receiveMessage(&event); + result == RETURN_OK; result = eventQueue->receiveMessage(&event)) { + switch (event.getMessageId()) { + case EventMessage::EVENT_MESSAGE: + handleEvent(&event); + break; + default: + sif::debug << "CCSDSHandler::checkEvents: Did not subscribe to this event message" + << std::endl; + break; + } + } } void StarTrackerHandler::doStartUp() { @@ -89,7 +155,9 @@ ReturnValue_t StarTrackerHandler::buildCommandFromCommand(DeviceCommandId_t devi return RETURN_OK; } case (StarTracker::UPLOAD_IMAGE): { - result = prepareImageUploadCommand(commandData, commandDataLen); + std::string uploadImage = std::string(reinterpret_cast(commandData), + commandDataLen); + strImageLoader->startImageUpload(uploadImage); return result; } case (StarTracker::REQ_POWER): { @@ -129,8 +197,7 @@ void StarTrackerHandler::fillCommandAndReplyMap() { StarTracker::MAX_FRAME_SIZE * 2 + 2); this->insertInCommandAndReplyMap(StarTracker::REQ_TIME, 3, &timeSet, StarTracker::MAX_FRAME_SIZE * 2 + 2); - this->insertInCommandAndReplyMap(StarTracker::UPLOAD_IMAGE, 3, nullptr, - StarTracker::MAX_FRAME_SIZE * 2 + 2); + this->insertInCommandMap(StarTracker::UPLOAD_IMAGE); this->insertInCommandAndReplyMap(StarTracker::REQ_POWER, 3, &powerSet, StarTracker::MAX_FRAME_SIZE * 2 + 2); this->insertInCommandAndReplyMap(StarTracker::REQ_INTERFACE, 3, &interfaceSet, @@ -151,52 +218,36 @@ ReturnValue_t StarTrackerHandler::scanForReply(const uint8_t *start, size_t rema ReturnValue_t result = RETURN_OK; uint32_t decodedLength = 0; size_t bytePos = 0; - for (bytePos = 0; bytePos < remainingSize; bytePos++) { - enum arc_dec_result decResult = arc_transport_decode_body(*(start + bytePos), &slipInfo, - decodedFrame, &decodedLength); + size_t bytesLeft = 0; - switch (decResult) { - case ARC_DEC_INPROGRESS: { - if (bytePos == remainingSize - 1) { - // second doSendread() required to read whole packet - return IGNORE_FULL_PACKET; - } - continue; - } - case ARC_DEC_ASYNC: { - sif::debug << "StarTrackerHandler::scanForReply: Received asynchronous tm" << std::endl; - /** No asynchronous replies are expected as of now */ - return RETURN_FAILED; - } - case ARC_DEC_ERROR_FRAME_SHORT: - return REPLY_TOO_SHORT; - case ARC_DEC_ERROR_CHECKSUM: - return CRC_FAILURE; - case ARC_DEC_SYNC: { - /** Reset length of SLIP struct for next frame */ - slipInfo.length = 0; - break; - } - default: - sif::debug << "StarTrackerHandler::scanForReply: Unknown result code" << std::endl; - break; - } + result = dataLinkLayer.decodeFrame(start, remainingSize, &bytesLeft); + remainingSize = *bytesLeft; + switch(result) { + case ArcsecDatalinkLayer::DEC_IN_PROGRESS: { + // Need a second doSendRead pass to reaa in whole packet + return IGNORE_REPLY_DATA; + } + case RETURN_OK: { + break; + } + default: + return result; } - switch (decodedFrame[0]) { + switch (dataLinkLayer.getReplyFrameType()) { case TMTC_ACTIONREPLY: { - *foundLen = bytePos; + *foundLen = remainingsize - bytesLeft; result = scanForActionReply(foundId); break; } case TMTC_SETPARAMREPLY: { - *foundLen = bytePos; + *foundLen = remainingsize - bytesLeft; result = scanForSetParameterReply(foundId); break; } case TMTC_TELEMETRYREPLYA: case TMTC_TELEMETRYREPLY: { - *foundLen = bytePos; + *foundLen = remainingsize - bytesLeft; result = scanForTmReply(foundId); break; } @@ -238,10 +289,6 @@ ReturnValue_t StarTrackerHandler::interpretDeviceReply(DeviceCommandId_t id, con result = handleInterfaceTm(); break; } - case (StarTracker::UPLOAD_IMAGE): { - result = handleUploadImageReply(); - break; - } case (StarTracker::REQ_POWER): { result = handlePowerTm(); break; @@ -352,11 +399,17 @@ ReturnValue_t StarTrackerHandler::initializeLocalDataPool(localpool::DataPool& l } size_t StarTrackerHandler::getNextReplyLength(DeviceCommandId_t commandId){ + // Prevent DHB from polling UART during upload command. Because UART is used by image loader + // task + if (commandId == StarTracker::UPLOAD_IMAGE) { + return 0; + } return StarTracker::MAX_FRAME_SIZE; } ReturnValue_t StarTrackerHandler::scanForActionReply(DeviceCommandId_t *foundId) { - switch (decodedFrame[1]) { + const uint8_t* reply = dataLinkLayer.getReply(); + switch (*reply) { case (StarTracker::ID::PING): { *foundId = StarTracker::PING_REQUEST; break; @@ -378,7 +431,8 @@ ReturnValue_t StarTrackerHandler::scanForActionReply(DeviceCommandId_t *foundId) } ReturnValue_t StarTrackerHandler::scanForSetParameterReply(DeviceCommandId_t *foundId) { - switch (decodedFrame[1]) { + const uint8_t* reply = dataLinkLayer.getReply(); + switch (*reply) { case (StarTracker::ID::SUBSCRIBE): { *foundId = StarTracker::SUBSCRIBE_TO_TM; break; @@ -392,7 +446,8 @@ ReturnValue_t StarTrackerHandler::scanForSetParameterReply(DeviceCommandId_t *fo } ReturnValue_t StarTrackerHandler::scanForTmReply(DeviceCommandId_t *foundId) { - switch (decodedFrame[1]) { + const uint8_t* reply = dataLinkLayer.getReply(); + switch (*reply) { case (StarTracker::ID::VERSION): { *foundId = StarTracker::REQ_VERSION; break; @@ -418,7 +473,7 @@ ReturnValue_t StarTrackerHandler::scanForTmReply(DeviceCommandId_t *foundId) { break; } default: { - sif::debug << "StarTrackerHandler::scanForReply: Reply contains invalid reply id" + sif::debug << "StarTrackerHandler::scanForTmReply: Reply contains invalid reply id" << std::endl; return RETURN_FAILED; break; @@ -427,31 +482,37 @@ ReturnValue_t StarTrackerHandler::scanForTmReply(DeviceCommandId_t *foundId) { return RETURN_OK; } -void StarTrackerHandler::slipInit() { - slipInfo.buffer = rxBuffer; - slipInfo.maxlength = StarTracker::MAX_FRAME_SIZE; - slipInfo.length = 0; - slipInfo.unescape_next = 0; - slipInfo.prev_state = SLIP_COMPLETE; +void StarTrackerHandler::handleEvent(EventMessage* eventMessage) { + object_id_t objectId = eventMessage->getReporter(); + switch(objectId){ + case objects::STR_IMG_LOADER: { + // All events from image loader signal either that the operation was successful or that it + // failed + imageLoaderExecuting = false; + break; + } + default: + sif::debug << "StarTrackerHandler::handleEvent: Did not subscribe to this event" + << std::endl; + break; + } } void StarTrackerHandler::prepareBootCommand() { uint32_t length = 0; struct BootActionRequest bootRequest = {BOOT_REGION_ID}; arc_pack_boot_action_req(&bootRequest, commandBuffer, &length); - uint32_t encLength = 0; - arc_transport_encode_body(commandBuffer, length, encBuffer, &encLength); - rawPacket = encBuffer; - rawPacketLen = encLength; + dataLinkLayer.encodeFrame(commandBuffer, length); + rawPacket = dataLinkLayer.getEncodedFrame(); + rawPacketLen = dataLinkLayer.getEncodedLength(); } void StarTrackerHandler::prepareTimeRequest() { uint32_t length = 0; arc_tm_pack_time_req(commandBuffer, &length); - uint32_t encLength = 0; - arc_transport_encode_body(commandBuffer, length, encBuffer, &encLength); - rawPacket = encBuffer; - rawPacketLen = encLength; + dataLinkLayer.encodeFrame(commandBuffer, length); + rawPacket = dataLinkLayer.getEncodedFrame(); + rawPacketLen = dataLinkLayer.getEncodedLength(); } void StarTrackerHandler::preparePingRequest() { @@ -467,64 +528,37 @@ void StarTrackerHandler::preparePingRequest() { void StarTrackerHandler::prepareVersionRequest() { uint32_t length = 0; arc_tm_pack_version_req(commandBuffer, &length); - uint32_t encLength = 0; - arc_transport_encode_body(commandBuffer, length, encBuffer, &encLength); - rawPacket = encBuffer; - rawPacketLen = encLength; + dataLinkLayer.encodeFrame(commandBuffer, length); + rawPacket = dataLinkLayer.getEncodedFrame(); + rawPacketLen = dataLinkLayer.getEncodedLength(); } void StarTrackerHandler::prepareInterfaceRequest() { uint32_t length = 0; arc_tm_pack_interface_req(commandBuffer, &length); - uint32_t encLength = 0; - arc_transport_encode_body(commandBuffer, length, encBuffer, &encLength); - rawPacket = encBuffer; - rawPacketLen = encLength; -} - -ReturnValue_t StarTrackerHandler::prepareImageUploadCommand(const uint8_t* commandData, - size_t commandDataLen) { - if (commandDataLen != UPLOAD_COMMAND_LEN) { - return INVALID_UPLOAD_COMMAND; - } - uint32_t length = 0; - uint32_t position = deserializeUint32(commandData); - if (position > MAX_POSITION) { - return MAX_POSITION; - } - rememberUploadPosition = position; - struct UploadActionRequest uploadRequest; - uploadRequest.position = position; - std::memcpy(uploadRequest.data, commandData + 4, commandDataLen - 4); - arc_pack_upload_action_req(&uploadRequest, commandBuffer, &length); - uint32_t encLength = 0; - arc_transport_encode_body(commandBuffer, length, encBuffer, &encLength); - rawPacket = encBuffer; - rawPacketLen = encLength; - return RETURN_OK; + dataLinkLayer.encodeFrame(commandBuffer, length); + rawPacket = dataLinkLayer.getEncodedFrame(); + rawPacketLen = dataLinkLayer.getEncodedLength(); } void StarTrackerHandler::preparePowerRequest() { uint32_t length = 0; arc_tm_pack_power_req(commandBuffer, &length); - uint32_t encLength = 0; - arc_transport_encode_body(commandBuffer, length, encBuffer, &encLength); - rawPacket = encBuffer; - rawPacketLen = encLength; + dataLinkLayer.encodeFrame(commandBuffer, length); + rawPacket = dataLinkLayer.getEncodedFrame(); + rawPacketLen = dataLinkLayer.getEncodedLength(); } void StarTrackerHandler::prepareRebootCommand() { uint32_t length = 0; struct RebootActionRequest rebootReq; arc_pack_reboot_action_req(&rebootReq, commandBuffer, &length); - uint32_t encLength = 0; - arc_transport_encode_body(commandBuffer, length, encBuffer, &encLength); - rawPacket = encBuffer; - rawPacketLen = encLength; + dataLinkLayer.encodeFrame(commandBuffer, length); + rawPacket = dataLinkLayer.getEncodedFrame(); + rawPacketLen = dataLinkLayer.getEncodedLength(); } void StarTrackerHandler::prepareSubscriptionCommand(const uint8_t* tmId) { - uint32_t encLength = 0; uint32_t length = 18; commandBuffer[0] = TMTC_SETPARAMREQ; commandBuffer[1] = StarTracker::ID::SUBSCRIBE; @@ -545,9 +579,9 @@ void StarTrackerHandler::prepareSubscriptionCommand(const uint8_t* tmId) { commandBuffer[15] = 0; commandBuffer[16] = 0; commandBuffer[17] = 0; - arc_transport_encode_body(commandBuffer, length, encBuffer, &encLength); - rawPacket = encBuffer; - rawPacketLen = encLength; + dataLinkLayer.encodeFrame(commandBuffer, length); + rawPacket = dataLinkLayer.getEncodedFrame(); + rawPacketLen = dataLinkLayer.getEncodedLength(); } void StarTrackerHandler::prepareSolutionRequest() { @@ -562,29 +596,30 @@ void StarTrackerHandler::prepareSolutionRequest() { void StarTrackerHandler::prepareTemperatureRequest() { uint32_t length = 0; arc_tm_pack_temperature_req(commandBuffer, &length); - uint32_t encLength = 0; - arc_transport_encode_body(commandBuffer, length, encBuffer, &encLength); - rawPacket = encBuffer; - rawPacketLen = encLength; + dataLinkLayer.encodeFrame(commandBuffer, length); + rawPacket = dataLinkLayer.getEncodedFrame(); + rawPacketLen = dataLinkLayer.getEncodedLength(); } ReturnValue_t StarTrackerHandler::handleSetParamReply() { - uint8_t status = *(decodedFrame + STATUS_OFFSET); + const uint8_t* reply = dataLinkLayer.getReply(); + uint8_t status = *(reply + STATUS_OFFSET); if (status != StarTracker::STATUS_OK) { sif::warning << "StarTrackerHandler::handleSetParamReply: Failed to execute parameter set " " command with parameter ID" << - static_cast(*(decodedFrame + PARAMETER_ID_OFFSET)) << std::endl; + static_cast(*(reply + PARAMETER_ID_OFFSET)) << std::endl; return SET_PARAM_FAILED; } return RETURN_OK; } ReturnValue_t StarTrackerHandler::handleActionReply() { - uint8_t status = *(decodedFrame + STATUS_OFFSET); + const uint8_t* reply = dataLinkLayer.getReply(); + uint8_t status = *(reply + STATUS_OFFSET); if (status != StarTracker::STATUS_OK) { sif::warning << "StarTrackerHandler::handleActionReply: Failed to execute action " << " command with action ID " - << static_cast(*(decodedFrame + ACTION_ID_OFFSET)) + << static_cast(*(reply + ACTION_ID_OFFSET)) << " and status "<< static_cast(status) << std::endl; return ACTION_FAILED; } @@ -594,8 +629,9 @@ ReturnValue_t StarTrackerHandler::handleActionReply() { ReturnValue_t StarTrackerHandler::handlePingReply() { ReturnValue_t result = RETURN_OK; uint32_t pingId = 0; - uint8_t status = *(decodedFrame + 2); - const uint8_t* buffer = decodedFrame + 3; + const uint8_t* reply = dataLinkLayer.getReply(); + uint8_t status = *(reply + 2); + const uint8_t* buffer = reply + 3; size_t size = sizeof(pingId); SerializeAdapter::deSerialize(&pingId, &buffer, &size, SerializeIF::Endianness::LITTLE); #if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_STARTRACKER == 1 @@ -609,22 +645,6 @@ ReturnValue_t StarTrackerHandler::handlePingReply() { return result; } -ReturnValue_t StarTrackerHandler::handleUploadImageReply() { - ReturnValue_t result = RETURN_OK; - result = handleActionReply(); - if (result != RETURN_OK) { - return result; - } - // Position seems to be always 0 (independent of sent position) -// uint32_t position = deserializeUint32(decodedFrame + ACTION_DATA_OFFSET); -// if (position != rememberUploadPosition) { -// sif::warning << "StarTrackerHandler::handleUploadImageReply: Invalid position" -// << std::endl; -// return UPLOAD_IMAGE_FAILED; -// } - return result; -} - ReturnValue_t StarTrackerHandler::handleTimeTm() { ReturnValue_t result = RETURN_OK; result = timeSet.read(TIMEOUT_TYPE, MUTEX_TIMEOUT); @@ -642,11 +662,12 @@ ReturnValue_t StarTrackerHandler::handleTimeTm() { result = VERSION_REQ_FAILED; return result; } + const uint8_t* reply = dataLinkLayer.getReply(); timeSet.ticks = ticks; timeSet.time = time; - timeSet.runTime = deserializeUint32(decodedFrame + offset); + timeSet.runTime = deserializeUint32(reply + offset); offset += sizeof(uint32_t); - timeSet.unixTime = deserializeUint64(decodedFrame + offset); + timeSet.unixTime = deserializeUint64(reply + offset); result = timeSet.commit(TIMEOUT_TYPE, MUTEX_TIMEOUT); if (result != RETURN_OK) { return result; @@ -674,13 +695,14 @@ ReturnValue_t StarTrackerHandler::handleVersionTm() { if (result != RETURN_OK) { return result; } + const uint8_t* reply = dataLinkLayer.getReply(); versionSet.ticks = ticks; versionSet.time = time; - versionSet.program = *(decodedFrame + offset); + versionSet.program = *(reply + offset); offset += 1; - versionSet.major = *(decodedFrame + offset); + versionSet.major = *(reply + offset); offset += 1; - versionSet.minor = *(decodedFrame + offset); + versionSet.minor = *(reply + offset); result = versionSet.commit(TIMEOUT_TYPE, MUTEX_TIMEOUT); if (result != RETURN_OK) { return result; @@ -708,12 +730,13 @@ ReturnValue_t StarTrackerHandler::handleInterfaceTm() { if (result != RETURN_OK) { return result; } + const uint8_t* reply = dataLinkLayer.getReply(); interfaceSet.ticks = ticks; interfaceSet.time = time; size_t size = sizeof(uint32_t); - interfaceSet.frameCount = deserializeUint32(decodedFrame + offset); + interfaceSet.frameCount = deserializeUint32(reply + offset); offset += size; - interfaceSet.checksumerrorCount = deserializeUint32(decodedFrame + offset); + interfaceSet.checksumerrorCount = deserializeUint32(reply + offset); result = interfaceSet.commit(TIMEOUT_TYPE, MUTEX_TIMEOUT); if (result != RETURN_OK) { return result; @@ -741,55 +764,56 @@ ReturnValue_t StarTrackerHandler::handlePowerTm() { if (result != RETURN_OK) { return result; } + const uint8_t* reply = dataLinkLayer.getReply(); powerSet.ticks= ticks; powerSet.time= time; float value = 0; - std::memcpy(&value, decodedFrame + offset, sizeof(value)); + std::memcpy(&value, reply + offset, sizeof(value)); powerSet.mcuCurrent = value; offset += 4; - std::memcpy(&value, decodedFrame + offset, sizeof(value)); + std::memcpy(&value, reply + offset, sizeof(value)); powerSet.mcuVoltage = value; offset += 4; - std::memcpy(&value, decodedFrame + offset, sizeof(value)); + std::memcpy(&value, reply + offset, sizeof(value)); powerSet.fpgaCoreCurrent = value; offset += 4; - std::memcpy(&value, decodedFrame + offset, sizeof(value)); + std::memcpy(&value, reply + offset, sizeof(value)); powerSet.fpgaCoreVoltage = value; offset += 4; - std::memcpy(&value, decodedFrame + offset, sizeof(value)); + std::memcpy(&value, reply + offset, sizeof(value)); powerSet.fpga18Current = value; offset += 4; - std::memcpy(&value, decodedFrame + offset, sizeof(value)); + std::memcpy(&value, reply + offset, sizeof(value)); powerSet.fpga18Voltage = value; offset += 4; - std::memcpy(&value, decodedFrame + offset, sizeof(value)); + std::memcpy(&value, reply + offset, sizeof(value)); powerSet.fpga25Current = value; offset += 4; - std::memcpy(&value, decodedFrame + offset, sizeof(value)); + std::memcpy(&value, reply + offset, sizeof(value)); powerSet.fpga25Voltage = value; offset += 4; - std::memcpy(&value, decodedFrame + offset, sizeof(value)); + std::memcpy(&value, reply + offset, sizeof(value)); powerSet.cmv21Current = value; offset += 4; - std::memcpy(&value, decodedFrame + offset, sizeof(value)); + std::memcpy(&value, reply + offset, sizeof(value)); powerSet.cmv21Voltage = value; offset += 4; - std::memcpy(&value, decodedFrame + offset, sizeof(value)); + std::memcpy(&value, reply + offset, sizeof(value)); powerSet.cmvPixCurrent= value; offset += 4; - std::memcpy(&value, decodedFrame + offset, sizeof(value)); + std::memcpy(&value, reply + offset, sizeof(value)); powerSet.cmvPixVoltage = value; offset += 4; - std::memcpy(&value, decodedFrame + offset, sizeof(value)); + std::memcpy(&value, reply + offset, sizeof(value)); powerSet.cmv33Current= value; offset += 4; - std::memcpy(&value, decodedFrame + offset, sizeof(value)); + std::memcpy(&value, reply + offset, sizeof(value)); powerSet.cmv33Voltage = value; offset += 4; - std::memcpy(&value, decodedFrame + offset, sizeof(value)); + std::memcpy(&value, reply + offset, sizeof(value)); powerSet.cmvResCurrent= value; offset += 4; - std::memcpy(&value, decodedFrame + offset, sizeof(value)); + std::memcpy(&value, reply + offset, sizeof(value)); powerSet.cmvResVoltage = value; result = powerSet.commit(TIMEOUT_TYPE, MUTEX_TIMEOUT); if (result != RETURN_OK) { @@ -818,64 +842,65 @@ ReturnValue_t StarTrackerHandler::handleSolutionTm() { result = TEMPERATURE_REQ_FAILED; return result; } + const uint8_t* reply = dataLinkLayer.getReply(); solutionSet.ticks= ticks; solutionSet.time= time; float word = 0; - std::memcpy(&word, decodedFrame + offset, sizeof(float)); + std::memcpy(&word, reply + offset, sizeof(float)); solutionSet.caliQw = word; offset += sizeof(float); - std::memcpy(&word, decodedFrame + offset, sizeof(float)); + std::memcpy(&word, reply + offset, sizeof(float)); solutionSet.caliQx = word; offset += sizeof(float); - std::memcpy(&word, decodedFrame + offset, sizeof(float)); + std::memcpy(&word, reply + offset, sizeof(float)); solutionSet.caliQy = word; offset += sizeof(float); - std::memcpy(&word, decodedFrame + offset, sizeof(float)); + std::memcpy(&word, reply + offset, sizeof(float)); solutionSet.caliQz = word; offset += sizeof(float); - std::memcpy(&word, decodedFrame + offset, sizeof(float)); + std::memcpy(&word, reply + offset, sizeof(float)); solutionSet.trackConfidence = word; offset += sizeof(float); - std::memcpy(&word, decodedFrame + offset, sizeof(float)); + std::memcpy(&word, reply + offset, sizeof(float)); solutionSet.trackQw = word; offset += sizeof(float); - std::memcpy(&word, decodedFrame + offset, sizeof(float)); + std::memcpy(&word, reply + offset, sizeof(float)); solutionSet.trackQx = word; offset += sizeof(float); - std::memcpy(&word, decodedFrame + offset, sizeof(float)); + std::memcpy(&word, reply + offset, sizeof(float)); solutionSet.trackQy = word; offset += sizeof(float); - std::memcpy(&word, decodedFrame + offset, sizeof(float)); + std::memcpy(&word, reply + offset, sizeof(float)); solutionSet.trackQz = word; offset += sizeof(float); - solutionSet.trackRemoved = *(decodedFrame + offset); + solutionSet.trackRemoved = *(reply + offset); offset += sizeof(uint8_t); - solutionSet.starsCentroided = *(decodedFrame + offset); + solutionSet.starsCentroided = *(reply + offset); offset += sizeof(uint8_t); - solutionSet.starsMatchedDatabase = *(decodedFrame + offset); + solutionSet.starsMatchedDatabase = *(reply + offset); offset += sizeof(float); - std::memcpy(&word, decodedFrame + offset, sizeof(float)); + std::memcpy(&word, reply + offset, sizeof(float)); solutionSet.lisaQw = word; offset += sizeof(float); - std::memcpy(&word, decodedFrame + offset, sizeof(float)); + std::memcpy(&word, reply + offset, sizeof(float)); solutionSet.lisaQx = word; offset += sizeof(float); - std::memcpy(&word, decodedFrame + offset, sizeof(float)); + std::memcpy(&word, reply + offset, sizeof(float)); solutionSet.lisaQy = word; offset += sizeof(float); - std::memcpy(&word, decodedFrame + offset, sizeof(float)); + std::memcpy(&word, reply + offset, sizeof(float)); solutionSet.lisaQz = word; offset += sizeof(float); - std::memcpy(&word, decodedFrame + offset, sizeof(float)); + std::memcpy(&word, reply + offset, sizeof(float)); solutionSet.lisaPercentageClose = word; offset += sizeof(float); - solutionSet.lisaNrClose = *(decodedFrame + offset); + solutionSet.lisaNrClose = *(reply + offset); offset += sizeof(uint8_t); - solutionSet.isTrustWorthy = *(decodedFrame + offset); + solutionSet.isTrustWorthy = *(reply + offset); offset += sizeof(uint8_t); - solutionSet.stableCount = *(decodedFrame + offset); + solutionSet.stableCount = *(reply + offset); offset += sizeof(uint32_t); - solutionSet.stableCount = *(decodedFrame + offset); + solutionSet.stableCount = *(reply + offset); result = solutionSet.commit(TIMEOUT_TYPE, MUTEX_TIMEOUT); if (result != RETURN_OK) { return result; @@ -903,13 +928,14 @@ ReturnValue_t StarTrackerHandler::handleTemperatureTm() { if (result != RETURN_OK) { return result; } + const uint8_t* reply = dataLinkLayer.getReply(); temperatureSet.ticks= ticks; temperatureSet.time= time; float temperature = 0; - std::memcpy(&temperature, decodedFrame + offset, sizeof(temperature)); + std::memcpy(&temperature, reply + offset, sizeof(temperature)); temperatureSet.mcuTemperature = temperature; offset += sizeof(float); - std::memcpy(&temperature, decodedFrame + offset, sizeof(temperature)); + std::memcpy(&temperature, reply + offset, sizeof(temperature)); temperatureSet.cmosTemperature = temperature; result = temperatureSet.commit(TIMEOUT_TYPE, MUTEX_TIMEOUT); if (result != RETURN_OK) { @@ -922,9 +948,10 @@ ReturnValue_t StarTrackerHandler::handleTemperatureTm() { } void StarTrackerHandler::getTmHeaderData(uint8_t* status, uint32_t* ticks, uint64_t* time) { - *status = *(decodedFrame + STATUS_OFFSET); - *ticks = deserializeUint32(decodedFrame + TICKS_OFFSET); - *time = deserializeUint64(decodedFrame + TIME_OFFSET); + const uint8_t* reply = dataLinkLayer.getReply(); + *status = *(reply + STATUS_OFFSET); + *ticks = deserializeUint32(reply + TICKS_OFFSET); + *time = deserializeUint64(reply + TIME_OFFSET); } uint32_t StarTrackerHandler::deserializeUint32(const uint8_t* buffer) { diff --git a/mission/devices/StarTrackerHandler.h b/mission/devices/StarTrackerHandler.h index d74d6fd2..e8aef15a 100644 --- a/mission/devices/StarTrackerHandler.h +++ b/mission/devices/StarTrackerHandler.h @@ -7,6 +7,8 @@ #include #include #include +#include +#include /** * @brief This is the device handler for the star tracker from arcsec. @@ -35,6 +37,15 @@ public: ReturnValue_t initialize() override; + /** + * @brief Overwrite this function from DHB to handle commands executed by the str image + * loader task. + */ + ReturnValue_t executeAction(ActionId_t actionId, MessageQueueId_t commandedBy, + const uint8_t* data, size_t size) override; + + void performOperationHook() override; + protected: void doStartUp() override; void doShutDown() override; @@ -64,7 +75,9 @@ private: //! [EXPORT] : [COMMENT] Received reply is too short static const ReturnValue_t REPLY_TOO_SHORT = MAKE_RETURN_CODE(0xB0); //! [EXPORT] : [COMMENT] Received reply with invalid CRC - static const ReturnValue_t CRC_FAILURE = MAKE_RETURN_CODE(0xB0); + static const ReturnValue_t CRC_FAILURE = MAKE_RETURN_CODE(0xB1); + //! [EXPORT] : [COMMENT] Image loader executing + static const ReturnValue_t IMAGE_LOADER_EXECUTING = MAKE_RETURN_CODE(0xB2); static const uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::STR_HANDLER; @@ -95,13 +108,13 @@ private: static const size_t UPLOAD_COMMAND_LEN = 1028; // Max valid position value in upload image command static const uint16_t MAX_POSITION= 4095; - static const uint8_t STATUS_OFFSET = 2; - static const uint8_t TICKS_OFFSET = 3; - static const uint8_t TIME_OFFSET = 7; - static const uint8_t TM_DATA_FIELD_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; + static const uint8_t STATUS_OFFSET = 1; + static const uint8_t TICKS_OFFSET = 2; + static const uint8_t TIME_OFFSET = 6; + static const uint8_t TM_DATA_FIELD_OFFSET = 14; + static const uint8_t PARAMETER_ID_OFFSET = 0; + static const uint8_t ACTION_ID_OFFSET = 0; + static const uint8_t ACTION_DATA_OFFSET = 2; // Ping request will reply ping with this ID (data field) static const uint32_t PING_ID = 0x55; @@ -113,6 +126,10 @@ private: // Pointer to object responsible for uploading and downloading images to/from the star tracker StrImageLoader* strImageLoader = nullptr; + MessageQueueIF* eventQueue = nullptr; + + ArcsecDatalinkLayer dataLinkLayer; + StarTracker::TemperatureSet temperatureSet; StarTracker::VersionSet versionSet; StarTracker::PowerSet powerSet; @@ -121,13 +138,6 @@ private: StarTracker::SolutionSet solutionSet; uint8_t commandBuffer[StarTracker::MAX_FRAME_SIZE]; - uint8_t rxBuffer[StarTracker::MAX_FRAME_SIZE]; - uint8_t decodedFrame[StarTracker::MAX_FRAME_SIZE]; - - /** Size of buffer derived from the egse source code */ - uint8_t encBuffer[StarTracker::MAX_FRAME_SIZE * 2 + 2]; - - slip_decode_state slipInfo; enum class InternalState { TEMPERATURE_REQUEST @@ -135,7 +145,7 @@ private: InternalState internalState = InternalState::TEMPERATURE_REQUEST; - uint32_t rememberUploadPosition = 0; + bool imageLoaderExecuting = false; /** * @brief This function initializes the serial link ip protocol struct slipInfo. @@ -172,11 +182,6 @@ private: */ void prepareInterfaceRequest(); - /** - * @brief Fills the command buffer with data to upload part of an image. - */ - ReturnValue_t prepareImageUploadCommand(const uint8_t* commandData, size_t commandDataLen); - /** * @brief Fills the command buffer with data to request the power telemetry packet. */ @@ -217,11 +222,6 @@ private: ReturnValue_t handlePingReply(); - /** - * @brief Handles reply to upload image command - */ - ReturnValue_t handleUploadImageReply(); - /** * @brief Fills the time set with the data of the time request reply. */ diff --git a/mission/devices/devicedefinitions/StarTrackerDefinitions.h b/mission/devices/devicedefinitions/StarTrackerDefinitions.h index ef9182ff..4721957b 100644 --- a/mission/devices/devicedefinitions/StarTrackerDefinitions.h +++ b/mission/devices/devicedefinitions/StarTrackerDefinitions.h @@ -91,6 +91,7 @@ static const DeviceCommandId_t REQ_VERSION = 2; static const DeviceCommandId_t REQ_INTERFACE = 3; static const DeviceCommandId_t REQ_TIME = 4; static const DeviceCommandId_t REBOOT = 7; +static const DeviceCommandId_t DOWNLOAD_IMAGE = 9; static const DeviceCommandId_t UPLOAD_IMAGE = 10; static const DeviceCommandId_t REQ_POWER = 11; static const DeviceCommandId_t SUBSCRIBE_TO_TM = 18; diff --git a/mission/tmtc/CCSDSHandler.cpp b/mission/tmtc/CCSDSHandler.cpp index e0239d9a..524fe4b8 100644 --- a/mission/tmtc/CCSDSHandler.cpp +++ b/mission/tmtc/CCSDSHandler.cpp @@ -80,15 +80,19 @@ ReturnValue_t CCSDSHandler::initialize() { EventManagerIF* manager = ObjectManager::instance()->get( objects::EVENT_MANAGER); - if (manager == nullptr) { + if (manager == nullptr) { #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "CCSDSHandler::initialize: Invalid event manager" << std::endl; #endif - return RETURN_FAILED; + return ObjectManagerIF::CHILD_INIT_FAILED; } result = manager->registerListener(eventQueue->getId()); if (result != HasReturnvaluesIF::RETURN_OK) { - return result; +#if FSFW_CPP_OSTREAM_ENABLED == 1 + sif::warning << "CCSDSHandler::initialize: Failed to register CCSDS handler as event " + "listener" << std::endl; +#endif + return ObjectManagerIF::CHILD_INIT_FAILED;; } result = manager->subscribeToEventRange(eventQueue->getId(), event::getEventId(PdecHandler::CARRIER_LOCK), diff --git a/tmtc b/tmtc index 1d374230..dedb2849 160000 --- a/tmtc +++ b/tmtc @@ -1 +1 @@ -Subproject commit 1d374230b34606d8b6aa4df1335befec316a1e35 +Subproject commit dedb28497f62314498034cd87d1e2a4361b92950