renormalized line endings
This commit is contained in:
@ -1,21 +1,21 @@
|
||||
/**
|
||||
* @file AcceptsMemoryMessagesIF.h
|
||||
* @brief This file defines the AcceptsMemoryMessagesIF class.
|
||||
* @date 11.07.2013
|
||||
* @author baetz
|
||||
*/
|
||||
|
||||
#ifndef ACCEPTSMEMORYMESSAGESIF_H_
|
||||
#define ACCEPTSMEMORYMESSAGESIF_H_
|
||||
|
||||
#include "../memory/HasMemoryIF.h"
|
||||
#include "../memory/MemoryMessage.h"
|
||||
#include "../ipc/MessageQueueSenderIF.h"
|
||||
|
||||
class AcceptsMemoryMessagesIF : public HasMemoryIF {
|
||||
public:
|
||||
virtual MessageQueueId_t getCommandQueue() const = 0;
|
||||
};
|
||||
|
||||
|
||||
#endif /* ACCEPTSMEMORYMESSAGESIF_H_ */
|
||||
/**
|
||||
* @file AcceptsMemoryMessagesIF.h
|
||||
* @brief This file defines the AcceptsMemoryMessagesIF class.
|
||||
* @date 11.07.2013
|
||||
* @author baetz
|
||||
*/
|
||||
|
||||
#ifndef ACCEPTSMEMORYMESSAGESIF_H_
|
||||
#define ACCEPTSMEMORYMESSAGESIF_H_
|
||||
|
||||
#include "../memory/HasMemoryIF.h"
|
||||
#include "../memory/MemoryMessage.h"
|
||||
#include "../ipc/MessageQueueSenderIF.h"
|
||||
|
||||
class AcceptsMemoryMessagesIF : public HasMemoryIF {
|
||||
public:
|
||||
virtual MessageQueueId_t getCommandQueue() const = 0;
|
||||
};
|
||||
|
||||
|
||||
#endif /* ACCEPTSMEMORYMESSAGESIF_H_ */
|
||||
|
@ -1,28 +1,28 @@
|
||||
/*
|
||||
* FileSystemMessage.cpp
|
||||
*
|
||||
* Created on: 19.01.2020
|
||||
* Author: Jakob Meier
|
||||
*/
|
||||
|
||||
#include "FileSystemMessage.h"
|
||||
#include "../objectmanager/ObjectManagerIF.h"
|
||||
|
||||
ReturnValue_t FileSystemMessage::setWriteToFileCommand(CommandMessage* message,
|
||||
MessageQueueId_t replyQueueId, store_address_t storageID) {
|
||||
message->setCommand(WRITE_TO_FILE);
|
||||
message->setParameter(replyQueueId);
|
||||
message->setParameter2(storageID.raw);
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
||||
store_address_t FileSystemMessage::getStoreID(const CommandMessage* message) {
|
||||
store_address_t temp;
|
||||
temp.raw = message->getParameter2();
|
||||
return temp;
|
||||
}
|
||||
|
||||
MessageQueueId_t FileSystemMessage::getReplyQueueId(const CommandMessage* message){
|
||||
return message->getParameter();
|
||||
}
|
||||
|
||||
/*
|
||||
* FileSystemMessage.cpp
|
||||
*
|
||||
* Created on: 19.01.2020
|
||||
* Author: Jakob Meier
|
||||
*/
|
||||
|
||||
#include "FileSystemMessage.h"
|
||||
#include "../objectmanager/ObjectManagerIF.h"
|
||||
|
||||
ReturnValue_t FileSystemMessage::setWriteToFileCommand(CommandMessage* message,
|
||||
MessageQueueId_t replyQueueId, store_address_t storageID) {
|
||||
message->setCommand(WRITE_TO_FILE);
|
||||
message->setParameter(replyQueueId);
|
||||
message->setParameter2(storageID.raw);
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
||||
store_address_t FileSystemMessage::getStoreID(const CommandMessage* message) {
|
||||
store_address_t temp;
|
||||
temp.raw = message->getParameter2();
|
||||
return temp;
|
||||
}
|
||||
|
||||
MessageQueueId_t FileSystemMessage::getReplyQueueId(const CommandMessage* message){
|
||||
return message->getParameter();
|
||||
}
|
||||
|
||||
|
@ -1,30 +1,30 @@
|
||||
/*
|
||||
* FileSystemMessage.h
|
||||
*
|
||||
* Created on: 19.01.2020
|
||||
* Author: Jakob Meier
|
||||
*/
|
||||
|
||||
#ifndef FRAMEWORK_MEMORY_FILESYSTEMMESSAGE_H_
|
||||
#define FRAMEWORK_MEMORY_FILESYSTEMMESSAGE_H_
|
||||
|
||||
#include "../ipc/CommandMessage.h"
|
||||
#include "../storagemanager/StorageManagerIF.h"
|
||||
#include "../objectmanager/SystemObject.h"
|
||||
|
||||
class FileSystemMessage {
|
||||
private:
|
||||
FileSystemMessage(); //A private ctor inhibits instantiation
|
||||
public:
|
||||
static const uint8_t MESSAGE_ID = messagetypes::FILE_SYSTEM_MESSAGE;
|
||||
static const Command_t CREATE_FILE = MAKE_COMMAND_ID( 0x01 );
|
||||
static const Command_t DELETE_FILE = MAKE_COMMAND_ID( 0x02 );
|
||||
static const Command_t WRITE_TO_FILE = MAKE_COMMAND_ID( 0x80 );
|
||||
|
||||
static ReturnValue_t setWriteToFileCommand(CommandMessage* message, MessageQueueId_t replyToQueue, store_address_t storageID );
|
||||
static store_address_t getStoreID( const CommandMessage* message );
|
||||
static MessageQueueId_t getReplyQueueId(const CommandMessage* message);
|
||||
|
||||
};
|
||||
|
||||
#endif /* FRAMEWORK_MEMORY_FILESYSTEMMESSAGE_H_ */
|
||||
/*
|
||||
* FileSystemMessage.h
|
||||
*
|
||||
* Created on: 19.01.2020
|
||||
* Author: Jakob Meier
|
||||
*/
|
||||
|
||||
#ifndef FRAMEWORK_MEMORY_FILESYSTEMMESSAGE_H_
|
||||
#define FRAMEWORK_MEMORY_FILESYSTEMMESSAGE_H_
|
||||
|
||||
#include "../ipc/CommandMessage.h"
|
||||
#include "../storagemanager/StorageManagerIF.h"
|
||||
#include "../objectmanager/SystemObject.h"
|
||||
|
||||
class FileSystemMessage {
|
||||
private:
|
||||
FileSystemMessage(); //A private ctor inhibits instantiation
|
||||
public:
|
||||
static const uint8_t MESSAGE_ID = messagetypes::FILE_SYSTEM_MESSAGE;
|
||||
static const Command_t CREATE_FILE = MAKE_COMMAND_ID( 0x01 );
|
||||
static const Command_t DELETE_FILE = MAKE_COMMAND_ID( 0x02 );
|
||||
static const Command_t WRITE_TO_FILE = MAKE_COMMAND_ID( 0x80 );
|
||||
|
||||
static ReturnValue_t setWriteToFileCommand(CommandMessage* message, MessageQueueId_t replyToQueue, store_address_t storageID );
|
||||
static store_address_t getStoreID( const CommandMessage* message );
|
||||
static MessageQueueId_t getReplyQueueId(const CommandMessage* message);
|
||||
|
||||
};
|
||||
|
||||
#endif /* FRAMEWORK_MEMORY_FILESYSTEMMESSAGE_H_ */
|
||||
|
@ -1,36 +1,36 @@
|
||||
/*
|
||||
* HasFileSystemIF.h
|
||||
*
|
||||
* Created on: 19.01.2020
|
||||
* Author: Jakob Meier
|
||||
*/
|
||||
|
||||
#ifndef FRAMEWORK_MEMORY_HASFILESYSTEMIF_H_
|
||||
#define FRAMEWORK_MEMORY_HASFILESYSTEMIF_H_
|
||||
|
||||
#include "../returnvalues/HasReturnvaluesIF.h"
|
||||
|
||||
class HasFileSystemIF {
|
||||
public:
|
||||
|
||||
virtual ~HasFileSystemIF() {}
|
||||
/**
|
||||
* Function to get the MessageQueueId_t of the implementing object
|
||||
* @return MessageQueueId_t of the object
|
||||
*/
|
||||
virtual MessageQueueId_t getCommandQueue() const = 0;
|
||||
/**
|
||||
* Function to write to a file
|
||||
* @param dirname Directory of the file
|
||||
* @param filename The filename of the file
|
||||
* @param data The data to write to the file
|
||||
* @param size The size of the data to write
|
||||
* @param packetNumber Counts the number of packets. For large files the write procedure must be split in multiple calls to writeToFile
|
||||
*/
|
||||
virtual ReturnValue_t writeToFile(const char* dirname, char* filename, const uint8_t* data, uint32_t size, uint16_t packetNumber) = 0;
|
||||
virtual ReturnValue_t createFile(const char* dirname, const char* filename, const uint8_t* data, uint32_t size) = 0;
|
||||
virtual ReturnValue_t deleteFile(const char* dirname, const char* filename) = 0;
|
||||
};
|
||||
|
||||
|
||||
#endif /* FRAMEWORK_MEMORY_HASFILESYSTEMIF_H_ */
|
||||
/*
|
||||
* HasFileSystemIF.h
|
||||
*
|
||||
* Created on: 19.01.2020
|
||||
* Author: Jakob Meier
|
||||
*/
|
||||
|
||||
#ifndef FRAMEWORK_MEMORY_HASFILESYSTEMIF_H_
|
||||
#define FRAMEWORK_MEMORY_HASFILESYSTEMIF_H_
|
||||
|
||||
#include "../returnvalues/HasReturnvaluesIF.h"
|
||||
|
||||
class HasFileSystemIF {
|
||||
public:
|
||||
|
||||
virtual ~HasFileSystemIF() {}
|
||||
/**
|
||||
* Function to get the MessageQueueId_t of the implementing object
|
||||
* @return MessageQueueId_t of the object
|
||||
*/
|
||||
virtual MessageQueueId_t getCommandQueue() const = 0;
|
||||
/**
|
||||
* Function to write to a file
|
||||
* @param dirname Directory of the file
|
||||
* @param filename The filename of the file
|
||||
* @param data The data to write to the file
|
||||
* @param size The size of the data to write
|
||||
* @param packetNumber Counts the number of packets. For large files the write procedure must be split in multiple calls to writeToFile
|
||||
*/
|
||||
virtual ReturnValue_t writeToFile(const char* dirname, char* filename, const uint8_t* data, uint32_t size, uint16_t packetNumber) = 0;
|
||||
virtual ReturnValue_t createFile(const char* dirname, const char* filename, const uint8_t* data, uint32_t size) = 0;
|
||||
virtual ReturnValue_t deleteFile(const char* dirname, const char* filename) = 0;
|
||||
};
|
||||
|
||||
|
||||
#endif /* FRAMEWORK_MEMORY_HASFILESYSTEMIF_H_ */
|
||||
|
@ -1,47 +1,47 @@
|
||||
#ifndef HASMEMORYIF_H_
|
||||
#define HASMEMORYIF_H_
|
||||
|
||||
#include "../returnvalues/HasReturnvaluesIF.h"
|
||||
|
||||
class HasMemoryIF {
|
||||
public:
|
||||
static const uint8_t INTERFACE_ID = CLASS_ID::HAS_MEMORY_IF;
|
||||
static const ReturnValue_t DO_IT_MYSELF = MAKE_RETURN_CODE(1);
|
||||
static const ReturnValue_t POINTS_TO_VARIABLE = MAKE_RETURN_CODE(2);
|
||||
static const ReturnValue_t POINTS_TO_MEMORY = MAKE_RETURN_CODE(3);
|
||||
static const ReturnValue_t ACTIVITY_COMPLETED = MAKE_RETURN_CODE(4);
|
||||
static const ReturnValue_t POINTS_TO_VECTOR_UINT8 = MAKE_RETURN_CODE(5);
|
||||
static const ReturnValue_t POINTS_TO_VECTOR_UINT16 = MAKE_RETURN_CODE(6);
|
||||
static const ReturnValue_t POINTS_TO_VECTOR_UINT32 = MAKE_RETURN_CODE(7);
|
||||
static const ReturnValue_t POINTS_TO_VECTOR_FLOAT = MAKE_RETURN_CODE(8);
|
||||
static const ReturnValue_t DUMP_NOT_SUPPORTED = MAKE_RETURN_CODE(0xA0);
|
||||
static const ReturnValue_t INVALID_SIZE = MAKE_RETURN_CODE(0xE0);
|
||||
static const ReturnValue_t INVALID_ADDRESS = MAKE_RETURN_CODE(0xE1);
|
||||
static const ReturnValue_t INVALID_CONTENT = MAKE_RETURN_CODE(0xE2);
|
||||
static const ReturnValue_t UNALIGNED_ACCESS = MAKE_RETURN_CODE(0xE3);
|
||||
static const ReturnValue_t WRITE_PROTECTED = MAKE_RETURN_CODE(0xE4);
|
||||
// static const ReturnValue_t TARGET_BUSY = MAKE_RETURN_CODE(0xE5);
|
||||
virtual ~HasMemoryIF() {}
|
||||
virtual ReturnValue_t handleMemoryLoad(uint32_t address, const uint8_t* data, uint32_t size, uint8_t** dataPointer) = 0;
|
||||
virtual ReturnValue_t handleMemoryDump(uint32_t address, uint32_t size, uint8_t** dataPointer, uint8_t* dumpTarget ) = 0;
|
||||
/**
|
||||
* Sets the address of the memory, if possible.
|
||||
* startAddress is a proposal for an address, or the base address if multiple addresses are set.
|
||||
*/
|
||||
virtual ReturnValue_t setAddress( uint32_t* startAddress ) { return HasReturnvaluesIF::RETURN_FAILED; }
|
||||
static bool memAccessWasSuccessful(ReturnValue_t result) {
|
||||
switch (result) {
|
||||
case DO_IT_MYSELF:
|
||||
case POINTS_TO_MEMORY:
|
||||
case POINTS_TO_VARIABLE:
|
||||
case HasReturnvaluesIF::RETURN_OK:
|
||||
case ACTIVITY_COMPLETED:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
#endif /* HASMEMORYIF_H_ */
|
||||
#ifndef HASMEMORYIF_H_
|
||||
#define HASMEMORYIF_H_
|
||||
|
||||
#include "../returnvalues/HasReturnvaluesIF.h"
|
||||
|
||||
class HasMemoryIF {
|
||||
public:
|
||||
static const uint8_t INTERFACE_ID = CLASS_ID::HAS_MEMORY_IF;
|
||||
static const ReturnValue_t DO_IT_MYSELF = MAKE_RETURN_CODE(1);
|
||||
static const ReturnValue_t POINTS_TO_VARIABLE = MAKE_RETURN_CODE(2);
|
||||
static const ReturnValue_t POINTS_TO_MEMORY = MAKE_RETURN_CODE(3);
|
||||
static const ReturnValue_t ACTIVITY_COMPLETED = MAKE_RETURN_CODE(4);
|
||||
static const ReturnValue_t POINTS_TO_VECTOR_UINT8 = MAKE_RETURN_CODE(5);
|
||||
static const ReturnValue_t POINTS_TO_VECTOR_UINT16 = MAKE_RETURN_CODE(6);
|
||||
static const ReturnValue_t POINTS_TO_VECTOR_UINT32 = MAKE_RETURN_CODE(7);
|
||||
static const ReturnValue_t POINTS_TO_VECTOR_FLOAT = MAKE_RETURN_CODE(8);
|
||||
static const ReturnValue_t DUMP_NOT_SUPPORTED = MAKE_RETURN_CODE(0xA0);
|
||||
static const ReturnValue_t INVALID_SIZE = MAKE_RETURN_CODE(0xE0);
|
||||
static const ReturnValue_t INVALID_ADDRESS = MAKE_RETURN_CODE(0xE1);
|
||||
static const ReturnValue_t INVALID_CONTENT = MAKE_RETURN_CODE(0xE2);
|
||||
static const ReturnValue_t UNALIGNED_ACCESS = MAKE_RETURN_CODE(0xE3);
|
||||
static const ReturnValue_t WRITE_PROTECTED = MAKE_RETURN_CODE(0xE4);
|
||||
// static const ReturnValue_t TARGET_BUSY = MAKE_RETURN_CODE(0xE5);
|
||||
virtual ~HasMemoryIF() {}
|
||||
virtual ReturnValue_t handleMemoryLoad(uint32_t address, const uint8_t* data, uint32_t size, uint8_t** dataPointer) = 0;
|
||||
virtual ReturnValue_t handleMemoryDump(uint32_t address, uint32_t size, uint8_t** dataPointer, uint8_t* dumpTarget ) = 0;
|
||||
/**
|
||||
* Sets the address of the memory, if possible.
|
||||
* startAddress is a proposal for an address, or the base address if multiple addresses are set.
|
||||
*/
|
||||
virtual ReturnValue_t setAddress( uint32_t* startAddress ) { return HasReturnvaluesIF::RETURN_FAILED; }
|
||||
static bool memAccessWasSuccessful(ReturnValue_t result) {
|
||||
switch (result) {
|
||||
case DO_IT_MYSELF:
|
||||
case POINTS_TO_MEMORY:
|
||||
case POINTS_TO_VARIABLE:
|
||||
case HasReturnvaluesIF::RETURN_OK:
|
||||
case ACTIVITY_COMPLETED:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
#endif /* HASMEMORYIF_H_ */
|
||||
|
@ -1,193 +1,193 @@
|
||||
#include "../globalfunctions/CRC.h"
|
||||
#include "../memory/MemoryHelper.h"
|
||||
#include "../memory/MemoryMessage.h"
|
||||
#include "../objectmanager/ObjectManagerIF.h"
|
||||
#include "../serialize/EndianConverter.h"
|
||||
#include "../serviceinterface/ServiceInterfaceStream.h"
|
||||
|
||||
MemoryHelper::MemoryHelper(HasMemoryIF* workOnThis,
|
||||
MessageQueueIF* useThisQueue):
|
||||
workOnThis(workOnThis), queueToUse(useThisQueue), ipcStore(nullptr),
|
||||
ipcAddress(), lastCommand(CommandMessage::CMD_NONE), busy(false) {
|
||||
}
|
||||
|
||||
ReturnValue_t MemoryHelper::handleMemoryCommand(CommandMessage* message) {
|
||||
lastSender = message->getSender();
|
||||
lastCommand = message->getCommand();
|
||||
if (busy) {
|
||||
sif::debug << "MemHelper: Busy!" << std::endl;
|
||||
}
|
||||
switch (lastCommand) {
|
||||
case MemoryMessage::CMD_MEMORY_DUMP:
|
||||
handleMemoryCheckOrDump(message);
|
||||
return RETURN_OK;
|
||||
case MemoryMessage::CMD_MEMORY_LOAD:
|
||||
handleMemoryLoad(message);
|
||||
return RETURN_OK;
|
||||
case MemoryMessage::CMD_MEMORY_CHECK:
|
||||
handleMemoryCheckOrDump(message);
|
||||
return RETURN_OK;
|
||||
default:
|
||||
lastCommand = CommandMessage::CMD_NONE;
|
||||
return UNKNOWN_CMD;
|
||||
}
|
||||
}
|
||||
|
||||
void MemoryHelper::completeLoad(ReturnValue_t errorCode,
|
||||
const uint8_t* dataToCopy, const uint32_t size, uint8_t* copyHere) {
|
||||
busy = false;
|
||||
switch (errorCode) {
|
||||
case HasMemoryIF::DO_IT_MYSELF:
|
||||
busy = true;
|
||||
return;
|
||||
case HasMemoryIF::POINTS_TO_MEMORY:
|
||||
memcpy(copyHere, dataToCopy, size);
|
||||
break;
|
||||
case HasMemoryIF::POINTS_TO_VARIABLE:
|
||||
EndianConverter::convertBigEndian(copyHere, dataToCopy, size);
|
||||
break;
|
||||
case HasMemoryIF::ACTIVITY_COMPLETED:
|
||||
case RETURN_OK:
|
||||
break;
|
||||
default:
|
||||
ipcStore->deleteData(ipcAddress);
|
||||
CommandMessage reply;
|
||||
MemoryMessage::setMemoryReplyFailed(&reply, errorCode,
|
||||
MemoryMessage::CMD_MEMORY_LOAD);
|
||||
queueToUse->sendMessage(lastSender, &reply);
|
||||
return;
|
||||
}
|
||||
//Only reached on success
|
||||
CommandMessage reply( CommandMessage::REPLY_COMMAND_OK, 0, 0);
|
||||
queueToUse->sendMessage(lastSender, &reply);
|
||||
ipcStore->deleteData(ipcAddress);
|
||||
}
|
||||
|
||||
void MemoryHelper::completeDump(ReturnValue_t errorCode,
|
||||
const uint8_t* dataToCopy, const uint32_t size) {
|
||||
busy = false;
|
||||
CommandMessage reply;
|
||||
MemoryMessage::setMemoryReplyFailed(&reply, errorCode, lastCommand);
|
||||
switch (errorCode) {
|
||||
case HasMemoryIF::DO_IT_MYSELF:
|
||||
busy = true;
|
||||
return;
|
||||
case HasReturnvaluesIF::RETURN_OK:
|
||||
case HasMemoryIF::POINTS_TO_MEMORY:
|
||||
case HasMemoryIF::POINTS_TO_VARIABLE:
|
||||
//"data" must be valid pointer!
|
||||
if (errorCode == HasMemoryIF::POINTS_TO_VARIABLE) {
|
||||
EndianConverter::convertBigEndian(reservedSpaceInIPC, dataToCopy, size);
|
||||
} else {
|
||||
memcpy(reservedSpaceInIPC, dataToCopy, size);
|
||||
}
|
||||
/* NO BREAK falls through*/
|
||||
case HasMemoryIF::ACTIVITY_COMPLETED:
|
||||
switch (lastCommand) {
|
||||
case MemoryMessage::CMD_MEMORY_DUMP: {
|
||||
MemoryMessage::setMemoryDumpReply(&reply, ipcAddress);
|
||||
break;
|
||||
}
|
||||
case MemoryMessage::CMD_MEMORY_CHECK: {
|
||||
uint16_t crc = CRC::crc16ccitt(reservedSpaceInIPC, size);
|
||||
//Delete data immediately, was temporary.
|
||||
ipcStore->deleteData(ipcAddress);
|
||||
MemoryMessage::setMemoryCheckReply(&reply, crc);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
//This should never happen!
|
||||
//Is it ok to send message? Otherwise: return;
|
||||
ipcStore->deleteData(ipcAddress);
|
||||
reply.setParameter(STATE_MISMATCH);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case HasMemoryIF::DUMP_NOT_SUPPORTED:
|
||||
if (lastCommand == MemoryMessage::CMD_MEMORY_CHECK){
|
||||
MemoryMessage::setMemoryCheckReply(&reply, 0);
|
||||
MemoryMessage::setCrcReturnValue(&reply,HasMemoryIF::DUMP_NOT_SUPPORTED);
|
||||
}
|
||||
ipcStore->deleteData(ipcAddress);
|
||||
break;
|
||||
default:
|
||||
//Reply is already set to REJECTED.
|
||||
ipcStore->deleteData(ipcAddress);
|
||||
break;
|
||||
}
|
||||
if (queueToUse->sendMessage(lastSender, &reply) != RETURN_OK) {
|
||||
reply.clear();
|
||||
}
|
||||
}
|
||||
|
||||
void MemoryHelper::swapMatrixCopy(uint8_t* out, const uint8_t *in,
|
||||
uint32_t totalSize, uint8_t datatypeSize) {
|
||||
if (totalSize % datatypeSize != 0){
|
||||
return;
|
||||
}
|
||||
|
||||
while (totalSize > 0){
|
||||
EndianConverter::convertBigEndian(out,in,datatypeSize);
|
||||
out += datatypeSize;
|
||||
in += datatypeSize;
|
||||
totalSize -= datatypeSize;
|
||||
}
|
||||
}
|
||||
|
||||
MemoryHelper::~MemoryHelper() {
|
||||
//Nothing to destroy
|
||||
}
|
||||
|
||||
void MemoryHelper::handleMemoryLoad(CommandMessage* message) {
|
||||
uint32_t address = MemoryMessage::getAddress(message);
|
||||
ipcAddress = MemoryMessage::getStoreID(message);
|
||||
const uint8_t* p_data = NULL;
|
||||
uint8_t* dataPointer = NULL;
|
||||
size_t size = 0;
|
||||
ReturnValue_t returnCode = ipcStore->getData(ipcAddress, &p_data, &size);
|
||||
if (returnCode == RETURN_OK) {
|
||||
returnCode = workOnThis->handleMemoryLoad(address, p_data, size,
|
||||
&dataPointer);
|
||||
completeLoad(returnCode, p_data, size, dataPointer);
|
||||
} else {
|
||||
//At least inform sender.
|
||||
CommandMessage reply;
|
||||
MemoryMessage::setMemoryReplyFailed(&reply, returnCode,
|
||||
MemoryMessage::CMD_MEMORY_LOAD);
|
||||
queueToUse->sendMessage(lastSender, &reply);
|
||||
}
|
||||
}
|
||||
|
||||
void MemoryHelper::handleMemoryCheckOrDump(CommandMessage* message) {
|
||||
uint32_t address = MemoryMessage::getAddress(message);
|
||||
uint32_t size = MemoryMessage::getLength(message);
|
||||
uint8_t* dataPointer = NULL;
|
||||
ReturnValue_t returnCode = ipcStore->getFreeElement(&ipcAddress, size,
|
||||
&reservedSpaceInIPC);
|
||||
if (returnCode == RETURN_OK) {
|
||||
returnCode = workOnThis->handleMemoryDump(address, size, &dataPointer,
|
||||
reservedSpaceInIPC);
|
||||
completeDump(returnCode, dataPointer, size);
|
||||
} else {
|
||||
CommandMessage reply;
|
||||
MemoryMessage::setMemoryReplyFailed(&reply, returnCode, lastCommand);
|
||||
queueToUse->sendMessage(lastSender, &reply);
|
||||
}
|
||||
}
|
||||
|
||||
ReturnValue_t MemoryHelper::initialize(MessageQueueIF* queueToUse_) {
|
||||
if(queueToUse_ == nullptr) {
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
}
|
||||
this->queueToUse = queueToUse_;
|
||||
return initialize();
|
||||
}
|
||||
|
||||
ReturnValue_t MemoryHelper::initialize() {
|
||||
ipcStore = objectManager->get<StorageManagerIF>(objects::IPC_STORE);
|
||||
if (ipcStore != nullptr) {
|
||||
return RETURN_OK;
|
||||
} else {
|
||||
return RETURN_FAILED;
|
||||
}
|
||||
}
|
||||
#include "../globalfunctions/CRC.h"
|
||||
#include "../memory/MemoryHelper.h"
|
||||
#include "../memory/MemoryMessage.h"
|
||||
#include "../objectmanager/ObjectManagerIF.h"
|
||||
#include "../serialize/EndianConverter.h"
|
||||
#include "../serviceinterface/ServiceInterfaceStream.h"
|
||||
|
||||
MemoryHelper::MemoryHelper(HasMemoryIF* workOnThis,
|
||||
MessageQueueIF* useThisQueue):
|
||||
workOnThis(workOnThis), queueToUse(useThisQueue), ipcStore(nullptr),
|
||||
ipcAddress(), lastCommand(CommandMessage::CMD_NONE), busy(false) {
|
||||
}
|
||||
|
||||
ReturnValue_t MemoryHelper::handleMemoryCommand(CommandMessage* message) {
|
||||
lastSender = message->getSender();
|
||||
lastCommand = message->getCommand();
|
||||
if (busy) {
|
||||
sif::debug << "MemHelper: Busy!" << std::endl;
|
||||
}
|
||||
switch (lastCommand) {
|
||||
case MemoryMessage::CMD_MEMORY_DUMP:
|
||||
handleMemoryCheckOrDump(message);
|
||||
return RETURN_OK;
|
||||
case MemoryMessage::CMD_MEMORY_LOAD:
|
||||
handleMemoryLoad(message);
|
||||
return RETURN_OK;
|
||||
case MemoryMessage::CMD_MEMORY_CHECK:
|
||||
handleMemoryCheckOrDump(message);
|
||||
return RETURN_OK;
|
||||
default:
|
||||
lastCommand = CommandMessage::CMD_NONE;
|
||||
return UNKNOWN_CMD;
|
||||
}
|
||||
}
|
||||
|
||||
void MemoryHelper::completeLoad(ReturnValue_t errorCode,
|
||||
const uint8_t* dataToCopy, const uint32_t size, uint8_t* copyHere) {
|
||||
busy = false;
|
||||
switch (errorCode) {
|
||||
case HasMemoryIF::DO_IT_MYSELF:
|
||||
busy = true;
|
||||
return;
|
||||
case HasMemoryIF::POINTS_TO_MEMORY:
|
||||
memcpy(copyHere, dataToCopy, size);
|
||||
break;
|
||||
case HasMemoryIF::POINTS_TO_VARIABLE:
|
||||
EndianConverter::convertBigEndian(copyHere, dataToCopy, size);
|
||||
break;
|
||||
case HasMemoryIF::ACTIVITY_COMPLETED:
|
||||
case RETURN_OK:
|
||||
break;
|
||||
default:
|
||||
ipcStore->deleteData(ipcAddress);
|
||||
CommandMessage reply;
|
||||
MemoryMessage::setMemoryReplyFailed(&reply, errorCode,
|
||||
MemoryMessage::CMD_MEMORY_LOAD);
|
||||
queueToUse->sendMessage(lastSender, &reply);
|
||||
return;
|
||||
}
|
||||
//Only reached on success
|
||||
CommandMessage reply( CommandMessage::REPLY_COMMAND_OK, 0, 0);
|
||||
queueToUse->sendMessage(lastSender, &reply);
|
||||
ipcStore->deleteData(ipcAddress);
|
||||
}
|
||||
|
||||
void MemoryHelper::completeDump(ReturnValue_t errorCode,
|
||||
const uint8_t* dataToCopy, const uint32_t size) {
|
||||
busy = false;
|
||||
CommandMessage reply;
|
||||
MemoryMessage::setMemoryReplyFailed(&reply, errorCode, lastCommand);
|
||||
switch (errorCode) {
|
||||
case HasMemoryIF::DO_IT_MYSELF:
|
||||
busy = true;
|
||||
return;
|
||||
case HasReturnvaluesIF::RETURN_OK:
|
||||
case HasMemoryIF::POINTS_TO_MEMORY:
|
||||
case HasMemoryIF::POINTS_TO_VARIABLE:
|
||||
//"data" must be valid pointer!
|
||||
if (errorCode == HasMemoryIF::POINTS_TO_VARIABLE) {
|
||||
EndianConverter::convertBigEndian(reservedSpaceInIPC, dataToCopy, size);
|
||||
} else {
|
||||
memcpy(reservedSpaceInIPC, dataToCopy, size);
|
||||
}
|
||||
/* NO BREAK falls through*/
|
||||
case HasMemoryIF::ACTIVITY_COMPLETED:
|
||||
switch (lastCommand) {
|
||||
case MemoryMessage::CMD_MEMORY_DUMP: {
|
||||
MemoryMessage::setMemoryDumpReply(&reply, ipcAddress);
|
||||
break;
|
||||
}
|
||||
case MemoryMessage::CMD_MEMORY_CHECK: {
|
||||
uint16_t crc = CRC::crc16ccitt(reservedSpaceInIPC, size);
|
||||
//Delete data immediately, was temporary.
|
||||
ipcStore->deleteData(ipcAddress);
|
||||
MemoryMessage::setMemoryCheckReply(&reply, crc);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
//This should never happen!
|
||||
//Is it ok to send message? Otherwise: return;
|
||||
ipcStore->deleteData(ipcAddress);
|
||||
reply.setParameter(STATE_MISMATCH);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case HasMemoryIF::DUMP_NOT_SUPPORTED:
|
||||
if (lastCommand == MemoryMessage::CMD_MEMORY_CHECK){
|
||||
MemoryMessage::setMemoryCheckReply(&reply, 0);
|
||||
MemoryMessage::setCrcReturnValue(&reply,HasMemoryIF::DUMP_NOT_SUPPORTED);
|
||||
}
|
||||
ipcStore->deleteData(ipcAddress);
|
||||
break;
|
||||
default:
|
||||
//Reply is already set to REJECTED.
|
||||
ipcStore->deleteData(ipcAddress);
|
||||
break;
|
||||
}
|
||||
if (queueToUse->sendMessage(lastSender, &reply) != RETURN_OK) {
|
||||
reply.clear();
|
||||
}
|
||||
}
|
||||
|
||||
void MemoryHelper::swapMatrixCopy(uint8_t* out, const uint8_t *in,
|
||||
uint32_t totalSize, uint8_t datatypeSize) {
|
||||
if (totalSize % datatypeSize != 0){
|
||||
return;
|
||||
}
|
||||
|
||||
while (totalSize > 0){
|
||||
EndianConverter::convertBigEndian(out,in,datatypeSize);
|
||||
out += datatypeSize;
|
||||
in += datatypeSize;
|
||||
totalSize -= datatypeSize;
|
||||
}
|
||||
}
|
||||
|
||||
MemoryHelper::~MemoryHelper() {
|
||||
//Nothing to destroy
|
||||
}
|
||||
|
||||
void MemoryHelper::handleMemoryLoad(CommandMessage* message) {
|
||||
uint32_t address = MemoryMessage::getAddress(message);
|
||||
ipcAddress = MemoryMessage::getStoreID(message);
|
||||
const uint8_t* p_data = NULL;
|
||||
uint8_t* dataPointer = NULL;
|
||||
size_t size = 0;
|
||||
ReturnValue_t returnCode = ipcStore->getData(ipcAddress, &p_data, &size);
|
||||
if (returnCode == RETURN_OK) {
|
||||
returnCode = workOnThis->handleMemoryLoad(address, p_data, size,
|
||||
&dataPointer);
|
||||
completeLoad(returnCode, p_data, size, dataPointer);
|
||||
} else {
|
||||
//At least inform sender.
|
||||
CommandMessage reply;
|
||||
MemoryMessage::setMemoryReplyFailed(&reply, returnCode,
|
||||
MemoryMessage::CMD_MEMORY_LOAD);
|
||||
queueToUse->sendMessage(lastSender, &reply);
|
||||
}
|
||||
}
|
||||
|
||||
void MemoryHelper::handleMemoryCheckOrDump(CommandMessage* message) {
|
||||
uint32_t address = MemoryMessage::getAddress(message);
|
||||
uint32_t size = MemoryMessage::getLength(message);
|
||||
uint8_t* dataPointer = NULL;
|
||||
ReturnValue_t returnCode = ipcStore->getFreeElement(&ipcAddress, size,
|
||||
&reservedSpaceInIPC);
|
||||
if (returnCode == RETURN_OK) {
|
||||
returnCode = workOnThis->handleMemoryDump(address, size, &dataPointer,
|
||||
reservedSpaceInIPC);
|
||||
completeDump(returnCode, dataPointer, size);
|
||||
} else {
|
||||
CommandMessage reply;
|
||||
MemoryMessage::setMemoryReplyFailed(&reply, returnCode, lastCommand);
|
||||
queueToUse->sendMessage(lastSender, &reply);
|
||||
}
|
||||
}
|
||||
|
||||
ReturnValue_t MemoryHelper::initialize(MessageQueueIF* queueToUse_) {
|
||||
if(queueToUse_ == nullptr) {
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
}
|
||||
this->queueToUse = queueToUse_;
|
||||
return initialize();
|
||||
}
|
||||
|
||||
ReturnValue_t MemoryHelper::initialize() {
|
||||
ipcStore = objectManager->get<StorageManagerIF>(objects::IPC_STORE);
|
||||
if (ipcStore != nullptr) {
|
||||
return RETURN_OK;
|
||||
} else {
|
||||
return RETURN_FAILED;
|
||||
}
|
||||
}
|
||||
|
@ -1,37 +1,37 @@
|
||||
#ifndef FRAMEWORK_MEMORY_MEMORYHELPER_H_
|
||||
#define FRAMEWORK_MEMORY_MEMORYHELPER_H_
|
||||
#include "../ipc/CommandMessage.h"
|
||||
#include "../memory/AcceptsMemoryMessagesIF.h"
|
||||
#include "../returnvalues/HasReturnvaluesIF.h"
|
||||
#include "../storagemanager/StorageManagerIF.h"
|
||||
#include "../ipc/MessageQueueIF.h"
|
||||
|
||||
class MemoryHelper : public HasReturnvaluesIF {
|
||||
public:
|
||||
static const uint8_t INTERFACE_ID = CLASS_ID::MEMORY_HELPER;
|
||||
static const ReturnValue_t UNKNOWN_CMD = MAKE_RETURN_CODE(0xE0);
|
||||
static const ReturnValue_t INVALID_ADDRESS = MAKE_RETURN_CODE(0xE1);
|
||||
static const ReturnValue_t INVALID_SIZE = MAKE_RETURN_CODE(0xE2);
|
||||
static const ReturnValue_t STATE_MISMATCH = MAKE_RETURN_CODE(0xE3);
|
||||
private:
|
||||
HasMemoryIF* workOnThis;
|
||||
MessageQueueIF* queueToUse;
|
||||
StorageManagerIF* ipcStore = nullptr;
|
||||
store_address_t ipcAddress;
|
||||
Command_t lastCommand;
|
||||
MessageQueueId_t lastSender = MessageQueueIF::NO_QUEUE;
|
||||
uint8_t* reservedSpaceInIPC = nullptr;
|
||||
bool busy;
|
||||
void handleMemoryLoad(CommandMessage* message);
|
||||
void handleMemoryCheckOrDump(CommandMessage* message);
|
||||
ReturnValue_t initialize();
|
||||
public:
|
||||
ReturnValue_t handleMemoryCommand(CommandMessage* message);
|
||||
void completeLoad( ReturnValue_t errorCode, const uint8_t* dataToCopy = NULL, const uint32_t size = 0, uint8_t* copyHere = NULL );
|
||||
void completeDump( ReturnValue_t errorCode, const uint8_t* dataToCopy = NULL, const uint32_t size = 0);
|
||||
void swapMatrixCopy( uint8_t *out, const uint8_t *in, uint32_t totalSize, uint8_t datatypeSize);
|
||||
ReturnValue_t initialize(MessageQueueIF* queueToUse_);
|
||||
MemoryHelper( HasMemoryIF* workOnThis, MessageQueueIF* useThisQueue );
|
||||
~MemoryHelper();
|
||||
};
|
||||
#endif /* MEMORYHELPER_H_ */
|
||||
#ifndef FRAMEWORK_MEMORY_MEMORYHELPER_H_
|
||||
#define FRAMEWORK_MEMORY_MEMORYHELPER_H_
|
||||
#include "../ipc/CommandMessage.h"
|
||||
#include "../memory/AcceptsMemoryMessagesIF.h"
|
||||
#include "../returnvalues/HasReturnvaluesIF.h"
|
||||
#include "../storagemanager/StorageManagerIF.h"
|
||||
#include "../ipc/MessageQueueIF.h"
|
||||
|
||||
class MemoryHelper : public HasReturnvaluesIF {
|
||||
public:
|
||||
static const uint8_t INTERFACE_ID = CLASS_ID::MEMORY_HELPER;
|
||||
static const ReturnValue_t UNKNOWN_CMD = MAKE_RETURN_CODE(0xE0);
|
||||
static const ReturnValue_t INVALID_ADDRESS = MAKE_RETURN_CODE(0xE1);
|
||||
static const ReturnValue_t INVALID_SIZE = MAKE_RETURN_CODE(0xE2);
|
||||
static const ReturnValue_t STATE_MISMATCH = MAKE_RETURN_CODE(0xE3);
|
||||
private:
|
||||
HasMemoryIF* workOnThis;
|
||||
MessageQueueIF* queueToUse;
|
||||
StorageManagerIF* ipcStore = nullptr;
|
||||
store_address_t ipcAddress;
|
||||
Command_t lastCommand;
|
||||
MessageQueueId_t lastSender = MessageQueueIF::NO_QUEUE;
|
||||
uint8_t* reservedSpaceInIPC = nullptr;
|
||||
bool busy;
|
||||
void handleMemoryLoad(CommandMessage* message);
|
||||
void handleMemoryCheckOrDump(CommandMessage* message);
|
||||
ReturnValue_t initialize();
|
||||
public:
|
||||
ReturnValue_t handleMemoryCommand(CommandMessage* message);
|
||||
void completeLoad( ReturnValue_t errorCode, const uint8_t* dataToCopy = NULL, const uint32_t size = 0, uint8_t* copyHere = NULL );
|
||||
void completeDump( ReturnValue_t errorCode, const uint8_t* dataToCopy = NULL, const uint32_t size = 0);
|
||||
void swapMatrixCopy( uint8_t *out, const uint8_t *in, uint32_t totalSize, uint8_t datatypeSize);
|
||||
ReturnValue_t initialize(MessageQueueIF* queueToUse_);
|
||||
MemoryHelper( HasMemoryIF* workOnThis, MessageQueueIF* useThisQueue );
|
||||
~MemoryHelper();
|
||||
};
|
||||
#endif /* MEMORYHELPER_H_ */
|
||||
|
@ -1,112 +1,112 @@
|
||||
#include "../memory/MemoryMessage.h"
|
||||
#include "../objectmanager/ObjectManagerIF.h"
|
||||
MemoryMessage::MemoryMessage() {
|
||||
}
|
||||
|
||||
uint32_t MemoryMessage::getAddress(const CommandMessage* message) {
|
||||
return message->getParameter();
|
||||
}
|
||||
|
||||
store_address_t MemoryMessage::getStoreID(const CommandMessage* message) {
|
||||
store_address_t temp;
|
||||
temp.raw = message->getParameter2();
|
||||
return temp;
|
||||
}
|
||||
|
||||
uint32_t MemoryMessage::getLength(const CommandMessage* message) {
|
||||
return message->getParameter2();
|
||||
}
|
||||
|
||||
ReturnValue_t MemoryMessage::setMemoryDumpCommand(CommandMessage* message,
|
||||
uint32_t address, uint32_t length) {
|
||||
message->setCommand(CMD_MEMORY_DUMP);
|
||||
message->setParameter( address );
|
||||
message->setParameter2( length );
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
||||
ReturnValue_t MemoryMessage::setMemoryDumpReply(CommandMessage* message, store_address_t storageID) {
|
||||
message->setCommand(REPLY_MEMORY_DUMP);
|
||||
message->setParameter2( storageID.raw );
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
||||
void MemoryMessage::setMemoryLoadCommand(CommandMessage* message,
|
||||
uint32_t address, store_address_t storageID) {
|
||||
message->setCommand(CMD_MEMORY_LOAD);
|
||||
message->setParameter( address );
|
||||
message->setParameter2( storageID.raw );
|
||||
}
|
||||
|
||||
ReturnValue_t MemoryMessage::getErrorCode(const CommandMessage* message) {
|
||||
return message->getParameter();
|
||||
}
|
||||
|
||||
void MemoryMessage::clear(CommandMessage* message) {
|
||||
switch (message->getCommand()) {
|
||||
case CMD_MEMORY_LOAD:
|
||||
case REPLY_MEMORY_DUMP: {
|
||||
StorageManagerIF *ipcStore = objectManager->get<StorageManagerIF>(
|
||||
objects::IPC_STORE);
|
||||
if (ipcStore != NULL) {
|
||||
ipcStore->deleteData(getStoreID(message));
|
||||
}
|
||||
}
|
||||
/* NO BREAK falls through*/
|
||||
case CMD_MEMORY_DUMP:
|
||||
case CMD_MEMORY_CHECK:
|
||||
case REPLY_MEMORY_CHECK:
|
||||
case END_OF_MEMORY_COPY:
|
||||
message->setCommand(CommandMessage::CMD_NONE);
|
||||
message->setParameter(0);
|
||||
message->setParameter2(0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
ReturnValue_t MemoryMessage::setMemoryCheckCommand(CommandMessage* message,
|
||||
uint32_t address, uint32_t length) {
|
||||
message->setCommand(CMD_MEMORY_CHECK);
|
||||
message->setParameter( address );
|
||||
message->setParameter2( length );
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
||||
ReturnValue_t MemoryMessage::setMemoryCheckReply(CommandMessage* message,
|
||||
uint16_t crc) {
|
||||
message->setCommand(REPLY_MEMORY_CHECK);
|
||||
message->setParameter( crc );
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
||||
void MemoryMessage::setCrcReturnValue(CommandMessage* message, ReturnValue_t returnValue){
|
||||
message->setParameter(returnValue<<16);
|
||||
};
|
||||
|
||||
uint16_t MemoryMessage::getCrc(const CommandMessage* message) {
|
||||
return (uint16_t)(message->getParameter());
|
||||
}
|
||||
|
||||
ReturnValue_t MemoryMessage::getCrcReturnValue(const CommandMessage* message){
|
||||
return (message->getParameter()>>16);
|
||||
}
|
||||
|
||||
Command_t MemoryMessage::getInitialCommand(const CommandMessage* message) {
|
||||
return message->getParameter2();
|
||||
}
|
||||
|
||||
ReturnValue_t MemoryMessage::setMemoryReplyFailed(CommandMessage* message,
|
||||
ReturnValue_t errorCode, Command_t initialCommand) {
|
||||
message->setCommand(REPLY_MEMORY_FAILED);
|
||||
message->setParameter(errorCode);
|
||||
message->setParameter2(initialCommand);
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
||||
ReturnValue_t MemoryMessage::setMemoryCopyEnd(CommandMessage* message) {
|
||||
message->setCommand(END_OF_MEMORY_COPY);
|
||||
message->setParameter(0);
|
||||
message->setParameter2(0);
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
||||
#include "../memory/MemoryMessage.h"
|
||||
#include "../objectmanager/ObjectManagerIF.h"
|
||||
MemoryMessage::MemoryMessage() {
|
||||
}
|
||||
|
||||
uint32_t MemoryMessage::getAddress(const CommandMessage* message) {
|
||||
return message->getParameter();
|
||||
}
|
||||
|
||||
store_address_t MemoryMessage::getStoreID(const CommandMessage* message) {
|
||||
store_address_t temp;
|
||||
temp.raw = message->getParameter2();
|
||||
return temp;
|
||||
}
|
||||
|
||||
uint32_t MemoryMessage::getLength(const CommandMessage* message) {
|
||||
return message->getParameter2();
|
||||
}
|
||||
|
||||
ReturnValue_t MemoryMessage::setMemoryDumpCommand(CommandMessage* message,
|
||||
uint32_t address, uint32_t length) {
|
||||
message->setCommand(CMD_MEMORY_DUMP);
|
||||
message->setParameter( address );
|
||||
message->setParameter2( length );
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
||||
ReturnValue_t MemoryMessage::setMemoryDumpReply(CommandMessage* message, store_address_t storageID) {
|
||||
message->setCommand(REPLY_MEMORY_DUMP);
|
||||
message->setParameter2( storageID.raw );
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
||||
void MemoryMessage::setMemoryLoadCommand(CommandMessage* message,
|
||||
uint32_t address, store_address_t storageID) {
|
||||
message->setCommand(CMD_MEMORY_LOAD);
|
||||
message->setParameter( address );
|
||||
message->setParameter2( storageID.raw );
|
||||
}
|
||||
|
||||
ReturnValue_t MemoryMessage::getErrorCode(const CommandMessage* message) {
|
||||
return message->getParameter();
|
||||
}
|
||||
|
||||
void MemoryMessage::clear(CommandMessage* message) {
|
||||
switch (message->getCommand()) {
|
||||
case CMD_MEMORY_LOAD:
|
||||
case REPLY_MEMORY_DUMP: {
|
||||
StorageManagerIF *ipcStore = objectManager->get<StorageManagerIF>(
|
||||
objects::IPC_STORE);
|
||||
if (ipcStore != NULL) {
|
||||
ipcStore->deleteData(getStoreID(message));
|
||||
}
|
||||
}
|
||||
/* NO BREAK falls through*/
|
||||
case CMD_MEMORY_DUMP:
|
||||
case CMD_MEMORY_CHECK:
|
||||
case REPLY_MEMORY_CHECK:
|
||||
case END_OF_MEMORY_COPY:
|
||||
message->setCommand(CommandMessage::CMD_NONE);
|
||||
message->setParameter(0);
|
||||
message->setParameter2(0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
ReturnValue_t MemoryMessage::setMemoryCheckCommand(CommandMessage* message,
|
||||
uint32_t address, uint32_t length) {
|
||||
message->setCommand(CMD_MEMORY_CHECK);
|
||||
message->setParameter( address );
|
||||
message->setParameter2( length );
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
||||
ReturnValue_t MemoryMessage::setMemoryCheckReply(CommandMessage* message,
|
||||
uint16_t crc) {
|
||||
message->setCommand(REPLY_MEMORY_CHECK);
|
||||
message->setParameter( crc );
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
||||
void MemoryMessage::setCrcReturnValue(CommandMessage* message, ReturnValue_t returnValue){
|
||||
message->setParameter(returnValue<<16);
|
||||
};
|
||||
|
||||
uint16_t MemoryMessage::getCrc(const CommandMessage* message) {
|
||||
return (uint16_t)(message->getParameter());
|
||||
}
|
||||
|
||||
ReturnValue_t MemoryMessage::getCrcReturnValue(const CommandMessage* message){
|
||||
return (message->getParameter()>>16);
|
||||
}
|
||||
|
||||
Command_t MemoryMessage::getInitialCommand(const CommandMessage* message) {
|
||||
return message->getParameter2();
|
||||
}
|
||||
|
||||
ReturnValue_t MemoryMessage::setMemoryReplyFailed(CommandMessage* message,
|
||||
ReturnValue_t errorCode, Command_t initialCommand) {
|
||||
message->setCommand(REPLY_MEMORY_FAILED);
|
||||
message->setParameter(errorCode);
|
||||
message->setParameter2(initialCommand);
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
||||
ReturnValue_t MemoryMessage::setMemoryCopyEnd(CommandMessage* message) {
|
||||
message->setCommand(END_OF_MEMORY_COPY);
|
||||
message->setParameter(0);
|
||||
message->setParameter2(0);
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
||||
|
@ -1,39 +1,39 @@
|
||||
#ifndef MEMORYMESSAGE_H_
|
||||
#define MEMORYMESSAGE_H_
|
||||
|
||||
#include "../ipc/CommandMessage.h"
|
||||
#include "../storagemanager/StorageManagerIF.h"
|
||||
|
||||
|
||||
class MemoryMessage {
|
||||
private:
|
||||
MemoryMessage(); //A private ctor inhibits instantiation
|
||||
public:
|
||||
static const uint8_t MESSAGE_ID = messagetypes::MEMORY;
|
||||
static const Command_t CMD_MEMORY_LOAD = MAKE_COMMAND_ID( 0x01 );
|
||||
static const Command_t CMD_MEMORY_DUMP = MAKE_COMMAND_ID( 0x02 );
|
||||
static const Command_t CMD_MEMORY_CHECK = MAKE_COMMAND_ID( 0x03 );
|
||||
static const Command_t REPLY_MEMORY_DUMP = MAKE_COMMAND_ID( 0x10 );
|
||||
static const Command_t REPLY_MEMORY_CHECK = MAKE_COMMAND_ID( 0x30 );
|
||||
static const Command_t REPLY_MEMORY_FAILED = MAKE_COMMAND_ID( 0xE0 );
|
||||
static const Command_t END_OF_MEMORY_COPY = MAKE_COMMAND_ID(0xF0);
|
||||
|
||||
static uint32_t getAddress( const CommandMessage* message );
|
||||
static store_address_t getStoreID( const CommandMessage* message );
|
||||
static uint32_t getLength( const CommandMessage* message );
|
||||
static ReturnValue_t getErrorCode( const CommandMessage* message );
|
||||
static ReturnValue_t setMemoryDumpCommand( CommandMessage* message, uint32_t address, uint32_t length );
|
||||
static ReturnValue_t setMemoryDumpReply( CommandMessage* message, store_address_t storageID );
|
||||
static void setMemoryLoadCommand( CommandMessage* message, uint32_t address, store_address_t storageID );
|
||||
static ReturnValue_t setMemoryCheckCommand( CommandMessage* message, uint32_t address, uint32_t length );
|
||||
static ReturnValue_t setMemoryCheckReply( CommandMessage* message, uint16_t crc );
|
||||
static ReturnValue_t setMemoryReplyFailed( CommandMessage* message, ReturnValue_t errorCode, Command_t initialCommand );
|
||||
static ReturnValue_t setMemoryCopyEnd( CommandMessage* message);
|
||||
static void setCrcReturnValue(CommandMessage*, ReturnValue_t returnValue);
|
||||
static uint16_t getCrc( const CommandMessage* message );
|
||||
static ReturnValue_t getCrcReturnValue(const CommandMessage* message);
|
||||
static Command_t getInitialCommand( const CommandMessage* message );
|
||||
static void clear(CommandMessage* message);
|
||||
};
|
||||
|
||||
#endif /* MEMORYMESSAGE_H_ */
|
||||
#ifndef MEMORYMESSAGE_H_
|
||||
#define MEMORYMESSAGE_H_
|
||||
|
||||
#include "../ipc/CommandMessage.h"
|
||||
#include "../storagemanager/StorageManagerIF.h"
|
||||
|
||||
|
||||
class MemoryMessage {
|
||||
private:
|
||||
MemoryMessage(); //A private ctor inhibits instantiation
|
||||
public:
|
||||
static const uint8_t MESSAGE_ID = messagetypes::MEMORY;
|
||||
static const Command_t CMD_MEMORY_LOAD = MAKE_COMMAND_ID( 0x01 );
|
||||
static const Command_t CMD_MEMORY_DUMP = MAKE_COMMAND_ID( 0x02 );
|
||||
static const Command_t CMD_MEMORY_CHECK = MAKE_COMMAND_ID( 0x03 );
|
||||
static const Command_t REPLY_MEMORY_DUMP = MAKE_COMMAND_ID( 0x10 );
|
||||
static const Command_t REPLY_MEMORY_CHECK = MAKE_COMMAND_ID( 0x30 );
|
||||
static const Command_t REPLY_MEMORY_FAILED = MAKE_COMMAND_ID( 0xE0 );
|
||||
static const Command_t END_OF_MEMORY_COPY = MAKE_COMMAND_ID(0xF0);
|
||||
|
||||
static uint32_t getAddress( const CommandMessage* message );
|
||||
static store_address_t getStoreID( const CommandMessage* message );
|
||||
static uint32_t getLength( const CommandMessage* message );
|
||||
static ReturnValue_t getErrorCode( const CommandMessage* message );
|
||||
static ReturnValue_t setMemoryDumpCommand( CommandMessage* message, uint32_t address, uint32_t length );
|
||||
static ReturnValue_t setMemoryDumpReply( CommandMessage* message, store_address_t storageID );
|
||||
static void setMemoryLoadCommand( CommandMessage* message, uint32_t address, store_address_t storageID );
|
||||
static ReturnValue_t setMemoryCheckCommand( CommandMessage* message, uint32_t address, uint32_t length );
|
||||
static ReturnValue_t setMemoryCheckReply( CommandMessage* message, uint16_t crc );
|
||||
static ReturnValue_t setMemoryReplyFailed( CommandMessage* message, ReturnValue_t errorCode, Command_t initialCommand );
|
||||
static ReturnValue_t setMemoryCopyEnd( CommandMessage* message);
|
||||
static void setCrcReturnValue(CommandMessage*, ReturnValue_t returnValue);
|
||||
static uint16_t getCrc( const CommandMessage* message );
|
||||
static ReturnValue_t getCrcReturnValue(const CommandMessage* message);
|
||||
static Command_t getInitialCommand( const CommandMessage* message );
|
||||
static void clear(CommandMessage* message);
|
||||
};
|
||||
|
||||
#endif /* MEMORYMESSAGE_H_ */
|
||||
|
@ -1,22 +1,22 @@
|
||||
#ifndef FRAMEWORK_MEMORY_MEMORYPROXYIF_H_
|
||||
#define FRAMEWORK_MEMORY_MEMORYPROXYIF_H_
|
||||
|
||||
#include "../memory/AcceptsMemoryMessagesIF.h"
|
||||
|
||||
/**
|
||||
* This was a nice idea to transparently forward incoming messages to another object.
|
||||
* But it doesn't work like that.
|
||||
*/
|
||||
class MemoryProxyIF : public AcceptsMemoryMessagesIF {
|
||||
public:
|
||||
virtual MessageQueueId_t getProxyQueue() const = 0;
|
||||
MessageQueueId_t getCommandQueue() const {
|
||||
return getProxyQueue();
|
||||
}
|
||||
virtual ~MemoryProxyIF() {}
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif /* FRAMEWORK_MEMORY_MEMORYPROXYIF_H_ */
|
||||
#ifndef FRAMEWORK_MEMORY_MEMORYPROXYIF_H_
|
||||
#define FRAMEWORK_MEMORY_MEMORYPROXYIF_H_
|
||||
|
||||
#include "../memory/AcceptsMemoryMessagesIF.h"
|
||||
|
||||
/**
|
||||
* This was a nice idea to transparently forward incoming messages to another object.
|
||||
* But it doesn't work like that.
|
||||
*/
|
||||
class MemoryProxyIF : public AcceptsMemoryMessagesIF {
|
||||
public:
|
||||
virtual MessageQueueId_t getProxyQueue() const = 0;
|
||||
MessageQueueId_t getCommandQueue() const {
|
||||
return getProxyQueue();
|
||||
}
|
||||
virtual ~MemoryProxyIF() {}
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif /* FRAMEWORK_MEMORY_MEMORYPROXYIF_H_ */
|
||||
|
Reference in New Issue
Block a user