moved print set of temperature set and time set to dataset class

This commit is contained in:
Jakob Meier 2021-11-28 09:57:14 +01:00
parent 5ea129d252
commit b84bdcc0fc
3 changed files with 46 additions and 14 deletions

View File

@ -563,7 +563,10 @@ ReturnValue_t StarTrackerHandler::handlePingReply() {
ReturnValue_t StarTrackerHandler::handleTimeTm() { ReturnValue_t StarTrackerHandler::handleTimeTm() {
ReturnValue_t result = RETURN_OK; ReturnValue_t result = RETURN_OK;
PoolReadGuard rg(&timeSet); result = timeSet.read(TIMEOUT_TYPE, MUTEX_TIMEOUT);
if (result != RETURN_OK) {
return result;
}
uint32_t offset = TM_DATA_FIELD_OFFSET; uint32_t offset = TM_DATA_FIELD_OFFSET;
uint8_t status = 0; uint8_t status = 0;
uint32_t ticks = 0; uint32_t ticks = 0;
@ -580,15 +583,12 @@ ReturnValue_t StarTrackerHandler::handleTimeTm() {
timeSet.runTime = deserializeUint32(decodedFrame + offset); timeSet.runTime = deserializeUint32(decodedFrame + offset);
offset += sizeof(uint32_t); offset += sizeof(uint32_t);
timeSet.unixTime = deserializeUint64(decodedFrame + offset); timeSet.unixTime = deserializeUint64(decodedFrame + offset);
result = timeSet.commit(TIMEOUT_TYPE, MUTEX_TIMEOUT);
if (result != RETURN_OK) {
return result;
}
#if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_STARTRACKER == 1 #if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_STARTRACKER == 1
sif::info << "StarTrackerHandler::handleTimeTm: Ticks: " timeSet.printSet();
<< timeSet.ticks << std::endl;
sif::info << "StarTrackerHandler::handleTimeTm: Time (time stamp): "
<< timeSet.time << " us" << std::endl;
sif::info << "StarTrackerHandler::handleTimeTm: Run Time: "
<< timeSet.runTime << " ms" << std::endl;
sif::info << "StarTrackerHandler::handleTimeTm: Unix Time: "
<< timeSet.unixTime << " s" << std::endl;
#endif /* OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_STARTRACKER == 1 */ #endif /* OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_STARTRACKER == 1 */
return result; return result;
} }
@ -800,7 +800,7 @@ ReturnValue_t StarTrackerHandler::handlePowerTm() {
ReturnValue_t StarTrackerHandler::handleSolutionTm() { ReturnValue_t StarTrackerHandler::handleSolutionTm() {
ReturnValue_t result = RETURN_OK; ReturnValue_t result = RETURN_OK;
result = solutionSet.read(MutexIF::TimeoutType::WAITING, 20); result = solutionSet.read(TIMEOUT_TYPE, MUTEX_TIMEOUT);
if (result != RETURN_OK) { if (result != RETURN_OK) {
return result; return result;
} }
@ -810,7 +810,7 @@ ReturnValue_t StarTrackerHandler::handleSolutionTm() {
uint64_t time = 0; uint64_t time = 0;
getTmHeaderData(&status, &ticks, &time); getTmHeaderData(&status, &ticks, &time);
if(status != StarTracker::STATUS_OK) { if(status != StarTracker::STATUS_OK) {
sif::warning << "StarTrackerHandler::handleTemperatureTm: Reply error: " sif::warning << "StarTrackerHandler::handleSolutioneTm: Reply error: "
<< static_cast<unsigned int>(status) << std::endl; << static_cast<unsigned int>(status) << std::endl;
result = TEMPERATURE_REQ_FAILED; result = TEMPERATURE_REQ_FAILED;
return result; return result;
@ -873,7 +873,7 @@ ReturnValue_t StarTrackerHandler::handleSolutionTm() {
solutionSet.stableCount = *(decodedFrame + offset); solutionSet.stableCount = *(decodedFrame + offset);
offset += sizeof(uint32_t); offset += sizeof(uint32_t);
solutionSet.stableCount = *(decodedFrame + offset); solutionSet.stableCount = *(decodedFrame + offset);
result = solutionSet.commit(MutexIF::TimeoutType::WAITING, 20); result = solutionSet.commit(TIMEOUT_TYPE, MUTEX_TIMEOUT);
if (result != RETURN_OK) { if (result != RETURN_OK) {
return result; return result;
} }
@ -885,7 +885,6 @@ ReturnValue_t StarTrackerHandler::handleSolutionTm() {
ReturnValue_t StarTrackerHandler::handleTemperatureTm() { ReturnValue_t StarTrackerHandler::handleTemperatureTm() {
ReturnValue_t result = RETURN_OK; ReturnValue_t result = RETURN_OK;
PoolReadGuard rg(&temperatureSet);
uint32_t offset = TM_DATA_FIELD_OFFSET; uint32_t offset = TM_DATA_FIELD_OFFSET;
uint8_t status = 0; uint8_t status = 0;
uint32_t ticks = 0; uint32_t ticks = 0;
@ -897,6 +896,10 @@ ReturnValue_t StarTrackerHandler::handleTemperatureTm() {
result = TEMPERATURE_REQ_FAILED; result = TEMPERATURE_REQ_FAILED;
return result; return result;
} }
result = temperatureSet.read(TIMEOUT_TYPE, MUTEX_TIMEOUT);
if (result != RETURN_OK) {
return result;
}
temperatureSet.ticks= ticks; temperatureSet.ticks= ticks;
temperatureSet.time= time; temperatureSet.time= time;
float temperature = 0; float temperature = 0;
@ -905,8 +908,12 @@ ReturnValue_t StarTrackerHandler::handleTemperatureTm() {
offset += sizeof(temperature); offset += sizeof(temperature);
std::memcpy(&temperature, decodedFrame + offset, sizeof(temperature)); std::memcpy(&temperature, decodedFrame + offset, sizeof(temperature));
temperatureSet.cmosTemperature = temperature; temperatureSet.cmosTemperature = temperature;
result = temperatureSet.commit(TIMEOUT_TYPE, MUTEX_TIMEOUT);
if (result != RETURN_OK) {
return result;
}
#if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_STARTRACKER == 1 #if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_STARTRACKER == 1
solutionSet.printSet(); temperatureSet.printSet();
#endif #endif
return result; return result;
} }

View File

@ -90,6 +90,9 @@ private:
static const uint32_t PING_ID = 0x55; static const uint32_t PING_ID = 0x55;
static const uint32_t BOOT_REGION_ID = 1; static const uint32_t BOOT_REGION_ID = 1;
static const MutexIF::TimeoutType TIMEOUT_TYPE= MutexIF::TimeoutType::WAITING;
static const uint32_t MUTEX_TIMEOUT = 20;
StarTracker::TemperatureSet temperatureSet; StarTracker::TemperatureSet temperatureSet;
StarTracker::VersionSet versionSet; StarTracker::VersionSet versionSet;
StarTracker::PowerSet powerSet; StarTracker::PowerSet powerSet;

View File

@ -152,6 +152,17 @@ public:
PoolIds::MCU_TEMPERATURE, this); PoolIds::MCU_TEMPERATURE, this);
lp_var_t<float> cmosTemperature = lp_var_t<float>(sid.objectId, lp_var_t<float> cmosTemperature = lp_var_t<float>(sid.objectId,
PoolIds::CMOS_TEMPERATURE, this); PoolIds::CMOS_TEMPERATURE, this);
void printSet() {
sif::info << "TemperatureSet::printSet: Ticks: "
<< this->ticks << std::endl;
sif::info << "TemperatureSet::printSet: Time: "
<< this->time << " us" << std::endl;
sif::info << "TemperatureSet::printSet: MCU Temperature: "
<< this->mcuTemperature << " °C" << std::endl;
sif::info << "TemperatureSet::printSet: CMOS Temperature: "
<< this->mcuTemperature << " °C" << std::endl;
}
}; };
/** /**
@ -307,6 +318,17 @@ public:
// Unix time in seconds?? --> maybe typo in datasheet. Seems to be microseconds // Unix time in seconds?? --> maybe typo in datasheet. Seems to be microseconds
lp_var_t<uint64_t> unixTime = lp_var_t<uint64_t>(sid.objectId, lp_var_t<uint64_t> unixTime = lp_var_t<uint64_t>(sid.objectId,
PoolIds::UNIX_TIME, this); PoolIds::UNIX_TIME, this);
void printSet() {
PoolReadGuard rg(this);
sif::info << "TimeSet::printSet: Ticks: "
<< this->ticks << std::endl;
sif::info << "TimeSet::printSet: Time (time stamp): "
<< this->time << " us" << std::endl;
sif::info << "TimeSet::printSet: Run Time: "
<< this->runTime << " ms" << std::endl;
sif::info << "TimeSet::printSet: Unix Time: "
<< this->unixTime << " s" << std::endl;
}
}; };
/** /**