fsfw/devicehandlers/DeviceCommunicationIF.h

85 lines
2.7 KiB
C
Raw Normal View History

#ifndef DEVICECOMMUNICATIONIF_H_
#define DEVICECOMMUNICATIONIF_H_
2020-04-19 13:24:10 +02:00
#include <framework/devicehandlers/Cookie.h>
#include <framework/returnvalues/HasReturnvaluesIF.h>
2020-04-19 13:24:10 +02:00
class DeviceCommunicationIF: public HasReturnvaluesIF {
public:
static const uint8_t INTERFACE_ID = CLASS_ID::DEVICE_COMMUNICATION_IF;
2020-04-19 13:24:10 +02:00
static const ReturnValue_t INVALID_COOKIE_TYPE = MAKE_RETURN_CODE(0x01);
static const ReturnValue_t NOT_ACTIVE = MAKE_RETURN_CODE(0x02);
static const ReturnValue_t INVALID_ADDRESS = MAKE_RETURN_CODE(0x03);
static const ReturnValue_t TOO_MUCH_DATA = MAKE_RETURN_CODE(0x04);
static const ReturnValue_t NULLPOINTER = MAKE_RETURN_CODE(0x05);
static const ReturnValue_t PROTOCOL_ERROR = MAKE_RETURN_CODE(0x06);
static const ReturnValue_t CANT_CHANGE_REPLY_LEN = MAKE_RETURN_CODE(0x07);
2020-04-19 13:24:10 +02:00
virtual ~DeviceCommunicationIF() {
2020-04-19 13:24:10 +02:00
}
2020-04-19 13:24:10 +02:00
virtual ReturnValue_t open(Cookie **cookie, uint32_t address,
uint32_t maxReplyLen) = 0;
2020-03-24 15:59:08 +01:00
/**
2020-04-19 13:24:10 +02:00
* 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.
*
2020-03-24 15:59:08 +01:00
* @param cookie
2020-04-19 13:24:10 +02:00
* @param address
* @param maxReplyLen
* @return
2020-03-24 15:59:08 +01:00
*/
2020-04-19 13:24:10 +02:00
virtual ReturnValue_t reOpen(Cookie *cookie, uint32_t address,
uint32_t maxReplyLen) = 0;
virtual void close(Cookie *cookie) = 0;
/**
* 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 sending failed event with
* returnvalue as parameter 1
*/
virtual ReturnValue_t sendMessage(Cookie *cookie,const uint8_t *data,
2020-04-19 13:24:10 +02:00
uint32_t len) = 0;
virtual ReturnValue_t getSendSuccess(Cookie *cookie) = 0;
virtual ReturnValue_t requestReceiveMessage(Cookie *cookie) = 0;
/**
* Called by DHB in the GET_WIRTE 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 receiving failed with returnvalue
* as parameter 1
*/
2020-04-19 13:24:10 +02:00
virtual ReturnValue_t readReceivedMessage(Cookie *cookie, uint8_t **buffer,
uint32_t *size) = 0;
virtual ReturnValue_t setAddress(Cookie *cookie, uint32_t address) = 0;
virtual uint32_t getAddress(Cookie *cookie) = 0;
virtual ReturnValue_t setParameter(Cookie *cookie, uint32_t parameter) = 0;
virtual uint32_t getParameter(Cookie *cookie) = 0;
};
#endif /* DEVICECOMMUNICATIONIF_H_ */