Merge pull request 'RMAP folder convergence' (#302) from KSat/fsfw:mueller/rmap-convergence into development
Reviewed-on: fsfw/fsfw#302
This commit is contained in:
commit
c53920f5ac
@ -1,8 +1,10 @@
|
|||||||
#include "../devicehandlers/DeviceCommunicationIF.h"
|
|
||||||
#include "rmapStructs.h"
|
|
||||||
#include "RMAP.h"
|
#include "RMAP.h"
|
||||||
|
#include "rmapStructs.h"
|
||||||
#include "RMAPChannelIF.h"
|
#include "RMAPChannelIF.h"
|
||||||
#include <stddef.h>
|
|
||||||
|
#include "../devicehandlers/DeviceCommunicationIF.h"
|
||||||
|
|
||||||
|
#include <cstddef>
|
||||||
|
|
||||||
ReturnValue_t RMAP::reset(RMAPCookie* cookie) {
|
ReturnValue_t RMAP::reset(RMAPCookie* cookie) {
|
||||||
return cookie->getChannel()->reset();
|
return cookie->getChannel()->reset();
|
||||||
@ -12,8 +14,8 @@ RMAP::RMAP(){
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ReturnValue_t RMAP::sendWriteCommand(RMAPCookie *cookie, uint8_t* buffer,
|
ReturnValue_t RMAP::sendWriteCommand(RMAPCookie *cookie, const uint8_t* buffer,
|
||||||
uint32_t length) {
|
size_t length) {
|
||||||
uint8_t instruction;
|
uint8_t instruction;
|
||||||
|
|
||||||
if ((buffer == NULL) && (length != 0)) {
|
if ((buffer == NULL) && (length != 0)) {
|
||||||
@ -61,7 +63,7 @@ ReturnValue_t RMAP::sendReadCommand(RMAPCookie *cookie, uint32_t expLength) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ReturnValue_t RMAP::getReadReply(RMAPCookie *cookie, uint8_t **buffer,
|
ReturnValue_t RMAP::getReadReply(RMAPCookie *cookie, uint8_t **buffer,
|
||||||
uint32_t *size) {
|
size_t *size) {
|
||||||
if (cookie->getChannel() == NULL) {
|
if (cookie->getChannel() == NULL) {
|
||||||
return COMMAND_NO_CHANNEL;
|
return COMMAND_NO_CHANNEL;
|
||||||
}
|
}
|
||||||
|
12
rmap/RMAP.h
12
rmap/RMAP.h
@ -1,8 +1,8 @@
|
|||||||
#ifndef RMAPpp_H_
|
#ifndef FSFW_RMAP_RMAP_H_
|
||||||
#define RMAPpp_H_
|
#define FSFW_RMAP_RMAP_H_
|
||||||
|
|
||||||
#include "../returnvalues/HasReturnvaluesIF.h"
|
#include "../returnvalues/HasReturnvaluesIF.h"
|
||||||
#include "RMAPCookie.h"
|
#include "../rmap/RMAPCookie.h"
|
||||||
|
|
||||||
//SHOULDTODO: clean up includes for RMAP, should be enough to include RMAP.h but right now it's quite chaotic...
|
//SHOULDTODO: clean up includes for RMAP, should be enough to include RMAP.h but right now it's quite chaotic...
|
||||||
|
|
||||||
@ -153,8 +153,8 @@ public:
|
|||||||
* - @c COMMAND_NULLPOINTER datalen was != 0 but data was == NULL in write command
|
* - @c COMMAND_NULLPOINTER datalen was != 0 but data was == NULL in write command
|
||||||
* - return codes of RMAPChannelIF::sendCommand()
|
* - return codes of RMAPChannelIF::sendCommand()
|
||||||
*/
|
*/
|
||||||
static ReturnValue_t sendWriteCommand(RMAPCookie *cookie, uint8_t* buffer,
|
static ReturnValue_t sendWriteCommand(RMAPCookie *cookie, const uint8_t* buffer,
|
||||||
uint32_t length);
|
size_t length);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* get the reply to a write command
|
* get the reply to a write command
|
||||||
@ -204,7 +204,7 @@ public:
|
|||||||
* - return codes of RMAPChannelIF::getReply()
|
* - return codes of RMAPChannelIF::getReply()
|
||||||
*/
|
*/
|
||||||
static ReturnValue_t getReadReply(RMAPCookie *cookie, uint8_t **buffer,
|
static ReturnValue_t getReadReply(RMAPCookie *cookie, uint8_t **buffer,
|
||||||
uint32_t *size);
|
size_t *size);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see sendReadCommand()
|
* @see sendReadCommand()
|
||||||
|
@ -1,8 +1,9 @@
|
|||||||
#ifndef RMAPCHANNELIF_H_
|
#ifndef FSFW_RMAP_RMAPCHANNELIF_H_
|
||||||
#define RMAPCHANNELIF_H_
|
#define FSFW_RMAP_RMAPCHANNELIF_H_
|
||||||
|
|
||||||
#include "RMAPCookie.h"
|
#include "RMAPCookie.h"
|
||||||
#include "../returnvalues/HasReturnvaluesIF.h"
|
#include "../returnvalues/HasReturnvaluesIF.h"
|
||||||
|
#include <cstddef>
|
||||||
|
|
||||||
class RMAPChannelIF {
|
class RMAPChannelIF {
|
||||||
public:
|
public:
|
||||||
@ -73,7 +74,7 @@ public:
|
|||||||
* - @c NOT_SUPPORTED if you dont feel like implementing something...
|
* - @c NOT_SUPPORTED if you dont feel like implementing something...
|
||||||
*/
|
*/
|
||||||
virtual ReturnValue_t sendCommand(RMAPCookie *cookie, uint8_t instruction,
|
virtual ReturnValue_t sendCommand(RMAPCookie *cookie, uint8_t instruction,
|
||||||
uint8_t *data, uint32_t datalen)=0;
|
const uint8_t *data, size_t datalen)=0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* get the reply to an rmap command
|
* get the reply to an rmap command
|
||||||
@ -92,7 +93,7 @@ public:
|
|||||||
* - all RMAP standard replies
|
* - all RMAP standard replies
|
||||||
*/
|
*/
|
||||||
virtual ReturnValue_t getReply(RMAPCookie *cookie, uint8_t **databuffer,
|
virtual ReturnValue_t getReply(RMAPCookie *cookie, uint8_t **databuffer,
|
||||||
uint32_t *len)=0;
|
size_t *len)=0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@ -112,4 +113,4 @@ public:
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* RMAPCHANNELIF_H_ */
|
#endif /* FSFW_RMAP_RMAPCHANNELIF_H_ */
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#include "RMAPChannelIF.h"
|
#include "RMAPChannelIF.h"
|
||||||
#include "RMAPCookie.h"
|
#include "RMAPCookie.h"
|
||||||
#include <stddef.h>
|
#include <cstddef>
|
||||||
|
|
||||||
|
|
||||||
RMAPCookie::RMAPCookie() {
|
RMAPCookie::RMAPCookie() {
|
||||||
@ -31,7 +31,8 @@ RMAPCookie::RMAPCookie() {
|
|||||||
|
|
||||||
|
|
||||||
RMAPCookie::RMAPCookie(uint32_t set_address, uint8_t set_extended_address,
|
RMAPCookie::RMAPCookie(uint32_t set_address, uint8_t set_extended_address,
|
||||||
RMAPChannelIF *set_channel, uint8_t set_command_mask, uint32_t maxReplyLen) {
|
RMAPChannelIF *set_channel, uint8_t set_command_mask,
|
||||||
|
size_t maxReplyLen) {
|
||||||
this->header.dest_address = 0;
|
this->header.dest_address = 0;
|
||||||
this->header.protocol = 0x01;
|
this->header.protocol = 0x01;
|
||||||
this->header.instruction = 0;
|
this->header.instruction = 0;
|
||||||
@ -93,11 +94,11 @@ RMAPCookie::~RMAPCookie() {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t RMAPCookie::getMaxReplyLen() const {
|
size_t RMAPCookie::getMaxReplyLen() const {
|
||||||
return maxReplyLen;
|
return maxReplyLen;
|
||||||
}
|
}
|
||||||
|
|
||||||
void RMAPCookie::setMaxReplyLen(uint32_t maxReplyLen) {
|
void RMAPCookie::setMaxReplyLen(size_t maxReplyLen) {
|
||||||
this->maxReplyLen = maxReplyLen;
|
this->maxReplyLen = maxReplyLen;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,8 +1,9 @@
|
|||||||
#ifndef RMAPCOOKIE_H_
|
#ifndef FSFW_RMAP_RMAPCOOKIE_H_
|
||||||
#define RMAPCOOKIE_H_
|
#define FSFW_RMAP_RMAPCOOKIE_H_
|
||||||
|
|
||||||
#include "../devicehandlers/CookieIF.h"
|
|
||||||
#include "rmapStructs.h"
|
#include "rmapStructs.h"
|
||||||
|
#include "../devicehandlers/CookieIF.h"
|
||||||
|
#include <cstddef>
|
||||||
|
|
||||||
class RMAPChannelIF;
|
class RMAPChannelIF;
|
||||||
|
|
||||||
@ -12,7 +13,8 @@ public:
|
|||||||
RMAPCookie();
|
RMAPCookie();
|
||||||
|
|
||||||
RMAPCookie(uint32_t set_address, uint8_t set_extended_address,
|
RMAPCookie(uint32_t set_address, uint8_t set_extended_address,
|
||||||
RMAPChannelIF *set_channel, uint8_t set_command_mask, uint32_t maxReplyLen = 0);
|
RMAPChannelIF *set_channel, uint8_t set_command_mask,
|
||||||
|
size_t maxReplyLen = 0);
|
||||||
virtual ~RMAPCookie();
|
virtual ~RMAPCookie();
|
||||||
|
|
||||||
|
|
||||||
@ -28,8 +30,8 @@ public:
|
|||||||
void setCommandMask(uint8_t commandMask);
|
void setCommandMask(uint8_t commandMask);
|
||||||
uint8_t getCommandMask();
|
uint8_t getCommandMask();
|
||||||
|
|
||||||
uint32_t getMaxReplyLen() const;
|
size_t getMaxReplyLen() const;
|
||||||
void setMaxReplyLen(uint32_t maxReplyLen);
|
void setMaxReplyLen(size_t maxReplyLen);
|
||||||
|
|
||||||
uint16_t getTransactionIdentifier() const;
|
uint16_t getTransactionIdentifier() const;
|
||||||
void setTransactionIdentifier(uint16_t id_);
|
void setTransactionIdentifier(uint16_t id_);
|
||||||
@ -55,4 +57,4 @@ protected:
|
|||||||
uint8_t dataCRC;
|
uint8_t dataCRC;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* RMAPCOOKIE_H_ */
|
#endif /* FSFW_RMAP_RMAPCOOKIE_H_ */
|
||||||
|
@ -6,8 +6,8 @@ RmapDeviceCommunicationIF::~RmapDeviceCommunicationIF() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ReturnValue_t RmapDeviceCommunicationIF::sendMessage(CookieIF *cookie,
|
ReturnValue_t RmapDeviceCommunicationIF::sendMessage(CookieIF *cookie,
|
||||||
uint8_t* data, uint32_t len) {
|
const uint8_t * sendData, size_t sendLen) {
|
||||||
return RMAP::sendWriteCommand((RMAPCookie *) cookie, data, len);
|
return RMAP::sendWriteCommand((RMAPCookie *) cookie, sendData, sendLen);
|
||||||
}
|
}
|
||||||
|
|
||||||
ReturnValue_t RmapDeviceCommunicationIF::getSendSuccess(CookieIF* cookie) {
|
ReturnValue_t RmapDeviceCommunicationIF::getSendSuccess(CookieIF* cookie) {
|
||||||
@ -15,13 +15,13 @@ ReturnValue_t RmapDeviceCommunicationIF::getSendSuccess(CookieIF* cookie) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ReturnValue_t RmapDeviceCommunicationIF::requestReceiveMessage(
|
ReturnValue_t RmapDeviceCommunicationIF::requestReceiveMessage(
|
||||||
CookieIF* cookie) {
|
CookieIF *cookie, size_t requestLen) {
|
||||||
return RMAP::sendReadCommand((RMAPCookie *) cookie,
|
return RMAP::sendReadCommand((RMAPCookie *) cookie,
|
||||||
((RMAPCookie *) cookie)->getMaxReplyLen());
|
((RMAPCookie *) cookie)->getMaxReplyLen());
|
||||||
}
|
}
|
||||||
|
|
||||||
ReturnValue_t RmapDeviceCommunicationIF::readReceivedMessage(CookieIF* cookie,
|
ReturnValue_t RmapDeviceCommunicationIF::readReceivedMessage(CookieIF* cookie,
|
||||||
uint8_t** buffer, uint32_t* size) {
|
uint8_t** buffer, size_t * size) {
|
||||||
return RMAP::getReadReply((RMAPCookie *) cookie, buffer, size);
|
return RMAP::getReadReply((RMAPCookie *) cookie, buffer, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,10 +1,11 @@
|
|||||||
#ifndef MISSION_RMAP_RMAPDEVICECOMMUNICATIONINTERFACE_H_
|
#ifndef FSFW_RMAP_RMAPDEVICECOMMUNICATIONINTERFACE_H_
|
||||||
#define MISSION_RMAP_RMAPDEVICECOMMUNICATIONINTERFACE_H_
|
#define FSFW_RMAP_RMAPDEVICECOMMUNICATIONINTERFACE_H_
|
||||||
|
|
||||||
#include "../devicehandlers/DeviceCommunicationIF.h"
|
#include "../devicehandlers/DeviceCommunicationIF.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief This class is a implementation of a DeviceCommunicationIF for RMAP calls. It expects RMAPCookies or a derived class of RMAPCookies
|
* @brief This class is a implementation of a DeviceCommunicationIF for RMAP calls.
|
||||||
|
* It expects RMAPCookies or a derived class of RMAPCookies
|
||||||
*
|
*
|
||||||
* @details The open, close and reOpen calls are mission specific
|
* @details The open, close and reOpen calls are mission specific
|
||||||
* The open call might return any child of RMAPCookies
|
* The open call might return any child of RMAPCookies
|
||||||
@ -16,65 +17,73 @@ class RmapDeviceCommunicationIF: public DeviceCommunicationIF {
|
|||||||
public:
|
public:
|
||||||
virtual ~RmapDeviceCommunicationIF();
|
virtual ~RmapDeviceCommunicationIF();
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method is mission specific as the open call will return a mission specific cookie
|
* @brief Device specific initialization, using the cookie.
|
||||||
*
|
* @details
|
||||||
* @param cookie A cookie, can be mission specific subclass of RMAP Cookie
|
* The cookie is already prepared in the factory. If the communication
|
||||||
* @param address The address of the RMAP Cookie
|
* interface needs to be set up in some way and requires cookie information,
|
||||||
* @param maxReplyLen Maximum length of expected reply
|
* this can be performed in this function, which is called on device handler
|
||||||
* @return
|
* initialization.
|
||||||
*/
|
|
||||||
virtual ReturnValue_t open(CookieIF **cookie, uint32_t address,
|
|
||||||
uint32_t maxReplyLen) = 0;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Use an existing cookie to open a connection to a new DeviceCommunication.
|
|
||||||
* The previous connection must not be closed.
|
|
||||||
* If the returnvalue is not RETURN_OK, the cookie is unchanged and
|
|
||||||
* can be used with the previous connection.
|
|
||||||
*
|
|
||||||
* @param cookie
|
* @param cookie
|
||||||
* @param address
|
* @return -@c RETURN_OK if initialization was successfull
|
||||||
* @param maxReplyLen
|
* - Everything else triggers failure event with returnvalue as parameter 1
|
||||||
* @return
|
|
||||||
*/
|
*/
|
||||||
virtual ReturnValue_t reOpen(CookieIF *cookie, uint32_t address,
|
virtual ReturnValue_t initializeInterface(CookieIF * cookie) = 0;
|
||||||
uint32_t maxReplyLen) = 0;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Closing call of connection and memory free of cookie. Mission dependent call
|
* Called by DHB in the SEND_WRITE doSendWrite().
|
||||||
|
* This function is used to send data to the physical device
|
||||||
|
* by implementing and calling related drivers or wrapper functions.
|
||||||
* @param cookie
|
* @param cookie
|
||||||
|
* @param data
|
||||||
|
* @param len
|
||||||
|
* @return -@c RETURN_OK for successfull send
|
||||||
|
* - Everything else triggers failure event with returnvalue as parameter 1
|
||||||
*/
|
*/
|
||||||
virtual void close(CookieIF *cookie) = 0;
|
virtual ReturnValue_t sendMessage(CookieIF *cookie, const uint8_t * sendData,
|
||||||
|
size_t sendLen);
|
||||||
|
|
||||||
//SHOULDDO can data be const?
|
|
||||||
/**
|
/**
|
||||||
*
|
* Called by DHB in the GET_WRITE doGetWrite().
|
||||||
*
|
* Get send confirmation that the data in sendMessage() was sent successfully.
|
||||||
* @param cookie Expects an RMAPCookie or derived from RMAPCookie Class
|
* @param cookie
|
||||||
* @param data Data to be send
|
* @return -@c RETURN_OK if data was sent successfull
|
||||||
* @param len Length of the data to be send
|
* - Everything else triggers falure event with returnvalue as parameter 1
|
||||||
* @return - Return codes of RMAP::sendWriteCommand()
|
|
||||||
*/
|
*/
|
||||||
virtual ReturnValue_t sendMessage(CookieIF *cookie, uint8_t *data,
|
|
||||||
uint32_t len);
|
|
||||||
|
|
||||||
virtual ReturnValue_t getSendSuccess(CookieIF *cookie);
|
virtual ReturnValue_t getSendSuccess(CookieIF *cookie);
|
||||||
|
|
||||||
virtual ReturnValue_t requestReceiveMessage(CookieIF *cookie);
|
/**
|
||||||
|
* Called by DHB in the SEND_WRITE doSendRead().
|
||||||
|
* It is assumed that it is always possible to request a reply
|
||||||
|
* from a device.
|
||||||
|
*
|
||||||
|
* @param cookie
|
||||||
|
* @return -@c RETURN_OK to confirm the request for data has been sent.
|
||||||
|
* -@c NO_READ_REQUEST if no request shall be made. readReceivedMessage()
|
||||||
|
* will not be called in the respective communication cycle.
|
||||||
|
* - Everything else triggers failure event with returnvalue as parameter 1
|
||||||
|
*/
|
||||||
|
virtual ReturnValue_t requestReceiveMessage(CookieIF *cookie, size_t requestLen);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called by DHB in the GET_WRITE doGetRead().
|
||||||
|
* This function is used to receive data from the physical device
|
||||||
|
* by implementing and calling related drivers or wrapper functions.
|
||||||
|
* @param cookie
|
||||||
|
* @param data
|
||||||
|
* @param len
|
||||||
|
* @return @c RETURN_OK for successfull receive
|
||||||
|
* - Everything else triggers failure event with returnvalue as parameter 1
|
||||||
|
*/
|
||||||
virtual ReturnValue_t readReceivedMessage(CookieIF *cookie, uint8_t **buffer,
|
virtual ReturnValue_t readReceivedMessage(CookieIF *cookie, uint8_t **buffer,
|
||||||
uint32_t *size);
|
size_t *size);
|
||||||
|
|
||||||
virtual ReturnValue_t setAddress(CookieIF *cookie, uint32_t address);
|
ReturnValue_t setAddress(CookieIF* cookie,
|
||||||
|
uint32_t address);
|
||||||
virtual uint32_t getAddress(CookieIF *cookie);
|
uint32_t getAddress(CookieIF* cookie);
|
||||||
|
ReturnValue_t setParameter(CookieIF* cookie,
|
||||||
virtual ReturnValue_t setParameter(CookieIF *cookie, uint32_t parameter);
|
uint32_t parameter);
|
||||||
|
uint32_t getParameter(CookieIF* cookie);
|
||||||
virtual uint32_t getParameter(CookieIF *cookie);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* MISSION_RMAP_RMAPDEVICECOMMUNICATIONINTERFACE_H_ */
|
#endif /* FSFW_RMAP_RMAPDEVICECOMMUNICATIONINTERFACE_H_ */
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#ifndef RMAPSTRUCTS_H_
|
#ifndef FSFW_RMAP_RMAPSTRUCTS_H_
|
||||||
#define RMAPSTRUCTS_H_
|
#define FSFW_RMAP_RMAPSTRUCTS_H_
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <cstdint>
|
||||||
|
|
||||||
//SHOULDDO: having the defines within a namespace would be nice. Problem are the defines referencing the previous define, eg RMAP_COMMAND_WRITE
|
//SHOULDDO: having the defines within a namespace would be nice. Problem are the defines referencing the previous define, eg RMAP_COMMAND_WRITE
|
||||||
|
|
||||||
@ -95,4 +95,4 @@ struct rmap_write_reply_header {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* RMAPSTRUCTS_H_ */
|
#endif /* FSFW_RMAP_RMAPSTRUCTS_H_ */
|
||||||
|
Loading…
Reference in New Issue
Block a user