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

View File

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

View File

@ -1,10 +1,10 @@
#ifndef MISSION_DEVICES_GPSHYPERIONHANDLER_H_
#define MISSION_DEVICES_GPSHYPERIONHANDLER_H_
#include "mission/devices/devicedefinitions/GPSDefinitions.h"
#include "fsfw/FSFW.h"
#include "fsfw/controller/ExtendedControllerBase.h"
#include "fsfw/devicehandlers/DeviceHandlerBase.h"
#include "mission/devices/devicedefinitions/GPSDefinitions.h"
#ifdef FSFW_OSAL_LINUX
#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::printDataset() {
if(periodicPrintout) {
if (periodicPrintout) {
if (divider.checkAndIncrement()) {
sif::info << "SUS " << std::setw(2) << std::dec << static_cast<int>(susIdx) << " ID "
<< std::hex << "0x" << this->getObjectId() << " [" << std::hex << std::setw(3);

View File

@ -85,6 +85,8 @@ debugging. */
#define OBSW_DEBUG_RTD 0
#define OBSW_TEST_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_PLOC_HANDLER 0
#define OBSW_TEST_BPX_BATT 0

View File

@ -360,8 +360,8 @@ ReturnValue_t pst::pstSpi(FixedTimeslotTaskIF *thisSequence) {
#endif
#if OBSW_ADD_ACS_BOARD == 1 && OBSW_ADD_ACS_HANDLERS == 1
bool enableAside = true;
bool enableBside = false;
bool enableAside = false;
bool enableBside = true;
if (enableAside) {
// A side
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 <fsfw/src/fsfw/datapool/PoolReadGuard.h>
#include "devices/gpioIds.h"
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) {
if (mode == _MODE_TO_NORMAL) {
if(adcState == AdcStates::BOOT_DELAY) {
if (adcState == AdcStates::BOOT_DELAY) {
if (adcCountdown.hasTimedOut()) {
adcState = AdcStates::SEND_SETUP;
adcCmdExecuted = false;
}
}
if(adcState == AdcStates::SEND_SETUP) {
if(adcCmdExecuted) {
if (adcState == AdcStates::SEND_SETUP) {
if (adcCmdExecuted) {
adcState = AdcStates::NORMAL;
adcCmdExecuted = false;
}
@ -138,26 +140,26 @@ void PayloadPcduHandler::doTransition(Mode_t modeFrom, Submode_t subModeFrom) {
void PayloadPcduHandler::doShutDown() {}
ReturnValue_t PayloadPcduHandler::buildNormalDeviceCommand(DeviceCommandId_t* id) {
switch(adcState) {
case(AdcStates::SEND_SETUP): {
*id = plpcdu::SETUP_CMD;
buildCommandFromCommand(*id, nullptr, 0);
break;
}
case(AdcStates::NORMAL): {
*id = plpcdu::READ_WITH_TEMP;
buildCommandFromCommand(*id, nullptr, 0);
break;
}
default: {
break;
}
switch (adcState) {
case (AdcStates::SEND_SETUP): {
*id = plpcdu::SETUP_CMD;
buildCommandFromCommand(*id, nullptr, 0);
break;
}
case (AdcStates::NORMAL): {
*id = plpcdu::READ_WITH_TEMP;
buildCommandFromCommand(*id, nullptr, 0);
break;
}
default: {
break;
}
}
return NOTHING_TO_SEND;
}
ReturnValue_t PayloadPcduHandler::buildTransitionDeviceCommand(DeviceCommandId_t* id) {
if(adcState == AdcStates::SEND_SETUP) {
if (adcState == AdcStates::SEND_SETUP) {
*id = plpcdu::SETUP_CMD;
buildCommandFromCommand(*id, nullptr, 0);
}
@ -174,30 +176,30 @@ void PayloadPcduHandler::fillCommandAndReplyMap() {
ReturnValue_t PayloadPcduHandler::buildCommandFromCommand(DeviceCommandId_t deviceCommand,
const uint8_t* commandData,
size_t commandDataLen) {
switch(deviceCommand) {
case(plpcdu::SETUP_CMD): {
cmdBuf[0] = plpcdu::SETUP_BYTE;
rawPacket = cmdBuf.data();
rawPacketLen = 1;
break;
}
case(plpcdu::READ_CMD): {
max1227::prepareExternallyClockedRead0ToN(cmdBuf.data(), plpcdu::CHANNEL_N, rawPacketLen);
rawPacket = cmdBuf.data();
break;
}
case(plpcdu::READ_TEMP): {
max1227::prepareExternallyClockedTemperatureRead(cmdBuf.data(), rawPacketLen);
rawPacket = cmdBuf.data();
break;
}
case(plpcdu::READ_WITH_TEMP): {
size_t sz = 0;
max1227::prepareExternallyClockedRead0ToN(cmdBuf.data(), plpcdu::CHANNEL_N, sz);
max1227::prepareExternallyClockedTemperatureRead(cmdBuf.data() + sz, sz);
rawPacketLen = sz;
rawPacket = cmdBuf.data();
}
switch (deviceCommand) {
case (plpcdu::SETUP_CMD): {
cmdBuf[0] = plpcdu::SETUP_BYTE;
rawPacket = cmdBuf.data();
rawPacketLen = 1;
break;
}
case (plpcdu::READ_CMD): {
max1227::prepareExternallyClockedRead0ToN(cmdBuf.data(), plpcdu::CHANNEL_N, rawPacketLen);
rawPacket = cmdBuf.data();
break;
}
case (plpcdu::READ_TEMP): {
max1227::prepareExternallyClockedTemperatureRead(cmdBuf.data(), rawPacketLen);
rawPacket = cmdBuf.data();
break;
}
case (plpcdu::READ_WITH_TEMP): {
size_t sz = 0;
max1227::prepareExternallyClockedRead0ToN(cmdBuf.data(), plpcdu::CHANNEL_N, sz);
max1227::prepareExternallyClockedTemperatureRead(cmdBuf.data() + sz, sz);
rawPacketLen = sz;
rawPacket = cmdBuf.data();
}
}
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,
const uint8_t* packet) {
using namespace plpcdu;
switch(id) {
case(SETUP_CMD): {
break;
}
case(READ_WITH_TEMP): {
PoolReadGuard pg(&adcSet);
if(pg.getReadResult() != HasReturnvaluesIF::RETURN_OK) {
return pg.getReadResult();
switch (id) {
case (SETUP_CMD): {
break;
}
for(uint8_t idx = 0; idx < 12; idx ++) {
adcSet.channels[idx] = packet[idx * 2 + 1] << 8 | packet[idx * 2 + 2];
case (READ_TEMP): {
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;
}
@ -244,3 +266,7 @@ ReturnValue_t PayloadPcduHandler::initializeLocalDataPool(localpool::DataPool& l
localDataPoolMap.emplace(plpcdu::PlPcduPoolIds::TEMP, &tempC);
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/timemanager/Countdown.h>
#include "devicedefinitions/payloadPcduDefinitions.h"
#include "fsfw_hal/common/gpio/GpioIF.h"
@ -24,6 +25,8 @@ class PayloadPcduHandler : DeviceHandlerBase {
public:
PayloadPcduHandler(object_id_t objectId, object_id_t comIF, CookieIF* cookie, GpioIF* gpioIF);
void setToGoToNormalModeImmediately(bool enable);
private:
enum class States {
PCDU_OFF,
@ -50,6 +53,7 @@ class PayloadPcduHandler : DeviceHandlerBase {
enum class AdcStates { OFF, BOOT_DELAY, SEND_SETUP, NORMAL } adcState = AdcStates::OFF;
bool goToNormalMode = false;
plpcdu::PlPcduAdcSet adcSet;
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

View File

@ -3,17 +3,16 @@
#include <fsfw/datapoollocal/StaticLocalDataSet.h>
#include <fsfw/devicehandlers/DeviceHandlerIF.h>
#include "mission/devices/max1227.h"
#include <cstddef>
#include "mission/devices/max1227.h"
namespace plpcdu {
using namespace max1227;
enum PlPcduPoolIds: uint32_t {
CHANNEL_VEC = 0,
TEMP = 1
};
enum PlPcduPoolIds : uint32_t { CHANNEL_VEC = 0, TEMP = 1 };
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
static constexpr size_t TEMP_REPLY_SIZE = 25;
static constexpr uint8_t SETUP_BYTE = max1227::buildSetupByte(ClkSel::EXT_CONV_EXT_TIMED,
RefSel::INT_REF_NO_WAKEUP, DiffSel::NONE_0);
static constexpr uint8_t SETUP_BYTE =
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 uint8_t CHANNELS_NUM = 12;
@ -40,13 +39,12 @@ class PlPcduAdcSet : public StaticLocalDataSet<DATASET_ENTRIES> {
public:
PlPcduAdcSet(HasLocalDataPoolIF* owner) : StaticLocalDataSet(owner, ADC_SET_ID) {}
PlPcduAdcSet(object_id_t objectId)
: StaticLocalDataSet(sid_t(objectId, ADC_SET_ID)) {}
PlPcduAdcSet(object_id_t objectId) : 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_var_t<float> tempC = lp_var_t<float>(sid.objectId, TEMP, this);
};
}
} // namespace plpcdu
#endif /* LINUX_DEVICES_DEVICEDEFINITIONS_PAYLOADPCDUDEFINITIONS_H_ */

View File

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