67 lines
2.2 KiB
C++
67 lines
2.2 KiB
C++
#ifndef BSP_LINUX_COMIF_COOKIES_CSPCOMIF_H_
|
|
#define BSP_LINUX_COMIF_COOKIES_CSPCOMIF_H_
|
|
|
|
#include <fsfw/devicehandlers/DeviceCommunicationIF.h>
|
|
#include <fsfw/objectmanager/SystemObject.h>
|
|
#include <fsfw/returnvalues/HasReturnvaluesIF.h>
|
|
#include <csp/csp.h>
|
|
|
|
#include <vector>
|
|
#include <unordered_map>
|
|
|
|
/**
|
|
* @brief This class is serves as the communication interface to devices
|
|
* supporting the CSP protocol. For now as physical interface only
|
|
* CAN is supported by this CSP implementation.
|
|
* @author Jakob Meier
|
|
*/
|
|
class CspComIF: public DeviceCommunicationIF, public SystemObject {
|
|
public:
|
|
CspComIF(object_id_t objectId);
|
|
virtual ~CspComIF();
|
|
|
|
ReturnValue_t initializeInterface(CookieIF * cookie) override;
|
|
ReturnValue_t sendMessage(CookieIF *cookie, const uint8_t * sendData,
|
|
size_t sendLen) override;
|
|
ReturnValue_t getSendSuccess(CookieIF *cookie) override;
|
|
ReturnValue_t requestReceiveMessage(CookieIF *cookie,
|
|
size_t requestLen) override;
|
|
ReturnValue_t readReceivedMessage(CookieIF *cookie,
|
|
uint8_t **readData, size_t *readLen) override;
|
|
|
|
private:
|
|
|
|
/**
|
|
* @brief This function initiates the CSP transfer.
|
|
*
|
|
* @param cspAddress The CSP address of the target device.
|
|
* @param cspPort The port of the target device.
|
|
* @param timeout The timeout to wait for csp_send and csp_read
|
|
* functions. Specifies how long the functions wait
|
|
* for a successful operation.
|
|
* @param cmdBuffer The data to send.
|
|
* @param cmpBuffer The number of bytes to send.
|
|
* @param querySize The size of the requested message.
|
|
*/
|
|
ReturnValue_t cspTransfer(uint8_t cspAddress, uint8_t cspPort,
|
|
const uint8_t* cmdBuffer, int cmdBufferLen, uint16_t querySize);
|
|
|
|
typedef uint8_t node_t;
|
|
using vectorBuffer = std::vector<uint8_t>;
|
|
using VectorBufferMap = std::unordered_map<node_t, vectorBuffer>;
|
|
using vectorBufferIter = VectorBufferMap::iterator;
|
|
|
|
/* In this map assigns reply buffers to a CSP device */
|
|
VectorBufferMap cspDeviceMap;
|
|
|
|
uint16_t rememberQuerySize = 0;
|
|
|
|
/* This is the CSP address of the OBC. */
|
|
node_t cspClientAddress = 1;
|
|
|
|
/* Interface struct for csp protocol stack */
|
|
csp_iface_t csp_if;
|
|
};
|
|
|
|
#endif /* BSP_LINUX_COMIF_COOKIES_CSPCOMIF_H_ */
|