fixed conflicts
Some checks failed
EIVE/eive-obsw/pipeline/head There was a failure building this commit
Some checks failed
EIVE/eive-obsw/pipeline/head There was a failure building this commit
This commit is contained in:
@ -24,7 +24,10 @@ GPSHyperionLinuxController::GPSHyperionLinuxController(object_id_t objectId, obj
|
||||
timeUpdateCd.resetTimer();
|
||||
}
|
||||
|
||||
GPSHyperionLinuxController::~GPSHyperionLinuxController() {}
|
||||
GPSHyperionLinuxController::~GPSHyperionLinuxController() {
|
||||
gps_stream(&gps, WATCH_DISABLE, nullptr);
|
||||
gps_close(&gps);
|
||||
}
|
||||
|
||||
void GPSHyperionLinuxController::performControlOperation() {
|
||||
#ifdef FSFW_OSAL_LINUX
|
||||
@ -99,6 +102,27 @@ ReturnValue_t GPSHyperionLinuxController::initialize() {
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
auto openError = [&](const char *type, int error) {
|
||||
if (gpsNotOpenSwitch) {
|
||||
// Opening failed
|
||||
#if FSFW_VERBOSE_LEVEL >= 1
|
||||
sif::warning << "GPSHyperionHandler::readGpsDataFromGpsd: Opening GPSMM " << type
|
||||
<< " failed | Error " << error << " | " << gps_errstr(error) << std::endl;
|
||||
#endif
|
||||
gpsNotOpenSwitch = false;
|
||||
}
|
||||
};
|
||||
if (readMode == ReadModes::SOCKET) {
|
||||
int retval = gps_open("localhost", DEFAULT_GPSD_PORT, &gps);
|
||||
if (retval != 0) {
|
||||
openError("Socket", retval);
|
||||
}
|
||||
} else if (readMode == ReadModes::SHM) {
|
||||
int retval = gps_open(GPSD_SHARED_MEMORY, "", &gps);
|
||||
if (retval != 0) {
|
||||
openError("SHM", retval);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -107,41 +131,29 @@ ReturnValue_t GPSHyperionLinuxController::handleCommandMessage(CommandMessage *m
|
||||
}
|
||||
|
||||
#ifdef FSFW_OSAL_LINUX
|
||||
void GPSHyperionLinuxController::readGpsDataFromGpsd() {
|
||||
gpsmm gpsmm("localhost", DEFAULT_GPSD_PORT);
|
||||
// The data from the device will generally be read all at once. Therefore, we
|
||||
// can set all field here
|
||||
if (not gpsmm.is_open()) {
|
||||
if (gpsNotOpenSwitch) {
|
||||
// Opening failed
|
||||
#if FSFW_VERBOSE_LEVEL >= 1
|
||||
sif::warning << "GPSHyperionHandler::readGpsDataFromGpsd: Opening GPSMM failed | "
|
||||
<< "Error " << errno << " | " << gps_errstr(errno) << std::endl;
|
||||
#endif
|
||||
|
||||
gpsNotOpenSwitch = false;
|
||||
void GPSHyperionLinuxController::readGpsDataFromGpsd() {
|
||||
auto readError = [&](int error) {
|
||||
if (gpsReadFailedSwitch) {
|
||||
gpsReadFailedSwitch = false;
|
||||
sif::warning << "GPSHyperionHandler::readGpsDataFromGpsd: Reading GPS data failed | "
|
||||
"Error "
|
||||
<< error << " | " << gps_errstr(error) << std::endl;
|
||||
}
|
||||
return;
|
||||
}
|
||||
// Stopwatch watch;
|
||||
gps_data_t *gps = nullptr;
|
||||
gps = gpsmm.stream(WATCH_ENABLE | WATCH_JSON);
|
||||
if (gps == nullptr) {
|
||||
sif::warning << "GPSHyperionHandler::readGpsDataFromGpsd:: Setting GPSD watch "
|
||||
"policy failed"
|
||||
<< std::endl;
|
||||
}
|
||||
while (gpsmm.waiting(2000)) {
|
||||
gps = gpsmm.read();
|
||||
if (gps == nullptr) {
|
||||
if (gpsReadFailedSwitch) {
|
||||
gpsReadFailedSwitch = false;
|
||||
sif::warning << "GPSHyperionHandler::readGpsDataFromGpsd: Reading GPS data failed"
|
||||
<< std::endl;
|
||||
}
|
||||
};
|
||||
currentClientBuf = gps_data(&gps);
|
||||
if (readMode == ReadModes::SOCKET) {
|
||||
gps_stream(&gps, WATCH_ENABLE | WATCH_JSON, nullptr);
|
||||
// Exit if no data is seen in 2 seconds (should not happen)
|
||||
if (not gps_waiting(&gps, 2000000)) {
|
||||
return;
|
||||
}
|
||||
if (MODE_SET != (MODE_SET & gps->set)) {
|
||||
int result = gps_read(&gps);
|
||||
if (result == -1) {
|
||||
readError(result);
|
||||
return;
|
||||
}
|
||||
if (MODE_SET != (MODE_SET & gps.set)) {
|
||||
if (noModeSetCntr >= 0) {
|
||||
noModeSetCntr++;
|
||||
}
|
||||
@ -152,24 +164,31 @@ void GPSHyperionLinuxController::readGpsDataFromGpsd() {
|
||||
<< std::endl;
|
||||
noModeSetCntr = -1;
|
||||
}
|
||||
}
|
||||
noModeSetCntr = 0;
|
||||
} else if (readMode == ReadModes::SHM) {
|
||||
int result = gps_read(&gps);
|
||||
if (result == -1) {
|
||||
readError(result);
|
||||
return;
|
||||
} else {
|
||||
noModeSetCntr = 0;
|
||||
}
|
||||
}
|
||||
gps = gpsmm.stream(WATCH_DISABLE);
|
||||
handleGpsRead();
|
||||
}
|
||||
|
||||
ReturnValue_t GPSHyperionLinuxController::handleGpsRead() {
|
||||
PoolReadGuard pg(&gpsSet);
|
||||
if (pg.getReadResult() != HasReturnvaluesIF::RETURN_OK) {
|
||||
#if FSFW_VERBOSE_LEVEL >= 1
|
||||
sif::warning << "GPSHyperionHandler::readGpsDataFromGpsd: Reading dataset failed" << std::endl;
|
||||
#endif
|
||||
return;
|
||||
return RETURN_FAILED;
|
||||
}
|
||||
|
||||
bool validFix = false;
|
||||
static_cast<void>(validFix);
|
||||
// 0: Not seen, 1: No fix, 2: 2D-Fix, 3: 3D-Fix
|
||||
int newFixMode = gps->fix.mode;
|
||||
int newFixMode = gps.fix.mode;
|
||||
if (newFixMode == 2 or newFixMode == 3) {
|
||||
validFix = true;
|
||||
}
|
||||
@ -177,7 +196,7 @@ void GPSHyperionLinuxController::readGpsDataFromGpsd() {
|
||||
triggerEvent(GpsHyperion::GPS_FIX_CHANGE, gpsSet.fixMode.value, newFixMode);
|
||||
}
|
||||
gpsSet.fixMode.value = newFixMode;
|
||||
if (gps->fix.mode == 0 or gps->fix.mode == 1) {
|
||||
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
|
||||
if (mode == MODE_ON or mode == MODE_NORMAL) {
|
||||
@ -186,51 +205,51 @@ void GPSHyperionLinuxController::readGpsDataFromGpsd() {
|
||||
modeCommanded = false;
|
||||
}
|
||||
gpsSet.setValidity(false, true);
|
||||
} else if (gps->satellites_used > 0) {
|
||||
} else if (gps.satellites_used > 0) {
|
||||
gpsSet.setValidity(true, true);
|
||||
}
|
||||
|
||||
gpsSet.satInUse.value = gps->satellites_used;
|
||||
gpsSet.satInView.value = gps->satellites_visible;
|
||||
gpsSet.satInUse.value = gps.satellites_used;
|
||||
gpsSet.satInView.value = gps.satellites_visible;
|
||||
|
||||
if (std::isfinite(gps->fix.latitude)) {
|
||||
if (std::isfinite(gps.fix.latitude)) {
|
||||
// Negative latitude -> South direction
|
||||
gpsSet.latitude.value = gps->fix.latitude;
|
||||
gpsSet.latitude.value = gps.fix.latitude;
|
||||
} else {
|
||||
gpsSet.latitude.setValid(false);
|
||||
}
|
||||
|
||||
if (std::isfinite(gps->fix.longitude)) {
|
||||
if (std::isfinite(gps.fix.longitude)) {
|
||||
// Negative longitude -> West direction
|
||||
gpsSet.longitude.value = gps->fix.longitude;
|
||||
gpsSet.longitude.value = gps.fix.longitude;
|
||||
} else {
|
||||
gpsSet.longitude.setValid(false);
|
||||
}
|
||||
|
||||
if (std::isfinite(gps->fix.altitude)) {
|
||||
gpsSet.altitude.value = gps->fix.altitude;
|
||||
if (std::isfinite(gps.fix.altitude)) {
|
||||
gpsSet.altitude.value = gps.fix.altitude;
|
||||
} else {
|
||||
gpsSet.altitude.setValid(false);
|
||||
}
|
||||
|
||||
if (std::isfinite(gps->fix.speed)) {
|
||||
gpsSet.speed.value = gps->fix.speed;
|
||||
if (std::isfinite(gps.fix.speed)) {
|
||||
gpsSet.speed.value = gps.fix.speed;
|
||||
} else {
|
||||
gpsSet.speed.setValid(false);
|
||||
}
|
||||
|
||||
#if LIBGPS_VERSION_MINOR <= 17
|
||||
gpsSet.unixSeconds.value = gps->fix.time;
|
||||
gpsSet.unixSeconds.value = gps.fix.time;
|
||||
#else
|
||||
gpsSet.unixSeconds.value = gps->fix.time.tv_sec;
|
||||
gpsSet.unixSeconds.value = gps.fix.time.tv_sec;
|
||||
#endif
|
||||
timeval time = {};
|
||||
time.tv_sec = gpsSet.unixSeconds.value;
|
||||
#if LIBGPS_VERSION_MINOR <= 17
|
||||
double fractionalPart = gps->fix.time - std::floor(gps->fix.time);
|
||||
double fractionalPart = gps.fix.time - std::floor(gps.fix.time);
|
||||
time.tv_usec = fractionalPart * 1000.0 * 1000.0;
|
||||
#else
|
||||
time.tv_usec = gps->fix.time.tv_nsec / 1000;
|
||||
time.tv_usec = gps.fix.time.tv_nsec / 1000;
|
||||
#endif
|
||||
std::time_t t = std::time(nullptr);
|
||||
if (time.tv_sec == t) {
|
||||
@ -271,26 +290,28 @@ void GPSHyperionLinuxController::readGpsDataFromGpsd() {
|
||||
if (debugHyperionGps) {
|
||||
sif::info << "-- Hyperion GPS Data --" << std::endl;
|
||||
#if LIBGPS_VERSION_MINOR <= 17
|
||||
time_t timeRaw = gps->fix.time;
|
||||
time_t timeRaw = gps.fix.time;
|
||||
#else
|
||||
time_t timeRaw = gps->fix.time.tv_sec;
|
||||
time_t timeRaw = gps.fix.time.tv_sec;
|
||||
#endif
|
||||
std::tm *time = gmtime(&timeRaw);
|
||||
std::cout << "Time: " << std::put_time(time, "%c %Z") << std::endl;
|
||||
std::cout << "Visible satellites: " << gps->satellites_visible << std::endl;
|
||||
std::cout << "Satellites used: " << gps->satellites_used << std::endl;
|
||||
std::cout << "Fix (0:Not Seen|1:No Fix|2:2D|3:3D): " << gps->fix.mode << std::endl;
|
||||
std::cout << "Latitude: " << gps->fix.latitude << std::endl;
|
||||
std::cout << "Longitude: " << gps->fix.longitude << std::endl;
|
||||
std::cout << "Visible satellites: " << gps.satellites_visible << std::endl;
|
||||
std::cout << "Satellites used: " << gps.satellites_used << std::endl;
|
||||
std::cout << "Fix (0:Not Seen|1:No Fix|2:2D|3:3D): " << gps.fix.mode << std::endl;
|
||||
std::cout << "Latitude: " << gps.fix.latitude << std::endl;
|
||||
std::cout << "Longitude: " << gps.fix.longitude << std::endl;
|
||||
#if LIBGPS_VERSION_MINOR <= 17
|
||||
std::cout << "Altitude(MSL): " << gps->fix.altitude << std::endl;
|
||||
std::cout << "Altitude(MSL): " << gps.fix.altitude << std::endl;
|
||||
#else
|
||||
std::cout << "Altitude(MSL): " << gps->fix.altMSL << std::endl;
|
||||
std::cout << "Altitude(MSL): " << gps.fix.altMSL << std::endl;
|
||||
#endif
|
||||
std::cout << "Speed(m/s): " << gps->fix.speed << 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;
|
||||
}
|
||||
return RETURN_OK;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -24,6 +24,8 @@ class GPSHyperionLinuxController : public ExtendedControllerBase {
|
||||
public:
|
||||
static constexpr uint32_t MAX_SECONDS_TO_REACH_FIX = 60 * 60 * 5;
|
||||
|
||||
enum ReadModes { SHM = 0, SOCKET = 1 };
|
||||
|
||||
GPSHyperionLinuxController(object_id_t objectId, object_id_t parentId,
|
||||
bool debugHyperionGps = false);
|
||||
virtual ~GPSHyperionLinuxController();
|
||||
@ -47,8 +49,13 @@ class GPSHyperionLinuxController : public ExtendedControllerBase {
|
||||
ReturnValue_t initializeLocalDataPool(localpool::DataPool& localDataPoolMap,
|
||||
LocalDataPoolManager& poolManager) override;
|
||||
|
||||
ReturnValue_t handleGpsRead();
|
||||
|
||||
private:
|
||||
GpsPrimaryDataset gpsSet;
|
||||
gps_data_t gps = {};
|
||||
const char* currentClientBuf = nullptr;
|
||||
ReadModes readMode = ReadModes::SOCKET;
|
||||
Countdown maxTimeToReachFix = Countdown(MAX_SECONDS_TO_REACH_FIX * 1000);
|
||||
bool modeCommanded = true;
|
||||
bool timeInit = true;
|
||||
|
@ -264,8 +264,8 @@ static const uint8_t ADC_RPT_SET_ENTRIES = 32;
|
||||
static const uint32_t HK_SET_ID = HK_REPORT;
|
||||
static const uint32_t BOOT_REPORT_SET_ID = BOOT_STATUS_REPORT;
|
||||
static const uint32_t LATCHUP_RPT_ID = LATCHUP_REPORT;
|
||||
static const uint32_t LOGGING_RPT_ID = LOGGING_REQUEST_COUNTERS;
|
||||
static const uint32_t ADC_REPORT_SET_ID = REQUEST_ADC_REPORT;
|
||||
static const uint32_t LOGGING_RPT_ID = LOGGING_REPORT;
|
||||
static const uint32_t ADC_REPORT_SET_ID = ADC_REPORT;
|
||||
|
||||
namespace recv_timeout {
|
||||
// Erase memory can require up to 60 seconds for execution
|
||||
|
@ -687,8 +687,8 @@ ReturnValue_t PlocMPSoCHandler::handleCamCmdRpt(const uint8_t* data) {
|
||||
std::string camCmdRptMsg(
|
||||
reinterpret_cast<const char*>(dataFieldPtr),
|
||||
tmCamCmdRpt.rememberSpacePacketSize - mpsoc::SPACE_PACKET_HEADER_SIZE - 3);
|
||||
uint8_t ackValue = *(packet.getPacketData() + packet.getPacketDataLength() - 2);
|
||||
#if OBSW_DEBUG_PLOC_MPSOC == 1
|
||||
uint8_t ackValue = *(packet.getPacketData() + packet.getPacketDataLength() - 2);
|
||||
sif::info << "PlocMPSoCHandler: CamCmdRpt message: " << camCmdRptMsg << std::endl;
|
||||
sif::info << "PlocMPSoCHandler: CamCmdRpt Ack value: 0x" << std::hex
|
||||
<< static_cast<unsigned int>(ackValue) << std::endl;
|
||||
@ -1014,7 +1014,7 @@ void PlocMPSoCHandler::handleActionCommandFailure(ActionId_t actionId) {
|
||||
switch (powerState) {
|
||||
case PowerState::BOOTING: {
|
||||
sif::info << "PlocMPSoCHandler::handleActionCommandFailure: MPSoC boot command failed"
|
||||
<< std::endl;
|
||||
<< std::endl;
|
||||
// This is commonly the case when the MPSoC is already operational. Thus the power state is
|
||||
// set to on here
|
||||
powerState = PowerState::ON;
|
||||
|
@ -1314,9 +1314,7 @@ ReturnValue_t PlocSupervisorHandler::doSendReadHook() {
|
||||
return RETURN_OK;
|
||||
}
|
||||
|
||||
void PlocSupervisorHandler::doOffActivity() {
|
||||
startupState = StartupState::OFF;
|
||||
}
|
||||
void PlocSupervisorHandler::doOffActivity() { startupState = StartupState::OFF; }
|
||||
|
||||
void PlocSupervisorHandler::handleDeviceTM(const uint8_t* data, size_t dataSize,
|
||||
DeviceCommandId_t replyId) {
|
||||
|
@ -83,21 +83,15 @@ class PlocSupervisorHandler : public DeviceHandlerBase {
|
||||
static const uint8_t SIZE_NULL_TERMINATOR = 1;
|
||||
// 5 s
|
||||
static const uint32_t EXECUTION_DEFAULT_TIMEOUT = 5000;
|
||||
// 30 s
|
||||
static const uint32_t MRAM_DUMP_EXECUTION_TIMEOUT = 30000;
|
||||
// 60 s
|
||||
static const uint32_t MRAM_DUMP_EXECUTION_TIMEOUT = 60000;
|
||||
// 70 s
|
||||
static const uint32_t COPY_ADC_TO_MRAM_TIMEOUT = 70000;
|
||||
// 60 s
|
||||
static const uint32_t MRAM_DUMP_TIMEOUT = 60000;
|
||||
// 2 s
|
||||
static const uint32_t BOOT_TIMEOUT = 2000;
|
||||
enum class StartupState: uint8_t {
|
||||
OFF,
|
||||
BOOTING,
|
||||
SET_TIME,
|
||||
SET_TIME_EXECUTING,
|
||||
ON
|
||||
};
|
||||
enum class StartupState : uint8_t { OFF, BOOTING, SET_TIME, SET_TIME_EXECUTING, ON };
|
||||
|
||||
StartupState startupState = StartupState::OFF;
|
||||
|
||||
|
Reference in New Issue
Block a user