Merge remote-tracking branch 'origin/mueller_CookieToCookieIF' into mueller_newDeviceCommunicationIF

This commit is contained in:
Robin Müller 2020-04-19 15:30:14 +02:00
commit bb650ac784
7 changed files with 60 additions and 36 deletions

View File

@ -1,10 +0,0 @@
#ifndef COOKIE_H_
#define COOKIE_H_
class Cookie{
public:
virtual ~Cookie(){}
};
#endif /* COOKIE_H_ */

34
devicehandlers/CookieIF.h Normal file
View File

@ -0,0 +1,34 @@
#ifndef COOKIE_H_
#define COOKIE_H_
#include <cstdint>
/**
* @brief Physical address type
*/
typedef std::uint32_t address_t;
/**
* @brief This datatype is used to identify different connection over a
* single interface (like RMAP or I2C)
* @details
* To use this class, implement a communication specific child cookie which
* inherits Cookie. Cookie instances are created in config/Factory.cpp by
* calling @code{.cpp} CookieIF* childCookie = new ChildCookie(...)
* @endcode .
*
* [not implemented yet]
* This cookie is then passed to the child device handlers, which stores the
* pointer and passes it to the communication interface functions.
*
* 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 CookieIF {
public:
virtual ~CookieIF() {};
};
#endif /* COOKIE_H_ */

View File

@ -2,7 +2,6 @@
#define DEVICECOMMUNICATIONIF_H_
#include <framework/devicehandlers/CookieIF.h>
#include <framework/devicehandlers/DeviceHandlerIF.h>
#include <framework/returnvalues/HasReturnvaluesIF.h>
/**
* @defgroup interfaces Interfaces
@ -78,7 +77,7 @@ public:
* - Everything else triggers failure event with returnvalue as parameter 1
*/
virtual ReturnValue_t sendMessage(CookieIF *cookie, const uint8_t * sendData,
size_t sendLen) = 0;
uint32_t sendLen) = 0;
/**
* Called by DHB in the GET_WRITE doGetWrite().
@ -103,7 +102,8 @@ public:
* - Everything else triggers failure event with
* returnvalue as parameter 1
*/
virtual ReturnValue_t requestReceiveMessage(CookieIF *cookie, size_t requestLen) = 0;
virtual ReturnValue_t requestReceiveMessage(CookieIF *cookie,
uint32_t requestLen) = 0;
/**
* Called by DHB in the GET_WRITE doGetRead().
@ -120,7 +120,7 @@ public:
* returnvalue as parameter 1
*/
virtual ReturnValue_t readReceivedMessage(CookieIF *cookie, uint8_t **buffer,
size_t *size) = 0;
uint32_t *size) = 0;
};
#endif /* DEVICECOMMUNICATIONIF_H_ */

View File

@ -244,7 +244,7 @@ protected:
/**
* Cookie used for communication
*/
Cookie *cookie;
CookieIF *cookie;
/**
* The MessageQueue used to receive device handler commands and to send replies.

View File

@ -1,12 +1,12 @@
#ifndef RMAPCOOKIE_H_
#define RMAPCOOKIE_H_
#include <framework/devicehandlers/Cookie.h>
#include <framework/devicehandlers/CookieIF.h>
#include <framework/rmap/rmapStructs.h>
class RMAPChannelIF;
class RMAPCookie : public Cookie{
class RMAPCookie : public CookieIF {
public:
//To Uli: Sorry, I need an empty ctor to initialize an array of cookies.
RMAPCookie();

View File

@ -5,43 +5,43 @@
RmapDeviceCommunicationIF::~RmapDeviceCommunicationIF() {
}
ReturnValue_t RmapDeviceCommunicationIF::sendMessage(Cookie* cookie,
ReturnValue_t RmapDeviceCommunicationIF::sendMessage(CookieIF* cookie,
uint8_t* data, uint32_t len) {
return RMAP::sendWriteCommand((RMAPCookie *) cookie, data, len);
}
ReturnValue_t RmapDeviceCommunicationIF::getSendSuccess(Cookie* cookie) {
ReturnValue_t RmapDeviceCommunicationIF::getSendSuccess(CookieIF* cookie) {
return RMAP::getWriteReply((RMAPCookie *) cookie);
}
ReturnValue_t RmapDeviceCommunicationIF::requestReceiveMessage(
Cookie* cookie) {
CookieIF* cookie) {
return RMAP::sendReadCommand((RMAPCookie *) cookie,
((RMAPCookie *) cookie)->getMaxReplyLen());
}
ReturnValue_t RmapDeviceCommunicationIF::readReceivedMessage(Cookie* cookie,
ReturnValue_t RmapDeviceCommunicationIF::readReceivedMessage(CookieIF* cookie,
uint8_t** buffer, uint32_t* size) {
return RMAP::getReadReply((RMAPCookie *) cookie, buffer, size);
}
ReturnValue_t RmapDeviceCommunicationIF::setAddress(Cookie* cookie,
ReturnValue_t RmapDeviceCommunicationIF::setAddress(CookieIF* cookie,
uint32_t address) {
((RMAPCookie *) cookie)->setAddress(address);
return HasReturnvaluesIF::RETURN_OK;
}
uint32_t RmapDeviceCommunicationIF::getAddress(Cookie* cookie) {
uint32_t RmapDeviceCommunicationIF::getAddress(CookieIF* cookie) {
return ((RMAPCookie *) cookie)->getAddress();
}
ReturnValue_t RmapDeviceCommunicationIF::setParameter(Cookie* cookie,
ReturnValue_t RmapDeviceCommunicationIF::setParameter(CookieIF* cookie,
uint32_t parameter) {
//TODO Empty?
return HasReturnvaluesIF::RETURN_FAILED;
}
uint32_t RmapDeviceCommunicationIF::getParameter(Cookie* cookie) {
uint32_t RmapDeviceCommunicationIF::getParameter(CookieIF* cookie) {
return 0;
}

View File

@ -25,7 +25,7 @@ public:
* @param maxReplyLen Maximum length of expected reply
* @return
*/
virtual ReturnValue_t open(Cookie **cookie, uint32_t address,
virtual ReturnValue_t open(CookieIF **cookie, uint32_t address,
uint32_t maxReplyLen) = 0;
/**
@ -39,7 +39,7 @@ public:
* @param maxReplyLen
* @return
*/
virtual ReturnValue_t reOpen(Cookie *cookie, uint32_t address,
virtual ReturnValue_t reOpen(CookieIF *cookie, uint32_t address,
uint32_t maxReplyLen) = 0;
@ -47,7 +47,7 @@ public:
* Closing call of connection and memory free of cookie. Mission dependent call
* @param cookie
*/
virtual void close(Cookie *cookie) = 0;
virtual void close(CookieIF *cookie) = 0;
//SHOULDDO can data be const?
/**
@ -58,23 +58,23 @@ public:
* @param len Length of the data to be send
* @return - Return codes of RMAP::sendWriteCommand()
*/
virtual ReturnValue_t sendMessage(Cookie *cookie, uint8_t *data,
virtual ReturnValue_t sendMessage(CookieIF *cookie, uint8_t *data,
uint32_t len);
virtual ReturnValue_t getSendSuccess(Cookie *cookie);
virtual ReturnValue_t getSendSuccess(CookieIF *cookie);
virtual ReturnValue_t requestReceiveMessage(Cookie *cookie);
virtual ReturnValue_t requestReceiveMessage(CookieIF *cookie);
virtual ReturnValue_t readReceivedMessage(Cookie *cookie, uint8_t **buffer,
virtual ReturnValue_t readReceivedMessage(CookieIF *cookie, uint8_t **buffer,
uint32_t *size);
virtual ReturnValue_t setAddress(Cookie *cookie, uint32_t address);
virtual ReturnValue_t setAddress(CookieIF *cookie, uint32_t address);
virtual uint32_t getAddress(Cookie *cookie);
virtual uint32_t getAddress(CookieIF *cookie);
virtual ReturnValue_t setParameter(Cookie *cookie, uint32_t parameter);
virtual ReturnValue_t setParameter(CookieIF *cookie, uint32_t parameter);
virtual uint32_t getParameter(Cookie *cookie);
virtual uint32_t getParameter(CookieIF *cookie);
};
#endif /* MISSION_RMAP_RMAPDEVICECOMMUNICATIONINTERFACE_H_ */