imrpoved form, removed comm msg for now

This commit is contained in:
Robin Müller 2020-10-12 18:12:26 +02:00
parent 736ce2d5fd
commit afe5a62789
15 changed files with 46 additions and 414 deletions

View File

@ -1,5 +1,5 @@
#ifndef FRAMEWORK_DEVICEHANDLERS_ACCEPTSDEVICERESPONSESIF_H_
#define FRAMEWORK_DEVICEHANDLERS_ACCEPTSDEVICERESPONSESIF_H_
#ifndef FSFW_DEVICEHANDLERS_ACCEPTSDEVICERESPONSESIF_H_
#define FSFW_DEVICEHANDLERS_ACCEPTSDEVICERESPONSESIF_H_
#include "../ipc/MessageQueueSenderIF.h"
@ -16,4 +16,4 @@ public:
virtual MessageQueueId_t getDeviceQueue() = 0;
};
#endif /* FRAMEWORK_DEVICEHANDLERS_ACCEPTSDEVICERESPONSESIF_H_ */
#endif /* FSFW_DEVICEHANDLERS_ACCEPTSDEVICERESPONSESIF_H_ */

View File

@ -1,4 +1,4 @@
#include "../devicehandlers/AssemblyBase.h"
#include "AssemblyBase.h"
AssemblyBase::AssemblyBase(object_id_t objectId, object_id_t parentId,
uint16_t commandQueueDepth) :

View File

@ -1,8 +1,8 @@
#ifndef FRAMEWORK_DEVICEHANDLERS_ASSEMBLYBASE_H_
#define FRAMEWORK_DEVICEHANDLERS_ASSEMBLYBASE_H_
#ifndef FSFW_DEVICEHANDLERS_ASSEMBLYBASE_H_
#define FSFW_DEVICEHANDLERS_ASSEMBLYBASE_H_
#include "DeviceHandlerBase.h"
#include "../container/FixedArrayList.h"
#include "../devicehandlers/DeviceHandlerBase.h"
#include "../subsystem/SubsystemBase.h"
/**
@ -156,8 +156,9 @@ protected:
* Also sets state to STATE_OVERWRITE_HEATH.
* @param objectId Must be a registered child.
*/
void overwriteDeviceHealth(object_id_t objectId, HasHealthIF::HealthState oldHealth);
void overwriteDeviceHealth(object_id_t objectId,
HasHealthIF::HealthState oldHealth);
};
#endif /* FRAMEWORK_DEVICEHANDLERS_ASSEMBLYBASE_H_ */
#endif /* FSFW_DEVICEHANDLERS_ASSEMBLYBASE_H_ */

View File

@ -1,5 +1,5 @@
#include "ChildHandlerBase.h"
#include "../subsystem/SubsystemBase.h"
#include "../devicehandlers/ChildHandlerBase.h"
#include "../subsystem/SubsystemBase.h"
ChildHandlerBase::ChildHandlerBase(object_id_t setObjectId,

View File

@ -1,8 +1,8 @@
#ifndef PAYLOADHANDLERBASE_H_
#define PAYLOADHANDLERBASE_H_
#ifndef FSFW_DEVICEHANDLER_CHILDHANDLERBASE_H_
#define FSFW_DEVICEHANDLER_CHILDHANDLERBASE_H_
#include "../devicehandlers/ChildHandlerFDIR.h"
#include "../devicehandlers/DeviceHandlerBase.h"
#include "DeviceHandlerBase.h"
#include "ChildHandlerFDIR.h"
class ChildHandlerBase: public DeviceHandlerBase {
public:
@ -10,7 +10,9 @@ public:
CookieIF * cookie, object_id_t hkDestination,
uint32_t thermalStatePoolId, uint32_t thermalRequestPoolId,
object_id_t parent = objects::NO_OBJECT,
FailureIsolationBase* customFdir = nullptr, size_t cmdQueueSize = 20);
FailureIsolationBase* customFdir = nullptr,
size_t cmdQueueSize = 20);
virtual ~ChildHandlerBase();
virtual ReturnValue_t initialize();
@ -21,4 +23,4 @@ protected:
};
#endif /* PAYLOADHANDLERBASE_H_ */
#endif /* FSFW_DEVICEHANDLER_CHILDHANDLERBASE_H_ */

View File

@ -1,6 +1,7 @@
#include "../devicehandlers/ChildHandlerFDIR.h"
#include "ChildHandlerFDIR.h"
ChildHandlerFDIR::ChildHandlerFDIR(object_id_t owner, object_id_t faultTreeParent, uint32_t recoveryCount) :
ChildHandlerFDIR::ChildHandlerFDIR(object_id_t owner,
object_id_t faultTreeParent, uint32_t recoveryCount) :
DeviceHandlerFailureIsolation(owner, faultTreeParent) {
recoveryCounter.setFailureThreshold(recoveryCount);
}

View File

@ -1,7 +1,7 @@
#ifndef FRAMEWORK_DEVICEHANDLERS_CHILDHANDLERFDIR_H_
#define FRAMEWORK_DEVICEHANDLERS_CHILDHANDLERFDIR_H_
#ifndef FSFW_DEVICEHANDLERS_CHILDHANDLERFDIR_H_
#define FSFW_DEVICEHANDLERS_CHILDHANDLERFDIR_H_
#include "../devicehandlers/DeviceHandlerFailureIsolation.h"
#include "DeviceHandlerFailureIsolation.h"
/**
* Very simple extension to normal FDIR.

View File

@ -1,201 +0,0 @@
/**
* @file CommunicationMessage.cpp
*
* @date 28.02.2020
*/
#include "../devicehandlers/CommunicationMessage.h"
#include "../serviceinterface/ServiceInterfaceStream.h"
#include <cstring>
CommunicationMessage::CommunicationMessage(): uninitialized(true) {
}
CommunicationMessage::~CommunicationMessage() {}
void CommunicationMessage::setSendRequestFromPointer(uint32_t address,
uint32_t dataLen, const uint8_t * data) {
setMessageType(SEND_DATA_FROM_POINTER);
setAddress(address);
setDataLen(dataLen);
setDataPointer(data);
}
void CommunicationMessage::setSendRequestFromIpcStore(uint32_t address, store_address_t storeId) {
setMessageType(SEND_DATA_FROM_IPC_STORE);
setAddress(address);
setStoreId(storeId.raw);
}
void CommunicationMessage::setSendRequestRaw(uint32_t address, uint32_t length,
uint16_t sendBufferPosition) {
setMessageType(SEND_DATA_RAW);
setAddress(address);
setDataLen(length);
if(sendBufferPosition != 0) {
setBufferPosition(sendBufferPosition);
}
}
void CommunicationMessage::setDataReplyFromIpcStore(uint32_t address, store_address_t storeId) {
setMessageType(REPLY_DATA_IPC_STORE);
setAddress(address);
setStoreId(storeId.raw);
}
void CommunicationMessage::setDataReplyFromPointer(uint32_t address,
uint32_t dataLen, uint8_t *data) {
setMessageType(REPLY_DATA_FROM_POINTER);
setAddress(address);
setDataLen(dataLen);
setDataPointer(data);
}
void CommunicationMessage::setDataReplyRaw(uint32_t address,
uint32_t length, uint16_t receiveBufferPosition) {
setMessageType(REPLY_DATA_RAW);
setAddress(address);
setDataLen(length);
if(receiveBufferPosition != 0) {
setBufferPosition(receiveBufferPosition);
}
}
void CommunicationMessage::setMessageType(messageType status) {
uint8_t status_uint8 = status;
memcpy(getData() + sizeof(uint32_t), &status_uint8, sizeof(status_uint8));
}
void CommunicationMessage::setAddress(address_t address) {
memcpy(getData(),&address,sizeof(address));
}
address_t CommunicationMessage::getAddress() const {
address_t address;
memcpy(&address,getData(),sizeof(address));
return address;
}
void CommunicationMessage::setBufferPosition(uint16_t bufferPosition) {
memcpy(getData() + sizeof(uint32_t) + sizeof(uint16_t),
&bufferPosition, sizeof(bufferPosition));
}
uint16_t CommunicationMessage::getBufferPosition() const {
uint16_t bufferPosition;
memcpy(&bufferPosition,
getData() + sizeof(uint32_t) + sizeof(uint16_t), sizeof(bufferPosition));
return bufferPosition;
}
void CommunicationMessage::setDataPointer(const void * data) {
memcpy(getData() + 3 * sizeof(uint32_t), &data, sizeof(uint32_t));
}
void CommunicationMessage::setStoreId(store_address_t storeId) {
memcpy(getData() + 2 * sizeof(uint32_t), &storeId.raw, sizeof(uint32_t));
}
store_address_t CommunicationMessage::getStoreId() const{
store_address_t temp;
memcpy(&temp.raw,getData() + 2 * sizeof(uint32_t), sizeof(uint32_t));
return temp;
}
void CommunicationMessage::setDataLen(uint32_t length) {
memcpy(getData() + 2 * sizeof(uint32_t), &length, sizeof(length));
}
uint32_t CommunicationMessage::getDataLen() const {
uint32_t len;
memcpy(&len, getData() + 2 * sizeof(uint32_t), sizeof(len));
return len;
}
void CommunicationMessage::setUint32Data(uint32_t data) {
memcpy(getData() + 3 * sizeof(uint32_t), &data, sizeof(data));
}
uint32_t CommunicationMessage::getUint32Data() const{
uint32_t data;
memcpy(&data,getData() + 3 * sizeof(uint32_t), sizeof(data));
return data;
}
void CommunicationMessage::setDataByte(uint8_t byte, uint8_t position) {
if(position <= 3) {
memcpy(getData() + 3 * sizeof(uint32_t) + position * sizeof(uint8_t), &byte, sizeof(byte));
}
else {
sif::error << "Comm Message: Invalid byte position" << std::endl;
}
}
uint8_t CommunicationMessage::getDataByte(uint8_t position) const {
if(position <= 3) {
uint8_t byte;
memcpy(&byte, getData() + 3 * sizeof(uint32_t) + position * sizeof(uint8_t), sizeof(byte));
return byte;
}
else {
return 0;
sif::error << "Comm Message: Invalid byte position" << std::endl;
}
}
void CommunicationMessage::setDataUint16(uint16_t data, uint8_t position) {
if(position == 0 || position == 1) {
memcpy(getData() + 3 * sizeof(uint32_t) + position * sizeof(uint16_t), &data, sizeof(data));
}
else {
sif::error << "Comm Message: Invalid byte position" << std::endl;
}
}
uint16_t CommunicationMessage::getDataUint16(uint8_t position) const{
if(position == 0 || position == 1) {
uint16_t data;
memcpy(&data, getData() + 3 * sizeof(uint32_t) + position * sizeof(uint16_t), sizeof(data));
return data;
}
else {
return 0;
sif::error << "Comm Message: Invalid byte position" << std::endl;
}
}
CommunicationMessage::messageType CommunicationMessage::getMessageType() const{
messageType messageType;
memcpy(&messageType, getData() + sizeof(uint32_t),sizeof(uint8_t));
return messageType;
}
void CommunicationMessage::setMessageId(uint8_t messageId) {
memcpy(getData() + sizeof(uint32_t) + sizeof(uint8_t), &messageId, sizeof(messageId));
}
uint8_t CommunicationMessage::getMessageId() const {
uint8_t messageId;
memcpy(&messageId, getData() + sizeof(uint32_t) + sizeof(uint8_t), sizeof(messageId));
return messageId;
}
void CommunicationMessage::clearCommunicationMessage() {
messageType messageType = getMessageType();
switch(messageType) {
case(messageType::REPLY_DATA_IPC_STORE):
case(messageType::SEND_DATA_FROM_IPC_STORE): {
store_address_t storeId = getStoreId();
StorageManagerIF *ipcStore = objectManager->
get<StorageManagerIF>(objects::IPC_STORE);
if (ipcStore != NULL) {
ipcStore->deleteData(storeId);
}
}
/* NO BREAK falls through*/
default:
memset(getData(),0,4*sizeof(uint32_t));
break;
}
}

View File

@ -1,173 +0,0 @@
/**
* @file CommunicationMessage.h
*
* @date 28.02.2020
*/
#ifndef FRAMEWORK_DEVICEHANDLERS_COMMUNICATIONMESSAGE_H_
#define FRAMEWORK_DEVICEHANDLERS_COMMUNICATIONMESSAGE_H_
#include "../devicehandlers/CommunicationMessage.h"
#include "../ipc/MessageQueueMessage.h"
#include "../storagemanager/StorageManagerIF.h"
#include "../devicehandlers/DeviceHandlerBase.h"
/**
* @brief Message type to send larger messages
*
* @details
* Can be used to pass information like data pointers and
* data sizes between communication tasks.
*
*/
class CommunicationMessage: public MessageQueueMessage {
public:
enum messageType {
NONE,
SEND_DATA_FROM_POINTER,
SEND_DATA_FROM_IPC_STORE,
SEND_DATA_RAW,
REPLY_DATA_FROM_POINTER,
REPLY_DATA_IPC_STORE,
REPLY_DATA_RAW,
FAULTY,
};
//Add other messageIDs here if necessary.
static const uint8_t COMMUNICATION_MESSAGE_SIZE = HEADER_SIZE + 4 * sizeof(uint32_t);
CommunicationMessage();
virtual ~CommunicationMessage();
/**
* Message Type is stored as the fifth byte of the message data
* @param status
*/
void setMessageType(messageType status);
messageType getMessageType() const;
/**
* This is a unique ID which can be used to handle different kinds of messages.
* For example, the same interface (e.g. SPI) could be used to exchange raw data
* (e.g. sensor values) and data stored in the IPC store.
* The ID can be used to distinguish the messages in child implementations.
* The message ID is stored as the sixth byte of the message data.
* @param messageId
*/
void setMessageId(uint8_t messageId);
uint8_t getMessageId() const;
/**
* Send requests with pointer to the data to be sent and send data length
* @param address Target Address, first four bytes
* @param dataLen Length of data to send, next four bytes
* @param data Pointer to data to send
*
*/
void setSendRequestFromPointer(uint32_t address, uint32_t dataLen, const uint8_t * data);
/**
* Send requests with a store ID, using the IPC store
* @param address Target Address, first four bytes
* @param storeId Store ID in the IPC store
*
*/
void setSendRequestFromIpcStore(uint32_t address, store_address_t storeId);
/**
* Send requests with data length and data in message (max. 4 bytes)
* @param address Target Address, first four bytes
* @param dataLen Length of data to send, next four bytes
* @param data Pointer to data to send
*
*/
void setSendRequestRaw(uint32_t address, uint32_t length,
uint16_t sendBufferPosition = 0);
/**
* Data message with data stored in IPC store
* @param address Target Address, first four bytes
* @param length
* @param storeId
*/
void setDataReplyFromIpcStore(uint32_t address, store_address_t storeId);
/**
* Data reply with data stored in buffer, passing the pointer to
* the buffer and the data size
* @param address Target Address, first four bytes
* @param dataLen Length of data to send, next four bytes
* @param data Pointer to the data
*/
void setDataReplyFromPointer(uint32_t address, uint32_t dataLen, uint8_t * data);
/**
* Data message with data stored in actual message.
* 4 byte datafield is intialized with 0.
* Set data with specific setter functions below.
* Can also be used to supply information at which position the raw data should be stored
* in a receive buffer.
*/
void setDataReplyRaw(uint32_t address, uint32_t length, uint16_t receiveBufferPosition = 0);
/**
* First four bytes of message data
* @param address
*/
void setAddress(address_t address);
address_t getAddress() const;
/**
* Set byte as position of 4 byte data field
* @param byte
* @param position Position, 0 to 3 possible
*/
void setDataByte(uint8_t byte, uint8_t position);
uint8_t getDataByte(uint8_t position) const;
/**
* Set 2 byte value at position 1 or 2 of data field
* @param data
* @param position 0 or 1 possible
*/
void setDataUint16(uint16_t data, uint8_t position);
uint16_t getDataUint16(uint8_t position) const;
void setUint32Data(uint32_t data);
uint32_t getUint32Data() const;
/**
* Stored in Bytes 13-16 of message data
* @param length
*/
void setDataLen(uint32_t length);
uint32_t getDataLen() const;
/**
* Stored in last four bytes (Bytes 17-20) of message data
* @param sendData
*/
void setDataPointer(const void * data);
/**
* In case the send request data or reply data is to be stored in a buffer,
* a buffer Position can be stored here as the seventh and eigth byte of
* the message, so the receive buffer can't be larger than sizeof(uint16_t) for now.
* @param bufferPosition In case the data is stored in a buffer, the position can be supplied here
*/
void setBufferPosition(uint16_t bufferPosition);
uint16_t getBufferPosition() const;
void setStoreId(store_address_t storeId);
store_address_t getStoreId() const;
/**
* Clear the message. Deletes IPC Store data
* and sets all data to 0. Also sets message type to NONE
*/
void clearCommunicationMessage();
private:
bool uninitialized; //!< Could be used to warn if data has not been set.
};
#endif /* FRAMEWORK_DEVICEHANDLERS_COMMUNICATIONMESSAGE_H_ */

View File

@ -1,11 +1,12 @@
#ifndef COOKIE_H_
#define COOKIE_H_
#ifndef FSFW_DEVICEHANDLER_COOKIE_H_
#define FSFW_DEVICEHANDLER_COOKIE_H_
#include <cstdint>
/**
* @brief Physical address type
*/
typedef std::uint32_t address_t;
using address_t = uint32_t;
/**
* @brief This datatype is used to identify different connection over a
@ -30,4 +31,4 @@ public:
virtual ~CookieIF() {};
};
#endif /* COOKIE_H_ */
#endif /* FSFW_DEVICEHANDLER_COOKIE_H_ */

View File

@ -1,8 +1,9 @@
#ifndef FRAMEWORK_DEVICES_DEVICECOMMUNICATIONIF_H_
#define FRAMEWORK_DEVICES_DEVICECOMMUNICATIONIF_H_
#ifndef FSFW_DEVICES_DEVICECOMMUNICATIONIF_H_
#define FSFW_DEVICES_DEVICECOMMUNICATIONIF_H_
#include "CookieIF.h"
#include "DeviceHandlerIF.h"
#include "../devicehandlers/CookieIF.h"
#include "../devicehandlers/DeviceHandlerIF.h"
#include "../returnvalues/HasReturnvaluesIF.h"
/**
* @defgroup interfaces Interfaces
@ -124,4 +125,4 @@ public:
uint8_t **buffer, size_t *size) = 0;
};
#endif /* DEVICECOMMUNICATIONIF_H_ */
#endif /* FSFW_DEVICES_DEVICECOMMUNICATIONIF_H_ */

View File

@ -1,5 +1,4 @@
#include "../serialize/SerializeAdapter.h"
#include "../devicehandlers/DeviceTmReportingWrapper.h"
#include "DeviceTmReportingWrapper.h"
#include "../serialize/SerializeAdapter.h"
DeviceTmReportingWrapper::DeviceTmReportingWrapper(object_id_t objectId,

View File

@ -1,5 +1,5 @@
#ifndef DEVICETMREPORTINGWRAPPER_H_
#define DEVICETMREPORTINGWRAPPER_H_
#ifndef FSFW_DEVICEHANDLERS_DEVICETMREPORTINGWRAPPER_H_
#define FSFW_DEVICEHANDLERS_DEVICETMREPORTINGWRAPPER_H_
#include "../action/HasActionsIF.h"
#include "../objectmanager/SystemObjectIF.h"
@ -24,4 +24,4 @@ private:
SerializeIF *data;
};
#endif /* DEVICETMREPORTINGWRAPPER_H_ */
#endif /* FSFW_DEVICEHANDLERS_DEVICETMREPORTINGWRAPPER_H_ */

View File

@ -1,11 +1,12 @@
#include "../devicehandlers/HealthDevice.h"
#include "HealthDevice.h"
#include "../ipc/QueueFactory.h"
HealthDevice::HealthDevice(object_id_t setObjectId,
MessageQueueId_t parentQueue) :
SystemObject(setObjectId), lastHealth(HEALTHY), parentQueue(
parentQueue), commandQueue(), healthHelper(this, setObjectId) {
commandQueue = QueueFactory::instance()->createMessageQueue(3, CommandMessage::MINIMUM_COMMAND_MESSAGE_SIZE);
commandQueue = QueueFactory::instance()->createMessageQueue(3,
CommandMessage::MINIMUM_COMMAND_MESSAGE_SIZE);
}
HealthDevice::~HealthDevice() {

View File

@ -1,5 +1,5 @@
#ifndef HEALTHDEVICE_H_
#define HEALTHDEVICE_H_
#ifndef FSFW_DEVICEHANDLERS_HEALTHDEVICE_H_
#define FSFW_DEVICEHANDLERS_HEALTHDEVICE_H_
#include "../health/HasHealthIF.h"
#include "../health/HealthHelper.h"
@ -37,4 +37,4 @@ public:
HealthHelper healthHelper;
};
#endif /* HEALTHDEVICE_H_ */
#endif /* FSFW_DEVICEHANDLERS_HEALTHDEVICE_H_ */