WIP: somethings wrong.. #19
@ -4,6 +4,101 @@
|
|||||||
* @date 28.02.2020
|
* @date 28.02.2020
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <framework/devicehandlers/CommunicationMessage.h>
|
||||||
|
#include <cstring>
|
||||||
|
|
||||||
|
CommunicationMessage::CommunicationMessage(): uninitialized(true) {
|
||||||
|
}
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CommunicationMessage::setSendRequestRaw(uint32_t address) {
|
||||||
|
}
|
||||||
|
|
||||||
|
void CommunicationMessage::setDataReplyFromIpcStore(uint32_t address, store_address_t storeId) {
|
||||||
|
setMessageType(REPLY_DATA_IPC_STORE);
|
||||||
|
setAddress(address);
|
||||||
|
setStoreId(storeId);
|
||||||
|
}
|
||||||
|
void CommunicationMessage::setDataReplyFromPointer(uint32_t address,
|
||||||
|
uint32_t dataLen, uint8_t *data) {
|
||||||
|
}
|
||||||
|
|
||||||
|
void CommunicationMessage::setDataReplyRaw(uint32_t address,
|
||||||
|
uint32_t length, uint16_t receiveBufferPosition) {
|
||||||
|
setMessageType(REPLY_DATA_RAW);
|
||||||
|
setAddress(address);
|
||||||
|
setDataLen(length);
|
||||||
|
if(receiveBufferPosition != 0) {
|
||||||
|
setReceiveBufferPosition(receiveBufferPosition);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void CommunicationMessage::setMessageType(messageType status) {
|
||||||
|
uint8_t status_uint8 = status;
|
||||||
|
memcpy(getData() + sizeof(uint32_t), &status_uint8, sizeof(status_uint8));
|
||||||
|
}
|
||||||
|
|
||||||
|
void CommunicationMessage::setAddress(uint32_t address) {
|
||||||
|
memcpy(getData(),&address,sizeof(address));
|
||||||
|
}
|
||||||
|
|
||||||
|
void CommunicationMessage::setReceiveBufferPosition(uint16_t bufferPosition) {
|
||||||
|
memcpy(getData() + sizeof(uint32_t) + sizeof(uint8_t),
|
||||||
|
&bufferPosition, sizeof(bufferPosition));
|
||||||
|
}
|
||||||
|
|
||||||
|
void CommunicationMessage::setDataPointer(const uint8_t *sendData) {
|
||||||
|
memcpy(getData() + 3 * sizeof(uint32_t), &sendData, sizeof(uint32_t));
|
||||||
|
}
|
||||||
|
|
||||||
|
void CommunicationMessage::setStoreId(store_address_t storeId) {
|
||||||
|
memcpy(getData() + 2 * sizeof(uint32_t), &storeId, sizeof(store_address_t));
|
||||||
|
}
|
||||||
|
|
||||||
|
void CommunicationMessage::setDataLen(uint32_t length) {
|
||||||
|
memcpy(getData() + 2 * sizeof(uint32_t), &length, sizeof(length));
|
||||||
|
}
|
||||||
|
|
||||||
|
void CommunicationMessage::setDataByte1(uint8_t byte1) {
|
||||||
|
}
|
||||||
|
|
||||||
|
void CommunicationMessage::setDataByte2(uint8_t byte2) {
|
||||||
|
}
|
||||||
|
|
||||||
|
void CommunicationMessage::setDataByte3(uint8_t byte3) {
|
||||||
|
}
|
||||||
|
|
||||||
|
void CommunicationMessage::setDataByte4(uint8_t byte4) {
|
||||||
|
}
|
||||||
|
|
||||||
|
void CommunicationMessage::setDataUINT16_1(uint16_t data1) {
|
||||||
|
}
|
||||||
|
|
||||||
|
void CommunicationMessage::setDataUINT16_2(uint16_t data2) {
|
||||||
|
}
|
||||||
|
|
||||||
|
void CommunicationMessage::setData(uint32_t data) {
|
||||||
|
}
|
||||||
|
|
||||||
|
CommunicationMessage::~CommunicationMessage() {
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -6,6 +6,8 @@
|
|||||||
|
|
||||||
#ifndef FRAMEWORK_DEVICEHANDLERS_COMMUNICATIONMESSAGE_H_
|
#ifndef FRAMEWORK_DEVICEHANDLERS_COMMUNICATIONMESSAGE_H_
|
||||||
#define FRAMEWORK_DEVICEHANDLERS_COMMUNICATIONMESSAGE_H_
|
#define FRAMEWORK_DEVICEHANDLERS_COMMUNICATIONMESSAGE_H_
|
||||||
|
#include <framework/devicehandlers/CommunicationMessage.h>
|
||||||
|
|
||||||
#include <framework/ipc/MessageQueueMessage.h>
|
#include <framework/ipc/MessageQueueMessage.h>
|
||||||
#include <framework/storagemanager/StorageManagerIF.h>
|
#include <framework/storagemanager/StorageManagerIF.h>
|
||||||
|
|
||||||
@ -23,9 +25,13 @@
|
|||||||
*/
|
*/
|
||||||
class CommunicationMessage: public MessageQueueMessage {
|
class CommunicationMessage: public MessageQueueMessage {
|
||||||
public:
|
public:
|
||||||
enum communicationStatus {
|
enum messageType {
|
||||||
SEND_DATA,
|
SEND_DATA_FROM_POINTER,
|
||||||
PROCESS_DATA,
|
SEND_DATA_FROM_IPC_STORE,
|
||||||
|
SEND_DATA_RAW,
|
||||||
|
REPLY_DATA_FROM_POINTER,
|
||||||
|
REPLY_DATA_IPC_STORE,
|
||||||
|
REPLY_DATA_RAW,
|
||||||
FAULTY,
|
FAULTY,
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -36,34 +42,60 @@ public:
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Send requests with pointer to the data to be sent and send data length
|
* Send requests with pointer to the data to be sent and send data length
|
||||||
* @param address Target Address
|
* @param address Target Address, first four bytes
|
||||||
* @param sendData
|
* @param dataLen Length of data to send, next four bytes
|
||||||
* @param length
|
* @param data Pointer to data to send
|
||||||
|
*
|
||||||
*/
|
*/
|
||||||
void setSendRequest(uint32_t address, const uint8_t * sendData, uint32_t length);
|
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);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Data message with data stored in IPC store
|
* Data message with data stored in IPC store
|
||||||
* @param address
|
* @param address Target Address, first four bytes
|
||||||
* @param length
|
* @param length
|
||||||
* @param storeId
|
* @param storeId
|
||||||
*/
|
*/
|
||||||
void setDataMessage(uint32_t address, uint32_t length, store_address_t * 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.
|
* Data message with data stored in actual message.
|
||||||
* 4 byte datafield is intialized with 0.
|
* 4 byte datafield is intialized with 0.
|
||||||
* Set data with specific setter functions.
|
* 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 setDataMessage(uint32_t address, uint32_t length);
|
void setDataReplyRaw(uint32_t address, uint32_t length, uint16_t receiveBufferPosition = 0);
|
||||||
|
|
||||||
private:
|
/*
|
||||||
void setCommunicationStatus(communicationStatus status);
|
* The following functions can be used to
|
||||||
void setAddress(uint32_t address);
|
* set the data field (4 bytes possible);
|
||||||
void setSendData(const uint8_t * sendData);
|
*/
|
||||||
void setDataLen(uint32_t length);
|
|
||||||
|
|
||||||
/** For low size data, maximum of 4 bytes can be sent */
|
|
||||||
void setDataByte1(uint8_t byte1);
|
void setDataByte1(uint8_t byte1);
|
||||||
void setDataByte2(uint8_t byte2);
|
void setDataByte2(uint8_t byte2);
|
||||||
void setDataByte3(uint8_t byte3);
|
void setDataByte3(uint8_t byte3);
|
||||||
@ -74,9 +106,42 @@ private:
|
|||||||
|
|
||||||
void setData(uint32_t data);
|
void setData(uint32_t data);
|
||||||
|
|
||||||
|
private:
|
||||||
|
/**
|
||||||
|
* Message Type is stored as the fifth byte of the message data
|
||||||
|
* @param status
|
||||||
|
*/
|
||||||
|
void setMessageType(messageType status);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* First four bytes of message data
|
||||||
|
* @param address
|
||||||
|
*/
|
||||||
|
void setAddress(uint32_t address);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Stored in Bytes 13-16 of message data
|
||||||
|
* @param length
|
||||||
|
*/
|
||||||
|
void setDataLen(uint32_t length);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Stored in last four bytes (Bytes 17-20) of message data
|
||||||
|
* @param sendData
|
||||||
|
*/
|
||||||
|
void setDataPointer(const uint8_t * sendData);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Buffer Position is stored 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
|
||||||
|
*/
|
||||||
|
void setReceiveBufferPosition(uint16_t bufferPosition);
|
||||||
|
void setStoreId(store_address_t storeId);
|
||||||
|
|
||||||
virtual ~CommunicationMessage();
|
virtual ~CommunicationMessage();
|
||||||
|
|
||||||
|
bool uninitialized;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#endif /* FRAMEWORK_DEVICEHANDLERS_COMMUNICATIONMESSAGE_H_ */
|
#endif /* FRAMEWORK_DEVICEHANDLERS_COMMUNICATIONMESSAGE_H_ */
|
||||||
|
@ -22,7 +22,8 @@
|
|||||||
* 4. Read received data
|
* 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.
|
||||||
*/
|
*/
|
||||||
class DeviceCommunicationIF: public HasReturnvaluesIF {
|
class DeviceCommunicationIF: public HasReturnvaluesIF {
|
||||||
public:
|
public:
|
||||||
|
@ -31,7 +31,7 @@ public:
|
|||||||
* \brief This attribute defines when a device handler object is executed.
|
* \brief This attribute defines when a device handler object is executed.
|
||||||
*
|
*
|
||||||
* \details The pollingTime attribute identifies the time the handler is executed in ms. It must be
|
* \details The pollingTime attribute identifies the time the handler is executed in ms. It must be
|
||||||
* smaller than the period length of the polling sequence, what is ensured by automated calculation
|
* smaller than the period length of the polling sequence, which is ensured by automated calculation
|
||||||
* from a database.
|
* from a database.
|
||||||
*/
|
*/
|
||||||
uint32_t pollingTimeMs;
|
uint32_t pollingTimeMs;
|
||||||
|
Loading…
Reference in New Issue
Block a user