Merge branch 'mueller/master' of https://egit.irs.uni-stuttgart.de/eive/eive-obsw into mueller/master
Some checks failed
EIVE/eive-obsw/pipeline/pr-develop There was a failure building this commit
EIVE/eive-obsw/pipeline/head There was a failure building this commit

This commit is contained in:
2022-02-18 15:00:35 +01:00
16 changed files with 691 additions and 314 deletions

View File

@ -69,7 +69,7 @@ void ObjectFactory::produceGenericObjects() {
objects::CCSDS_PACKET_DISTRIBUTOR);
// Every TM packet goes through this funnel
new TmFunnel(objects::TM_FUNNEL);
new TmFunnel(objects::TM_FUNNEL, 50);
// PUS service stack
new Service1TelecommandVerification(objects::PUS_SERVICE_1_VERIFICATION, apid::EIVE_OBSW,
@ -79,7 +79,7 @@ void ObjectFactory::produceGenericObjects() {
new Service3Housekeeping(objects::PUS_SERVICE_3_HOUSEKEEPING, apid::EIVE_OBSW,
pus::PUS_SERVICE_3);
new Service5EventReporting(objects::PUS_SERVICE_5_EVENT_REPORTING, apid::EIVE_OBSW,
pus::PUS_SERVICE_5, 50);
pus::PUS_SERVICE_5, 120);
new Service8FunctionManagement(objects::PUS_SERVICE_8_FUNCTION_MGMT, apid::EIVE_OBSW,
pus::PUS_SERVICE_8, 3, 60);
new Service9TimeManagement(objects::PUS_SERVICE_9_TIME_MGMT, apid::EIVE_OBSW, pus::PUS_SERVICE_9);

View File

@ -14,11 +14,13 @@ RadiationSensorHandler::~RadiationSensorHandler() {}
void RadiationSensorHandler::doStartUp() {
if (internalState == InternalState::CONFIGURED) {
#if OBSW_SWITCH_TO_NORMAL_MODE_AFTER_STARTUP == 1
setMode(MODE_NORMAL);
#else
setMode(_MODE_TO_ON);
#endif
if (goToNormalMode) {
setMode(MODE_NORMAL);
}
else {
setMode(_MODE_TO_ON);
}
}
}
@ -124,7 +126,8 @@ ReturnValue_t RadiationSensorHandler::interpretDeviceReply(DeviceCommandId_t id,
case RAD_SENSOR::READ_CONVERSIONS: {
uint8_t offset = 0;
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;
dataset.ain0 = (*(packet + offset) << 8 | *(packet + offset + 1));
offset += 2;
@ -175,3 +178,5 @@ ReturnValue_t RadiationSensorHandler::initializeLocalDataPool(localpool::DataPoo
localDataPoolMap.emplace(RAD_SENSOR::AIN7, new PoolEntry<uint16_t>({0}));
return HasReturnvaluesIF::RETURN_OK;
}
void RadiationSensorHandler::setToGoToNormalModeImmediately() { this->goToNormalMode = true; }

View File

@ -16,6 +16,7 @@ class RadiationSensorHandler : public DeviceHandlerBase {
public:
RadiationSensorHandler(object_id_t objectId, object_id_t comIF, CookieIF *comCookie);
virtual ~RadiationSensorHandler();
void setToGoToNormalModeImmediately();
protected:
void doStartUp() override;
@ -42,6 +43,7 @@ class RadiationSensorHandler : public DeviceHandlerBase {
static const uint8_t MAX_CMD_LEN = RAD_SENSOR::READ_SIZE;
bool goToNormalMode = false;
uint8_t cmdBuffer[MAX_CMD_LEN];
InternalState internalState = InternalState::SETUP;
CommunicationStep communicationStep = CommunicationStep::START_CONVERSION;

View File

@ -1,5 +1,7 @@
#include "max1227.h"
#include <cstring>
uint8_t max1227::buildConvByte(ScanModes scanMode, uint8_t channel, bool readTemp) {
return (1 << 7) | (channel << 3) | (scanMode << 1) | readTemp;
}
@ -7,3 +9,30 @@ uint8_t max1227::buildConvByte(ScanModes scanMode, uint8_t channel, bool readTem
uint8_t max1227::buildSetupByte(ClkSel clkSel, RefSel refSel, DiffSel diffSel) {
return (1 << 6) | (clkSel << 4) | (refSel << 2) | diffSel;
}
void max1227::prepareExternallyClockedSingleChannelRead(uint8_t *spiBuf, uint8_t channel,
size_t &sz) {
spiBuf[0] = buildConvByte(ScanModes::N_ONCE, channel, false);
spiBuf[1] = 0x00;
spiBuf[2] = 0x00;
sz = 3;
}
uint8_t max1227::buildResetByte(bool fifoOnly) { return (1 << 4) | (fifoOnly << 3); }
void max1227::prepareExternallyClockedRead0ToN(uint8_t *spiBuf, uint8_t n, size_t &sz) {
for (uint8_t idx = 0; idx <= n; idx++) {
spiBuf[idx * 2] = buildConvByte(ScanModes::N_ONCE, idx, false);
spiBuf[idx * 2 + 1] = 0x00;
}
spiBuf[(n + 1) * 2] = 0x00;
sz = (n + 1) * 2 + 1;
}
void max1227::prepareExternallyClockedTemperatureRead(uint8_t *spiBuf, size_t &sz) {
spiBuf[0] = buildConvByte(ScanModes::N_ONCE, 0, true);
std::memset(spiBuf + 1, 0, 24);
sz = 25;
}
float max1227::getTemperature(int16_t temp) { return static_cast<float>(temp) * 0.125; }

View File

@ -1,6 +1,7 @@
#ifndef MISSION_DEVICES_MAX1227_H_
#define MISSION_DEVICES_MAX1227_H_
#include <cstddef>
#include <cstdint>
namespace max1227 {
@ -38,9 +39,40 @@ enum DiffSel : uint8_t {
// One bipolar config byte follows the setup byte
BIPOLAR_CFG = 0b11
};
uint8_t buildResetByte(bool fifoOnly);
uint8_t buildConvByte(ScanModes scanMode, uint8_t channel, bool readTemp);
uint8_t buildSetupByte(ClkSel clkSel, RefSel refSel, DiffSel diffSel);
/**
* If there is a wakeup delay, there needs to be a 65 us delay between sending
* the first byte (conversion byte) and the the rest of the SPI buffer.
* The raw ADC value will be located in the first and second reply byte.
* @param spiBuf
* @param n
* @param sz
*/
void prepareExternallyClockedSingleChannelRead(uint8_t* spiBuf, uint8_t channel, size_t& sz);
/**
* If there is a wakeup delay, there needs to be a 65 us delay between sending
* the first byte (first conversion byte) the the rest of the SPI buffer.
* @param spiBuf
* @param n Channel number. Example: If the ADC has 6 channels, n will be 5
* @param sz
*/
void prepareExternallyClockedRead0ToN(uint8_t* spiBuf, uint8_t n, size_t& sz);
/**
* Prepare an externally clocked temperature read. 25 bytes have to be sent
* and the raw temperature value will appear on the last 2 bytes of the reply.
* @param spiBuf
* @param sz
*/
void prepareExternallyClockedTemperatureRead(uint8_t* spiBuf, size_t& sz);
float getTemperature(int16_t temp);
} // namespace max1227
#endif /* MISSION_DEVICES_MAX1227_H_ */