RTD update and TCP server in hosted build #65

Merged
meierj merged 12 commits from mueller/staging-rtd-update-hosted-tcp into develop 2021-07-29 09:07:50 +02:00
2 changed files with 12 additions and 20 deletions
Showing only changes of commit 5018b24cfc - Show all commits

View File

@ -1,5 +1,7 @@
#include "Max31865PT1000Handler.h" #include "Max31865PT1000Handler.h"
#include "fsfw/datapool/PoolReadGuard.h"
#include <bitset> #include <bitset>
#include <cmath> #include <cmath>
@ -360,7 +362,6 @@ ReturnValue_t Max31865PT1000Handler::interpretDeviceReply(
// do something with rtd value, will propably be stored in // do something with rtd value, will propably be stored in
// dataset. // dataset.
float rtdValue = adcCode * RTD_RREF_PT1000 / INT16_MAX; float rtdValue = adcCode * RTD_RREF_PT1000 / INT16_MAX;
// calculate approximation // calculate approximation
float approxTemp = adcCode / 32.0 - 256.0; float approxTemp = adcCode / 32.0 - 256.0;
@ -369,7 +370,7 @@ ReturnValue_t Max31865PT1000Handler::interpretDeviceReply(
#if FSFW_CPP_OSTREAM_ENABLED == 1 #if FSFW_CPP_OSTREAM_ENABLED == 1
sif::info << "Max31865PT1000Handler::interpretDeviceReply: Measured " sif::info << "Max31865PT1000Handler::interpretDeviceReply: Measured "
<< "resistance is " << rtdValue << " Ohms." << std::endl; << "resistance is " << rtdValue << " Ohms." << std::endl;
sif::info << "Approximated temperature is " << approxTemp << " °C" sif::info << "Approximated temperature is " << approxTemp << " C"
<< std::endl; << std::endl;
#else #else
sif::printInfo("Max31865PT1000Handler::interpretDeviceReply: Measured resistance is %f" sif::printInfo("Max31865PT1000Handler::interpretDeviceReply: Measured resistance is %f"
@ -380,8 +381,8 @@ ReturnValue_t Max31865PT1000Handler::interpretDeviceReply(
} }
#endif #endif
ReturnValue_t result = sensorDataset.read(); PoolReadGuard pg(&sensorDataset);
if(result != HasReturnvaluesIF::RETURN_OK) { if(pg.getReadResult() != HasReturnvaluesIF::RETURN_OK) {
// Configuration error // Configuration error
#if FSFW_CPP_OSTREAM_ENABLED == 1 #if FSFW_CPP_OSTREAM_ENABLED == 1
sif::debug << "Max31865PT1000Handler::interpretDeviceReply: Error reading dataset!" sif::debug << "Max31865PT1000Handler::interpretDeviceReply: Error reading dataset!"
@ -389,29 +390,17 @@ ReturnValue_t Max31865PT1000Handler::interpretDeviceReply(
#else #else
sif::printDebug("Max31865PT1000Handler::interpretDeviceReply: Error reading dataset!\n"); sif::printDebug("Max31865PT1000Handler::interpretDeviceReply: Error reading dataset!\n");
#endif #endif
return result; return pg.getReadResult();
} }
if(not sensorDataset.isValid()) { if(not sensorDataset.isValid()) {
sensorDataset.setValidity(true, false);
sensorDataset.rtdValue.setValid(true);
sensorDataset.temperatureCelcius.setValid(true); sensorDataset.temperatureCelcius.setValid(true);
} }
sensorDataset.rtdValue = rtdValue;
sensorDataset.temperatureCelcius = approxTemp; sensorDataset.temperatureCelcius = approxTemp;
result = sensorDataset.commit();
if(result != HasReturnvaluesIF::RETURN_OK) {
// Configuration error
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::debug << "Max31865PT1000Handler::interpretDeviceReply: "
"Error commiting dataset!" << std::endl;
#else
sif::printDebug("Max31865PT1000Handler::interpretDeviceReply: "
"Error commiting dataset!\n");
#endif
return result;
}
break; break;
} }
case(Max31865Definitions::REQUEST_FAULT_BYTE): { case(Max31865Definitions::REQUEST_FAULT_BYTE): {

View File

@ -9,6 +9,7 @@
namespace Max31865Definitions { namespace Max31865Definitions {
enum PoolIds: lp_id_t { enum PoolIds: lp_id_t {
RTD_VALUE,
TEMPERATURE_C, TEMPERATURE_C,
FAULT_BYTE FAULT_BYTE
}; };
@ -46,6 +47,8 @@ public:
StaticLocalDataSet(sid_t(objectId, MAX31865_SET_ID)) { StaticLocalDataSet(sid_t(objectId, MAX31865_SET_ID)) {
} }
lp_var_t<float> rtdValue = lp_var_t<float>(sid.objectId,
PoolIds::RTD_VALUE, this);
lp_var_t<float> temperatureCelcius = lp_var_t<float>(sid.objectId, lp_var_t<float> temperatureCelcius = lp_var_t<float>(sid.objectId,
PoolIds::TEMPERATURE_C, this); PoolIds::TEMPERATURE_C, this);
lp_var_t<uint8_t> errorByte = lp_var_t<uint8_t>(sid.objectId, lp_var_t<uint8_t> errorByte = lp_var_t<uint8_t>(sid.objectId,