GPS controller update #239

Merged
meierj merged 6 commits from mueller/gps-tests into develop 2022-05-03 13:41:30 +02:00
2 changed files with 159 additions and 178 deletions
Showing only changes of commit c131c685a4 - Show all commits

View File

@ -23,7 +23,7 @@
Q7STestTask::Q7STestTask(object_id_t objectId) : TestTask(objectId) {
doTestSdCard = false;
doTestScratchApi = false;
doTestGpsShm = true;
doTestGpsShm = false;
doTestGpsSocket = false;
doTestXadc = false;
}
@ -273,10 +273,12 @@ void Q7STestTask::testGpsDaemonShm() {
}
void Q7STestTask::testGpsDaemonSocket() {
gpsmm gpsmm("localhost", DEFAULT_GPSD_PORT);
if(gpsmmPtr == nullptr) {
gpsmmPtr = new 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 (not gpsmmPtr->is_open()) {
if (gpsNotOpenSwitch) {
// Opening failed
#if FSFW_VERBOSE_LEVEL >= 1
@ -288,14 +290,36 @@ void Q7STestTask::testGpsDaemonSocket() {
}
return;
}
for (;;) {
struct gps_data_t* gps;
if (!gpsmm.waiting(50000000)) continue;
if ((gps = gpsmm.read()) == NULL) {
std::cerr << "Read error.\n";
// Stopwatch watch;
gps_data_t *gps = nullptr;
gpsmmPtr->stream(WATCH_ENABLE | WATCH_JSON);
if(not gpsmmPtr->waiting(50000000)) {
return;
}
gps = gpsmmPtr->read();
if (gps == nullptr) {
if (gpsReadFailedSwitch) {
gpsReadFailedSwitch = false;
sif::warning << "Q7STestTask::testGpsDaemonSocket: Reading GPS data failed"
<< std::endl;
}
return;
}
if (MODE_SET != (MODE_SET & gps->set)) {
if (noModeSetCntr >= 0) {
noModeSetCntr++;
}
if (noModeSetCntr == 10) {
// TODO: Trigger event here
sif::warning << "Q7STestTask::testGpsDaemonSocket: No mode could be "
"read for 10 consecutive reads"
<< std::endl;
noModeSetCntr = -1;
}
return;
} else {
noModeSetCntr = 0;
}
sif::info << "-- Q7STestTask: GPS socket read test --" << std::endl;
#if LIBGPS_VERSION_MINOR <= 17
time_t timeRaw = gps->fix.time;
@ -309,51 +333,6 @@ void Q7STestTask::testGpsDaemonSocket() {
sif::info << "Fix (0:Not Seen|1:No Fix|2:2D|3:3D): " << gps->fix.mode << std::endl;
sif::info << "Latitude: " << gps->fix.latitude << std::endl;
sif::info << "Longitude: " << gps->fix.longitude << std::endl;
}
}
// // Stopwatch watch;
// gps_data_t *gps = nullptr;
// gpsmm.stream(WATCH_ENABLE | WATCH_JSON);
// if(not gpsmm.waiting(50000000)) {
// return;
// }
// gps = gpsmm.read();
// if (gps == nullptr) {
// if (gpsReadFailedSwitch) {
// gpsReadFailedSwitch = false;
// sif::warning << "Q7STestTask::testGpsDaemonSocket: Reading GPS data failed"
// << std::endl;
// }
// return;
// }
// if (MODE_SET != (MODE_SET & gps->set)) {
// if (noModeSetCntr >= 0) {
// noModeSetCntr++;
// }
// if (noModeSetCntr == 10) {
// // TODO: Trigger event here
// sif::warning << "Q7STestTask::testGpsDaemonSocket: No mode could be "
// "read for 10 consecutive reads"
// << std::endl;
// noModeSetCntr = -1;
// }
// return;
// } else {
// noModeSetCntr = 0;
// }
// sif::info << "-- Q7STestTask: GPS socket read test --" << std::endl;
//#if LIBGPS_VERSION_MINOR <= 17
// time_t timeRaw = gps->fix.time;
//#else
// time_t timeRaw = gps->fix.time.tv_sec;
//#endif
// std::tm* time = gmtime(&timeRaw);
// sif::info << "Time: " << std::put_time(time, "%c %Z") << std::endl;
// sif::info << "Visible satellites: " << gps->satellites_visible << std::endl;
// sif::info << "Satellites used: " << gps->satellites_used << std::endl;
// sif::info << "Fix (0:Not Seen|1:No Fix|2:2D|3:3D): " << gps->fix.mode << std::endl;
// sif::info << "Latitude: " << gps->fix.latitude << std::endl;
// sif::info << "Longitude: " << gps->fix.longitude << std::endl;
}
void Q7STestTask::testFileSystemHandlerDirect(FsOpCodes opCode) {

View File

@ -1,6 +1,7 @@
#ifndef BSP_Q7S_BOARDTEST_Q7STESTTASK_H_
#define BSP_Q7S_BOARDTEST_Q7STESTTASK_H_
#include <libgpsmm.h>
#include "test/testtasks/TestTask.h"
class CoreController;
@ -22,6 +23,7 @@ class Q7STestTask : public TestTask {
bool gpsNotOpenSwitch = false;
bool gpsReadFailedSwitch = false;
int32_t noModeSetCntr = 0;
gpsmm* gpsmmPtr = nullptr;
CoreController* coreController = nullptr;
ReturnValue_t performOneShotAction() override;