improve SW switch handling
All checks were successful
EIVE/eive-obsw/pipeline/pr-develop This commit looks good
All checks were successful
EIVE/eive-obsw/pipeline/pr-develop This commit looks good
- also add CANT_GET_FIX event
This commit is contained in:
parent
ab0a3bfd45
commit
36ed787db1
@ -34,7 +34,6 @@ ReturnValue_t GpsHyperionLinuxController::checkModeCommand(Mode_t mode, Submode_
|
|||||||
uint32_t *msToReachTheMode) {
|
uint32_t *msToReachTheMode) {
|
||||||
if (not modeCommanded) {
|
if (not modeCommanded) {
|
||||||
if (mode == MODE_ON or mode == MODE_OFF) {
|
if (mode == MODE_ON or mode == MODE_OFF) {
|
||||||
gpsNotOpenSwitch = true;
|
|
||||||
// 5h time to reach fix
|
// 5h time to reach fix
|
||||||
*msToReachTheMode = MAX_SECONDS_TO_REACH_FIX;
|
*msToReachTheMode = MAX_SECONDS_TO_REACH_FIX;
|
||||||
maxTimeToReachFix.resetTimer();
|
maxTimeToReachFix.resetTimer();
|
||||||
@ -46,6 +45,7 @@ ReturnValue_t GpsHyperionLinuxController::checkModeCommand(Mode_t mode, Submode_
|
|||||||
if (mode == MODE_OFF) {
|
if (mode == MODE_OFF) {
|
||||||
PoolReadGuard pg(&gpsSet);
|
PoolReadGuard pg(&gpsSet);
|
||||||
gpsSet.setValidity(false, true);
|
gpsSet.setValidity(false, true);
|
||||||
|
oneShotSwitches.reset();
|
||||||
}
|
}
|
||||||
return returnvalue::OK;
|
return returnvalue::OK;
|
||||||
}
|
}
|
||||||
@ -102,7 +102,6 @@ ReturnValue_t GpsHyperionLinuxController::performOperation(uint8_t opCode) {
|
|||||||
if (not callAgainImmediately) {
|
if (not callAgainImmediately) {
|
||||||
handleQueue();
|
handleQueue();
|
||||||
poolManager.performHkOperation();
|
poolManager.performHkOperation();
|
||||||
TaskFactory::delayTask(200);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Should never be reached.
|
// Should never be reached.
|
||||||
@ -115,25 +114,24 @@ ReturnValue_t GpsHyperionLinuxController::initialize() {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
auto openError = [&](const char *type, int error) {
|
auto openError = [&](const char *type, int error) {
|
||||||
if (gpsNotOpenSwitch) {
|
// Opening failed
|
||||||
// Opening failed
|
|
||||||
#if FSFW_VERBOSE_LEVEL >= 1
|
#if FSFW_VERBOSE_LEVEL >= 1
|
||||||
sif::warning << "GPSHyperionHandler::readGpsDataFromGpsd: Opening GPSMM " << type
|
sif::warning << "GPSHyperionHandler::readGpsDataFromGpsd: Opening GPSMM " << type
|
||||||
<< " failed | Error " << error << " | " << gps_errstr(error) << std::endl;
|
<< " failed | Error " << error << " | " << gps_errstr(error) << std::endl;
|
||||||
#endif
|
#endif
|
||||||
gpsNotOpenSwitch = false;
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
if (readMode == ReadModes::SOCKET) {
|
if (readMode == ReadModes::SOCKET) {
|
||||||
int retval = gps_open("localhost", DEFAULT_GPSD_PORT, &gps);
|
int retval = gps_open("localhost", DEFAULT_GPSD_PORT, &gps);
|
||||||
if (retval != 0) {
|
if (retval != 0) {
|
||||||
openError("Socket", retval);
|
openError("Socket", retval);
|
||||||
|
return ObjectManager::CHILD_INIT_FAILED;
|
||||||
}
|
}
|
||||||
gps_stream(&gps, WATCH_ENABLE | WATCH_JSON, nullptr);
|
gps_stream(&gps, WATCH_ENABLE | WATCH_JSON, nullptr);
|
||||||
} else if (readMode == ReadModes::SHM) {
|
} else if (readMode == ReadModes::SHM) {
|
||||||
int retval = gps_open(GPSD_SHARED_MEMORY, "", &gps);
|
int retval = gps_open(GPSD_SHARED_MEMORY, "", &gps);
|
||||||
if (retval != 0) {
|
if (retval != 0) {
|
||||||
openError("SHM", retval);
|
openError("SHM", retval);
|
||||||
|
return ObjectManager::CHILD_INIT_FAILED;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
@ -147,8 +145,8 @@ void GpsHyperionLinuxController::performControlOperation() {}
|
|||||||
|
|
||||||
bool GpsHyperionLinuxController::readGpsDataFromGpsd() {
|
bool GpsHyperionLinuxController::readGpsDataFromGpsd() {
|
||||||
auto readError = [&]() {
|
auto readError = [&]() {
|
||||||
if (gpsReadFailedSwitch) {
|
if (oneShotSwitches.gpsReadFailedSwitch) {
|
||||||
gpsReadFailedSwitch = false;
|
oneShotSwitches.gpsReadFailedSwitch = false;
|
||||||
sif::warning << "GPSHyperionHandler::readGpsDataFromGpsd: Reading GPS data failed | "
|
sif::warning << "GPSHyperionHandler::readGpsDataFromGpsd: Reading GPS data failed | "
|
||||||
"Error "
|
"Error "
|
||||||
<< errno << " | " << gps_errstr(errno) << std::endl;
|
<< errno << " | " << gps_errstr(errno) << std::endl;
|
||||||
@ -156,23 +154,21 @@ bool GpsHyperionLinuxController::readGpsDataFromGpsd() {
|
|||||||
};
|
};
|
||||||
if (readMode == ReadModes::SOCKET) {
|
if (readMode == ReadModes::SOCKET) {
|
||||||
// Perform other necessary handling if not data seen for 0.2 seconds.
|
// Perform other necessary handling if not data seen for 0.2 seconds.
|
||||||
if (gps_waiting(&gps, 0)) {
|
if (gps_waiting(&gps, 200000)) {
|
||||||
if (-1 == gps_read(&gps)) {
|
if (-1 == gps_read(&gps)) {
|
||||||
readError();
|
readError();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
oneShotSwitches.gpsReadFailedSwitch = true;
|
||||||
if (MODE_SET != (MODE_SET & gps.set)) {
|
if (MODE_SET != (MODE_SET & gps.set)) {
|
||||||
if (mode == MODE_ON) {
|
if (mode != MODE_OFF and maxTimeToReachFix.hasTimedOut() and
|
||||||
if (noModeSetCntr >= 0) {
|
oneShotSwitches.cantGetFixSwitch) {
|
||||||
noModeSetCntr++;
|
// TODO: Trigger event here
|
||||||
}
|
sif::warning << "GPSHyperionHandler::readGpsDataFromGpsd: No mode could be "
|
||||||
if (noModeSetCntr == 10) {
|
"read for 10 consecutive reads"
|
||||||
// TODO: Trigger event here
|
<< std::endl;
|
||||||
sif::warning << "GPSHyperionHandler::readGpsDataFromGpsd: No mode could be "
|
triggerEvent(GpsHyperion::CANT_GET_FIX, maxTimeToReachFix.timeout);
|
||||||
"read for 10 consecutive reads"
|
oneShotSwitches.cantGetFixSwitch = false;
|
||||||
<< std::endl;
|
|
||||||
noModeSetCntr = -1;
|
|
||||||
}
|
|
||||||
// did not event get mode, nothing to see.
|
// did not event get mode, nothing to see.
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -58,10 +58,19 @@ class GpsHyperionLinuxController : public ExtendedControllerBase {
|
|||||||
const char* currentClientBuf = nullptr;
|
const char* currentClientBuf = nullptr;
|
||||||
ReadModes readMode = ReadModes::SOCKET;
|
ReadModes readMode = ReadModes::SOCKET;
|
||||||
Countdown maxTimeToReachFix = Countdown(MAX_SECONDS_TO_REACH_FIX * 1000);
|
Countdown maxTimeToReachFix = Countdown(MAX_SECONDS_TO_REACH_FIX * 1000);
|
||||||
bool modeCommanded = true;
|
bool modeCommanded = false;
|
||||||
bool timeInit = false;
|
bool timeInit = false;
|
||||||
bool gpsNotOpenSwitch = true;
|
|
||||||
bool gpsReadFailedSwitch = true;
|
struct OneShotSwitches {
|
||||||
|
void reset() {
|
||||||
|
gpsReadFailedSwitch = true;
|
||||||
|
cantGetFixSwitch = true;
|
||||||
|
}
|
||||||
|
bool gpsReadFailedSwitch = true;
|
||||||
|
bool cantGetFixSwitch = true;
|
||||||
|
|
||||||
|
} oneShotSwitches;
|
||||||
|
|
||||||
bool debugHyperionGps = false;
|
bool debugHyperionGps = false;
|
||||||
int32_t noModeSetCntr = 0;
|
int32_t noModeSetCntr = 0;
|
||||||
Countdown timeUpdateCd = Countdown(60);
|
Countdown timeUpdateCd = Countdown(60);
|
||||||
|
@ -13,6 +13,9 @@ static constexpr uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::GPS_HANDLER;
|
|||||||
//! [EXPORT] : [COMMENT] Fix has changed. P1: Old fix. P2: New fix
|
//! [EXPORT] : [COMMENT] Fix has changed. P1: Old fix. P2: New fix
|
||||||
//! 0: Not seen, 1: No Fix, 2: 2D-Fix, 3: 3D-Fix
|
//! 0: Not seen, 1: No Fix, 2: 2D-Fix, 3: 3D-Fix
|
||||||
static constexpr Event GPS_FIX_CHANGE = event::makeEvent(SUBSYSTEM_ID, 0, severity::INFO);
|
static constexpr Event GPS_FIX_CHANGE = event::makeEvent(SUBSYSTEM_ID, 0, severity::INFO);
|
||||||
|
//! [EXPORT] : [COMMENT] Could not get fix in maximum allowed time. P1: Maximum allowed time
|
||||||
|
//! to get a fix after the GPS was switched on.
|
||||||
|
static constexpr Event CANT_GET_FIX = event::makeEvent(SUBSYSTEM_ID, 0, severity::LOW);
|
||||||
|
|
||||||
static constexpr DeviceCommandId_t GPS_REPLY = 0;
|
static constexpr DeviceCommandId_t GPS_REPLY = 0;
|
||||||
static constexpr DeviceCommandId_t TRIGGER_RESET_PIN_GNSS = 5;
|
static constexpr DeviceCommandId_t TRIGGER_RESET_PIN_GNSS = 5;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user