Merge pull request 'Add RAD sensor dummy' (#745) from add-rad-sensor-dummy into main
All checks were successful
EIVE/eive-obsw/pipeline/head This commit looks good
All checks were successful
EIVE/eive-obsw/pipeline/head This commit looks good
Reviewed-on: #745 Reviewed-by: Marius Eggert <eggertm@irs.uni-stuttgart.de>
This commit is contained in:
commit
2c9df747e8
@ -29,6 +29,7 @@ will consitute of a breaking change warranting a new major release:
|
||||
startup.
|
||||
- The STR handler can now handle the COM error reply and triggers an low severity event accordingly.
|
||||
- Add SCEX handler for EM.
|
||||
- Radiation sensor handler dummy for the EM.
|
||||
|
||||
## Fixed
|
||||
|
||||
|
@ -249,7 +249,7 @@ ReturnValue_t ObjectFactory::createRadSensorComponent(LinuxLibgpioIF* gpioComIF,
|
||||
createRadSensorChipSelect(gpioComIF);
|
||||
|
||||
SpiCookie* spiCookieRadSensor =
|
||||
new SpiCookie(addresses::RAD_SENSOR, gpioIds::CS_RAD_SENSOR, RAD_SENSOR::READ_SIZE,
|
||||
new SpiCookie(addresses::RAD_SENSOR, gpioIds::CS_RAD_SENSOR, radSens::READ_SIZE,
|
||||
spi::DEFAULT_MAX_1227_MODE, spi::DEFAULT_MAX_1227_SPEED);
|
||||
spiCookieRadSensor->setMutexParams(MutexIF::TimeoutType::WAITING, spi::RAD_SENSOR_CS_TIMEOUT);
|
||||
auto radSensor = new RadiationSensorHandler(objects::RAD_SENSOR, objects::SPI_MAIN_COM_IF,
|
||||
|
@ -19,6 +19,7 @@ target_sources(
|
||||
GpsCtrlDummy.cpp
|
||||
GyroAdisDummy.cpp
|
||||
GyroL3GD20Dummy.cpp
|
||||
RadSensorDummy.cpp
|
||||
MgmLIS3MDLDummy.cpp
|
||||
PlPcduDummy.cpp
|
||||
ExecutableComIfDummy.cpp
|
||||
|
55
dummies/RadSensorDummy.cpp
Normal file
55
dummies/RadSensorDummy.cpp
Normal file
@ -0,0 +1,55 @@
|
||||
#include "RadSensorDummy.h"
|
||||
|
||||
RadSensorDummy::RadSensorDummy(object_id_t objectId, object_id_t comif, CookieIF *comCookie)
|
||||
: DeviceHandlerBase(objectId, comif, comCookie), sensorSet(this) {}
|
||||
|
||||
RadSensorDummy::~RadSensorDummy() {}
|
||||
|
||||
void RadSensorDummy::doStartUp() { setMode(MODE_ON); }
|
||||
|
||||
void RadSensorDummy::doShutDown() { setMode(MODE_OFF); }
|
||||
|
||||
ReturnValue_t RadSensorDummy::buildNormalDeviceCommand(DeviceCommandId_t *id) {
|
||||
return NOTHING_TO_SEND;
|
||||
}
|
||||
|
||||
ReturnValue_t RadSensorDummy::buildTransitionDeviceCommand(DeviceCommandId_t *id) {
|
||||
return NOTHING_TO_SEND;
|
||||
}
|
||||
|
||||
ReturnValue_t RadSensorDummy::buildCommandFromCommand(DeviceCommandId_t deviceCommand,
|
||||
const uint8_t *commandData,
|
||||
size_t commandDataLen) {
|
||||
return returnvalue::OK;
|
||||
}
|
||||
|
||||
ReturnValue_t RadSensorDummy::scanForReply(const uint8_t *start, size_t len,
|
||||
DeviceCommandId_t *foundId, size_t *foundLen) {
|
||||
return returnvalue::OK;
|
||||
}
|
||||
|
||||
ReturnValue_t RadSensorDummy::interpretDeviceReply(DeviceCommandId_t id, const uint8_t *packet) {
|
||||
return returnvalue::OK;
|
||||
}
|
||||
|
||||
void RadSensorDummy::fillCommandAndReplyMap() {}
|
||||
|
||||
uint32_t RadSensorDummy::getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) { return 500; }
|
||||
|
||||
ReturnValue_t RadSensorDummy::initializeLocalDataPool(localpool::DataPool &localDataPoolMap,
|
||||
LocalDataPoolManager &poolManager) {
|
||||
localDataPoolMap.emplace(radSens::TEMPERATURE_C, new PoolEntry<float>({0.0}));
|
||||
localDataPoolMap.emplace(radSens::AIN0, new PoolEntry<uint16_t>({0}));
|
||||
localDataPoolMap.emplace(radSens::AIN1, new PoolEntry<uint16_t>({0}));
|
||||
localDataPoolMap.emplace(radSens::AIN4, new PoolEntry<uint16_t>({0}));
|
||||
localDataPoolMap.emplace(radSens::AIN5, new PoolEntry<uint16_t>({0}));
|
||||
localDataPoolMap.emplace(radSens::AIN6, new PoolEntry<uint16_t>({0}));
|
||||
localDataPoolMap.emplace(radSens::AIN7, new PoolEntry<uint16_t>({0}));
|
||||
poolManager.subscribeForRegularPeriodicPacket(
|
||||
subdp::RegularHkPeriodicParams(sensorSet.getSid(), false, 20.0));
|
||||
return returnvalue::OK;
|
||||
|
||||
return returnvalue::OK;
|
||||
}
|
||||
|
||||
LocalPoolDataSetBase *RadSensorDummy::getDataSetHandle(sid_t sid) { return &sensorSet; }
|
35
dummies/RadSensorDummy.h
Normal file
35
dummies/RadSensorDummy.h
Normal file
@ -0,0 +1,35 @@
|
||||
#pragma once
|
||||
|
||||
#include <fsfw/devicehandlers/DeviceHandlerBase.h>
|
||||
|
||||
#include "mission/payload/radSensorDefinitions.h"
|
||||
|
||||
class RadSensorDummy : public DeviceHandlerBase {
|
||||
public:
|
||||
static const DeviceCommandId_t SIMPLE_COMMAND = 1;
|
||||
static const DeviceCommandId_t PERIODIC_REPLY = 2;
|
||||
|
||||
static const uint8_t SIMPLE_COMMAND_DATA = 1;
|
||||
static const uint8_t PERIODIC_REPLY_DATA = 2;
|
||||
|
||||
RadSensorDummy(object_id_t objectId, object_id_t comif, CookieIF *comCookie);
|
||||
virtual ~RadSensorDummy();
|
||||
|
||||
protected:
|
||||
radSens::RadSensorDataset sensorSet;
|
||||
|
||||
void doStartUp() override;
|
||||
void doShutDown() override;
|
||||
ReturnValue_t buildNormalDeviceCommand(DeviceCommandId_t *id) override;
|
||||
ReturnValue_t buildTransitionDeviceCommand(DeviceCommandId_t *id) override;
|
||||
ReturnValue_t buildCommandFromCommand(DeviceCommandId_t deviceCommand, const uint8_t *commandData,
|
||||
size_t commandDataLen) override;
|
||||
ReturnValue_t scanForReply(const uint8_t *start, size_t len, DeviceCommandId_t *foundId,
|
||||
size_t *foundLen) override;
|
||||
ReturnValue_t interpretDeviceReply(DeviceCommandId_t id, const uint8_t *packet) override;
|
||||
void fillCommandAndReplyMap() override;
|
||||
uint32_t getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) override;
|
||||
ReturnValue_t initializeLocalDataPool(localpool::DataPool &localDataPoolMap,
|
||||
LocalDataPoolManager &poolManager) override;
|
||||
LocalPoolDataSetBase *getDataSetHandle(sid_t sid) override;
|
||||
};
|
@ -18,6 +18,7 @@
|
||||
#include <dummies/PlPcduDummy.h>
|
||||
#include <dummies/PlocMpsocDummy.h>
|
||||
#include <dummies/PlocSupervisorDummy.h>
|
||||
#include <dummies/RadSensorDummy.h>
|
||||
#include <dummies/RwDummy.h>
|
||||
#include <dummies/SaDeploymentDummy.h>
|
||||
#include <dummies/ScexDummy.h>
|
||||
@ -34,6 +35,7 @@
|
||||
|
||||
#include "TemperatureSensorInserter.h"
|
||||
#include "dummies/Max31865Dummy.h"
|
||||
#include "dummies/SusDummy.h"
|
||||
#include "dummies/Tmp1075Dummy.h"
|
||||
#include "mission/genericFactory.h"
|
||||
#include "mission/system/acs/acsModeTree.h"
|
||||
@ -257,4 +259,9 @@ void dummy::createDummies(DummyCfg cfg, PowerSwitchIF& pwrSwitcher, GpioIF* gpio
|
||||
objects::PLOC_SUPERVISOR_HANDLER, objects::DUMMY_COM_IF, comCookieDummy, pwrSwitcher);
|
||||
plocSupervisorDummy->connectModeTreeParent(satsystem::payload::SUBSYSTEM);
|
||||
}
|
||||
if (cfg.addRadSensorDummy) {
|
||||
auto* radSensorDummy =
|
||||
new RadSensorDummy(objects::RAD_SENSOR, objects::DUMMY_COM_IF, comCookieDummy);
|
||||
radSensorDummy->connectModeTreeParent(satsystem::payload::SUBSYSTEM);
|
||||
}
|
||||
}
|
||||
|
@ -29,6 +29,7 @@ struct DummyCfg {
|
||||
bool addPlocDummies = true;
|
||||
bool addStrDummy = true;
|
||||
bool addTmpDummies = true;
|
||||
bool addRadSensorDummy = true;
|
||||
Tmp1075Cfg tmp1075Cfg;
|
||||
bool addCamSwitcherDummy = false;
|
||||
bool addScexDummy = false;
|
||||
|
@ -53,12 +53,12 @@ void RadiationSensorHandler::doShutDown() {
|
||||
ReturnValue_t RadiationSensorHandler::buildNormalDeviceCommand(DeviceCommandId_t *id) {
|
||||
switch (communicationStep) {
|
||||
case CommunicationStep::START_CONVERSION: {
|
||||
*id = RAD_SENSOR::START_CONVERSION;
|
||||
*id = radSens::START_CONVERSION;
|
||||
communicationStep = CommunicationStep::READ_CONVERSIONS;
|
||||
break;
|
||||
}
|
||||
case CommunicationStep::READ_CONVERSIONS: {
|
||||
*id = RAD_SENSOR::READ_CONVERSIONS;
|
||||
*id = radSens::READ_CONVERSIONS;
|
||||
communicationStep = CommunicationStep::START_CONVERSION;
|
||||
break;
|
||||
}
|
||||
@ -73,7 +73,7 @@ ReturnValue_t RadiationSensorHandler::buildNormalDeviceCommand(DeviceCommandId_t
|
||||
|
||||
ReturnValue_t RadiationSensorHandler::buildTransitionDeviceCommand(DeviceCommandId_t *id) {
|
||||
if (internalState == InternalState::SETUP) {
|
||||
*id = RAD_SENSOR::WRITE_SETUP;
|
||||
*id = radSens::WRITE_SETUP;
|
||||
} else {
|
||||
return NOTHING_TO_SEND;
|
||||
}
|
||||
@ -84,14 +84,14 @@ ReturnValue_t RadiationSensorHandler::buildCommandFromCommand(DeviceCommandId_t
|
||||
const uint8_t *commandData,
|
||||
size_t commandDataLen) {
|
||||
switch (deviceCommand) {
|
||||
case (RAD_SENSOR::WRITE_SETUP): {
|
||||
cmdBuffer[0] = RAD_SENSOR::SETUP_DEFINITION;
|
||||
case (radSens::WRITE_SETUP): {
|
||||
cmdBuffer[0] = radSens::SETUP_DEFINITION;
|
||||
rawPacket = cmdBuffer;
|
||||
rawPacketLen = 1;
|
||||
internalState = InternalState::CONFIGURED;
|
||||
return returnvalue::OK;
|
||||
}
|
||||
case (RAD_SENSOR::START_CONVERSION): {
|
||||
case (radSens::START_CONVERSION): {
|
||||
ReturnValue_t result = gpioIF->pullHigh(gpioIds::ENABLE_RADFET);
|
||||
if (result != returnvalue::OK) {
|
||||
#if OBSW_VERBOSE_LEVEL >= 1
|
||||
@ -102,25 +102,25 @@ ReturnValue_t RadiationSensorHandler::buildCommandFromCommand(DeviceCommandId_t
|
||||
#endif
|
||||
}
|
||||
/* First the fifo will be reset here */
|
||||
cmdBuffer[0] = RAD_SENSOR::RESET_DEFINITION;
|
||||
cmdBuffer[1] = RAD_SENSOR::CONVERSION_DEFINITION;
|
||||
cmdBuffer[0] = radSens::RESET_DEFINITION;
|
||||
cmdBuffer[1] = radSens::CONVERSION_DEFINITION;
|
||||
rawPacket = cmdBuffer;
|
||||
rawPacketLen = 2;
|
||||
return returnvalue::OK;
|
||||
}
|
||||
case (RAD_SENSOR::READ_CONVERSIONS): {
|
||||
cmdBuffer[0] = RAD_SENSOR::DUMMY_BYTE;
|
||||
std::memset(cmdBuffer, RAD_SENSOR::DUMMY_BYTE, RAD_SENSOR::READ_SIZE);
|
||||
case (radSens::READ_CONVERSIONS): {
|
||||
cmdBuffer[0] = radSens::DUMMY_BYTE;
|
||||
std::memset(cmdBuffer, radSens::DUMMY_BYTE, radSens::READ_SIZE);
|
||||
rawPacket = cmdBuffer;
|
||||
rawPacketLen = RAD_SENSOR::READ_SIZE;
|
||||
rawPacketLen = radSens::READ_SIZE;
|
||||
return returnvalue::OK;
|
||||
}
|
||||
case RAD_SENSOR::ENABLE_DEBUG_OUTPUT: {
|
||||
case radSens::ENABLE_DEBUG_OUTPUT: {
|
||||
printPeriodicData = true;
|
||||
rawPacketLen = 0;
|
||||
return returnvalue::OK;
|
||||
}
|
||||
case RAD_SENSOR::DISABLE_DEBUG_OUTPUT: {
|
||||
case radSens::DISABLE_DEBUG_OUTPUT: {
|
||||
rawPacketLen = 0;
|
||||
printPeriodicData = false;
|
||||
return returnvalue::OK;
|
||||
@ -132,12 +132,11 @@ ReturnValue_t RadiationSensorHandler::buildCommandFromCommand(DeviceCommandId_t
|
||||
}
|
||||
|
||||
void RadiationSensorHandler::fillCommandAndReplyMap() {
|
||||
this->insertInCommandMap(RAD_SENSOR::WRITE_SETUP);
|
||||
this->insertInCommandMap(RAD_SENSOR::START_CONVERSION);
|
||||
this->insertInCommandMap(RAD_SENSOR::ENABLE_DEBUG_OUTPUT);
|
||||
this->insertInCommandMap(RAD_SENSOR::DISABLE_DEBUG_OUTPUT);
|
||||
this->insertInCommandAndReplyMap(RAD_SENSOR::READ_CONVERSIONS, 1, &dataset,
|
||||
RAD_SENSOR::READ_SIZE);
|
||||
this->insertInCommandMap(radSens::WRITE_SETUP);
|
||||
this->insertInCommandMap(radSens::START_CONVERSION);
|
||||
this->insertInCommandMap(radSens::ENABLE_DEBUG_OUTPUT);
|
||||
this->insertInCommandMap(radSens::DISABLE_DEBUG_OUTPUT);
|
||||
this->insertInCommandAndReplyMap(radSens::READ_CONVERSIONS, 1, &dataset, radSens::READ_SIZE);
|
||||
}
|
||||
|
||||
ReturnValue_t RadiationSensorHandler::scanForReply(const uint8_t *start, size_t remainingSize,
|
||||
@ -145,11 +144,11 @@ ReturnValue_t RadiationSensorHandler::scanForReply(const uint8_t *start, size_t
|
||||
*foundId = this->getPendingCommand();
|
||||
|
||||
switch (*foundId) {
|
||||
case RAD_SENSOR::START_CONVERSION:
|
||||
case RAD_SENSOR::WRITE_SETUP:
|
||||
case radSens::START_CONVERSION:
|
||||
case radSens::WRITE_SETUP:
|
||||
*foundLen = remainingSize;
|
||||
return IGNORE_REPLY_DATA;
|
||||
case RAD_SENSOR::READ_CONVERSIONS: {
|
||||
case radSens::READ_CONVERSIONS: {
|
||||
ReturnValue_t result = gpioIF->pullLow(gpioIds::ENABLE_RADFET);
|
||||
if (result != returnvalue::OK) {
|
||||
#if OBSW_VERBOSE_LEVEL >= 1
|
||||
@ -160,8 +159,8 @@ ReturnValue_t RadiationSensorHandler::scanForReply(const uint8_t *start, size_t
|
||||
}
|
||||
break;
|
||||
}
|
||||
case RAD_SENSOR::ENABLE_DEBUG_OUTPUT:
|
||||
case RAD_SENSOR::DISABLE_DEBUG_OUTPUT:
|
||||
case radSens::ENABLE_DEBUG_OUTPUT:
|
||||
case radSens::DISABLE_DEBUG_OUTPUT:
|
||||
sif::info << "RadiationSensorHandler::scanForReply: " << remainingSize << std::endl;
|
||||
break;
|
||||
default:
|
||||
@ -176,7 +175,7 @@ ReturnValue_t RadiationSensorHandler::scanForReply(const uint8_t *start, size_t
|
||||
ReturnValue_t RadiationSensorHandler::interpretDeviceReply(DeviceCommandId_t id,
|
||||
const uint8_t *packet) {
|
||||
switch (id) {
|
||||
case RAD_SENSOR::READ_CONVERSIONS: {
|
||||
case radSens::READ_CONVERSIONS: {
|
||||
uint8_t offset = 0;
|
||||
PoolReadGuard readSet(&dataset);
|
||||
uint16_t tempRaw = ((packet[offset] & 0x0f) << 8) | packet[offset + 1];
|
||||
@ -220,13 +219,13 @@ uint32_t RadiationSensorHandler::getTransitionDelayMs(Mode_t modeFrom, Mode_t mo
|
||||
|
||||
ReturnValue_t RadiationSensorHandler::initializeLocalDataPool(localpool::DataPool &localDataPoolMap,
|
||||
LocalDataPoolManager &poolManager) {
|
||||
localDataPoolMap.emplace(RAD_SENSOR::TEMPERATURE_C, new PoolEntry<float>({0.0}));
|
||||
localDataPoolMap.emplace(RAD_SENSOR::AIN0, new PoolEntry<uint16_t>({0}));
|
||||
localDataPoolMap.emplace(RAD_SENSOR::AIN1, new PoolEntry<uint16_t>({0}));
|
||||
localDataPoolMap.emplace(RAD_SENSOR::AIN4, new PoolEntry<uint16_t>({0}));
|
||||
localDataPoolMap.emplace(RAD_SENSOR::AIN5, new PoolEntry<uint16_t>({0}));
|
||||
localDataPoolMap.emplace(RAD_SENSOR::AIN6, new PoolEntry<uint16_t>({0}));
|
||||
localDataPoolMap.emplace(RAD_SENSOR::AIN7, new PoolEntry<uint16_t>({0}));
|
||||
localDataPoolMap.emplace(radSens::TEMPERATURE_C, new PoolEntry<float>({0.0}));
|
||||
localDataPoolMap.emplace(radSens::AIN0, new PoolEntry<uint16_t>({0}));
|
||||
localDataPoolMap.emplace(radSens::AIN1, new PoolEntry<uint16_t>({0}));
|
||||
localDataPoolMap.emplace(radSens::AIN4, new PoolEntry<uint16_t>({0}));
|
||||
localDataPoolMap.emplace(radSens::AIN5, new PoolEntry<uint16_t>({0}));
|
||||
localDataPoolMap.emplace(radSens::AIN6, new PoolEntry<uint16_t>({0}));
|
||||
localDataPoolMap.emplace(radSens::AIN7, new PoolEntry<uint16_t>({0}));
|
||||
poolManager.subscribeForRegularPeriodicPacket(
|
||||
subdp::RegularHkPeriodicParams(dataset.getSid(), false, 20.0));
|
||||
return returnvalue::OK;
|
||||
|
@ -43,8 +43,8 @@ class RadiationSensorHandler : public DeviceHandlerBase {
|
||||
enum class InternalState { OFF, POWER_SWITCHING, SETUP, CONFIGURED };
|
||||
|
||||
bool printPeriodicData = false;
|
||||
RAD_SENSOR::RadSensorDataset dataset;
|
||||
static const uint8_t MAX_CMD_LEN = RAD_SENSOR::READ_SIZE;
|
||||
radSens::RadSensorDataset dataset;
|
||||
static const uint8_t MAX_CMD_LEN = radSens::READ_SIZE;
|
||||
GpioIF *gpioIF = nullptr;
|
||||
Stack5VHandler &stackHandler;
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
#ifndef MISSION_DEVICES_DEVICEDEFINITIONS_RADSENSOR_H_
|
||||
#define MISSION_DEVICES_DEVICEDEFINITIONS_RADSENSOR_H_
|
||||
|
||||
namespace RAD_SENSOR {
|
||||
namespace radSens {
|
||||
|
||||
static const DeviceCommandId_t NONE = 0x0; // Set when no command is pending
|
||||
|
||||
@ -78,6 +78,6 @@ class RadSensorDataset : public StaticLocalDataSet<DATASET_ENTRIES> {
|
||||
lp_var_t<uint16_t> ain6 = lp_var_t<uint16_t>(sid.objectId, AIN6, this);
|
||||
lp_var_t<uint16_t> ain7 = lp_var_t<uint16_t>(sid.objectId, AIN7, this);
|
||||
};
|
||||
} // namespace RAD_SENSOR
|
||||
} // namespace radSens
|
||||
|
||||
#endif /* MISSION_DEVICES_DEVICEDEFINITIONS_RADSENSOR_H_ */
|
||||
|
@ -591,7 +591,6 @@ ReturnValue_t pst::pstTcsAndAcs(FixedTimeslotTaskIF *thisSequence, AcsPstCfg cfg
|
||||
thisSequence->addSlot(objects::BPX_BATT_HANDLER, length * config::spiSched::SCHED_BLOCK_9_PERIOD,
|
||||
DeviceHandlerIF::GET_READ);
|
||||
|
||||
#if OBSW_ADD_RAD_SENSORS == 1
|
||||
/* Radiation sensor */
|
||||
thisSequence->addSlot(objects::RAD_SENSOR, length * config::spiSched::SCHED_BLOCK_9_PERIOD,
|
||||
DeviceHandlerIF::PERFORM_OPERATION);
|
||||
@ -603,6 +602,5 @@ ReturnValue_t pst::pstTcsAndAcs(FixedTimeslotTaskIF *thisSequence, AcsPstCfg cfg
|
||||
DeviceHandlerIF::SEND_READ);
|
||||
thisSequence->addSlot(objects::RAD_SENSOR, length * config::spiSched::SCHED_BLOCK_9_PERIOD,
|
||||
DeviceHandlerIF::GET_READ);
|
||||
#endif
|
||||
return returnvalue::OK;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user