added gps reset callback
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:
@ -6,6 +6,11 @@
|
||||
|
||||
#include "lwgps/lwgps.h"
|
||||
|
||||
#if FSFW_DEV_HYPERION_GPS_CREATE_NMEA_CSV == 1
|
||||
#include <filesystem>
|
||||
#include <fstream>
|
||||
#endif
|
||||
|
||||
GPSHyperionHandler::GPSHyperionHandler(object_id_t objectId, object_id_t deviceCommunication,
|
||||
CookieIF *comCookie, bool debugHyperionGps):
|
||||
DeviceHandlerBase(objectId, deviceCommunication, comCookie), gpsSet(this),
|
||||
@ -47,6 +52,19 @@ ReturnValue_t GPSHyperionHandler::buildNormalDeviceCommand(DeviceCommandId_t *id
|
||||
ReturnValue_t GPSHyperionHandler::buildCommandFromCommand(
|
||||
DeviceCommandId_t deviceCommand, const uint8_t *commandData,
|
||||
size_t commandDataLen) {
|
||||
switch(deviceCommand) {
|
||||
case(GpsHyperion::TRIGGER_RESET_PIN): {
|
||||
if(resetPinTrigger != nullptr) {
|
||||
PoolReadGuard pg(&gpsSet);
|
||||
// Set HK entries invalid
|
||||
gpsSet.setValidity(false, true);
|
||||
// The user needs to implement this. Don't touch states for now, the device should
|
||||
// quickly reboot and send valid strings again.
|
||||
return resetPinTrigger(resetPinTriggerArgs);
|
||||
}
|
||||
return DeviceHandlerIF::COMMAND_NOT_IMPLEMENTED;
|
||||
}
|
||||
}
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
||||
@ -54,9 +72,9 @@ ReturnValue_t GPSHyperionHandler::scanForReply(const uint8_t *start, size_t len,
|
||||
DeviceCommandId_t *foundId, size_t *foundLen) {
|
||||
// Pass data to GPS library
|
||||
if(len > 0) {
|
||||
sif::info << "GPSHandler::scanForReply: Received " << len << " bytes" << std::endl;
|
||||
sif::debug << "GPSHandler::scanForReply: Received " << len << " bytes" << std::endl;
|
||||
if (internalState == InternalStates::WAIT_FIRST_MESSAGE) {
|
||||
// TODO: Check whether data is valid by chcking whether NMEA start string is valid
|
||||
// TODO: Check whether data is valid by checking whether NMEA start string is valid?
|
||||
commandExecuted = true;
|
||||
}
|
||||
int result = lwgps_process(&gpsData, start, len);
|
||||
@ -110,6 +128,13 @@ ReturnValue_t GPSHyperionHandler::scanForReply(const uint8_t *start, size_t len,
|
||||
printf("Altitude: %f meters\n", gpsData.altitude);
|
||||
}
|
||||
#if FSFW_DEV_HYPERION_GPS_CREATE_NMEA_CSV == 1
|
||||
std::string filename = "/mnt/sd0/gps_log_070921.txt";
|
||||
std::ofstream gpsFile;
|
||||
if(not std::filesystem::exists(filename)) {
|
||||
gpsFile.open(filename, std::ofstream::out);
|
||||
}
|
||||
gpsFile.open(filename, std::ofstream::out | std::ofstream::app);
|
||||
gpsFile.write(reinterpret_cast<const char*>(start), len);
|
||||
#endif
|
||||
}
|
||||
*foundLen = len;
|
||||
@ -155,6 +180,12 @@ void GPSHyperionHandler::modeChanged() {
|
||||
internalState = InternalStates::NONE;
|
||||
}
|
||||
|
||||
void GPSHyperionHandler::setResetPinTriggerFunction(ReturnValue_t (*function)(void *args),
|
||||
void *args) {
|
||||
resetPinTrigger = function;
|
||||
resetPinTriggerArgs = args;
|
||||
}
|
||||
|
||||
void GPSHyperionHandler::debugInterface(uint8_t positionTracker, object_id_t objectId,
|
||||
uint32_t parameter) {
|
||||
}
|
||||
|
Reference in New Issue
Block a user