merged develop
This commit is contained in:
@ -3,19 +3,24 @@
|
||||
#include "OBSWConfig.h"
|
||||
#include "fsfw/datapool/PoolReadGuard.h"
|
||||
#include "fsfw/timemanager/Clock.h"
|
||||
#include "linux/utility/utility.h"
|
||||
#include "mission/utility/compileTime.h"
|
||||
|
||||
#if FSFW_DEV_HYPERION_GPS_CREATE_NMEA_CSV == 1
|
||||
#include <filesystem>
|
||||
#include <fstream>
|
||||
#endif
|
||||
#include <cmath>
|
||||
#include <ctime>
|
||||
|
||||
GPSHyperionLinuxController::GPSHyperionLinuxController(object_id_t objectId, object_id_t parentId,
|
||||
bool debugHyperionGps)
|
||||
: ExtendedControllerBase(objectId, objects::NO_OBJECT),
|
||||
gpsSet(this),
|
||||
myGpsmm(GPSD_SHARED_MEMORY, nullptr),
|
||||
debugHyperionGps(debugHyperionGps) {}
|
||||
debugHyperionGps(debugHyperionGps) {
|
||||
timeUpdateCd.resetTimer();
|
||||
}
|
||||
|
||||
GPSHyperionLinuxController::~GPSHyperionLinuxController() {}
|
||||
|
||||
@ -76,9 +81,7 @@ ReturnValue_t GPSHyperionLinuxController::initializeLocalDataPool(
|
||||
localDataPoolMap.emplace(GpsHyperion::SATS_IN_USE, new PoolEntry<uint8_t>());
|
||||
localDataPoolMap.emplace(GpsHyperion::SATS_IN_VIEW, new PoolEntry<uint8_t>());
|
||||
localDataPoolMap.emplace(GpsHyperion::FIX_MODE, new PoolEntry<uint8_t>());
|
||||
#if OBSW_ENABLE_PERIODIC_HK == 1
|
||||
poolManager.subscribeForPeriodicPacket(gpsSet.getSid(), true, 2.0, false);
|
||||
#endif
|
||||
poolManager.subscribeForPeriodicPacket(gpsSet.getSid(), false, 30.0, false);
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
||||
@ -124,8 +127,17 @@ void GPSHyperionLinuxController::readGpsDataFromGpsd() {
|
||||
return;
|
||||
}
|
||||
|
||||
bool validFix = false;
|
||||
static_cast<void>(validFix);
|
||||
// 0: Not seen, 1: No fix, 2: 2D-Fix, 3: 3D-Fix
|
||||
gpsSet.fixMode.value = gps->fix.mode;
|
||||
int newFixMode = gps->fix.mode;
|
||||
if (newFixMode == 2 or newFixMode == 3) {
|
||||
validFix = true;
|
||||
}
|
||||
if (gpsSet.fixMode.value != newFixMode) {
|
||||
triggerEvent(GpsHyperion::GPS_FIX_CHANGE, gpsSet.fixMode.value, newFixMode);
|
||||
}
|
||||
gpsSet.fixMode.value = newFixMode;
|
||||
if (gps->fix.mode == 0 or gps->fix.mode == 1) {
|
||||
if (modeCommanded and maxTimeToReachFix.hasTimedOut()) {
|
||||
// We are supposed to be on and functioning, but not fix was found
|
||||
@ -172,6 +184,34 @@ void GPSHyperionLinuxController::readGpsDataFromGpsd() {
|
||||
timeval time = {};
|
||||
time.tv_sec = gpsSet.unixSeconds.value;
|
||||
time.tv_usec = gps->fix.time.tv_nsec / 1000;
|
||||
std::time_t t = std::time(nullptr);
|
||||
if (time.tv_sec == t) {
|
||||
timeIsConstantCounter++;
|
||||
} else {
|
||||
timeIsConstantCounter = 0;
|
||||
}
|
||||
if (timeInit and validFix) {
|
||||
if (not utility::timeSanityCheck()) {
|
||||
#if OBSW_VERBOSE_LEVEL >= 1
|
||||
time_t timeRaw = time.tv_sec;
|
||||
std::tm *timeTm = std::gmtime(&timeRaw);
|
||||
sif::info << "Setting invalid system time from GPS data directly: "
|
||||
<< std::put_time(timeTm, "%c %Z") << std::endl;
|
||||
#endif
|
||||
// For some reason, the clock needs to be somewhat correct for NTP to work. Really dumb..
|
||||
Clock::setClock(&time);
|
||||
}
|
||||
timeInit = false;
|
||||
}
|
||||
// If the received time does not change anymore for whatever reason, do not set it here
|
||||
// to avoid stale times. Also, don't do it too often often to avoid jumping times
|
||||
if (timeIsConstantCounter < 20 and timeUpdateCd.hasTimedOut()) {
|
||||
// Update the system time here for now. NTP seems to be unable to do so for whatever reason.
|
||||
// Further tests have shown that the time seems to be set by NTPD after some time..
|
||||
// Clock::setClock(&time);
|
||||
timeUpdateCd.resetTimer();
|
||||
}
|
||||
|
||||
Clock::TimeOfDay_t timeOfDay = {};
|
||||
Clock::convertTimevalToTimeOfDay(&time, &timeOfDay);
|
||||
gpsSet.year = timeOfDay.year;
|
||||
@ -192,6 +232,9 @@ void GPSHyperionLinuxController::readGpsDataFromGpsd() {
|
||||
std::cout << "Longitude: " << gps->fix.longitude << std::endl;
|
||||
std::cout << "Altitude(MSL): " << gps->fix.altMSL << std::endl;
|
||||
std::cout << "Speed(m/s): " << gps->fix.speed << std::endl;
|
||||
std::time_t t = std::time(nullptr);
|
||||
std::tm tm = *std::gmtime(&t);
|
||||
std::cout << "C Time: " << std::put_time(&tm, "%c") << std::endl;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
@ -1,6 +1,7 @@
|
||||
#ifndef MISSION_DEVICES_GPSHYPERIONHANDLER_H_
|
||||
#define MISSION_DEVICES_GPSHYPERIONHANDLER_H_
|
||||
|
||||
#include "commonSubsystemIds.h"
|
||||
#include "fsfw/FSFW.h"
|
||||
#include "fsfw/controller/ExtendedControllerBase.h"
|
||||
#include "fsfw/devicehandlers/DeviceHandlerBase.h"
|
||||
@ -22,6 +23,7 @@
|
||||
class GPSHyperionLinuxController : public ExtendedControllerBase {
|
||||
public:
|
||||
static constexpr uint32_t MAX_SECONDS_TO_REACH_FIX = 60 * 60 * 5;
|
||||
|
||||
GPSHyperionLinuxController(object_id_t objectId, object_id_t parentId,
|
||||
bool debugHyperionGps = false);
|
||||
virtual ~GPSHyperionLinuxController();
|
||||
@ -49,8 +51,11 @@ class GPSHyperionLinuxController : public ExtendedControllerBase {
|
||||
GpsPrimaryDataset gpsSet;
|
||||
Countdown maxTimeToReachFix = Countdown(MAX_SECONDS_TO_REACH_FIX * 1000);
|
||||
bool modeCommanded = true;
|
||||
bool timeInit = true;
|
||||
gpsmm myGpsmm;
|
||||
bool debugHyperionGps = false;
|
||||
uint32_t timeIsConstantCounter = 0;
|
||||
Countdown timeUpdateCd = Countdown(60);
|
||||
|
||||
void readGpsDataFromGpsd();
|
||||
};
|
||||
|
@ -191,8 +191,8 @@ ReturnValue_t PlocSupvHelper::performUpdate() {
|
||||
bytesWritten += dataLength;
|
||||
#if OBSW_DEBUG_PLOC_SUPERVISOR == 1
|
||||
progressPrinter.print(bytesWritten);
|
||||
}
|
||||
#endif /* OBSW_DEBUG_PLOC_SUPERVISOR == 1 */
|
||||
}
|
||||
result = handleCheckMemoryCommand();
|
||||
if (result != RETURN_OK) {
|
||||
return result;
|
||||
@ -262,6 +262,7 @@ ReturnValue_t PlocSupvHelper::handlePacketTransmission(SpacePacket& packet) {
|
||||
|
||||
ReturnValue_t PlocSupvHelper::sendCommand(SpacePacket& packet) {
|
||||
ReturnValue_t result = RETURN_OK;
|
||||
rememberApid = packet.getAPID();
|
||||
result = uartComIF->sendMessage(comCookie, packet.getWholeData(), packet.getFullSize());
|
||||
if (result != RETURN_OK) {
|
||||
sif::warning << "PlocSupvHelper::sendCommand: Failed to send command" << std::endl;
|
||||
@ -276,6 +277,7 @@ ReturnValue_t PlocSupvHelper::handleAck() {
|
||||
supv::TmPacket tmPacket;
|
||||
result = handleTmReception(&tmPacket, supv::SIZE_ACK_REPORT);
|
||||
if (result != RETURN_OK) {
|
||||
triggerEvent(ACK_RECEPTION_FAILURE, result, static_cast<uint32_t>(rememberApid));
|
||||
sif::warning << "PlocSupvHelper::handleAck: Error in reception of acknowledgment report"
|
||||
<< std::endl;
|
||||
return result;
|
||||
@ -305,6 +307,7 @@ ReturnValue_t PlocSupvHelper::handleExe() {
|
||||
supv::TmPacket tmPacket;
|
||||
result = handleTmReception(&tmPacket, supv::SIZE_EXE_REPORT);
|
||||
if (result != RETURN_OK) {
|
||||
triggerEvent(EXE_RECEPTION_FAILURE, result, static_cast<uint32_t>(rememberApid));
|
||||
sif::warning << "PlocSupvHelper::handleExe: Error in reception of execution report"
|
||||
<< std::endl;
|
||||
return result;
|
||||
|
@ -72,6 +72,14 @@ class PlocSupvHelper : public SystemObject, public ExecutableObjectIF, public Ha
|
||||
//! P1: Apid of received space packet
|
||||
//! P2: Internal state of supervisor helper
|
||||
static const Event SUPV_EXE_INVALID_APID = MAKE_EVENT(14, severity::LOW);
|
||||
//! [EXPORT] : [COMMENT] Failed to receive acknowledgment report
|
||||
//! P1: Return value
|
||||
//! P2: Apid of command for which the reception of the acknowledgment report failed
|
||||
static const Event ACK_RECEPTION_FAILURE = MAKE_EVENT(15, severity::LOW);
|
||||
//! [EXPORT] : [COMMENT] Failed to receive execution report
|
||||
//! P1: Return value
|
||||
//! P2: Apid of command for which the reception of the execution report failed
|
||||
static const Event EXE_RECEPTION_FAILURE = MAKE_EVENT(16, severity::LOW);
|
||||
|
||||
PlocSupvHelper(object_id_t objectId);
|
||||
virtual ~PlocSupvHelper();
|
||||
@ -167,6 +175,9 @@ class PlocSupvHelper : public SystemObject, public ExecutableObjectIF, public Ha
|
||||
|
||||
bool timestamping = true;
|
||||
|
||||
// Remembers APID to know at which command a procedure failed
|
||||
uint16_t rememberApid = 0;
|
||||
|
||||
ReturnValue_t performUpdate();
|
||||
ReturnValue_t performEventBufferRequest();
|
||||
ReturnValue_t handlePacketTransmission(SpacePacket& packet);
|
||||
|
Reference in New Issue
Block a user