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 "rmapStructs.h"
|
||||
#include "RMAPChannelIF.h"
|
||||
#include <stddef.h>
|
||||
|
||||
#include "../devicehandlers/DeviceCommunicationIF.h"
|
||||
|
||||
#include <cstddef>
|
||||
|
||||
ReturnValue_t RMAP::reset(RMAPCookie* cookie) {
|
||||
return cookie->getChannel()->reset();
|
||||
@ -12,8 +14,8 @@ RMAP::RMAP(){
|
||||
|
||||
}
|
||||
|
||||
ReturnValue_t RMAP::sendWriteCommand(RMAPCookie *cookie, uint8_t* buffer,
|
||||
uint32_t length) {
|
||||
ReturnValue_t RMAP::sendWriteCommand(RMAPCookie *cookie, const uint8_t* buffer,
|
||||
size_t length) {
|
||||
uint8_t instruction;
|
||||
|
||||
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,
|
||||
uint32_t *size) {
|
||||
size_t *size) {
|
||||
if (cookie->getChannel() == NULL) {
|
||||
return COMMAND_NO_CHANNEL;
|
||||
}
|
||||
|
12
rmap/RMAP.h
12
rmap/RMAP.h
@ -1,8 +1,8 @@
|
||||
#ifndef RMAPpp_H_
|
||||
#define RMAPpp_H_
|
||||
#ifndef FSFW_RMAP_RMAP_H_
|
||||
#define FSFW_RMAP_RMAP_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...
|
||||
|
||||
@ -153,8 +153,8 @@ public:
|
||||
* - @c COMMAND_NULLPOINTER datalen was != 0 but data was == NULL in write command
|
||||
* - return codes of RMAPChannelIF::sendCommand()
|
||||
*/
|
||||
static ReturnValue_t sendWriteCommand(RMAPCookie *cookie, uint8_t* buffer,
|
||||
uint32_t length);
|
||||
static ReturnValue_t sendWriteCommand(RMAPCookie *cookie, const uint8_t* buffer,
|
||||
size_t length);
|
||||
|
||||
/**
|
||||
* get the reply to a write command
|
||||
@ -204,7 +204,7 @@ public:
|
||||
* - return codes of RMAPChannelIF::getReply()
|
||||
*/
|
||||
static ReturnValue_t getReadReply(RMAPCookie *cookie, uint8_t **buffer,
|
||||
uint32_t *size);
|
||||
size_t *size);
|
||||
|
||||
/**
|
||||
* @see sendReadCommand()
|
||||
|
@ -1,8 +1,9 @@
|
||||
#ifndef RMAPCHANNELIF_H_
|
||||
#define RMAPCHANNELIF_H_
|
||||
#ifndef FSFW_RMAP_RMAPCHANNELIF_H_
|
||||
#define FSFW_RMAP_RMAPCHANNELIF_H_
|
||||
|
||||
#include "RMAPCookie.h"
|
||||
#include "../returnvalues/HasReturnvaluesIF.h"
|
||||
#include <cstddef>
|
||||
|
||||
class RMAPChannelIF {
|
||||
public:
|
||||
@ -73,7 +74,7 @@ public:
|
||||
* - @c NOT_SUPPORTED if you dont feel like implementing something...
|
||||
*/
|
||||
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
|
||||
@ -92,7 +93,7 @@ public:
|
||||
* - all RMAP standard replies
|
||||
*/
|
||||
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 "RMAPCookie.h"
|
||||
#include <stddef.h>
|
||||
#include <cstddef>
|
||||
|
||||
|
||||
RMAPCookie::RMAPCookie() {
|
||||
@ -31,7 +31,8 @@ RMAPCookie::RMAPCookie() {
|
||||
|
||||
|
||||
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.protocol = 0x01;
|
||||
this->header.instruction = 0;
|
||||
@ -93,11 +94,11 @@ RMAPCookie::~RMAPCookie() {
|
||||
|
||||
}
|
||||
|
||||
uint32_t RMAPCookie::getMaxReplyLen() const {
|
||||
size_t RMAPCookie::getMaxReplyLen() const {
|
||||
return maxReplyLen;
|
||||
}
|
||||
|
||||
void RMAPCookie::setMaxReplyLen(uint32_t maxReplyLen) {
|
||||
void RMAPCookie::setMaxReplyLen(size_t maxReplyLen) {
|
||||
this->maxReplyLen = maxReplyLen;
|
||||
}
|
||||
|
||||
|
@ -1,8 +1,9 @@
|
||||
#ifndef RMAPCOOKIE_H_
|
||||
#define RMAPCOOKIE_H_
|
||||
#ifndef FSFW_RMAP_RMAPCOOKIE_H_
|
||||
#define FSFW_RMAP_RMAPCOOKIE_H_
|
||||
|
||||
#include "../devicehandlers/CookieIF.h"
|
||||
#include "rmapStructs.h"
|
||||
#include "../devicehandlers/CookieIF.h"
|
||||
#include <cstddef>
|
||||
|
||||
class RMAPChannelIF;
|
||||
|
||||
@ -12,7 +13,8 @@ public:
|
||||
RMAPCookie();
|
||||
|
||||
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();
|
||||
|
||||
|
||||
@ -28,8 +30,8 @@ public:
|
||||
void setCommandMask(uint8_t commandMask);
|
||||
uint8_t getCommandMask();
|
||||
|
||||
uint32_t getMaxReplyLen() const;
|
||||
void setMaxReplyLen(uint32_t maxReplyLen);
|
||||
size_t getMaxReplyLen() const;
|
||||
void setMaxReplyLen(size_t maxReplyLen);
|
||||
|
||||
uint16_t getTransactionIdentifier() const;
|
||||
void setTransactionIdentifier(uint16_t id_);
|
||||
@ -55,4 +57,4 @@ protected:
|
||||
uint8_t dataCRC;
|
||||
};
|
||||
|
||||
#endif /* RMAPCOOKIE_H_ */
|
||||
#endif /* FSFW_RMAP_RMAPCOOKIE_H_ */
|
||||
|
@ -5,9 +5,9 @@
|
||||
RmapDeviceCommunicationIF::~RmapDeviceCommunicationIF() {
|
||||
}
|
||||
|
||||
ReturnValue_t RmapDeviceCommunicationIF::sendMessage(CookieIF* cookie,
|
||||
uint8_t* data, uint32_t len) {
|
||||
return RMAP::sendWriteCommand((RMAPCookie *) cookie, data, len);
|
||||
ReturnValue_t RmapDeviceCommunicationIF::sendMessage(CookieIF *cookie,
|
||||
const uint8_t * sendData, size_t sendLen) {
|
||||
return RMAP::sendWriteCommand((RMAPCookie *) cookie, sendData, sendLen);
|
||||
}
|
||||
|
||||
ReturnValue_t RmapDeviceCommunicationIF::getSendSuccess(CookieIF* cookie) {
|
||||
@ -15,13 +15,13 @@ ReturnValue_t RmapDeviceCommunicationIF::getSendSuccess(CookieIF* cookie) {
|
||||
}
|
||||
|
||||
ReturnValue_t RmapDeviceCommunicationIF::requestReceiveMessage(
|
||||
CookieIF* cookie) {
|
||||
CookieIF *cookie, size_t requestLen) {
|
||||
return RMAP::sendReadCommand((RMAPCookie *) cookie,
|
||||
((RMAPCookie *) cookie)->getMaxReplyLen());
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
|
@ -1,10 +1,11 @@
|
||||
#ifndef MISSION_RMAP_RMAPDEVICECOMMUNICATIONINTERFACE_H_
|
||||
#define MISSION_RMAP_RMAPDEVICECOMMUNICATIONINTERFACE_H_
|
||||
#ifndef FSFW_RMAP_RMAPDEVICECOMMUNICATIONINTERFACE_H_
|
||||
#define FSFW_RMAP_RMAPDEVICECOMMUNICATIONINTERFACE_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
|
||||
* The open call might return any child of RMAPCookies
|
||||
@ -16,65 +17,73 @@ class RmapDeviceCommunicationIF: public DeviceCommunicationIF {
|
||||
public:
|
||||
virtual ~RmapDeviceCommunicationIF();
|
||||
|
||||
|
||||
/**
|
||||
* This method is mission specific as the open call will return a mission specific cookie
|
||||
*
|
||||
* @param cookie A cookie, can be mission specific subclass of RMAP Cookie
|
||||
* @param address The address of the RMAP Cookie
|
||||
* @param maxReplyLen Maximum length of expected reply
|
||||
* @return
|
||||
*/
|
||||
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.
|
||||
*
|
||||
* @brief Device specific initialization, using the cookie.
|
||||
* @details
|
||||
* The cookie is already prepared in the factory. If the communication
|
||||
* interface needs to be set up in some way and requires cookie information,
|
||||
* this can be performed in this function, which is called on device handler
|
||||
* initialization.
|
||||
* @param cookie
|
||||
* @param address
|
||||
* @param maxReplyLen
|
||||
* @return
|
||||
* @return -@c RETURN_OK if initialization was successfull
|
||||
* - Everything else triggers failure event with returnvalue as parameter 1
|
||||
*/
|
||||
virtual ReturnValue_t reOpen(CookieIF *cookie, uint32_t address,
|
||||
uint32_t maxReplyLen) = 0;
|
||||
|
||||
virtual ReturnValue_t initializeInterface(CookieIF * cookie) = 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 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?
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @param cookie Expects an RMAPCookie or derived from RMAPCookie Class
|
||||
* @param data Data to be send
|
||||
* @param len Length of the data to be send
|
||||
* @return - Return codes of RMAP::sendWriteCommand()
|
||||
* Called by DHB in the GET_WRITE doGetWrite().
|
||||
* Get send confirmation that the data in sendMessage() was sent successfully.
|
||||
* @param cookie
|
||||
* @return -@c RETURN_OK if data was sent successfull
|
||||
* - Everything else triggers falure event with returnvalue as parameter 1
|
||||
*/
|
||||
virtual ReturnValue_t sendMessage(CookieIF *cookie, uint8_t *data,
|
||||
uint32_t len);
|
||||
|
||||
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,
|
||||
uint32_t *size);
|
||||
size_t *size);
|
||||
|
||||
virtual ReturnValue_t setAddress(CookieIF *cookie, uint32_t address);
|
||||
|
||||
virtual uint32_t getAddress(CookieIF *cookie);
|
||||
|
||||
virtual ReturnValue_t setParameter(CookieIF *cookie, uint32_t parameter);
|
||||
|
||||
virtual uint32_t getParameter(CookieIF *cookie);
|
||||
ReturnValue_t setAddress(CookieIF* cookie,
|
||||
uint32_t address);
|
||||
uint32_t getAddress(CookieIF* cookie);
|
||||
ReturnValue_t setParameter(CookieIF* cookie,
|
||||
uint32_t parameter);
|
||||
uint32_t getParameter(CookieIF* cookie);
|
||||
};
|
||||
|
||||
#endif /* MISSION_RMAP_RMAPDEVICECOMMUNICATIONINTERFACE_H_ */
|
||||
#endif /* FSFW_RMAP_RMAPDEVICECOMMUNICATIONINTERFACE_H_ */
|
||||
|
@ -1,7 +1,7 @@
|
||||
#ifndef RMAPSTRUCTS_H_
|
||||
#define RMAPSTRUCTS_H_
|
||||
#ifndef FSFW_RMAP_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
|
||||
|
||||
@ -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