finally it works
Some checks failed
EIVE/eive-obsw/pipeline/head There was a failure building this commit

This commit is contained in:
2022-08-26 03:20:44 +02:00
parent d098ed6403
commit efb0bce718
13 changed files with 165 additions and 113 deletions

View File

@ -3,6 +3,8 @@
#include <csp/drivers/can_socketcan.h>
#include <fsfw/serialize/SerializeAdapter.h>
#include <fsfw/serviceinterface/ServiceInterfaceStream.h>
#include <mission/devices/devicedefinitions/GomspaceDefinitions.h>
#include <p60pdu.h>
#include "CspCookie.h"
@ -65,44 +67,56 @@ ReturnValue_t CspComIF::initializeInterface(CookieIF* cookie) {
/* Insert device information in CSP map */
cspDeviceMap.emplace(cspAddress, vectorBuffer(maxReplyLength));
}
return HasReturnvaluesIF::RETURN_OK;
}
ReturnValue_t CspComIF::sendMessage(CookieIF* cookie, const uint8_t* sendData, size_t sendLen) {
int result;
if (cookie == NULL) {
if (cookie == nullptr) {
return HasReturnvaluesIF::RETURN_FAILED;
}
CspCookie* cspCookie = dynamic_cast<CspCookie*>(cookie);
if (cspCookie == NULL) {
if (cspCookie == nullptr) {
return HasReturnvaluesIF::RETURN_FAILED;
}
/* Extract csp port and bytes to query from command buffer */
uint8_t cspPort;
uint16_t querySize = 0;
result = getPortAndQuerySize(&sendData, &sendLen, &cspPort, &querySize);
if (result != HasReturnvaluesIF::RETURN_OK) {
return result;
if(cspCookie->getRequest() == CspCookie::SpecialRequestTypes::DEFAULT_COM_IF) {
/* Extract csp port and bytes to query from command buffer */
result = getPortAndQuerySize(&sendData, &sendLen, &cspPort, &querySize);
if (result != HasReturnvaluesIF::RETURN_OK) {
return result;
}
} else {
cspPort = cspCookie->getCspPort();
querySize = cspCookie->getReplyLen();
}
uint8_t cspAddress = cspCookie->getCspAddress();
switch (cspPort) {
case (Ports::CSP_PING): {
case (GOMSPACE::CspPorts::CSP_PING): {
initiatePingRequest(cspAddress, querySize);
break;
}
case (Ports::CSP_REBOOT): {
case (GOMSPACE::CspPorts::CSP_REBOOT): {
csp_reboot(cspAddress);
break;
}
case (Ports::P60_PORT_GNDWDT_RESET):
case (Ports::P60_PORT_RPARAM): {
/* No CSP fixed port was selected. Send data to the specified port and
* wait for querySize number of bytes */
result = cspTransfer(cspAddress, cspPort, sendData, sendLen, querySize);
if (result != HasReturnvaluesIF::RETURN_OK) {
return HasReturnvaluesIF::RETURN_FAILED;
case (GOMSPACE::CspPorts::P60_PORT_GNDWDT_RESET_ENUM):
case (GOMSPACE::CspPorts::P60_PORT_RPARAM_ENUM): {
if(cspCookie->getRequest() == CspCookie::SpecialRequestTypes::GET_PDU_HK) {
param_index_t requestStruct{};
requestStruct.physaddr = cspDeviceMap[cspAddress].data();
if(!p60pdu_get_hk(&requestStruct, cspAddress, cspCookie->getTimeout())) {
return HasReturnvaluesIF::RETURN_FAILED;
}
} else {
/* No CSP fixed port was selected. Send data to the specified port and
* wait for querySize number of bytes */
result = cspTransfer(cspAddress, cspPort, sendData, sendLen, querySize);
if (result != HasReturnvaluesIF::RETURN_OK) {
return HasReturnvaluesIF::RETURN_FAILED;
}
}
replySize = querySize;
break;

View File

@ -42,8 +42,6 @@ class CspComIF : public DeviceCommunicationIF, public SystemObject {
ReturnValue_t cspTransfer(uint8_t cspAddress, uint8_t cspPort, const uint8_t *cmdBuffer,
int cmdLen, uint16_t querySize);
enum Ports { CSP_PING = 1, CSP_REBOOT = 4, P60_PORT_RPARAM = 7, P60_PORT_GNDWDT_RESET = 9 };
typedef uint8_t node_t;
using vectorBuffer = std::vector<uint8_t>;
using VectorBufferMap = std::unordered_map<node_t, vectorBuffer>;
@ -59,7 +57,6 @@ class CspComIF : public DeviceCommunicationIF, public SystemObject {
/* Interface struct for csp protocol stack */
csp_iface_t csp_if;
char canInterface[5] = "can0";
int bitrate = 1000;

View File

@ -1,10 +1,38 @@
#include "CspCookie.h"
CspCookie::CspCookie(uint16_t maxReplyLength_, uint8_t cspAddress_)
: maxReplyLength(maxReplyLength_), cspAddress(cspAddress_) {}
CspCookie::CspCookie(uint16_t maxReplyLength_, uint8_t cspAddress_, uint32_t timeoutMs)
: maxReplyLength(maxReplyLength_), cspAddress(cspAddress_), timeoutMs(timeoutMs),
reqType(DEFAULT_COM_IF) {}
CspCookie::~CspCookie() {}
uint16_t CspCookie::getMaxReplyLength() { return maxReplyLength; }
uint8_t CspCookie::getCspAddress() { return cspAddress; }
uint8_t CspCookie::getCspAddress() {
return cspAddress;
}
CspCookie::SpecialRequestTypes CspCookie::getRequest() const {
return reqType;
}
void CspCookie::setRequest(SpecialRequestTypes request, size_t replyLen_) {
reqType = request;
replyLen = replyLen_;
}
uint8_t CspCookie::getCspPort() const {
return cspPort;
}
uint32_t CspCookie::getTimeout() const {
return timeoutMs;
}
void CspCookie::setCspPort(uint8_t port) {
cspPort = port;
}
size_t CspCookie::getReplyLen() const {
return replyLen;
}

View File

@ -4,6 +4,7 @@
#include <fsfw/devicehandlers/CookieIF.h>
#include <cstdint>
#include <cstddef>
/**
* @brief This is the cookie for devices supporting the CSP (CubeSat Space
@ -12,15 +13,35 @@
*/
class CspCookie : public CookieIF {
public:
CspCookie(uint16_t maxReplyLength_, uint8_t cspAddress_);
enum SpecialRequestTypes {
DEFAULT_COM_IF,
GET_PDU_HK,
GET_PDU_CONFIG,
GET_ACU_HK,
GET_ACU_CONFIG,
GET_P60DOCK_HK,
GET_P60DOCK_CONFIG
};
CspCookie(uint16_t maxReplyLength_, uint8_t cspAddress_, uint32_t timeoutMs);
virtual ~CspCookie();
void setCspPort(uint8_t port);
uint8_t getCspPort() const;
uint16_t getMaxReplyLength();
SpecialRequestTypes getRequest() const;
void setRequest(SpecialRequestTypes request, size_t replyLen);
size_t getReplyLen() const;
uint8_t getCspAddress();
uint32_t getTimeout() const;
private:
uint8_t cspPort;
uint16_t maxReplyLength;
uint8_t cspAddress;
size_t replyLen = 0;
uint32_t timeoutMs;
SpecialRequestTypes reqType;
};
#endif /* LINUX_CSP_CSPCOOKIE_H_ */