Merge pull request 'Reduced rad sensor polling' (#747) from rad-sensor-polling-update 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: #747 Reviewed-by: Marius Eggert <eggertm@irs.uni-stuttgart.de>
This commit is contained in:
commit
5e9fd332d9
@ -21,6 +21,8 @@ will consitute of a breaking change warranting a new major release:
|
|||||||
- STR missed reply handling is now moved to DHB rather than the COM interface. The COM IF will
|
- STR missed reply handling is now moved to DHB rather than the COM interface. The COM IF will
|
||||||
still trigger an event if a reply is taking too long, and FDIR should still work via reply
|
still trigger an event if a reply is taking too long, and FDIR should still work via reply
|
||||||
timeouts.
|
timeouts.
|
||||||
|
- Rad sensor is now only polled every 30 minutes instead of every device cycle to reduce wear of
|
||||||
|
the RADFET electronics.
|
||||||
|
|
||||||
## Added
|
## Added
|
||||||
|
|
||||||
|
@ -15,6 +15,8 @@ RadiationSensorHandler::RadiationSensorHandler(object_id_t objectId, object_id_t
|
|||||||
if (comCookie == nullptr) {
|
if (comCookie == nullptr) {
|
||||||
sif::error << "RadiationSensorHandler: Invalid com cookie" << std::endl;
|
sif::error << "RadiationSensorHandler: Invalid com cookie" << std::endl;
|
||||||
}
|
}
|
||||||
|
// Time out immediately so we get an immediate measurement at device startup.
|
||||||
|
measurementCd.timeOut();
|
||||||
}
|
}
|
||||||
|
|
||||||
RadiationSensorHandler::~RadiationSensorHandler() {}
|
RadiationSensorHandler::~RadiationSensorHandler() {}
|
||||||
@ -51,6 +53,9 @@ void RadiationSensorHandler::doShutDown() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ReturnValue_t RadiationSensorHandler::buildNormalDeviceCommand(DeviceCommandId_t *id) {
|
ReturnValue_t RadiationSensorHandler::buildNormalDeviceCommand(DeviceCommandId_t *id) {
|
||||||
|
if (measurementCd.isBusy()) {
|
||||||
|
return NOTHING_TO_SEND;
|
||||||
|
}
|
||||||
switch (communicationStep) {
|
switch (communicationStep) {
|
||||||
case CommunicationStep::START_CONVERSION: {
|
case CommunicationStep::START_CONVERSION: {
|
||||||
*id = radSens::START_CONVERSION;
|
*id = radSens::START_CONVERSION;
|
||||||
@ -177,6 +182,8 @@ ReturnValue_t RadiationSensorHandler::interpretDeviceReply(DeviceCommandId_t id,
|
|||||||
switch (id) {
|
switch (id) {
|
||||||
case radSens::READ_CONVERSIONS: {
|
case radSens::READ_CONVERSIONS: {
|
||||||
uint8_t offset = 0;
|
uint8_t offset = 0;
|
||||||
|
measurementCd.resetTimer();
|
||||||
|
{
|
||||||
PoolReadGuard readSet(&dataset);
|
PoolReadGuard readSet(&dataset);
|
||||||
uint16_t tempRaw = ((packet[offset] & 0x0f) << 8) | packet[offset + 1];
|
uint16_t tempRaw = ((packet[offset] & 0x0f) << 8) | packet[offset + 1];
|
||||||
dataset.temperatureCelcius = max1227::getTemperature(tempRaw);
|
dataset.temperatureCelcius = max1227::getTemperature(tempRaw);
|
||||||
@ -193,6 +200,7 @@ ReturnValue_t RadiationSensorHandler::interpretDeviceReply(DeviceCommandId_t id,
|
|||||||
offset += 2;
|
offset += 2;
|
||||||
dataset.ain7 = (*(packet + offset) << 8) | *(packet + offset + 1);
|
dataset.ain7 = (*(packet + offset) << 8) | *(packet + offset + 1);
|
||||||
dataset.setValidity(true, true);
|
dataset.setValidity(true, true);
|
||||||
|
}
|
||||||
if (printPeriodicData) {
|
if (printPeriodicData) {
|
||||||
sif::info << "Radiation sensor temperature: " << dataset.temperatureCelcius << " °C"
|
sif::info << "Radiation sensor temperature: " << dataset.temperatureCelcius << " °C"
|
||||||
<< std::dec << std::endl;
|
<< std::dec << std::endl;
|
||||||
@ -203,6 +211,12 @@ ReturnValue_t RadiationSensorHandler::interpretDeviceReply(DeviceCommandId_t id,
|
|||||||
sif::info << "Radiation sensor ADC value channel 6: " << dataset.ain6 << std::endl;
|
sif::info << "Radiation sensor ADC value channel 6: " << dataset.ain6 << std::endl;
|
||||||
sif::info << "Radiation sensor ADC value channel 7: " << dataset.ain7 << std::endl;
|
sif::info << "Radiation sensor ADC value channel 7: " << dataset.ain7 << std::endl;
|
||||||
}
|
}
|
||||||
|
ReturnValue_t result =
|
||||||
|
getHkManagerHandle()->generateHousekeepingPacket(dataset.getSid(), &dataset, true);
|
||||||
|
if (result != returnvalue::OK) {
|
||||||
|
// TODO: Maybe add event?
|
||||||
|
sif::error << "Generating HK set for radiation sensor failed" << std::endl;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default: {
|
default: {
|
||||||
@ -226,8 +240,11 @@ ReturnValue_t RadiationSensorHandler::initializeLocalDataPool(localpool::DataPoo
|
|||||||
localDataPoolMap.emplace(radSens::AIN5, 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::AIN6, new PoolEntry<uint16_t>({0}));
|
||||||
localDataPoolMap.emplace(radSens::AIN7, new PoolEntry<uint16_t>({0}));
|
localDataPoolMap.emplace(radSens::AIN7, new PoolEntry<uint16_t>({0}));
|
||||||
|
// It should normally not be necessary to enable this set, as a sample TM will be generated
|
||||||
|
// after a measurement. If this is still enabled, sample with double the measurement frequency
|
||||||
|
// to ensure we get all measurements.
|
||||||
poolManager.subscribeForRegularPeriodicPacket(
|
poolManager.subscribeForRegularPeriodicPacket(
|
||||||
subdp::RegularHkPeriodicParams(dataset.getSid(), false, 20.0));
|
subdp::RegularHkPeriodicParams(dataset.getSid(), false, DEFAULT_MEASUREMENT_CD_MS / 2));
|
||||||
return returnvalue::OK;
|
return returnvalue::OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -38,12 +38,15 @@ class RadiationSensorHandler : public DeviceHandlerBase {
|
|||||||
LocalDataPoolManager &poolManager) override;
|
LocalDataPoolManager &poolManager) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
static constexpr uint32_t DEFAULT_MEASUREMENT_CD_MS = 30 * 60 * 1000;
|
||||||
|
|
||||||
enum class CommunicationStep { START_CONVERSION, READ_CONVERSIONS };
|
enum class CommunicationStep { START_CONVERSION, READ_CONVERSIONS };
|
||||||
|
|
||||||
enum class InternalState { OFF, POWER_SWITCHING, SETUP, CONFIGURED };
|
enum class InternalState { OFF, POWER_SWITCHING, SETUP, CONFIGURED };
|
||||||
|
|
||||||
bool printPeriodicData = false;
|
bool printPeriodicData = false;
|
||||||
radSens::RadSensorDataset dataset;
|
radSens::RadSensorDataset dataset;
|
||||||
|
Countdown measurementCd = Countdown(DEFAULT_MEASUREMENT_CD_MS);
|
||||||
static const uint8_t MAX_CMD_LEN = radSens::READ_SIZE;
|
static const uint8_t MAX_CMD_LEN = radSens::READ_SIZE;
|
||||||
GpioIF *gpioIF = nullptr;
|
GpioIF *gpioIF = nullptr;
|
||||||
Stack5VHandler &stackHandler;
|
Stack5VHandler &stackHandler;
|
||||||
|
Loading…
Reference in New Issue
Block a user