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

This commit is contained in:
Robin Müller 2022-08-26 03:20:44 +02:00
parent d098ed6403
commit efb0bce718
No known key found for this signature in database
GPG Key ID: 71B58F8A3CDFA9AC
13 changed files with 165 additions and 113 deletions

View File

@ -466,6 +466,7 @@ endif()
if(ADD_GOMSPACE_CLIENTS)
target_link_libraries(${OBSW_NAME} PRIVATE ${LIB_GOMSPACE_CLIENTS})
target_link_libraries(${LIB_EIVE_MISSION} PRIVATE ${LIB_GOMSPACE_CLIENTS})
endif()
if(EIVE_ADD_ETL_LIB)

View File

@ -3,6 +3,7 @@
#include <bsp_q7s/core/CoreController.h>
#include <bsp_q7s/memory/FileSystemHandler.h>
#include <bsp_q7s/xadc/Xadc.h>
#include <fsfw/globalfunctions/arrayprinter.h>
#include <fsfw/objectmanager/ObjectManager.h>
#include <gps.h>
#include <libgpsmm.h>

View File

@ -158,10 +158,10 @@ void ObjectFactory::createCommunicationInterfaces(LinuxLibgpioIF** gpioComIF, Ua
}
void ObjectFactory::createPcduComponents(LinuxLibgpioIF* gpioComIF, PowerSwitchIF** pwrSwitcher) {
CspCookie* p60DockCspCookie = new CspCookie(P60Dock::MAX_REPLY_LENGTH, addresses::P60DOCK);
CspCookie* pdu1CspCookie = new CspCookie(PDU::MAX_REPLY_LENGTH, addresses::PDU1);
CspCookie* pdu2CspCookie = new CspCookie(PDU::MAX_REPLY_LENGTH, addresses::PDU2);
CspCookie* acuCspCookie = new CspCookie(ACU::MAX_REPLY_LENGTH, addresses::ACU);
CspCookie* p60DockCspCookie = new CspCookie(P60Dock::MAX_REPLY_LENGTH, addresses::P60DOCK, 500);
CspCookie* pdu1CspCookie = new CspCookie(PDU::MAX_REPLY_LENGTH, addresses::PDU1, 500);
CspCookie* pdu2CspCookie = new CspCookie(PDU::MAX_REPLY_LENGTH, addresses::PDU2, 500);
CspCookie* acuCspCookie = new CspCookie(ACU::MAX_REPLY_LENGTH, addresses::ACU, 500);
auto p60Fdir = new GomspacePowerFdir(objects::P60DOCK_HANDLER);
P60DockHandler* p60dockhandler =

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_ */

View File

@ -2,9 +2,13 @@
#include <common/config/commonObjects.h>
#include <fsfw/datapool/PoolReadGuard.h>
#include <fsfw/globalfunctions/arrayprinter.h>
#include <linux/csp/CspComIF.h>
#include <linux/csp/CspCookie.h>
#include "devicedefinitions/GomSpacePackets.h"
#include "devicedefinitions/powerDefinitions.h"
#include <cassert>
using namespace GOMSPACE;
@ -426,22 +430,29 @@ ReturnValue_t GomspaceDeviceHandler::generateResetWatchdogCmd() {
}
ReturnValue_t GomspaceDeviceHandler::generateRequestFullTableCmd(uint8_t tableId,
uint16_t hkTableReplySize) {
uint16_t querySize = hkTableReplySize;
RequestFullTableCommand requestFullTableCommand(querySize, tableId);
uint16_t tableReplySize) {
uint16_t querySize = tableReplySize;
if(getObjectId() == objects::PDU1_HANDLER or getObjectId() == objects::PDU2_HANDLER) {
auto* cspCookie = dynamic_cast<CspCookie*>(comCookie);
cspCookie->setRequest(CspCookie::SpecialRequestTypes::GET_PDU_HK, tableReplySize);
cspCookie->setCspPort(GOMSPACE::CspPorts::P60_PORT_RPARAM_ENUM);
} else {
RequestFullTableCommand requestFullTableCommand(querySize, tableId);
size_t cspPacketLen = 0;
uint8_t* buffer = cspPacket;
ReturnValue_t result = requestFullTableCommand.serialize(
&buffer, &cspPacketLen, sizeof(cspPacket), SerializeIF::Endianness::BIG);
if (result != HasReturnvaluesIF::RETURN_OK) {
sif::error << "GomspaceDeviceHandler::generateRequestFullTableCmd Failed to serialize "
"full table request command "
<< std::endl;
return result;
size_t cspPacketLen = 0;
uint8_t* buffer = cspPacket;
ReturnValue_t result = requestFullTableCommand.serialize(
&buffer, &cspPacketLen, sizeof(cspPacket), SerializeIF::Endianness::BIG);
if (result != HasReturnvaluesIF::RETURN_OK) {
sif::error << "GomspaceDeviceHandler::generateRequestFullTableCmd Failed to serialize "
"full table request command "
<< std::endl;
return result;
}
rawPacket = cspPacket;
rawPacketLen = cspPacketLen;
}
rawPacket = cspPacket;
rawPacketLen = cspPacketLen;
rememberRequestedSize = querySize;
rememberCommandId = GOMSPACE::REQUEST_HK_TABLE;
return RETURN_OK;
@ -458,7 +469,6 @@ ReturnValue_t GomspaceDeviceHandler::printStatus(DeviceCommandId_t cmd) {
ReturnValue_t GomspaceDeviceHandler::parsePduHkTable(PDU::PduCoreHk& coreHk, PDU::PduAuxHk& auxHk,
const uint8_t* packet) {
uint16_t dataOffset = 0;
PoolReadGuard pg0(&coreHk);
PoolReadGuard pg1(&auxHk);
if (pg0.getReadResult() != HasReturnvaluesIF::RETURN_OK or
@ -468,92 +478,51 @@ ReturnValue_t GomspaceDeviceHandler::parsePduHkTable(PDU::PduCoreHk& coreHk, PDU
}
/* Fist 10 bytes contain the gomspace header. Each variable is preceded by the 16-bit table
* address. */
dataOffset += 12;
//dataOffset += 12;
for (uint8_t idx = 0; idx < PDU::CHANNELS_LEN; idx++) {
coreHk.currents[idx] = (packet[dataOffset] << 8) | packet[dataOffset + 1];
dataOffset += 4;
coreHk.currents[idx] = as<int16_t>(packet + (idx * 2));
}
for (uint8_t idx = 0; idx < PDU::CHANNELS_LEN; idx++) {
coreHk.voltages[idx] = (packet[dataOffset] << 8) | packet[dataOffset + 1];
dataOffset += 4;
coreHk.voltages[idx] = as<uint16_t>(packet + 0x12 + (idx*2));
}
auxHk.vcc = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
auxHk.vbat = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
coreHk.temperature =
static_cast<int16_t>(*(packet + dataOffset) << 8 | *(packet + dataOffset + 1)) * 0.1;
dataOffset += 4;
auxHk.vcc.value = as<int16_t>(packet + 0x24);
auxHk.vbat.value = as<int16_t>(packet + 0x26);
coreHk.temperature = as<int16_t>(packet + 0x28) * 0.1;
for (uint8_t idx = 0; idx < 3; idx++) {
auxHk.converterEnable[idx] = packet[dataOffset];
dataOffset += 3;
auxHk.converterEnable[idx] = packet[0x2a + idx];
}
for (uint8_t idx = 0; idx < PDU::CHANNELS_LEN; idx++) {
coreHk.outputEnables[idx] = packet[dataOffset];
dataOffset += 3;
coreHk.outputEnables[idx] = packet[0x2e + idx];
}
auxHk.bootcause = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 |
*(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3);
dataOffset += 6;
coreHk.bootcount = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 |
*(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3);
dataOffset += 6;
auxHk.uptime = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 |
*(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3);
dataOffset += 6;
auxHk.resetcause = *(packet + dataOffset + 1) << 8 | *(packet + dataOffset);
dataOffset += 4;
coreHk.battMode = *(packet + dataOffset);
/* +10 because here begins the second gomspace csp packet */
dataOffset += 3 + 10;
auxHk.bootcause = as<uint32_t>(packet + 0x38);
coreHk.bootcount = as<uint32_t>(packet + 0x3c);
auxHk.uptime = as<uint32_t>(packet + 0x40);
auxHk.resetcause = as<uint16_t>(packet + 0x44);
coreHk.battMode = *(packet + 0x46);
for (uint8_t idx = 0; idx < PDU::CHANNELS_LEN; idx++) {
auxHk.latchups[idx] = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
auxHk.latchups[idx] = as<uint16_t>(packet + 0x48 + (idx*2));
}
for (uint8_t idx = 0; idx < PDU::DEVICES_NUM; idx++) {
auxHk.deviceTypes[idx] = *(packet + dataOffset);
dataOffset += 3;
auxHk.deviceTypes[idx] = *(packet + 0x5a + idx);
}
for (uint8_t idx = 0; idx < PDU::DEVICES_NUM; idx++) {
auxHk.devicesStatus[idx] = *(packet + dataOffset);
dataOffset += 3;
auxHk.devicesStatus[idx] = *(packet + 0x62 + idx);
}
auxHk.gndWdtReboots = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 |
*(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3);
dataOffset += 6;
auxHk.i2cWdtReboots = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 |
*(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3);
dataOffset += 6;
auxHk.canWdtReboots = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 |
*(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3);
dataOffset += 6;
auxHk.csp1WdtReboots = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 |
*(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3);
dataOffset += 6;
auxHk.csp2WdtReboots = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 |
*(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3);
dataOffset += 6;
auxHk.groundWatchdogSecondsLeft = *(packet + dataOffset) << 24 |
*(packet + dataOffset + 1) << 16 |
*(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3);
dataOffset += 6;
auxHk.i2cWatchdogSecondsLeft = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 |
*(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3);
dataOffset += 6;
auxHk.canWatchdogSecondsLeft = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 |
*(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3);
dataOffset += 6;
auxHk.csp1WatchdogPingsLeft = *(packet + dataOffset);
dataOffset += 3;
auxHk.csp2WatchdogPingsLeft = *(packet + dataOffset);
auxHk.gndWdtReboots = as<uint32_t>(packet + 0x6c);
auxHk.i2cWdtReboots = as<uint32_t>(packet + 0x70);
auxHk.canWdtReboots = as<uint32_t>(packet + 0x74);
auxHk.csp1WdtReboots = as<uint32_t>(packet + 0x78);
auxHk.csp2WdtReboots = as<uint32_t>(packet + 0x78 + 4);
auxHk.groundWatchdogSecondsLeft = as<uint32_t>(packet + 0x80);
auxHk.i2cWatchdogSecondsLeft = as<uint32_t>(packet + 0x84);
auxHk.canWatchdogSecondsLeft = as<uint32_t>(packet + 0x88);
auxHk.csp1WatchdogPingsLeft = *(packet + 0x8c);
auxHk.csp2WatchdogPingsLeft = *(packet + 0x8c + 1);
coreHk.setChanged(true);
if (not coreHk.isValid()) {
coreHk.setValidity(true, true);

View File

@ -82,7 +82,7 @@ class GomspaceDeviceHandler : public DeviceHandlerBase {
* @brief The command to generate a request to receive the full housekeeping table is device
* specific. Thus the child has to build this command.
*/
virtual ReturnValue_t generateRequestFullTableCmd(uint8_t tableId, uint16_t hkTableSize);
virtual ReturnValue_t generateRequestFullTableCmd(uint8_t tableId, uint16_t tableSize);
/**
* This command handles printing the HK table to the console. This is useful for debugging
@ -115,6 +115,7 @@ class GomspaceDeviceHandler : public DeviceHandlerBase {
LocalDataPoolManager &poolManager,
std::array<uint8_t, PDU::CHANNELS_LEN> initOutEnb);
template<typename T> T as(const uint8_t*);
static bool validTableId(uint8_t id);
private:
@ -160,4 +161,9 @@ class GomspaceDeviceHandler : public DeviceHandlerBase {
ReturnValue_t generateResetWatchdogCmd();
};
template<typename T>
inline T GomspaceDeviceHandler::as(const uint8_t* ptr) {
return *(reinterpret_cast<const T*>(ptr));
}
#endif /* MISSION_DEVICES_GOMSPACEDEVICEHANDLER_H_ */

View File

@ -2,13 +2,14 @@
#include <fsfw/datapool/PoolReadGuard.h>
#include <mission/devices/devicedefinitions/GomSpacePackets.h>
#include <p60pdu_hk.h>
#include "devices/powerSwitcherList.h"
PDU1Handler::PDU1Handler(object_id_t objectId, object_id_t comIF, CookieIF *comCookie,
FailureIsolationBase *customFdir)
: GomspaceDeviceHandler(objectId, comIF, comCookie, customFdir, PDU::MAX_CONFIGTABLE_ADDRESS,
PDU::MAX_HKTABLE_ADDRESS, PDU::HK_TABLE_REPLY_SIZE),
PDU::MAX_HKTABLE_ADDRESS, P60PDU_HK_SIZE),
coreHk(this),
auxHk(this) {}

View File

@ -2,13 +2,14 @@
#include <fsfw/datapool/PoolReadGuard.h>
#include <mission/devices/devicedefinitions/GomSpacePackets.h>
#include <p60pdu_hk.h>
#include "devices/powerSwitcherList.h"
PDU2Handler::PDU2Handler(object_id_t objectId, object_id_t comIF, CookieIF *comCookie,
FailureIsolationBase *customFdir)
: GomspaceDeviceHandler(objectId, comIF, comCookie, customFdir, PDU::MAX_CONFIGTABLE_ADDRESS,
PDU::MAX_HKTABLE_ADDRESS, PDU::HK_TABLE_REPLY_SIZE),
PDU::MAX_HKTABLE_ADDRESS, P60PDU_HK_SIZE),
coreHk(this),
auxHk(this) {}

View File

@ -12,6 +12,13 @@
namespace GOMSPACE {
enum CspPorts: uint8_t {
CSP_PING = 1,
CSP_REBOOT = 4,
P60_PORT_RPARAM_ENUM = 7,
P60_PORT_GNDWDT_RESET_ENUM = 9
};
enum class Pdu { PDU1, PDU2 };
using ChannelSwitchHook = void (*)(Pdu pdu, uint8_t channel, bool on, void* args);
@ -466,6 +473,12 @@ class PduAuxHk : public StaticLocalDataSet<36> {
lp_var_t<uint8_t>(sid.objectId, P60System::pool::PDU_WDT_CSP_LEFT2, this);
};
//class HkWrapper {
//public:
// HkWrapper(PduCoreHk& coreHk, PduAuxHk& auxHk) {
//
// }
//};
} // namespace PDU
namespace PDU1 {

@ -1 +1 @@
Subproject commit 6b9db5e60cadcb9bbe1712f0f1b50aede2cbf7be
Subproject commit 0b66e23a8900e315f01cfc52088adad10bdabf26