continued pl pcdu handler
All checks were successful
EIVE/eive-obsw/pipeline/pr-develop This commit looks good

This commit is contained in:
Robin Müller 2022-02-21 16:57:16 +01:00
parent 8953f6f60d
commit c683097635
10 changed files with 127 additions and 105 deletions

View File

@ -44,11 +44,9 @@
#include "linux/csp/CspComIF.h" #include "linux/csp/CspComIF.h"
#include "linux/csp/CspCookie.h" #include "linux/csp/CspCookie.h"
#include "linux/devices/GPSHyperionLinuxController.h" #include "linux/devices/GPSHyperionLinuxController.h"
#include "linux/devices/PayloadPcduHandler.h"
#include "linux/devices/SolarArrayDeploymentHandler.h" #include "linux/devices/SolarArrayDeploymentHandler.h"
#include "linux/devices/SusHandler.h" #include "linux/devices/SusHandler.h"
#include "linux/devices/devicedefinitions/SusDefinitions.h" #include "linux/devices/devicedefinitions/SusDefinitions.h"
#include "linux/devices/devicedefinitions/payloadPcduDefinitions.h"
#include "mission/core/GenericFactory.h" #include "mission/core/GenericFactory.h"
#include "mission/devices/ACUHandler.h" #include "mission/devices/ACUHandler.h"
#include "mission/devices/BpxBatteryHandler.h" #include "mission/devices/BpxBatteryHandler.h"
@ -60,6 +58,7 @@
#include "mission/devices/PCDUHandler.h" #include "mission/devices/PCDUHandler.h"
#include "mission/devices/PDU1Handler.h" #include "mission/devices/PDU1Handler.h"
#include "mission/devices/PDU2Handler.h" #include "mission/devices/PDU2Handler.h"
#include "mission/devices/PayloadPcduHandler.h"
#include "mission/devices/PlocMPSoCHandler.h" #include "mission/devices/PlocMPSoCHandler.h"
#include "mission/devices/RadiationSensorHandler.h" #include "mission/devices/RadiationSensorHandler.h"
#include "mission/devices/RwHandler.h" #include "mission/devices/RwHandler.h"
@ -71,6 +70,7 @@
#include "mission/devices/devicedefinitions/RadSensorDefinitions.h" #include "mission/devices/devicedefinitions/RadSensorDefinitions.h"
#include "mission/devices/devicedefinitions/RwDefinitions.h" #include "mission/devices/devicedefinitions/RwDefinitions.h"
#include "mission/devices/devicedefinitions/SyrlinksDefinitions.h" #include "mission/devices/devicedefinitions/SyrlinksDefinitions.h"
#include "mission/devices/devicedefinitions/payloadPcduDefinitions.h"
#include "mission/tmtc/CCSDSHandler.h" #include "mission/tmtc/CCSDSHandler.h"
#include "mission/tmtc/VirtualChannel.h" #include "mission/tmtc/VirtualChannel.h"
#include "mission/utility/TmFunnel.h" #include "mission/utility/TmFunnel.h"

View File

@ -296,35 +296,29 @@ void SpiTestClass::performOneShotMax1227Test() {
adcCfg.testRadSensorExtConvWithDelay = false; adcCfg.testRadSensorExtConvWithDelay = false;
adcCfg.testRadSensorIntConv = false; adcCfg.testRadSensorIntConv = false;
adcCfg.testSus[0].doTest = true; bool setAllSusOn = false;
adcCfg.testSus[0].intConv = true; bool susIntConv = false;
adcCfg.testSus[6].doTest = true; bool susExtConv = false;
adcCfg.testSus[6].intConv = true; if (setAllSusOn) {
for (uint8_t idx = 0; idx < 12; idx++) {
adcCfg.testSus[idx].doTest = true;
}
} else {
for (uint8_t idx = 0; idx < 12; idx++) {
adcCfg.testSus[idx].doTest = false;
}
}
adcCfg.testSus[1].doTest = true; if (susIntConv) {
adcCfg.testSus[1].intConv = true; for (uint8_t idx = 0; idx < 12; idx++) {
adcCfg.testSus[7].doTest = true; adcCfg.testSus[idx].intConv = true;
adcCfg.testSus[7].intConv = true; }
}
adcCfg.testSus[10].doTest = true; if (susExtConv) {
adcCfg.testSus[10].intConv = true; for (uint8_t idx = 0; idx < 12; idx++) {
adcCfg.testSus[4].doTest = true; adcCfg.testSus[idx].extConv = true;
adcCfg.testSus[4].intConv = true; }
}
adcCfg.testSus[11].doTest = true;
adcCfg.testSus[11].intConv = true;
adcCfg.testSus[5].doTest = true;
adcCfg.testSus[5].intConv = true;
adcCfg.testSus[2].doTest = true;
adcCfg.testSus[2].intConv = true;
adcCfg.testSus[3].doTest = true;
adcCfg.testSus[3].intConv = true;
adcCfg.testSus[8].doTest = true;
adcCfg.testSus[8].intConv = true;
adcCfg.testSus[9].doTest = true;
adcCfg.testSus[9].intConv = true;
adcCfg.plPcduAdcExtConv = false; adcCfg.plPcduAdcExtConv = false;
adcCfg.plPcduAdcIntConv = true; adcCfg.plPcduAdcIntConv = true;
@ -334,7 +328,7 @@ void SpiTestClass::performOneShotMax1227Test() {
void SpiTestClass::performPeriodicMax1227Test() { void SpiTestClass::performPeriodicMax1227Test() {
using namespace max1227; using namespace max1227;
adcCfg.testRadSensorExtConvWithDelay = false; adcCfg.testRadSensorExtConvWithDelay = false;
adcCfg.testRadSensorIntConv = false; adcCfg.testRadSensorIntConv = true;
adcCfg.plPcduAdcExtConv = false; adcCfg.plPcduAdcExtConv = false;
adcCfg.plPcduAdcIntConv = false; adcCfg.plPcduAdcIntConv = false;

View File

@ -1,10 +1,10 @@
#ifndef MISSION_DEVICES_GPSHYPERIONHANDLER_H_ #ifndef MISSION_DEVICES_GPSHYPERIONHANDLER_H_
#define MISSION_DEVICES_GPSHYPERIONHANDLER_H_ #define MISSION_DEVICES_GPSHYPERIONHANDLER_H_
#include "mission/devices/devicedefinitions/GPSDefinitions.h"
#include "fsfw/FSFW.h" #include "fsfw/FSFW.h"
#include "fsfw/controller/ExtendedControllerBase.h" #include "fsfw/controller/ExtendedControllerBase.h"
#include "fsfw/devicehandlers/DeviceHandlerBase.h" #include "fsfw/devicehandlers/DeviceHandlerBase.h"
#include "mission/devices/devicedefinitions/GPSDefinitions.h"
#ifdef FSFW_OSAL_LINUX #ifdef FSFW_OSAL_LINUX
#include <gps.h> #include <gps.h>

View File

@ -226,7 +226,7 @@ ReturnValue_t SusHandler::initializeLocalDataPool(localpool::DataPool &localData
void SusHandler::setToGoToNormalMode(bool enable) { this->goToNormalModeImmediately = enable; } void SusHandler::setToGoToNormalMode(bool enable) { this->goToNormalModeImmediately = enable; }
void SusHandler::printDataset() { void SusHandler::printDataset() {
if(periodicPrintout) { if (periodicPrintout) {
if (divider.checkAndIncrement()) { if (divider.checkAndIncrement()) {
sif::info << "SUS " << std::setw(2) << std::dec << static_cast<int>(susIdx) << " ID " sif::info << "SUS " << std::setw(2) << std::dec << static_cast<int>(susIdx) << " ID "
<< std::hex << "0x" << this->getObjectId() << " [" << std::hex << std::setw(3); << std::hex << "0x" << this->getObjectId() << " [" << std::hex << std::setw(3);

View File

@ -85,6 +85,8 @@ debugging. */
#define OBSW_DEBUG_RTD 0 #define OBSW_DEBUG_RTD 0
#define OBSW_TEST_RAD_SENSOR 0 #define OBSW_TEST_RAD_SENSOR 0
#define OBSW_DEBUG_RAD_SENSOR 0 #define OBSW_DEBUG_RAD_SENSOR 0
#define OBSW_TEST_PL_PCDU 0
#define OBSW_DEBUG_PL_PCDU 0
#define OBSW_TEST_LIBGPIOD 0 #define OBSW_TEST_LIBGPIOD 0
#define OBSW_TEST_PLOC_HANDLER 0 #define OBSW_TEST_PLOC_HANDLER 0
#define OBSW_TEST_BPX_BATT 0 #define OBSW_TEST_BPX_BATT 0

View File

@ -360,8 +360,8 @@ ReturnValue_t pst::pstSpi(FixedTimeslotTaskIF *thisSequence) {
#endif #endif
#if OBSW_ADD_ACS_BOARD == 1 && OBSW_ADD_ACS_HANDLERS == 1 #if OBSW_ADD_ACS_BOARD == 1 && OBSW_ADD_ACS_HANDLERS == 1
bool enableAside = true; bool enableAside = false;
bool enableBside = false; bool enableBside = true;
if (enableAside) { if (enableAside) {
// A side // A side
thisSequence->addSlot(objects::MGM_0_LIS3_HANDLER, length * 0, thisSequence->addSlot(objects::MGM_0_LIS3_HANDLER, length * 0,

View File

@ -1,5 +1,7 @@
#include <fsfw/src/fsfw/datapool/PoolReadGuard.h>
#include "PayloadPcduHandler.h" #include "PayloadPcduHandler.h"
#include <fsfw/src/fsfw/datapool/PoolReadGuard.h>
#include "devices/gpioIds.h" #include "devices/gpioIds.h"
PayloadPcduHandler::PayloadPcduHandler(object_id_t objectId, object_id_t comIF, CookieIF* cookie, PayloadPcduHandler::PayloadPcduHandler(object_id_t objectId, object_id_t comIF, CookieIF* cookie,
@ -34,14 +36,14 @@ void PayloadPcduHandler::doStartUp() {
void PayloadPcduHandler::doTransition(Mode_t modeFrom, Submode_t subModeFrom) { void PayloadPcduHandler::doTransition(Mode_t modeFrom, Submode_t subModeFrom) {
if (mode == _MODE_TO_NORMAL) { if (mode == _MODE_TO_NORMAL) {
if(adcState == AdcStates::BOOT_DELAY) { if (adcState == AdcStates::BOOT_DELAY) {
if (adcCountdown.hasTimedOut()) { if (adcCountdown.hasTimedOut()) {
adcState = AdcStates::SEND_SETUP; adcState = AdcStates::SEND_SETUP;
adcCmdExecuted = false; adcCmdExecuted = false;
} }
} }
if(adcState == AdcStates::SEND_SETUP) { if (adcState == AdcStates::SEND_SETUP) {
if(adcCmdExecuted) { if (adcCmdExecuted) {
adcState = AdcStates::NORMAL; adcState = AdcStates::NORMAL;
adcCmdExecuted = false; adcCmdExecuted = false;
} }
@ -138,26 +140,26 @@ void PayloadPcduHandler::doTransition(Mode_t modeFrom, Submode_t subModeFrom) {
void PayloadPcduHandler::doShutDown() {} void PayloadPcduHandler::doShutDown() {}
ReturnValue_t PayloadPcduHandler::buildNormalDeviceCommand(DeviceCommandId_t* id) { ReturnValue_t PayloadPcduHandler::buildNormalDeviceCommand(DeviceCommandId_t* id) {
switch(adcState) { switch (adcState) {
case(AdcStates::SEND_SETUP): { case (AdcStates::SEND_SETUP): {
*id = plpcdu::SETUP_CMD; *id = plpcdu::SETUP_CMD;
buildCommandFromCommand(*id, nullptr, 0); buildCommandFromCommand(*id, nullptr, 0);
break; break;
} }
case(AdcStates::NORMAL): { case (AdcStates::NORMAL): {
*id = plpcdu::READ_WITH_TEMP; *id = plpcdu::READ_WITH_TEMP;
buildCommandFromCommand(*id, nullptr, 0); buildCommandFromCommand(*id, nullptr, 0);
break; break;
} }
default: { default: {
break; break;
} }
} }
return NOTHING_TO_SEND; return NOTHING_TO_SEND;
} }
ReturnValue_t PayloadPcduHandler::buildTransitionDeviceCommand(DeviceCommandId_t* id) { ReturnValue_t PayloadPcduHandler::buildTransitionDeviceCommand(DeviceCommandId_t* id) {
if(adcState == AdcStates::SEND_SETUP) { if (adcState == AdcStates::SEND_SETUP) {
*id = plpcdu::SETUP_CMD; *id = plpcdu::SETUP_CMD;
buildCommandFromCommand(*id, nullptr, 0); buildCommandFromCommand(*id, nullptr, 0);
} }
@ -174,30 +176,30 @@ void PayloadPcduHandler::fillCommandAndReplyMap() {
ReturnValue_t PayloadPcduHandler::buildCommandFromCommand(DeviceCommandId_t deviceCommand, ReturnValue_t PayloadPcduHandler::buildCommandFromCommand(DeviceCommandId_t deviceCommand,
const uint8_t* commandData, const uint8_t* commandData,
size_t commandDataLen) { size_t commandDataLen) {
switch(deviceCommand) { switch (deviceCommand) {
case(plpcdu::SETUP_CMD): { case (plpcdu::SETUP_CMD): {
cmdBuf[0] = plpcdu::SETUP_BYTE; cmdBuf[0] = plpcdu::SETUP_BYTE;
rawPacket = cmdBuf.data(); rawPacket = cmdBuf.data();
rawPacketLen = 1; rawPacketLen = 1;
break; break;
} }
case(plpcdu::READ_CMD): { case (plpcdu::READ_CMD): {
max1227::prepareExternallyClockedRead0ToN(cmdBuf.data(), plpcdu::CHANNEL_N, rawPacketLen); max1227::prepareExternallyClockedRead0ToN(cmdBuf.data(), plpcdu::CHANNEL_N, rawPacketLen);
rawPacket = cmdBuf.data(); rawPacket = cmdBuf.data();
break; break;
} }
case(plpcdu::READ_TEMP): { case (plpcdu::READ_TEMP): {
max1227::prepareExternallyClockedTemperatureRead(cmdBuf.data(), rawPacketLen); max1227::prepareExternallyClockedTemperatureRead(cmdBuf.data(), rawPacketLen);
rawPacket = cmdBuf.data(); rawPacket = cmdBuf.data();
break; break;
} }
case(plpcdu::READ_WITH_TEMP): { case (plpcdu::READ_WITH_TEMP): {
size_t sz = 0; size_t sz = 0;
max1227::prepareExternallyClockedRead0ToN(cmdBuf.data(), plpcdu::CHANNEL_N, sz); max1227::prepareExternallyClockedRead0ToN(cmdBuf.data(), plpcdu::CHANNEL_N, sz);
max1227::prepareExternallyClockedTemperatureRead(cmdBuf.data() + sz, sz); max1227::prepareExternallyClockedTemperatureRead(cmdBuf.data() + sz, sz);
rawPacketLen = sz; rawPacketLen = sz;
rawPacket = cmdBuf.data(); rawPacket = cmdBuf.data();
} }
} }
return DeviceHandlerIF::COMMAND_NOT_IMPLEMENTED; return DeviceHandlerIF::COMMAND_NOT_IMPLEMENTED;
} }
@ -213,22 +215,42 @@ ReturnValue_t PayloadPcduHandler::scanForReply(const uint8_t* start, size_t rema
ReturnValue_t PayloadPcduHandler::interpretDeviceReply(DeviceCommandId_t id, ReturnValue_t PayloadPcduHandler::interpretDeviceReply(DeviceCommandId_t id,
const uint8_t* packet) { const uint8_t* packet) {
using namespace plpcdu; using namespace plpcdu;
switch(id) { switch (id) {
case(SETUP_CMD): { case (SETUP_CMD): {
break; break;
}
case(READ_WITH_TEMP): {
PoolReadGuard pg(&adcSet);
if(pg.getReadResult() != HasReturnvaluesIF::RETURN_OK) {
return pg.getReadResult();
} }
for(uint8_t idx = 0; idx < 12; idx ++) { case (READ_TEMP): {
adcSet.channels[idx] = packet[idx * 2 + 1] << 8 | packet[idx * 2 + 2]; uint8_t tempStartIdx = TEMP_REPLY_SIZE - 2;
adcSet.tempC.value =
max1227::getTemperature(packet[tempStartIdx] << 8 | packet[tempStartIdx + 2]);
break;
}
case (READ_CMD): {
PoolReadGuard pg(&adcSet);
if (pg.getReadResult() != HasReturnvaluesIF::RETURN_OK) {
return pg.getReadResult();
}
for (uint8_t idx = 0; idx < 12; idx++) {
adcSet.channels[idx] = packet[idx * 2 + 1] << 8 | packet[idx * 2 + 2];
}
break;
}
case (READ_WITH_TEMP): {
PoolReadGuard pg(&adcSet);
if (pg.getReadResult() != HasReturnvaluesIF::RETURN_OK) {
return pg.getReadResult();
}
for (uint8_t idx = 0; idx < 12; idx++) {
adcSet.channels[idx] = packet[idx * 2 + 1] << 8 | packet[idx * 2 + 2];
}
uint8_t tempStartIdx = ADC_REPLY_SIZE + TEMP_REPLY_SIZE - 2;
adcSet.tempC.value =
max1227::getTemperature(packet[tempStartIdx] << 8 | packet[tempStartIdx + 2]);
break;
}
default: {
break;
} }
uint8_t tempStartIdx = ADC_REPLY_SIZE + TEMP_REPLY_SIZE - 2;
adcSet.tempC.value = max1227::getTemperature(packet[tempStartIdx] << 8 | packet[tempStartIdx + 2]);
}
} }
return HasReturnvaluesIF::RETURN_OK; return HasReturnvaluesIF::RETURN_OK;
} }
@ -244,3 +266,7 @@ ReturnValue_t PayloadPcduHandler::initializeLocalDataPool(localpool::DataPool& l
localDataPoolMap.emplace(plpcdu::PlPcduPoolIds::TEMP, &tempC); localDataPoolMap.emplace(plpcdu::PlPcduPoolIds::TEMP, &tempC);
return HasReturnvaluesIF::RETURN_OK; return HasReturnvaluesIF::RETURN_OK;
} }
void PayloadPcduHandler::setToGoToNormalModeImmediately(bool enable) {
this->goToNormalMode = enable;
}

View File

@ -3,6 +3,7 @@
#include <fsfw/devicehandlers/DeviceHandlerBase.h> #include <fsfw/devicehandlers/DeviceHandlerBase.h>
#include <fsfw/timemanager/Countdown.h> #include <fsfw/timemanager/Countdown.h>
#include "devicedefinitions/payloadPcduDefinitions.h" #include "devicedefinitions/payloadPcduDefinitions.h"
#include "fsfw_hal/common/gpio/GpioIF.h" #include "fsfw_hal/common/gpio/GpioIF.h"
@ -24,6 +25,8 @@ class PayloadPcduHandler : DeviceHandlerBase {
public: public:
PayloadPcduHandler(object_id_t objectId, object_id_t comIF, CookieIF* cookie, GpioIF* gpioIF); PayloadPcduHandler(object_id_t objectId, object_id_t comIF, CookieIF* cookie, GpioIF* gpioIF);
void setToGoToNormalModeImmediately(bool enable);
private: private:
enum class States { enum class States {
PCDU_OFF, PCDU_OFF,
@ -50,6 +53,7 @@ class PayloadPcduHandler : DeviceHandlerBase {
enum class AdcStates { OFF, BOOT_DELAY, SEND_SETUP, NORMAL } adcState = AdcStates::OFF; enum class AdcStates { OFF, BOOT_DELAY, SEND_SETUP, NORMAL } adcState = AdcStates::OFF;
bool goToNormalMode = false;
plpcdu::PlPcduAdcSet adcSet; plpcdu::PlPcduAdcSet adcSet;
std::array<uint8_t, plpcdu::MAX_ADC_REPLY_SIZE> cmdBuf = {}; std::array<uint8_t, plpcdu::MAX_ADC_REPLY_SIZE> cmdBuf = {};
// This variable is tied to DRO +6 V voltage. Voltages, currents are monitored and the experiment // This variable is tied to DRO +6 V voltage. Voltages, currents are monitored and the experiment

View File

@ -3,17 +3,16 @@
#include <fsfw/datapoollocal/StaticLocalDataSet.h> #include <fsfw/datapoollocal/StaticLocalDataSet.h>
#include <fsfw/devicehandlers/DeviceHandlerIF.h> #include <fsfw/devicehandlers/DeviceHandlerIF.h>
#include "mission/devices/max1227.h"
#include <cstddef> #include <cstddef>
#include "mission/devices/max1227.h"
namespace plpcdu { namespace plpcdu {
using namespace max1227; using namespace max1227;
enum PlPcduPoolIds: uint32_t { enum PlPcduPoolIds : uint32_t { CHANNEL_VEC = 0, TEMP = 1 };
CHANNEL_VEC = 0,
TEMP = 1
};
static constexpr size_t MAX_ADC_REPLY_SIZE = 64; static constexpr size_t MAX_ADC_REPLY_SIZE = 64;
@ -27,8 +26,8 @@ static constexpr size_t ADC_REPLY_SIZE = 25;
// Conversion byte + 24 * zero // Conversion byte + 24 * zero
static constexpr size_t TEMP_REPLY_SIZE = 25; static constexpr size_t TEMP_REPLY_SIZE = 25;
static constexpr uint8_t SETUP_BYTE = max1227::buildSetupByte(ClkSel::EXT_CONV_EXT_TIMED, static constexpr uint8_t SETUP_BYTE =
RefSel::INT_REF_NO_WAKEUP, DiffSel::NONE_0); max1227::buildSetupByte(ClkSel::EXT_CONV_EXT_TIMED, RefSel::INT_REF_NO_WAKEUP, DiffSel::NONE_0);
static constexpr uint32_t ADC_SET_ID = READ_CMD; static constexpr uint32_t ADC_SET_ID = READ_CMD;
static constexpr uint8_t CHANNELS_NUM = 12; static constexpr uint8_t CHANNELS_NUM = 12;
@ -40,13 +39,12 @@ class PlPcduAdcSet : public StaticLocalDataSet<DATASET_ENTRIES> {
public: public:
PlPcduAdcSet(HasLocalDataPoolIF* owner) : StaticLocalDataSet(owner, ADC_SET_ID) {} PlPcduAdcSet(HasLocalDataPoolIF* owner) : StaticLocalDataSet(owner, ADC_SET_ID) {}
PlPcduAdcSet(object_id_t objectId) PlPcduAdcSet(object_id_t objectId) : StaticLocalDataSet(sid_t(objectId, ADC_SET_ID)) {}
: StaticLocalDataSet(sid_t(objectId, ADC_SET_ID)) {}
lp_vec_t<uint16_t, 12> channels = lp_vec_t<uint16_t, 12>(sid.objectId, CHANNEL_VEC, this); lp_vec_t<uint16_t, 12> channels = lp_vec_t<uint16_t, 12>(sid.objectId, CHANNEL_VEC, this);
lp_var_t<float> tempC = lp_var_t<float>(sid.objectId, TEMP, this); lp_var_t<float> tempC = lp_var_t<float>(sid.objectId, TEMP, this);
}; };
} } // namespace plpcdu
#endif /* LINUX_DEVICES_DEVICEDEFINITIONS_PAYLOADPCDUDEFINITIONS_H_ */ #endif /* LINUX_DEVICES_DEVICEDEFINITIONS_PAYLOADPCDUDEFINITIONS_H_ */

View File

@ -40,9 +40,7 @@ enum DiffSel : uint8_t {
BIPOLAR_CFG = 0b11 BIPOLAR_CFG = 0b11
}; };
constexpr uint8_t buildResetByte(bool fifoOnly) { constexpr uint8_t buildResetByte(bool fifoOnly) { return (1 << 4) | (fifoOnly << 3); }
return (1 << 4) | (fifoOnly << 3);
}
constexpr uint8_t buildConvByte(ScanModes scanMode, uint8_t channel, bool readTemp) { constexpr uint8_t buildConvByte(ScanModes scanMode, uint8_t channel, bool readTemp) {
return (1 << 7) | (channel << 3) | (scanMode << 1) | readTemp; return (1 << 7) | (channel << 3) | (scanMode << 1) | readTemp;