SHM and socket readout working now
All checks were successful
EIVE/eive-obsw/pipeline/head This commit looks good
All checks were successful
EIVE/eive-obsw/pipeline/head This commit looks good
This commit is contained in:
parent
cce0d5448d
commit
456dac6afd
@ -15,10 +15,9 @@ list yields a list of all related PRs for each release.
|
|||||||
|
|
||||||
## Added
|
## Added
|
||||||
|
|
||||||
|
- Custom Gomspace FDIR which disabled most of the default FDIR functionality
|
||||||
- Custom Syrlinks FDIR which disabled most of the default FDIR functionality
|
- Custom Syrlinks FDIR which disabled most of the default FDIR functionality
|
||||||
|
|
||||||
|
|
||||||
## Changed
|
## Changed
|
||||||
|
|
||||||
- PCDU handler only called once in PST, but can handle multiple messages now
|
- PCDU handler only called once in PST, but can handle multiple messages now
|
||||||
@ -27,6 +26,8 @@ list yields a list of all related PRs for each release.
|
|||||||
- Add `/usr/local/bin` to PATH. All shell scripts are there now
|
- Add `/usr/local/bin` to PATH. All shell scripts are there now
|
||||||
- Rename GPS device to `/dev/gps0`
|
- Rename GPS device to `/dev/gps0`
|
||||||
- Add Syrlinks and TMP devices to Software by default
|
- Add Syrlinks and TMP devices to Software by default
|
||||||
|
- Update GPS Linux Hyperion Handler to use socket interface. Still allows switching
|
||||||
|
back to SHM interface, but the SHM interface is a possible cause of SW crashes
|
||||||
|
|
||||||
# [v1.10.1]
|
# [v1.10.1]
|
||||||
|
|
||||||
|
@ -24,7 +24,10 @@ GPSHyperionLinuxController::GPSHyperionLinuxController(object_id_t objectId, obj
|
|||||||
timeUpdateCd.resetTimer();
|
timeUpdateCd.resetTimer();
|
||||||
}
|
}
|
||||||
|
|
||||||
GPSHyperionLinuxController::~GPSHyperionLinuxController() {}
|
GPSHyperionLinuxController::~GPSHyperionLinuxController() {
|
||||||
|
gps_stream(&gps, WATCH_DISABLE, nullptr);
|
||||||
|
gps_close(&gps);
|
||||||
|
}
|
||||||
|
|
||||||
void GPSHyperionLinuxController::performControlOperation() {
|
void GPSHyperionLinuxController::performControlOperation() {
|
||||||
#ifdef FSFW_OSAL_LINUX
|
#ifdef FSFW_OSAL_LINUX
|
||||||
@ -99,6 +102,27 @@ ReturnValue_t GPSHyperionLinuxController::initialize() {
|
|||||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||||
return result;
|
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;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -109,42 +133,27 @@ ReturnValue_t GPSHyperionLinuxController::handleCommandMessage(CommandMessage *m
|
|||||||
#ifdef FSFW_OSAL_LINUX
|
#ifdef FSFW_OSAL_LINUX
|
||||||
|
|
||||||
void GPSHyperionLinuxController::readGpsDataFromGpsd() {
|
void GPSHyperionLinuxController::readGpsDataFromGpsd() {
|
||||||
gps_data_t *gps = nullptr;
|
auto readError = [&](int error) {
|
||||||
auto openError = [&](const char *type) {
|
|
||||||
if (gpsNotOpenSwitch) {
|
|
||||||
// Opening failed
|
|
||||||
#if FSFW_VERBOSE_LEVEL >= 1
|
|
||||||
sif::warning << "GPSHyperionHandler::readGpsDataFromGpsd: Opening GPSMM " << type
|
|
||||||
<< " failed | Error " << errno << " | " << gps_errstr(errno) << std::endl;
|
|
||||||
#endif
|
|
||||||
gpsNotOpenSwitch = false;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
auto readError = [&]() {
|
|
||||||
if (gpsReadFailedSwitch) {
|
if (gpsReadFailedSwitch) {
|
||||||
gpsReadFailedSwitch = false;
|
gpsReadFailedSwitch = false;
|
||||||
sif::warning << "GPSHyperionHandler::readGpsDataFromGpsd: Reading GPS data failed"
|
sif::warning << "GPSHyperionHandler::readGpsDataFromGpsd: Reading GPS data failed | "
|
||||||
<< std::endl;
|
"Error "
|
||||||
|
<< error << " | " << gps_errstr(error) << std::endl;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
currentClientBuf = gps_data(&gps);
|
||||||
if (readMode == ReadModes::SOCKET) {
|
if (readMode == ReadModes::SOCKET) {
|
||||||
gpsmm gpsmm("localhost", DEFAULT_GPSD_PORT);
|
gps_stream(&gps, WATCH_ENABLE | WATCH_JSON, nullptr);
|
||||||
// The data from the device will generally be read all at once. Therefore, we
|
// Exit if no data is seen in 2 seconds (should not happen)
|
||||||
// can set all field here
|
if (not gps_waiting(&gps, 2000000)) {
|
||||||
if (not gpsmm.is_open()) {
|
|
||||||
return openError("Socket");
|
|
||||||
}
|
|
||||||
// Stopwatch watch;
|
|
||||||
gpsmm.stream(WATCH_ENABLE | WATCH_JSON);
|
|
||||||
if (not gpsmm.waiting(50000000)) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
gps = gpsmm.read();
|
int result = gps_read(&gps);
|
||||||
if (gps == nullptr) {
|
if (result == -1) {
|
||||||
readError();
|
readError(result);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (MODE_SET != (MODE_SET & gps->set)) {
|
if (MODE_SET != (MODE_SET & gps.set)) {
|
||||||
if (noModeSetCntr >= 0) {
|
if (noModeSetCntr >= 0) {
|
||||||
noModeSetCntr++;
|
noModeSetCntr++;
|
||||||
}
|
}
|
||||||
@ -155,27 +164,19 @@ void GPSHyperionLinuxController::readGpsDataFromGpsd() {
|
|||||||
<< std::endl;
|
<< std::endl;
|
||||||
noModeSetCntr = -1;
|
noModeSetCntr = -1;
|
||||||
}
|
}
|
||||||
return;
|
}
|
||||||
} else {
|
|
||||||
noModeSetCntr = 0;
|
noModeSetCntr = 0;
|
||||||
}
|
} else if (readMode == ReadModes::SHM) {
|
||||||
} else {
|
int result = gps_read(&gps);
|
||||||
gpsmm gpsmm(GPSD_SHARED_MEMORY, "");
|
if (result == -1) {
|
||||||
if (not gpsmm.is_open()) {
|
readError(result);
|
||||||
return openError("SHM");
|
|
||||||
}
|
|
||||||
gps = gpsmm.read();
|
|
||||||
if (gps == nullptr) {
|
|
||||||
readError();
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (gps != nullptr) {
|
handleGpsRead();
|
||||||
handleGpsRead(gps);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ReturnValue_t GPSHyperionLinuxController::handleGpsRead(gps_data_t *gps) {
|
ReturnValue_t GPSHyperionLinuxController::handleGpsRead() {
|
||||||
PoolReadGuard pg(&gpsSet);
|
PoolReadGuard pg(&gpsSet);
|
||||||
if (pg.getReadResult() != HasReturnvaluesIF::RETURN_OK) {
|
if (pg.getReadResult() != HasReturnvaluesIF::RETURN_OK) {
|
||||||
#if FSFW_VERBOSE_LEVEL >= 1
|
#if FSFW_VERBOSE_LEVEL >= 1
|
||||||
@ -187,7 +188,7 @@ ReturnValue_t GPSHyperionLinuxController::handleGpsRead(gps_data_t *gps) {
|
|||||||
bool validFix = false;
|
bool validFix = false;
|
||||||
static_cast<void>(validFix);
|
static_cast<void>(validFix);
|
||||||
// 0: Not seen, 1: No fix, 2: 2D-Fix, 3: 3D-Fix
|
// 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) {
|
if (newFixMode == 2 or newFixMode == 3) {
|
||||||
validFix = true;
|
validFix = true;
|
||||||
}
|
}
|
||||||
@ -195,7 +196,7 @@ ReturnValue_t GPSHyperionLinuxController::handleGpsRead(gps_data_t *gps) {
|
|||||||
triggerEvent(GpsHyperion::GPS_FIX_CHANGE, gpsSet.fixMode.value, newFixMode);
|
triggerEvent(GpsHyperion::GPS_FIX_CHANGE, gpsSet.fixMode.value, newFixMode);
|
||||||
}
|
}
|
||||||
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()) {
|
if (modeCommanded and maxTimeToReachFix.hasTimedOut()) {
|
||||||
// We are supposed to be on and functioning, but not fix was found
|
// We are supposed to be on and functioning, but not fix was found
|
||||||
if (mode == MODE_ON or mode == MODE_NORMAL) {
|
if (mode == MODE_ON or mode == MODE_NORMAL) {
|
||||||
@ -204,51 +205,51 @@ ReturnValue_t GPSHyperionLinuxController::handleGpsRead(gps_data_t *gps) {
|
|||||||
modeCommanded = false;
|
modeCommanded = false;
|
||||||
}
|
}
|
||||||
gpsSet.setValidity(false, true);
|
gpsSet.setValidity(false, true);
|
||||||
} else if (gps->satellites_used > 0) {
|
} else if (gps.satellites_used > 0) {
|
||||||
gpsSet.setValidity(true, true);
|
gpsSet.setValidity(true, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
gpsSet.satInUse.value = gps->satellites_used;
|
gpsSet.satInUse.value = gps.satellites_used;
|
||||||
gpsSet.satInView.value = gps->satellites_visible;
|
gpsSet.satInView.value = gps.satellites_visible;
|
||||||
|
|
||||||
if (std::isfinite(gps->fix.latitude)) {
|
if (std::isfinite(gps.fix.latitude)) {
|
||||||
// Negative latitude -> South direction
|
// Negative latitude -> South direction
|
||||||
gpsSet.latitude.value = gps->fix.latitude;
|
gpsSet.latitude.value = gps.fix.latitude;
|
||||||
} else {
|
} else {
|
||||||
gpsSet.latitude.setValid(false);
|
gpsSet.latitude.setValid(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (std::isfinite(gps->fix.longitude)) {
|
if (std::isfinite(gps.fix.longitude)) {
|
||||||
// Negative longitude -> West direction
|
// Negative longitude -> West direction
|
||||||
gpsSet.longitude.value = gps->fix.longitude;
|
gpsSet.longitude.value = gps.fix.longitude;
|
||||||
} else {
|
} else {
|
||||||
gpsSet.longitude.setValid(false);
|
gpsSet.longitude.setValid(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (std::isfinite(gps->fix.altitude)) {
|
if (std::isfinite(gps.fix.altitude)) {
|
||||||
gpsSet.altitude.value = gps->fix.altitude;
|
gpsSet.altitude.value = gps.fix.altitude;
|
||||||
} else {
|
} else {
|
||||||
gpsSet.altitude.setValid(false);
|
gpsSet.altitude.setValid(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (std::isfinite(gps->fix.speed)) {
|
if (std::isfinite(gps.fix.speed)) {
|
||||||
gpsSet.speed.value = gps->fix.speed;
|
gpsSet.speed.value = gps.fix.speed;
|
||||||
} else {
|
} else {
|
||||||
gpsSet.speed.setValid(false);
|
gpsSet.speed.setValid(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if LIBGPS_VERSION_MINOR <= 17
|
#if LIBGPS_VERSION_MINOR <= 17
|
||||||
gpsSet.unixSeconds.value = gps->fix.time;
|
gpsSet.unixSeconds.value = gps.fix.time;
|
||||||
#else
|
#else
|
||||||
gpsSet.unixSeconds.value = gps->fix.time.tv_sec;
|
gpsSet.unixSeconds.value = gps.fix.time.tv_sec;
|
||||||
#endif
|
#endif
|
||||||
timeval time = {};
|
timeval time = {};
|
||||||
time.tv_sec = gpsSet.unixSeconds.value;
|
time.tv_sec = gpsSet.unixSeconds.value;
|
||||||
#if LIBGPS_VERSION_MINOR <= 17
|
#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;
|
time.tv_usec = fractionalPart * 1000.0 * 1000.0;
|
||||||
#else
|
#else
|
||||||
time.tv_usec = gps->fix.time.tv_nsec / 1000;
|
time.tv_usec = gps.fix.time.tv_nsec / 1000;
|
||||||
#endif
|
#endif
|
||||||
std::time_t t = std::time(nullptr);
|
std::time_t t = std::time(nullptr);
|
||||||
if (time.tv_sec == t) {
|
if (time.tv_sec == t) {
|
||||||
@ -289,23 +290,23 @@ ReturnValue_t GPSHyperionLinuxController::handleGpsRead(gps_data_t *gps) {
|
|||||||
if (debugHyperionGps) {
|
if (debugHyperionGps) {
|
||||||
sif::info << "-- Hyperion GPS Data --" << std::endl;
|
sif::info << "-- Hyperion GPS Data --" << std::endl;
|
||||||
#if LIBGPS_VERSION_MINOR <= 17
|
#if LIBGPS_VERSION_MINOR <= 17
|
||||||
time_t timeRaw = gps->fix.time;
|
time_t timeRaw = gps.fix.time;
|
||||||
#else
|
#else
|
||||||
time_t timeRaw = gps->fix.time.tv_sec;
|
time_t timeRaw = gps.fix.time.tv_sec;
|
||||||
#endif
|
#endif
|
||||||
std::tm *time = gmtime(&timeRaw);
|
std::tm *time = gmtime(&timeRaw);
|
||||||
std::cout << "Time: " << std::put_time(time, "%c %Z") << std::endl;
|
std::cout << "Time: " << std::put_time(time, "%c %Z") << std::endl;
|
||||||
std::cout << "Visible satellites: " << gps->satellites_visible << std::endl;
|
std::cout << "Visible satellites: " << gps.satellites_visible << std::endl;
|
||||||
std::cout << "Satellites used: " << gps->satellites_used << 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 << "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 << "Latitude: " << gps.fix.latitude << std::endl;
|
||||||
std::cout << "Longitude: " << gps->fix.longitude << std::endl;
|
std::cout << "Longitude: " << gps.fix.longitude << std::endl;
|
||||||
#if LIBGPS_VERSION_MINOR <= 17
|
#if LIBGPS_VERSION_MINOR <= 17
|
||||||
std::cout << "Altitude(MSL): " << gps->fix.altitude << std::endl;
|
std::cout << "Altitude(MSL): " << gps.fix.altitude << std::endl;
|
||||||
#else
|
#else
|
||||||
std::cout << "Altitude(MSL): " << gps->fix.altMSL << std::endl;
|
std::cout << "Altitude(MSL): " << gps.fix.altMSL << std::endl;
|
||||||
#endif
|
#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::time_t t = std::time(nullptr);
|
||||||
std::tm tm = *std::gmtime(&t);
|
std::tm tm = *std::gmtime(&t);
|
||||||
std::cout << "C Time: " << std::put_time(&tm, "%c") << std::endl;
|
std::cout << "C Time: " << std::put_time(&tm, "%c") << std::endl;
|
||||||
|
@ -49,11 +49,13 @@ class GPSHyperionLinuxController : public ExtendedControllerBase {
|
|||||||
ReturnValue_t initializeLocalDataPool(localpool::DataPool& localDataPoolMap,
|
ReturnValue_t initializeLocalDataPool(localpool::DataPool& localDataPoolMap,
|
||||||
LocalDataPoolManager& poolManager) override;
|
LocalDataPoolManager& poolManager) override;
|
||||||
|
|
||||||
ReturnValue_t handleGpsRead(gps_data_t* gps);
|
ReturnValue_t handleGpsRead();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
GpsPrimaryDataset gpsSet;
|
GpsPrimaryDataset gpsSet;
|
||||||
ReadModes readMode = ReadModes::SHM;
|
gps_data_t gps = {};
|
||||||
|
const char* currentClientBuf = nullptr;
|
||||||
|
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 = true;
|
||||||
bool timeInit = true;
|
bool timeInit = true;
|
||||||
|
Loading…
Reference in New Issue
Block a user