rtd handler compiled

This commit is contained in:
2021-03-13 14:42:30 +01:00
parent b75eef7c51
commit e048d6d7ec
18 changed files with 431 additions and 70 deletions

View File

@ -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);