moved gps handler and deployment handler #152

Merged
muellerr merged 5 commits from mueller/move-deply-handler into develop 2022-02-25 11:22:53 +01:00
8 changed files with 56 additions and 28 deletions
Showing only changes of commit e01f2a8947 - Show all commits

View File

@ -67,6 +67,7 @@ static constexpr char EN_RW_3[] = "enable_rw_3";
static constexpr char EN_RW_4[] = "enable_rw_4"; static constexpr char EN_RW_4[] = "enable_rw_4";
static constexpr char GNSS_MUX_SELECT[] = "gnss_mux_select"; static constexpr char GNSS_MUX_SELECT[] = "gnss_mux_select";
static constexpr char RAD_SENSOR_CHIP_SELECT[] = "rad_sensor_chip_select"; static constexpr char RAD_SENSOR_CHIP_SELECT[] = "rad_sensor_chip_select";
static constexpr char ENABLE_RADFET[] = "enable_radfet";
static constexpr char PAPB_BUSY_SIGNAL_VC0[] = "papb_busy_signal_vc0"; static constexpr char PAPB_BUSY_SIGNAL_VC0[] = "papb_busy_signal_vc0";
static constexpr char PAPB_EMPTY_SIGNAL_VC0[] = "papb_empty_signal_vc0"; static constexpr char PAPB_EMPTY_SIGNAL_VC0[] = "papb_empty_signal_vc0";
static constexpr char PAPB_BUSY_SIGNAL_VC1[] = "papb_busy_signal_vc1"; static constexpr char PAPB_BUSY_SIGNAL_VC1[] = "papb_busy_signal_vc1";

View File

@ -295,12 +295,21 @@ void ObjectFactory::createRadSensorComponent(LinuxLibgpioIF* gpioComIF) {
GpiodRegularByLineName* gpio = new GpiodRegularByLineName( GpiodRegularByLineName* gpio = new GpiodRegularByLineName(
q7s::gpioNames::RAD_SENSOR_CHIP_SELECT, consumer.str(), gpio::DIR_OUT, gpio::HIGH); q7s::gpioNames::RAD_SENSOR_CHIP_SELECT, consumer.str(), gpio::DIR_OUT, gpio::HIGH);
gpioCookieRadSensor->addGpio(gpioIds::CS_RAD_SENSOR, gpio); gpioCookieRadSensor->addGpio(gpioIds::CS_RAD_SENSOR, gpio);
gpio = new GpiodRegularByLineName(q7s::gpioNames::ENABLE_RADFET, consumer.str(), gpio::DIR_OUT,
gpio::LOW);
gpioCookieRadSensor->addGpio(gpioIds::ENABLE_RADFET, gpio);
gpioComIF->addGpios(gpioCookieRadSensor); gpioComIF->addGpios(gpioCookieRadSensor);
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);
new RadiationSensorHandler(objects::RAD_SENSOR, objects::SPI_COM_IF, spiCookieRadSensor); auto radSensor = new RadiationSensorHandler(objects::RAD_SENSOR, objects::SPI_COM_IF,
spiCookieRadSensor, gpioComIF);
static_cast<void>(radSensor);
#if OBSW_TEST_RAD_SENSOR == 1
radSensor->setStartUpImmediately();
radSensor->setToGoToNormalModeImmediately();
#endif
} }
void ObjectFactory::createSunSensorComponents(LinuxLibgpioIF* gpioComIF, SpiComIF* spiComIF) { void ObjectFactory::createSunSensorComponents(LinuxLibgpioIF* gpioComIF, SpiComIF* spiComIF) {

View File

@ -1,7 +1,6 @@
#include "simple.h" #include "simple.h"
#include "iostream" #include "iostream"
#include "q7sConfig.h" #include "q7sConfig.h"
#if Q7S_SIMPLE_ADD_FILE_SYSTEM_TEST == 1 #if Q7S_SIMPLE_ADD_FILE_SYSTEM_TEST == 1

View File

@ -76,6 +76,7 @@ enum gpioId_t {
SPI_MUX_BIT_6, SPI_MUX_BIT_6,
CS_RAD_SENSOR, CS_RAD_SENSOR,
ENABLE_RADFET,
PAPB_BUSY_N, PAPB_BUSY_N,
PAPB_EMPTY, PAPB_EMPTY,

View File

@ -7,8 +7,6 @@
#include <fsfw/serviceinterface/ServiceInterfaceStream.h> #include <fsfw/serviceinterface/ServiceInterfaceStream.h>
#include <fsfw/tasks/FixedTimeslotTaskIF.h> #include <fsfw/tasks/FixedTimeslotTaskIF.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;
} }
} }
@ -14,11 +15,13 @@ RadiationSensorHandler::~RadiationSensorHandler() {}
void RadiationSensorHandler::doStartUp() { void RadiationSensorHandler::doStartUp() {
if (internalState == InternalState::CONFIGURED) { if (internalState == InternalState::CONFIGURED) {
#if OBSW_SWITCH_TO_NORMAL_MODE_AFTER_STARTUP == 1 if (goToNormalMode) {
setMode(MODE_NORMAL); setMode(MODE_NORMAL);
#else }
setMode(_MODE_TO_ON);
#endif else {
setMode(_MODE_TO_ON);
}
} }
} }
@ -66,6 +69,14 @@ ReturnValue_t RadiationSensorHandler::buildCommandFromCommand(DeviceCommandId_t
return RETURN_OK; return RETURN_OK;
} }
case (RAD_SENSOR::START_CONVERSION): { case (RAD_SENSOR::START_CONVERSION): {
ReturnValue_t result = gpioIF->pullHigh(gpioIds::ENABLE_RADFET);
if (result != HasReturnvaluesIF::RETURN_OK) {
#if OBSW_VERBOSE_LEVEL >= 1
sif::warning << "RadiationSensorHandler::buildCommandFromCommand; Pulling RADFET Enale pin "
"high failed"
<< std::endl;
#endif
}
/* 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;
@ -80,14 +91,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;
} }
@ -109,6 +112,17 @@ 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: {
ReturnValue_t result = gpioIF->pullLow(gpioIds::ENABLE_RADFET);
if (result != HasReturnvaluesIF::RETURN_OK) {
#if OBSW_VERBOSE_LEVEL >= 1
sif::warning << "RadiationSensorHandler::buildCommandFromCommand; Pulling RADFET Enale pin "
"low failed"
<< std::endl;
#endif
}
break;
}
default: default:
break; break;
} }
@ -124,7 +138,8 @@ ReturnValue_t RadiationSensorHandler::interpretDeviceReply(DeviceCommandId_t id,
case RAD_SENSOR::READ_CONVERSIONS: { case RAD_SENSOR::READ_CONVERSIONS: {
uint8_t offset = 0; uint8_t offset = 0;
PoolReadGuard readSet(&dataset); PoolReadGuard readSet(&dataset);
dataset.temperatureCelcius = (*(packet + offset) << 8 | *(packet + offset + 1)) * 0.125; int16_t tempRaw = ((packet[offset] & 0x0f) << 8) | packet[offset + 1];
dataset.temperatureCelcius = tempRaw * 0.125;
offset += 2; offset += 2;
dataset.ain0 = (*(packet + offset) << 8 | *(packet + offset + 1)); dataset.ain0 = (*(packet + offset) << 8 | *(packet + offset + 1));
offset += 2; offset += 2;
@ -138,7 +153,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;
@ -158,8 +173,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;
} }
@ -175,3 +188,5 @@ ReturnValue_t RadiationSensorHandler::initializeLocalDataPool(localpool::DataPoo
localDataPoolMap.emplace(RAD_SENSOR::AIN7, new PoolEntry<uint16_t>({0})); localDataPoolMap.emplace(RAD_SENSOR::AIN7, new PoolEntry<uint16_t>({0}));
return HasReturnvaluesIF::RETURN_OK; return HasReturnvaluesIF::RETURN_OK;
} }
void RadiationSensorHandler::setToGoToNormalModeImmediately() { this->goToNormalMode = true; }

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,8 +16,10 @@
*/ */
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();
protected: protected:
void doStartUp() override; void doStartUp() override;
@ -28,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;
@ -39,9 +42,10 @@ 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;
uint8_t cmdBuffer[MAX_CMD_LEN]; uint8_t cmdBuffer[MAX_CMD_LEN];
InternalState internalState = InternalState::SETUP; InternalState internalState = InternalState::SETUP;
CommunicationStep communicationStep = CommunicationStep::START_CONVERSION; CommunicationStep communicationStep = CommunicationStep::START_CONVERSION;

View File

@ -214,7 +214,8 @@ void SusHandler::setToGoToNormalMode(bool enable) { this->goToNormalModeImmediat
void SusHandler::printDataset() { void SusHandler::printDataset() {
if (periodicPrintout) { if (periodicPrintout) {
if (divider.checkAndIncrement()) { if (divider.checkAndIncrement()) {
sif::info << "SUS ADC " << static_cast<int>(susIdx) << " hex [" << std::setfill('0') << std::hex; sif::info << "SUS ADC " << static_cast<int>(susIdx) << " hex [" << std::setfill('0')
<< std::hex;
for (uint8_t idx = 0; idx < 6; idx++) { for (uint8_t idx = 0; idx < 6; idx++) {
sif::info << std::setw(3) << dataset.channels[idx]; sif::info << std::setw(3) << dataset.channels[idx];
if (idx < 6 - 1) { if (idx < 6 - 1) {