rtd handler compiled
This commit is contained in:
@ -11,6 +11,7 @@ target_sources(${TARGET_NAME} PUBLIC
|
||||
PDU2Handler.cpp
|
||||
ACUHandler.cpp
|
||||
SyrlinksHkHandler.cpp
|
||||
Max31865PT1000Handler.cpp
|
||||
)
|
||||
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
#include "Max31865PT1000Handler.h"
|
||||
|
||||
#include <bitset>
|
||||
#include <cmath>
|
||||
#include "Max31865PT100Handler.h"
|
||||
|
||||
Max31865PT1000Handler::Max31865PT1000Handler(object_id_t objectId,
|
||||
object_id_t comIF, CookieIF *comCookie, uint8_t switchId):
|
||||
@ -53,11 +54,11 @@ void Max31865PT1000Handler::doShutDown() {
|
||||
ReturnValue_t Max31865PT1000Handler::buildNormalDeviceCommand(
|
||||
DeviceCommandId_t *id) {
|
||||
if(internalState == InternalState::RUNNING) {
|
||||
*id = TSensorDefinitions::REQUEST_RTD;
|
||||
*id = Max31865Definitions::REQUEST_RTD;
|
||||
return buildCommandFromCommand(*id, nullptr, 0);
|
||||
}
|
||||
else if(internalState == InternalState::REQUEST_FAULT_BYTE) {
|
||||
*id = TSensorDefinitions::REQUEST_FAULT_BYTE;
|
||||
*id = Max31865Definitions::REQUEST_FAULT_BYTE;
|
||||
return buildCommandFromCommand(*id, nullptr, 0);
|
||||
}
|
||||
else {
|
||||
@ -73,12 +74,12 @@ ReturnValue_t Max31865PT1000Handler::buildTransitionDeviceCommand(
|
||||
case(InternalState::RUNNING):
|
||||
return DeviceHandlerBase::NOTHING_TO_SEND;
|
||||
case(InternalState::CONFIGURE): {
|
||||
*id = TSensorDefinitions::CONFIG_CMD;
|
||||
*id = Max31865Definitions::CONFIG_CMD;
|
||||
uint8_t config[1] = {DEFAULT_CONFIG};
|
||||
return buildCommandFromCommand(*id, config, 1);
|
||||
}
|
||||
case(InternalState::REQUEST_CONFIG): {
|
||||
*id = TSensorDefinitions::REQUEST_CONFIG;
|
||||
*id = Max31865Definitions::REQUEST_CONFIG;
|
||||
return buildCommandFromCommand(*id, nullptr, 0);
|
||||
}
|
||||
|
||||
@ -96,8 +97,8 @@ ReturnValue_t Max31865PT1000Handler::buildCommandFromCommand(
|
||||
DeviceCommandId_t deviceCommand, const uint8_t *commandData,
|
||||
size_t commandDataLen) {
|
||||
switch(deviceCommand) {
|
||||
case(TSensorDefinitions::CONFIG_CMD) : {
|
||||
commandBuffer[0] = static_cast<uint8_t>(TSensorDefinitions::CONFIG_CMD);
|
||||
case(Max31865Definitions::CONFIG_CMD) : {
|
||||
commandBuffer[0] = static_cast<uint8_t>(Max31865Definitions::CONFIG_CMD);
|
||||
if(commandDataLen == 1) {
|
||||
commandBuffer[1] = commandData[0];
|
||||
DeviceHandlerBase::rawPacketLen = 2;
|
||||
@ -108,17 +109,17 @@ ReturnValue_t Max31865PT1000Handler::buildCommandFromCommand(
|
||||
return DeviceHandlerIF::NO_COMMAND_DATA;
|
||||
}
|
||||
}
|
||||
case(TSensorDefinitions::REQUEST_CONFIG): {
|
||||
case(Max31865Definitions::REQUEST_CONFIG): {
|
||||
commandBuffer[0] = 0x00; // dummy byte
|
||||
commandBuffer[1] = static_cast<uint8_t>(
|
||||
TSensorDefinitions::REQUEST_CONFIG);
|
||||
Max31865Definitions::REQUEST_CONFIG);
|
||||
DeviceHandlerBase::rawPacketLen = 2;
|
||||
DeviceHandlerBase::rawPacket = commandBuffer.data();
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
case(TSensorDefinitions::REQUEST_RTD): {
|
||||
case(Max31865Definitions::REQUEST_RTD): {
|
||||
commandBuffer[0] = static_cast<uint8_t>(
|
||||
TSensorDefinitions::REQUEST_RTD);
|
||||
Max31865Definitions::REQUEST_RTD);
|
||||
// two dummy bytes
|
||||
commandBuffer[1] = 0x00;
|
||||
commandBuffer[2] = 0x00;
|
||||
@ -126,9 +127,9 @@ ReturnValue_t Max31865PT1000Handler::buildCommandFromCommand(
|
||||
DeviceHandlerBase::rawPacket = commandBuffer.data();
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
case(TSensorDefinitions::REQUEST_FAULT_BYTE): {
|
||||
case(Max31865Definitions::REQUEST_FAULT_BYTE): {
|
||||
commandBuffer[0] = static_cast<uint8_t>(
|
||||
TSensorDefinitions::REQUEST_FAULT_BYTE);
|
||||
Max31865Definitions::REQUEST_FAULT_BYTE);
|
||||
commandBuffer[1] = 0x00;
|
||||
DeviceHandlerBase::rawPacketLen = 2;
|
||||
DeviceHandlerBase::rawPacket = commandBuffer.data();
|
||||
@ -141,11 +142,11 @@ ReturnValue_t Max31865PT1000Handler::buildCommandFromCommand(
|
||||
}
|
||||
|
||||
void Max31865PT1000Handler::fillCommandAndReplyMap() {
|
||||
insertInCommandAndReplyMap(TSensorDefinitions::CONFIG_CMD, 3);
|
||||
insertInCommandAndReplyMap(TSensorDefinitions::REQUEST_CONFIG, 3);
|
||||
insertInCommandAndReplyMap(TSensorDefinitions::REQUEST_RTD, 3,
|
||||
insertInCommandAndReplyMap(Max31865Definitions::CONFIG_CMD, 3);
|
||||
insertInCommandAndReplyMap(Max31865Definitions::REQUEST_CONFIG, 3);
|
||||
insertInCommandAndReplyMap(Max31865Definitions::REQUEST_RTD, 3,
|
||||
&sensorDataset);
|
||||
insertInCommandAndReplyMap(TSensorDefinitions::REQUEST_FAULT_BYTE, 3);
|
||||
insertInCommandAndReplyMap(Max31865Definitions::REQUEST_FAULT_BYTE, 3);
|
||||
}
|
||||
|
||||
ReturnValue_t Max31865PT1000Handler::scanForReply(const uint8_t *start,
|
||||
@ -155,7 +156,7 @@ ReturnValue_t Max31865PT1000Handler::scanForReply(const uint8_t *start,
|
||||
|
||||
if(remainingSize == rtdReplySize and
|
||||
internalState == InternalState::RUNNING) {
|
||||
*foundId = TSensorDefinitions::REQUEST_RTD;
|
||||
*foundId = Max31865Definitions::REQUEST_RTD;
|
||||
*foundLen = rtdReplySize;
|
||||
}
|
||||
|
||||
@ -163,15 +164,15 @@ ReturnValue_t Max31865PT1000Handler::scanForReply(const uint8_t *start,
|
||||
if(internalState == InternalState::CONFIGURE) {
|
||||
commandExecuted = true;
|
||||
*foundLen = configReplySize;
|
||||
*foundId = TSensorDefinitions::CONFIG_CMD;
|
||||
*foundId = Max31865Definitions::CONFIG_CMD;
|
||||
}
|
||||
else if(internalState == InternalState::REQUEST_FAULT_BYTE) {
|
||||
*foundId = TSensorDefinitions::REQUEST_FAULT_BYTE;
|
||||
*foundId = Max31865Definitions::REQUEST_FAULT_BYTE;
|
||||
*foundLen = 2;
|
||||
internalState = InternalState::RUNNING;
|
||||
}
|
||||
else {
|
||||
*foundId = TSensorDefinitions::REQUEST_CONFIG;
|
||||
*foundId = Max31865Definitions::REQUEST_CONFIG;
|
||||
*foundLen = configReplySize;
|
||||
}
|
||||
}
|
||||
@ -182,7 +183,7 @@ ReturnValue_t Max31865PT1000Handler::scanForReply(const uint8_t *start,
|
||||
ReturnValue_t Max31865PT1000Handler::interpretDeviceReply(
|
||||
DeviceCommandId_t id, const uint8_t *packet) {
|
||||
switch(id) {
|
||||
case(TSensorDefinitions::REQUEST_CONFIG): {
|
||||
case(Max31865Definitions::REQUEST_CONFIG): {
|
||||
if(packet[1] != DEFAULT_CONFIG) {
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
// it propably would be better if we at least try one restart..
|
||||
@ -202,7 +203,7 @@ ReturnValue_t Max31865PT1000Handler::interpretDeviceReply(
|
||||
}
|
||||
break;
|
||||
}
|
||||
case(TSensorDefinitions::REQUEST_RTD): {
|
||||
case(Max31865Definitions::REQUEST_RTD): {
|
||||
// first bit of LSB reply byte is the fault bit
|
||||
uint8_t faultBit = packet[2] & 0b0000'0001;
|
||||
if(faultBit == 1) {
|
||||
@ -272,7 +273,7 @@ ReturnValue_t Max31865PT1000Handler::interpretDeviceReply(
|
||||
|
||||
break;
|
||||
}
|
||||
case(TSensorDefinitions::REQUEST_FAULT_BYTE): {
|
||||
case(Max31865Definitions::REQUEST_FAULT_BYTE): {
|
||||
faultByte = packet[1];
|
||||
#if OBSW_VERBOSE_LEVEL >= 1
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
@ -343,9 +344,9 @@ void Max31865PT1000Handler::doTransition(Mode_t modeFrom,
|
||||
|
||||
ReturnValue_t Max31865PT1000Handler::initializeLocalDataPool(localpool::DataPool& localDataPoolMap,
|
||||
LocalDataPoolManager& poolManager) {
|
||||
localDataPoolMap.emplace(TSensorDefinitions::PoolIds::TEMPERATURE_C,
|
||||
localDataPoolMap.emplace(Max31865Definitions::PoolIds::TEMPERATURE_C,
|
||||
new PoolEntry<float>({0}, 1, true));
|
||||
localDataPoolMap.emplace(TSensorDefinitions::PoolIds::FAULT_BYTE,
|
||||
localDataPoolMap.emplace(Max31865Definitions::PoolIds::FAULT_BYTE,
|
||||
new PoolEntry<uint8_t>({0}));
|
||||
poolManager.subscribeForPeriodicPacket(sensorDatasetSid,
|
||||
false, 4.0, false);
|
||||
|
@ -1,7 +1,6 @@
|
||||
#ifndef MISSION_DEVICES_MAX31865PT100HANDLER_H_
|
||||
#define MISSION_DEVICES_MAX31865PT100HANDLER_H_
|
||||
#ifndef MISSION_DEVICES_MAX31865PT1000HANDLER_H_
|
||||
#define MISSION_DEVICES_MAX31865PT1000HANDLER_H_
|
||||
|
||||
#include "devicedefinitions/ThermalSensorPacket.h"
|
||||
#include <OBSWConfig.h>
|
||||
|
||||
#include <fsfw/devicehandlers/DeviceHandlerBase.h>
|
||||
@ -9,6 +8,7 @@
|
||||
|
||||
#include <array>
|
||||
#include <cstdint>
|
||||
#include "devicedefinitions/Max31865Definitions.h"
|
||||
|
||||
/**
|
||||
* @brief Device Handler for the thermal sensors
|
||||
@ -92,7 +92,7 @@ private:
|
||||
uint8_t faultByte = 0;
|
||||
std::array<uint8_t, 3> commandBuffer { 0 };
|
||||
|
||||
TSensorDefinitions::ThermalSensorDataset sensorDataset;
|
||||
Max31865Definitions::Max31865Set sensorDataset;
|
||||
sid_t sensorDatasetSid;
|
||||
|
||||
#if OBSW_VERBOSE_LEVEL >= 1
|
||||
@ -100,5 +100,5 @@ private:
|
||||
#endif
|
||||
};
|
||||
|
||||
#endif /* MISSION_DEVICES_MAX31865PT100HANDLER_H_ */
|
||||
#endif /* MISSION_DEVICES_MAX31865PT1000HANDLER_H_ */
|
||||
|
@ -6,15 +6,7 @@
|
||||
#include <fsfw/devicehandlers/DeviceHandlerIF.h>
|
||||
#include <fsfwconfig/objects/systemObjectList.h>
|
||||
|
||||
namespace TSensorDefinitions {
|
||||
|
||||
enum ObjIds: object_id_t {
|
||||
TEST_HKB_HANDLER = objects::SPI_Test_PT1000,
|
||||
SYRLINKS_HANDLER = objects::PT1000_Syrlinks_DEC1_O1,
|
||||
MGT_1_HANDLER = objects::PT1000_MGT1_DEC2,
|
||||
PLOC_HANDLER = objects::PT1000_PLOC_DEC4,
|
||||
MESHCAM_HANDLER = objects::PT1000_Camera_DEC1_O2
|
||||
};
|
||||
namespace Max31865Definitions {
|
||||
|
||||
enum PoolIds: lp_id_t {
|
||||
TEMPERATURE_C,
|
||||
@ -26,9 +18,11 @@ static constexpr DeviceCommandId_t REQUEST_CONFIG = 0x00;
|
||||
static constexpr DeviceCommandId_t REQUEST_RTD = 0x01;
|
||||
static constexpr DeviceCommandId_t REQUEST_FAULT_BYTE = 0x07;
|
||||
|
||||
static constexpr uint32_t THERMAL_SENSOR_SET_ID = REQUEST_RTD;
|
||||
static constexpr uint32_t MAX31865_SET_ID = REQUEST_RTD;
|
||||
|
||||
class ThermalSensorDataset:
|
||||
static constexpr size_t MAX_REPLY_SIZE = 5;
|
||||
|
||||
class Max31865Set:
|
||||
public StaticLocalDataSet<sizeof(float) + sizeof(uint8_t)> {
|
||||
public:
|
||||
/**
|
||||
@ -36,16 +30,16 @@ public:
|
||||
* @param owner
|
||||
* @param setId
|
||||
*/
|
||||
ThermalSensorDataset(HasLocalDataPoolIF* owner):
|
||||
StaticLocalDataSet(owner, THERMAL_SENSOR_SET_ID) {
|
||||
Max31865Set(HasLocalDataPoolIF* owner):
|
||||
StaticLocalDataSet(owner, MAX31865_SET_ID) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor used by data users like controllers.
|
||||
* @param sid
|
||||
*/
|
||||
ThermalSensorDataset(object_id_t objectId):
|
||||
StaticLocalDataSet(sid_t(objectId, THERMAL_SENSOR_SET_ID)) {
|
||||
Max31865Set(object_id_t objectId):
|
||||
StaticLocalDataSet(sid_t(objectId, MAX31865_SET_ID)) {
|
||||
}
|
||||
|
||||
lp_var_t<float> temperatureCelcius = lp_var_t<float>(sid.objectId,
|
Reference in New Issue
Block a user