that should do the job
All checks were successful
EIVE/eive-obsw/pipeline/head This commit looks good
EIVE/eive-obsw/pipeline/pr-main This commit looks good

This commit is contained in:
Robin Müller 2023-07-18 11:01:53 +02:00
parent 2c9df747e8
commit a4a5800cba
Signed by: muellerr
GPG Key ID: A649FB78196E3849
2 changed files with 34 additions and 17 deletions

View File

@ -51,6 +51,9 @@ void RadiationSensorHandler::doShutDown() {
}
ReturnValue_t RadiationSensorHandler::buildNormalDeviceCommand(DeviceCommandId_t *id) {
if (measurementCd.isBusy()) {
return NOTHING_TO_SEND;
}
switch (communicationStep) {
case CommunicationStep::START_CONVERSION: {
*id = radSens::START_CONVERSION;
@ -177,6 +180,7 @@ ReturnValue_t RadiationSensorHandler::interpretDeviceReply(DeviceCommandId_t id,
switch (id) {
case radSens::READ_CONVERSIONS: {
uint8_t offset = 0;
{
PoolReadGuard readSet(&dataset);
uint16_t tempRaw = ((packet[offset] & 0x0f) << 8) | packet[offset + 1];
dataset.temperatureCelcius = max1227::getTemperature(tempRaw);
@ -193,6 +197,7 @@ ReturnValue_t RadiationSensorHandler::interpretDeviceReply(DeviceCommandId_t id,
offset += 2;
dataset.ain7 = (*(packet + offset) << 8) | *(packet + offset + 1);
dataset.setValidity(true, true);
}
if (printPeriodicData) {
sif::info << "Radiation sensor temperature: " << dataset.temperatureCelcius << " °C"
<< std::dec << std::endl;
@ -203,6 +208,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 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;
}
default: {
@ -226,8 +237,11 @@ ReturnValue_t RadiationSensorHandler::initializeLocalDataPool(localpool::DataPoo
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}));
// 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(
subdp::RegularHkPeriodicParams(dataset.getSid(), false, 20.0));
subdp::RegularHkPeriodicParams(dataset.getSid(), false, DEFAULT_MEASUREMENT_CD_MS / 2));
return returnvalue::OK;
}

View File

@ -38,12 +38,15 @@ class RadiationSensorHandler : public DeviceHandlerBase {
LocalDataPoolManager &poolManager) override;
private:
static constexpr uint32_t DEFAULT_MEASUREMENT_CD_MS = 30 * 60 * 1000;
enum class CommunicationStep { START_CONVERSION, READ_CONVERSIONS };
enum class InternalState { OFF, POWER_SWITCHING, SETUP, CONFIGURED };
bool printPeriodicData = false;
radSens::RadSensorDataset dataset;
Countdown measurementCd = Countdown(DEFAULT_MEASUREMENT_CD_MS);
static const uint8_t MAX_CMD_LEN = radSens::READ_SIZE;
GpioIF *gpioIF = nullptr;
Stack5VHandler &stackHandler;