diff --git a/bsp_q7s/devices/startracker/StarTrackerDefinitions.h b/bsp_q7s/devices/startracker/StarTrackerDefinitions.h index 4ff30ec0..18fe38d7 100644 --- a/bsp_q7s/devices/startracker/StarTrackerDefinitions.h +++ b/bsp_q7s/devices/startracker/StarTrackerDefinitions.h @@ -639,7 +639,7 @@ class HistogramSet: public: // Size of dataset - static const size_t SIZE = 154; + static const size_t SIZE = 156; HistogramSet(HasLocalDataPoolIF* owner): StaticLocalDataSet(owner, HISTOGRAM_SET_ID) { diff --git a/bsp_q7s/devices/startracker/StarTrackerHandler.cpp b/bsp_q7s/devices/startracker/StarTrackerHandler.cpp index f1e029dc..16960f76 100644 --- a/bsp_q7s/devices/startracker/StarTrackerHandler.cpp +++ b/bsp_q7s/devices/startracker/StarTrackerHandler.cpp @@ -1411,8 +1411,7 @@ ReturnValue_t StarTrackerHandler::handleHistogramTm() { if(status != StarTracker::STATUS_OK) { sif::warning << "StarTrackerHandler::handleHistogramTm: Reply error: " << static_cast(status) << std::endl; - result = HISTOGRAM_REQ_FAILED; - return result; + return HISTOGRAM_REQ_FAILED; } result = histogramSet.read(TIMEOUT_TYPE, MUTEX_TIMEOUT); if (result != RETURN_OK) { @@ -1425,6 +1424,10 @@ ReturnValue_t StarTrackerHandler::handleHistogramTm() { sif::warning << "StarTrackerHandler::handleHistogramTm: Deserialization failed" << std::endl; } + result = histogramSet.commit(TIMEOUT_TYPE, MUTEX_TIMEOUT); + if (result != RETURN_OK) { + return result; + } #if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_STARTRACKER == 1 histogramSet.printSet(); #endif diff --git a/mission/devices/ACUHandler.cpp b/mission/devices/ACUHandler.cpp index 24bd52fe..a52e48ff 100644 --- a/mission/devices/ACUHandler.cpp +++ b/mission/devices/ACUHandler.cpp @@ -266,3 +266,44 @@ ReturnValue_t ACUHandler::initializeLocalDataPool( return HasReturnvaluesIF::RETURN_OK; } + +ReturnValue_t ACUHandler::deviceSpecificCommand(DeviceCommandId_t cmd) { + switch(cmd) { + case PRINT_CHANNEL_STATS: { + printChannelStats(); + return RETURN_OK; + } + default: { + return DeviceHandlerIF::COMMAND_NOT_IMPLEMENTED; + } + } +} + +void ACUHandler::printChannelStats() { + PoolReadGuard pg(&acuHkTableDataset); + sif::info << "ACU Info: Stats, Current [mA], Voltage [mV]" << std::endl; + sif::info << std::setw(30) << std::left << "Ch0" << std::dec << "| " << + static_cast(acuHkTableDataset.currentInChannel0.value) << ", " << + std::setw(4) << std::right << acuHkTableDataset.voltageInChannel0.value << ", " + << std::setw(4) << std::endl; + sif::info << std::setw(30) << std::left << "Ch1" << std::dec << "| " << + static_cast(acuHkTableDataset.currentInChannel1.value) << ", " << + std::setw(4) << std::right << acuHkTableDataset.voltageInChannel1.value << ", " + << std::setw(4) << std::endl; + sif::info << std::setw(30) << std::left << "Ch2" << std::dec << "| " << + static_cast(acuHkTableDataset.currentInChannel2.value) << ", " << + std::setw(4) << std::right << acuHkTableDataset.voltageInChannel2.value << ", " + << std::setw(4) << std::endl; + sif::info << std::setw(30) << std::left << "Ch3" << std::dec << "| " << + static_cast(acuHkTableDataset.currentInChannel3.value) << ", " << + std::setw(4) << std::right << acuHkTableDataset.voltageInChannel3.value << ", " + << std::setw(4) << std::endl; + sif::info << std::setw(30) << std::left << "Ch4" << std::dec << "| " << + static_cast(acuHkTableDataset.currentInChannel4.value) << ", " << + std::setw(4) << std::right << acuHkTableDataset.voltageInChannel4.value << ", " + << std::setw(4) << std::endl; + sif::info << std::setw(30) << std::left << "Ch5" << std::dec << "| " << + static_cast(acuHkTableDataset.currentInChannel5.value) << ", " << + std::setw(4) << std::right << acuHkTableDataset.voltageInChannel5.value << ", " + << std::setw(4) << std::endl; +} diff --git a/mission/devices/ACUHandler.h b/mission/devices/ACUHandler.h index 8ab32a24..886faba7 100644 --- a/mission/devices/ACUHandler.h +++ b/mission/devices/ACUHandler.h @@ -3,6 +3,7 @@ #include "GomspaceDeviceHandler.h" #include +#include "fsfw/datapool/PoolReadGuard.h" /** * @brief Handler for the ACU from Gomspace. Monitors and controls the battery charging via @@ -25,8 +26,12 @@ protected: */ virtual ReturnValue_t buildNormalDeviceCommand(DeviceCommandId_t * id) override; + virtual ReturnValue_t deviceSpecificCommand(DeviceCommandId_t cmd) override; + private: + static const DeviceCommandId_t PRINT_CHANNEL_STATS = 51; + ACU::HkTableDataset acuHkTableDataset; /** @@ -34,6 +39,11 @@ private: * the values in the acuHkTableDataset. */ void parseHkTableReply(const uint8_t *packet); + + /** + * @brief Prints channel statistics (current and voltage) to console + */ + void printChannelStats(); }; #endif /* MISSION_DEVICES_ACUHANDLER_H_ */ diff --git a/mission/devices/GomspaceDeviceHandler.cpp b/mission/devices/GomspaceDeviceHandler.cpp index e5912969..95e35a5e 100644 --- a/mission/devices/GomspaceDeviceHandler.cpp +++ b/mission/devices/GomspaceDeviceHandler.cpp @@ -87,7 +87,7 @@ ReturnValue_t GomspaceDeviceHandler::buildCommandFromCommand( break; } default: - return DeviceHandlerIF::COMMAND_NOT_IMPLEMENTED; + return deviceSpecificCommand(deviceCommand); } return HasReturnvaluesIF::RETURN_OK; } @@ -398,6 +398,10 @@ LocalPoolDataSetBase* GomspaceDeviceHandler::getDataSetHandle(sid_t sid) { } } +ReturnValue_t GomspaceDeviceHandler::deviceSpecificCommand(DeviceCommandId_t cmd) { + return DeviceHandlerIF::COMMAND_NOT_IMPLEMENTED; +} + void GomspaceDeviceHandler::setModeNormal() { mode = MODE_NORMAL; } diff --git a/mission/devices/GomspaceDeviceHandler.h b/mission/devices/GomspaceDeviceHandler.h index 78257b83..bb11ba0e 100644 --- a/mission/devices/GomspaceDeviceHandler.h +++ b/mission/devices/GomspaceDeviceHandler.h @@ -105,6 +105,11 @@ protected: virtual LocalPoolDataSetBase* getDataSetHandle(sid_t sid) override; + /** + * @brief Can be used by gomspace devices to implement device specific commands. + */ + virtual ReturnValue_t deviceSpecificCommand(DeviceCommandId_t cmd); + private: /** diff --git a/mission/devices/devicedefinitions/GomspaceDefinitions.h b/mission/devices/devicedefinitions/GomspaceDefinitions.h index bd509239..0fbbc5b0 100644 --- a/mission/devices/devicedefinitions/GomspaceDefinitions.h +++ b/mission/devices/devicedefinitions/GomspaceDefinitions.h @@ -25,7 +25,10 @@ static const uint8_t REBOOT_PORT = 4; static const uint8_t PARAM_PORT = 7; static const uint8_t P60_PORT_GNDWDT_RESET = 9; -/* Device commands are derived from the rparam.h of the gomspace lib */ +/** + * Device commands are derived from the rparam.h of the gomspace lib.. + * IDs above 50 are reserved for device specific commands. + */ static const DeviceCommandId_t PING = 1; //!< [EXPORT] : [COMMAND] static const DeviceCommandId_t NONE = 2; // Set when no command is pending static const DeviceCommandId_t REBOOT = 4; //!< [EXPORT] : [COMMAND]