From 743d8abeaffe55cefbddbd2b264be4adcac4d19c Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Thu, 17 Oct 2019 00:23:46 +0200 Subject: [PATCH 01/26] first attempt to document and explain serialization tools for application developers --- serialize/SerialLinkedListAdapter.h | 16 +++++++++++++++- serialize/SerializeAdapter.h | 14 +++++++++++++- serialize/SerializeIF.h | 2 +- 3 files changed, 29 insertions(+), 3 deletions(-) diff --git a/serialize/SerialLinkedListAdapter.h b/serialize/SerialLinkedListAdapter.h index 29952c4a3..44d9e15bc 100644 --- a/serialize/SerialLinkedListAdapter.h +++ b/serialize/SerialLinkedListAdapter.h @@ -13,7 +13,21 @@ #include //This is where we need the SerializeAdapter! -/** + /** + * An alternative to the AutoSerializeAdapter functions to implement the conversion + * of object data to data streams or vice-versa, using linked lists. + * + * All object members with a datatype are declared as SerializeElement inside the class. + * + * Buffers with a size header inside that class can be declared with + * SerialFixedArrayListAdapter. + * typeOfMaxData specifies the data type of the buffer header containing the buffer size that follows + * and MAX_BUFFER_LENGTH specifies the maximum allowed value for the buffer size. + * The sequence of objects is defined in the constructor by using the setStart and setNext functions. + * + * The serialization and deserialization process is done by instantiating the class and + * calling the serialize or deserialize function. + * * \ingroup serialize */ template diff --git a/serialize/SerializeAdapter.h b/serialize/SerializeAdapter.h index fd9e1b6af..67c37493a 100644 --- a/serialize/SerializeAdapter.h +++ b/serialize/SerializeAdapter.h @@ -7,7 +7,19 @@ #include #include -/** + /** + * This adapter provides an interface to use the SerializeIF functions + * with arbitrary template objects to facilitate and simplify the serialization of classes + * with different multiple different data types into buffers vice-versa. + * + * Examples: + * A report class is converted into a TM buffer. The report class implements a serialize functions and calls + * the AutoSerializeAdapter::serialize function repeatedly on all object data fields. + * The getSerializedSize function is implemented by calling the + * AutoSerializeAdapter::getSerializedSize function repeatedly on all data fields. + * + * The AutoSerializeAdapter functions can also be used as an alternative to memcpy + * to retrieve data out of a buffer directly into a class variable with data type T while being able to specify endianness. * \ingroup serialize */ template diff --git a/serialize/SerializeIF.h b/serialize/SerializeIF.h index 701fbf563..50555d379 100644 --- a/serialize/SerializeIF.h +++ b/serialize/SerializeIF.h @@ -9,7 +9,7 @@ */ /** - * Translation of objects into data streams. + * An interface for alle classes which require translation of objects data into data streams and vice-versa. * \ingroup serialize */ class SerializeIF { -- 2.34.1 From 5e3b7c36257314bab40b36c78c13c0525b08eb86 Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Fri, 18 Oct 2019 13:37:09 +0200 Subject: [PATCH 02/26] explanation of cookie purpose added, device handler base indentation --- devicehandlers/Cookie.h | 3 +++ devicehandlers/DeviceHandlerBase.cpp | 27 +++++++++++++-------------- 2 files changed, 16 insertions(+), 14 deletions(-) diff --git a/devicehandlers/Cookie.h b/devicehandlers/Cookie.h index 495c8c403..618c901ff 100644 --- a/devicehandlers/Cookie.h +++ b/devicehandlers/Cookie.h @@ -1,6 +1,9 @@ #ifndef COOKIE_H_ #define COOKIE_H_ +/** + * This datatype is used to identify different connection over a single interface (like RMAP or I2C) + */ class Cookie{ public: virtual ~Cookie(){} diff --git a/devicehandlers/DeviceHandlerBase.cpp b/devicehandlers/DeviceHandlerBase.cpp index ae9199f2c..750d4d4ad 100644 --- a/devicehandlers/DeviceHandlerBase.cpp +++ b/devicehandlers/DeviceHandlerBase.cpp @@ -21,20 +21,19 @@ DeviceHandlerBase::DeviceHandlerBase(uint32_t ioBoardAddress, uint8_t setDeviceSwitch, object_id_t deviceCommunication, uint32_t thermalStatePoolId, uint32_t thermalRequestPoolId, FailureIsolationBase* fdirInstance, uint32_t cmdQueueSize) : - SystemObject(setObjectId), rawPacket(0), rawPacketLen(0), mode( - MODE_OFF), submode(SUBMODE_NONE), pstStep(0), maxDeviceReplyLen( - maxDeviceReplyLen), wiretappingMode(OFF), defaultRawReceiver(0), storedRawData( - StorageManagerIF::INVALID_ADDRESS), requestedRawTraffic(0), powerSwitcher( - NULL), IPCStore(NULL), deviceCommunicationId(deviceCommunication), communicationInterface( - NULL), cookie( - NULL), commandQueue(NULL), deviceThermalStatePoolId(thermalStatePoolId), deviceThermalRequestPoolId( - thermalRequestPoolId), healthHelper(this, setObjectId), modeHelper( - this), parameterHelper(this), childTransitionFailure(RETURN_OK), ignoreMissedRepliesCount( - 0), fdirInstance(fdirInstance), hkSwitcher(this), defaultFDIRUsed( - fdirInstance == NULL), switchOffWasReported(false),executingTask(NULL), actionHelper(this, NULL), cookieInfo(), ioBoardAddress( - ioBoardAddress), timeoutStart(0), childTransitionDelay(5000), transitionSourceMode( - _MODE_POWER_DOWN), transitionSourceSubMode(SUBMODE_NONE), deviceSwitch( - setDeviceSwitch) { + SystemObject(setObjectId), rawPacket(0), rawPacketLen(0), mode(MODE_OFF), + submode(SUBMODE_NONE), pstStep(0), maxDeviceReplyLen(maxDeviceReplyLen), + wiretappingMode(OFF), defaultRawReceiver(0), storedRawData(StorageManagerIF::INVALID_ADDRESS), + requestedRawTraffic(0), powerSwitcher(NULL), IPCStore(NULL), + deviceCommunicationId(deviceCommunication), communicationInterface(NULL), + cookie(NULL), commandQueue(NULL), deviceThermalStatePoolId(thermalStatePoolId), + deviceThermalRequestPoolId(thermalRequestPoolId), healthHelper(this, setObjectId), + modeHelper(this), parameterHelper(this), childTransitionFailure(RETURN_OK), + ignoreMissedRepliesCount(0), fdirInstance(fdirInstance), hkSwitcher(this), + defaultFDIRUsed(fdirInstance == NULL), switchOffWasReported(false), + executingTask(NULL), actionHelper(this, NULL), cookieInfo(), ioBoardAddress(ioBoardAddress), + timeoutStart(0), childTransitionDelay(5000), transitionSourceMode(_MODE_POWER_DOWN), + transitionSourceSubMode(SUBMODE_NONE), deviceSwitch(setDeviceSwitch) { commandQueue = QueueFactory::instance()->createMessageQueue(cmdQueueSize, CommandMessage::MAX_MESSAGE_SIZE); cookieInfo.state = COOKIE_UNUSED; -- 2.34.1 From 907664cea9958f1259ed19560839c26533481cf7 Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Mon, 21 Oct 2019 11:38:13 +0200 Subject: [PATCH 03/26] added do performOperation where the comIF functions are called, some comments added in DeviceHandlerIF --- devicehandlers/DeviceHandlerBase.h | 18 +++++++++++------- devicehandlers/DeviceHandlerIF.h | 7 ++++++- 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/devicehandlers/DeviceHandlerBase.h b/devicehandlers/DeviceHandlerBase.h index 756ad530d..70fefe8aa 100644 --- a/devicehandlers/DeviceHandlerBase.h +++ b/devicehandlers/DeviceHandlerBase.h @@ -33,6 +33,7 @@ class StorageManagerIF; * Contains all devices and the DeviceHandlerBase class. */ +// Robin: We're not really using RMAP, right? Maybe we should adapt class description for that? /** * \brief This is the abstract base class for device handlers. * @@ -81,7 +82,7 @@ public: /** - * This function is a core component and is called periodically. + * This function is the device handler base core component and is called periodically. * General sequence: * If the State is SEND_WRITE: * 1. Set the cookie state to COOKIE_UNUSED and read the command queue @@ -95,13 +96,16 @@ public: * 7. If the device mode is MODE_OFF, return RETURN_OK. Otherwise, perform the Action property * and performs depending on value specified * by input value counter. The child class tells base class what to do by setting this value. - * - SEND_WRITE: Send data or commands to device by calling doSendWrite() - * Calls abstract funtions buildNomalDeviceCommand() - * or buildTransitionDeviceCommand() - * - GET_WRITE: Get ackknowledgement for sending by calling doGetWrite(). + * - SEND_WRITE: Send data or commands to device by calling doSendWrite() which calls + * sendMessage function of #communicationInterface + * and calls buildInternalCommand if the cookie state is COOKIE_UNUSED + * - GET_WRITE: Get ackknowledgement for sending by calling doGetWrite() which calls + * getSendSuccess of #communicationInterface. * Calls abstract functions scanForReply() and interpretDeviceReply(). - * - SEND_READ: Request reading data from device by calling doSendRead() - * - GET_READ: Access requested reading data by calling doGetRead() + * - SEND_READ: Request reading data from device by calling doSendRead() which calls + * requestReceiveMessage of #communcationInterface + * - GET_READ: Access requested reading data by calling doGetRead() which calls + * readReceivedMessage of #communicationInterface * @param counter Specifies which Action to perform * @return RETURN_OK for successful execution */ diff --git a/devicehandlers/DeviceHandlerIF.h b/devicehandlers/DeviceHandlerIF.h index fe0ee8e8b..8fdd04fe9 100644 --- a/devicehandlers/DeviceHandlerIF.h +++ b/devicehandlers/DeviceHandlerIF.h @@ -23,6 +23,11 @@ public: * @details The mode of the device handler must not be confused with the mode the device is in. * The mode of the device itself is transparent to the user but related to the mode of the handler. */ + // Robin: The first two modes (MODE_ON, MODE_OFF) are specified in hasModesIF. + // We could mention in a comment where those modes are located. + // The comments for _MODE_TO_ON have been taken from the comments in DeviceHandlerBase.cpp file. + // Is the same explanation valid for _MODE_TO_RAW and MODE_TO_NORMAL? + // MODE_ON = 0, //!< The device is powered and ready to perform operations. In this mode, no commands are sent by the device handler itself, but direct commands van be commanded and will be interpreted // MODE_OFF = 1, //!< The device is powered off. The only command accepted in this mode is a mode change to on. static const Mode_t MODE_NORMAL = 2; //!< The device is powered on and the device handler periodically sends commands. The commands to be sent are selected by the handler according to the submode. @@ -30,7 +35,7 @@ public: static const Mode_t MODE_ERROR_ON = 4; //!4< The device is shut down but the switch could not be turned off, so the device still is powered. In this mode, only a mode change to @c MODE_OFF can be commanded, which tries to switch off the device again. static const Mode_t _MODE_START_UP = TRANSITION_MODE_CHILD_ACTION_MASK | 5; //!< This is a transitional state which can not be commanded. The device handler performs all commands to get the device in a state ready to perform commands. When this is completed, the mode changes to @c MODE_ON. static const Mode_t _MODE_SHUT_DOWN = TRANSITION_MODE_CHILD_ACTION_MASK | 6; //!< This is a transitional state which can not be commanded. The device handler performs all actions and commands to get the device shut down. When the device is off, the mode changes to @c MODE_OFF. - static const Mode_t _MODE_TO_ON = TRANSITION_MODE_CHILD_ACTION_MASK | HasModesIF::MODE_ON; + static const Mode_t _MODE_TO_ON = TRANSITION_MODE_CHILD_ACTION_MASK | HasModesIF::MODE_ON; //!< It is possible to set the mode to _MODE_TO_ON to use the to on transition if available. static const Mode_t _MODE_TO_RAW = TRANSITION_MODE_CHILD_ACTION_MASK | MODE_RAW; static const Mode_t _MODE_TO_NORMAL = TRANSITION_MODE_CHILD_ACTION_MASK | MODE_NORMAL; static const Mode_t _MODE_POWER_DOWN = TRANSITION_MODE_BASE_ACTION_MASK | 1; //!< This is a transitional state which can not be commanded. The device is shut down and ready to be switched off. After the command to set the switch off has been sent, the mode changes to @c MODE_WAIT_OFF -- 2.34.1 From cbc8012198da6e94870f2b5fe63b799587092bc8 Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Tue, 22 Oct 2019 00:06:11 +0200 Subject: [PATCH 04/26] ioBoardAddress protected instead of private to allow custom initialize --- devicehandlers/DeviceHandlerBase.cpp | 4 ++-- devicehandlers/DeviceHandlerBase.h | 14 ++++++++++---- devicehandlers/DeviceHandlerIF.h | 6 ++---- health/HealthHelper.h | 2 +- osal/FreeRTOS/FixedTimeslotTask.cpp | 3 +-- 5 files changed, 16 insertions(+), 13 deletions(-) diff --git a/devicehandlers/DeviceHandlerBase.cpp b/devicehandlers/DeviceHandlerBase.cpp index 750d4d4ad..bc87422d8 100644 --- a/devicehandlers/DeviceHandlerBase.cpp +++ b/devicehandlers/DeviceHandlerBase.cpp @@ -21,7 +21,7 @@ DeviceHandlerBase::DeviceHandlerBase(uint32_t ioBoardAddress, uint8_t setDeviceSwitch, object_id_t deviceCommunication, uint32_t thermalStatePoolId, uint32_t thermalRequestPoolId, FailureIsolationBase* fdirInstance, uint32_t cmdQueueSize) : - SystemObject(setObjectId), rawPacket(0), rawPacketLen(0), mode(MODE_OFF), + SystemObject(setObjectId),ioBoardAddress(ioBoardAddress), rawPacket(0), rawPacketLen(0), mode(MODE_OFF), submode(SUBMODE_NONE), pstStep(0), maxDeviceReplyLen(maxDeviceReplyLen), wiretappingMode(OFF), defaultRawReceiver(0), storedRawData(StorageManagerIF::INVALID_ADDRESS), requestedRawTraffic(0), powerSwitcher(NULL), IPCStore(NULL), @@ -31,7 +31,7 @@ DeviceHandlerBase::DeviceHandlerBase(uint32_t ioBoardAddress, modeHelper(this), parameterHelper(this), childTransitionFailure(RETURN_OK), ignoreMissedRepliesCount(0), fdirInstance(fdirInstance), hkSwitcher(this), defaultFDIRUsed(fdirInstance == NULL), switchOffWasReported(false), - executingTask(NULL), actionHelper(this, NULL), cookieInfo(), ioBoardAddress(ioBoardAddress), + executingTask(NULL), actionHelper(this, NULL), cookieInfo(), timeoutStart(0), childTransitionDelay(5000), transitionSourceMode(_MODE_POWER_DOWN), transitionSourceSubMode(SUBMODE_NONE), deviceSwitch(setDeviceSwitch) { commandQueue = QueueFactory::instance()->createMessageQueue(cmdQueueSize, diff --git a/devicehandlers/DeviceHandlerBase.h b/devicehandlers/DeviceHandlerBase.h index 70fefe8aa..45a87a8aa 100644 --- a/devicehandlers/DeviceHandlerBase.h +++ b/devicehandlers/DeviceHandlerBase.h @@ -141,6 +141,11 @@ public: */ virtual void setTaskIF(PeriodicTaskIF* task_); protected: + /** + * cached from ctor for initialize() + */ + const uint32_t ioBoardAddress; + /** * The Returnvalues id of this class, required by HasReturnvaluesIF */ @@ -163,6 +168,8 @@ protected: static const DeviceCommandId_t NO_COMMAND_ID = -2; static const MessageQueueId_t NO_COMMANDER = 0; + + /** * Pointer to the raw packet that will be sent. */ @@ -833,6 +840,9 @@ protected: DeviceCommandMap deviceCommandMap; ActionHelper actionHelper; + + + private: /** @@ -865,10 +875,6 @@ private: */ CookieInfo cookieInfo; - /** - * cached from ctor for initialize() - */ - const uint32_t ioBoardAddress; /** * Used for timing out mode transitions. diff --git a/devicehandlers/DeviceHandlerIF.h b/devicehandlers/DeviceHandlerIF.h index 8fdd04fe9..bfa7c7b24 100644 --- a/devicehandlers/DeviceHandlerIF.h +++ b/devicehandlers/DeviceHandlerIF.h @@ -22,11 +22,9 @@ public: * * @details The mode of the device handler must not be confused with the mode the device is in. * The mode of the device itself is transparent to the user but related to the mode of the handler. + * MODE_ON and MODE_OFF are included in hasModesIF.h */ - // Robin: The first two modes (MODE_ON, MODE_OFF) are specified in hasModesIF. - // We could mention in a comment where those modes are located. - // The comments for _MODE_TO_ON have been taken from the comments in DeviceHandlerBase.cpp file. - // Is the same explanation valid for _MODE_TO_RAW and MODE_TO_NORMAL? + // MODE_ON = 0, //!< The device is powered and ready to perform operations. In this mode, no commands are sent by the device handler itself, but direct commands van be commanded and will be interpreted // MODE_OFF = 1, //!< The device is powered off. The only command accepted in this mode is a mode change to on. diff --git a/health/HealthHelper.h b/health/HealthHelper.h index a1ca2c525..24fd0d14a 100644 --- a/health/HealthHelper.h +++ b/health/HealthHelper.h @@ -27,8 +27,8 @@ public: /** * ctor * + * @param owner * @param objectId the object Id to use when communication with the HealthTable - * @param useAsFrom id to use as from id when sending replies, can be set to 0 */ HealthHelper(HasHealthIF* owner, object_id_t objectId); diff --git a/osal/FreeRTOS/FixedTimeslotTask.cpp b/osal/FreeRTOS/FixedTimeslotTask.cpp index 00fd73d35..5bf09f136 100644 --- a/osal/FreeRTOS/FixedTimeslotTask.cpp +++ b/osal/FreeRTOS/FixedTimeslotTask.cpp @@ -19,8 +19,7 @@ FixedTimeslotTask::~FixedTimeslotTask() { void FixedTimeslotTask::taskEntryPoint(void* argument) { //The argument is re-interpreted as FixedTimeslotTask. The Task object is global, so it is found from any place. - FixedTimeslotTask *originalTask( - reinterpret_cast(argument)); + FixedTimeslotTask *originalTask(reinterpret_cast(argument)); // Task should not start until explicitly requested // in FreeRTOS, tasks start as soon as they are created if the scheduler is running // but not if the scheduler is not running. -- 2.34.1 From 4db655e4898de934f6388365ec036d9d6e6b1bbe Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 22 Oct 2019 14:01:17 +0200 Subject: [PATCH 05/26] task priority order comment --- osal/FreeRTOS/TaskFactory.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/osal/FreeRTOS/TaskFactory.cpp b/osal/FreeRTOS/TaskFactory.cpp index 7b2f70a3a..753da60f7 100644 --- a/osal/FreeRTOS/TaskFactory.cpp +++ b/osal/FreeRTOS/TaskFactory.cpp @@ -15,6 +15,7 @@ TaskFactory* TaskFactory::instance() { } /*** * Keep in Mind that you need to call before this vTaskStartScheduler()! + * High taskPriority_ number means high priority. */ PeriodicTaskIF* TaskFactory::createPeriodicTask(TaskName name_, TaskPriority taskPriority_, TaskStackSize stackSize_, -- 2.34.1 From c6e34cada64f59757e420347dec8373401d73c7a Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Tue, 22 Oct 2019 17:15:29 +0200 Subject: [PATCH 06/26] documentation for DHB init function, ioBoard addres has default value 0 now, order in ctor changed (not used in source) --- devicehandlers/ChildHandlerBase.cpp | 4 ++-- devicehandlers/DeviceHandlerBase.cpp | 9 ++++----- devicehandlers/DeviceHandlerBase.h | 21 ++++++++++++++++++--- 3 files changed, 24 insertions(+), 10 deletions(-) diff --git a/devicehandlers/ChildHandlerBase.cpp b/devicehandlers/ChildHandlerBase.cpp index 50a5c07e5..fb9238f7e 100644 --- a/devicehandlers/ChildHandlerBase.cpp +++ b/devicehandlers/ChildHandlerBase.cpp @@ -7,8 +7,8 @@ ChildHandlerBase::ChildHandlerBase(uint32_t ioBoardAddress, uint32_t maxDeviceReplyLen, uint8_t setDeviceSwitch, uint32_t thermalStatePoolId, uint32_t thermalRequestPoolId, uint32_t parent, FailureIsolationBase* customFdir, uint32_t cmdQueueSize) : - DeviceHandlerBase(ioBoardAddress, setObjectId, maxDeviceReplyLen, - setDeviceSwitch, deviceCommunication, thermalStatePoolId, + DeviceHandlerBase(setObjectId, maxDeviceReplyLen, + setDeviceSwitch, deviceCommunication,ioBoardAddress, thermalStatePoolId, thermalRequestPoolId, (customFdir == NULL? &childHandlerFdir : customFdir), cmdQueueSize), parentId( parent), childHandlerFdir(setObjectId) { } diff --git a/devicehandlers/DeviceHandlerBase.cpp b/devicehandlers/DeviceHandlerBase.cpp index bc87422d8..d0f9d8b24 100644 --- a/devicehandlers/DeviceHandlerBase.cpp +++ b/devicehandlers/DeviceHandlerBase.cpp @@ -16,11 +16,10 @@ object_id_t DeviceHandlerBase::powerSwitcherId = 0; object_id_t DeviceHandlerBase::rawDataReceiverId = 0; object_id_t DeviceHandlerBase::defaultFDIRParentId = 0; -DeviceHandlerBase::DeviceHandlerBase(uint32_t ioBoardAddress, - object_id_t setObjectId, uint32_t maxDeviceReplyLen, - uint8_t setDeviceSwitch, object_id_t deviceCommunication, - uint32_t thermalStatePoolId, uint32_t thermalRequestPoolId, - FailureIsolationBase* fdirInstance, uint32_t cmdQueueSize) : +DeviceHandlerBase::DeviceHandlerBase(object_id_t setObjectId, + uint32_t maxDeviceReplyLen, uint8_t setDeviceSwitch, + object_id_t deviceCommunication, uint32_t ioBoardAddress, uint32_t thermalStatePoolId, + uint32_t thermalRequestPoolId, FailureIsolationBase* fdirInstance, uint32_t cmdQueueSize) : SystemObject(setObjectId),ioBoardAddress(ioBoardAddress), rawPacket(0), rawPacketLen(0), mode(MODE_OFF), submode(SUBMODE_NONE), pstStep(0), maxDeviceReplyLen(maxDeviceReplyLen), wiretappingMode(OFF), defaultRawReceiver(0), storedRawData(StorageManagerIF::INVALID_ADDRESS), diff --git a/devicehandlers/DeviceHandlerBase.h b/devicehandlers/DeviceHandlerBase.h index 45a87a8aa..2278e1f5d 100644 --- a/devicehandlers/DeviceHandlerBase.h +++ b/devicehandlers/DeviceHandlerBase.h @@ -71,10 +71,10 @@ public: * @param maxDeviceReplyLen the length the RMAP getRead call will be sent with * @param setDeviceSwitch the switch the device is connected to, for devices using two switches, overwrite getSwitches() */ - DeviceHandlerBase(uint32_t ioBoardAddress, object_id_t setObjectId, + DeviceHandlerBase(object_id_t setObjectId, uint32_t maxDeviceReplyLen, uint8_t setDeviceSwitch, - object_id_t deviceCommunication, uint32_t thermalStatePoolId = - PoolVariableIF::NO_PARAMETER, + object_id_t deviceCommunication,uint32_t ioBoardAddress = 0, + uint32_t thermalStatePoolId = PoolVariableIF::NO_PARAMETER, uint32_t thermalRequestPoolId = PoolVariableIF::NO_PARAMETER, FailureIsolationBase* fdirInstance = NULL, uint32_t cmdQueueSize = 20); @@ -111,6 +111,21 @@ public: */ virtual ReturnValue_t performOperation(uint8_t counter); + /** + * Prerequisites to call initialize function without custom implementation: + * 1. The three static framework IDs are set to respective objects in the Factory function + * - First ID: Power Switcher ID. Example: PCDU Handler Object + * - Second ID: Raw Data Receiver. Example: PUS Service 2 Object + * - Third ID: Default FDIR parent ID. Example: ? + * 2. Communication Interface Object for respective device. + * Example: UART Communication Interface which calls respective UART drivers + * 3. Health table class has been instantiated in Factory + * 4. deviceThermalRequestPoolId and deviceThermalStatePoolId are set to the respective data pool entries. + * This is only required if thermal checking is needed. Otherwise, set both variables to + * PoolVariableIF::NO_PARAMETER + * + * @return + */ virtual ReturnValue_t initialize(); /** -- 2.34.1 From 07950b0c2bb9c3822729a225302cb685cb62ea7a Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Wed, 23 Oct 2019 00:31:45 +0200 Subject: [PATCH 07/26] documentation for object manager IF get function --- fdir/FailureIsolationBase.cpp | 7 ++++--- objectmanager/ObjectManagerIF.h | 7 +++++++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/fdir/FailureIsolationBase.cpp b/fdir/FailureIsolationBase.cpp index 4b7caac53..c65640c27 100644 --- a/fdir/FailureIsolationBase.cpp +++ b/fdir/FailureIsolationBase.cpp @@ -5,9 +5,10 @@ #include #include -FailureIsolationBase::FailureIsolationBase(object_id_t owner, object_id_t parent, uint8_t messageDepth, uint8_t parameterDomainBase) : - eventQueue(NULL), ownerId( - owner), owner(NULL), faultTreeParent(parent), parameterDomainBase(parameterDomainBase) { +FailureIsolationBase::FailureIsolationBase(object_id_t owner, + object_id_t parent, uint8_t messageDepth, uint8_t parameterDomainBase) : + eventQueue(NULL), ownerId(owner), owner(NULL), + faultTreeParent(parent), parameterDomainBase(parameterDomainBase) { eventQueue = QueueFactory::instance()->createMessageQueue(messageDepth, EventMessage::EVENT_MESSAGE_SIZE); } diff --git a/objectmanager/ObjectManagerIF.h b/objectmanager/ObjectManagerIF.h index aca24a24a..9f58f600c 100644 --- a/objectmanager/ObjectManagerIF.h +++ b/objectmanager/ObjectManagerIF.h @@ -78,6 +78,13 @@ public: virtual void printList() = 0; }; +/** + * Used to retrieve Target Interface Pointers of objects. + * The object has to implement the SystemObject or SystemObjectIF at the very least, + * otherwise NULL will be returned. + * @param id + * @return NULL or pointer to target interface specified by template object + */ template T* ObjectManagerIF::get( object_id_t id ) { SystemObjectIF* temp = this->getSystemObject(id); -- 2.34.1 From 1631e739b8c0b3b7ab0af314309da898df7e2eae Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Wed, 23 Oct 2019 12:03:32 +0200 Subject: [PATCH 08/26] at91sam9g20 uses custom stdio.c, unsigned long cast in sprintf does not seem to work, casting (unsigned int) does, timestamp now visible in debug output --- serviceinterface/ServiceInterfaceBuffer.cpp | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/serviceinterface/ServiceInterfaceBuffer.cpp b/serviceinterface/ServiceInterfaceBuffer.cpp index 58065994a..d5ce60568 100644 --- a/serviceinterface/ServiceInterfaceBuffer.cpp +++ b/serviceinterface/ServiceInterfaceBuffer.cpp @@ -5,6 +5,8 @@ // to be implemented by bsp extern "C" void printChar(const char*); + + int ServiceInterfaceBuffer::overflow(int c) { // Handle output putChars(pbase(), pptr()); @@ -19,16 +21,18 @@ int ServiceInterfaceBuffer::overflow(int c) { return 0; } +// custom stdio.c library for at91sam9g20 chip which does not support unsigned long +// So I cast (unsigned int) on loggerTimes int ServiceInterfaceBuffer::sync(void) { if (this->isActive) { Clock::TimeOfDay_t loggerTime; Clock::getDateAndTime(&loggerTime); char preamble[96] = { 0 }; - sprintf(preamble, "%s: | %lu:%02lu:%02lu.%03lu | ", - this->log_message.c_str(), (unsigned long) loggerTime.hour, - (unsigned long) loggerTime.minute, - (unsigned long) loggerTime.second, - (unsigned long) loggerTime.usecond /1000); + sprintf(preamble, "%s: | %u:%02u:%02u.%03u | ", + this->log_message.c_str(), (unsigned int) loggerTime.hour, + (unsigned int) loggerTime.minute, + (unsigned int) loggerTime.second, + (unsigned int) loggerTime.usecond /1000); // Write log_message and time this->putChars(preamble, preamble + sizeof(preamble)); // Handle output -- 2.34.1 From 8f1517d276aac56dc260b8ea4609204ab8e1036a Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Fri, 25 Oct 2019 21:12:11 +0200 Subject: [PATCH 09/26] additional comments on endianness (I hope this is correct) --- devicehandlers/DeviceHandlerBase.cpp | 2 -- serialize/SerializeAdapter.h | 7 +++++++ serialize/SerializeIF.h | 7 +++++++ 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/devicehandlers/DeviceHandlerBase.cpp b/devicehandlers/DeviceHandlerBase.cpp index d0f9d8b24..4eb9f5049 100644 --- a/devicehandlers/DeviceHandlerBase.cpp +++ b/devicehandlers/DeviceHandlerBase.cpp @@ -53,7 +53,6 @@ DeviceHandlerBase::~DeviceHandlerBase() { ReturnValue_t DeviceHandlerBase::performOperation(uint8_t counter) { this->pstStep = counter; - if (counter == 0) { cookieInfo.state = COOKIE_UNUSED; readCommandQueue(); @@ -670,7 +669,6 @@ void DeviceHandlerBase::replyRawData(const uint8_t *data, size_t len, } CommandMessage message; - DeviceHandlerMessage::setDeviceHandlerRawReplyMessage(&message, getObjectId(), address, isCommand); diff --git a/serialize/SerializeAdapter.h b/serialize/SerializeAdapter.h index 67c37493a..6e2f3e5fb 100644 --- a/serialize/SerializeAdapter.h +++ b/serialize/SerializeAdapter.h @@ -20,6 +20,13 @@ * * The AutoSerializeAdapter functions can also be used as an alternative to memcpy * to retrieve data out of a buffer directly into a class variable with data type T while being able to specify endianness. + * + * In the SOURCE mission , the target architecture is little endian, + * so any buffers must be deSerialized with bool bigEndian = false if + * the parameters are used in the FSFW. + * When serializing for downlink, the packets are generally serialized into big endian for the network when using a TC/UDP client + * like seen in TmPacketStored.cpp for example. + * * \ingroup serialize */ template diff --git a/serialize/SerializeIF.h b/serialize/SerializeIF.h index 50555d379..14f6995e5 100644 --- a/serialize/SerializeIF.h +++ b/serialize/SerializeIF.h @@ -10,6 +10,13 @@ /** * An interface for alle classes which require translation of objects data into data streams and vice-versa. + * + * In the SOURCE mission , the target architecture is little endian, + * so any buffers must be deSerialized with bool bigEndian = false if + * the parameters are used in the FSFW. + * When serializing for downlink, the packets are generally serialized into big endian for the network when using a TC/UDP client + * like seen in TmPacketStored.cpp for example. + * * \ingroup serialize */ class SerializeIF { -- 2.34.1 From 64f84d9d9ffbf2d4b357ac72ad24956b8540db07 Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Sun, 27 Oct 2019 03:21:38 +0100 Subject: [PATCH 10/26] doc for dhb, serializeIF and SerializeAdapter --- devicehandlers/DeviceCommunicationIF.h | 2 +- devicehandlers/DeviceHandlerBase.cpp | 11 ++++++---- devicehandlers/DeviceHandlerBase.h | 11 ++++++---- serialize/SerializeAdapter.h | 28 ++++++++++++++++++++++---- serialize/SerializeIF.h | 14 +++++++++---- tmtcservices/PusServiceBase.h | 4 ++-- 6 files changed, 51 insertions(+), 19 deletions(-) diff --git a/devicehandlers/DeviceCommunicationIF.h b/devicehandlers/DeviceCommunicationIF.h index e0aca5731..88f0d1240 100644 --- a/devicehandlers/DeviceCommunicationIF.h +++ b/devicehandlers/DeviceCommunicationIF.h @@ -40,7 +40,7 @@ public: virtual void close(Cookie *cookie) = 0; //SHOULDDO can data be const? - virtual ReturnValue_t sendMessage(Cookie *cookie, uint8_t *data, + virtual ReturnValue_t sendMessage(Cookie *cookie,const uint8_t *data, uint32_t len) = 0; virtual ReturnValue_t getSendSuccess(Cookie *cookie) = 0; diff --git a/devicehandlers/DeviceHandlerBase.cpp b/devicehandlers/DeviceHandlerBase.cpp index 4eb9f5049..2f16f8462 100644 --- a/devicehandlers/DeviceHandlerBase.cpp +++ b/devicehandlers/DeviceHandlerBase.cpp @@ -11,6 +11,7 @@ #include #include #include +#include object_id_t DeviceHandlerBase::powerSwitcherId = 0; object_id_t DeviceHandlerBase::rawDataReceiverId = 0; @@ -452,7 +453,7 @@ void DeviceHandlerBase::doGetWrite() { if (wiretappingMode == RAW) { replyRawData(rawPacket, rawPacketLen, requestedRawTraffic, true); } - //We need to distinguish here, because a raw command never expects a reply. (Could be done in eRIRM, but then child implementations need to be careful. + // We need to distinguish here, because a raw command never expects a reply. (Could be done in eRIRM, but then child implementations need to be careful. result = enableReplyInReplyMap(cookieInfo.pendingCommand); } else { //always generate a failure event, so that FDIR knows what's up @@ -473,9 +474,9 @@ void DeviceHandlerBase::doSendRead() { cookieInfo.state = COOKIE_READ_SENT; } else { triggerEvent(DEVICE_REQUESTING_REPLY_FAILED, result); - //We can't inform anyone, because we don't know which command was sent last. - //So, we need to wait for a timeout. - //but I think we can allow to ignore one missedReply. + // We can't inform anyone, because we don't know which command was sent last. + // So, we need to wait for a timeout. + // but I think we can allow to ignore one missedReply. ignoreMissedRepliesCount++; cookieInfo.state = COOKIE_UNUSED; } @@ -1266,3 +1267,5 @@ void DeviceHandlerBase::changeHK(Mode_t mode, Submode_t submode, bool enable) { void DeviceHandlerBase::setTaskIF(PeriodicTaskIF* task_){ executingTask = task_; } + + diff --git a/devicehandlers/DeviceHandlerBase.h b/devicehandlers/DeviceHandlerBase.h index 2278e1f5d..6abfb675c 100644 --- a/devicehandlers/DeviceHandlerBase.h +++ b/devicehandlers/DeviceHandlerBase.h @@ -167,7 +167,7 @@ protected: static const uint8_t INTERFACE_ID = CLASS_ID::DEVICE_HANDLER_BASE; static const ReturnValue_t INVALID_CHANNEL = MAKE_RETURN_CODE(4); - static const ReturnValue_t APERIODIC_REPLY = MAKE_RETURN_CODE(5); + static const ReturnValue_t APERIODIC_REPLY = MAKE_RETURN_CODE(5); //!< This is used to specify for replies from a device which are not replies to requests static const ReturnValue_t IGNORE_REPLY_DATA = MAKE_RETURN_CODE(6); // static const ReturnValue_t ONE_SWITCH = MAKE_RETURN_CODE(8); // static const ReturnValue_t TWO_SWITCHES = MAKE_RETURN_CODE(9); @@ -626,9 +626,9 @@ protected: * @param[out] foundLen length of the packet found * @return * - @c RETURN_OK a valid packet was found at @c start, @c foundLen is valid - * - @c NO_VALID_REPLY no reply could be found starting at @c start, implies @c foundLen is not valid, base class will call scanForReply() again with ++start - * - @c INVALID_REPLY a packet was found but it is invalid, eg checksum error, implies @c foundLen is valid, can be used to skip some bytes - * - @c TOO_SHORT @c len is too short for any valid packet + * - @c RETURN_FAILED no reply could be found starting at @c start, implies @c foundLen is not valid, base class will call scanForReply() again with ++start + * - @c DeviceHandlerIF::INVALID_DATA a packet was found but it is invalid, eg checksum error, implies @c foundLen is valid, can be used to skip some bytes + * - @c DeviceHandlerIF::LENGTH_MISSMATCH @c len is invalid * - @c APERIODIC_REPLY if a valid reply is received that has not been requested by a command, but should be handled anyway (@see also fillCommandAndCookieMap() ) */ virtual ReturnValue_t scanForReply(const uint8_t *start, uint32_t len, @@ -954,6 +954,7 @@ private: * * This is called at the beginning of each cycle. It checks whether a reply has timed out (that means a reply was expected * but not received). + * In case the reply is periodic, the counter is simply set back to a specified value. */ void decrementDeviceReplyMap(void); @@ -1053,6 +1054,8 @@ private: ReturnValue_t switchCookieChannel(object_id_t newChannelId); ReturnValue_t handleDeviceHandlerMessage(CommandMessage *message); + + }; #endif /* DEVICEHANDLERBASE_H_ */ diff --git a/serialize/SerializeAdapter.h b/serialize/SerializeAdapter.h index 6e2f3e5fb..04216c897 100644 --- a/serialize/SerializeAdapter.h +++ b/serialize/SerializeAdapter.h @@ -20,11 +20,31 @@ * * The AutoSerializeAdapter functions can also be used as an alternative to memcpy * to retrieve data out of a buffer directly into a class variable with data type T while being able to specify endianness. + * The boolean bigEndian specifies the endiness of the data to serialize or deSerialize. * - * In the SOURCE mission , the target architecture is little endian, - * so any buffers must be deSerialized with bool bigEndian = false if - * the parameters are used in the FSFW. - * When serializing for downlink, the packets are generally serialized into big endian for the network when using a TC/UDP client + * If the target architecture is little endian (ARM), any data types created might + * have the wrong endiness if they are to be used for the FSFW. + * there are three ways to retrieve data out of a buffer to be used in the FSFW to use regular aligned (big endian) data. + * This can also be applied to uint32_t and uint64_t: + * + * 1. Use the AutoSerializeAdapter::deSerialize function with bool bigEndian = true: + * + * uint16_t data; + * int32_t dataLen = sizeof(data); + * ReturnValue_t result = AutoSerializeAdapter::deSerialize(&data,&buffer,&dataLen,true); + * + * 2. Perform a bitshift operation: + * + * uint16_t data; + * data = buffer[targetByte1] >> 8 | buffer[targetByte2]; + * + * 3. Memcpy can be used when data is little-endian. Otherwise, endian-swapper has to be used. + * + * uint16_t data; + * memcpy(&data,buffer + positionOfTargetByte1,sizeof(data)); + * data = EndianSwapper::swap(data); + * + * When serializing for downlink, the packets are generally serialized assuming big endian data format * like seen in TmPacketStored.cpp for example. * * \ingroup serialize diff --git a/serialize/SerializeIF.h b/serialize/SerializeIF.h index 14f6995e5..d86349ab5 100644 --- a/serialize/SerializeIF.h +++ b/serialize/SerializeIF.h @@ -11,10 +11,16 @@ /** * An interface for alle classes which require translation of objects data into data streams and vice-versa. * - * In the SOURCE mission , the target architecture is little endian, - * so any buffers must be deSerialized with bool bigEndian = false if - * the parameters are used in the FSFW. - * When serializing for downlink, the packets are generally serialized into big endian for the network when using a TC/UDP client + * If the target architecture is little endian (ARM), any data types created might + * have the wrong endiness if they are to be used for the FSFW. + * there are three ways to retrieve data out of a buffer to be used in the FSFW to use regular aligned (big endian) data. + * This can also be applied to uint32_t and uint64_t: + * + * 1. Use the @c AutoSerializeAdapter::deSerialize function with @c bigEndian = true + * 2. Perform a bitshift operation + * 3. @c memcpy can be used when data is little-endian. Otherwise, @c EndianSwapper has to be used. + * + * When serializing for downlink, the packets are generally serialized assuming big endian data format * like seen in TmPacketStored.cpp for example. * * \ingroup serialize diff --git a/tmtcservices/PusServiceBase.h b/tmtcservices/PusServiceBase.h index 782d375ff..4fe13ca91 100644 --- a/tmtcservices/PusServiceBase.h +++ b/tmtcservices/PusServiceBase.h @@ -68,8 +68,8 @@ public: * It checks for new requests, and, if found, calls handleRequest, sends completion verification messages and deletes * the TC requests afterwards. * performService is always executed afterwards. - * @return - \c RETURN_OK if the periodic performService was successful. - * - \c RETURN_FAILED else. + * @return \c RETURN_OK if the periodic performService was successful. + * \c RETURN_FAILED else. */ ReturnValue_t performOperation(uint8_t opCode); virtual uint16_t getIdentifier(); -- 2.34.1 From d79f072851264ec3f9e369f2b2ccbfa7fddd3145 Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Sun, 27 Oct 2019 13:38:08 +0100 Subject: [PATCH 11/26] Additional documentation for DHB and CSB --- devicehandlers/DeviceHandlerBase.h | 19 ++++++---- tmtcservices/CommandingServiceBase.h | 54 +++++++++++++++++++++++++--- 2 files changed, 62 insertions(+), 11 deletions(-) diff --git a/devicehandlers/DeviceHandlerBase.h b/devicehandlers/DeviceHandlerBase.h index 6abfb675c..be488d354 100644 --- a/devicehandlers/DeviceHandlerBase.h +++ b/devicehandlers/DeviceHandlerBase.h @@ -33,24 +33,29 @@ class StorageManagerIF; * Contains all devices and the DeviceHandlerBase class. */ -// Robin: We're not really using RMAP, right? Maybe we should adapt class description for that? + /** * \brief This is the abstract base class for device handlers. * * Documentation: Dissertation Baetz p.138,139, p.141-149 - * SpaceWire Remote Memory Access Protocol (RMAP) * - * It features handling of @link DeviceHandlerIF::Mode_t Modes @endlink, the RMAP communication and the - * communication with commanding objects. + * It features handling of @link DeviceHandlerIF::Mode_t Modes @endlink, communication with + * physical devices, using the @link DeviceCommunicationIF, and communication with commanding objects. + * + * NOTE: RMAP is a legacy standard which is used for FLP. + * RMAP communication is not mandatory for projects implementing the FSFW. + * However, the communication principles are similar to RMAP as there are two write and two send calls involved. + * * It inherits SystemObject and thus can be created by the ObjectManagerIF. * * This class uses the opcode of ExecutableObjectIF to perform a step-wise execution. - * For each step an RMAP action is selected and executed. If data has been received (eg in case of an RMAP Read), the data will be interpreted. - * The action for each step can be defined by the child class but as most device handlers share a 4-call (Read-getRead-write-getWrite) structure, - * a default implementation is provided. + * For each step an RMAP action is selected and executed. If data has been received (GET_READ), the data will be interpreted. + * The action for each step can be defined by the child class but as most device handlers share a 4-call + * (sendRead-getRead-sendWrite-getWrite) structure, a default implementation is provided. * * Device handler instances should extend this class and implement the abstract functions. * Components and drivers can send so called cookies which are used for communication + * and contain information about the communcation (e.g. slave address for I2C or RMAP structs). * * \ingroup devices */ diff --git a/tmtcservices/CommandingServiceBase.h b/tmtcservices/CommandingServiceBase.h index ee59ffe44..f662072fd 100644 --- a/tmtcservices/CommandingServiceBase.h +++ b/tmtcservices/CommandingServiceBase.h @@ -180,20 +180,65 @@ protected: */ void sendTmPacket(uint8_t subservice, SerializeIF* content, SerializeIF* header = NULL); + + /** + * Check the target subservice + * @param subservice + * @return + */ virtual ReturnValue_t isValidSubservice(uint8_t subservice) = 0; + /** + * Once a TC Request is valid, the existence of the destination and its target interface is checked and retrieved. + * The target message queue ID can then be acquired by using the target interface. + * @param subservice + * @param tcData Application Data of TC Packet + * @param tcDataLen + * @param id MessageQueue ID is stored here + * @param objectId + * @return - @c RETURN_OK on success + * - @c RETURN_FAILED + * - @c CSB or implementation specific return codes + */ + virtual ReturnValue_t getMessageQueueAndObject(uint8_t subservice, + const uint8_t *tcData, uint32_t tcDataLen, MessageQueueId_t *id, + object_id_t *objectId) = 0; + + /** + * After the Message Queue and Object ID are determined, + * the command is prepared by using an implementation specific CommandMessage type which is sent to + * the target device. It contains all necessary information for the device to + * execute telecommands. + * @param message + * @param subservice + * @param tcData + * @param tcDataLen + * @param state + * @param objectId + * @return + */ virtual ReturnValue_t prepareCommand(CommandMessage *message, uint8_t subservice, const uint8_t *tcData, uint32_t tcDataLen, uint32_t *state, object_id_t objectId) = 0; + /** + * This function is responsible for the communication between the Command Service Base + * and the respective PUS Commanding Service once the execution has started. + * The PUS Commanding Service receives replies from the target device and forwards them by calling this function. + * There are different translations of these replies to specify how the Command Service proceeds. + * @param reply Command Message which determines how CommandServiceBase proceeds + * @param previousCommand + * @param state + * @param optionalNextCommand + * @param objectId + * @param isStep Flag value to mark steps of command execution + * @return + */ virtual ReturnValue_t handleReply(const CommandMessage *reply, Command_t previousCommand, uint32_t *state, CommandMessage *optionalNextCommand, object_id_t objectId, bool *isStep) = 0; - virtual ReturnValue_t getMessageQueueAndObject(uint8_t subservice, - const uint8_t *tcData, uint32_t tcDataLen, MessageQueueId_t *id, - object_id_t *objectId) = 0; virtual void handleUnrequestedReply(CommandMessage *reply); @@ -209,7 +254,8 @@ private: * It handles replies generated by the devices and relayed by the specific service implementation. * This means that it determines further course of action depending on the return values specified * in the service implementation. - * This includes the generation of TC verification messages: + * This includes the generation of TC verification messages. Note that + * the static framework object ID @c VerificationReporter::messageReceiver needs to be set. * - TM[1,5] Step Successs * - TM[1,6] Step Failure * - TM[1,7] Completion Success -- 2.34.1 From b51536c772c9d058b7c7a4449f8cf8ca107773ec Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Mon, 28 Oct 2019 12:48:41 +0100 Subject: [PATCH 12/26] CSB doc correction --- fdir/FailureIsolationBase.h | 4 ++++ tmtcservices/CommandingServiceBase.h | 8 +++++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/fdir/FailureIsolationBase.h b/fdir/FailureIsolationBase.h index cd582e399..894f63562 100644 --- a/fdir/FailureIsolationBase.h +++ b/fdir/FailureIsolationBase.h @@ -21,6 +21,10 @@ public: uint8_t messageDepth = 10, uint8_t parameterDomainBase = 0xF0); virtual ~FailureIsolationBase(); virtual ReturnValue_t initialize(); + + /** + * This is called by the DHB in performOperation() + */ void checkForFailures(); MessageQueueId_t getEventReceptionQueue(); virtual void triggerEvent(Event event, uint32_t parameter1 = 0, diff --git a/tmtcservices/CommandingServiceBase.h b/tmtcservices/CommandingServiceBase.h index f662072fd..8ce25f007 100644 --- a/tmtcservices/CommandingServiceBase.h +++ b/tmtcservices/CommandingServiceBase.h @@ -64,7 +64,7 @@ public: virtual ~CommandingServiceBase(); /*** - * This is the periodic called function + * This is the periodically called function. * Handle request queue for external commands. * Handle command Queue for internal commands. * @param opCode is unused here at the moment @@ -226,13 +226,15 @@ protected: * and the respective PUS Commanding Service once the execution has started. * The PUS Commanding Service receives replies from the target device and forwards them by calling this function. * There are different translations of these replies to specify how the Command Service proceeds. - * @param reply Command Message which determines how CommandServiceBase proceeds + * @param reply Command Message which contains information about the command * @param previousCommand * @param state * @param optionalNextCommand * @param objectId * @param isStep Flag value to mark steps of command execution - * @return + * @return - @c RETURN_OK, @c EXECUTION_COMPLETE or @c NO_STEP_MESSAGE to generate TC verification success + * - @c INVALID_REPLY can handle unrequested replies + * - Anything else triggers a TC verification failure */ virtual ReturnValue_t handleReply(const CommandMessage *reply, Command_t previousCommand, uint32_t *state, -- 2.34.1 From 1ee445ce245b0383a3d770b44f971693ff37542f Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Tue, 29 Oct 2019 11:17:07 +0100 Subject: [PATCH 13/26] fifo typo --- container/FIFO.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/container/FIFO.h b/container/FIFO.h index 670a50d74..134da9b80 100644 --- a/container/FIFO.h +++ b/container/FIFO.h @@ -21,7 +21,7 @@ public: readIndex(0), writeIndex(0), currentSize(0) { } - bool emtpy() { + bool empty() { return (currentSize == 0); } @@ -45,7 +45,7 @@ public: } ReturnValue_t retrieve(T *value) { - if (emtpy()) { + if (empty()) { return EMPTY; } else { *value = data[readIndex]; -- 2.34.1 From e8a16ac59cf87d27d1e79a6571a6ee11f0edc3c2 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 29 Oct 2019 18:21:01 +0100 Subject: [PATCH 14/26] dummy com if sendMessage data const --- devicehandlers/DeviceCommunicationIF.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/devicehandlers/DeviceCommunicationIF.h b/devicehandlers/DeviceCommunicationIF.h index e0aca5731..88f0d1240 100644 --- a/devicehandlers/DeviceCommunicationIF.h +++ b/devicehandlers/DeviceCommunicationIF.h @@ -40,7 +40,7 @@ public: virtual void close(Cookie *cookie) = 0; //SHOULDDO can data be const? - virtual ReturnValue_t sendMessage(Cookie *cookie, uint8_t *data, + virtual ReturnValue_t sendMessage(Cookie *cookie,const uint8_t *data, uint32_t len) = 0; virtual ReturnValue_t getSendSuccess(Cookie *cookie) = 0; -- 2.34.1 From 3887cb8ca14f4a12a2fd446e1779b66c76096962 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 29 Oct 2019 18:22:34 +0100 Subject: [PATCH 15/26] removed wrong include in dhb --- devicehandlers/DeviceHandlerBase.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/devicehandlers/DeviceHandlerBase.cpp b/devicehandlers/DeviceHandlerBase.cpp index 2f16f8462..1bb411b7d 100644 --- a/devicehandlers/DeviceHandlerBase.cpp +++ b/devicehandlers/DeviceHandlerBase.cpp @@ -11,7 +11,6 @@ #include #include #include -#include object_id_t DeviceHandlerBase::powerSwitcherId = 0; object_id_t DeviceHandlerBase::rawDataReceiverId = 0; -- 2.34.1 From 16af33a7bb52e3d9363e1e6f61e16a67783f74df Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Tue, 29 Oct 2019 19:31:18 +0100 Subject: [PATCH 16/26] doc for fifo, device com if.. --- container/FIFO.h | 4 +-- container/SimpleRingBuffer.h | 28 +++++++++++++++++++++ devicehandlers/DeviceCommunicationIF.h | 35 +++++++++++++++++++++++++- serialize/SerializeAdapter.h | 2 ++ 4 files changed, 66 insertions(+), 3 deletions(-) diff --git a/container/FIFO.h b/container/FIFO.h index 670a50d74..134da9b80 100644 --- a/container/FIFO.h +++ b/container/FIFO.h @@ -21,7 +21,7 @@ public: readIndex(0), writeIndex(0), currentSize(0) { } - bool emtpy() { + bool empty() { return (currentSize == 0); } @@ -45,7 +45,7 @@ public: } ReturnValue_t retrieve(T *value) { - if (emtpy()) { + if (empty()) { return EMPTY; } else { *value = data[readIndex]; diff --git a/container/SimpleRingBuffer.h b/container/SimpleRingBuffer.h index 6d7d67e1d..45cb09277 100644 --- a/container/SimpleRingBuffer.h +++ b/container/SimpleRingBuffer.h @@ -4,12 +4,40 @@ #include #include +/** + * Circular buffer implementation, useful for buffering into data streams. + * Note that the deleteData() has to be called to increment the read pointer + */ class SimpleRingBuffer: public RingBufferBase<> { public: SimpleRingBuffer(uint32_t size, bool overwriteOld); virtual ~SimpleRingBuffer(); + + /** + * Write to circular buffer and increment write pointer by amount + * @param data + * @param amount + * @return + */ ReturnValue_t writeData(const uint8_t* data, uint32_t amount); + + /** + * Read from circular buffer at read pointer + * @param data + * @param amount + * @param readRemaining + * @param trueAmount + * @return + */ ReturnValue_t readData(uint8_t* data, uint32_t amount, bool readRemaining = false, uint32_t* trueAmount = NULL); + + /** + * Delete data starting by incrementing read pointer + * @param amount + * @param deleteRemaining + * @param trueAmount + * @return + */ ReturnValue_t deleteData(uint32_t amount, bool deleteRemaining = false, uint32_t* trueAmount = NULL); private: // static const uint8_t TEMP_READ_PTR = 1; diff --git a/devicehandlers/DeviceCommunicationIF.h b/devicehandlers/DeviceCommunicationIF.h index 88f0d1240..59420861e 100644 --- a/devicehandlers/DeviceCommunicationIF.h +++ b/devicehandlers/DeviceCommunicationIF.h @@ -4,6 +4,22 @@ #include #include +/** + * Documentation: Dissertation Baetz p.138 + * + * This is an interface to decouple device communication from + * the device handler to allow reuse of these components. + * It works with the assumption that received data + * is polled by a component. There are four generic steps of device communication: + * + * 1. Send data to a device + * 2. Get acknowledgement for sending + * 3. Request reading data from a device + * 4. Read received data + * + * To identify different connection over a single interface can return so-called cookies to components. + * + */ class DeviceCommunicationIF: public HasReturnvaluesIF { public: static const uint8_t INTERFACE_ID = CLASS_ID::DEVICE_COMMUNICATION_IF; @@ -39,7 +55,15 @@ public: virtual void close(Cookie *cookie) = 0; - //SHOULDDO can data be const? + /** + * Called by DHB in the SEND_WRITE doSendWrite(). + * This function is used to send data to the physical device + * by implementing and calling related drivers or wrapper functions. + * @param cookie + * @param data + * @param len + * @return + */ virtual ReturnValue_t sendMessage(Cookie *cookie,const uint8_t *data, uint32_t len) = 0; @@ -47,6 +71,15 @@ public: virtual ReturnValue_t requestReceiveMessage(Cookie *cookie) = 0; + /** + * Called by DHB in the GET_WIRTE doGetRead(). + * This function is used to receive data from the physical device + * by implementing and calling related drivers or wrapper functions. + * @param cookie + * @param data + * @param len + * @return + */ virtual ReturnValue_t readReceivedMessage(Cookie *cookie, uint8_t **buffer, uint32_t *size) = 0; diff --git a/serialize/SerializeAdapter.h b/serialize/SerializeAdapter.h index 04216c897..a0aab9e98 100644 --- a/serialize/SerializeAdapter.h +++ b/serialize/SerializeAdapter.h @@ -28,6 +28,8 @@ * This can also be applied to uint32_t and uint64_t: * * 1. Use the AutoSerializeAdapter::deSerialize function with bool bigEndian = true: + * The pointer *buffer will be incremented automatically by the typeSize of data, + * so this function can be called on &buffer without adjusting pointer position * * uint16_t data; * int32_t dataLen = sizeof(data); -- 2.34.1 From 46986f69e4a17923717464c120f4d227df561618 Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Sat, 2 Nov 2019 23:30:12 +0100 Subject: [PATCH 17/26] serialize tools more documentation --- serialize/SerialBufferAdapter.cpp | 8 ++++---- serialize/SerialBufferAdapter.h | 8 ++++++++ serialize/SerialFixedArrayListAdapter.h | 11 +++++++++++ serialize/SerialLinkedListAdapter.h | 10 +++++++++- serialize/SerializeIF.h | 6 +++--- 5 files changed, 35 insertions(+), 8 deletions(-) diff --git a/serialize/SerialBufferAdapter.cpp b/serialize/SerialBufferAdapter.cpp index 3ed083bf5..c5fcfb57e 100644 --- a/serialize/SerialBufferAdapter.cpp +++ b/serialize/SerialBufferAdapter.cpp @@ -5,15 +5,15 @@ template SerialBufferAdapter::SerialBufferAdapter(const uint8_t* buffer, - T bufferLength, bool serializeLenght) : - serializeLength(serializeLenght), constBuffer(buffer), buffer(NULL), bufferLength( + T bufferLength, bool serializeLength) : + serializeLength(serializeLength), constBuffer(buffer), buffer(NULL), bufferLength( bufferLength) { } template SerialBufferAdapter::SerialBufferAdapter(uint8_t* buffer, T bufferLength, - bool serializeLenght) : - serializeLength(serializeLenght), constBuffer(NULL), buffer(buffer), bufferLength( + bool serializeLength) : + serializeLength(serializeLength), constBuffer(NULL), buffer(buffer), bufferLength( bufferLength) { } diff --git a/serialize/SerialBufferAdapter.h b/serialize/SerialBufferAdapter.h index 7cd75d556..7d192bb45 100644 --- a/serialize/SerialBufferAdapter.h +++ b/serialize/SerialBufferAdapter.h @@ -5,6 +5,14 @@ #include /** + * This adapter provides an interface for SerializeIF to serialize or deserialize + * buffers with no length header but a known size. + * + * Additionally, the buffer length can be serialized too and will be put in front of the serialized buffer. + * + * Can be used with SerialLinkedListAdapter by declaring a SerializeElement with + * SerialElement> serialBufferElement + * * \ingroup serialize */ template diff --git a/serialize/SerialFixedArrayListAdapter.h b/serialize/SerialFixedArrayListAdapter.h index 16919b623..821e87104 100644 --- a/serialize/SerialFixedArrayListAdapter.h +++ b/serialize/SerialFixedArrayListAdapter.h @@ -5,6 +5,17 @@ #include /** + * This adapter provides an interface for SerializeIF to serialize and deserialize + * buffers with a header containing the buffer length. + * + * Can be used by SerialLinkedListAdapter. + * + * Buffers with a size header inside that class can be declared with + * SerialFixedArrayListAdapter. + * typeOfMaxData specifies the data type of the buffer header containing the buffer size that follows + * and MAX_BUFFER_LENGTH specifies the maximum allowed value for the buffer size. + * The sequence of objects is defined in the constructor by using the setStart and setNext functions. + * * \ingroup serialize */ template diff --git a/serialize/SerialLinkedListAdapter.h b/serialize/SerialLinkedListAdapter.h index 44d9e15bc..08d385eec 100644 --- a/serialize/SerialLinkedListAdapter.h +++ b/serialize/SerialLinkedListAdapter.h @@ -17,12 +17,20 @@ * An alternative to the AutoSerializeAdapter functions to implement the conversion * of object data to data streams or vice-versa, using linked lists. * - * All object members with a datatype are declared as SerializeElement inside the class. + * All object members with a datatype are declared as SerializeElement inside the class + * implementing this adapter. * * Buffers with a size header inside that class can be declared with * SerialFixedArrayListAdapter. * typeOfMaxData specifies the data type of the buffer header containing the buffer size that follows * and MAX_BUFFER_LENGTH specifies the maximum allowed value for the buffer size. + * Please note that a direct link from a linked element to a SerialFixedArrayListAdapter element is not possible and a + * helper needs to be used by calling .setNext(&linkHelper) + * and initialising the link helper as linkHelper(&SerialFixedArrayListAdapterElement). + * + * For buffers with no size header, declare + * SerializeElement> and initialise the buffer adapter in the constructor. + * * The sequence of objects is defined in the constructor by using the setStart and setNext functions. * * The serialization and deserialization process is done by instantiating the class and diff --git a/serialize/SerializeIF.h b/serialize/SerializeIF.h index d86349ab5..cada1e72a 100644 --- a/serialize/SerializeIF.h +++ b/serialize/SerializeIF.h @@ -11,14 +11,14 @@ /** * An interface for alle classes which require translation of objects data into data streams and vice-versa. * - * If the target architecture is little endian (ARM), any data types created might + * If the target architecture is little endian (e.g. ARM), any data types created might * have the wrong endiness if they are to be used for the FSFW. - * there are three ways to retrieve data out of a buffer to be used in the FSFW to use regular aligned (big endian) data. + * There are three ways to retrieve data out of a buffer to be used in the FSFW to use regular aligned (big endian) data. * This can also be applied to uint32_t and uint64_t: * * 1. Use the @c AutoSerializeAdapter::deSerialize function with @c bigEndian = true * 2. Perform a bitshift operation - * 3. @c memcpy can be used when data is little-endian. Otherwise, @c EndianSwapper has to be used. + * 3. @c memcpy can be used when data is in little-endian format. Otherwise, @c EndianSwapper has to be used in conjuction. * * When serializing for downlink, the packets are generally serialized assuming big endian data format * like seen in TmPacketStored.cpp for example. -- 2.34.1 From 8eb1a5b13e2fccf21176aed9a6a27287196fd236 Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Mon, 4 Nov 2019 00:47:46 +0100 Subject: [PATCH 18/26] proposal 1: expectedReplies parameter is set in insertInCommandAndReplyMap, default value stays one. overriding enableReplyInReplyMap is not necessary anymore.second proposal: the commander id is supplied in the interpretDeviceReply function, so we don't have to look for it in the DeviceCommandMap. was it removed at some point because it is listed in the documentation? --- action/ActionHelper.h | 2 +- devicehandlers/DeviceHandlerBase.cpp | 32 +++++++++++++++++--------- devicehandlers/DeviceHandlerBase.h | 16 ++++++++----- modes/ModeHelper.h | 13 ++++++++++- tmtcservices/CommandingServiceBase.cpp | 11 ++++----- 5 files changed, 49 insertions(+), 25 deletions(-) diff --git a/action/ActionHelper.h b/action/ActionHelper.h index 6ba6dd89b..a72e3654a 100644 --- a/action/ActionHelper.h +++ b/action/ActionHelper.h @@ -74,7 +74,7 @@ public: protected: static const uint8_t STEP_OFFSET = 1;//!< Increase of value of this per step HasActionsIF* owner;//!< Pointer to the owner - MessageQueueIF* queueToUse;//!< Queue to be used as response sender, has to be set with + MessageQueueIF* queueToUse;//!< Queue to be used as response sender, has to be set with @c setQueueToUse StorageManagerIF* ipcStore;//!< Pointer to an IPC Store, initialized during construction or initialize(MessageQueueIF* queueToUse_) or with setQueueToUse(MessageQueueIF *queue) /** *Internal function called by handleActionMessage(CommandMessage* command) diff --git a/devicehandlers/DeviceHandlerBase.cpp b/devicehandlers/DeviceHandlerBase.cpp index 1bb411b7d..c92cac332 100644 --- a/devicehandlers/DeviceHandlerBase.cpp +++ b/devicehandlers/DeviceHandlerBase.cpp @@ -255,9 +255,9 @@ ReturnValue_t DeviceHandlerBase::isModeCombinationValid(Mode_t mode, ReturnValue_t DeviceHandlerBase::insertInCommandAndReplyMap( DeviceCommandId_t deviceCommand, uint16_t maxDelayCycles, - uint8_t periodic, bool hasDifferentReplyId, DeviceCommandId_t replyId) { -//No need to check, as we may try to insert multiple times. - insertInCommandMap(deviceCommand); + uint8_t periodic, uint8_t expectedReplies, bool hasDifferentReplyId, DeviceCommandId_t replyId) { + //No need to check, as we may try to insert multiple times. + insertInCommandMap(deviceCommand,expectedReplies); if (hasDifferentReplyId) { return insertInReplyMap(replyId, maxDelayCycles, periodic); } else { @@ -283,9 +283,9 @@ ReturnValue_t DeviceHandlerBase::insertInReplyMap(DeviceCommandId_t replyId, } ReturnValue_t DeviceHandlerBase::insertInCommandMap( - DeviceCommandId_t deviceCommand) { + DeviceCommandId_t deviceCommand, uint8_t expectedReplies) { DeviceCommandInfo info; - info.expectedReplies = 0; + info.expectedReplies = expectedReplies; info.isExecuting = false; info.sendReplyTo = NO_COMMANDER; std::pair::iterator, bool> returnValue; @@ -712,6 +712,7 @@ void DeviceHandlerBase::handleReply(const uint8_t* receivedData, DeviceCommandId_t foundId, uint32_t foundLen) { ReturnValue_t result; DeviceReplyMap::iterator iter = deviceReplyMap.find(foundId); + MessageQueueId_t commander; if (iter == deviceReplyMap.end()) { replyRawReplyIfnotWiretapped(receivedData, foundLen); @@ -728,7 +729,17 @@ void DeviceHandlerBase::handleReply(const uint8_t* receivedData, } else { info->delayCycles = 0; } - result = interpretDeviceReply(foundId, receivedData); + + DeviceCommandMap::iterator commandIter = deviceCommandMap.find(foundId); + // could be a reply only packet + if(commandIter == deviceCommandMap.end()) { + commander = 0; + } + else { + commander = commandIter->second.sendReplyTo; + } + + result = interpretDeviceReply(foundId, receivedData,commander); if (result != RETURN_OK) { //Report failed interpretation to FDIR. replyRawReplyIfnotWiretapped(receivedData, foundLen); @@ -798,7 +809,7 @@ void DeviceHandlerBase::modeChanged(void) { } ReturnValue_t DeviceHandlerBase::enableReplyInReplyMap( - DeviceCommandMap::iterator command, uint8_t expectedReplies, + DeviceCommandMap::iterator command,/* uint8_t expectedReplies, */ bool useAlternativeId, DeviceCommandId_t alternativeReply) { DeviceReplyMap::iterator iter; if (useAlternativeId) { @@ -810,7 +821,7 @@ ReturnValue_t DeviceHandlerBase::enableReplyInReplyMap( DeviceReplyInfo *info = &(iter->second); info->delayCycles = info->maxDelayCycles; info->command = command; - command->second.expectedReplies = expectedReplies; + // command->second.expectedReplies = expectedReplies; return RETURN_OK; } else { return NO_REPLY_EXPECTED; @@ -1108,8 +1119,7 @@ void DeviceHandlerBase::handleDeviceTM(SerializeIF* data, // hiding of sender needed so the service will handle it as unexpected Data, no matter what state //(progress or completed) it is in - actionHelper.reportData(defaultRawReceiver, replyId, &wrapper, - true); + actionHelper.reportData(defaultRawReceiver, replyId, &wrapper); } } else { //unrequested/aperiodic replies @@ -1122,7 +1132,7 @@ void DeviceHandlerBase::handleDeviceTM(SerializeIF* data, true); } } -//Try to cast to DataSet and commit data. + //Try to cast to DataSet and commit data. if (!neverInDataPool) { DataSet* dataSet = dynamic_cast(data); if (dataSet != NULL) { diff --git a/devicehandlers/DeviceHandlerBase.h b/devicehandlers/DeviceHandlerBase.h index be488d354..89f965036 100644 --- a/devicehandlers/DeviceHandlerBase.h +++ b/devicehandlers/DeviceHandlerBase.h @@ -576,8 +576,9 @@ protected: * Default is aperiodic (0) * @return RETURN_OK when the command was successfully inserted, COMMAND_MAP_ERROR else. */ + // Proposal: Set expected replies for a command in insertInCommandAndReplyMap so we don't have to overwrite enableReplyInReplyMap ReturnValue_t insertInCommandAndReplyMap(DeviceCommandId_t deviceCommand, - uint16_t maxDelayCycles, uint8_t periodic = 0, + uint16_t maxDelayCycles, uint8_t periodic = 0, uint8_t expectedReplies = 1, bool hasDifferentReplyId = false, DeviceCommandId_t replyId = 0); /** * This is a helper method to insert replies in the reply map. @@ -594,7 +595,7 @@ protected: * @param deviceCommand The command to add * @return RETURN_OK if the command was successfully inserted, RETURN_FAILED else. */ - ReturnValue_t insertInCommandMap(DeviceCommandId_t deviceCommand); + ReturnValue_t insertInCommandMap(DeviceCommandId_t deviceCommand, uint8_t expectedReplies = 1); /** * This is a helper method to facilitate updating entries in the reply map. * @param deviceCommand Identifier of the reply to update. @@ -644,18 +645,19 @@ protected: * * This is called after scanForReply() found a valid packet, it can be assumed that the length and structure is valid. * This routine extracts the data from the packet into a DataSet and then calls handleDeviceTM(), which either sends - * a TM packet or stores the data in the DataPool depending on whether the it was an external command. + * a TM packet or stores the data in the DataPool depending on whether it was an external command. * No packet length is given, as it should be defined implicitly by the id. * * @param id the id found by scanForReply() * @param packet - * @param commander the one who initiated the command, is 0 if not external commanded + * @param commander the one who initiated the command, is 0 if not external commanded. + * UPDATE: This parameter does not exist anymore. Why? * @return * - @c RETURN_OK when the reply was interpreted. * - @c RETURN_FAILED when the reply could not be interpreted, eg. logical errors or range violations occurred */ virtual ReturnValue_t interpretDeviceReply(DeviceCommandId_t id, - const uint8_t *packet) = 0; + const uint8_t *packet, MessageQueueId_t commander = 0) = 0; /** * Construct a command reply containing a raw reply. @@ -723,13 +725,15 @@ protected: * - If the command was not found in the reply map, NO_REPLY_EXPECTED MUST be returned. * - A failure code may be returned if something went fundamentally wrong. * + * * @param deviceCommand * @return - RETURN_OK if a reply was activated. * - NO_REPLY_EXPECTED if there was no reply found. This is not an error case as many commands * do not expect a reply. */ + // Proposal: Set expected replies in insertInCommandAndReplyMap so we don't have to overwrite that function anymore. virtual ReturnValue_t enableReplyInReplyMap(DeviceCommandMap::iterator cmd, - uint8_t expectedReplies = 1, bool useAlternateId = false, + /* uint8_t expectedReplies = 0 */ bool useAlternateId = false, DeviceCommandId_t alternateReplyID = 0); /** diff --git a/modes/ModeHelper.h b/modes/ModeHelper.h index 87f6d4112..b23eb69e5 100644 --- a/modes/ModeHelper.h +++ b/modes/ModeHelper.h @@ -16,11 +16,17 @@ public: ModeHelper(HasModesIF *owner); virtual ~ModeHelper(); + /** + * This is used by DHB to handle all mode messages issued by a service + * @param message + * @return + */ ReturnValue_t handleModeCommand(CommandMessage *message); /** * - * @param parentQueue the Queue id of the parent object. Set to 0 if no parent present + * @param parentQueue the Queue id of the parent object (assembly or subsystem object). + * Set to 0 if no parent present */ void setParentQueue(MessageQueueId_t parentQueueId); @@ -28,6 +34,11 @@ public: ReturnValue_t initialize(void); //void is there to stop eclipse CODAN from falsely reporting an error + /** + * Used to notify + * @param mode + * @param submode + */ void modeChanged(Mode_t mode, Submode_t submode); void startTimer(uint32_t timeoutMs); diff --git a/tmtcservices/CommandingServiceBase.cpp b/tmtcservices/CommandingServiceBase.cpp index d70b90428..ec65492de 100644 --- a/tmtcservices/CommandingServiceBase.cpp +++ b/tmtcservices/CommandingServiceBase.cpp @@ -11,12 +11,11 @@ CommandingServiceBase::CommandingServiceBase(object_id_t setObjectId, uint16_t apid, uint8_t service, uint8_t numberOfParallelCommands, uint16_t commandTimeout_seconds, object_id_t setPacketSource, object_id_t setPacketDestination, size_t queueDepth) : - SystemObject(setObjectId), apid(apid), service(service), timeout_seconds( - commandTimeout_seconds), tmPacketCounter(0), IPCStore(NULL), TCStore( - NULL), commandQueue(NULL), requestQueue(NULL), commandMap( - numberOfParallelCommands), failureParameter1(0), failureParameter2( - 0), packetSource(setPacketSource), packetDestination( - setPacketDestination),executingTask(NULL) { + SystemObject(setObjectId), apid(apid), service(service), + timeout_seconds(commandTimeout_seconds), tmPacketCounter(0), IPCStore(NULL), + TCStore(NULL), commandQueue(NULL), requestQueue(NULL), commandMap(numberOfParallelCommands), + failureParameter1(0), failureParameter2(0), packetSource(setPacketSource), + packetDestination(setPacketDestination),executingTask(NULL) { commandQueue = QueueFactory::instance()->createMessageQueue(queueDepth); requestQueue = QueueFactory::instance()->createMessageQueue(queueDepth); } -- 2.34.1 From 12f51575eb42bffc9e2cf5a72a5678975f87db34 Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Mon, 4 Nov 2019 00:53:05 +0100 Subject: [PATCH 19/26] removed a flag by accident, fixed now --- devicehandlers/DeviceHandlerBase.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/devicehandlers/DeviceHandlerBase.cpp b/devicehandlers/DeviceHandlerBase.cpp index c92cac332..3018a076f 100644 --- a/devicehandlers/DeviceHandlerBase.cpp +++ b/devicehandlers/DeviceHandlerBase.cpp @@ -1119,7 +1119,7 @@ void DeviceHandlerBase::handleDeviceTM(SerializeIF* data, // hiding of sender needed so the service will handle it as unexpected Data, no matter what state //(progress or completed) it is in - actionHelper.reportData(defaultRawReceiver, replyId, &wrapper); + actionHelper.reportData(defaultRawReceiver, replyId, &wrapper, true); } } else { //unrequested/aperiodic replies -- 2.34.1 From cb919ada2a99b818624d05a4e4fdfeb85e9b8174 Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Mon, 4 Nov 2019 01:55:40 +0100 Subject: [PATCH 20/26] assuming that a default value of 0 for expectedReplies is needed, I introduced a new variable into DeviceCommandInfo, which stores another number of replies expected. this value is assigned in enableReplyInReplyMap. That way, the initial value of 0 remains the same (if it was needed), and is only set to another desired value if a write was sent --- devicehandlers/DeviceHandlerBase.cpp | 5 +++-- devicehandlers/DeviceHandlerBase.h | 9 +++++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/devicehandlers/DeviceHandlerBase.cpp b/devicehandlers/DeviceHandlerBase.cpp index 3018a076f..491d792b5 100644 --- a/devicehandlers/DeviceHandlerBase.cpp +++ b/devicehandlers/DeviceHandlerBase.cpp @@ -285,7 +285,8 @@ ReturnValue_t DeviceHandlerBase::insertInReplyMap(DeviceCommandId_t replyId, ReturnValue_t DeviceHandlerBase::insertInCommandMap( DeviceCommandId_t deviceCommand, uint8_t expectedReplies) { DeviceCommandInfo info; - info.expectedReplies = expectedReplies; + info.expectedReplies = 0; + info.expectedRepliesWhenEnablingReplyMap = expectedReplies; info.isExecuting = false; info.sendReplyTo = NO_COMMANDER; std::pair::iterator, bool> returnValue; @@ -821,7 +822,7 @@ ReturnValue_t DeviceHandlerBase::enableReplyInReplyMap( DeviceReplyInfo *info = &(iter->second); info->delayCycles = info->maxDelayCycles; info->command = command; - // command->second.expectedReplies = expectedReplies; + command->second.expectedReplies = command->second.expectedRepliesWhenEnablingReplyMap; return RETURN_OK; } else { return NO_REPLY_EXPECTED; diff --git a/devicehandlers/DeviceHandlerBase.h b/devicehandlers/DeviceHandlerBase.h index 89f965036..ad4a22035 100644 --- a/devicehandlers/DeviceHandlerBase.h +++ b/devicehandlers/DeviceHandlerBase.h @@ -704,7 +704,8 @@ protected: struct DeviceCommandInfo { bool isExecuting; //!< Indicates if the command is already executing. - uint8_t expectedReplies; //!< Dynamic value to indicate how many replies are expected. + uint8_t expectedReplies; //!< Dynamic value to indicate how many replies are expected. Inititated with 0. + uint8_t expectedRepliesWhenEnablingReplyMap; //!< Constant value which specifies expected replies when enabling reply map. Inititated in insertInCommandAndReplyMap() MessageQueueId_t sendReplyTo; //!< if this is != NO_COMMANDER, DHB was commanded externally and shall report everything to commander. }; @@ -732,8 +733,12 @@ protected: * do not expect a reply. */ // Proposal: Set expected replies in insertInCommandAndReplyMap so we don't have to overwrite that function anymore. + // Replies are only checked when a write was issued and the default value here was one, so + // it should be possible to set this in the DeviceCommandMap with default value one. + // UPDATE: The default value of 0 when inserting into command and reply map is retained now by introducing a new + // variable in the DeviceCommandInfo which specifies expected replies if this function is called. virtual ReturnValue_t enableReplyInReplyMap(DeviceCommandMap::iterator cmd, - /* uint8_t expectedReplies = 0 */ bool useAlternateId = false, + /* uint8_t expectedReplies = 1, */ bool useAlternateId = false, DeviceCommandId_t alternateReplyID = 0); /** -- 2.34.1 From e7f7625adf27263aec16580fa70ca137e412aef6 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 4 Nov 2019 11:06:59 +0100 Subject: [PATCH 21/26] removed wrong include --- devicehandlers/DeviceHandlerBase.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/devicehandlers/DeviceHandlerBase.cpp b/devicehandlers/DeviceHandlerBase.cpp index 2f16f8462..1bb411b7d 100644 --- a/devicehandlers/DeviceHandlerBase.cpp +++ b/devicehandlers/DeviceHandlerBase.cpp @@ -11,7 +11,6 @@ #include #include #include -#include object_id_t DeviceHandlerBase::powerSwitcherId = 0; object_id_t DeviceHandlerBase::rawDataReceiverId = 0; -- 2.34.1 From b594bc2a9719b6ffb99cb3fdaf4813c688576158 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 5 Nov 2019 19:25:00 +0100 Subject: [PATCH 22/26] removed obsolete comment --- action/ActionHelper.h | 2 +- devicehandlers/DeviceHandlerBase.cpp | 28 ++++++++------------------ devicehandlers/DeviceHandlerBase.h | 19 +++++------------ modes/ModeHelper.h | 13 +----------- tmtcservices/CommandingServiceBase.cpp | 11 +++++----- 5 files changed, 21 insertions(+), 52 deletions(-) diff --git a/action/ActionHelper.h b/action/ActionHelper.h index a72e3654a..6ba6dd89b 100644 --- a/action/ActionHelper.h +++ b/action/ActionHelper.h @@ -74,7 +74,7 @@ public: protected: static const uint8_t STEP_OFFSET = 1;//!< Increase of value of this per step HasActionsIF* owner;//!< Pointer to the owner - MessageQueueIF* queueToUse;//!< Queue to be used as response sender, has to be set with @c setQueueToUse + MessageQueueIF* queueToUse;//!< Queue to be used as response sender, has to be set with StorageManagerIF* ipcStore;//!< Pointer to an IPC Store, initialized during construction or initialize(MessageQueueIF* queueToUse_) or with setQueueToUse(MessageQueueIF *queue) /** *Internal function called by handleActionMessage(CommandMessage* command) diff --git a/devicehandlers/DeviceHandlerBase.cpp b/devicehandlers/DeviceHandlerBase.cpp index 491d792b5..6150954d9 100644 --- a/devicehandlers/DeviceHandlerBase.cpp +++ b/devicehandlers/DeviceHandlerBase.cpp @@ -255,9 +255,9 @@ ReturnValue_t DeviceHandlerBase::isModeCombinationValid(Mode_t mode, ReturnValue_t DeviceHandlerBase::insertInCommandAndReplyMap( DeviceCommandId_t deviceCommand, uint16_t maxDelayCycles, - uint8_t periodic, uint8_t expectedReplies, bool hasDifferentReplyId, DeviceCommandId_t replyId) { - //No need to check, as we may try to insert multiple times. - insertInCommandMap(deviceCommand,expectedReplies); + uint8_t periodic, bool hasDifferentReplyId, DeviceCommandId_t replyId) { +//No need to check, as we may try to insert multiple times. + insertInCommandMap(deviceCommand); if (hasDifferentReplyId) { return insertInReplyMap(replyId, maxDelayCycles, periodic); } else { @@ -283,10 +283,9 @@ ReturnValue_t DeviceHandlerBase::insertInReplyMap(DeviceCommandId_t replyId, } ReturnValue_t DeviceHandlerBase::insertInCommandMap( - DeviceCommandId_t deviceCommand, uint8_t expectedReplies) { + DeviceCommandId_t deviceCommand) { DeviceCommandInfo info; info.expectedReplies = 0; - info.expectedRepliesWhenEnablingReplyMap = expectedReplies; info.isExecuting = false; info.sendReplyTo = NO_COMMANDER; std::pair::iterator, bool> returnValue; @@ -713,7 +712,6 @@ void DeviceHandlerBase::handleReply(const uint8_t* receivedData, DeviceCommandId_t foundId, uint32_t foundLen) { ReturnValue_t result; DeviceReplyMap::iterator iter = deviceReplyMap.find(foundId); - MessageQueueId_t commander; if (iter == deviceReplyMap.end()) { replyRawReplyIfnotWiretapped(receivedData, foundLen); @@ -730,17 +728,7 @@ void DeviceHandlerBase::handleReply(const uint8_t* receivedData, } else { info->delayCycles = 0; } - - DeviceCommandMap::iterator commandIter = deviceCommandMap.find(foundId); - // could be a reply only packet - if(commandIter == deviceCommandMap.end()) { - commander = 0; - } - else { - commander = commandIter->second.sendReplyTo; - } - - result = interpretDeviceReply(foundId, receivedData,commander); + result = interpretDeviceReply(foundId, receivedData); if (result != RETURN_OK) { //Report failed interpretation to FDIR. replyRawReplyIfnotWiretapped(receivedData, foundLen); @@ -810,7 +798,7 @@ void DeviceHandlerBase::modeChanged(void) { } ReturnValue_t DeviceHandlerBase::enableReplyInReplyMap( - DeviceCommandMap::iterator command,/* uint8_t expectedReplies, */ + DeviceCommandMap::iterator command, uint8_t expectedReplies, bool useAlternativeId, DeviceCommandId_t alternativeReply) { DeviceReplyMap::iterator iter; if (useAlternativeId) { @@ -822,7 +810,7 @@ ReturnValue_t DeviceHandlerBase::enableReplyInReplyMap( DeviceReplyInfo *info = &(iter->second); info->delayCycles = info->maxDelayCycles; info->command = command; - command->second.expectedReplies = command->second.expectedRepliesWhenEnablingReplyMap; + command->second.expectedReplies = expectedReplies; return RETURN_OK; } else { return NO_REPLY_EXPECTED; @@ -1133,7 +1121,7 @@ void DeviceHandlerBase::handleDeviceTM(SerializeIF* data, true); } } - //Try to cast to DataSet and commit data. +//Try to cast to DataSet and commit data. if (!neverInDataPool) { DataSet* dataSet = dynamic_cast(data); if (dataSet != NULL) { diff --git a/devicehandlers/DeviceHandlerBase.h b/devicehandlers/DeviceHandlerBase.h index ad4a22035..040c21903 100644 --- a/devicehandlers/DeviceHandlerBase.h +++ b/devicehandlers/DeviceHandlerBase.h @@ -576,9 +576,8 @@ protected: * Default is aperiodic (0) * @return RETURN_OK when the command was successfully inserted, COMMAND_MAP_ERROR else. */ - // Proposal: Set expected replies for a command in insertInCommandAndReplyMap so we don't have to overwrite enableReplyInReplyMap ReturnValue_t insertInCommandAndReplyMap(DeviceCommandId_t deviceCommand, - uint16_t maxDelayCycles, uint8_t periodic = 0, uint8_t expectedReplies = 1, + uint16_t maxDelayCycles, uint8_t periodic = 0, bool hasDifferentReplyId = false, DeviceCommandId_t replyId = 0); /** * This is a helper method to insert replies in the reply map. @@ -595,7 +594,7 @@ protected: * @param deviceCommand The command to add * @return RETURN_OK if the command was successfully inserted, RETURN_FAILED else. */ - ReturnValue_t insertInCommandMap(DeviceCommandId_t deviceCommand, uint8_t expectedReplies = 1); + ReturnValue_t insertInCommandMap(DeviceCommandId_t deviceCommand); /** * This is a helper method to facilitate updating entries in the reply map. * @param deviceCommand Identifier of the reply to update. @@ -645,19 +644,17 @@ protected: * * This is called after scanForReply() found a valid packet, it can be assumed that the length and structure is valid. * This routine extracts the data from the packet into a DataSet and then calls handleDeviceTM(), which either sends - * a TM packet or stores the data in the DataPool depending on whether it was an external command. + * a TM packet or stores the data in the DataPool depending on whether the it was an external command. * No packet length is given, as it should be defined implicitly by the id. * * @param id the id found by scanForReply() * @param packet - * @param commander the one who initiated the command, is 0 if not external commanded. - * UPDATE: This parameter does not exist anymore. Why? * @return * - @c RETURN_OK when the reply was interpreted. * - @c RETURN_FAILED when the reply could not be interpreted, eg. logical errors or range violations occurred */ virtual ReturnValue_t interpretDeviceReply(DeviceCommandId_t id, - const uint8_t *packet, MessageQueueId_t commander = 0) = 0; + const uint8_t *packet) = 0; /** * Construct a command reply containing a raw reply. @@ -726,19 +723,13 @@ protected: * - If the command was not found in the reply map, NO_REPLY_EXPECTED MUST be returned. * - A failure code may be returned if something went fundamentally wrong. * - * * @param deviceCommand * @return - RETURN_OK if a reply was activated. * - NO_REPLY_EXPECTED if there was no reply found. This is not an error case as many commands * do not expect a reply. */ - // Proposal: Set expected replies in insertInCommandAndReplyMap so we don't have to overwrite that function anymore. - // Replies are only checked when a write was issued and the default value here was one, so - // it should be possible to set this in the DeviceCommandMap with default value one. - // UPDATE: The default value of 0 when inserting into command and reply map is retained now by introducing a new - // variable in the DeviceCommandInfo which specifies expected replies if this function is called. virtual ReturnValue_t enableReplyInReplyMap(DeviceCommandMap::iterator cmd, - /* uint8_t expectedReplies = 1, */ bool useAlternateId = false, + uint8_t expectedReplies = 1, bool useAlternateId = false, DeviceCommandId_t alternateReplyID = 0); /** diff --git a/modes/ModeHelper.h b/modes/ModeHelper.h index b23eb69e5..87f6d4112 100644 --- a/modes/ModeHelper.h +++ b/modes/ModeHelper.h @@ -16,17 +16,11 @@ public: ModeHelper(HasModesIF *owner); virtual ~ModeHelper(); - /** - * This is used by DHB to handle all mode messages issued by a service - * @param message - * @return - */ ReturnValue_t handleModeCommand(CommandMessage *message); /** * - * @param parentQueue the Queue id of the parent object (assembly or subsystem object). - * Set to 0 if no parent present + * @param parentQueue the Queue id of the parent object. Set to 0 if no parent present */ void setParentQueue(MessageQueueId_t parentQueueId); @@ -34,11 +28,6 @@ public: ReturnValue_t initialize(void); //void is there to stop eclipse CODAN from falsely reporting an error - /** - * Used to notify - * @param mode - * @param submode - */ void modeChanged(Mode_t mode, Submode_t submode); void startTimer(uint32_t timeoutMs); diff --git a/tmtcservices/CommandingServiceBase.cpp b/tmtcservices/CommandingServiceBase.cpp index ec65492de..d70b90428 100644 --- a/tmtcservices/CommandingServiceBase.cpp +++ b/tmtcservices/CommandingServiceBase.cpp @@ -11,11 +11,12 @@ CommandingServiceBase::CommandingServiceBase(object_id_t setObjectId, uint16_t apid, uint8_t service, uint8_t numberOfParallelCommands, uint16_t commandTimeout_seconds, object_id_t setPacketSource, object_id_t setPacketDestination, size_t queueDepth) : - SystemObject(setObjectId), apid(apid), service(service), - timeout_seconds(commandTimeout_seconds), tmPacketCounter(0), IPCStore(NULL), - TCStore(NULL), commandQueue(NULL), requestQueue(NULL), commandMap(numberOfParallelCommands), - failureParameter1(0), failureParameter2(0), packetSource(setPacketSource), - packetDestination(setPacketDestination),executingTask(NULL) { + SystemObject(setObjectId), apid(apid), service(service), timeout_seconds( + commandTimeout_seconds), tmPacketCounter(0), IPCStore(NULL), TCStore( + NULL), commandQueue(NULL), requestQueue(NULL), commandMap( + numberOfParallelCommands), failureParameter1(0), failureParameter2( + 0), packetSource(setPacketSource), packetDestination( + setPacketDestination),executingTask(NULL) { commandQueue = QueueFactory::instance()->createMessageQueue(queueDepth); requestQueue = QueueFactory::instance()->createMessageQueue(queueDepth); } -- 2.34.1 From bf7bc342ff2bb816d910bd2c142661fecd25c867 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 5 Nov 2019 19:30:02 +0100 Subject: [PATCH 23/26] Revert "documentation for DHB init function, ioBoard addres has default value 0 now, order in ctor changed (not used in source)" This reverts commit c6e34cada64f59757e420347dec8373401d73c7a. --- devicehandlers/ChildHandlerBase.cpp | 4 ++-- devicehandlers/DeviceHandlerBase.cpp | 9 +++++---- devicehandlers/DeviceHandlerBase.h | 21 +++------------------ 3 files changed, 10 insertions(+), 24 deletions(-) diff --git a/devicehandlers/ChildHandlerBase.cpp b/devicehandlers/ChildHandlerBase.cpp index fb9238f7e..50a5c07e5 100644 --- a/devicehandlers/ChildHandlerBase.cpp +++ b/devicehandlers/ChildHandlerBase.cpp @@ -7,8 +7,8 @@ ChildHandlerBase::ChildHandlerBase(uint32_t ioBoardAddress, uint32_t maxDeviceReplyLen, uint8_t setDeviceSwitch, uint32_t thermalStatePoolId, uint32_t thermalRequestPoolId, uint32_t parent, FailureIsolationBase* customFdir, uint32_t cmdQueueSize) : - DeviceHandlerBase(setObjectId, maxDeviceReplyLen, - setDeviceSwitch, deviceCommunication,ioBoardAddress, thermalStatePoolId, + DeviceHandlerBase(ioBoardAddress, setObjectId, maxDeviceReplyLen, + setDeviceSwitch, deviceCommunication, thermalStatePoolId, thermalRequestPoolId, (customFdir == NULL? &childHandlerFdir : customFdir), cmdQueueSize), parentId( parent), childHandlerFdir(setObjectId) { } diff --git a/devicehandlers/DeviceHandlerBase.cpp b/devicehandlers/DeviceHandlerBase.cpp index 6150954d9..def9a7245 100644 --- a/devicehandlers/DeviceHandlerBase.cpp +++ b/devicehandlers/DeviceHandlerBase.cpp @@ -16,10 +16,11 @@ object_id_t DeviceHandlerBase::powerSwitcherId = 0; object_id_t DeviceHandlerBase::rawDataReceiverId = 0; object_id_t DeviceHandlerBase::defaultFDIRParentId = 0; -DeviceHandlerBase::DeviceHandlerBase(object_id_t setObjectId, - uint32_t maxDeviceReplyLen, uint8_t setDeviceSwitch, - object_id_t deviceCommunication, uint32_t ioBoardAddress, uint32_t thermalStatePoolId, - uint32_t thermalRequestPoolId, FailureIsolationBase* fdirInstance, uint32_t cmdQueueSize) : +DeviceHandlerBase::DeviceHandlerBase(uint32_t ioBoardAddress, + object_id_t setObjectId, uint32_t maxDeviceReplyLen, + uint8_t setDeviceSwitch, object_id_t deviceCommunication, + uint32_t thermalStatePoolId, uint32_t thermalRequestPoolId, + FailureIsolationBase* fdirInstance, uint32_t cmdQueueSize) : SystemObject(setObjectId),ioBoardAddress(ioBoardAddress), rawPacket(0), rawPacketLen(0), mode(MODE_OFF), submode(SUBMODE_NONE), pstStep(0), maxDeviceReplyLen(maxDeviceReplyLen), wiretappingMode(OFF), defaultRawReceiver(0), storedRawData(StorageManagerIF::INVALID_ADDRESS), diff --git a/devicehandlers/DeviceHandlerBase.h b/devicehandlers/DeviceHandlerBase.h index 040c21903..03e35727e 100644 --- a/devicehandlers/DeviceHandlerBase.h +++ b/devicehandlers/DeviceHandlerBase.h @@ -76,10 +76,10 @@ public: * @param maxDeviceReplyLen the length the RMAP getRead call will be sent with * @param setDeviceSwitch the switch the device is connected to, for devices using two switches, overwrite getSwitches() */ - DeviceHandlerBase(object_id_t setObjectId, + DeviceHandlerBase(uint32_t ioBoardAddress, object_id_t setObjectId, uint32_t maxDeviceReplyLen, uint8_t setDeviceSwitch, - object_id_t deviceCommunication,uint32_t ioBoardAddress = 0, - uint32_t thermalStatePoolId = PoolVariableIF::NO_PARAMETER, + object_id_t deviceCommunication, uint32_t thermalStatePoolId = + PoolVariableIF::NO_PARAMETER, uint32_t thermalRequestPoolId = PoolVariableIF::NO_PARAMETER, FailureIsolationBase* fdirInstance = NULL, uint32_t cmdQueueSize = 20); @@ -116,21 +116,6 @@ public: */ virtual ReturnValue_t performOperation(uint8_t counter); - /** - * Prerequisites to call initialize function without custom implementation: - * 1. The three static framework IDs are set to respective objects in the Factory function - * - First ID: Power Switcher ID. Example: PCDU Handler Object - * - Second ID: Raw Data Receiver. Example: PUS Service 2 Object - * - Third ID: Default FDIR parent ID. Example: ? - * 2. Communication Interface Object for respective device. - * Example: UART Communication Interface which calls respective UART drivers - * 3. Health table class has been instantiated in Factory - * 4. deviceThermalRequestPoolId and deviceThermalStatePoolId are set to the respective data pool entries. - * This is only required if thermal checking is needed. Otherwise, set both variables to - * PoolVariableIF::NO_PARAMETER - * - * @return - */ virtual ReturnValue_t initialize(); /** -- 2.34.1 From 801bd4d7ebce3ce32eab46e561dec5bc95401c4a Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Sat, 9 Nov 2019 13:07:26 +0100 Subject: [PATCH 24/26] debug interface for dhb created. This is useful to track states or values in child handler. some documentation added. New doxygen group for interfaced added. --- action/HasActionsIF.h | 6 +++++- devicehandlers/DeviceHandlerBase.cpp | 8 ++++++-- devicehandlers/DeviceHandlerBase.h | 12 ++++++++++++ events/EventManager.cpp | 7 ++++--- modes/ModeHelper.cpp | 2 +- power/PowerSwitchIF.h | 9 +++++++-- 6 files changed, 35 insertions(+), 9 deletions(-) diff --git a/action/HasActionsIF.h b/action/HasActionsIF.h index f30fcb45e..4d66ad1f6 100644 --- a/action/HasActionsIF.h +++ b/action/HasActionsIF.h @@ -7,8 +7,10 @@ #include #include /** - * \brief Interface for component which uses actions + * @brief + * Interface for component which uses actions * + * @details * This interface is used to execute actions in the component. Actions, in the sense of this interface, are activities with a well-defined beginning and * end in time. They may adjust sub-states of components, but are not supposed to change * the main mode of operation, which is handled with the HasModesIF described below. @@ -23,6 +25,8 @@ * parameters and immediately start execution of the action. It is, however, not required to * immediately finish execution. Instead, this may be deferred to a later point in time, at * which the component needs to inform the caller about finished or failed execution. + * + * \ingroup interfaces */ class HasActionsIF { public: diff --git a/devicehandlers/DeviceHandlerBase.cpp b/devicehandlers/DeviceHandlerBase.cpp index def9a7245..35a987f33 100644 --- a/devicehandlers/DeviceHandlerBase.cpp +++ b/devicehandlers/DeviceHandlerBase.cpp @@ -834,8 +834,9 @@ ReturnValue_t DeviceHandlerBase::getStateOfSwitches(void) { ReturnValue_t result = getSwitches(&switches, &numberOfSwitches); if ((result == RETURN_OK) && (numberOfSwitches != 0)) { while (numberOfSwitches > 0) { - if (powerSwitcher->getSwitchState(switches[numberOfSwitches - 1]) - == PowerSwitchIF::SWITCH_OFF) { + if (powerSwitcher-> getSwitchState(switches[numberOfSwitches - 1]) + == PowerSwitchIF::SWITCH_OFF) + { return PowerSwitchIF::SWITCH_OFF; } numberOfSwitches--; @@ -1267,4 +1268,7 @@ void DeviceHandlerBase::setTaskIF(PeriodicTaskIF* task_){ executingTask = task_; } +void DeviceHandlerBase::debugInterface(uint8_t positionTracker) { +} + diff --git a/devicehandlers/DeviceHandlerBase.h b/devicehandlers/DeviceHandlerBase.h index 03e35727e..4938e0196 100644 --- a/devicehandlers/DeviceHandlerBase.h +++ b/devicehandlers/DeviceHandlerBase.h @@ -553,6 +553,18 @@ protected: */ virtual void fillCommandAndReplyMap() = 0; + + /** + * @brief Can be implemented by child handler to + * perform debugging + * @details Example: Calling this in performOperation + * to track values like mode. An optional position tracker can be supplied + * to provide the child handler a way to know where the debugInterface was called + * + * Please delete all debugInterface calls in DHB after debugging is finished ! + */ + virtual void debugInterface(uint8_t positionTracker = 0); + /** * This is a helper method to facilitate inserting entries in the command map. * @param deviceCommand Identifier of the command to add. diff --git a/events/EventManager.cpp b/events/EventManager.cpp index 01334bac9..46c537520 100644 --- a/events/EventManager.cpp +++ b/events/EventManager.cpp @@ -137,9 +137,10 @@ void EventManager::printEvent(EventMessage* message) { error << "0x" << std::hex << message->getReporter() << std::dec; } error << " reported " << translateEvents(message->getEvent()) << " (" - << std::dec << message->getEventId() << std::hex << ") P1: 0x" - << message->getParameter1() << " P2: 0x" - << message->getParameter2() << std::dec << std::endl; + << std::dec << message->getEventId() << ") " << std::endl; + + error << std::hex << "P1 Hex: 0x" << message->getParameter1() << ", P1 Dec: " << std::dec << message->getParameter1() << std::endl; + error << std::hex << "P2 Hex: 0x" << message->getParameter2() << ", P2 Dec: " << std::dec << message->getParameter2() << std::endl; break; } diff --git a/modes/ModeHelper.cpp b/modes/ModeHelper.cpp index 7b98bdc64..d9266c354 100644 --- a/modes/ModeHelper.cpp +++ b/modes/ModeHelper.cpp @@ -1,6 +1,7 @@ #include #include #include +#include ModeHelper::ModeHelper(HasModesIF *owner) : theOneWhoCommandedAMode(0), commandedMode(HasModesIF::MODE_OFF), commandedSubmode( @@ -42,7 +43,6 @@ ReturnValue_t ModeHelper::handleModeCommand(CommandMessage* message) { } countdown.setTimeout(timeout); - owner->startTransition(mode, submode); } break; diff --git a/power/PowerSwitchIF.h b/power/PowerSwitchIF.h index 1c4c06f7f..f25589c4d 100644 --- a/power/PowerSwitchIF.h +++ b/power/PowerSwitchIF.h @@ -11,8 +11,13 @@ #include #include /** - * This interface defines a connection to a device that is capable of turning on and off - * switches of devices identified by a switch ID. + * + * @brief This interface defines a connection to a device that is capable of turning on and off + * switches of devices identified by a switch ID. + * @details The virtual functions of this interface do not allow to make any assignments + * because they can be called asynchronosuly (const ending). + * + * @ingroup interfaces */ class PowerSwitchIF : public HasReturnvaluesIF { public: -- 2.34.1 From ee765eafc766d9a4a1053d3d685d7d63e6f9f95f Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Sat, 9 Nov 2019 13:17:54 +0100 Subject: [PATCH 25/26] ioBoardAddress renamed to logicalAddress --- devicehandlers/DeviceHandlerBase.cpp | 8 ++++---- devicehandlers/DeviceHandlerBase.h | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/devicehandlers/DeviceHandlerBase.cpp b/devicehandlers/DeviceHandlerBase.cpp index 35a987f33..fd8d61410 100644 --- a/devicehandlers/DeviceHandlerBase.cpp +++ b/devicehandlers/DeviceHandlerBase.cpp @@ -16,12 +16,12 @@ object_id_t DeviceHandlerBase::powerSwitcherId = 0; object_id_t DeviceHandlerBase::rawDataReceiverId = 0; object_id_t DeviceHandlerBase::defaultFDIRParentId = 0; -DeviceHandlerBase::DeviceHandlerBase(uint32_t ioBoardAddress, +DeviceHandlerBase::DeviceHandlerBase(uint32_t logicalAddress_, object_id_t setObjectId, uint32_t maxDeviceReplyLen, uint8_t setDeviceSwitch, object_id_t deviceCommunication, uint32_t thermalStatePoolId, uint32_t thermalRequestPoolId, FailureIsolationBase* fdirInstance, uint32_t cmdQueueSize) : - SystemObject(setObjectId),ioBoardAddress(ioBoardAddress), rawPacket(0), rawPacketLen(0), mode(MODE_OFF), + SystemObject(setObjectId),logicalAddress(logicalAddress_), rawPacket(0), rawPacketLen(0), mode(MODE_OFF), submode(SUBMODE_NONE), pstStep(0), maxDeviceReplyLen(maxDeviceReplyLen), wiretappingMode(OFF), defaultRawReceiver(0), storedRawData(StorageManagerIF::INVALID_ADDRESS), requestedRawTraffic(0), powerSwitcher(NULL), IPCStore(NULL), @@ -589,7 +589,7 @@ ReturnValue_t DeviceHandlerBase::initialize() { return RETURN_FAILED; } - result = communicationInterface->open(&cookie, ioBoardAddress, + result = communicationInterface->open(&cookie, logicalAddress, maxDeviceReplyLen); if (result != RETURN_OK) { return result; @@ -750,7 +750,7 @@ ReturnValue_t DeviceHandlerBase::switchCookieChannel(object_id_t newChannelId) { DeviceCommunicationIF>(newChannelId); if (newCommunication != NULL) { - ReturnValue_t result = newCommunication->reOpen(cookie, ioBoardAddress, + ReturnValue_t result = newCommunication->reOpen(cookie, logicalAddress, maxDeviceReplyLen); if (result != RETURN_OK) { return result; diff --git a/devicehandlers/DeviceHandlerBase.h b/devicehandlers/DeviceHandlerBase.h index 4938e0196..8f7f065a4 100644 --- a/devicehandlers/DeviceHandlerBase.h +++ b/devicehandlers/DeviceHandlerBase.h @@ -76,7 +76,7 @@ public: * @param maxDeviceReplyLen the length the RMAP getRead call will be sent with * @param setDeviceSwitch the switch the device is connected to, for devices using two switches, overwrite getSwitches() */ - DeviceHandlerBase(uint32_t ioBoardAddress, object_id_t setObjectId, + DeviceHandlerBase(uint32_t logicalAddress, object_id_t setObjectId, uint32_t maxDeviceReplyLen, uint8_t setDeviceSwitch, object_id_t deviceCommunication, uint32_t thermalStatePoolId = PoolVariableIF::NO_PARAMETER, @@ -149,7 +149,7 @@ protected: /** * cached from ctor for initialize() */ - const uint32_t ioBoardAddress; + const uint32_t logicalAddress; /** * The Returnvalues id of this class, required by HasReturnvaluesIF -- 2.34.1 From 537e2ceb18ddd360176fddec37331bb952f8c674 Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Sat, 9 Nov 2019 13:29:12 +0100 Subject: [PATCH 26/26] Getter method for logicalAddress --- devicehandlers/DeviceHandlerBase.cpp | 9 ++++++--- devicehandlers/DeviceHandlerBase.h | 17 +++++++++++------ 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/devicehandlers/DeviceHandlerBase.cpp b/devicehandlers/DeviceHandlerBase.cpp index fd8d61410..09c27c87d 100644 --- a/devicehandlers/DeviceHandlerBase.cpp +++ b/devicehandlers/DeviceHandlerBase.cpp @@ -21,7 +21,7 @@ DeviceHandlerBase::DeviceHandlerBase(uint32_t logicalAddress_, uint8_t setDeviceSwitch, object_id_t deviceCommunication, uint32_t thermalStatePoolId, uint32_t thermalRequestPoolId, FailureIsolationBase* fdirInstance, uint32_t cmdQueueSize) : - SystemObject(setObjectId),logicalAddress(logicalAddress_), rawPacket(0), rawPacketLen(0), mode(MODE_OFF), + SystemObject(setObjectId), rawPacket(0), rawPacketLen(0), mode(MODE_OFF), submode(SUBMODE_NONE), pstStep(0), maxDeviceReplyLen(maxDeviceReplyLen), wiretappingMode(OFF), defaultRawReceiver(0), storedRawData(StorageManagerIF::INVALID_ADDRESS), requestedRawTraffic(0), powerSwitcher(NULL), IPCStore(NULL), @@ -31,7 +31,7 @@ DeviceHandlerBase::DeviceHandlerBase(uint32_t logicalAddress_, modeHelper(this), parameterHelper(this), childTransitionFailure(RETURN_OK), ignoreMissedRepliesCount(0), fdirInstance(fdirInstance), hkSwitcher(this), defaultFDIRUsed(fdirInstance == NULL), switchOffWasReported(false), - executingTask(NULL), actionHelper(this, NULL), cookieInfo(), + executingTask(NULL), actionHelper(this, NULL), cookieInfo(), logicalAddress(logicalAddress_), timeoutStart(0), childTransitionDelay(5000), transitionSourceMode(_MODE_POWER_DOWN), transitionSourceSubMode(SUBMODE_NONE), deviceSwitch(setDeviceSwitch) { commandQueue = QueueFactory::instance()->createMessageQueue(cmdQueueSize, @@ -1018,6 +1018,7 @@ void DeviceHandlerBase::replyRawReplyIfnotWiretapped(const uint8_t* data, } } + ReturnValue_t DeviceHandlerBase::handleDeviceHandlerMessage( CommandMessage * message) { ReturnValue_t result; @@ -1271,4 +1272,6 @@ void DeviceHandlerBase::setTaskIF(PeriodicTaskIF* task_){ void DeviceHandlerBase::debugInterface(uint8_t positionTracker) { } - +uint32_t DeviceHandlerBase::getLogicalAddress() { + return logicalAddress; +} diff --git a/devicehandlers/DeviceHandlerBase.h b/devicehandlers/DeviceHandlerBase.h index 8f7f065a4..4c83b230d 100644 --- a/devicehandlers/DeviceHandlerBase.h +++ b/devicehandlers/DeviceHandlerBase.h @@ -146,11 +146,6 @@ public: */ virtual void setTaskIF(PeriodicTaskIF* task_); protected: - /** - * cached from ctor for initialize() - */ - const uint32_t logicalAddress; - /** * The Returnvalues id of this class, required by HasReturnvaluesIF */ @@ -763,6 +758,11 @@ protected: */ virtual bool dontCheckQueue(); + /** + * Used to retrieve logical address + * @return + */ + virtual uint32_t getLogicalAddress(); Mode_t getBaseMode(Mode_t transitionMode); bool isAwaitingReply(); @@ -775,7 +775,6 @@ protected: virtual void startTransition(Mode_t mode, Submode_t submode); virtual void setToExternalControl(); virtual void announceMode(bool recursive); - virtual ReturnValue_t letChildHandleMessage(CommandMessage *message); /** @@ -862,6 +861,8 @@ protected: private: + + /** * State a cookie is in. * @@ -892,6 +893,10 @@ private: */ CookieInfo cookieInfo; + /** + * cached from ctor for initialize() + */ + const uint32_t logicalAddress; /** * Used for timing out mode transitions. -- 2.34.1