Merge branch 'mueller/rad-sensor-update' into mueller/master
Some checks failed
EIVE/eive-obsw/pipeline/head There was a failure building this commit

This commit is contained in:
Robin Müller 2022-02-24 11:52:16 +01:00
commit 42da2f2153
No known key found for this signature in database
GPG Key ID: 71B58F8A3CDFA9AC
4 changed files with 19 additions and 23 deletions

View File

@ -302,8 +302,8 @@ void ObjectFactory::createRadSensorComponent(LinuxLibgpioIF* gpioComIF) {
SpiCookie* spiCookieRadSensor = new SpiCookie( SpiCookie* spiCookieRadSensor = new SpiCookie(
addresses::RAD_SENSOR, gpioIds::CS_RAD_SENSOR, std::string(q7s::SPI_DEFAULT_DEV), addresses::RAD_SENSOR, gpioIds::CS_RAD_SENSOR, std::string(q7s::SPI_DEFAULT_DEV),
RAD_SENSOR::READ_SIZE, spi::DEFAULT_MAX_1227_MODE, spi::DEFAULT_MAX_1227_SPEED); RAD_SENSOR::READ_SIZE, spi::DEFAULT_MAX_1227_MODE, spi::DEFAULT_MAX_1227_SPEED);
auto radSensor = auto radSensor = new RadiationSensorHandler(objects::RAD_SENSOR, objects::SPI_COM_IF,
new RadiationSensorHandler(objects::RAD_SENSOR, objects::SPI_COM_IF, spiCookieRadSensor); spiCookieRadSensor, gpioComIF);
static_cast<void>(radSensor); static_cast<void>(radSensor);
#if OBSW_TEST_RAD_SENSOR == 1 #if OBSW_TEST_RAD_SENSOR == 1
radSensor->setStartUpImmediately(); radSensor->setStartUpImmediately();

View File

@ -1,14 +1,12 @@
#include "pollingSequenceFactory.h" #include "pollingSequenceFactory.h"
#include "OBSWConfig.h"
#include "objects/systemObjectList.h"
#include <fsfw/devicehandlers/DeviceHandlerIF.h> #include <fsfw/devicehandlers/DeviceHandlerIF.h>
#include <fsfw/objectmanager/ObjectManagerIF.h> #include <fsfw/objectmanager/ObjectManagerIF.h>
#include <fsfw/serviceinterface/ServiceInterfaceStream.h> #include <fsfw/serviceinterface/ServiceInterfaceStream.h>
#include <fsfw/tasks/FixedTimeslotTaskIF.h> #include <fsfw/tasks/FixedTimeslotTaskIF.h>
#include "OBSWConfig.h"
#include "mission/devices/SusHandler.h"
#include "objects/systemObjectList.h"
ReturnValue_t pst::pstGpio(FixedTimeslotTaskIF *thisSequence) { ReturnValue_t pst::pstGpio(FixedTimeslotTaskIF *thisSequence) {
// Length of a communication cycle // Length of a communication cycle
uint32_t length = thisSequence->getPeriodMs(); uint32_t length = thisSequence->getPeriodMs();

View File

@ -1,11 +1,12 @@
#include <OBSWConfig.h> #include <OBSWConfig.h>
#include <devices/gpioIds.h>
#include <fsfw/datapool/PoolReadGuard.h> #include <fsfw/datapool/PoolReadGuard.h>
#include <mission/devices/RadiationSensorHandler.h> #include <mission/devices/RadiationSensorHandler.h>
RadiationSensorHandler::RadiationSensorHandler(object_id_t objectId, object_id_t comIF, RadiationSensorHandler::RadiationSensorHandler(object_id_t objectId, object_id_t comIF,
CookieIF *comCookie) CookieIF *comCookie, GpioIF *gpioIF)
: DeviceHandlerBase(objectId, comIF, comCookie), dataset(this) { : DeviceHandlerBase(objectId, comIF, comCookie), dataset(this), gpioIF(gpioIF) {
if (comCookie == NULL) { if (comCookie == nullptr) {
sif::error << "RadiationSensorHandler: Invalid com cookie" << std::endl; sif::error << "RadiationSensorHandler: Invalid com cookie" << std::endl;
} }
} }
@ -68,6 +69,7 @@ ReturnValue_t RadiationSensorHandler::buildCommandFromCommand(DeviceCommandId_t
return RETURN_OK; return RETURN_OK;
} }
case (RAD_SENSOR::START_CONVERSION): { case (RAD_SENSOR::START_CONVERSION): {
gpioIF->pullHigh(gpioIds::ENABLE_RADFET);
/* First the fifo will be reset here */ /* First the fifo will be reset here */
cmdBuffer[0] = RAD_SENSOR::RESET_DEFINITION; cmdBuffer[0] = RAD_SENSOR::RESET_DEFINITION;
cmdBuffer[1] = RAD_SENSOR::CONVERSION_DEFINITION; cmdBuffer[1] = RAD_SENSOR::CONVERSION_DEFINITION;
@ -82,14 +84,6 @@ ReturnValue_t RadiationSensorHandler::buildCommandFromCommand(DeviceCommandId_t
rawPacketLen = RAD_SENSOR::READ_SIZE; rawPacketLen = RAD_SENSOR::READ_SIZE;
return RETURN_OK; return RETURN_OK;
} }
// case(RAD_SENSOR::AIN0_AND_TMP_CONVERSION): {
// /* First the fifo will be reset here */
// cmdBuffer[0] = RAD_SENSOR::RESET_DEFINITION;
// cmdBuffer[1] = RAD_SENSOR::CONVERSION_DEFINITION;
// rawPacket = cmdBuffer;
// rawPacketLen = 2;
// return RETURN_OK;
// }
default: default:
return DeviceHandlerIF::COMMAND_NOT_IMPLEMENTED; return DeviceHandlerIF::COMMAND_NOT_IMPLEMENTED;
} }
@ -111,6 +105,10 @@ ReturnValue_t RadiationSensorHandler::scanForReply(const uint8_t *start, size_t
case RAD_SENSOR::START_CONVERSION: case RAD_SENSOR::START_CONVERSION:
case RAD_SENSOR::WRITE_SETUP: case RAD_SENSOR::WRITE_SETUP:
return IGNORE_REPLY_DATA; return IGNORE_REPLY_DATA;
case RAD_SENSOR::READ_CONVERSIONS: {
gpioIF->pullLow(gpioIds::ENABLE_RADFET);
break;
}
default: default:
break; break;
} }
@ -141,7 +139,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));
#if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_RAD_SENSOR #if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_RAD_SENSOR == 1
sif::info << "Radiation sensor temperature: " << dataset.temperatureCelcius << " °C" sif::info << "Radiation sensor temperature: " << dataset.temperatureCelcius << " °C"
<< std::endl; << std::endl;
sif::info << "Radiation sensor ADC value channel 0: " << dataset.ain0 << std::endl; sif::info << "Radiation sensor ADC value channel 0: " << dataset.ain0 << std::endl;
@ -161,8 +159,6 @@ ReturnValue_t RadiationSensorHandler::interpretDeviceReply(DeviceCommandId_t id,
return HasReturnvaluesIF::RETURN_OK; return HasReturnvaluesIF::RETURN_OK;
} }
void RadiationSensorHandler::setNormalDatapoolEntriesInvalid() {}
uint32_t RadiationSensorHandler::getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) { uint32_t RadiationSensorHandler::getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) {
return 5000; return 5000;
} }

View File

@ -4,6 +4,8 @@
#include <fsfw/devicehandlers/DeviceHandlerBase.h> #include <fsfw/devicehandlers/DeviceHandlerBase.h>
#include <mission/devices/devicedefinitions/RadSensorDefinitions.h> #include <mission/devices/devicedefinitions/RadSensorDefinitions.h>
class GpioIF;
/** /**
* @brief This is the device handler class for radiation sensor on the OBC IF Board. The * @brief This is the device handler class for radiation sensor on the OBC IF Board. The
* sensor is based on the MAX1227 ADC converter. * sensor is based on the MAX1227 ADC converter.
@ -14,7 +16,8 @@
*/ */
class RadiationSensorHandler : public DeviceHandlerBase { class RadiationSensorHandler : public DeviceHandlerBase {
public: public:
RadiationSensorHandler(object_id_t objectId, object_id_t comIF, CookieIF *comCookie); RadiationSensorHandler(object_id_t objectId, object_id_t comIF, CookieIF *comCookie,
GpioIF *gpioIF);
virtual ~RadiationSensorHandler(); virtual ~RadiationSensorHandler();
void setToGoToNormalModeImmediately(); void setToGoToNormalModeImmediately();
@ -29,7 +32,6 @@ class RadiationSensorHandler : public DeviceHandlerBase {
ReturnValue_t scanForReply(const uint8_t *start, size_t remainingSize, DeviceCommandId_t *foundId, ReturnValue_t scanForReply(const uint8_t *start, size_t remainingSize, DeviceCommandId_t *foundId,
size_t *foundLen) override; size_t *foundLen) override;
ReturnValue_t interpretDeviceReply(DeviceCommandId_t id, const uint8_t *packet) override; ReturnValue_t interpretDeviceReply(DeviceCommandId_t id, const uint8_t *packet) override;
void setNormalDatapoolEntriesInvalid() override;
uint32_t getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) override; uint32_t getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) override;
ReturnValue_t initializeLocalDataPool(localpool::DataPool &localDataPoolMap, ReturnValue_t initializeLocalDataPool(localpool::DataPool &localDataPoolMap,
LocalDataPoolManager &poolManager) override; LocalDataPoolManager &poolManager) override;
@ -40,8 +42,8 @@ class RadiationSensorHandler : public DeviceHandlerBase {
enum class InternalState { SETUP, CONFIGURED }; enum class InternalState { SETUP, CONFIGURED };
RAD_SENSOR::RadSensorDataset dataset; RAD_SENSOR::RadSensorDataset dataset;
static const uint8_t MAX_CMD_LEN = RAD_SENSOR::READ_SIZE; static const uint8_t MAX_CMD_LEN = RAD_SENSOR::READ_SIZE;
GpioIF *gpioIF = nullptr;
bool goToNormalMode = false; bool goToNormalMode = false;
uint8_t cmdBuffer[MAX_CMD_LEN]; uint8_t cmdBuffer[MAX_CMD_LEN];