diff --git a/action/ActionHelper.cpp b/action/ActionHelper.cpp index 9c1475f1..18e46fba 100644 --- a/action/ActionHelper.cpp +++ b/action/ActionHelper.cpp @@ -49,7 +49,7 @@ void ActionHelper::setQueueToUse(MessageQueueIF* queue) { void ActionHelper::prepareExecution(MessageQueueId_t commandedBy, ActionId_t actionId, store_address_t dataAddress) { const uint8_t* dataPtr = NULL; - uint32_t size = 0; + size_t size = 0; ReturnValue_t result = ipcStore->getData(dataAddress, &dataPtr, &size); if (result != HasReturnvaluesIF::RETURN_OK) { CommandMessage reply; diff --git a/action/CommandActionHelper.cpp b/action/CommandActionHelper.cpp index 05eb9346..ceb97d3b 100644 --- a/action/CommandActionHelper.cpp +++ b/action/CommandActionHelper.cpp @@ -113,7 +113,7 @@ uint8_t CommandActionHelper::getCommandCount() const { void CommandActionHelper::extractDataForOwner(ActionId_t actionId, store_address_t storeId) { const uint8_t * data = NULL; - uint32_t size = 0; + size_t size = 0; ReturnValue_t result = ipcStore->getData(storeId, &data, &size); if (result != HasReturnvaluesIF::RETURN_OK) { return; diff --git a/action/SimpleActionHelper.cpp b/action/SimpleActionHelper.cpp index 6de372fb..6861fc28 100644 --- a/action/SimpleActionHelper.cpp +++ b/action/SimpleActionHelper.cpp @@ -44,7 +44,7 @@ void SimpleActionHelper::prepareExecution(MessageQueueId_t commandedBy, queueToUse->sendMessage(commandedBy, &reply); } const uint8_t* dataPtr = NULL; - uint32_t size = 0; + size_t size = 0; ReturnValue_t result = ipcStore->getData(dataAddress, &dataPtr, &size); if (result != HasReturnvaluesIF::RETURN_OK) { ActionMessage::setStepReply(&reply, actionId, 0, result); diff --git a/datapool/DataPoolAdmin.cpp b/datapool/DataPoolAdmin.cpp index fe6b9215..99d2b51b 100644 --- a/datapool/DataPoolAdmin.cpp +++ b/datapool/DataPoolAdmin.cpp @@ -215,7 +215,7 @@ ReturnValue_t DataPoolAdmin::handleParameterCommand(CommandMessage* command) { ParameterMessage::getParameterId(command)); const uint8_t *storedStream; - uint32_t storedStreamSize; + size_t storedStreamSize; result = storage->getData(ParameterMessage::getStoreId(command), &storedStream, &storedStreamSize); if (result != HasReturnvaluesIF::RETURN_OK) { diff --git a/devicehandlers/ChildHandlerBase.cpp b/devicehandlers/ChildHandlerBase.cpp index 50a5c07e..a0630fc6 100644 --- a/devicehandlers/ChildHandlerBase.cpp +++ b/devicehandlers/ChildHandlerBase.cpp @@ -2,15 +2,16 @@ #include #include -ChildHandlerBase::ChildHandlerBase(uint32_t ioBoardAddress, - object_id_t setObjectId, object_id_t deviceCommunication, +ChildHandlerBase::ChildHandlerBase(object_id_t setObjectId, address_t logicalAddress, + object_id_t deviceCommunication, Cookie * cookie, 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, - thermalRequestPoolId, (customFdir == NULL? &childHandlerFdir : customFdir), cmdQueueSize), parentId( - parent), childHandlerFdir(setObjectId) { + uint32_t parent, FailureIsolationBase* customFdir, size_t cmdQueueSize) : + DeviceHandlerBase(setObjectId, logicalAddress, deviceCommunication, cookie, + maxDeviceReplyLen, setDeviceSwitch, thermalStatePoolId, + thermalRequestPoolId, (customFdir == NULL? &childHandlerFdir : customFdir), + cmdQueueSize), + parentId(parent), childHandlerFdir(setObjectId) { } ChildHandlerBase::~ChildHandlerBase() { diff --git a/devicehandlers/ChildHandlerBase.h b/devicehandlers/ChildHandlerBase.h index 3879f66f..4e9eee49 100644 --- a/devicehandlers/ChildHandlerBase.h +++ b/devicehandlers/ChildHandlerBase.h @@ -6,12 +6,12 @@ class ChildHandlerBase: public DeviceHandlerBase { public: - ChildHandlerBase(uint32_t ioBoardAddress, object_id_t setObjectId, - object_id_t deviceCommunication, uint32_t maxDeviceReplyLen, - uint8_t setDeviceSwitch, uint32_t thermalStatePoolId, - uint32_t thermalRequestPoolId, uint32_t parent, - FailureIsolationBase* customFdir = NULL, - uint32_t cmdQueueSize = 20); + ChildHandlerBase(object_id_t setObjectId, uint32_t logicalAddress, + object_id_t deviceCommunication, Cookie * cookie, + uint32_t maxDeviceReplyLen, uint8_t setDeviceSwitch, + uint32_t thermalStatePoolId, uint32_t thermalRequestPoolId, + uint32_t parent, FailureIsolationBase* customFdir = nullptr, + size_t cmdQueueSize = 20); virtual ~ChildHandlerBase(); virtual ReturnValue_t initialize(); diff --git a/devicehandlers/Cookie.cpp b/devicehandlers/Cookie.cpp new file mode 100644 index 00000000..f0748b5d --- /dev/null +++ b/devicehandlers/Cookie.cpp @@ -0,0 +1,24 @@ +/** + * @file Cookie.cpp + * + * @date 23.03.2020 + */ +#include + +//Cookie::Cookie(address_t logicalAddress_, size_t maxReplyLen_): +// logicalAddress(logicalAddress_), maxReplyLen(maxReplyLen_){} + +Cookie::Cookie(address_t logicalAddress_): logicalAddress(logicalAddress_) { +} + +void Cookie::setMaxReplyLen(size_t maxReplyLen_) { + maxReplyLen = maxReplyLen_; +} + +address_t Cookie::getAddress() const { + return logicalAddress; +} + +size_t Cookie::getMaxReplyLen() const { + return maxReplyLen; +} diff --git a/devicehandlers/Cookie.h b/devicehandlers/Cookie.h index ec22ec3a..60f20ff1 100644 --- a/devicehandlers/Cookie.h +++ b/devicehandlers/Cookie.h @@ -1,5 +1,6 @@ #ifndef COOKIE_H_ #define COOKIE_H_ +#include /** * @brief This datatype is used to identify different connection over a single interface @@ -7,13 +8,27 @@ * @details * To use this class, implement a communication specific child cookie. This cookie * can be used in the device communication interface by performing - * a C++ dynamic cast. The cookie can be used to store all kinds of information - * about the communication between read and send calls. + * a C++ dynamic cast and passing it to a child device handler, which stores + * it and passes the Cookie to the communication interface where it can be used + * by again performing a dynamic cast. + * The cookie can be used to store all kinds of information + * about the communication, like slave addresses, communication status, + * communication parameters etc. + * @ingroup comm */ class Cookie{ public: + Cookie() = default; + Cookie(address_t logicalAddress_); virtual ~Cookie(){} + + void setMaxReplyLen(size_t maxReplyLen_); + + address_t getAddress() const; + size_t getMaxReplyLen() const; +private: + address_t logicalAddress = 0; + size_t maxReplyLen = 0; }; - #endif /* COOKIE_H_ */ diff --git a/devicehandlers/DeviceCommunicationIF.h b/devicehandlers/DeviceCommunicationIF.h index 1e307b6c..43aa7965 100644 --- a/devicehandlers/DeviceCommunicationIF.h +++ b/devicehandlers/DeviceCommunicationIF.h @@ -6,7 +6,12 @@ #include /** * @defgroup interfaces Interfaces - * @brief Communication interfaces for flight software objects + * @brief Interfaces for flight software objects + */ + +/** + * @defgroup communication comm + * @brief Communication software components. */ /** @@ -22,9 +27,12 @@ * 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. + * To identify different connection over a single interface can return + * so-called cookies to components. * The CommunicationMessage message type can be used to extend the functionality of the * ComIF if a separate polling task is required. + * @ingroup interfaces + * @ingroup comm */ class DeviceCommunicationIF: public HasReturnvaluesIF { public: @@ -32,52 +40,12 @@ public: static const ReturnValue_t INVALID_COOKIE_TYPE = MAKE_RETURN_CODE(0x01); static const ReturnValue_t NOT_ACTIVE = MAKE_RETURN_CODE(0x02); - static const ReturnValue_t INVALID_ADDRESS = MAKE_RETURN_CODE(0x03); - static const ReturnValue_t TOO_MUCH_DATA = MAKE_RETURN_CODE(0x04); - static const ReturnValue_t NULLPOINTER = MAKE_RETURN_CODE(0x05); - static const ReturnValue_t PROTOCOL_ERROR = MAKE_RETURN_CODE(0x06); - static const ReturnValue_t CANT_CHANGE_REPLY_LEN = MAKE_RETURN_CODE(0x07); + static const ReturnValue_t TOO_MUCH_DATA = MAKE_RETURN_CODE(0x03); + static const ReturnValue_t NULLPOINTER = MAKE_RETURN_CODE(0x04); + static const ReturnValue_t PROTOCOL_ERROR = MAKE_RETURN_CODE(0x05); virtual ~DeviceCommunicationIF() {} - /** - * Open a connection. Define a communication specific cookie which can - * be used to store information about the communication. - * The two optional parameter provide additional flexibility to - * set up the communication interface as desired. If there are a lot of - * variables to set, a store ID to the parameters stored in the IPC store - * can also be passed. - * - * @param cookie [out] This data class stores information about the communication. - * @param address Logical device address - * @param maxReplyLen Maximum length of expected reply - * @param comParameter1 Arbitrary parameter which can be used to set up the cookie or comIF. - * @param comParameter2 Arbitrary parameter which can be used to set up the cookie or comIF. - * @return - */ - virtual ReturnValue_t open(Cookie **cookie, address_t address, - uint32_t maxReplyLen, uint32_t comParameter1, uint32_t comParameter2) = 0; - - /** - * Use an existing cookie to open a connection to a new DeviceCommunication. - * The previous connection must not be closed. - * - * @param cookie - * @param address - * @param maxReplyLen - * @return -@c RETURN_OK New communication set up successfully - * - Everything else: Cookie is unchanged and can be used with - * previous connection - */ - virtual ReturnValue_t reOpen(Cookie *cookie, address_t address, - uint32_t maxReplyLen, uint32_t comParameter1, uint32_t comParameter2) = 0; - - /** - * Closing call of connection. Don't forget to free memory of cookie. - * @param cookie - */ - virtual void close(Cookie *cookie) = 0; - /** * Called by DHB in the SEND_WRITE doSendWrite(). * This function is used to send data to the physical device @@ -86,21 +54,29 @@ public: * @param data * @param len * @return -@c RETURN_OK for successfull send - * -Everything else triggers sending failed event with - * returnvalue as parameter 1 + * - Everything else triggers sending failed event with + * returnvalue as parameter 1 */ - virtual ReturnValue_t sendMessage(Cookie *cookie, const uint8_t *data, - uint32_t len) = 0; + virtual ReturnValue_t sendMessage(Cookie *cookie, const uint8_t * sendData, + size_t sendLen) = 0; + /** + * Called by DHB in the GET_WRITE doGetWrite(). + * Get send confirmation that the data in sendMessage() was sent successfully. + * @param cookie + * @return -@c RETURN_OK if data was sent successfull + * - Everything else triggers sending failed event with + * returnvalue as parameter 1 + */ virtual ReturnValue_t getSendSuccess(Cookie *cookie) = 0; /** * Called by DHB in the SEND_WRITE doSendRead(). - * Instructs the Communication Interface to prepare + * Request a reply. * @param cookie * @return */ - virtual ReturnValue_t requestReceiveMessage(Cookie *cookie) = 0; + virtual ReturnValue_t requestReceiveMessage(Cookie *cookie, size_t requestLen) = 0; /** * Called by DHB in the GET_WRITE doGetRead(). @@ -110,30 +86,11 @@ public: * @param data * @param len * @return @c RETURN_OK for successfull receive - * Everything else triggers receiving failed with returnvalue as parameter 1 + * - Everything else triggers receiving failed with + * returnvalue as parameter 1 */ virtual ReturnValue_t readReceivedMessage(Cookie *cookie, uint8_t **buffer, - uint32_t *size) = 0; - - virtual ReturnValue_t setAddress(Cookie *cookie, address_t address) = 0; - - virtual address_t getAddress(Cookie *cookie) = 0; - - /** - * Can be used by DeviceHandlerBase getParameter() call to set DeviceComIF parameters - * @param cookie - * @param parameter - * @return - */ - virtual ReturnValue_t setParameter(Cookie *cookie, uint32_t parameter) = 0; - - /** - * Can be used by DeviceHandlerBase getParameter() call to set DeviceComIF parameters - * @param cookie - * @param parameter - * @return - */ - virtual uint32_t getParameter(Cookie *cookie) = 0; + size_t *size) = 0; }; #endif /* DEVICECOMMUNICATIONIF_H_ */ diff --git a/devicehandlers/DeviceHandlerBase.cpp b/devicehandlers/DeviceHandlerBase.cpp index ca883e83..5834db2f 100644 --- a/devicehandlers/DeviceHandlerBase.cpp +++ b/devicehandlers/DeviceHandlerBase.cpp @@ -16,37 +16,34 @@ object_id_t DeviceHandlerBase::powerSwitcherId = 0; object_id_t DeviceHandlerBase::rawDataReceiverId = 0; object_id_t DeviceHandlerBase::defaultFDIRParentId = 0; -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), 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(), logicalAddress(logicalAddress_), - timeoutStart(0), childTransitionDelay(5000), transitionSourceMode(_MODE_POWER_DOWN), - transitionSourceSubMode(SUBMODE_NONE), deviceSwitch(setDeviceSwitch) +DeviceHandlerBase::DeviceHandlerBase(object_id_t setObjectId, address_t logicalAddress_, + object_id_t deviceCommunication, Cookie * cookie_, size_t maxReplyLen, + uint8_t setDeviceSwitch, uint32_t thermalStatePoolId, uint32_t thermalRequestPoolId, + FailureIsolationBase* fdirInstance, size_t cmdQueueSize) : + SystemObject(setObjectId), mode(MODE_OFF), submode(SUBMODE_NONE), + wiretappingMode(OFF), storedRawData(StorageManagerIF::INVALID_ADDRESS), + deviceCommunicationId(deviceCommunication), cookie(cookie_), + deviceThermalStatePoolId(thermalStatePoolId), deviceThermalRequestPoolId(thermalRequestPoolId), + healthHelper(this, setObjectId), modeHelper(this), parameterHelper(this), + fdirInstance(fdirInstance), hkSwitcher(this), + defaultFDIRUsed(fdirInstance == nullptr), switchOffWasReported(false), + executingTask(nullptr), actionHelper(this, nullptr), cookieInfo(), + logicalAddress(logicalAddress_), childTransitionDelay(5000), + transitionSourceMode(_MODE_POWER_DOWN), transitionSourceSubMode(SUBMODE_NONE), + deviceSwitch(setDeviceSwitch) { + this->cookie->setMaxReplyLen(maxReplyLen); commandQueue = QueueFactory::instance()-> createMessageQueue(cmdQueueSize, CommandMessage::MAX_MESSAGE_SIZE); cookieInfo.state = COOKIE_UNUSED; insertInCommandMap(RAW_COMMAND_ID); - if (this->fdirInstance == NULL) { + if (this->fdirInstance == nullptr) { this->fdirInstance = new DeviceHandlerFailureIsolation(setObjectId, defaultFDIRParentId); } } DeviceHandlerBase::~DeviceHandlerBase() { - communicationInterface->close(cookie); if (defaultFDIRUsed) { delete fdirInstance; } @@ -105,11 +102,11 @@ ReturnValue_t DeviceHandlerBase::initialize() { return RETURN_FAILED; } - result = communicationInterface->open(&cookie, logicalAddress, - maxDeviceReplyLen, comParameter1, comParameter2); - if (result != RETURN_OK) { - return result; - } +// result = communicationInterface->open(&cookie, logicalAddress, +// maxDeviceReplyLen, comParameter1, comParameter2); +// if (result != RETURN_OK) { +// return result; +// } IPCStore = objectManager->get(objects::IPC_STORE); if (IPCStore == NULL) { @@ -551,7 +548,7 @@ void DeviceHandlerBase::doGetWrite() { void DeviceHandlerBase::doSendRead() { ReturnValue_t result; - result = communicationInterface->requestReceiveMessage(cookie); + result = communicationInterface->requestReceiveMessage(cookie, requestLen); if (result == RETURN_OK) { cookieInfo.state = COOKIE_READ_SENT; } else { @@ -565,10 +562,10 @@ void DeviceHandlerBase::doSendRead() { } void DeviceHandlerBase::doGetRead() { - uint32_t receivedDataLen; + size_t receivedDataLen; uint8_t *receivedData; DeviceCommandId_t foundId = 0xFFFFFFFF; - uint32_t foundLen = 0; + size_t foundLen = 0; ReturnValue_t result; if (cookieInfo.state != COOKIE_READ_SENT) { @@ -639,8 +636,8 @@ void DeviceHandlerBase::doGetRead() { } ReturnValue_t DeviceHandlerBase::getStorageData(store_address_t storageAddress, - uint8_t * *data, uint32_t * len) { - uint32_t lenTmp; + uint8_t ** data, size_t * len) { + size_t lenTmp; if (IPCStore == NULL) { *data = NULL; @@ -751,20 +748,20 @@ void DeviceHandlerBase::handleReply(const uint8_t* receivedData, } } -ReturnValue_t DeviceHandlerBase::switchCookieChannel(object_id_t newChannelId) { - DeviceCommunicationIF *newCommunication = objectManager->get< - DeviceCommunicationIF>(newChannelId); - - if (newCommunication != NULL) { - ReturnValue_t result = newCommunication->reOpen(cookie, logicalAddress, - maxDeviceReplyLen, comParameter1, comParameter2); - if (result != RETURN_OK) { - return result; - } - return RETURN_OK; - } - return RETURN_FAILED; -} +//ReturnValue_t DeviceHandlerBase::switchCookieChannel(object_id_t newChannelId) { +// DeviceCommunicationIF *newCommunication = objectManager->get< +// DeviceCommunicationIF>(newChannelId); +// +// if (newCommunication != NULL) { +// ReturnValue_t result = newCommunication->reOpen(cookie, logicalAddress, +// maxDeviceReplyLen, comParameter1, comParameter2); +// if (result != RETURN_OK) { +// return result; +// } +// return RETURN_OK; +// } +// return RETURN_FAILED; +//} void DeviceHandlerBase::buildRawDeviceCommand(CommandMessage* commandMessage) { storedRawData = DeviceHandlerMessage::getStoreAddress(commandMessage); @@ -1048,12 +1045,13 @@ ReturnValue_t DeviceHandlerBase::handleDeviceHandlerMessage( } replyReturnvalueToCommand(RETURN_OK); return RETURN_OK; - case DeviceHandlerMessage::CMD_SWITCH_IOBOARD: + case DeviceHandlerMessage::CMD_SWITCH_ADDRESS: if (mode != MODE_OFF) { replyReturnvalueToCommand(WRONG_MODE_FOR_COMMAND); } else { - result = switchCookieChannel( - DeviceHandlerMessage::getIoBoardObjectId(message)); + // rework in progress + //result = switchCookieChannel( + // DeviceHandlerMessage::getIoBoardObjectId(message)); if (result == RETURN_OK) { replyReturnvalueToCommand(RETURN_OK); } else { diff --git a/devicehandlers/DeviceHandlerBase.h b/devicehandlers/DeviceHandlerBase.h index 868412ed..e9288921 100644 --- a/devicehandlers/DeviceHandlerBase.h +++ b/devicehandlers/DeviceHandlerBase.h @@ -29,7 +29,7 @@ void setStaticFrameworkObjectIds(); class StorageManagerIF; /** - * \defgroup devices Devices + * @defgroup devices Devices * Contains all devices and the DeviceHandlerBase class. */ @@ -93,12 +93,11 @@ public: * @param fdirInstance * @param cmdQueueSize */ - DeviceHandlerBase(address_t logicalAddress, object_id_t setObjectId, - uint32_t maxDeviceReplyLen, uint8_t setDeviceSwitch, - object_id_t deviceCommunication, - uint32_t thermalStatePoolId = PoolVariableIF::NO_PARAMETER, + DeviceHandlerBase(object_id_t setObjectId, address_t logicalAddress_, + object_id_t deviceCommunication, Cookie* cookie_, size_t maxReplyLen, + uint8_t setDeviceSwitch, uint32_t thermalStatePoolId = PoolVariableIF::NO_PARAMETER, uint32_t thermalRequestPoolId = PoolVariableIF::NO_PARAMETER, - FailureIsolationBase* fdirInstance = NULL, uint32_t cmdQueueSize = 20); + FailureIsolationBase* fdirInstance = nullptr, size_t cmdQueueSize = 20); /** * @brief This function is the device handler base core component and is called periodically. @@ -283,8 +282,8 @@ protected: * - @c DeviceHandlerIF::IGNORE_FULL_PACKET Ignore the packet * - @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, - DeviceCommandId_t *foundId, uint32_t *foundLen) = 0; + virtual ReturnValue_t scanForReply(const uint8_t *start, size_t len, + DeviceCommandId_t *foundId, size_t *foundLen) = 0; /** * @brief Interpret a reply from the device. @@ -412,11 +411,16 @@ protected: /** * Pointer to the raw packet that will be sent. */ - uint8_t *rawPacket; + uint8_t *rawPacket = nullptr; /** * Size of the #rawPacket. */ - uint32_t rawPacketLen; + size_t rawPacketLen = 0; + + /** + * Size of data to request. + */ + size_t requestLen = 0; // /** // * This union (or std::variant) type can be used to set comParameters which @@ -431,8 +435,8 @@ protected: // * 4 bytes of parameters AND a store ID. // */ // comParameters_t comParameters; - uint32_t comParameter1 = 0; - uint32_t comParameter2 = 0; + // uint32_t comParameter1 = 0; + // uint32_t comParameter2 = 0; /** * The mode the device handler is currently in. @@ -451,12 +455,12 @@ protected: /** * This is the counter value from performOperation(). */ - uint8_t pstStep; + uint8_t pstStep = 0; /** * This will be used in the RMAP getRead command as expected length, is set by the constructor, can be modiefied at will. */ - const uint32_t maxDeviceReplyLen; + const uint32_t maxDeviceReplyLen = 0; /** * wiretapping flag: @@ -474,7 +478,7 @@ protected: * Statically initialized in initialize() to a configurable object. Used when there is no method * of finding a recipient, ie raw mode and reporting erreonous replies */ - MessageQueueId_t defaultRawReceiver; + MessageQueueId_t defaultRawReceiver = 0; store_address_t storedRawData; @@ -483,19 +487,19 @@ protected: * * if #isWiretappingActive all raw communication from and to the device will be sent to this queue */ - MessageQueueId_t requestedRawTraffic; + MessageQueueId_t requestedRawTraffic = 0; /** * the object used to set power switches */ - PowerSwitchIF *powerSwitcher; + PowerSwitchIF *powerSwitcher = nullptr; /** * Pointer to the IPCStore. * * This caches the pointer received from the objectManager in the constructor. */ - StorageManagerIF *IPCStore; + StorageManagerIF *IPCStore = nullptr; /** * cached for init @@ -505,7 +509,7 @@ protected: /** * Communication object used for device communication */ - DeviceCommunicationIF *communicationInterface; + DeviceCommunicationIF *communicationInterface = nullptr; /** * Cookie used for communication. This is passed to the communication @@ -516,7 +520,7 @@ protected: /** * The MessageQueue used to receive device handler commands and to send replies. */ - MessageQueueIF* commandQueue; + MessageQueueIF* commandQueue = nullptr; /** * this is the datapool variable with the thermal state of the device @@ -545,9 +549,9 @@ protected: * Optional Error code * Can be set in doStartUp(), doShutDown() and doTransition() to signal cause for Transition failure. */ - ReturnValue_t childTransitionFailure; + ReturnValue_t childTransitionFailure = RETURN_OK; - uint32_t ignoreMissedRepliesCount; //!< Counts if communication channel lost a reply, so some missed replys can be ignored. + uint32_t ignoreMissedRepliesCount = 0; //!< Counts if communication channel lost a reply, so some missed replys can be ignored. FailureIsolationBase* fdirInstance; //!< Pointer to the used FDIR instance. If not provided by child, default class is instantiated. @@ -962,7 +966,7 @@ private: * * Set when setMode() is called. */ - uint32_t timeoutStart; + uint32_t timeoutStart = 0; /** * Delay for the current mode transition, used for time out @@ -1084,8 +1088,8 @@ private: * - @c RETURN_FAILED IPCStore is NULL * - the return value from the IPCStore if it was not @c RETURN_OK */ - ReturnValue_t getStorageData(store_address_t storageAddress, uint8_t **data, - uint32_t *len); + ReturnValue_t getStorageData(store_address_t storageAddress, + uint8_t ** data, size_t * len); /** * set all switches returned by getSwitches() @@ -1114,7 +1118,7 @@ private: * - @c RETURN_FAILED when cookies could not be changed, eg because the newChannel is not enabled * - @c returnvalues of RMAPChannelIF::isActive() */ - ReturnValue_t switchCookieChannel(object_id_t newChannelId); + //ReturnValue_t switchCookieChannel(object_id_t newChannelId); /** * Handle device handler messages (e.g. commands sent by PUS Service 2) diff --git a/devicehandlers/DeviceHandlerMessage.cpp b/devicehandlers/DeviceHandlerMessage.cpp index 58a6d312..97abcac5 100644 --- a/devicehandlers/DeviceHandlerMessage.cpp +++ b/devicehandlers/DeviceHandlerMessage.cpp @@ -47,7 +47,7 @@ void DeviceHandlerMessage::setDeviceHandlerWiretappingMessage( void DeviceHandlerMessage::setDeviceHandlerSwitchIoBoardMessage( CommandMessage* message, uint32_t ioBoardIdentifier) { - message->setCommand(CMD_SWITCH_IOBOARD); + message->setCommand(CMD_SWITCH_ADDRESS); message->setParameter(ioBoardIdentifier); } @@ -90,7 +90,7 @@ void DeviceHandlerMessage::clear(CommandMessage* message) { } } /* NO BREAK falls through*/ - case CMD_SWITCH_IOBOARD: + case CMD_SWITCH_ADDRESS: case CMD_WIRETAPPING: message->setCommand(CommandMessage::CMD_NONE); message->setParameter(0); diff --git a/devicehandlers/DeviceHandlerMessage.h b/devicehandlers/DeviceHandlerMessage.h index fad0f1b1..c91bb0a4 100644 --- a/devicehandlers/DeviceHandlerMessage.h +++ b/devicehandlers/DeviceHandlerMessage.h @@ -28,7 +28,7 @@ public: static const uint8_t MESSAGE_ID = MESSAGE_TYPE::DEVICE_HANDLER_COMMAND; static const Command_t CMD_RAW = MAKE_COMMAND_ID( 1 ); //!< Sends a raw command, setParameter is a ::store_id_t containing the raw packet to send // static const Command_t CMD_DIRECT = MAKE_COMMAND_ID( 2 ); //!< Sends a direct command, setParameter is a ::DeviceCommandId_t, setParameter2 is a ::store_id_t containing the data needed for the command - static const Command_t CMD_SWITCH_IOBOARD = MAKE_COMMAND_ID( 3 ); //!< Requests a IO-Board switch, setParameter() is the IO-Board identifier + static const Command_t CMD_SWITCH_ADDRESS = MAKE_COMMAND_ID( 3 ); //!< Requests a IO-Board switch, setParameter() is the IO-Board identifier static const Command_t CMD_WIRETAPPING = MAKE_COMMAND_ID( 4 ); //!< (De)Activates the monitoring of all raw traffic in DeviceHandlers, setParameter is 0 to deactivate, 1 to activate /*static const Command_t REPLY_SWITCHED_IOBOARD = MAKE_COMMAND_ID(1 );//!< Reply to a @c CMD_SWITCH_IOBOARD, indicates switch was successful, getParameter() contains the board switched to (0: nominal, 1: redundant) diff --git a/memory/MemoryHelper.cpp b/memory/MemoryHelper.cpp index 4905875e..9bebb597 100644 --- a/memory/MemoryHelper.cpp +++ b/memory/MemoryHelper.cpp @@ -152,7 +152,7 @@ void MemoryHelper::handleMemoryLoad(CommandMessage* message) { ipcAddress = MemoryMessage::getStoreID(message); const uint8_t* p_data = NULL; uint8_t* dataPointer = NULL; - uint32_t size = 0; + size_t size = 0; ReturnValue_t returnCode = ipcStore->getData(ipcAddress, &p_data, &size); if (returnCode == RETURN_OK) { returnCode = workOnThis->handleMemoryLoad(address, p_data, size, diff --git a/osal/FreeRTOS/BinarySemaphore.cpp b/osal/FreeRTOS/BinarySemaphore.cpp index d429f1a0..4ec61ff7 100644 --- a/osal/FreeRTOS/BinarySemaphore.cpp +++ b/osal/FreeRTOS/BinarySemaphore.cpp @@ -11,7 +11,7 @@ #include "task.h" BinarySemaphore::BinarySemaphore() { - vSemaphoreCreateBinary(handle); + xSemaphoreCreateBinary(handle); // @suppress("Function cannot be resolved") if(handle == NULL) { error << "Binary semaphore creation failure" << std::endl; } @@ -81,7 +81,7 @@ ReturnValue_t BinarySemaphore::giveBinarySemaphore(SemaphoreHandle_t semaphore) void BinarySemaphore::resetSemaphore() { vSemaphoreDelete(handle); - vSemaphoreCreateBinary(handle); + xSemaphoreCreateBinary(handle); } ReturnValue_t BinarySemaphore::giveBinarySemaphoreFromISR(SemaphoreHandle_t semaphore, diff --git a/parameters/ParameterHelper.cpp b/parameters/ParameterHelper.cpp index 6ebc9e62..e260465a 100644 --- a/parameters/ParameterHelper.cpp +++ b/parameters/ParameterHelper.cpp @@ -37,7 +37,7 @@ ReturnValue_t ParameterHelper::handleParameterMessage(CommandMessage *message) { ParameterMessage::getParameterId(message)); const uint8_t *storedStream; - uint32_t storedStreamSize; + size_t storedStreamSize; result = storage->getData( ParameterMessage::getStoreId(message), &storedStream, &storedStreamSize); diff --git a/storagemanager/LocalPool.h b/storagemanager/LocalPool.h index f6d5ba8a..c2fab82b 100644 --- a/storagemanager/LocalPool.h +++ b/storagemanager/LocalPool.h @@ -100,7 +100,7 @@ public: * @return @c RETURN_OK if data retrieval was successfull */ ReturnValue_t getData(store_address_t packet_id, const uint8_t** packet_ptr, - uint32_t* size); + size_t * size); /** * Modify data by supplying a packet pointer and using that packet pointer @@ -111,7 +111,7 @@ public: * @return */ ReturnValue_t modifyData(store_address_t packet_id, uint8_t** packet_ptr, - uint32_t* size); + size_t * size); virtual ReturnValue_t deleteData(store_address_t); virtual ReturnValue_t deleteData(uint8_t* ptr, uint32_t size, store_address_t* storeId = NULL); @@ -348,7 +348,7 @@ inline ReturnValue_t LocalPool::getFreeElement( template inline ReturnValue_t LocalPool::getData( - store_address_t packet_id, const uint8_t** packet_ptr, uint32_t* size) { + store_address_t packet_id, const uint8_t** packet_ptr, size_t * size) { uint8_t* tempData = NULL; ReturnValue_t status = modifyData(packet_id, &tempData, size); *packet_ptr = tempData; @@ -357,7 +357,7 @@ inline ReturnValue_t LocalPool::getData( template inline ReturnValue_t LocalPool::modifyData(store_address_t packet_id, - uint8_t** packet_ptr, uint32_t* size) { + uint8_t** packet_ptr, size_t * size) { ReturnValue_t status = RETURN_FAILED; if (packet_id.pool_index >= NUMBER_OF_POOLS) { return ILLEGAL_STORAGE_ID; diff --git a/storagemanager/StorageManagerIF.h b/storagemanager/StorageManagerIF.h index 575e9caa..e8d8b413 100644 --- a/storagemanager/StorageManagerIF.h +++ b/storagemanager/StorageManagerIF.h @@ -125,12 +125,12 @@ public: * (e.g. an illegal packet_id was passed). */ virtual ReturnValue_t getData(store_address_t packet_id, - const uint8_t** packet_ptr, uint32_t* size) = 0; + const uint8_t** packet_ptr, size_t * size) = 0; /** * Same as above, but not const and therefore modifiable. */ virtual ReturnValue_t modifyData(store_address_t packet_id, - uint8_t** packet_ptr, uint32_t* size) = 0; + uint8_t** packet_ptr, size_t * size) = 0; /** * This method reserves an element of \c size. * diff --git a/subsystem/Subsystem.cpp b/subsystem/Subsystem.cpp index e1ec544b..2d7d9c44 100644 --- a/subsystem/Subsystem.cpp +++ b/subsystem/Subsystem.cpp @@ -162,7 +162,7 @@ ReturnValue_t Subsystem::handleCommandMessage(CommandMessage* message) { case ModeSequenceMessage::ADD_SEQUENCE: { FixedArrayList sequence; const uint8_t *pointer; - uint32_t sizeRead; + size_t sizeRead; result = IPCStore->getData( ModeSequenceMessage::getStoreAddress(message), &pointer, &sizeRead); @@ -188,7 +188,7 @@ ReturnValue_t Subsystem::handleCommandMessage(CommandMessage* message) { case ModeSequenceMessage::ADD_TABLE: { FixedArrayList table; const uint8_t *pointer; - uint32_t sizeRead; + size_t sizeRead; result = IPCStore->getData( ModeSequenceMessage::getStoreAddress(message), &pointer, &sizeRead); diff --git a/tcdistribution/CCSDSDistributor.cpp b/tcdistribution/CCSDSDistributor.cpp index ecd7702e..878b8f7d 100644 --- a/tcdistribution/CCSDSDistributor.cpp +++ b/tcdistribution/CCSDSDistributor.cpp @@ -13,7 +13,7 @@ CCSDSDistributor::~CCSDSDistributor() { iterator_t CCSDSDistributor::selectDestination() { // debug << "CCSDSDistributor::selectDestination received: " << this->currentMessage.getStorageId().pool_index << ", " << this->currentMessage.getStorageId().packet_index << std::endl; const uint8_t* p_packet = NULL; - uint32_t size = 0; + size_t size = 0; //TODO check returncode? this->tcStore->getData( this->currentMessage.getStorageId(), &p_packet, &size ); SpacePacketBase current_packet( p_packet ); diff --git a/tmtcpacket/pus/TcPacketStored.cpp b/tmtcpacket/pus/TcPacketStored.cpp index 1f31a763..4bfd0e37 100644 --- a/tmtcpacket/pus/TcPacketStored.cpp +++ b/tmtcpacket/pus/TcPacketStored.cpp @@ -59,7 +59,7 @@ bool TcPacketStored::checkAndSetStore() { void TcPacketStored::setStoreAddress(store_address_t setAddress) { this->storeAddress = setAddress; const uint8_t* temp_data = NULL; - uint32_t temp_size; + size_t temp_size; ReturnValue_t status = StorageManagerIF::RETURN_FAILED; if (this->checkAndSetStore()) { status = this->store->getData(this->storeAddress, &temp_data, @@ -79,7 +79,7 @@ store_address_t TcPacketStored::getStoreAddress() { bool TcPacketStored::isSizeCorrect() { const uint8_t* temp_data = NULL; - uint32_t temp_size; + size_t temp_size; ReturnValue_t status = this->store->getData(this->storeAddress, &temp_data, &temp_size); if (status == StorageManagerIF::RETURN_OK) { diff --git a/tmtcpacket/pus/TmPacketStored.cpp b/tmtcpacket/pus/TmPacketStored.cpp index b1c1ec62..bb932641 100644 --- a/tmtcpacket/pus/TmPacketStored.cpp +++ b/tmtcpacket/pus/TmPacketStored.cpp @@ -82,7 +82,7 @@ void TmPacketStored::deletePacket() { void TmPacketStored::setStoreAddress(store_address_t setAddress) { storeAddress = setAddress; const uint8_t* temp_data = NULL; - uint32_t temp_size; + size_t temp_size; if (!checkAndSetStore()) { return; } diff --git a/tmtcservices/TmTcBridge.cpp b/tmtcservices/TmTcBridge.cpp index e402d79e..6b563f98 100644 --- a/tmtcservices/TmTcBridge.cpp +++ b/tmtcservices/TmTcBridge.cpp @@ -76,7 +76,7 @@ ReturnValue_t TmTcBridge::handleTm() { ReturnValue_t TmTcBridge::readTmQueue() { TmTcMessage message; const uint8_t* data = NULL; - uint32_t size = 0; + size_t size = 0; for (ReturnValue_t result = TmTcReceptionQueue->receiveMessage(&message); result == RETURN_OK; result = TmTcReceptionQueue->receiveMessage(&message)) { @@ -127,7 +127,7 @@ ReturnValue_t TmTcBridge::sendStoredTm() { << (int) fifo.size() << " left to send" << std::endl; store_address_t storeId; const uint8_t* data = NULL; - uint32_t size = 0; + size_t size = 0; fifo.retrieve(&storeId); result = tmStore->getData(storeId, &data, &size); sendTm(data,size);