temperature reading successul, but i2c sometimes hanging up

This commit is contained in:
2021-01-11 16:56:44 +01:00
parent c73c41b03a
commit adef6eb188
167 changed files with 5938 additions and 20 deletions

View File

@ -1,5 +1,6 @@
#include <mission/devices/Tmp1075Handler.h>
#include <mission/devices/devicedefinitions/Tmp1075Definitions.h>
#include <fsfwconfig/OBSWConfig.h>
Tmp1075Handler::Tmp1075Handler(object_id_t objectId, object_id_t comIF,
CookieIF * comCookie) :
@ -16,7 +17,7 @@ Tmp1075Handler::~Tmp1075Handler() {
void Tmp1075Handler::doStartUp(){
if(mode == _MODE_START_UP){
setMode(MODE_NORMAL);
setMode(MODE_ON);
}
}
@ -94,7 +95,8 @@ ReturnValue_t Tmp1075Handler::interpretDeviceReply(DeviceCommandId_t id,
const uint8_t *packet) {
switch (id) {
case TMP1075::GET_TEMP: {
int16_t tempValueRaw = packet[1] << 8 | packet[0] >> 4;
int16_t tempValueRaw = 0;
tempValueRaw = packet[0] << 4 | packet[1] >> 4;
float tempValue = ((static_cast<float>(tempValueRaw)) * 0.0625);
#if OBSW_ENHANCED_PRINTOUT == 1
sif::info << "Tmp1075: Temperature: " << tempValue<< " °C" << std::endl;
@ -130,5 +132,13 @@ void Tmp1075Handler::prepareGetTempCommand(){
}
uint32_t Tmp1075Handler::getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo){
return 0;
return 500;
}
ReturnValue_t Tmp1075Handler::initializeLocalDataPool(
LocalDataPool &localDataPoolMap, LocalDataPoolManager &poolManager) {
localDataPoolMap.emplace(TMP1075::TEMPERATURE_C_TMP1075_1,
new PoolEntry<float>({0.0}));
return HasReturnvaluesIF::RETURN_OK;
}

View File

@ -36,6 +36,8 @@ protected:
const uint8_t *packet) override;
void setNormalDatapoolEntriesInvalid() override;
uint32_t getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) override;
ReturnValue_t initializeLocalDataPool(LocalDataPool &localDataPoolMap,
LocalDataPoolManager &poolManager) override;
private:

View File

@ -17,33 +17,29 @@ namespace TMP1075 {
static const uint8_t CFGR_CMD_SIZE = 3;
static const uint8_t POINTER_REG_SIZE = 1;
static const lp_id_t TEMPERATURE_C = GET_TEMP;
static const uint32_t DATA_SET_ID = 0x0;
static const uint32_t TMP1075_DATA_SET_ID = GET_TEMP;
static const uint8_t MAX_REPLY_LENGTH = GET_TEMP_REPLY_SIZE;
enum Tmp1075PoolIds: lp_id_t {
TEMPERATURE_C_TMP1075_1,
TEMPERATURE_C_TMP1075_2
};
class Tmp1075Dataset:
public StaticLocalDataSet<sizeof(float)> {
public:
/**
* Constructor used by owner and data creators like device handlers.
* @param owner
* @param setId
*/
Tmp1075Dataset(HasLocalDataPoolIF* owner):
StaticLocalDataSet(owner, DATA_SET_ID) {
StaticLocalDataSet(owner, TMP1075_DATA_SET_ID) {
}
/**
* Constructor used by data users like controllers.
* @param sid
*/
Tmp1075Dataset(object_id_t objectId):
StaticLocalDataSet(sid_t(objectId, DATA_SET_ID)) {
StaticLocalDataSet(sid_t(objectId, TMP1075_DATA_SET_ID)) {
}
lp_var_t<float> temperatureCelcius = lp_var_t<float>(sid.objectId,
TEMPERATURE_C, this);
TEMPERATURE_C_TMP1075_1, this);
};
}