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) {
|
||||
}
|
||||
|
@@ -19,8 +19,12 @@ public:
|
||||
CookieIF* comCookie, bool debugHyperionGps = false);
|
||||
virtual ~GPSHyperionHandler();
|
||||
|
||||
void setResetPinTriggerFunction(ReturnValue_t (*function) (void*args), void*args);
|
||||
protected:
|
||||
|
||||
ReturnValue_t (*resetPinTrigger) (void* args) = nullptr;
|
||||
void* resetPinTriggerArgs = nullptr;
|
||||
|
||||
enum class InternalStates {
|
||||
NONE,
|
||||
WAIT_FIRST_MESSAGE,
|
||||
|
@@ -75,6 +75,10 @@ ReturnValue_t GomspaceDeviceHandler::buildCommandFromCommand(
|
||||
}
|
||||
break;
|
||||
}
|
||||
case(GOMSPACE::PRINT_OUT_ENB_STATUS): {
|
||||
result = printStatus(deviceCommand);
|
||||
break;
|
||||
}
|
||||
case(GOMSPACE::REQUEST_HK_TABLE): {
|
||||
result = generateRequestFullHkTableCmd(hkTableReplySize);
|
||||
if(result != HasReturnvaluesIF::RETURN_OK){
|
||||
@@ -396,3 +400,8 @@ LocalPoolDataSetBase* GomspaceDeviceHandler::getDataSetHandle(sid_t sid) {
|
||||
void GomspaceDeviceHandler::setModeNormal() {
|
||||
mode = MODE_NORMAL;
|
||||
}
|
||||
|
||||
ReturnValue_t GomspaceDeviceHandler::printStatus(DeviceCommandId_t cmd) {
|
||||
sif::info << "No printHkTable implementation given.." << std::endl;
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
@@ -88,6 +88,13 @@ protected:
|
||||
*/
|
||||
virtual ReturnValue_t generateRequestFullHkTableCmd(uint16_t hkTableSize);
|
||||
|
||||
/**
|
||||
* This command handles printing the HK table to the console. This is useful for debugging
|
||||
* purposes
|
||||
* @return
|
||||
*/
|
||||
virtual ReturnValue_t printStatus(DeviceCommandId_t cmd);
|
||||
|
||||
/**
|
||||
* @brief Because housekeeping tables are device specific the handling of the reply is
|
||||
* given to the child class.
|
||||
|
@@ -1,11 +1,12 @@
|
||||
#include <fsfw/datapool/PoolReadGuard.h>
|
||||
#include "PDU1Handler.h"
|
||||
#include <mission/devices/devicedefinitions/GomSpacePackets.h>
|
||||
#include <OBSWConfig.h>
|
||||
|
||||
PDU1Handler::PDU1Handler(object_id_t objectId, object_id_t comIF, CookieIF * comCookie) :
|
||||
GomspaceDeviceHandler(objectId, comIF, comCookie, PDU::MAX_CONFIGTABLE_ADDRESS,
|
||||
PDU::MAX_HKTABLE_ADDRESS, PDU::HK_TABLE_REPLY_SIZE, &pdu1HkTableDataset), pdu1HkTableDataset(
|
||||
this) {
|
||||
PDU::MAX_HKTABLE_ADDRESS, PDU::HK_TABLE_REPLY_SIZE, &pdu1HkTableDataset),
|
||||
pdu1HkTableDataset(this) {
|
||||
}
|
||||
|
||||
PDU1Handler::~PDU1Handler() {
|
||||
@@ -55,25 +56,9 @@ void PDU1Handler::letChildHandleHkReply(DeviceCommandId_t id, const uint8_t *pac
|
||||
<< std::endl;
|
||||
sif::info << "PDU1 channel 8 current: " << pdu1HkTableDataset.currentOutChannel8
|
||||
<< std::endl;
|
||||
sif::info << "PDU1 TCS Board switch: "
|
||||
<< static_cast<unsigned int>(pdu1HkTableDataset.outEnabledTCSBoard3V3.value) << std::endl;
|
||||
sif::info << "PDU1 Syrlinks switch: "
|
||||
<< static_cast<unsigned int>(pdu1HkTableDataset.outEnabledSyrlinks.value) << std::endl;
|
||||
sif::info << "PDU1 star tracker switch: "
|
||||
<< static_cast<unsigned int>(pdu1HkTableDataset.outEnabledStarTracker.value) << std::endl;
|
||||
sif::info << "PDU1 MGT switch: "
|
||||
<< static_cast<unsigned int>(pdu1HkTableDataset.outEnabledMGT.value) << std::endl;
|
||||
sif::info << "PDU1 SUS nominal switch: "
|
||||
<< static_cast<unsigned int>(pdu1HkTableDataset.outEnabledSUSNominal.value) << std::endl;
|
||||
sif::info << "PDU1 solar cell experiment switch: "
|
||||
<< static_cast<unsigned int>(pdu1HkTableDataset.outEnabledSolarCellExp.value) << std::endl;
|
||||
sif::info << "PDU1 PLOC switch: "
|
||||
<< static_cast<unsigned int>(pdu1HkTableDataset.outEnabledPLOC.value) << std::endl;
|
||||
sif::info << "PDU1 ACS Side A switch: "
|
||||
<< static_cast<unsigned int>(pdu1HkTableDataset.outEnabledAcsBoardSideA.value) << std::endl;
|
||||
sif::info << "PDU1 channel 8 switch: "
|
||||
<< static_cast<unsigned int>(pdu1HkTableDataset.outEnabledChannel8.value) << std::endl;
|
||||
sif::info << "PDU1 battery mode: " << static_cast<unsigned int>(pdu1HkTableDataset.battMode.value) << std::endl;
|
||||
printOutputSwitchStates();
|
||||
sif::info << "PDU1 battery mode: " <<
|
||||
static_cast<unsigned int>(pdu1HkTableDataset.battMode.value) << std::endl;
|
||||
sif::info << "PDU1 VCC: " << pdu1HkTableDataset.vcc << " mV" << std::endl;
|
||||
float vbat = pdu1HkTableDataset.vbat.value * 0.001;
|
||||
sif::info << "PDU1 VBAT: " << vbat << "V" << std::endl;
|
||||
@@ -87,9 +72,35 @@ void PDU1Handler::letChildHandleHkReply(DeviceCommandId_t id, const uint8_t *pac
|
||||
#endif
|
||||
}
|
||||
|
||||
void PDU1Handler::printOutputSwitchStates() {
|
||||
sif::info << "PDU1 TCS Board switch: " <<
|
||||
static_cast<unsigned int>(pdu1HkTableDataset.outEnabledTCSBoard3V3.value) << std::endl;
|
||||
sif::info << "PDU1 Syrlinks switch: " <<
|
||||
static_cast<unsigned int>(pdu1HkTableDataset.outEnabledSyrlinks.value) << std::endl;
|
||||
sif::info << "PDU1 star tracker switch: " <<
|
||||
static_cast<unsigned int>(pdu1HkTableDataset.outEnabledStarTracker.value) << std::endl;
|
||||
sif::info << "PDU1 MGT switch: " <<
|
||||
static_cast<unsigned int>(pdu1HkTableDataset.outEnabledMGT.value) << std::endl;
|
||||
sif::info << "PDU1 SUS nominal switch: " <<
|
||||
static_cast<unsigned int>(pdu1HkTableDataset.outEnabledSUSNominal.value) << std::endl;
|
||||
sif::info << "PDU1 solar cell experiment switch: " <<
|
||||
static_cast<unsigned int>(pdu1HkTableDataset.outEnabledSolarCellExp.value) << std::endl;
|
||||
sif::info << "PDU1 PLOC switch: " <<
|
||||
static_cast<unsigned int>(pdu1HkTableDataset.outEnabledPLOC.value) << std::endl;
|
||||
sif::info << "PDU1 ACS Side A switch: " <<
|
||||
static_cast<unsigned int>(pdu1HkTableDataset.outEnabledAcsBoardSideA.value) << std::endl;
|
||||
sif::info << "PDU1 channel 8 switch: " <<
|
||||
static_cast<unsigned int>(pdu1HkTableDataset.outEnabledChannel8.value) << std::endl;
|
||||
}
|
||||
|
||||
void PDU1Handler::parseHkTableReply(const uint8_t *packet) {
|
||||
uint16_t dataOffset = 0;
|
||||
pdu1HkTableDataset.read();
|
||||
PoolReadGuard pg(&pdu1HkTableDataset);
|
||||
ReturnValue_t readResult = pg.getReadResult();
|
||||
if(readResult != HasReturnvaluesIF::RETURN_OK) {
|
||||
sif::warning << "Reading PDU1 HK table failed!" << std::endl;
|
||||
return;
|
||||
}
|
||||
/* Fist 10 bytes contain the gomspace header. Each variable is preceded by the 16-bit table
|
||||
* address. */
|
||||
dataOffset += 12;
|
||||
@@ -249,8 +260,10 @@ void PDU1Handler::parseHkTableReply(const uint8_t *packet) {
|
||||
dataOffset += 3;
|
||||
pdu1HkTableDataset.csp2WatchdogPingsLeft = *(packet + dataOffset);
|
||||
|
||||
pdu1HkTableDataset.commit();
|
||||
pdu1HkTableDataset.setChanged(true);
|
||||
if(not pdu1HkTableDataset.isValid()) {
|
||||
pdu1HkTableDataset.setValidity(true, true);
|
||||
}
|
||||
}
|
||||
|
||||
ReturnValue_t PDU1Handler::initializeLocalDataPool(
|
||||
@@ -341,3 +354,20 @@ ReturnValue_t PDU1Handler::initializeLocalDataPool(
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
||||
ReturnValue_t PDU1Handler::printStatus(DeviceCommandId_t cmd) {
|
||||
switch(cmd) {
|
||||
case(GOMSPACE::PRINT_OUT_ENB_STATUS): {
|
||||
PoolReadGuard pg(&pdu1HkTableDataset);
|
||||
ReturnValue_t readResult = pg.getReadResult();
|
||||
if(readResult != HasReturnvaluesIF::RETURN_OK) {
|
||||
sif::warning << "Reading PDU1 HK table failed!" << std::endl;
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
}
|
||||
printOutputSwitchStates();
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
default: {
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -32,11 +32,13 @@ protected:
|
||||
*/
|
||||
virtual ReturnValue_t buildNormalDeviceCommand(DeviceCommandId_t * id) override;
|
||||
virtual void letChildHandleHkReply(DeviceCommandId_t id, const uint8_t *packet) override;
|
||||
ReturnValue_t printStatus(DeviceCommandId_t cmd) override;
|
||||
|
||||
private:
|
||||
/** Dataset for the housekeeping table of the PDU1 */
|
||||
PDU1::PDU1HkTableDataset pdu1HkTableDataset;
|
||||
|
||||
void printOutputSwitchStates();
|
||||
void parseHkTableReply(const uint8_t *packet);
|
||||
};
|
||||
|
||||
|
@@ -7,6 +7,7 @@
|
||||
namespace GpsHyperion {
|
||||
|
||||
static constexpr DeviceCommandId_t GPS_REPLY = 0;
|
||||
static constexpr DeviceCommandId_t TRIGGER_RESET_PIN = 5;
|
||||
|
||||
static constexpr uint32_t DATASET_ID = 0;
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user