Merge remote-tracking branch 'origin/develop' into flipped-tmtctest-preproc-define
All checks were successful
EIVE/eive-obsw/pipeline/pr-develop This commit looks good
EIVE/eive-obsw/pipeline/head This commit looks good

This commit is contained in:
2022-01-19 18:10:12 +01:00
206 changed files with 29214 additions and 30589 deletions

View File

@ -1,49 +1,42 @@
#include "ThermalController.h"
#include <mission/devices/devicedefinitions/ThermalSensorPacket.h>
ThermalController::ThermalController(object_id_t objectId):
ExtendedControllerBase(objectId, objects::NO_OBJECT),
thermalControllerSet(objectId) {
ThermalController::ThermalController(object_id_t objectId)
: ExtendedControllerBase(objectId, objects::NO_OBJECT), thermalControllerSet(objectId) {}
ReturnValue_t ThermalController::handleCommandMessage(CommandMessage *message) {
return HasReturnvaluesIF::RETURN_OK;
}
ReturnValue_t ThermalController::handleCommandMessage(
CommandMessage *message) {
return HasReturnvaluesIF::RETURN_OK;
}
void ThermalController::performControlOperation() {}
void ThermalController::performControlOperation() {
}
void ThermalController::handleChangedDataset(sid_t sid,
store_address_t storeId) {
if(sid == sid_t(TSensorDefinitions::ObjIds::TEST_HKB_HANDLER,
TSensorDefinitions::THERMAL_SENSOR_SET_ID)) {
sif::info << "Update registered!" << std::endl;
}
void ThermalController::handleChangedDataset(sid_t sid, store_address_t storeId) {
if (sid == sid_t(TSensorDefinitions::ObjIds::TEST_HKB_HANDLER,
TSensorDefinitions::THERMAL_SENSOR_SET_ID)) {
sif::info << "Update registered!" << std::endl;
}
}
ReturnValue_t ThermalController::initializeAfterTaskCreation() {
ReturnValue_t result =
ExtendedControllerBase::initializeAfterTaskCreation();
if(result != HasReturnvaluesIF::RETURN_OK) {
sif::error << "ThermalController::initializeAfterTaskCreation: Base"
<< " class initialization failed!" << std::endl;
}
HasLocalDataPoolIF* testHkbHandler = ObjectManager::instance()->get<HasLocalDataPoolIF>(
TSensorDefinitions::ObjIds::TEST_HKB_HANDLER);
if(testHkbHandler == nullptr) {
sif::warning << "ThermalController::initializeAfterTaskCreation: Test"
<< " HKB Handler invalid!" << std::endl;
}
// Test normal notifications without data packet first.
testHkbHandler->getHkManagerHandle()->subscribeForSetUpdateMessages(
TSensorDefinitions::THERMAL_SENSOR_SET_ID,
this->getObjectId(), commandQueue->getId(), false);
return result;
ReturnValue_t result = ExtendedControllerBase::initializeAfterTaskCreation();
if (result != HasReturnvaluesIF::RETURN_OK) {
sif::error << "ThermalController::initializeAfterTaskCreation: Base"
<< " class initialization failed!" << std::endl;
}
HasLocalDataPoolIF *testHkbHandler = ObjectManager::instance()->get<HasLocalDataPoolIF>(
TSensorDefinitions::ObjIds::TEST_HKB_HANDLER);
if (testHkbHandler == nullptr) {
sif::warning << "ThermalController::initializeAfterTaskCreation: Test"
<< " HKB Handler invalid!" << std::endl;
}
// Test normal notifications without data packet first.
testHkbHandler->getHkManagerHandle()->subscribeForSetUpdateMessages(
TSensorDefinitions::THERMAL_SENSOR_SET_ID, this->getObjectId(), commandQueue->getId(), false);
return result;
}
ReturnValue_t ThermalController::checkModeCommand(Mode_t mode,
Submode_t submode, uint32_t *msToReachTheMode) {
return HasReturnvaluesIF::RETURN_OK;
ReturnValue_t ThermalController::checkModeCommand(Mode_t mode, Submode_t submode,
uint32_t *msToReachTheMode) {
return HasReturnvaluesIF::RETURN_OK;
}

View File

@ -2,32 +2,30 @@
#define MISSION_CONTROLLER_THERMALCONTROLLER_H_
#include <fsfw/controller/ExtendedControllerBase.h>
#include "ctrldefinitions/ThermalCtrlPackets.h"
class ThermalController : public ExtendedControllerBase {
public:
ThermalController(object_id_t objectId);
class ThermalController: public ExtendedControllerBase {
public:
ThermalController(object_id_t objectId);
private:
private:
// TODO: Add stubs for thermal components. Each device / assembly with one
// or multiple redundant sensors will have a thermal component.
// TODO: Add stubs for thermal components. Each device / assembly with one
// or multiple redundant sensors will have a thermal component.
/** ExtendedControllerBase overrides */
virtual ReturnValue_t handleCommandMessage(CommandMessage *message) override;
/** ExtendedControllerBase overrides */
virtual ReturnValue_t handleCommandMessage(
CommandMessage *message) override;
virtual void performControlOperation() override;
virtual void performControlOperation() override;
virtual ReturnValue_t checkModeCommand(Mode_t mode, Submode_t submode,
uint32_t *msToReachTheMode) override;
virtual ReturnValue_t checkModeCommand(Mode_t mode, Submode_t submode,
uint32_t *msToReachTheMode) override;
ReturnValue_t initializeAfterTaskCreation() override;
ReturnValue_t initializeAfterTaskCreation() override;
void handleChangedDataset(sid_t sid, store_address_t storeId) override;
void handleChangedDataset(sid_t sid, store_address_t storeId) override;
ThermalCtrl::ThermalControllerTemperatureSet thermalControllerSet;
ThermalCtrl::ThermalControllerTemperatureSet thermalControllerSet;
};
#endif /* MISSION_CONTROLLER_THERMALCONTROLLER_H_ */

View File

@ -1,11 +1,6 @@
#include "GenericFactory.h"
#include <OBSWConfig.h>
#include <tmtc/apid.h>
#include <tmtc/pusIds.h>
#include "objects/systemObjectList.h"
#include <fsfw/events/EventManager.h>
#include <fsfw/health/HealthTable.h>
#include <fsfw/internalerror/InternalErrorReporter.h>
@ -13,8 +8,8 @@
#include <fsfw/pus/Service17Test.h>
#include <fsfw/pus/Service1TelecommandVerification.h>
#include <fsfw/pus/Service20ParameterManagement.h>
#include <fsfw/pus/Service3Housekeeping.h>
#include <fsfw/pus/Service2DeviceAccess.h>
#include <fsfw/pus/Service3Housekeeping.h>
#include <fsfw/pus/Service5EventReporting.h>
#include <fsfw/pus/Service8FunctionManagement.h>
#include <fsfw/pus/Service9TimeManagement.h>
@ -23,12 +18,16 @@
#include <fsfw/tcdistribution/PUSDistributor.h>
#include <fsfw/timemanager/TimeStamper.h>
#include <mission/utility/TmFunnel.h>
#include <tmtc/apid.h>
#include <tmtc/pusIds.h>
#include "objects/systemObjectList.h"
#if OBSW_ADD_TCPIP_BRIDGE == 1
#if OBSW_USE_TCP_BRIDGE == 0
// UDP server includes
#include "fsfw/osal/common/UdpTmTcBridge.h"
#include "fsfw/osal/common/UdpTcPollingTask.h"
#include "fsfw/osal/common/UdpTmTcBridge.h"
#else
// TCP server includes
#include "fsfw/osal/common/TcpTmTcBridge.h"
@ -41,78 +40,69 @@
#endif
void ObjectFactory::produceGenericObjects() {
// Framework objects
new EventManager(objects::EVENT_MANAGER);
new HealthTable(objects::HEALTH_TABLE);
new InternalErrorReporter(objects::INTERNAL_ERROR_REPORTER);
new TimeStamper(objects::TIME_STAMPER);
// Framework objects
new EventManager(objects::EVENT_MANAGER);
new HealthTable(objects::HEALTH_TABLE);
new InternalErrorReporter(objects::INTERNAL_ERROR_REPORTER);
new TimeStamper(objects::TIME_STAMPER);
{
PoolManager::LocalPoolConfig poolCfg = {
{300, 16}, {300, 32}, {200, 64}, {200, 128}, {100, 1024}, {10, 2048}
};
new PoolManager(objects::TC_STORE, poolCfg);
}
{
PoolManager::LocalPoolConfig poolCfg = {{300, 16}, {300, 32}, {200, 64},
{200, 128}, {100, 1024}, {10, 2048}};
new PoolManager(objects::TC_STORE, poolCfg);
}
{
PoolManager::LocalPoolConfig poolCfg = {
{300, 16}, {300, 32}, {100, 64}, {100, 128}, {100, 1024}, {10, 2048}
};
new PoolManager(objects::TM_STORE, poolCfg);
}
{
PoolManager::LocalPoolConfig poolCfg = {{300, 16}, {300, 32}, {100, 64},
{100, 128}, {100, 1024}, {10, 2048}};
new PoolManager(objects::TM_STORE, poolCfg);
}
{
PoolManager::LocalPoolConfig poolCfg = {
{ 300, 16 }, { 200, 32 }, { 150, 64 },
{ 150, 128 }, { 100, 256 }, { 50, 512 }, { 50, 1024 }, { 10, 2048 }
};
new PoolManager(objects::IPC_STORE, poolCfg);
}
{
PoolManager::LocalPoolConfig poolCfg = {{300, 16}, {200, 32}, {150, 64}, {150, 128},
{100, 256}, {50, 512}, {50, 1024}, {10, 2048}};
new PoolManager(objects::IPC_STORE, poolCfg);
}
new CCSDSDistributor(apid::EIVE_OBSW, objects::CCSDS_PACKET_DISTRIBUTOR);
new PUSDistributor(apid::EIVE_OBSW, objects::PUS_PACKET_DISTRIBUTOR,
objects::CCSDS_PACKET_DISTRIBUTOR);
new CCSDSDistributor(apid::EIVE_OBSW, objects::CCSDS_PACKET_DISTRIBUTOR);
new PUSDistributor(apid::EIVE_OBSW, objects::PUS_PACKET_DISTRIBUTOR,
objects::CCSDS_PACKET_DISTRIBUTOR);
// Every TM packet goes through this funnel
new TmFunnel(objects::TM_FUNNEL);
// Every TM packet goes through this funnel
new TmFunnel(objects::TM_FUNNEL);
// PUS service stack
new Service1TelecommandVerification(objects::PUS_SERVICE_1_VERIFICATION,
apid::EIVE_OBSW, pus::PUS_SERVICE_1, objects::TM_FUNNEL, 20);
new Service2DeviceAccess(objects::PUS_SERVICE_2_DEVICE_ACCESS,
apid::EIVE_OBSW, pus::PUS_SERVICE_2, 3, 10);
new Service3Housekeeping(objects::PUS_SERVICE_3_HOUSEKEEPING,
apid::EIVE_OBSW, pus::PUS_SERVICE_3);
new Service5EventReporting(objects::PUS_SERVICE_5_EVENT_REPORTING,
apid::EIVE_OBSW, pus::PUS_SERVICE_5, 50);
new Service8FunctionManagement(objects::PUS_SERVICE_8_FUNCTION_MGMT,
apid::EIVE_OBSW, pus::PUS_SERVICE_8, 3, 60);
new Service9TimeManagement(objects::PUS_SERVICE_9_TIME_MGMT,
apid::EIVE_OBSW, pus::PUS_SERVICE_9);
new Service17Test(objects::PUS_SERVICE_17_TEST, apid::EIVE_OBSW,
pus::PUS_SERVICE_17);
new Service20ParameterManagement(objects::PUS_SERVICE_20_PARAMETERS, apid::EIVE_OBSW,
pus::PUS_SERVICE_20);
new CService200ModeCommanding(objects::PUS_SERVICE_200_MODE_MGMT,
apid::EIVE_OBSW, pus::PUS_SERVICE_200);
// PUS service stack
new Service1TelecommandVerification(objects::PUS_SERVICE_1_VERIFICATION, apid::EIVE_OBSW,
pus::PUS_SERVICE_1, objects::TM_FUNNEL, 20);
new Service2DeviceAccess(objects::PUS_SERVICE_2_DEVICE_ACCESS, apid::EIVE_OBSW,
pus::PUS_SERVICE_2, 3, 10);
new Service3Housekeeping(objects::PUS_SERVICE_3_HOUSEKEEPING, apid::EIVE_OBSW,
pus::PUS_SERVICE_3);
new Service5EventReporting(objects::PUS_SERVICE_5_EVENT_REPORTING, apid::EIVE_OBSW,
pus::PUS_SERVICE_5, 50);
new Service8FunctionManagement(objects::PUS_SERVICE_8_FUNCTION_MGMT, apid::EIVE_OBSW,
pus::PUS_SERVICE_8, 3, 60);
new Service9TimeManagement(objects::PUS_SERVICE_9_TIME_MGMT, apid::EIVE_OBSW, pus::PUS_SERVICE_9);
new Service17Test(objects::PUS_SERVICE_17_TEST, apid::EIVE_OBSW, pus::PUS_SERVICE_17);
new Service20ParameterManagement(objects::PUS_SERVICE_20_PARAMETERS, apid::EIVE_OBSW,
pus::PUS_SERVICE_20);
new CService200ModeCommanding(objects::PUS_SERVICE_200_MODE_MGMT, apid::EIVE_OBSW,
pus::PUS_SERVICE_200);
#if OBSW_ADD_TCPIP_BRIDGE == 1
#if OBSW_USE_TCP_BRIDGE == 0
auto tmtcBridge = new UdpTmTcBridge(objects::TMTC_BRIDGE, objects::CCSDS_PACKET_DISTRIBUTOR);
new UdpTcPollingTask(objects::TMTC_POLLING_TASK, objects::TMTC_BRIDGE);
sif::info << "Created UDP server for TMTC commanding with listener port " <<
udpBridge->getUdpPort() << std::endl;
auto tmtcBridge = new UdpTmTcBridge(objects::TMTC_BRIDGE, objects::CCSDS_PACKET_DISTRIBUTOR);
new UdpTcPollingTask(objects::TMTC_POLLING_TASK, objects::TMTC_BRIDGE);
sif::info << "Created UDP server for TMTC commanding with listener port "
<< udpBridge->getUdpPort() << std::endl;
#else
auto tmtcBridge = new TcpTmTcBridge(objects::TMTC_BRIDGE, objects::CCSDS_PACKET_DISTRIBUTOR);
auto tcpServer = new TcpTmTcServer(objects::TMTC_POLLING_TASK, objects::TMTC_BRIDGE);
// TCP is stream based. Use packet ID as start marker when parsing for space packets
tcpServer->setSpacePacketParsingOptions({common::PUS_PACKET_ID});
sif::info << "Created TCP server for TMTC commanding with listener port "
auto tmtcBridge = new TcpTmTcBridge(objects::TMTC_BRIDGE, objects::CCSDS_PACKET_DISTRIBUTOR);
auto tcpServer = new TcpTmTcServer(objects::TMTC_POLLING_TASK, objects::TMTC_BRIDGE);
// TCP is stream based. Use packet ID as start marker when parsing for space packets
tcpServer->setSpacePacketParsingOptions({common::PUS_PACKET_ID});
sif::info << "Created TCP server for TMTC commanding with listener port "
<< tcpServer->getTcpPort() << std::endl;
#endif /* OBSW_USE_TMTC_TCP_BRIDGE == 0 */
tmtcBridge->setMaxNumberOfPacketsStored(70);
tmtcBridge->setMaxNumberOfPacketsStored(70);
#endif /* OBSW_ADD_TCPIP_BRIDGE == 1 */
}

View File

@ -5,8 +5,6 @@ namespace ObjectFactory {
void produceGenericObjects();
}
#endif /* MISSION_CORE_GENERICFACTORY_H_ */

View File

@ -1,308 +1,309 @@
#include "ACUHandler.h"
#include "OBSWConfig.h"
ACUHandler::ACUHandler(object_id_t objectId, object_id_t comIF, CookieIF * comCookie) :
GomspaceDeviceHandler(objectId, comIF, comCookie, ACU::MAX_CONFIGTABLE_ADDRESS,
ACU::MAX_HKTABLE_ADDRESS, ACU::HK_TABLE_REPLY_SIZE, &acuHkTableDataset), acuHkTableDataset(
this) {
}
ACUHandler::ACUHandler(object_id_t objectId, object_id_t comIF, CookieIF *comCookie)
: GomspaceDeviceHandler(objectId, comIF, comCookie, ACU::MAX_CONFIGTABLE_ADDRESS,
ACU::MAX_HKTABLE_ADDRESS, ACU::HK_TABLE_REPLY_SIZE, &acuHkTableDataset),
acuHkTableDataset(this) {}
ACUHandler::~ACUHandler() {
}
ACUHandler::~ACUHandler() {}
ReturnValue_t ACUHandler::buildNormalDeviceCommand(
DeviceCommandId_t * id) {
*id = GOMSPACE::REQUEST_HK_TABLE;
return buildCommandFromCommand(*id, NULL, 0);
ReturnValue_t ACUHandler::buildNormalDeviceCommand(DeviceCommandId_t *id) {
*id = GOMSPACE::REQUEST_HK_TABLE;
return buildCommandFromCommand(*id, NULL, 0);
}
void ACUHandler::fillCommandAndReplyMap() {
GomspaceDeviceHandler::fillCommandAndReplyMap();
this->insertInCommandMap(PRINT_CHANNEL_STATS);
GomspaceDeviceHandler::fillCommandAndReplyMap();
this->insertInCommandMap(PRINT_CHANNEL_STATS);
}
void ACUHandler::letChildHandleHkReply(DeviceCommandId_t id, const uint8_t *packet) {
parseHkTableReply(packet);
handleDeviceTM(&acuHkTableDataset, id, true);
parseHkTableReply(packet);
handleDeviceTM(&acuHkTableDataset, id, true);
#if OBSW_ENHANCED_PRINTOUT == 1 && OBSW_DEBUG_ACU == 1
acuHkTableDataset.read();
float temperatureC_1 = acuHkTableDataset.temperature1.value * 0.1;
float temperatureC_2 = acuHkTableDataset.temperature2.value * 0.1;
float temperatureC_3 = acuHkTableDataset.temperature3.value * 0.1;
sif::info << "ACU: Temperature 1: " << temperatureC_1 << " °C" << std::endl;
sif::info << "ACU: Temperature 2: " << temperatureC_2 << " °C" << std::endl;
sif::info << "ACU: Temperature 3: " << temperatureC_3 << " °C" << std::endl;
sif::info << "ACU: Ground Watchdog Timer Count: "
<< acuHkTableDataset.wdtCntGnd.value << std::endl;
sif::info << "ACU: Ground watchdog timer, seconds left before reboot: "
<< acuHkTableDataset.wdtGndLeft.value << std::endl;
acuHkTableDataset.commit();
acuHkTableDataset.read();
float temperatureC_1 = acuHkTableDataset.temperature1.value * 0.1;
float temperatureC_2 = acuHkTableDataset.temperature2.value * 0.1;
float temperatureC_3 = acuHkTableDataset.temperature3.value * 0.1;
sif::info << "ACU: Temperature 1: " << temperatureC_1 << " °C" << std::endl;
sif::info << "ACU: Temperature 2: " << temperatureC_2 << " °C" << std::endl;
sif::info << "ACU: Temperature 3: " << temperatureC_3 << " °C" << std::endl;
sif::info << "ACU: Ground Watchdog Timer Count: " << acuHkTableDataset.wdtCntGnd.value
<< std::endl;
sif::info << "ACU: Ground watchdog timer, seconds left before reboot: "
<< acuHkTableDataset.wdtGndLeft.value << std::endl;
acuHkTableDataset.commit();
#endif
}
void ACUHandler::parseHkTableReply(const uint8_t *packet) {
uint16_t dataOffset = 0;
acuHkTableDataset.read();
dataOffset += 12;
acuHkTableDataset.currentInChannel0 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
acuHkTableDataset.currentInChannel1 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
acuHkTableDataset.currentInChannel2 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
acuHkTableDataset.currentInChannel3 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
acuHkTableDataset.currentInChannel4 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
acuHkTableDataset.currentInChannel5 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
uint16_t dataOffset = 0;
acuHkTableDataset.read();
dataOffset += 12;
acuHkTableDataset.currentInChannel0 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
acuHkTableDataset.currentInChannel1 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
acuHkTableDataset.currentInChannel2 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
acuHkTableDataset.currentInChannel3 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
acuHkTableDataset.currentInChannel4 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
acuHkTableDataset.currentInChannel5 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
acuHkTableDataset.voltageInChannel0 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
acuHkTableDataset.voltageInChannel1 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
acuHkTableDataset.voltageInChannel2 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
acuHkTableDataset.voltageInChannel3 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
acuHkTableDataset.voltageInChannel4 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
acuHkTableDataset.voltageInChannel5 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
acuHkTableDataset.voltageInChannel0 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
acuHkTableDataset.voltageInChannel1 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
acuHkTableDataset.voltageInChannel2 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
acuHkTableDataset.voltageInChannel3 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
acuHkTableDataset.voltageInChannel4 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
acuHkTableDataset.voltageInChannel5 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
acuHkTableDataset.vcc = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
acuHkTableDataset.vbat = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
acuHkTableDataset.vcc = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
acuHkTableDataset.vbat = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
acuHkTableDataset.temperature1 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
acuHkTableDataset.temperature2 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
acuHkTableDataset.temperature3 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
acuHkTableDataset.temperature1 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
acuHkTableDataset.temperature2 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
acuHkTableDataset.temperature3 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
acuHkTableDataset.mpptMode = *(packet + dataOffset);
dataOffset += 3;
acuHkTableDataset.mpptMode = *(packet + dataOffset);
dataOffset += 3;
acuHkTableDataset.vboostInChannel0 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
acuHkTableDataset.vboostInChannel1 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
acuHkTableDataset.vboostInChannel2 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
acuHkTableDataset.vboostInChannel3 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
acuHkTableDataset.vboostInChannel4 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
acuHkTableDataset.vboostInChannel5 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
acuHkTableDataset.vboostInChannel0 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
acuHkTableDataset.vboostInChannel1 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
acuHkTableDataset.vboostInChannel2 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
acuHkTableDataset.vboostInChannel3 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
acuHkTableDataset.vboostInChannel4 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
acuHkTableDataset.vboostInChannel5 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
acuHkTableDataset.powerInChannel0 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
acuHkTableDataset.powerInChannel1 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
acuHkTableDataset.powerInChannel2 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
acuHkTableDataset.powerInChannel3 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
acuHkTableDataset.powerInChannel4 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
acuHkTableDataset.powerInChannel5 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
acuHkTableDataset.powerInChannel0 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
acuHkTableDataset.powerInChannel1 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
acuHkTableDataset.powerInChannel2 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
acuHkTableDataset.powerInChannel3 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
acuHkTableDataset.powerInChannel4 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
acuHkTableDataset.powerInChannel5 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
acuHkTableDataset.dac0Enable = *(packet + dataOffset);
dataOffset += 3;
acuHkTableDataset.dac1Enable = *(packet + dataOffset);
dataOffset += 3;
acuHkTableDataset.dac2Enable = *(packet + dataOffset);
dataOffset += 3;
acuHkTableDataset.dac0Enable = *(packet + dataOffset);
dataOffset += 3;
acuHkTableDataset.dac1Enable = *(packet + dataOffset);
dataOffset += 3;
acuHkTableDataset.dac2Enable = *(packet + dataOffset);
dataOffset += 3;
acuHkTableDataset.dacRawChannelVal0 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
acuHkTableDataset.dacRawChannelVal1 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
acuHkTableDataset.dacRawChannelVal2 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
acuHkTableDataset.dacRawChannelVal3 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
acuHkTableDataset.dacRawChannelVal4 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
acuHkTableDataset.dacRawChannelVal5 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
acuHkTableDataset.dacRawChannelVal0 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
acuHkTableDataset.dacRawChannelVal1 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
acuHkTableDataset.dacRawChannelVal2 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
acuHkTableDataset.dacRawChannelVal3 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
acuHkTableDataset.dacRawChannelVal4 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
acuHkTableDataset.dacRawChannelVal5 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
acuHkTableDataset.bootCause = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3);
dataOffset += 6;
acuHkTableDataset.bootcnt = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3);
dataOffset += 6;
acuHkTableDataset.uptime = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3);
dataOffset += 6;
acuHkTableDataset.resetCause = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
acuHkTableDataset.mpptTime = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
/* +12 because here starts the second csp packet */
dataOffset += 2 + 12;
acuHkTableDataset.bootCause = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 |
*(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3);
dataOffset += 6;
acuHkTableDataset.bootcnt = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 |
*(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3);
dataOffset += 6;
acuHkTableDataset.uptime = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 |
*(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3);
dataOffset += 6;
acuHkTableDataset.resetCause = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
acuHkTableDataset.mpptTime = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
/* +12 because here starts the second csp packet */
dataOffset += 2 + 12;
acuHkTableDataset.mpptPeriod = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
acuHkTableDataset.mpptPeriod = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
acuHkTableDataset.device0 = *(packet + dataOffset);
dataOffset += 3;
acuHkTableDataset.device1 = *(packet + dataOffset);
dataOffset += 3;
acuHkTableDataset.device2 = *(packet + dataOffset);
dataOffset += 3;
acuHkTableDataset.device3 = *(packet + dataOffset);
dataOffset += 3;
acuHkTableDataset.device4 = *(packet + dataOffset);
dataOffset += 3;
acuHkTableDataset.device5 = *(packet + dataOffset);
dataOffset += 3;
acuHkTableDataset.device6 = *(packet + dataOffset);
dataOffset += 3;
acuHkTableDataset.device7 = *(packet + dataOffset);
dataOffset += 3;
acuHkTableDataset.device0 = *(packet + dataOffset);
dataOffset += 3;
acuHkTableDataset.device1 = *(packet + dataOffset);
dataOffset += 3;
acuHkTableDataset.device2 = *(packet + dataOffset);
dataOffset += 3;
acuHkTableDataset.device3 = *(packet + dataOffset);
dataOffset += 3;
acuHkTableDataset.device4 = *(packet + dataOffset);
dataOffset += 3;
acuHkTableDataset.device5 = *(packet + dataOffset);
dataOffset += 3;
acuHkTableDataset.device6 = *(packet + dataOffset);
dataOffset += 3;
acuHkTableDataset.device7 = *(packet + dataOffset);
dataOffset += 3;
acuHkTableDataset.device0Status = *(packet + dataOffset);
dataOffset += 3;
acuHkTableDataset.device1Status = *(packet + dataOffset);
dataOffset += 3;
acuHkTableDataset.device2Status = *(packet + dataOffset);
dataOffset += 3;
acuHkTableDataset.device3Status = *(packet + dataOffset);
dataOffset += 3;
acuHkTableDataset.device4Status = *(packet + dataOffset);
dataOffset += 3;
acuHkTableDataset.device5Status = *(packet + dataOffset);
dataOffset += 3;
acuHkTableDataset.device6Status = *(packet + dataOffset);
dataOffset += 3;
acuHkTableDataset.device7Status = *(packet + dataOffset);
dataOffset += 3;
acuHkTableDataset.device0Status = *(packet + dataOffset);
dataOffset += 3;
acuHkTableDataset.device1Status = *(packet + dataOffset);
dataOffset += 3;
acuHkTableDataset.device2Status = *(packet + dataOffset);
dataOffset += 3;
acuHkTableDataset.device3Status = *(packet + dataOffset);
dataOffset += 3;
acuHkTableDataset.device4Status = *(packet + dataOffset);
dataOffset += 3;
acuHkTableDataset.device5Status = *(packet + dataOffset);
dataOffset += 3;
acuHkTableDataset.device6Status = *(packet + dataOffset);
dataOffset += 3;
acuHkTableDataset.device7Status = *(packet + dataOffset);
dataOffset += 3;
acuHkTableDataset.wdtCntGnd = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3);
dataOffset += 6;
acuHkTableDataset.wdtGndLeft = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3);
dataOffset += 6;
acuHkTableDataset.wdtCntGnd = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 |
*(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3);
dataOffset += 6;
acuHkTableDataset.wdtGndLeft = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 |
*(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3);
dataOffset += 6;
acuHkTableDataset.commit();
acuHkTableDataset.commit();
}
ReturnValue_t ACUHandler::initializeLocalDataPool(
localpool::DataPool &localDataPoolMap, LocalDataPoolManager &poolManager) {
ReturnValue_t ACUHandler::initializeLocalDataPool(localpool::DataPool &localDataPoolMap,
LocalDataPoolManager &poolManager) {
localDataPoolMap.emplace(P60System::ACU_CURRENT_IN_CHANNEL0, new PoolEntry<int16_t>({0}));
localDataPoolMap.emplace(P60System::ACU_CURRENT_IN_CHANNEL1, new PoolEntry<int16_t>({0}));
localDataPoolMap.emplace(P60System::ACU_CURRENT_IN_CHANNEL2, new PoolEntry<int16_t>({0}));
localDataPoolMap.emplace(P60System::ACU_CURRENT_IN_CHANNEL3, new PoolEntry<int16_t>({0}));
localDataPoolMap.emplace(P60System::ACU_CURRENT_IN_CHANNEL4, new PoolEntry<int16_t>({0}));
localDataPoolMap.emplace(P60System::ACU_CURRENT_IN_CHANNEL5, new PoolEntry<int16_t>({0}));
localDataPoolMap.emplace(P60System::ACU_CURRENT_IN_CHANNEL0, new PoolEntry<int16_t>( { 0 }));
localDataPoolMap.emplace(P60System::ACU_CURRENT_IN_CHANNEL1, new PoolEntry<int16_t>( { 0 }));
localDataPoolMap.emplace(P60System::ACU_CURRENT_IN_CHANNEL2, new PoolEntry<int16_t>( { 0 }));
localDataPoolMap.emplace(P60System::ACU_CURRENT_IN_CHANNEL3, new PoolEntry<int16_t>( { 0 }));
localDataPoolMap.emplace(P60System::ACU_CURRENT_IN_CHANNEL4, new PoolEntry<int16_t>( { 0 }));
localDataPoolMap.emplace(P60System::ACU_CURRENT_IN_CHANNEL5, new PoolEntry<int16_t>( { 0 }));
localDataPoolMap.emplace(P60System::ACU_VOLTAGE_IN_CHANNEL0, new PoolEntry<uint16_t>({0}));
localDataPoolMap.emplace(P60System::ACU_VOLTAGE_IN_CHANNEL1, new PoolEntry<uint16_t>({0}));
localDataPoolMap.emplace(P60System::ACU_VOLTAGE_IN_CHANNEL2, new PoolEntry<uint16_t>({0}));
localDataPoolMap.emplace(P60System::ACU_VOLTAGE_IN_CHANNEL3, new PoolEntry<uint16_t>({0}));
localDataPoolMap.emplace(P60System::ACU_VOLTAGE_IN_CHANNEL4, new PoolEntry<uint16_t>({0}));
localDataPoolMap.emplace(P60System::ACU_VOLTAGE_IN_CHANNEL5, new PoolEntry<uint16_t>({0}));
localDataPoolMap.emplace(P60System::ACU_VOLTAGE_IN_CHANNEL0, new PoolEntry<uint16_t>( { 0 }));
localDataPoolMap.emplace(P60System::ACU_VOLTAGE_IN_CHANNEL1, new PoolEntry<uint16_t>( { 0 }));
localDataPoolMap.emplace(P60System::ACU_VOLTAGE_IN_CHANNEL2, new PoolEntry<uint16_t>( { 0 }));
localDataPoolMap.emplace(P60System::ACU_VOLTAGE_IN_CHANNEL3, new PoolEntry<uint16_t>( { 0 }));
localDataPoolMap.emplace(P60System::ACU_VOLTAGE_IN_CHANNEL4, new PoolEntry<uint16_t>( { 0 }));
localDataPoolMap.emplace(P60System::ACU_VOLTAGE_IN_CHANNEL5, new PoolEntry<uint16_t>( { 0 }));
localDataPoolMap.emplace(P60System::ACU_VCC, new PoolEntry<uint16_t>({0}));
localDataPoolMap.emplace(P60System::ACU_VBAT, new PoolEntry<uint16_t>({0}));
localDataPoolMap.emplace(P60System::ACU_VCC, new PoolEntry<uint16_t>( { 0 }));
localDataPoolMap.emplace(P60System::ACU_VBAT, new PoolEntry<uint16_t>( { 0 }));
localDataPoolMap.emplace(P60System::ACU_TEMPERATURE_1, new PoolEntry<int16_t>({0}));
localDataPoolMap.emplace(P60System::ACU_TEMPERATURE_2, new PoolEntry<int16_t>({0}));
localDataPoolMap.emplace(P60System::ACU_TEMPERATURE_3, new PoolEntry<int16_t>({0}));
localDataPoolMap.emplace(P60System::ACU_TEMPERATURE_1, new PoolEntry<int16_t>( { 0 }));
localDataPoolMap.emplace(P60System::ACU_TEMPERATURE_2, new PoolEntry<int16_t>( { 0 }));
localDataPoolMap.emplace(P60System::ACU_TEMPERATURE_3, new PoolEntry<int16_t>( { 0 }));
localDataPoolMap.emplace(P60System::ACU_MPPT_MODE, new PoolEntry<uint8_t>({0}));
localDataPoolMap.emplace(P60System::ACU_MPPT_MODE, new PoolEntry<uint8_t>( { 0 }));
localDataPoolMap.emplace(P60System::ACU_VBOOST_CHANNEL0, new PoolEntry<uint16_t>({0}));
localDataPoolMap.emplace(P60System::ACU_VBOOST_CHANNEL1, new PoolEntry<uint16_t>({0}));
localDataPoolMap.emplace(P60System::ACU_VBOOST_CHANNEL2, new PoolEntry<uint16_t>({0}));
localDataPoolMap.emplace(P60System::ACU_VBOOST_CHANNEL3, new PoolEntry<uint16_t>({0}));
localDataPoolMap.emplace(P60System::ACU_VBOOST_CHANNEL4, new PoolEntry<uint16_t>({0}));
localDataPoolMap.emplace(P60System::ACU_VBOOST_CHANNEL5, new PoolEntry<uint16_t>({0}));
localDataPoolMap.emplace(P60System::ACU_VBOOST_CHANNEL0, new PoolEntry<uint16_t>( { 0 }));
localDataPoolMap.emplace(P60System::ACU_VBOOST_CHANNEL1, new PoolEntry<uint16_t>( { 0 }));
localDataPoolMap.emplace(P60System::ACU_VBOOST_CHANNEL2, new PoolEntry<uint16_t>( { 0 }));
localDataPoolMap.emplace(P60System::ACU_VBOOST_CHANNEL3, new PoolEntry<uint16_t>( { 0 }));
localDataPoolMap.emplace(P60System::ACU_VBOOST_CHANNEL4, new PoolEntry<uint16_t>( { 0 }));
localDataPoolMap.emplace(P60System::ACU_VBOOST_CHANNEL5, new PoolEntry<uint16_t>( { 0 }));
localDataPoolMap.emplace(P60System::ACU_POWER_CHANNEL0, new PoolEntry<uint16_t>({0}));
localDataPoolMap.emplace(P60System::ACU_POWER_CHANNEL1, new PoolEntry<uint16_t>({0}));
localDataPoolMap.emplace(P60System::ACU_POWER_CHANNEL2, new PoolEntry<uint16_t>({0}));
localDataPoolMap.emplace(P60System::ACU_POWER_CHANNEL3, new PoolEntry<uint16_t>({0}));
localDataPoolMap.emplace(P60System::ACU_POWER_CHANNEL4, new PoolEntry<uint16_t>({0}));
localDataPoolMap.emplace(P60System::ACU_POWER_CHANNEL5, new PoolEntry<uint16_t>({0}));
localDataPoolMap.emplace(P60System::ACU_POWER_CHANNEL0, new PoolEntry<uint16_t>( { 0 }));
localDataPoolMap.emplace(P60System::ACU_POWER_CHANNEL1, new PoolEntry<uint16_t>( { 0 }));
localDataPoolMap.emplace(P60System::ACU_POWER_CHANNEL2, new PoolEntry<uint16_t>( { 0 }));
localDataPoolMap.emplace(P60System::ACU_POWER_CHANNEL3, new PoolEntry<uint16_t>( { 0 }));
localDataPoolMap.emplace(P60System::ACU_POWER_CHANNEL4, new PoolEntry<uint16_t>( { 0 }));
localDataPoolMap.emplace(P60System::ACU_POWER_CHANNEL5, new PoolEntry<uint16_t>( { 0 }));
localDataPoolMap.emplace(P60System::ACU_DAC_EN_0, new PoolEntry<uint8_t>({0}));
localDataPoolMap.emplace(P60System::ACU_DAC_EN_1, new PoolEntry<uint8_t>({0}));
localDataPoolMap.emplace(P60System::ACU_DAC_EN_2, new PoolEntry<uint8_t>({0}));
localDataPoolMap.emplace(P60System::ACU_DAC_EN_0, new PoolEntry<uint8_t>( { 0 }));
localDataPoolMap.emplace(P60System::ACU_DAC_EN_1, new PoolEntry<uint8_t>( { 0 }));
localDataPoolMap.emplace(P60System::ACU_DAC_EN_2, new PoolEntry<uint8_t>( { 0 }));
localDataPoolMap.emplace(P60System::ACU_DAC_RAW_0, new PoolEntry<uint16_t>({0}));
localDataPoolMap.emplace(P60System::ACU_DAC_RAW_1, new PoolEntry<uint16_t>({0}));
localDataPoolMap.emplace(P60System::ACU_DAC_RAW_2, new PoolEntry<uint16_t>({0}));
localDataPoolMap.emplace(P60System::ACU_DAC_RAW_3, new PoolEntry<uint16_t>({0}));
localDataPoolMap.emplace(P60System::ACU_DAC_RAW_4, new PoolEntry<uint16_t>({0}));
localDataPoolMap.emplace(P60System::ACU_DAC_RAW_5, new PoolEntry<uint16_t>({0}));
localDataPoolMap.emplace(P60System::ACU_DAC_RAW_0, new PoolEntry<uint16_t>( { 0 }));
localDataPoolMap.emplace(P60System::ACU_DAC_RAW_1, new PoolEntry<uint16_t>( { 0 }));
localDataPoolMap.emplace(P60System::ACU_DAC_RAW_2, new PoolEntry<uint16_t>( { 0 }));
localDataPoolMap.emplace(P60System::ACU_DAC_RAW_3, new PoolEntry<uint16_t>( { 0 }));
localDataPoolMap.emplace(P60System::ACU_DAC_RAW_4, new PoolEntry<uint16_t>( { 0 }));
localDataPoolMap.emplace(P60System::ACU_DAC_RAW_5, new PoolEntry<uint16_t>( { 0 }));
localDataPoolMap.emplace(P60System::ACU_BOOTCAUSE, new PoolEntry<uint32_t>({0}));
localDataPoolMap.emplace(P60System::ACU_BOOTCNT, new PoolEntry<uint32_t>({0}));
localDataPoolMap.emplace(P60System::ACU_UPTIME, new PoolEntry<uint32_t>({0}));
localDataPoolMap.emplace(P60System::ACU_RESET_CAUSE, new PoolEntry<uint16_t>({0}));
localDataPoolMap.emplace(P60System::ACU_MPPT_TIME, new PoolEntry<uint16_t>({0}));
localDataPoolMap.emplace(P60System::ACU_MPPT_PERIOD, new PoolEntry<uint16_t>({0}));
localDataPoolMap.emplace(P60System::ACU_BOOTCAUSE, new PoolEntry<uint32_t>( { 0 }));
localDataPoolMap.emplace(P60System::ACU_BOOTCNT, new PoolEntry<uint32_t>( { 0 }));
localDataPoolMap.emplace(P60System::ACU_UPTIME, new PoolEntry<uint32_t>( { 0 }));
localDataPoolMap.emplace(P60System::ACU_RESET_CAUSE, new PoolEntry<uint16_t>( { 0 }));
localDataPoolMap.emplace(P60System::ACU_MPPT_TIME, new PoolEntry<uint16_t>( { 0 }));
localDataPoolMap.emplace(P60System::ACU_MPPT_PERIOD, new PoolEntry<uint16_t>( { 0 }));
localDataPoolMap.emplace(P60System::ACU_DEVICE_0, new PoolEntry<uint8_t>({0}));
localDataPoolMap.emplace(P60System::ACU_DEVICE_1, new PoolEntry<uint8_t>({0}));
localDataPoolMap.emplace(P60System::ACU_DEVICE_2, new PoolEntry<uint8_t>({0}));
localDataPoolMap.emplace(P60System::ACU_DEVICE_3, new PoolEntry<uint8_t>({0}));
localDataPoolMap.emplace(P60System::ACU_DEVICE_4, new PoolEntry<uint8_t>({0}));
localDataPoolMap.emplace(P60System::ACU_DEVICE_5, new PoolEntry<uint8_t>({0}));
localDataPoolMap.emplace(P60System::ACU_DEVICE_6, new PoolEntry<uint8_t>({0}));
localDataPoolMap.emplace(P60System::ACU_DEVICE_7, new PoolEntry<uint8_t>({0}));
localDataPoolMap.emplace(P60System::ACU_DEVICE_0, new PoolEntry<uint8_t>( { 0 }));
localDataPoolMap.emplace(P60System::ACU_DEVICE_1, new PoolEntry<uint8_t>( { 0 }));
localDataPoolMap.emplace(P60System::ACU_DEVICE_2, new PoolEntry<uint8_t>( { 0 }));
localDataPoolMap.emplace(P60System::ACU_DEVICE_3, new PoolEntry<uint8_t>( { 0 }));
localDataPoolMap.emplace(P60System::ACU_DEVICE_4, new PoolEntry<uint8_t>( { 0 }));
localDataPoolMap.emplace(P60System::ACU_DEVICE_5, new PoolEntry<uint8_t>( { 0 }));
localDataPoolMap.emplace(P60System::ACU_DEVICE_6, new PoolEntry<uint8_t>( { 0 }));
localDataPoolMap.emplace(P60System::ACU_DEVICE_7, new PoolEntry<uint8_t>( { 0 }));
localDataPoolMap.emplace(P60System::ACU_DEVICE_0_STATUS, new PoolEntry<uint8_t>({0}));
localDataPoolMap.emplace(P60System::ACU_DEVICE_1_STATUS, new PoolEntry<uint8_t>({0}));
localDataPoolMap.emplace(P60System::ACU_DEVICE_2_STATUS, new PoolEntry<uint8_t>({0}));
localDataPoolMap.emplace(P60System::ACU_DEVICE_3_STATUS, new PoolEntry<uint8_t>({0}));
localDataPoolMap.emplace(P60System::ACU_DEVICE_4_STATUS, new PoolEntry<uint8_t>({0}));
localDataPoolMap.emplace(P60System::ACU_DEVICE_5_STATUS, new PoolEntry<uint8_t>({0}));
localDataPoolMap.emplace(P60System::ACU_DEVICE_6_STATUS, new PoolEntry<uint8_t>({0}));
localDataPoolMap.emplace(P60System::ACU_DEVICE_7_STATUS, new PoolEntry<uint8_t>({0}));
localDataPoolMap.emplace(P60System::ACU_DEVICE_0_STATUS, new PoolEntry<uint8_t>( { 0 }));
localDataPoolMap.emplace(P60System::ACU_DEVICE_1_STATUS, new PoolEntry<uint8_t>( { 0 }));
localDataPoolMap.emplace(P60System::ACU_DEVICE_2_STATUS, new PoolEntry<uint8_t>( { 0 }));
localDataPoolMap.emplace(P60System::ACU_DEVICE_3_STATUS, new PoolEntry<uint8_t>( { 0 }));
localDataPoolMap.emplace(P60System::ACU_DEVICE_4_STATUS, new PoolEntry<uint8_t>( { 0 }));
localDataPoolMap.emplace(P60System::ACU_DEVICE_5_STATUS, new PoolEntry<uint8_t>( { 0 }));
localDataPoolMap.emplace(P60System::ACU_DEVICE_6_STATUS, new PoolEntry<uint8_t>( { 0 }));
localDataPoolMap.emplace(P60System::ACU_DEVICE_7_STATUS, new PoolEntry<uint8_t>( { 0 }));
localDataPoolMap.emplace(P60System::ACU_WDT_CNT_GND, new PoolEntry<uint32_t>({0}));
localDataPoolMap.emplace(P60System::ACU_WDT_GND_LEFT, new PoolEntry<uint32_t>({0}));
localDataPoolMap.emplace(P60System::ACU_WDT_CNT_GND, new PoolEntry<uint32_t>( { 0 }));
localDataPoolMap.emplace(P60System::ACU_WDT_GND_LEFT, new PoolEntry<uint32_t>( { 0 }));
return HasReturnvaluesIF::RETURN_OK;
return HasReturnvaluesIF::RETURN_OK;
}
ReturnValue_t ACUHandler::deviceSpecificCommand(DeviceCommandId_t cmd) {
switch(cmd) {
switch (cmd) {
case PRINT_CHANNEL_STATS: {
printChannelStats();
return RETURN_OK;
printChannelStats();
return RETURN_OK;
}
default: {
return DeviceHandlerIF::COMMAND_NOT_IMPLEMENTED;
}
return DeviceHandlerIF::COMMAND_NOT_IMPLEMENTED;
}
}
}
void ACUHandler::printChannelStats() {
PoolReadGuard pg(&acuHkTableDataset);
sif::info << "ACU Info: Current [mA], Voltage [mV]" << std::endl;
sif::info << std::setw(8) << std::left << "Ch0" << std::dec << "| " <<
static_cast<unsigned int>(acuHkTableDataset.currentInChannel0.value) <<
std::setw(15) << std::right << acuHkTableDataset.voltageInChannel0.value << std::endl;
sif::info << std::setw(8) << std::left << "Ch1" << std::dec << "| " <<
static_cast<unsigned int>(acuHkTableDataset.currentInChannel1.value) <<
std::setw(15) << std::right << acuHkTableDataset.voltageInChannel1.value << std::endl;
sif::info << std::setw(8) << std::left << "Ch2" << std::dec << "| " <<
static_cast<unsigned int>(acuHkTableDataset.currentInChannel2.value) <<
std::setw(15) << std::right << acuHkTableDataset.voltageInChannel2.value << std::endl;
sif::info << std::setw(8) << std::left << "Ch3" << std::dec << "| " <<
static_cast<unsigned int>(acuHkTableDataset.currentInChannel3.value) <<
std::setw(15) << std::right << acuHkTableDataset.voltageInChannel3.value << std::endl;
sif::info << std::setw(8) << std::left << "Ch4" << std::dec << "| " <<
static_cast<unsigned int>(acuHkTableDataset.currentInChannel4.value) <<
std::setw(15) << std::right << acuHkTableDataset.voltageInChannel4.value << std::endl;
sif::info << std::setw(8) << std::left << "Ch5" << std::dec << "| " <<
static_cast<unsigned int>(acuHkTableDataset.currentInChannel5.value) <<
std::setw(15) << std::right << acuHkTableDataset.voltageInChannel5.value << std::endl;
PoolReadGuard pg(&acuHkTableDataset);
sif::info << "ACU Info: Current [mA], Voltage [mV]" << std::endl;
sif::info << std::setw(8) << std::left << "Ch0" << std::dec << "| "
<< static_cast<unsigned int>(acuHkTableDataset.currentInChannel0.value) << std::setw(15)
<< std::right << acuHkTableDataset.voltageInChannel0.value << std::endl;
sif::info << std::setw(8) << std::left << "Ch1" << std::dec << "| "
<< static_cast<unsigned int>(acuHkTableDataset.currentInChannel1.value) << std::setw(15)
<< std::right << acuHkTableDataset.voltageInChannel1.value << std::endl;
sif::info << std::setw(8) << std::left << "Ch2" << std::dec << "| "
<< static_cast<unsigned int>(acuHkTableDataset.currentInChannel2.value) << std::setw(15)
<< std::right << acuHkTableDataset.voltageInChannel2.value << std::endl;
sif::info << std::setw(8) << std::left << "Ch3" << std::dec << "| "
<< static_cast<unsigned int>(acuHkTableDataset.currentInChannel3.value) << std::setw(15)
<< std::right << acuHkTableDataset.voltageInChannel3.value << std::endl;
sif::info << std::setw(8) << std::left << "Ch4" << std::dec << "| "
<< static_cast<unsigned int>(acuHkTableDataset.currentInChannel4.value) << std::setw(15)
<< std::right << acuHkTableDataset.voltageInChannel4.value << std::endl;
sif::info << std::setw(8) << std::left << "Ch5" << std::dec << "| "
<< static_cast<unsigned int>(acuHkTableDataset.currentInChannel5.value) << std::setw(15)
<< std::right << acuHkTableDataset.voltageInChannel5.value << std::endl;
}

View File

@ -1,51 +1,50 @@
#ifndef MISSION_DEVICES_ACUHANDLER_H_
#define MISSION_DEVICES_ACUHANDLER_H_
#include "GomspaceDeviceHandler.h"
#include <mission/devices/devicedefinitions/GomspaceDefinitions.h>
#include "GomspaceDeviceHandler.h"
#include "fsfw/datapool/PoolReadGuard.h"
/**
* @brief Handler for the ACU from Gomspace. Monitors and controls the battery charging via
* the solar panels.
*/
class ACUHandler: public GomspaceDeviceHandler {
public:
ACUHandler(object_id_t objectId, object_id_t comIF, CookieIF * comCookie);
virtual ~ACUHandler();
class ACUHandler : public GomspaceDeviceHandler {
public:
ACUHandler(object_id_t objectId, object_id_t comIF, CookieIF* comCookie);
virtual ~ACUHandler();
virtual ReturnValue_t initializeLocalDataPool(localpool::DataPool& localDataPoolMap,
LocalDataPoolManager& poolManager) override;
virtual ReturnValue_t initializeLocalDataPool(localpool::DataPool& localDataPoolMap,
LocalDataPoolManager& poolManager) override;
protected:
protected:
virtual void letChildHandleHkReply(DeviceCommandId_t id, const uint8_t* packet) override;
virtual void letChildHandleHkReply(DeviceCommandId_t id, const uint8_t *packet) override;
/**
* @brief As soon as the device is in MODE_NORMAL, this function is executed periodically.
*/
virtual ReturnValue_t buildNormalDeviceCommand(DeviceCommandId_t* id) override;
/**
* @brief As soon as the device is in MODE_NORMAL, this function is executed periodically.
*/
virtual ReturnValue_t buildNormalDeviceCommand(DeviceCommandId_t * id) override;
virtual void fillCommandAndReplyMap() override;
virtual void fillCommandAndReplyMap() override;
virtual ReturnValue_t deviceSpecificCommand(DeviceCommandId_t cmd) override;
virtual ReturnValue_t deviceSpecificCommand(DeviceCommandId_t cmd) override;
private:
static const DeviceCommandId_t PRINT_CHANNEL_STATS = 51;
private:
ACU::HkTableDataset acuHkTableDataset;
static const DeviceCommandId_t PRINT_CHANNEL_STATS = 51;
/**
* @brief Function extracts the hk table information from the received csp packet and stores
* the values in the acuHkTableDataset.
*/
void parseHkTableReply(const uint8_t* packet);
ACU::HkTableDataset acuHkTableDataset;
/**
* @brief Function extracts the hk table information from the received csp packet and stores
* the values in the acuHkTableDataset.
*/
void parseHkTableReply(const uint8_t *packet);
/**
* @brief Prints channel statistics (current and voltage) to console
*/
void printChannelStats();
/**
* @brief Prints channel statistics (current and voltage) to console
*/
void printChannelStats();
};
#endif /* MISSION_DEVICES_ACUHANDLER_H_ */

View File

@ -1,6 +1,6 @@
#include "GPSHyperionHandler.h"
#include "devicedefinitions/GPSDefinitions.h"
#include "devicedefinitions/GPSDefinitions.h"
#include "fsfw/datapool/PoolReadGuard.h"
#include "fsfw/timemanager/Clock.h"
@ -17,165 +17,160 @@
#endif
GPSHyperionHandler::GPSHyperionHandler(object_id_t objectId, object_id_t parentId,
bool debugHyperionGps):
ExtendedControllerBase(objectId, objects::NO_OBJECT), gpsSet(this),
debugHyperionGps(debugHyperionGps) {
}
bool debugHyperionGps)
: ExtendedControllerBase(objectId, objects::NO_OBJECT),
gpsSet(this),
debugHyperionGps(debugHyperionGps) {}
GPSHyperionHandler::~GPSHyperionHandler() {}
void GPSHyperionHandler::performControlOperation() {
#ifdef FSFW_OSAL_LINUX
readGpsDataFromGpsd();
readGpsDataFromGpsd();
#endif
}
LocalPoolDataSetBase* GPSHyperionHandler::getDataSetHandle(sid_t sid) {
return nullptr;
}
LocalPoolDataSetBase *GPSHyperionHandler::getDataSetHandle(sid_t sid) { return nullptr; }
ReturnValue_t GPSHyperionHandler::checkModeCommand(Mode_t mode, Submode_t submode,
uint32_t *msToReachTheMode) {
return HasReturnvaluesIF::RETURN_OK;
uint32_t *msToReachTheMode) {
return HasReturnvaluesIF::RETURN_OK;
}
ReturnValue_t GPSHyperionHandler::executeAction(ActionId_t actionId, MessageQueueId_t commandedBy,
const uint8_t *data, size_t size) {
switch(actionId) {
case(GpsHyperion::TRIGGER_RESET_PIN): {
if(resetCallback != nullptr) {
PoolReadGuard pg(&gpsSet);
// Set HK entries invalid
gpsSet.setValidity(false, true);
resetCallback(resetCallbackArgs);
return HasActionsIF::EXECUTION_FINISHED;
}
return DeviceHandlerIF::COMMAND_NOT_IMPLEMENTED;
const uint8_t *data, size_t size) {
switch (actionId) {
case (GpsHyperion::TRIGGER_RESET_PIN): {
if (resetCallback != nullptr) {
PoolReadGuard pg(&gpsSet);
// Set HK entries invalid
gpsSet.setValidity(false, true);
resetCallback(resetCallbackArgs);
return HasActionsIF::EXECUTION_FINISHED;
}
return DeviceHandlerIF::COMMAND_NOT_IMPLEMENTED;
}
}
return HasReturnvaluesIF::RETURN_OK;
}
return HasReturnvaluesIF::RETURN_OK;
}
ReturnValue_t GPSHyperionHandler::initializeLocalDataPool(
localpool::DataPool &localDataPoolMap, LocalDataPoolManager &poolManager) {
localDataPoolMap.emplace(GpsHyperion::ALTITUDE, new PoolEntry<double>({0.0}));
localDataPoolMap.emplace(GpsHyperion::LONGITUDE, new PoolEntry<double>({0.0}));
localDataPoolMap.emplace(GpsHyperion::LATITUDE, new PoolEntry<double>({0.0}));
localDataPoolMap.emplace(GpsHyperion::YEAR, new PoolEntry<uint16_t>());
localDataPoolMap.emplace(GpsHyperion::MONTH, new PoolEntry<uint8_t>());
localDataPoolMap.emplace(GpsHyperion::DAY, new PoolEntry<uint8_t>());
localDataPoolMap.emplace(GpsHyperion::HOURS, new PoolEntry<uint8_t>());
localDataPoolMap.emplace(GpsHyperion::MINUTES, new PoolEntry<uint8_t>());
localDataPoolMap.emplace(GpsHyperion::SECONDS, new PoolEntry<uint8_t>());
localDataPoolMap.emplace(GpsHyperion::UNIX_SECONDS, new PoolEntry<uint32_t>());
localDataPoolMap.emplace(GpsHyperion::SATS_IN_USE, new PoolEntry<uint8_t>());
localDataPoolMap.emplace(GpsHyperion::FIX_MODE, new PoolEntry<uint8_t>());
poolManager.subscribeForPeriodicPacket(gpsSet.getSid(), true, 2.0, false);
return HasReturnvaluesIF::RETURN_OK;
ReturnValue_t GPSHyperionHandler::initializeLocalDataPool(localpool::DataPool &localDataPoolMap,
LocalDataPoolManager &poolManager) {
localDataPoolMap.emplace(GpsHyperion::ALTITUDE, new PoolEntry<double>({0.0}));
localDataPoolMap.emplace(GpsHyperion::LONGITUDE, new PoolEntry<double>({0.0}));
localDataPoolMap.emplace(GpsHyperion::LATITUDE, new PoolEntry<double>({0.0}));
localDataPoolMap.emplace(GpsHyperion::YEAR, new PoolEntry<uint16_t>());
localDataPoolMap.emplace(GpsHyperion::MONTH, new PoolEntry<uint8_t>());
localDataPoolMap.emplace(GpsHyperion::DAY, new PoolEntry<uint8_t>());
localDataPoolMap.emplace(GpsHyperion::HOURS, new PoolEntry<uint8_t>());
localDataPoolMap.emplace(GpsHyperion::MINUTES, new PoolEntry<uint8_t>());
localDataPoolMap.emplace(GpsHyperion::SECONDS, new PoolEntry<uint8_t>());
localDataPoolMap.emplace(GpsHyperion::UNIX_SECONDS, new PoolEntry<uint32_t>());
localDataPoolMap.emplace(GpsHyperion::SATS_IN_USE, new PoolEntry<uint8_t>());
localDataPoolMap.emplace(GpsHyperion::FIX_MODE, new PoolEntry<uint8_t>());
poolManager.subscribeForPeriodicPacket(gpsSet.getSid(), true, 2.0, false);
return HasReturnvaluesIF::RETURN_OK;
}
void GPSHyperionHandler::setResetPinTriggerFunction(gpioResetFunction_t resetCallback,
void *args) {
this->resetCallback = resetCallback;
resetCallbackArgs = args;
void GPSHyperionHandler::setResetPinTriggerFunction(gpioResetFunction_t resetCallback, void *args) {
this->resetCallback = resetCallback;
resetCallbackArgs = args;
}
ReturnValue_t GPSHyperionHandler::initialize() {
ReturnValue_t result = ExtendedControllerBase::initialize();
if(result != HasReturnvaluesIF::RETURN_OK) {
return result;
}
ReturnValue_t result = ExtendedControllerBase::initialize();
if (result != HasReturnvaluesIF::RETURN_OK) {
return result;
}
return result;
}
ReturnValue_t GPSHyperionHandler::handleCommandMessage(CommandMessage *message) {
return ExtendedControllerBase::handleCommandMessage(message);
return ExtendedControllerBase::handleCommandMessage(message);
}
#ifdef FSFW_OSAL_LINUX
void GPSHyperionHandler::readGpsDataFromGpsd() {
// The data from the device will generally be read all at once. Therefore, we
// can set all field here
gpsmm gpsmm(GPSD_SHARED_MEMORY, 0);
gps_data_t* gps;
gps = gpsmm.read();
if(gps == nullptr) {
sif::warning << "Q7STestTask: Reading GPS data failed" << std::endl;
}
PoolReadGuard pg(&gpsSet);
if(pg.getReadResult() != HasReturnvaluesIF::RETURN_OK) {
// The data from the device will generally be read all at once. Therefore, we
// can set all field here
gpsmm gpsmm(GPSD_SHARED_MEMORY, 0);
gps_data_t *gps;
gps = gpsmm.read();
if (gps == nullptr) {
sif::warning << "Q7STestTask: Reading GPS data failed" << std::endl;
}
PoolReadGuard pg(&gpsSet);
if (pg.getReadResult() != HasReturnvaluesIF::RETURN_OK) {
#if FSFW_VERBOSE_LEVEL >= 1
sif::warning << "GPSHyperionHandler::scanForReply: Reading dataset failed"
<< std::endl;
sif::warning << "GPSHyperionHandler::scanForReply: Reading dataset failed" << std::endl;
#endif
}
// Print messages
if((gps->set & MODE_SET) != MODE_SET) {
// Could not even set mode
gpsSet.setValidity(false, true);
return;
}
}
// Print messages
if ((gps->set & MODE_SET) != MODE_SET) {
// Could not even set mode
gpsSet.setValidity(false, true);
return;
}
if(gps->satellites_used > 0) {
gpsSet.setValidity(true, true);
}
if (gps->satellites_used > 0) {
gpsSet.setValidity(true, true);
}
gpsSet.satInUse.value = gps->satellites_used;
gpsSet.satInView.value = gps->satellites_visible;
gpsSet.satInUse.value = gps->satellites_used;
gpsSet.satInView.value = gps->satellites_visible;
// 0: Not seen, 1: No fix, 2: 2D-Fix, 3: 3D-Fix
gpsSet.fixMode = gps->fix.mode;
if(std::isfinite(gps->fix.latitude)) {
// Negative latitude -> South direction
gpsSet.latitude.value = gps->fix.latitude;
} else {
gpsSet.latitude.setValid(false);
}
// 0: Not seen, 1: No fix, 2: 2D-Fix, 3: 3D-Fix
gpsSet.fixMode = gps->fix.mode;
if (std::isfinite(gps->fix.latitude)) {
// Negative latitude -> South direction
gpsSet.latitude.value = gps->fix.latitude;
} else {
gpsSet.latitude.setValid(false);
}
if(std::isfinite(gps->fix.longitude)) {
// Negative longitude -> West direction
gpsSet.longitude.value = gps->fix.longitude;
} else {
gpsSet.longitude.setValid(false);
}
if (std::isfinite(gps->fix.longitude)) {
// Negative longitude -> West direction
gpsSet.longitude.value = gps->fix.longitude;
} else {
gpsSet.longitude.setValid(false);
}
if(std::isfinite(gps->fix.altitude)) {
gpsSet.altitude.value = gps->fix.altitude;
} else {
gpsSet.altitude.setValid(false);
}
if (std::isfinite(gps->fix.altitude)) {
gpsSet.altitude.value = gps->fix.altitude;
} else {
gpsSet.altitude.setValid(false);
}
if(std::isfinite(gps->fix.speed)) {
gpsSet.speed.value = gps->fix.speed;
} else {
gpsSet.speed.setValid(false);
}
if (std::isfinite(gps->fix.speed)) {
gpsSet.speed.value = gps->fix.speed;
} else {
gpsSet.speed.setValid(false);
}
gpsSet.unixSeconds.value = gps->fix.time.tv_sec;
timeval time = {};
time.tv_sec = gpsSet.unixSeconds.value;
time.tv_usec = gps->fix.time.tv_nsec / 1000;
Clock::TimeOfDay_t timeOfDay = {};
Clock::convertTimevalToTimeOfDay(&time, &timeOfDay);
gpsSet.year = timeOfDay.year;
gpsSet.month = timeOfDay.month;
gpsSet.day = timeOfDay.day;
gpsSet.hours = timeOfDay.hour;
gpsSet.minutes = timeOfDay.minute;
gpsSet.seconds = timeOfDay.second;
if(debugHyperionGps) {
sif::info << "-- Hyperion GPS Data --" << std::endl;
time_t timeRaw = gps->fix.time.tv_sec;
std::tm* time = gmtime(&timeRaw);
std::cout << "Time: " << std::put_time(time, "%c %Z") << std::endl;
std::cout << "Visible satellites: " << gps->satellites_visible << 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 << "Latitude: " << gps->fix.latitude << std::endl;
std::cout << "Longitude: " << gps->fix.longitude << std::endl;
std::cout << "Altitude(MSL): " << gps->fix.altMSL << std::endl;
std::cout << "Speed(m/s): " << gps->fix.speed << std::endl;
}
gpsSet.unixSeconds.value = gps->fix.time.tv_sec;
timeval time = {};
time.tv_sec = gpsSet.unixSeconds.value;
time.tv_usec = gps->fix.time.tv_nsec / 1000;
Clock::TimeOfDay_t timeOfDay = {};
Clock::convertTimevalToTimeOfDay(&time, &timeOfDay);
gpsSet.year = timeOfDay.year;
gpsSet.month = timeOfDay.month;
gpsSet.day = timeOfDay.day;
gpsSet.hours = timeOfDay.hour;
gpsSet.minutes = timeOfDay.minute;
gpsSet.seconds = timeOfDay.second;
if (debugHyperionGps) {
sif::info << "-- Hyperion GPS Data --" << std::endl;
time_t timeRaw = gps->fix.time.tv_sec;
std::tm *time = gmtime(&timeRaw);
std::cout << "Time: " << std::put_time(time, "%c %Z") << std::endl;
std::cout << "Visible satellites: " << gps->satellites_visible << 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 << "Latitude: " << gps->fix.latitude << std::endl;
std::cout << "Longitude: " << gps->fix.longitude << std::endl;
std::cout << "Altitude(MSL): " << gps->fix.altMSL << std::endl;
std::cout << "Speed(m/s): " << gps->fix.speed << std::endl;
}
}
#endif

View File

@ -1,10 +1,10 @@
#ifndef MISSION_DEVICES_GPSHYPERIONHANDLER_H_
#define MISSION_DEVICES_GPSHYPERIONHANDLER_H_
#include "fsfw/FSFW.h"
#include "fsfw/devicehandlers/DeviceHandlerBase.h"
#include "fsfw/controller/ExtendedControllerBase.h"
#include "devicedefinitions/GPSDefinitions.h"
#include "fsfw/FSFW.h"
#include "fsfw/controller/ExtendedControllerBase.h"
#include "fsfw/devicehandlers/DeviceHandlerBase.h"
/**
* @brief Device handler for the Hyperion HT-GPS200 device
@ -12,38 +12,35 @@
* Flight manual:
* https://egit.irs.uni-stuttgart.de/redmine/projects/eive-flight-manual/wiki/Hyperion_HT-GPS200
*/
class GPSHyperionHandler: public ExtendedControllerBase {
public:
class GPSHyperionHandler : public ExtendedControllerBase {
public:
GPSHyperionHandler(object_id_t objectId, object_id_t parentId, bool debugHyperionGps = false);
virtual ~GPSHyperionHandler();
GPSHyperionHandler(object_id_t objectId, object_id_t parentId,
bool debugHyperionGps = false);
virtual ~GPSHyperionHandler();
using gpioResetFunction_t = ReturnValue_t (*)(void* args);
using gpioResetFunction_t = ReturnValue_t (*) (void* args);
void setResetPinTriggerFunction(gpioResetFunction_t resetCallback, void* args);
ReturnValue_t handleCommandMessage(CommandMessage* message) override;
void performControlOperation() override;
LocalPoolDataSetBase* getDataSetHandle(sid_t sid) override;
ReturnValue_t checkModeCommand(Mode_t mode, Submode_t submode,
uint32_t* msToReachTheMode) override;
ReturnValue_t executeAction(ActionId_t actionId, MessageQueueId_t commandedBy,
const uint8_t* data, size_t size) override;
ReturnValue_t initialize() override;
void setResetPinTriggerFunction(gpioResetFunction_t resetCallback, void*args);
ReturnValue_t handleCommandMessage(CommandMessage *message) override;
void performControlOperation() override;
LocalPoolDataSetBase* getDataSetHandle(sid_t sid) override;
ReturnValue_t checkModeCommand(Mode_t mode, Submode_t submode,
uint32_t *msToReachTheMode) override;
ReturnValue_t executeAction(ActionId_t actionId,
MessageQueueId_t commandedBy, const uint8_t* data,
size_t size) override;
ReturnValue_t initialize() override;
protected:
protected:
gpioResetFunction_t resetCallback = nullptr;
void* resetCallbackArgs = nullptr;
gpioResetFunction_t resetCallback = nullptr;
void* resetCallbackArgs = nullptr;
ReturnValue_t initializeLocalDataPool(localpool::DataPool& localDataPoolMap,
LocalDataPoolManager& poolManager) override;
ReturnValue_t initializeLocalDataPool(localpool::DataPool &localDataPoolMap,
LocalDataPoolManager &poolManager) override;
private:
GpsPrimaryDataset gpsSet;
bool debugHyperionGps = false;
private:
GpsPrimaryDataset gpsSet;
bool debugHyperionGps = false;
void readGpsDataFromGpsd();
void readGpsDataFromGpsd();
};
#endif /* MISSION_DEVICES_GPSHYPERIONHANDLER_H_ */

View File

@ -2,411 +2,397 @@
#include <mission/devices/devicedefinitions/GomSpacePackets.h>
GomspaceDeviceHandler::GomspaceDeviceHandler(object_id_t objectId, object_id_t comIF,
CookieIF * comCookie, uint16_t maxConfigTableAddress, uint16_t maxHkTableAddress,
uint16_t hkTableReplySize, LocalPoolDataSetBase* hkTableDataset) :
DeviceHandlerBase(objectId, comIF, comCookie), maxConfigTableAddress(maxConfigTableAddress),
maxHkTableAddress(maxHkTableAddress), hkTableReplySize(hkTableReplySize),
hkTableDataset(hkTableDataset) {
if (comCookie == nullptr) {
sif::error << "GomspaceDeviceHandler::GomspaceDeviceHandler: Invalid com cookie"
<< std::endl;
}
if (hkTableDataset == nullptr) {
sif::error << "GomspaceDeviceHandler::GomspaceDeviceHandler: Invalid hk table data set"
<< std::endl;
}
CookieIF* comCookie, uint16_t maxConfigTableAddress,
uint16_t maxHkTableAddress, uint16_t hkTableReplySize,
LocalPoolDataSetBase* hkTableDataset)
: DeviceHandlerBase(objectId, comIF, comCookie),
maxConfigTableAddress(maxConfigTableAddress),
maxHkTableAddress(maxHkTableAddress),
hkTableReplySize(hkTableReplySize),
hkTableDataset(hkTableDataset) {
if (comCookie == nullptr) {
sif::error << "GomspaceDeviceHandler::GomspaceDeviceHandler: Invalid com cookie" << std::endl;
}
if (hkTableDataset == nullptr) {
sif::error << "GomspaceDeviceHandler::GomspaceDeviceHandler: Invalid hk table data set"
<< std::endl;
}
}
GomspaceDeviceHandler::~GomspaceDeviceHandler() {
GomspaceDeviceHandler::~GomspaceDeviceHandler() {}
void GomspaceDeviceHandler::doStartUp() {}
void GomspaceDeviceHandler::doShutDown() {}
ReturnValue_t GomspaceDeviceHandler::buildNormalDeviceCommand(DeviceCommandId_t* id) {
return HasReturnvaluesIF::RETURN_OK;
}
void GomspaceDeviceHandler::doStartUp(){
ReturnValue_t GomspaceDeviceHandler::buildTransitionDeviceCommand(DeviceCommandId_t* id) {
return HasReturnvaluesIF::RETURN_OK;
}
void GomspaceDeviceHandler::doShutDown(){
}
ReturnValue_t GomspaceDeviceHandler::buildNormalDeviceCommand(
DeviceCommandId_t * id) {
return HasReturnvaluesIF::RETURN_OK;
}
ReturnValue_t GomspaceDeviceHandler::buildTransitionDeviceCommand(
DeviceCommandId_t * id){
return HasReturnvaluesIF::RETURN_OK;
}
ReturnValue_t GomspaceDeviceHandler::buildCommandFromCommand(
DeviceCommandId_t deviceCommand, const uint8_t * commandData,
size_t commandDataLen) {
ReturnValue_t result;
switch(deviceCommand) {
case(GOMSPACE::PING): {
result = generatePingCommand(commandData, commandDataLen);
if(result != HasReturnvaluesIF::RETURN_OK) {
return result;
}
break;
ReturnValue_t GomspaceDeviceHandler::buildCommandFromCommand(DeviceCommandId_t deviceCommand,
const uint8_t* commandData,
size_t commandDataLen) {
ReturnValue_t result;
switch (deviceCommand) {
case (GOMSPACE::PING): {
result = generatePingCommand(commandData, commandDataLen);
if (result != HasReturnvaluesIF::RETURN_OK) {
return result;
}
break;
}
case(GOMSPACE::REBOOT): {
generateRebootCommand();
break;
case (GOMSPACE::REBOOT): {
generateRebootCommand();
break;
}
case(GOMSPACE::PARAM_SET):{
result = generateSetParamCommand(commandData, commandDataLen);
if(result != HasReturnvaluesIF::RETURN_OK){
return result;
}
break;
case (GOMSPACE::PARAM_SET): {
result = generateSetParamCommand(commandData, commandDataLen);
if (result != HasReturnvaluesIF::RETURN_OK) {
return result;
}
break;
}
case(GOMSPACE::PARAM_GET):{
result = generateGetParamCommand(commandData, commandDataLen);
if(result != HasReturnvaluesIF::RETURN_OK){
return result;
}
break;
case (GOMSPACE::PARAM_GET): {
result = generateGetParamCommand(commandData, commandDataLen);
if (result != HasReturnvaluesIF::RETURN_OK) {
return result;
}
break;
}
case(GOMSPACE::GNDWDT_RESET): {
result = generateResetWatchdogCmd();
if(result != HasReturnvaluesIF::RETURN_OK){
return result;
}
break;
case (GOMSPACE::GNDWDT_RESET): {
result = generateResetWatchdogCmd();
if (result != HasReturnvaluesIF::RETURN_OK) {
return result;
}
break;
}
case(GOMSPACE::PRINT_SWITCH_V_I): {
result = printStatus(deviceCommand);
break;
case (GOMSPACE::PRINT_SWITCH_V_I): {
result = printStatus(deviceCommand);
break;
}
case(GOMSPACE::REQUEST_HK_TABLE): {
result = generateRequestFullHkTableCmd(hkTableReplySize);
if(result != HasReturnvaluesIF::RETURN_OK){
return result;
}
break;
case (GOMSPACE::REQUEST_HK_TABLE): {
result = generateRequestFullHkTableCmd(hkTableReplySize);
if (result != HasReturnvaluesIF::RETURN_OK) {
return result;
}
break;
}
default:
return deviceSpecificCommand(deviceCommand);
}
return HasReturnvaluesIF::RETURN_OK;
return deviceSpecificCommand(deviceCommand);
}
return HasReturnvaluesIF::RETURN_OK;
}
void GomspaceDeviceHandler::fillCommandAndReplyMap(){
this->insertInCommandAndReplyMap(GOMSPACE::PING, 3);
this->insertInCommandMap(GOMSPACE::REBOOT);
this->insertInCommandAndReplyMap(GOMSPACE::PARAM_SET, 3);
this->insertInCommandAndReplyMap(GOMSPACE::PARAM_GET, 3);
this->insertInCommandAndReplyMap(GOMSPACE::REQUEST_HK_TABLE, 3);
this->insertInCommandMap(GOMSPACE::GNDWDT_RESET);
this->insertInCommandMap(GOMSPACE::PRINT_SWITCH_V_I);
void GomspaceDeviceHandler::fillCommandAndReplyMap() {
this->insertInCommandAndReplyMap(GOMSPACE::PING, 3);
this->insertInCommandMap(GOMSPACE::REBOOT);
this->insertInCommandAndReplyMap(GOMSPACE::PARAM_SET, 3);
this->insertInCommandAndReplyMap(GOMSPACE::PARAM_GET, 3);
this->insertInCommandAndReplyMap(GOMSPACE::REQUEST_HK_TABLE, 3);
this->insertInCommandMap(GOMSPACE::GNDWDT_RESET);
this->insertInCommandMap(GOMSPACE::PRINT_SWITCH_V_I);
}
ReturnValue_t GomspaceDeviceHandler::scanForReply(const uint8_t *start,
size_t remainingSize, DeviceCommandId_t *foundId, size_t *foundLen) {
switch(rememberCommandId) {
case(GOMSPACE::PING):
*foundId = GOMSPACE::PING;
*foundLen = PING_REPLY_SIZE;
rememberCommandId = GOMSPACE::NONE;
break;
case(GOMSPACE::PARAM_GET): {
*foundId = GOMSPACE::PARAM_GET;
*foundLen = rememberRequestedSize + GOMSPACE::GS_HDR_LENGTH;
rememberCommandId = GOMSPACE::NONE;
break;
ReturnValue_t GomspaceDeviceHandler::scanForReply(const uint8_t* start, size_t remainingSize,
DeviceCommandId_t* foundId, size_t* foundLen) {
switch (rememberCommandId) {
case (GOMSPACE::PING):
*foundId = GOMSPACE::PING;
*foundLen = PING_REPLY_SIZE;
rememberCommandId = GOMSPACE::NONE;
break;
case (GOMSPACE::PARAM_GET): {
*foundId = GOMSPACE::PARAM_GET;
*foundLen = rememberRequestedSize + GOMSPACE::GS_HDR_LENGTH;
rememberCommandId = GOMSPACE::NONE;
break;
}
case(GOMSPACE::PARAM_SET): {
*foundId = GOMSPACE::PARAM_SET;
*foundLen = rememberRequestedSize;
rememberCommandId = GOMSPACE::NONE;
break;
case (GOMSPACE::PARAM_SET): {
*foundId = GOMSPACE::PARAM_SET;
*foundLen = rememberRequestedSize;
rememberCommandId = GOMSPACE::NONE;
break;
}
case(GOMSPACE::REQUEST_HK_TABLE): {
*foundId = GOMSPACE::REQUEST_HK_TABLE;
*foundLen = rememberRequestedSize + GOMSPACE::GS_HDR_LENGTH;
rememberCommandId = GOMSPACE::NONE;
break;
case (GOMSPACE::REQUEST_HK_TABLE): {
*foundId = GOMSPACE::REQUEST_HK_TABLE;
*foundLen = rememberRequestedSize + GOMSPACE::GS_HDR_LENGTH;
rememberCommandId = GOMSPACE::NONE;
break;
}
default:
return IGNORE_REPLY_DATA;
}
return HasReturnvaluesIF::RETURN_OK;
return IGNORE_REPLY_DATA;
}
return HasReturnvaluesIF::RETURN_OK;
}
ReturnValue_t GomspaceDeviceHandler::interpretDeviceReply(DeviceCommandId_t id,
const uint8_t *packet) {
switch(id) {
case(GOMSPACE::PING): {
SerializeElement<uint32_t> replyTime = *packet;
handleDeviceTM(&replyTime, id, true);
break;
const uint8_t* packet) {
switch (id) {
case (GOMSPACE::PING): {
SerializeElement<uint32_t> replyTime = *packet;
handleDeviceTM(&replyTime, id, true);
break;
}
case(GOMSPACE::PARAM_GET): {
// -2 to subtract address size from gomspace parameter reply packet
uint16_t payloadLength = (*(packet + 2) << 8 | *(packet + 3)) - 2;
if(payloadLength > sizeof(uint32_t)){
sif::error << "GomspaceDeviceHandler: PARAM_GET: Invalid payload "
<< "size in reply" << std::endl;
return INVALID_PAYLOAD_SIZE;
}
uint8_t tempPayloadBuffer[payloadLength];
/* Extract information from received data */
CspGetParamReply cspGetParamReply(tempPayloadBuffer, payloadLength);
size_t size = GOMSPACE::GS_HDR_LENGTH + payloadLength;
ReturnValue_t result = cspGetParamReply.deSerialize(&packet, &size,
SerializeIF::Endianness::BIG);
if(result != HasReturnvaluesIF::RETURN_OK){
sif::error << "GomspaceDeviceHandler: Failed to deserialize get parameter"
<< "reply" << std::endl;
return result;
}
uint8_t action = cspGetParamReply.getAction();
uint8_t tableId = cspGetParamReply.getTableId();
uint16_t address = cspGetParamReply.getAddress();
/* Pack relevant information into a tm packet */
ParamReply paramReply(action, tableId, address, payloadLength,
tempPayloadBuffer);
handleDeviceTM(&paramReply, id, true);
break;
case (GOMSPACE::PARAM_GET): {
// -2 to subtract address size from gomspace parameter reply packet
uint16_t payloadLength = (*(packet + 2) << 8 | *(packet + 3)) - 2;
if (payloadLength > sizeof(uint32_t)) {
sif::error << "GomspaceDeviceHandler: PARAM_GET: Invalid payload "
<< "size in reply" << std::endl;
return INVALID_PAYLOAD_SIZE;
}
uint8_t tempPayloadBuffer[payloadLength];
/* Extract information from received data */
CspGetParamReply cspGetParamReply(tempPayloadBuffer, payloadLength);
size_t size = GOMSPACE::GS_HDR_LENGTH + payloadLength;
ReturnValue_t result =
cspGetParamReply.deSerialize(&packet, &size, SerializeIF::Endianness::BIG);
if (result != HasReturnvaluesIF::RETURN_OK) {
sif::error << "GomspaceDeviceHandler: Failed to deserialize get parameter"
<< "reply" << std::endl;
return result;
}
uint8_t action = cspGetParamReply.getAction();
uint8_t tableId = cspGetParamReply.getTableId();
uint16_t address = cspGetParamReply.getAddress();
/* Pack relevant information into a tm packet */
ParamReply paramReply(action, tableId, address, payloadLength, tempPayloadBuffer);
handleDeviceTM(&paramReply, id, true);
break;
}
case(GOMSPACE::PARAM_SET): {
/* When setting a parameter, the p60dock sends back the state of the
* operation */
if(*packet != PARAM_SET_OK){
return HasReturnvaluesIF::RETURN_FAILED;
}
break;
case (GOMSPACE::PARAM_SET): {
/* When setting a parameter, the p60dock sends back the state of the
* operation */
if (*packet != PARAM_SET_OK) {
return HasReturnvaluesIF::RETURN_FAILED;
}
break;
}
case(GOMSPACE::REQUEST_HK_TABLE): {
letChildHandleHkReply(id, packet);
break;
case (GOMSPACE::REQUEST_HK_TABLE): {
letChildHandleHkReply(id, packet);
break;
}
default:
break;
}
return HasReturnvaluesIF::RETURN_OK;
break;
}
return HasReturnvaluesIF::RETURN_OK;
}
void GomspaceDeviceHandler::setNormalDatapoolEntriesInvalid(){
void GomspaceDeviceHandler::setNormalDatapoolEntriesInvalid() {}
ReturnValue_t GomspaceDeviceHandler::generateSetParamCommand(const uint8_t* commandData,
size_t commandDataLen) {
SetParamMessageUnpacker setParamMessageUnpacker;
ReturnValue_t result = setParamMessageUnpacker.deSerialize(&commandData, &commandDataLen,
SerializeIF::Endianness::BIG);
if (result != HasReturnvaluesIF::RETURN_OK) {
sif::error << "GomspaceDeviceHandler: Failed to deserialize set parameter "
"message"
<< std::endl;
return result;
}
/* Get and check address */
uint16_t address = setParamMessageUnpacker.getAddress();
if (address > maxConfigTableAddress) {
sif::error << "GomspaceDeviceHandler: Invalid address for set parameter "
<< "action" << std::endl;
return INVALID_ADDRESS;
}
uint16_t checksum = GOMSPACE::IGNORE_CHECKSUM;
uint16_t seq = 0;
uint16_t total = 0;
/* CSP reply only contains the transaction state */
uint16_t querySize = 1;
const uint8_t* parameterPtr = setParamMessageUnpacker.getParameter();
uint8_t parameterSize = setParamMessageUnpacker.getParameterSize();
uint16_t payloadlength = sizeof(address) + parameterSize;
/* Generate command for CspComIF */
CspSetParamCommand setParamCmd(querySize, payloadlength, checksum, seq, total, address,
parameterPtr, parameterSize);
size_t cspPacketLen = 0;
uint8_t* buffer = cspPacket;
result = setParamCmd.serialize(&buffer, &cspPacketLen, sizeof(cspPacket),
SerializeIF::Endianness::BIG);
if (result != HasReturnvaluesIF::RETURN_OK) {
sif::error << "GomspaceDeviceHandler: Failed to serialize command for "
<< "CspComIF" << std::endl;
return result;
}
if (cspPacketLen > MAX_PACKET_LEN) {
sif::error << "GomspaceDeviceHandler: Invalid length of set parameter "
"command"
<< std::endl;
return PACKET_TOO_LONG;
}
rawPacket = cspPacket;
rawPacketLen = cspPacketLen;
rememberRequestedSize = querySize;
rememberCommandId = GOMSPACE::PARAM_SET;
return HasReturnvaluesIF::RETURN_OK;
}
ReturnValue_t GomspaceDeviceHandler::generateSetParamCommand(
const uint8_t * commandData, size_t commandDataLen) {
SetParamMessageUnpacker setParamMessageUnpacker;
ReturnValue_t result = setParamMessageUnpacker.deSerialize(&commandData,
&commandDataLen, SerializeIF::Endianness::BIG);
if(result != HasReturnvaluesIF::RETURN_OK){
sif::error << "GomspaceDeviceHandler: Failed to deserialize set parameter "
"message" << std::endl;
return result;
}
/* Get and check address */
uint16_t address = setParamMessageUnpacker.getAddress();
if(address > maxConfigTableAddress){
sif::error << "GomspaceDeviceHandler: Invalid address for set parameter "
<< "action" << std::endl;
return INVALID_ADDRESS;
}
uint16_t checksum = GOMSPACE::IGNORE_CHECKSUM;
uint16_t seq = 0;
uint16_t total = 0;
/* CSP reply only contains the transaction state */
uint16_t querySize = 1;
const uint8_t* parameterPtr = setParamMessageUnpacker.getParameter();
uint8_t parameterSize = setParamMessageUnpacker.getParameterSize();
uint16_t payloadlength = sizeof(address) + parameterSize;
ReturnValue_t GomspaceDeviceHandler::generateGetParamCommand(const uint8_t* commandData,
size_t commandDataLen) {
ReturnValue_t result;
/* Unpack the received action message */
GetParamMessageUnpacker getParamMessage;
result = getParamMessage.deSerialize(&commandData, &commandDataLen, SerializeIF::Endianness::BIG);
if (result != HasReturnvaluesIF::RETURN_OK) {
sif::error << "Failed to deserialize message to extract information "
"from get parameter message"
<< std::endl;
return result;
}
/* Get an check table id to read from */
uint8_t tableId = getParamMessage.getTableId();
if (tableId != CONFIG_TABLE_ID && tableId != HK_TABLE_ID) {
sif::error << "GomspaceDeviceHandler: Invalid table id in get parameter"
" message"
<< std::endl;
return INVALID_TABLE_ID;
}
/* Get and check address */
uint16_t address = getParamMessage.getAddress();
if (address > maxHkTableAddress && tableId == HK_TABLE_ID) {
sif::error << "GomspaceDeviceHandler: Invalid address to get parameter from "
<< "housekeeping table" << std::endl;
return INVALID_ADDRESS;
}
if (address > maxConfigTableAddress && tableId == CONFIG_TABLE_ID) {
sif::error << "GomspaceDeviceHandler: Invalid address to get parameter from "
<< "configuration table" << std::endl;
return INVALID_ADDRESS;
}
uint16_t length = sizeof(address);
uint16_t checksum = GOMSPACE::IGNORE_CHECKSUM;
uint16_t seq = 0;
uint16_t total = 0;
uint8_t parameterSize = getParamMessage.getParameterSize();
if (parameterSize > sizeof(uint32_t)) {
sif::error << "GomspaceDeviceHandler: GET_PARAM: Invalid parameter "
<< "size" << std::endl;
return INVALID_PARAM_SIZE;
}
uint16_t querySize = parameterSize + GOMSPACE::GS_HDR_LENGTH;
/* Generate command for CspComIF */
CspSetParamCommand setParamCmd(querySize, payloadlength, checksum, seq,
total, address, parameterPtr, parameterSize);
size_t cspPacketLen = 0;
uint8_t* buffer = cspPacket;
result = setParamCmd.serialize(&buffer, &cspPacketLen, sizeof(cspPacket),
SerializeIF::Endianness::BIG);
if(result != HasReturnvaluesIF::RETURN_OK){
sif::error << "GomspaceDeviceHandler: Failed to serialize command for "
<< "CspComIF" << std::endl;
return result;
}
if(cspPacketLen > MAX_PACKET_LEN){
sif::error << "GomspaceDeviceHandler: Invalid length of set parameter "
"command" << std::endl;
return PACKET_TOO_LONG;
}
rawPacket = cspPacket;
rawPacketLen = cspPacketLen;
rememberRequestedSize = querySize;
rememberCommandId = GOMSPACE::PARAM_SET;
return HasReturnvaluesIF::RETURN_OK;
/* Generate the CSP command to send to the P60 Dock */
CspGetParamCommand getParamCmd(querySize, tableId, length, checksum, seq, total, address);
size_t cspPacketLen = 0;
uint8_t* buffer = cspPacket;
result = getParamCmd.serialize(&buffer, &cspPacketLen, sizeof(cspPacket),
SerializeIF::Endianness::BIG);
if (result != HasReturnvaluesIF::RETURN_OK) {
sif::error << "GomspaceDeviceHandler: Failed to serialize command to "
<< "get parameter" << std::endl;
}
if (cspPacketLen > MAX_PACKET_LEN) {
sif::error << "GomspaceDeviceHandler: Received invalid get parameter "
"command"
<< std::endl;
return PACKET_TOO_LONG;
}
rawPacket = cspPacket;
rawPacketLen = cspPacketLen;
rememberRequestedSize = querySize;
rememberCommandId = GOMSPACE::PARAM_GET;
return HasReturnvaluesIF::RETURN_OK;
}
ReturnValue_t GomspaceDeviceHandler::generateGetParamCommand(
const uint8_t * commandData, size_t commandDataLen){
ReturnValue_t result;
/* Unpack the received action message */
GetParamMessageUnpacker getParamMessage;
result = getParamMessage.deSerialize(&commandData, &commandDataLen,
SerializeIF::Endianness::BIG);
if(result != HasReturnvaluesIF::RETURN_OK) {
sif::error << "Failed to deserialize message to extract information "
"from get parameter message" << std::endl;
return result;
}
/* Get an check table id to read from */
uint8_t tableId = getParamMessage.getTableId();
if(tableId != CONFIG_TABLE_ID && tableId != HK_TABLE_ID){
sif::error << "GomspaceDeviceHandler: Invalid table id in get parameter"
" message" << std::endl;
return INVALID_TABLE_ID;
}
/* Get and check address */
uint16_t address = getParamMessage.getAddress();
if(address > maxHkTableAddress && tableId == HK_TABLE_ID){
sif::error << "GomspaceDeviceHandler: Invalid address to get parameter from "
<< "housekeeping table" << std::endl;
return INVALID_ADDRESS;
}
if(address > maxConfigTableAddress && tableId == CONFIG_TABLE_ID){
sif::error << "GomspaceDeviceHandler: Invalid address to get parameter from "
<< "configuration table" << std::endl;
return INVALID_ADDRESS;
}
uint16_t length = sizeof(address);
uint16_t checksum = GOMSPACE::IGNORE_CHECKSUM;
uint16_t seq = 0;
uint16_t total = 0;
uint8_t parameterSize = getParamMessage.getParameterSize();
if(parameterSize > sizeof(uint32_t)) {
sif::error << "GomspaceDeviceHandler: GET_PARAM: Invalid parameter "
<< "size" << std::endl;
return INVALID_PARAM_SIZE;
}
uint16_t querySize = parameterSize + GOMSPACE::GS_HDR_LENGTH;
/* Generate the CSP command to send to the P60 Dock */
CspGetParamCommand getParamCmd(querySize, tableId, length,
checksum, seq, total, address);
size_t cspPacketLen = 0;
uint8_t* buffer = cspPacket;
result = getParamCmd.serialize(&buffer, &cspPacketLen, sizeof(cspPacket),
SerializeIF::Endianness::BIG);
if(result != HasReturnvaluesIF::RETURN_OK){
sif::error << "GomspaceDeviceHandler: Failed to serialize command to "
<< "get parameter" << std::endl;
}
if(cspPacketLen > MAX_PACKET_LEN){
sif::error << "GomspaceDeviceHandler: Received invalid get parameter "
"command" << std::endl;
return PACKET_TOO_LONG;
}
rawPacket = cspPacket;
rawPacketLen = cspPacketLen;
rememberRequestedSize = querySize;
rememberCommandId = GOMSPACE::PARAM_GET;
return HasReturnvaluesIF::RETURN_OK;
ReturnValue_t GomspaceDeviceHandler::generatePingCommand(const uint8_t* commandData,
size_t commandDataLen) {
CspPingCommand cspPingCommand(commandData, commandDataLen);
size_t cspPacketLen = 0;
uint8_t* buffer = cspPacket;
ReturnValue_t result = cspPingCommand.serialize(&buffer, &cspPacketLen, sizeof(cspPacket),
SerializeIF::Endianness::BIG);
if (result != HasReturnvaluesIF::RETURN_OK) {
sif::error << "GomspaceDeviceHandler: Failed to serialize ping command" << std::endl;
return result;
}
if (cspPacketLen > MAX_PACKET_LEN) {
sif::error << "GomspaceDeviceHandler: Received invalid ping message" << std::endl;
return PACKET_TOO_LONG;
}
rawPacket = cspPacket;
rawPacketLen = cspPacketLen;
rememberCommandId = GOMSPACE::PING;
return HasReturnvaluesIF::RETURN_OK;
}
ReturnValue_t GomspaceDeviceHandler::generatePingCommand(
const uint8_t * commandData, size_t commandDataLen) {
CspPingCommand cspPingCommand(commandData, commandDataLen);
size_t cspPacketLen = 0;
uint8_t* buffer = cspPacket;
ReturnValue_t result = cspPingCommand.serialize(&buffer, &cspPacketLen,
sizeof(cspPacket),
SerializeIF::Endianness::BIG);
if(result != HasReturnvaluesIF::RETURN_OK){
sif::error << "GomspaceDeviceHandler: Failed to serialize ping command"
<< std::endl;
return result;
}
if(cspPacketLen > MAX_PACKET_LEN){
sif::error << "GomspaceDeviceHandler: Received invalid ping message"
<< std::endl;
return PACKET_TOO_LONG;
}
rawPacket = cspPacket;
rawPacketLen = cspPacketLen;
rememberCommandId = GOMSPACE::PING;
return HasReturnvaluesIF::RETURN_OK;
void GomspaceDeviceHandler::generateRebootCommand() {
uint8_t cspPort = GOMSPACE::REBOOT_PORT;
uint16_t querySize = 0;
*cspPacket = GOMSPACE::REBOOT_PORT;
*(cspPacket + 1) = querySize;
size_t cspPacketLen = sizeof(cspPort) + sizeof(cspPacketLen);
rawPacket = cspPacket;
rawPacketLen = cspPacketLen;
}
void GomspaceDeviceHandler::generateRebootCommand(){
uint8_t cspPort = GOMSPACE::REBOOT_PORT;
uint16_t querySize = 0;
*cspPacket = GOMSPACE::REBOOT_PORT;
*(cspPacket + 1) = querySize;
size_t cspPacketLen = sizeof(cspPort) + sizeof(cspPacketLen);
rawPacket = cspPacket;
rawPacketLen = cspPacketLen;
}
ReturnValue_t GomspaceDeviceHandler::generateResetWatchdogCmd(){
WatchdogResetCommand watchdogResetCommand;
size_t cspPacketLen = 0;
uint8_t* buffer = cspPacket;
ReturnValue_t result = watchdogResetCommand.serialize(&buffer,
&cspPacketLen, sizeof(cspPacket), SerializeIF::Endianness::BIG);
if(result != HasReturnvaluesIF::RETURN_OK){
sif::error << "GomspaceDeviceHandler: Failed to serialize watchdog reset "
<< "command" << std::endl;
return result;
}
rawPacket = cspPacket;
rawPacketLen = cspPacketLen;
rememberRequestedSize = 0; // No bytes will be queried with the ground
// watchdog command.
rememberCommandId = GOMSPACE::GNDWDT_RESET;
return HasReturnvaluesIF::RETURN_OK;
ReturnValue_t GomspaceDeviceHandler::generateResetWatchdogCmd() {
WatchdogResetCommand watchdogResetCommand;
size_t cspPacketLen = 0;
uint8_t* buffer = cspPacket;
ReturnValue_t result = watchdogResetCommand.serialize(&buffer, &cspPacketLen, sizeof(cspPacket),
SerializeIF::Endianness::BIG);
if (result != HasReturnvaluesIF::RETURN_OK) {
sif::error << "GomspaceDeviceHandler: Failed to serialize watchdog reset "
<< "command" << std::endl;
return result;
}
rawPacket = cspPacket;
rawPacketLen = cspPacketLen;
rememberRequestedSize = 0; // No bytes will be queried with the ground
// watchdog command.
rememberCommandId = GOMSPACE::GNDWDT_RESET;
return HasReturnvaluesIF::RETURN_OK;
}
ReturnValue_t GomspaceDeviceHandler::generateRequestFullHkTableCmd(uint16_t hkTableReplySize) {
uint16_t querySize = hkTableReplySize;
uint8_t tableId = HK_TABLE_ID;
RequestFullTableCommand requestFullTableCommand(querySize, tableId);
uint16_t querySize = hkTableReplySize;
uint8_t tableId = HK_TABLE_ID;
RequestFullTableCommand requestFullTableCommand(querySize, tableId);
size_t cspPacketLen = 0;
uint8_t* buffer = cspPacket;
ReturnValue_t result = requestFullTableCommand.serialize(&buffer,
&cspPacketLen, sizeof(cspPacket), SerializeIF::Endianness::BIG);
if(result != HasReturnvaluesIF::RETURN_OK){
sif::error << "GomspaceDeviceHandler::generateRequestFullHkTableCmd Failed to serialize "
"full table request command " << std::endl;
return result;
}
rawPacket = cspPacket;
rawPacketLen = cspPacketLen;
rememberRequestedSize = querySize;
rememberCommandId = GOMSPACE::REQUEST_HK_TABLE;
return RETURN_OK;
size_t cspPacketLen = 0;
uint8_t* buffer = cspPacket;
ReturnValue_t result = requestFullTableCommand.serialize(
&buffer, &cspPacketLen, sizeof(cspPacket), SerializeIF::Endianness::BIG);
if (result != HasReturnvaluesIF::RETURN_OK) {
sif::error << "GomspaceDeviceHandler::generateRequestFullHkTableCmd Failed to serialize "
"full table request command "
<< std::endl;
return result;
}
rawPacket = cspPacket;
rawPacketLen = cspPacketLen;
rememberRequestedSize = querySize;
rememberCommandId = GOMSPACE::REQUEST_HK_TABLE;
return RETURN_OK;
}
uint32_t GomspaceDeviceHandler::getTransitionDelayMs(Mode_t modeFrom,
Mode_t modeTo) {
return 0;
}
uint32_t GomspaceDeviceHandler::getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) { return 0; }
LocalPoolDataSetBase* GomspaceDeviceHandler::getDataSetHandle(sid_t sid) {
if(sid == hkTableDataset->getSid()) {
return hkTableDataset;
}
else {
return nullptr;
}
if (sid == hkTableDataset->getSid()) {
return hkTableDataset;
} else {
return nullptr;
}
}
ReturnValue_t GomspaceDeviceHandler::deviceSpecificCommand(DeviceCommandId_t cmd) {
return DeviceHandlerIF::COMMAND_NOT_IMPLEMENTED;
return DeviceHandlerIF::COMMAND_NOT_IMPLEMENTED;
}
void GomspaceDeviceHandler::setModeNormal() {
mode = MODE_NORMAL;
}
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;
sif::info << "No printHkTable implementation given.." << std::endl;
return HasReturnvaluesIF::RETURN_OK;
}

View File

@ -16,135 +16,125 @@
* Flight manual:
* https://egit.irs.uni-stuttgart.de/redmine/projects/eive-flight-manual/wiki/Gomspace_PCDU_P60_System
*/
class GomspaceDeviceHandler: public DeviceHandlerBase {
public:
class GomspaceDeviceHandler : public DeviceHandlerBase {
public:
static constexpr uint8_t CLASS_ID = CLASS_ID::GOM_SPACE_HANDLER;
static const ReturnValue_t PACKET_TOO_LONG = HasReturnvaluesIF::makeReturnCode(CLASS_ID, 0);
static const ReturnValue_t INVALID_TABLE_ID = HasReturnvaluesIF::makeReturnCode(CLASS_ID, 1);
static const ReturnValue_t INVALID_ADDRESS = HasReturnvaluesIF::makeReturnCode(CLASS_ID, 2);
static const ReturnValue_t INVALID_PARAM_SIZE = HasReturnvaluesIF::makeReturnCode(CLASS_ID, 3);
static const ReturnValue_t INVALID_PAYLOAD_SIZE = HasReturnvaluesIF::makeReturnCode(CLASS_ID, 4);
static const ReturnValue_t UNKNOWN_REPLY_ID = HasReturnvaluesIF::makeReturnCode(CLASS_ID, 5);
static constexpr uint8_t CLASS_ID = CLASS_ID::GOM_SPACE_HANDLER;
static const ReturnValue_t PACKET_TOO_LONG = HasReturnvaluesIF::makeReturnCode(CLASS_ID, 0);
static const ReturnValue_t INVALID_TABLE_ID = HasReturnvaluesIF::makeReturnCode(CLASS_ID, 1);
static const ReturnValue_t INVALID_ADDRESS = HasReturnvaluesIF::makeReturnCode(CLASS_ID, 2);
static const ReturnValue_t INVALID_PARAM_SIZE = HasReturnvaluesIF::makeReturnCode(CLASS_ID, 3);
static const ReturnValue_t INVALID_PAYLOAD_SIZE =
HasReturnvaluesIF::makeReturnCode(CLASS_ID, 4);
static const ReturnValue_t UNKNOWN_REPLY_ID = HasReturnvaluesIF::makeReturnCode(CLASS_ID, 5);
/**
* @brief Constructor
*
* @param maxConfigTableAddress The maximum memory address of the configu-
* ration table of a gomspace device.
* @param maxHkTableAddress The maximum memory address of a value in the
* houskeeping (telemetry) table of a gomspace
* device.
*/
GomspaceDeviceHandler(object_id_t objectId, object_id_t comIF, CookieIF *comCookie,
uint16_t maxConfigTableAddress, uint16_t maxHkTableAddress,
uint16_t hkTableReplySize, LocalPoolDataSetBase *hkTableDataset);
virtual ~GomspaceDeviceHandler();
/**
* @brief Constructor
*
* @param maxConfigTableAddress The maximum memory address of the configu-
* ration table of a gomspace device.
* @param maxHkTableAddress The maximum memory address of a value in the
* houskeeping (telemetry) table of a gomspace
* device.
*/
GomspaceDeviceHandler(object_id_t objectId, object_id_t comIF,
CookieIF * comCookie, uint16_t maxConfigTableAddress, uint16_t maxHkTableAddress,
uint16_t hkTableReplySize, LocalPoolDataSetBase* hkTableDataset);
virtual ~GomspaceDeviceHandler();
/**
* @brief This function can be used to set a gomspace device to normal mode immediately after
* object creation.
*/
void setModeNormal();
/**
* @brief This function can be used to set a gomspace device to normal mode immediately after
* object creation.
*/
void setModeNormal();
protected:
static const uint8_t MAX_PACKET_LEN = 36;
static const uint8_t PARAM_SET_OK = 1;
static const uint8_t PING_REPLY_SIZE = 2;
static const uint8_t CONFIG_TABLE_ID = 1;
static const uint8_t HK_TABLE_ID = 4;
protected:
uint8_t rememberRequestedSize = 0;
uint8_t rememberCommandId = GOMSPACE::NONE;
uint8_t cspPacket[MAX_PACKET_LEN];
static const uint8_t MAX_PACKET_LEN = 36;
static const uint8_t PARAM_SET_OK = 1;
static const uint8_t PING_REPLY_SIZE = 2;
static const uint8_t CONFIG_TABLE_ID = 1;
static const uint8_t HK_TABLE_ID = 4;
uint16_t maxConfigTableAddress;
uint16_t maxHkTableAddress;
uint8_t rememberRequestedSize = 0;
uint8_t rememberCommandId = GOMSPACE::NONE;
uint8_t cspPacket[MAX_PACKET_LEN];
/** The size of the reply following a full hk table request.*/
uint16_t hkTableReplySize;
uint16_t maxConfigTableAddress;
uint16_t maxHkTableAddress;
LocalPoolDataSetBase *hkTableDataset = nullptr;
/** The size of the reply following a full hk table request.*/
uint16_t hkTableReplySize;
void doStartUp() override;
void doShutDown() override;
virtual ReturnValue_t buildNormalDeviceCommand(DeviceCommandId_t *id) override;
ReturnValue_t buildTransitionDeviceCommand(DeviceCommandId_t *id) override;
virtual void fillCommandAndReplyMap() override;
ReturnValue_t buildCommandFromCommand(DeviceCommandId_t deviceCommand, const uint8_t *commandData,
size_t commandDataLen) override;
ReturnValue_t scanForReply(const uint8_t *start, size_t remainingSize, DeviceCommandId_t *foundId,
size_t *foundLen) override;
ReturnValue_t interpretDeviceReply(DeviceCommandId_t id, const uint8_t *packet) override;
void setNormalDatapoolEntriesInvalid() override;
uint32_t getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) override;
/**
* @brief The command to generate a request to receive the full housekeeping table is device
* specific. Thus the child has to build this command.
*/
virtual ReturnValue_t generateRequestFullHkTableCmd(uint16_t hkTableSize);
LocalPoolDataSetBase* hkTableDataset = nullptr;
/**
* This command handles printing the HK table to the console. This is useful for debugging
* purposes
* @return
*/
virtual ReturnValue_t printStatus(DeviceCommandId_t cmd);
void doStartUp() override;
void doShutDown() override;
virtual ReturnValue_t buildNormalDeviceCommand(DeviceCommandId_t * id)
override;
ReturnValue_t buildTransitionDeviceCommand(DeviceCommandId_t * id) override;
virtual void fillCommandAndReplyMap() override;
ReturnValue_t buildCommandFromCommand(DeviceCommandId_t deviceCommand,
const uint8_t * commandData,size_t commandDataLen) override;
ReturnValue_t scanForReply(const uint8_t *start, size_t remainingSize,
DeviceCommandId_t *foundId, size_t *foundLen) override;
ReturnValue_t interpretDeviceReply(DeviceCommandId_t id,
const uint8_t *packet) override;
void setNormalDatapoolEntriesInvalid() override;
uint32_t getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) override;
/**
* @brief The command to generate a request to receive the full housekeeping table is device
* specific. Thus the child has to build this command.
*/
virtual ReturnValue_t generateRequestFullHkTableCmd(uint16_t hkTableSize);
/**
* @brief Because housekeeping tables are device specific the handling of the reply is
* given to the child class.
* @param id The id of the command which initiates the full table request.
* @param packet Pointer to the reply containing the hk table.
*/
virtual void letChildHandleHkReply(DeviceCommandId_t id, const uint8_t *packet) = 0;
/**
* This command handles printing the HK table to the console. This is useful for debugging
* purposes
* @return
*/
virtual ReturnValue_t printStatus(DeviceCommandId_t cmd);
virtual LocalPoolDataSetBase *getDataSetHandle(sid_t sid) override;
/**
* @brief Because housekeeping tables are device specific the handling of the reply is
* given to the child class.
* @param id The id of the command which initiates the full table request.
* @param packet Pointer to the reply containing the hk table.
*/
virtual void letChildHandleHkReply(DeviceCommandId_t id, const uint8_t *packet) = 0;
/**
* @brief Can be used by gomspace devices to implement device specific commands.
*/
virtual ReturnValue_t deviceSpecificCommand(DeviceCommandId_t cmd);
virtual LocalPoolDataSetBase* getDataSetHandle(sid_t sid) override;
private:
/**
* @brief Function to generate the command to set a parameter. Command
* will be sent to the ComIF over the rawPacket buffer.
*/
ReturnValue_t generateSetParamCommand(const uint8_t *commandData, size_t commandDataLen);
/**
* @brief Can be used by gomspace devices to implement device specific commands.
*/
virtual ReturnValue_t deviceSpecificCommand(DeviceCommandId_t cmd);
/**
* @brief Function to generate the command to get a parameter from a
* gomspace device. Command will be sent to the ComIF over the
* rawPacket buffer.
*/
ReturnValue_t generateGetParamCommand(const uint8_t *commandData, size_t commandDataLen);
private:
/**
* @brief Function to generate the ping command for the ComIF.
*/
ReturnValue_t generatePingCommand(const uint8_t *commandData, size_t commandDataLen);
/**
* @brief Function to generate the command to set a parameter. Command
* will be sent to the ComIF over the rawPacket buffer.
*/
ReturnValue_t generateSetParamCommand(const uint8_t * commandData,
size_t commandDataLen);
/**
* @brief Function to generate the command to get a parameter from a
* gomspace device. Command will be sent to the ComIF over the
* rawPacket buffer.
*/
ReturnValue_t generateGetParamCommand(const uint8_t * commandData,
size_t commandDataLen);
/**
* @brief Function to generate the ping command for the ComIF.
*/
ReturnValue_t generatePingCommand(const uint8_t * commandData,
size_t commandDataLen);
/**
* @brief Function to generate the command to reboot a gomspace device
* via the ComIF.
*/
void generateRebootCommand();
/**
* @brief Function to generate the command to force a ground watchdog
* reset in a gomspace device.
*/
ReturnValue_t generateResetWatchdogCmd();
/**
* @brief Function to generate the command to reboot a gomspace device
* via the ComIF.
*/
void generateRebootCommand();
/**
* @brief Function to generate the command to force a ground watchdog
* reset in a gomspace device.
*/
ReturnValue_t generateResetWatchdogCmd();
};
#endif /* MISSION_DEVICES_GOMSPACEDEVICEHANDLER_H_ */

View File

@ -1,481 +1,482 @@
#include "GyroADIS1650XHandler.h"
#include <fsfw/action/HasActionsIF.h>
#include <fsfw/datapool/PoolReadGuard.h>
#if OBSW_ADIS1650X_LINUX_COM_IF == 1
#include "fsfw_hal/linux/utility.h"
#include "fsfw_hal/linux/spi/SpiCookie.h"
#include "fsfw_hal/linux/spi/SpiComIF.h"
#include "fsfw_hal/linux/UnixFileGuard.h"
#include <sys/ioctl.h>
#include <unistd.h>
#include "fsfw_hal/linux/UnixFileGuard.h"
#include "fsfw_hal/linux/spi/SpiComIF.h"
#include "fsfw_hal/linux/spi/SpiCookie.h"
#include "fsfw_hal/linux/utility.h"
#endif
GyroADIS1650XHandler::GyroADIS1650XHandler(object_id_t objectId,
object_id_t deviceCommunication, CookieIF * comCookie, ADIS1650X::Type type):
DeviceHandlerBase(objectId, deviceCommunication, comCookie), adisType(type),
primaryDataset(this), configDataset(this), breakCountdown() {
GyroADIS1650XHandler::GyroADIS1650XHandler(object_id_t objectId, object_id_t deviceCommunication,
CookieIF *comCookie, ADIS1650X::Type type)
: DeviceHandlerBase(objectId, deviceCommunication, comCookie),
adisType(type),
primaryDataset(this),
configDataset(this),
breakCountdown() {
#if FSFW_HAL_ADIS1650X_GYRO_DEBUG == 1
debugDivider = new PeriodicOperationDivider(5);
debugDivider = new PeriodicOperationDivider(5);
#endif
#if OBSW_ADIS1650X_LINUX_COM_IF == 1
SpiCookie* cookie = dynamic_cast<SpiCookie*>(comCookie);
if(cookie != nullptr) {
cookie->setCallbackMode(&spiSendCallback, this);
}
SpiCookie *cookie = dynamic_cast<SpiCookie *>(comCookie);
if (cookie != nullptr) {
cookie->setCallbackMode(&spiSendCallback, this);
}
#endif
}
void GyroADIS1650XHandler::doStartUp() {
// Initial 310 ms start up time after power-up
if(internalState == InternalState::STARTUP) {
if(not commandExecuted) {
breakCountdown.setTimeout(ADIS1650X::START_UP_TIME);
commandExecuted = true;
}
if(breakCountdown.hasTimedOut()) {
internalState = InternalState::CONFIG;
commandExecuted = false;
}
// Initial 310 ms start up time after power-up
if (internalState == InternalState::STARTUP) {
if (not commandExecuted) {
breakCountdown.setTimeout(ADIS1650X::START_UP_TIME);
commandExecuted = true;
}
if (breakCountdown.hasTimedOut()) {
internalState = InternalState::CONFIG;
commandExecuted = false;
}
}
// Read all configuration registers first
if(internalState == InternalState::CONFIG) {
if(commandExecuted) {
commandExecuted = false;
internalState = InternalState::IDLE;
}
// Read all configuration registers first
if (internalState == InternalState::CONFIG) {
if (commandExecuted) {
commandExecuted = false;
internalState = InternalState::IDLE;
}
}
if(internalState == InternalState::IDLE) {
setMode(MODE_NORMAL);
// setMode(MODE_ON);
}
if (internalState == InternalState::IDLE) {
setMode(MODE_NORMAL);
// setMode(MODE_ON);
}
}
void GyroADIS1650XHandler::doShutDown() {
commandExecuted = false;
setMode(_MODE_POWER_DOWN);
commandExecuted = false;
setMode(_MODE_POWER_DOWN);
}
ReturnValue_t GyroADIS1650XHandler::buildNormalDeviceCommand(DeviceCommandId_t *id) {
*id = ADIS1650X::READ_SENSOR_DATA;
return buildCommandFromCommand(*id, nullptr, 0);
*id = ADIS1650X::READ_SENSOR_DATA;
return buildCommandFromCommand(*id, nullptr, 0);
}
ReturnValue_t GyroADIS1650XHandler::buildTransitionDeviceCommand(DeviceCommandId_t *id) {
switch(internalState) {
case(InternalState::CONFIG): {
*id = ADIS1650X::READ_OUT_CONFIG;
buildCommandFromCommand(*id, nullptr, 0);
break;
switch (internalState) {
case (InternalState::CONFIG): {
*id = ADIS1650X::READ_OUT_CONFIG;
buildCommandFromCommand(*id, nullptr, 0);
break;
}
case(InternalState::STARTUP): {
return NOTHING_TO_SEND;
break;
case (InternalState::STARTUP): {
return NOTHING_TO_SEND;
break;
}
default: {
/* Might be a configuration error. */
sif::debug << "GyroADIS16507Handler::buildTransitionDeviceCommand: "
"Unknown internal state!" << std::endl;
return HasReturnvaluesIF::RETURN_OK;
/* Might be a configuration error. */
sif::debug << "GyroADIS16507Handler::buildTransitionDeviceCommand: "
"Unknown internal state!"
<< std::endl;
return HasReturnvaluesIF::RETURN_OK;
}
}
return HasReturnvaluesIF::RETURN_OK;
}
return HasReturnvaluesIF::RETURN_OK;
}
ReturnValue_t GyroADIS1650XHandler::buildCommandFromCommand(DeviceCommandId_t deviceCommand,
const uint8_t *commandData, size_t commandDataLen) {
switch(deviceCommand) {
case(ADIS1650X::READ_OUT_CONFIG): {
this->rawPacketLen = ADIS1650X::CONFIG_READOUT_SIZE;
uint8_t regList[5];
regList[0] = ADIS1650X::DIAG_STAT_REG;
regList[1] = ADIS1650X::FILTER_CTRL_REG;
regList[2] = ADIS1650X::MSC_CTRL_REG;
regList[3] = ADIS1650X::DEC_RATE_REG;
regList[4] = ADIS1650X::PROD_ID_REG;
prepareReadCommand(regList, sizeof(regList));
this->rawPacket = commandBuffer.data();
break;
const uint8_t *commandData,
size_t commandDataLen) {
switch (deviceCommand) {
case (ADIS1650X::READ_OUT_CONFIG): {
this->rawPacketLen = ADIS1650X::CONFIG_READOUT_SIZE;
uint8_t regList[5];
regList[0] = ADIS1650X::DIAG_STAT_REG;
regList[1] = ADIS1650X::FILTER_CTRL_REG;
regList[2] = ADIS1650X::MSC_CTRL_REG;
regList[3] = ADIS1650X::DEC_RATE_REG;
regList[4] = ADIS1650X::PROD_ID_REG;
prepareReadCommand(regList, sizeof(regList));
this->rawPacket = commandBuffer.data();
break;
}
case(ADIS1650X::READ_SENSOR_DATA): {
if(breakCountdown.isBusy()) {
// A glob command is pending and sensor data can't be read currently
return NO_REPLY_EXPECTED;
}
std::memcpy(commandBuffer.data(), ADIS1650X::BURST_READ_ENABLE.data(),
ADIS1650X::BURST_READ_ENABLE.size());
std::memset(commandBuffer.data() + 2, 0, 10 * 2);
this->rawPacketLen = ADIS1650X::SENSOR_READOUT_SIZE;
this->rawPacket = commandBuffer.data();
break;
case (ADIS1650X::READ_SENSOR_DATA): {
if (breakCountdown.isBusy()) {
// A glob command is pending and sensor data can't be read currently
return NO_REPLY_EXPECTED;
}
std::memcpy(commandBuffer.data(), ADIS1650X::BURST_READ_ENABLE.data(),
ADIS1650X::BURST_READ_ENABLE.size());
std::memset(commandBuffer.data() + 2, 0, 10 * 2);
this->rawPacketLen = ADIS1650X::SENSOR_READOUT_SIZE;
this->rawPacket = commandBuffer.data();
break;
}
case(ADIS1650X::SELF_TEST_SENSORS): {
if(breakCountdown.isBusy()) {
// Another glob command is pending
return HasActionsIF::IS_BUSY;
}
prepareWriteCommand(ADIS1650X::GLOB_CMD, ADIS1650X::GlobCmds::SENSOR_SELF_TEST, 0x00);
breakCountdown.setTimeout(ADIS1650X::SELF_TEST_BREAK);
break;
case (ADIS1650X::SELF_TEST_SENSORS): {
if (breakCountdown.isBusy()) {
// Another glob command is pending
return HasActionsIF::IS_BUSY;
}
prepareWriteCommand(ADIS1650X::GLOB_CMD, ADIS1650X::GlobCmds::SENSOR_SELF_TEST, 0x00);
breakCountdown.setTimeout(ADIS1650X::SELF_TEST_BREAK);
break;
}
case(ADIS1650X::SELF_TEST_MEMORY): {
if(breakCountdown.isBusy()) {
// Another glob command is pending
return HasActionsIF::IS_BUSY;
}
prepareWriteCommand(ADIS1650X::GLOB_CMD, ADIS1650X::GlobCmds::FLASH_MEMORY_TEST, 0x00);
breakCountdown.setTimeout(ADIS1650X::FLASH_MEMORY_TEST_BREAK);
break;
case (ADIS1650X::SELF_TEST_MEMORY): {
if (breakCountdown.isBusy()) {
// Another glob command is pending
return HasActionsIF::IS_BUSY;
}
prepareWriteCommand(ADIS1650X::GLOB_CMD, ADIS1650X::GlobCmds::FLASH_MEMORY_TEST, 0x00);
breakCountdown.setTimeout(ADIS1650X::FLASH_MEMORY_TEST_BREAK);
break;
}
case(ADIS1650X::UPDATE_NV_CONFIGURATION): {
if(breakCountdown.isBusy()) {
// Another glob command is pending
return HasActionsIF::IS_BUSY;
}
prepareWriteCommand(ADIS1650X::GLOB_CMD, ADIS1650X::GlobCmds::FLASH_MEMORY_UPDATE, 0x00);
breakCountdown.setTimeout(ADIS1650X::FLASH_MEMORY_UPDATE_BREAK);
break;
case (ADIS1650X::UPDATE_NV_CONFIGURATION): {
if (breakCountdown.isBusy()) {
// Another glob command is pending
return HasActionsIF::IS_BUSY;
}
prepareWriteCommand(ADIS1650X::GLOB_CMD, ADIS1650X::GlobCmds::FLASH_MEMORY_UPDATE, 0x00);
breakCountdown.setTimeout(ADIS1650X::FLASH_MEMORY_UPDATE_BREAK);
break;
}
case(ADIS1650X::RESET_SENSOR_CONFIGURATION): {
if(breakCountdown.isBusy()) {
// Another glob command is pending
return HasActionsIF::IS_BUSY;
}
prepareWriteCommand(ADIS1650X::GLOB_CMD, ADIS1650X::GlobCmds::FACTORY_CALIBRATION, 0x00);
breakCountdown.setTimeout(ADIS1650X::FACTORY_CALIBRATION_BREAK);
break;
case (ADIS1650X::RESET_SENSOR_CONFIGURATION): {
if (breakCountdown.isBusy()) {
// Another glob command is pending
return HasActionsIF::IS_BUSY;
}
prepareWriteCommand(ADIS1650X::GLOB_CMD, ADIS1650X::GlobCmds::FACTORY_CALIBRATION, 0x00);
breakCountdown.setTimeout(ADIS1650X::FACTORY_CALIBRATION_BREAK);
break;
}
case(ADIS1650X::SW_RESET): {
if(breakCountdown.isBusy()) {
// Another glob command is pending
return HasActionsIF::IS_BUSY;
}
prepareWriteCommand(ADIS1650X::GLOB_CMD, ADIS1650X::GlobCmds::SOFTWARE_RESET, 0x00);
breakCountdown.setTimeout(ADIS1650X::SW_RESET_BREAK);
break;
case (ADIS1650X::SW_RESET): {
if (breakCountdown.isBusy()) {
// Another glob command is pending
return HasActionsIF::IS_BUSY;
}
prepareWriteCommand(ADIS1650X::GLOB_CMD, ADIS1650X::GlobCmds::SOFTWARE_RESET, 0x00);
breakCountdown.setTimeout(ADIS1650X::SW_RESET_BREAK);
break;
}
case(ADIS1650X::PRINT_CURRENT_CONFIGURATION): {
case (ADIS1650X::PRINT_CURRENT_CONFIGURATION): {
#if OBSW_VERBOSE_LEVEL >= 1
PoolReadGuard pg(&configDataset);
sif::info << "ADIS16507 Sensor configuration: DIAG_STAT: 0x" << std::hex << std::setw(4) <<
std::setfill('0') << "0x" << configDataset.diagStatReg.value << std::endl;
sif::info << "MSC_CTRL: " << std::hex << std::setw(4) << "0x" <<
configDataset.mscCtrlReg.value << " | FILT_CTRL: 0x" <<
configDataset.filterSetting.value << " | DEC_RATE: 0x" <<
configDataset.decRateReg.value << std::setfill(' ') << std::endl;
PoolReadGuard pg(&configDataset);
sif::info << "ADIS16507 Sensor configuration: DIAG_STAT: 0x" << std::hex << std::setw(4)
<< std::setfill('0') << "0x" << configDataset.diagStatReg.value << std::endl;
sif::info << "MSC_CTRL: " << std::hex << std::setw(4) << "0x"
<< configDataset.mscCtrlReg.value << " | FILT_CTRL: 0x"
<< configDataset.filterSetting.value << " | DEC_RATE: 0x"
<< configDataset.decRateReg.value << std::setfill(' ') << std::endl;
#endif /* OBSW_VERBOSE_LEVEL >= 1 */
}
}
return HasReturnvaluesIF::RETURN_OK;
}
return HasReturnvaluesIF::RETURN_OK;
}
void GyroADIS1650XHandler::fillCommandAndReplyMap() {
insertInCommandAndReplyMap(ADIS1650X::READ_SENSOR_DATA, 1, &primaryDataset);
insertInCommandAndReplyMap(ADIS1650X::READ_OUT_CONFIG, 1, &configDataset);
insertInCommandAndReplyMap(ADIS1650X::SELF_TEST_SENSORS, 1);
insertInCommandAndReplyMap(ADIS1650X::SELF_TEST_MEMORY, 1);
insertInCommandAndReplyMap(ADIS1650X::UPDATE_NV_CONFIGURATION, 1);
insertInCommandAndReplyMap(ADIS1650X::RESET_SENSOR_CONFIGURATION, 1);
insertInCommandAndReplyMap(ADIS1650X::SW_RESET, 1);
insertInCommandAndReplyMap(ADIS1650X::PRINT_CURRENT_CONFIGURATION, 1);
insertInCommandAndReplyMap(ADIS1650X::READ_SENSOR_DATA, 1, &primaryDataset);
insertInCommandAndReplyMap(ADIS1650X::READ_OUT_CONFIG, 1, &configDataset);
insertInCommandAndReplyMap(ADIS1650X::SELF_TEST_SENSORS, 1);
insertInCommandAndReplyMap(ADIS1650X::SELF_TEST_MEMORY, 1);
insertInCommandAndReplyMap(ADIS1650X::UPDATE_NV_CONFIGURATION, 1);
insertInCommandAndReplyMap(ADIS1650X::RESET_SENSOR_CONFIGURATION, 1);
insertInCommandAndReplyMap(ADIS1650X::SW_RESET, 1);
insertInCommandAndReplyMap(ADIS1650X::PRINT_CURRENT_CONFIGURATION, 1);
}
ReturnValue_t GyroADIS1650XHandler::scanForReply(const uint8_t *start, size_t remainingSize,
DeviceCommandId_t *foundId, size_t *foundLen) {
// For SPI, the ID will always be the one of the last sent command
*foundId = this->getPendingCommand();
*foundLen = this->rawPacketLen;
DeviceCommandId_t *foundId, size_t *foundLen) {
// For SPI, the ID will always be the one of the last sent command
*foundId = this->getPendingCommand();
*foundLen = this->rawPacketLen;
return HasReturnvaluesIF::RETURN_OK;
return HasReturnvaluesIF::RETURN_OK;
}
ReturnValue_t GyroADIS1650XHandler::interpretDeviceReply(DeviceCommandId_t id,
const uint8_t *packet) {
switch(id) {
case(ADIS1650X::READ_OUT_CONFIG): {
uint16_t readProdId = packet[10] << 8 | packet[11];
if(((adisType == ADIS1650X::Type::ADIS16507) and
(readProdId != ADIS1650X::PROD_ID_16507)) or
((adisType == ADIS1650X::Type::ADIS16505) and
(readProdId != ADIS1650X::PROD_ID_16505))) {
const uint8_t *packet) {
switch (id) {
case (ADIS1650X::READ_OUT_CONFIG): {
uint16_t readProdId = packet[10] << 8 | packet[11];
if (((adisType == ADIS1650X::Type::ADIS16507) and (readProdId != ADIS1650X::PROD_ID_16507)) or
((adisType == ADIS1650X::Type::ADIS16505) and (readProdId != ADIS1650X::PROD_ID_16505))) {
#if OBSW_VERBOSE_LEVEL >= 1
sif::warning << "GyroADIS1650XHandler::interpretDeviceReply: Invalid product ID "
<< readProdId << std::endl;
sif::warning << "GyroADIS1650XHandler::interpretDeviceReply: Invalid product ID "
<< readProdId << std::endl;
#endif
return HasReturnvaluesIF::RETURN_FAILED;
}
PoolReadGuard rg(&configDataset);
configDataset.diagStatReg.value = packet[2] << 8 | packet[3];
configDataset.filterSetting.value = packet[4] << 8 | packet[5];
configDataset.mscCtrlReg.value = packet[6] << 8 | packet[7];
configDataset.decRateReg.value = packet[8] << 8 | packet[9];
configDataset.setValidity(true, true);
if(internalState == InternalState::CONFIG) {
commandExecuted = true;
}
break;
return HasReturnvaluesIF::RETURN_FAILED;
}
PoolReadGuard rg(&configDataset);
configDataset.diagStatReg.value = packet[2] << 8 | packet[3];
configDataset.filterSetting.value = packet[4] << 8 | packet[5];
configDataset.mscCtrlReg.value = packet[6] << 8 | packet[7];
configDataset.decRateReg.value = packet[8] << 8 | packet[9];
configDataset.setValidity(true, true);
if (internalState == InternalState::CONFIG) {
commandExecuted = true;
}
break;
}
case(ADIS1650X::READ_SENSOR_DATA): {
return handleSensorData(packet);
case (ADIS1650X::READ_SENSOR_DATA): {
return handleSensorData(packet);
}
}
return HasReturnvaluesIF::RETURN_OK;
}
return HasReturnvaluesIF::RETURN_OK;
}
ReturnValue_t GyroADIS1650XHandler::handleSensorData(const uint8_t *packet) {
BurstModes burstMode = getBurstMode();
switch(burstMode) {
case(BurstModes::BURST_16_BURST_SEL_1):
case(BurstModes::BURST_32_BURST_SEL_1): {
sif::warning << "GyroADIS1650XHandler::interpretDeviceReply: Analysis with BURST_SEL1"
" not implemented!" << std::endl;
return HasReturnvaluesIF::RETURN_OK;
BurstModes burstMode = getBurstMode();
switch (burstMode) {
case (BurstModes::BURST_16_BURST_SEL_1):
case (BurstModes::BURST_32_BURST_SEL_1): {
sif::warning << "GyroADIS1650XHandler::interpretDeviceReply: Analysis with BURST_SEL1"
" not implemented!"
<< std::endl;
return HasReturnvaluesIF::RETURN_OK;
}
case(BurstModes::BURST_16_BURST_SEL_0): {
uint16_t checksum = packet[20] << 8 | packet[21];
// Now verify the read checksum with the expected checksum according to datasheet p. 20
uint16_t calcChecksum = 0;
for(size_t idx = 2; idx < 20; idx ++) {
calcChecksum += packet[idx];
}
if(checksum != calcChecksum) {
case (BurstModes::BURST_16_BURST_SEL_0): {
uint16_t checksum = packet[20] << 8 | packet[21];
// Now verify the read checksum with the expected checksum according to datasheet p. 20
uint16_t calcChecksum = 0;
for (size_t idx = 2; idx < 20; idx++) {
calcChecksum += packet[idx];
}
if (checksum != calcChecksum) {
#if OBSW_VERBOSE_LEVEL >= 1
sif::warning << "GyroADIS1650XHandler::interpretDeviceReply: "
"Invalid checksum detected!" << std::endl;
sif::warning << "GyroADIS1650XHandler::interpretDeviceReply: "
"Invalid checksum detected!"
<< std::endl;
#endif
return HasReturnvaluesIF::RETURN_FAILED;
return HasReturnvaluesIF::RETURN_FAILED;
}
ReturnValue_t result = configDataset.diagStatReg.read();
if (result == HasReturnvaluesIF::RETURN_OK) {
configDataset.diagStatReg.value = packet[2] << 8 | packet[3];
configDataset.diagStatReg.setValid(true);
}
configDataset.diagStatReg.commit();
{
PoolReadGuard pg(&primaryDataset);
int16_t angVelocXRaw = packet[4] << 8 | packet[5];
primaryDataset.angVelocX.value =
static_cast<float>(angVelocXRaw) / INT16_MAX * ADIS1650X::GYRO_RANGE;
int16_t angVelocYRaw = packet[6] << 8 | packet[7];
primaryDataset.angVelocY.value =
static_cast<float>(angVelocYRaw) / INT16_MAX * ADIS1650X::GYRO_RANGE;
int16_t angVelocZRaw = packet[8] << 8 | packet[9];
primaryDataset.angVelocZ.value =
static_cast<float>(angVelocZRaw) / INT16_MAX * ADIS1650X::GYRO_RANGE;
float accelScaling = 0;
if (adisType == ADIS1650X::Type::ADIS16507) {
accelScaling = ADIS1650X::ACCELEROMETER_RANGE_16507;
} else if (adisType == ADIS1650X::Type::ADIS16505) {
accelScaling = ADIS1650X::ACCELEROMETER_RANGE_16505;
} else {
sif::warning << "GyroADIS1650XHandler::handleSensorData: "
"Unknown ADIS type"
<< std::endl;
}
int16_t accelXRaw = packet[10] << 8 | packet[11];
primaryDataset.accelX.value = static_cast<float>(accelXRaw) / INT16_MAX * accelScaling;
int16_t accelYRaw = packet[12] << 8 | packet[13];
primaryDataset.accelY.value = static_cast<float>(accelYRaw) / INT16_MAX * accelScaling;
int16_t accelZRaw = packet[14] << 8 | packet[15];
primaryDataset.accelZ.value = static_cast<float>(accelZRaw) / INT16_MAX * accelScaling;
ReturnValue_t result = configDataset.diagStatReg.read();
if(result == HasReturnvaluesIF::RETURN_OK) {
configDataset.diagStatReg.value = packet[2] << 8 | packet[3];
configDataset.diagStatReg.setValid(true);
}
configDataset.diagStatReg.commit();
{
PoolReadGuard pg(&primaryDataset);
int16_t angVelocXRaw = packet[4] << 8 | packet[5];
primaryDataset.angVelocX.value = static_cast<float>(angVelocXRaw) / INT16_MAX *
ADIS1650X::GYRO_RANGE;
int16_t angVelocYRaw = packet[6] << 8 | packet[7];
primaryDataset.angVelocY.value = static_cast<float>(angVelocYRaw) / INT16_MAX *
ADIS1650X::GYRO_RANGE;
int16_t angVelocZRaw = packet[8] << 8 | packet[9];
primaryDataset.angVelocZ.value = static_cast<float>(angVelocZRaw) / INT16_MAX *
ADIS1650X::GYRO_RANGE;
float accelScaling = 0;
if(adisType == ADIS1650X::Type::ADIS16507) {
accelScaling = ADIS1650X::ACCELEROMETER_RANGE_16507;
} else if(adisType == ADIS1650X::Type::ADIS16505) {
accelScaling = ADIS1650X::ACCELEROMETER_RANGE_16505;
} else {
sif::warning << "GyroADIS1650XHandler::handleSensorData: "
"Unknown ADIS type" << std::endl;
}
int16_t accelXRaw = packet[10] << 8 | packet[11];
primaryDataset.accelX.value = static_cast<float>(accelXRaw) / INT16_MAX *
accelScaling;
int16_t accelYRaw = packet[12] << 8 | packet[13];
primaryDataset.accelY.value = static_cast<float>(accelYRaw) / INT16_MAX *
accelScaling;
int16_t accelZRaw = packet[14] << 8 | packet[15];
primaryDataset.accelZ.value = static_cast<float>(accelZRaw) / INT16_MAX *
accelScaling;
int16_t temperatureRaw = packet[16] << 8 | packet[17];
primaryDataset.temperature.value = static_cast<float>(temperatureRaw) * 0.1;
// Ignore data counter for now
primaryDataset.setValidity(true, true);
}
int16_t temperatureRaw = packet[16] << 8 | packet[17];
primaryDataset.temperature.value = static_cast<float>(temperatureRaw) * 0.1;
// Ignore data counter for now
primaryDataset.setValidity(true, true);
}
#if FSFW_HAL_ADIS1650X_GYRO_DEBUG == 1
if(debugDivider->checkAndIncrement()) {
sif::info << "GyroADIS1650XHandler: Angular velocities in deg / s" << std::endl;
sif::info << "X: " << primaryDataset.angVelocX.value << std::endl;
sif::info << "Y: " << primaryDataset.angVelocY.value << std::endl;
sif::info << "Z: " << primaryDataset.angVelocZ.value << std::endl;
sif::info << "GyroADIS1650XHandler: Accelerations in m / s^2: " << std::endl;
sif::info << "X: " << primaryDataset.accelX.value << std::endl;
sif::info << "Y: " << primaryDataset.accelY.value << std::endl;
sif::info << "Z: " << primaryDataset.accelZ.value << std::endl;
}
if (debugDivider->checkAndIncrement()) {
sif::info << "GyroADIS1650XHandler: Angular velocities in deg / s" << std::endl;
sif::info << "X: " << primaryDataset.angVelocX.value << std::endl;
sif::info << "Y: " << primaryDataset.angVelocY.value << std::endl;
sif::info << "Z: " << primaryDataset.angVelocZ.value << std::endl;
sif::info << "GyroADIS1650XHandler: Accelerations in m / s^2: " << std::endl;
sif::info << "X: " << primaryDataset.accelX.value << std::endl;
sif::info << "Y: " << primaryDataset.accelY.value << std::endl;
sif::info << "Z: " << primaryDataset.accelZ.value << std::endl;
}
#endif
break;
break;
}
case(BurstModes::BURST_32_BURST_SEL_0): {
break;
case (BurstModes::BURST_32_BURST_SEL_0): {
break;
}
}
return HasReturnvaluesIF::RETURN_OK;
}
return HasReturnvaluesIF::RETURN_OK;
}
uint32_t GyroADIS1650XHandler::getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) {
return 10000;
return 10000;
}
void GyroADIS1650XHandler::prepareWriteCommand(uint8_t startReg, uint8_t valueOne,
uint8_t valueTwo) {
uint8_t secondReg = startReg + 1;
startReg |= ADIS1650X::WRITE_MASK;
secondReg |= ADIS1650X::WRITE_MASK;
commandBuffer[0] = startReg;
commandBuffer[1] = valueOne;
commandBuffer[2] = secondReg;
commandBuffer[3] = valueTwo;
this->rawPacketLen = 4;
this->rawPacket = commandBuffer.data();
uint8_t valueTwo) {
uint8_t secondReg = startReg + 1;
startReg |= ADIS1650X::WRITE_MASK;
secondReg |= ADIS1650X::WRITE_MASK;
commandBuffer[0] = startReg;
commandBuffer[1] = valueOne;
commandBuffer[2] = secondReg;
commandBuffer[3] = valueTwo;
this->rawPacketLen = 4;
this->rawPacket = commandBuffer.data();
}
void GyroADIS1650XHandler::prepareReadCommand(uint8_t *regList, size_t len) {
for(size_t idx = 0; idx < len; idx++) {
commandBuffer[idx * 2] = regList[idx];
commandBuffer[idx * 2 + 1] = 0x00;
}
commandBuffer[len * 2] = 0x00;
commandBuffer[len * 2 + 1] = 0x00;
for (size_t idx = 0; idx < len; idx++) {
commandBuffer[idx * 2] = regList[idx];
commandBuffer[idx * 2 + 1] = 0x00;
}
commandBuffer[len * 2] = 0x00;
commandBuffer[len * 2 + 1] = 0x00;
}
ReturnValue_t GyroADIS1650XHandler::initializeLocalDataPool(localpool::DataPool &localDataPoolMap,
LocalDataPoolManager &poolManager) {
localDataPoolMap.emplace(ADIS1650X::ANG_VELOC_X, new PoolEntry<double>({0.0}));
localDataPoolMap.emplace(ADIS1650X::ANG_VELOC_Y, new PoolEntry<double>({0.0}));
localDataPoolMap.emplace(ADIS1650X::ANG_VELOC_Z, new PoolEntry<double>({0.0}));
localDataPoolMap.emplace(ADIS1650X::ACCELERATION_X, new PoolEntry<double>({0.0}));
localDataPoolMap.emplace(ADIS1650X::ACCELERATION_Y, new PoolEntry<double>({0.0}));
localDataPoolMap.emplace(ADIS1650X::ACCELERATION_Z, new PoolEntry<double>({0.0}));
localDataPoolMap.emplace(ADIS1650X::TEMPERATURE, new PoolEntry<float>({0.0}));
LocalDataPoolManager &poolManager) {
localDataPoolMap.emplace(ADIS1650X::ANG_VELOC_X, new PoolEntry<double>({0.0}));
localDataPoolMap.emplace(ADIS1650X::ANG_VELOC_Y, new PoolEntry<double>({0.0}));
localDataPoolMap.emplace(ADIS1650X::ANG_VELOC_Z, new PoolEntry<double>({0.0}));
localDataPoolMap.emplace(ADIS1650X::ACCELERATION_X, new PoolEntry<double>({0.0}));
localDataPoolMap.emplace(ADIS1650X::ACCELERATION_Y, new PoolEntry<double>({0.0}));
localDataPoolMap.emplace(ADIS1650X::ACCELERATION_Z, new PoolEntry<double>({0.0}));
localDataPoolMap.emplace(ADIS1650X::TEMPERATURE, new PoolEntry<float>({0.0}));
localDataPoolMap.emplace(ADIS1650X::DIAG_STAT_REGISTER, new PoolEntry<uint16_t>());
localDataPoolMap.emplace(ADIS1650X::FILTER_SETTINGS, new PoolEntry<uint8_t>());
localDataPoolMap.emplace(ADIS1650X::MSC_CTRL_REGISTER, new PoolEntry<uint16_t>());
localDataPoolMap.emplace(ADIS1650X::DEC_RATE_REGISTER, new PoolEntry<uint16_t>());
return HasReturnvaluesIF::RETURN_OK;
localDataPoolMap.emplace(ADIS1650X::DIAG_STAT_REGISTER, new PoolEntry<uint16_t>());
localDataPoolMap.emplace(ADIS1650X::FILTER_SETTINGS, new PoolEntry<uint8_t>());
localDataPoolMap.emplace(ADIS1650X::MSC_CTRL_REGISTER, new PoolEntry<uint16_t>());
localDataPoolMap.emplace(ADIS1650X::DEC_RATE_REGISTER, new PoolEntry<uint16_t>());
return HasReturnvaluesIF::RETURN_OK;
}
GyroADIS1650XHandler::BurstModes GyroADIS1650XHandler::getBurstMode() {
configDataset.mscCtrlReg.read();
uint16_t currentCtrlReg = configDataset.mscCtrlReg.value;
configDataset.mscCtrlReg.commit();
if((currentCtrlReg & ADIS1650X::BURST_32_BIT) == ADIS1650X::BURST_32_BIT) {
if((currentCtrlReg & ADIS1650X::BURST_SEL_BIT) == ADIS1650X::BURST_SEL_BIT) {
return BurstModes::BURST_32_BURST_SEL_1;
}
else {
return BurstModes::BURST_32_BURST_SEL_0;
}
configDataset.mscCtrlReg.read();
uint16_t currentCtrlReg = configDataset.mscCtrlReg.value;
configDataset.mscCtrlReg.commit();
if ((currentCtrlReg & ADIS1650X::BURST_32_BIT) == ADIS1650X::BURST_32_BIT) {
if ((currentCtrlReg & ADIS1650X::BURST_SEL_BIT) == ADIS1650X::BURST_SEL_BIT) {
return BurstModes::BURST_32_BURST_SEL_1;
} else {
return BurstModes::BURST_32_BURST_SEL_0;
}
else {
if((currentCtrlReg & ADIS1650X::BURST_SEL_BIT) == ADIS1650X::BURST_SEL_BIT) {
return BurstModes::BURST_16_BURST_SEL_1;
}
else {
return BurstModes::BURST_16_BURST_SEL_0;
}
} else {
if ((currentCtrlReg & ADIS1650X::BURST_SEL_BIT) == ADIS1650X::BURST_SEL_BIT) {
return BurstModes::BURST_16_BURST_SEL_1;
} else {
return BurstModes::BURST_16_BURST_SEL_0;
}
}
}
#if OBSW_ADIS1650X_LINUX_COM_IF == 1
ReturnValue_t GyroADIS1650XHandler::spiSendCallback(SpiComIF *comIf, SpiCookie *cookie,
const uint8_t *sendData, size_t sendLen, void *args) {
GyroADIS1650XHandler* handler = reinterpret_cast<GyroADIS1650XHandler*>(args);
if(handler == nullptr) {
sif::error << "GyroADIS16507Handler::spiSendCallback: Passed handler pointer is invalid!"
<< std::endl;
return HasReturnvaluesIF::RETURN_FAILED;
const uint8_t *sendData, size_t sendLen,
void *args) {
GyroADIS1650XHandler *handler = reinterpret_cast<GyroADIS1650XHandler *>(args);
if (handler == nullptr) {
sif::error << "GyroADIS16507Handler::spiSendCallback: Passed handler pointer is invalid!"
<< std::endl;
return HasReturnvaluesIF::RETURN_FAILED;
}
DeviceCommandId_t currentCommand = handler->getPendingCommand();
switch (currentCommand) {
case (ADIS1650X::READ_SENSOR_DATA): {
return comIf->performRegularSendOperation(cookie, sendData, sendLen);
}
DeviceCommandId_t currentCommand = handler->getPendingCommand();
switch(currentCommand) {
case(ADIS1650X::READ_SENSOR_DATA): {
return comIf->performRegularSendOperation(cookie, sendData, sendLen);
}
case(ADIS1650X::READ_OUT_CONFIG):
case (ADIS1650X::READ_OUT_CONFIG):
default: {
ReturnValue_t result = HasReturnvaluesIF::RETURN_OK;
int retval = 0;
// Prepare transfer
int fileDescriptor = 0;
std::string device = cookie->getSpiDevice();
UnixFileGuard fileHelper(device, &fileDescriptor, O_RDWR, "SpiComIF::sendMessage");
if(fileHelper.getOpenResult() != HasReturnvaluesIF::RETURN_OK) {
return SpiComIF::OPENING_FILE_FAILED;
}
spi::SpiModes spiMode = spi::SpiModes::MODE_0;
uint32_t spiSpeed = 0;
cookie->getSpiParameters(spiMode, spiSpeed, nullptr);
comIf->setSpiSpeedAndMode(fileDescriptor, spiMode, spiSpeed);
cookie->assignWriteBuffer(sendData);
cookie->setTransferSize(2);
ReturnValue_t result = HasReturnvaluesIF::RETURN_OK;
int retval = 0;
// Prepare transfer
int fileDescriptor = 0;
std::string device = cookie->getSpiDevice();
UnixFileGuard fileHelper(device, &fileDescriptor, O_RDWR, "SpiComIF::sendMessage");
if (fileHelper.getOpenResult() != HasReturnvaluesIF::RETURN_OK) {
return SpiComIF::OPENING_FILE_FAILED;
}
spi::SpiModes spiMode = spi::SpiModes::MODE_0;
uint32_t spiSpeed = 0;
cookie->getSpiParameters(spiMode, spiSpeed, nullptr);
comIf->setSpiSpeedAndMode(fileDescriptor, spiMode, spiSpeed);
cookie->assignWriteBuffer(sendData);
cookie->setTransferSize(2);
gpioId_t gpioId = cookie->getChipSelectPin();
GpioIF* gpioIF = comIf->getGpioInterface();
MutexIF::TimeoutType timeoutType = MutexIF::TimeoutType::WAITING;
uint32_t timeoutMs = 0;
MutexIF* mutex = comIf->getMutex(&timeoutType, &timeoutMs);
if(mutex == nullptr or gpioIF == nullptr) {
gpioId_t gpioId = cookie->getChipSelectPin();
GpioIF *gpioIF = comIf->getGpioInterface();
MutexIF::TimeoutType timeoutType = MutexIF::TimeoutType::WAITING;
uint32_t timeoutMs = 0;
MutexIF *mutex = comIf->getMutex(&timeoutType, &timeoutMs);
if (mutex == nullptr or gpioIF == nullptr) {
#if OBSW_VERBOSE_LEVEL >= 1
sif::warning << "GyroADIS16507Handler::spiSendCallback: "
"Mutex or GPIO interface invalid" << std::endl;
return HasReturnvaluesIF::RETURN_FAILED;
sif::warning << "GyroADIS16507Handler::spiSendCallback: "
"Mutex or GPIO interface invalid"
<< std::endl;
return HasReturnvaluesIF::RETURN_FAILED;
#endif
}
}
if(gpioId != gpio::NO_GPIO) {
result = mutex->lockMutex(timeoutType, timeoutMs);
if (result != RETURN_OK) {
if (gpioId != gpio::NO_GPIO) {
result = mutex->lockMutex(timeoutType, timeoutMs);
if (result != RETURN_OK) {
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "SpiComIF::sendMessage: Failed to lock mutex" << std::endl;
sif::error << "SpiComIF::sendMessage: Failed to lock mutex" << std::endl;
#endif
return result;
}
return result;
}
}
size_t idx = 0;
while (idx < sendLen) {
// Pull SPI CS low. For now, no support for active high given
if (gpioId != gpio::NO_GPIO) {
gpioIF->pullLow(gpioId);
}
size_t idx = 0;
while(idx < sendLen) {
// Pull SPI CS low. For now, no support for active high given
if(gpioId != gpio::NO_GPIO) {
gpioIF->pullLow(gpioId);
}
// Execute transfer
// Initiate a full duplex SPI transfer.
retval = ioctl(fileDescriptor, SPI_IOC_MESSAGE(1), cookie->getTransferStructHandle());
if(retval < 0) {
utility::handleIoctlError("SpiComIF::sendMessage: ioctl error.");
result = SpiComIF::FULL_DUPLEX_TRANSFER_FAILED;
}
// Execute transfer
// Initiate a full duplex SPI transfer.
retval = ioctl(fileDescriptor, SPI_IOC_MESSAGE(1), cookie->getTransferStructHandle());
if (retval < 0) {
utility::handleIoctlError("SpiComIF::sendMessage: ioctl error.");
result = SpiComIF::FULL_DUPLEX_TRANSFER_FAILED;
}
#if FSFW_HAL_SPI_WIRETAPPING == 1
comIf->performSpiWiretapping(cookie);
comIf->performSpiWiretapping(cookie);
#endif /* FSFW_LINUX_SPI_WIRETAPPING == 1 */
if(gpioId != gpio::NO_GPIO) {
gpioIF->pullHigh(gpioId);
}
idx += 2;
if(idx < sendLen) {
usleep(ADIS1650X::STALL_TIME_MICROSECONDS);
}
spi_ioc_transfer* transferStruct = cookie->getTransferStructHandle();
transferStruct->tx_buf += 2;
transferStruct->rx_buf += 2;
if (gpioId != gpio::NO_GPIO) {
gpioIF->pullHigh(gpioId);
}
if(gpioId != gpio::NO_GPIO) {
mutex->unlockMutex();
idx += 2;
if (idx < sendLen) {
usleep(ADIS1650X::STALL_TIME_MICROSECONDS);
}
spi_ioc_transfer *transferStruct = cookie->getTransferStructHandle();
transferStruct->tx_buf += 2;
transferStruct->rx_buf += 2;
}
if (gpioId != gpio::NO_GPIO) {
mutex->unlockMutex();
}
}
}
return HasReturnvaluesIF::RETURN_OK;
}
return HasReturnvaluesIF::RETURN_OK;
}
#endif /* OBSW_ADIS1650X_LINUX_COM_IF == 1 */

View File

@ -1,12 +1,11 @@
#ifndef MISSION_DEVICES_GYROADIS16507HANDLER_H_
#define MISSION_DEVICES_GYROADIS16507HANDLER_H_
#include "OBSWConfig.h"
#include "FSFWConfig.h"
#include "OBSWConfig.h"
#include "devicedefinitions/GyroADIS1650XDefinitions.h"
#include "fsfw/globalfunctions/PeriodicOperationDivider.h"
#include "fsfw/devicehandlers/DeviceHandlerBase.h"
#include "fsfw/globalfunctions/PeriodicOperationDivider.h"
#if OBSW_ADIS1650X_LINUX_COM_IF == 1
class SpiComIF;
@ -19,67 +18,60 @@ class SpiCookie;
* Flight manual:
* https://egit.irs.uni-stuttgart.de/redmine/projects/eive-flight-manual/wiki/ADIS16507_Gyro
*/
class GyroADIS1650XHandler: public DeviceHandlerBase {
public:
GyroADIS1650XHandler(object_id_t objectId, object_id_t deviceCommunication,
CookieIF* comCookie, ADIS1650X::Type type);
class GyroADIS1650XHandler : public DeviceHandlerBase {
public:
GyroADIS1650XHandler(object_id_t objectId, object_id_t deviceCommunication, CookieIF *comCookie,
ADIS1650X::Type type);
// DeviceHandlerBase abstract function implementation
void doStartUp() override;
void doShutDown() override;
ReturnValue_t buildNormalDeviceCommand(DeviceCommandId_t * id) override;
ReturnValue_t buildTransitionDeviceCommand(DeviceCommandId_t * id) override;
ReturnValue_t buildCommandFromCommand(DeviceCommandId_t deviceCommand,
const uint8_t * commandData, size_t commandDataLen) override;
void fillCommandAndReplyMap() override;
ReturnValue_t scanForReply(const uint8_t *start, size_t remainingSize,
DeviceCommandId_t *foundId, size_t *foundLen) override;
ReturnValue_t interpretDeviceReply(DeviceCommandId_t id,
const uint8_t *packet) override;
uint32_t getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) override;
ReturnValue_t initializeLocalDataPool(localpool::DataPool &localDataPoolMap,
LocalDataPoolManager &poolManager) override;
// DeviceHandlerBase abstract function implementation
void doStartUp() override;
void doShutDown() override;
ReturnValue_t buildNormalDeviceCommand(DeviceCommandId_t *id) override;
ReturnValue_t buildTransitionDeviceCommand(DeviceCommandId_t *id) override;
ReturnValue_t buildCommandFromCommand(DeviceCommandId_t deviceCommand, const uint8_t *commandData,
size_t commandDataLen) override;
void fillCommandAndReplyMap() override;
ReturnValue_t scanForReply(const uint8_t *start, size_t remainingSize, DeviceCommandId_t *foundId,
size_t *foundLen) override;
ReturnValue_t interpretDeviceReply(DeviceCommandId_t id, const uint8_t *packet) override;
uint32_t getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) override;
ReturnValue_t initializeLocalDataPool(localpool::DataPool &localDataPoolMap,
LocalDataPoolManager &poolManager) override;
private:
std::array<uint8_t, 32> commandBuffer;
ADIS1650X::Type adisType;
AdisGyroPrimaryDataset primaryDataset;
AdisGyroConfigDataset configDataset;
private:
std::array<uint8_t, 32> commandBuffer;
ADIS1650X::Type adisType;
AdisGyroPrimaryDataset primaryDataset;
AdisGyroConfigDataset configDataset;
enum class InternalState {
STARTUP,
CONFIG,
IDLE
};
enum class InternalState { STARTUP, CONFIG, IDLE };
enum class BurstModes {
BURST_16_BURST_SEL_0,
BURST_16_BURST_SEL_1,
BURST_32_BURST_SEL_0,
BURST_32_BURST_SEL_1
};
enum class BurstModes {
BURST_16_BURST_SEL_0,
BURST_16_BURST_SEL_1,
BURST_32_BURST_SEL_0,
BURST_32_BURST_SEL_1
};
InternalState internalState = InternalState::STARTUP;
bool commandExecuted = false;
InternalState internalState = InternalState::STARTUP;
bool commandExecuted = false;
void prepareReadCommand(uint8_t* regList, size_t len);
void prepareReadCommand(uint8_t *regList, size_t len);
BurstModes getBurstMode();
BurstModes getBurstMode();
#if OBSW_ADIS1650X_LINUX_COM_IF == 1
static ReturnValue_t spiSendCallback(SpiComIF* comIf, SpiCookie *cookie,
const uint8_t *sendData, size_t sendLen, void* args);
static ReturnValue_t spiSendCallback(SpiComIF *comIf, SpiCookie *cookie, const uint8_t *sendData,
size_t sendLen, void *args);
#endif
#if FSFW_HAL_ADIS1650X_GYRO_DEBUG == 1
PeriodicOperationDivider* debugDivider;
PeriodicOperationDivider *debugDivider;
#endif
Countdown breakCountdown;
void prepareWriteCommand(uint8_t startReg, uint8_t valueOne, uint8_t valueTwo);
Countdown breakCountdown;
void prepareWriteCommand(uint8_t startReg, uint8_t valueOne, uint8_t valueTwo);
ReturnValue_t handleSensorData(const uint8_t* packet);
ReturnValue_t handleSensorData(const uint8_t *packet);
};
#endif /* MISSION_DEVICES_GYROADIS16507HANDLER_H_ */

View File

@ -1,373 +1,346 @@
#include "HeaterHandler.h"
#include <fsfw/ipc/QueueFactory.h>
#include <fsfw/objectmanager/ObjectManager.h>
#include <fsfw_hal/common/gpio/GpioCookie.h>
#include "devices/gpioIds.h"
#include "devices/powerSwitcherList.h"
#include <fsfw/objectmanager/ObjectManager.h>
#include <fsfw/ipc/QueueFactory.h>
#include <fsfw_hal/common/gpio/GpioCookie.h>
HeaterHandler::HeaterHandler(object_id_t setObjectId_, object_id_t gpioDriverId_,
CookieIF * gpioCookie_, object_id_t mainLineSwitcherObjectId_, uint8_t mainLineSwitch_) :
SystemObject(setObjectId_), gpioDriverId(gpioDriverId_), gpioCookie(gpioCookie_),
mainLineSwitcherObjectId(mainLineSwitcherObjectId_), mainLineSwitch(mainLineSwitch_),
actionHelper(this, nullptr) {
commandQueue = QueueFactory::instance()->createMessageQueue(cmdQueueSize,
MessageQueueMessage::MAX_MESSAGE_SIZE);
CookieIF* gpioCookie_, object_id_t mainLineSwitcherObjectId_,
uint8_t mainLineSwitch_)
: SystemObject(setObjectId_),
gpioDriverId(gpioDriverId_),
gpioCookie(gpioCookie_),
mainLineSwitcherObjectId(mainLineSwitcherObjectId_),
mainLineSwitch(mainLineSwitch_),
actionHelper(this, nullptr) {
commandQueue = QueueFactory::instance()->createMessageQueue(
cmdQueueSize, MessageQueueMessage::MAX_MESSAGE_SIZE);
}
HeaterHandler::~HeaterHandler() {
}
HeaterHandler::~HeaterHandler() {}
ReturnValue_t HeaterHandler::performOperation(uint8_t operationCode) {
if (operationCode == DeviceHandlerIF::PERFORM_OPERATION) {
readCommandQueue();
handleActiveCommands();
return RETURN_OK;
}
return RETURN_OK;
if (operationCode == DeviceHandlerIF::PERFORM_OPERATION) {
readCommandQueue();
handleActiveCommands();
return RETURN_OK;
}
return RETURN_OK;
}
ReturnValue_t HeaterHandler::initialize() {
ReturnValue_t result = SystemObject::initialize();
if (result != RETURN_OK) {
return ObjectManagerIF::CHILD_INIT_FAILED;
}
ReturnValue_t result = SystemObject::initialize();
if (result != RETURN_OK) {
return ObjectManagerIF::CHILD_INIT_FAILED;
}
result = initializeHeaterMap();
if (result != RETURN_OK) {
return ObjectManagerIF::CHILD_INIT_FAILED;
}
result = initializeHeaterMap();
if (result != RETURN_OK) {
return ObjectManagerIF::CHILD_INIT_FAILED;
}
gpioInterface = ObjectManager::instance()->get<GpioIF>(gpioDriverId);
if (gpioInterface == nullptr) {
sif::error << "HeaterHandler::initialize: Invalid Gpio interface." << std::endl;
return ObjectManagerIF::CHILD_INIT_FAILED;
}
gpioInterface = ObjectManager::instance()->get<GpioIF>(gpioDriverId);
if (gpioInterface == nullptr) {
sif::error << "HeaterHandler::initialize: Invalid Gpio interface." << std::endl;
return ObjectManagerIF::CHILD_INIT_FAILED;
}
result = gpioInterface->addGpios(dynamic_cast<GpioCookie*>(gpioCookie));
if (result != RETURN_OK) {
sif::error << "HeaterHandler::initialize: Failed to initialize Gpio interface" << std::endl;
return ObjectManagerIF::CHILD_INIT_FAILED;
}
result = gpioInterface->addGpios(dynamic_cast<GpioCookie*>(gpioCookie));
if (result != RETURN_OK) {
sif::error << "HeaterHandler::initialize: Failed to initialize Gpio interface" << std::endl;
return ObjectManagerIF::CHILD_INIT_FAILED;
}
IPCStore = ObjectManager::instance()->get<StorageManagerIF>(objects::IPC_STORE);
if (IPCStore == nullptr) {
sif::error << "HeaterHandler::initialize: IPC store not set up in factory." << std::endl;
return ObjectManagerIF::CHILD_INIT_FAILED;
}
IPCStore = ObjectManager::instance()->get<StorageManagerIF>(objects::IPC_STORE);
if (IPCStore == nullptr) {
sif::error << "HeaterHandler::initialize: IPC store not set up in factory." << std::endl;
return ObjectManagerIF::CHILD_INIT_FAILED;
}
if(mainLineSwitcherObjectId != objects::NO_OBJECT) {
mainLineSwitcher = ObjectManager::instance()->get<PowerSwitchIF>(mainLineSwitcherObjectId);
if (mainLineSwitcher == nullptr) {
sif::error
<< "HeaterHandler::initialize: Failed to get main line switcher. Make sure "
<< "main line switcher object is initialized." << std::endl;
return ObjectManagerIF::CHILD_INIT_FAILED;
}
}
if (mainLineSwitcherObjectId != objects::NO_OBJECT) {
mainLineSwitcher = ObjectManager::instance()->get<PowerSwitchIF>(mainLineSwitcherObjectId);
if (mainLineSwitcher == nullptr) {
sif::error << "HeaterHandler::initialize: Failed to get main line switcher. Make sure "
<< "main line switcher object is initialized." << std::endl;
return ObjectManagerIF::CHILD_INIT_FAILED;
}
}
result = actionHelper.initialize(commandQueue);
if (result != RETURN_OK) {
return ObjectManagerIF::CHILD_INIT_FAILED;
}
result = actionHelper.initialize(commandQueue);
if (result != RETURN_OK) {
return ObjectManagerIF::CHILD_INIT_FAILED;
}
return RETURN_OK;
return RETURN_OK;
}
ReturnValue_t HeaterHandler::initializeHeaterMap(){
HeaterCommandInfo_t heaterCommandInfo;
for(switchNr_t switchNr = 0; switchNr < heaterSwitches::NUMBER_OF_SWITCHES; switchNr++) {
std::pair status = heaterMap.emplace(switchNr, heaterCommandInfo);
if (status.second == false) {
sif::error << "HeaterHandler::initializeHeaterMap: Failed to initialize heater map"
<< std::endl;
return RETURN_FAILED;
}
}
return RETURN_OK;
ReturnValue_t HeaterHandler::initializeHeaterMap() {
HeaterCommandInfo_t heaterCommandInfo;
for (switchNr_t switchNr = 0; switchNr < heaterSwitches::NUMBER_OF_SWITCHES; switchNr++) {
std::pair status = heaterMap.emplace(switchNr, heaterCommandInfo);
if (status.second == false) {
sif::error << "HeaterHandler::initializeHeaterMap: Failed to initialize heater map"
<< std::endl;
return RETURN_FAILED;
}
}
return RETURN_OK;
}
void HeaterHandler::setInitialSwitchStates() {
for (switchNr_t switchNr = 0; switchNr < heaterSwitches::NUMBER_OF_SWITCHES; switchNr++) {
switchStates[switchNr] = OFF;
}
for (switchNr_t switchNr = 0; switchNr < heaterSwitches::NUMBER_OF_SWITCHES; switchNr++) {
switchStates[switchNr] = OFF;
}
}
void HeaterHandler::readCommandQueue() {
CommandMessage command;
ReturnValue_t result = commandQueue->receiveMessage(&command);
if (result != RETURN_OK) {
return;
}
CommandMessage command;
ReturnValue_t result = commandQueue->receiveMessage(&command);
if (result != RETURN_OK) {
return;
}
result = actionHelper.handleActionMessage(&command);
if (result == RETURN_OK) {
return;
}
result = actionHelper.handleActionMessage(&command);
if (result == RETURN_OK) {
return;
}
}
ReturnValue_t HeaterHandler::executeAction(ActionId_t actionId,
MessageQueueId_t commandedBy, const uint8_t* data, size_t size) {
ReturnValue_t result;
if (actionId != SWITCH_HEATER) {
result = COMMAND_NOT_SUPPORTED;
} else {
switchNr_t switchNr = *data;
HeaterMapIter heaterMapIter = heaterMap.find(switchNr);
if (heaterMapIter != heaterMap.end()) {
if (heaterMapIter->second.active) {
return COMMAND_ALREADY_WAITING;
}
heaterMapIter->second.action = *(data + 1);
heaterMapIter->second.active = true;
heaterMapIter->second.replyQueue = commandedBy;
}
else {
sif::error << "HeaterHandler::executeAction: Invalid switchNr" << std::endl;
return INVALID_SWITCH_NR;
}
result = RETURN_OK;
}
return result;
ReturnValue_t HeaterHandler::executeAction(ActionId_t actionId, MessageQueueId_t commandedBy,
const uint8_t* data, size_t size) {
ReturnValue_t result;
if (actionId != SWITCH_HEATER) {
result = COMMAND_NOT_SUPPORTED;
} else {
switchNr_t switchNr = *data;
HeaterMapIter heaterMapIter = heaterMap.find(switchNr);
if (heaterMapIter != heaterMap.end()) {
if (heaterMapIter->second.active) {
return COMMAND_ALREADY_WAITING;
}
heaterMapIter->second.action = *(data + 1);
heaterMapIter->second.active = true;
heaterMapIter->second.replyQueue = commandedBy;
} else {
sif::error << "HeaterHandler::executeAction: Invalid switchNr" << std::endl;
return INVALID_SWITCH_NR;
}
result = RETURN_OK;
}
return result;
}
void HeaterHandler::sendSwitchCommand(uint8_t switchNr, ReturnValue_t onOff) const {
ReturnValue_t result;
store_address_t storeAddress;
uint8_t commandData[2];
void HeaterHandler::sendSwitchCommand(uint8_t switchNr,
ReturnValue_t onOff) const {
switch (onOff) {
case PowerSwitchIF::SWITCH_ON:
commandData[0] = switchNr;
commandData[1] = SET_SWITCH_ON;
break;
case PowerSwitchIF::SWITCH_OFF:
commandData[0] = switchNr;
commandData[1] = SET_SWITCH_OFF;
break;
default:
sif::error << "HeaterHandler::sendSwitchCommand: Invalid switch request" << std::endl;
break;
}
ReturnValue_t result;
store_address_t storeAddress;
uint8_t commandData[2];
switch(onOff) {
case PowerSwitchIF::SWITCH_ON:
commandData[0] = switchNr;
commandData[1] = SET_SWITCH_ON;
break;
case PowerSwitchIF::SWITCH_OFF:
commandData[0] = switchNr;
commandData[1] = SET_SWITCH_OFF;
break;
default:
sif::error << "HeaterHandler::sendSwitchCommand: Invalid switch request"
<< std::endl;
break;
}
result = IPCStore->addData(&storeAddress, commandData, sizeof(commandData));
if (result == RETURN_OK) {
CommandMessage message;
ActionMessage::setCommand(&message, SWITCH_HEATER, storeAddress);
/* Send heater command to own command queue */
result = commandQueue->sendMessage(commandQueue->getId(), &message, 0);
if (result != RETURN_OK) {
sif::debug << "HeaterHandler::sendSwitchCommand: Failed to send switch"
<< "message" << std::endl;
}
}
result = IPCStore->addData(&storeAddress, commandData, sizeof(commandData));
if (result == RETURN_OK) {
CommandMessage message;
ActionMessage::setCommand(&message, SWITCH_HEATER, storeAddress);
/* Send heater command to own command queue */
result = commandQueue->sendMessage(commandQueue->getId(), &message, 0);
if (result != RETURN_OK) {
sif::debug << "HeaterHandler::sendSwitchCommand: Failed to send switch"
<< "message" << std::endl;
}
}
}
void HeaterHandler::handleActiveCommands(){
HeaterMapIter heaterMapIter = heaterMap.begin();
for (; heaterMapIter != heaterMap.end(); heaterMapIter++) {
if (heaterMapIter->second.active) {
switch(heaterMapIter->second.action) {
case SET_SWITCH_ON:
handleSwitchOnCommand(heaterMapIter);
break;
case SET_SWITCH_OFF:
handleSwitchOffCommand(heaterMapIter);
break;
default:
sif::error << "HeaterHandler::handleActiveCommands: Invalid action commanded"
<< std::endl;
break;
}
}
}
void HeaterHandler::handleActiveCommands() {
HeaterMapIter heaterMapIter = heaterMap.begin();
for (; heaterMapIter != heaterMap.end(); heaterMapIter++) {
if (heaterMapIter->second.active) {
switch (heaterMapIter->second.action) {
case SET_SWITCH_ON:
handleSwitchOnCommand(heaterMapIter);
break;
case SET_SWITCH_OFF:
handleSwitchOffCommand(heaterMapIter);
break;
default:
sif::error << "HeaterHandler::handleActiveCommands: Invalid action commanded"
<< std::endl;
break;
}
}
}
}
void HeaterHandler::handleSwitchOnCommand(HeaterMapIter heaterMapIter) {
ReturnValue_t result = RETURN_OK;
switchNr_t switchNr;
ReturnValue_t result = RETURN_OK;
switchNr_t switchNr;
/* Check if command waits for main switch being set on and whether the timeout has expired */
if (heaterMapIter->second.waitMainSwitchOn &&
heaterMapIter->second.mainSwitchCountdown.hasTimedOut()) {
// TODO - This requires the initiation of an FDIR procedure
triggerEvent(MAIN_SWITCH_TIMEOUT);
sif::error << "HeaterHandler::handleSwitchOnCommand: Main switch setting on timeout"
<< std::endl;
heaterMapIter->second.active = false;
heaterMapIter->second.waitMainSwitchOn = false;
if (heaterMapIter->second.replyQueue != commandQueue->getId()) {
actionHelper.finish(false, heaterMapIter->second.replyQueue, heaterMapIter->second.action,
MAIN_SWITCH_SET_TIMEOUT);
}
return;
}
/* Check if command waits for main switch being set on and whether the timeout has expired */
if (heaterMapIter->second.waitMainSwitchOn
&& heaterMapIter->second.mainSwitchCountdown.hasTimedOut()) {
//TODO - This requires the initiation of an FDIR procedure
triggerEvent(MAIN_SWITCH_TIMEOUT);
sif::error << "HeaterHandler::handleSwitchOnCommand: Main switch setting on timeout"
<< std::endl;
heaterMapIter->second.active = false;
heaterMapIter->second.waitMainSwitchOn = false;
if (heaterMapIter->second.replyQueue != commandQueue->getId()) {
actionHelper.finish(false, heaterMapIter->second.replyQueue,
heaterMapIter->second.action, MAIN_SWITCH_SET_TIMEOUT );
}
return;
switchNr = heaterMapIter->first;
/* Check state of main line switch */
ReturnValue_t mainSwitchState = mainLineSwitcher->getSwitchState(mainLineSwitch);
if (mainSwitchState == PowerSwitchIF::SWITCH_ON) {
if (!checkSwitchState(switchNr)) {
gpioId_t gpioId = getGpioIdFromSwitchNr(switchNr);
result = gpioInterface->pullHigh(gpioId);
if (result != RETURN_OK) {
sif::error << "HeaterHandler::handleSwitchOnCommand: Failed to pull gpio with id " << gpioId
<< " high" << std::endl;
triggerEvent(GPIO_PULL_HIGH_FAILED, result);
} else {
switchStates[switchNr] = ON;
}
} else {
triggerEvent(SWITCH_ALREADY_ON, switchNr);
}
switchNr = heaterMapIter->first;
/* Check state of main line switch */
ReturnValue_t mainSwitchState = mainLineSwitcher->getSwitchState(mainLineSwitch);
if (mainSwitchState == PowerSwitchIF::SWITCH_ON) {
if (!checkSwitchState(switchNr)) {
gpioId_t gpioId = getGpioIdFromSwitchNr(switchNr);
result = gpioInterface->pullHigh(gpioId);
if (result != RETURN_OK) {
sif::error << "HeaterHandler::handleSwitchOnCommand: Failed to pull gpio with id "
<< gpioId << " high" << std::endl;
triggerEvent(GPIO_PULL_HIGH_FAILED, result);
}
else {
switchStates[switchNr] = ON;
}
}
else {
triggerEvent(SWITCH_ALREADY_ON, switchNr);
}
/* There is no need to send action finish replies if the sender was the
* HeaterHandler itself. */
if (heaterMapIter->second.replyQueue != commandQueue->getId()) {
if(result == RETURN_OK) {
actionHelper.finish(true, heaterMapIter->second.replyQueue,
heaterMapIter->second.action, result);
}
else {
actionHelper.finish(false, heaterMapIter->second.replyQueue,
heaterMapIter->second.action, result);
}
}
heaterMapIter->second.active = false;
heaterMapIter->second.waitMainSwitchOn = false;
/* There is no need to send action finish replies if the sender was the
* HeaterHandler itself. */
if (heaterMapIter->second.replyQueue != commandQueue->getId()) {
if (result == RETURN_OK) {
actionHelper.finish(true, heaterMapIter->second.replyQueue, heaterMapIter->second.action,
result);
} else {
actionHelper.finish(false, heaterMapIter->second.replyQueue, heaterMapIter->second.action,
result);
}
}
else if (mainSwitchState == PowerSwitchIF::SWITCH_OFF
&& heaterMapIter->second.waitMainSwitchOn) {
/* Just waiting for the main switch being set on */
return;
}
else if (mainSwitchState == PowerSwitchIF::SWITCH_OFF) {
mainLineSwitcher->sendSwitchCommand(mainLineSwitch,
PowerSwitchIF::SWITCH_ON);
heaterMapIter->second.mainSwitchCountdown.setTimeout(mainLineSwitcher->getSwitchDelayMs());
heaterMapIter->second.waitMainSwitchOn = true;
}
else {
sif::debug << "HeaterHandler::handleActiveCommands: Failed to get state of"
<< " main line switch" << std::endl;
if (heaterMapIter->second.replyQueue != commandQueue->getId()) {
actionHelper.finish(false, heaterMapIter->second.replyQueue,
heaterMapIter->second.action, mainSwitchState);
}
heaterMapIter->second.active = false;
heaterMapIter->second.active = false;
heaterMapIter->second.waitMainSwitchOn = false;
} else if (mainSwitchState == PowerSwitchIF::SWITCH_OFF &&
heaterMapIter->second.waitMainSwitchOn) {
/* Just waiting for the main switch being set on */
return;
} else if (mainSwitchState == PowerSwitchIF::SWITCH_OFF) {
mainLineSwitcher->sendSwitchCommand(mainLineSwitch, PowerSwitchIF::SWITCH_ON);
heaterMapIter->second.mainSwitchCountdown.setTimeout(mainLineSwitcher->getSwitchDelayMs());
heaterMapIter->second.waitMainSwitchOn = true;
} else {
sif::debug << "HeaterHandler::handleActiveCommands: Failed to get state of"
<< " main line switch" << std::endl;
if (heaterMapIter->second.replyQueue != commandQueue->getId()) {
actionHelper.finish(false, heaterMapIter->second.replyQueue, heaterMapIter->second.action,
mainSwitchState);
}
heaterMapIter->second.active = false;
}
}
void HeaterHandler::handleSwitchOffCommand(HeaterMapIter heaterMapIter) {
ReturnValue_t result = RETURN_OK;
switchNr_t switchNr = heaterMapIter->first;
/* Check whether switch is already off */
if (checkSwitchState(switchNr)) {
gpioId_t gpioId = getGpioIdFromSwitchNr(switchNr);
result = gpioInterface->pullLow(gpioId);
if (result != RETURN_OK) {
sif::error << "HeaterHandler::handleSwitchOffCommand: Failed to pull gpio with id"
<< gpioId << " low" << std::endl;
triggerEvent(GPIO_PULL_LOW_FAILED, result);
}
else {
switchStates[switchNr] = OFF;
/* When all switches are off, also main line switch will be turned off */
if (allSwitchesOff()) {
mainLineSwitcher->sendSwitchCommand(mainLineSwitch, PowerSwitchIF::SWITCH_OFF);
}
}
ReturnValue_t result = RETURN_OK;
switchNr_t switchNr = heaterMapIter->first;
/* Check whether switch is already off */
if (checkSwitchState(switchNr)) {
gpioId_t gpioId = getGpioIdFromSwitchNr(switchNr);
result = gpioInterface->pullLow(gpioId);
if (result != RETURN_OK) {
sif::error << "HeaterHandler::handleSwitchOffCommand: Failed to pull gpio with id" << gpioId
<< " low" << std::endl;
triggerEvent(GPIO_PULL_LOW_FAILED, result);
} else {
switchStates[switchNr] = OFF;
/* When all switches are off, also main line switch will be turned off */
if (allSwitchesOff()) {
mainLineSwitcher->sendSwitchCommand(mainLineSwitch, PowerSwitchIF::SWITCH_OFF);
}
}
else {
sif::info << "HeaterHandler::handleSwitchOffCommand: Switch already off" << std::endl;
triggerEvent(SWITCH_ALREADY_OFF, switchNr);
} else {
sif::info << "HeaterHandler::handleSwitchOffCommand: Switch already off" << std::endl;
triggerEvent(SWITCH_ALREADY_OFF, switchNr);
}
if (heaterMapIter->second.replyQueue != NO_COMMANDER) {
/* Report back switch command reply if necessary */
if (result == HasReturnvaluesIF::RETURN_OK) {
actionHelper.finish(true, heaterMapIter->second.replyQueue, heaterMapIter->second.action,
result);
} else {
actionHelper.finish(false, heaterMapIter->second.replyQueue, heaterMapIter->second.action,
result);
}
if (heaterMapIter->second.replyQueue != NO_COMMANDER) {
/* Report back switch command reply if necessary */
if(result == HasReturnvaluesIF::RETURN_OK) {
actionHelper.finish(true, heaterMapIter->second.replyQueue,
heaterMapIter->second.action, result);
}
else {
actionHelper.finish(false, heaterMapIter->second.replyQueue,
heaterMapIter->second.action, result);
}
}
heaterMapIter->second.active = false;
}
heaterMapIter->second.active = false;
}
bool HeaterHandler::checkSwitchState(int switchNr) {
return switchStates[switchNr];
}
bool HeaterHandler::checkSwitchState(int switchNr) { return switchStates[switchNr]; }
bool HeaterHandler::allSwitchesOff() {
bool allSwitchesOrd = false;
/* Or all switches. As soon one switch is on, allSwitchesOrd will be true */
for (switchNr_t switchNr = 0; switchNr < heaterSwitches::NUMBER_OF_SWITCHES; switchNr++) {
allSwitchesOrd = allSwitchesOrd || switchStates[switchNr];
}
return !allSwitchesOrd;
bool allSwitchesOrd = false;
/* Or all switches. As soon one switch is on, allSwitchesOrd will be true */
for (switchNr_t switchNr = 0; switchNr < heaterSwitches::NUMBER_OF_SWITCHES; switchNr++) {
allSwitchesOrd = allSwitchesOrd || switchStates[switchNr];
}
return !allSwitchesOrd;
}
gpioId_t HeaterHandler::getGpioIdFromSwitchNr(int switchNr) {
gpioId_t gpioId = 0xFFFF;
switch(switchNr) {
gpioId_t gpioId = 0xFFFF;
switch (switchNr) {
case heaterSwitches::HEATER_0:
gpioId = gpioIds::HEATER_0;
break;
gpioId = gpioIds::HEATER_0;
break;
case heaterSwitches::HEATER_1:
gpioId = gpioIds::HEATER_1;
break;
gpioId = gpioIds::HEATER_1;
break;
case heaterSwitches::HEATER_2:
gpioId = gpioIds::HEATER_2;
break;
gpioId = gpioIds::HEATER_2;
break;
case heaterSwitches::HEATER_3:
gpioId = gpioIds::HEATER_3;
break;
gpioId = gpioIds::HEATER_3;
break;
case heaterSwitches::HEATER_4:
gpioId = gpioIds::HEATER_4;
break;
gpioId = gpioIds::HEATER_4;
break;
case heaterSwitches::HEATER_5:
gpioId = gpioIds::HEATER_5;
break;
gpioId = gpioIds::HEATER_5;
break;
case heaterSwitches::HEATER_6:
gpioId = gpioIds::HEATER_6;
break;
gpioId = gpioIds::HEATER_6;
break;
case heaterSwitches::HEATER_7:
gpioId = gpioIds::HEATER_7;
break;
gpioId = gpioIds::HEATER_7;
break;
default:
sif::error << "HeaterHandler::getGpioIdFromSwitchNr: Unknown heater switch number"
<< std::endl;
break;
}
return gpioId;
sif::error << "HeaterHandler::getGpioIdFromSwitchNr: Unknown heater switch number"
<< std::endl;
break;
}
return gpioId;
}
MessageQueueId_t HeaterHandler::getCommandQueue() const {
return commandQueue->getId();
}
MessageQueueId_t HeaterHandler::getCommandQueue() const { return commandQueue->getId(); }
void HeaterHandler::sendFuseOnCommand(uint8_t fuseNr) const {
}
void HeaterHandler::sendFuseOnCommand(uint8_t fuseNr) const {}
ReturnValue_t HeaterHandler::getSwitchState( uint8_t switchNr ) const {
return 0;
}
ReturnValue_t HeaterHandler::getSwitchState(uint8_t switchNr) const { return 0; }
ReturnValue_t HeaterHandler::getFuseState( uint8_t fuseNr ) const {
return 0;
}
ReturnValue_t HeaterHandler::getFuseState(uint8_t fuseNr) const { return 0; }
uint32_t HeaterHandler::getSwitchDelayMs(void) const {
return 0;
}
uint32_t HeaterHandler::getSwitchDelayMs(void) const { return 0; }

View File

@ -1,177 +1,169 @@
#ifndef MISSION_DEVICES_HEATERHANDLER_H_
#define MISSION_DEVICES_HEATERHANDLER_H_
#include "devices/heaterSwitcherList.h"
#include <fsfw/objectmanager/SystemObject.h>
#include <fsfw/tasks/ExecutableObjectIF.h>
#include <fsfw/returnvalues/HasReturnvaluesIF.h>
#include <fsfw/action/HasActionsIF.h>
#include <fsfw/power/PowerSwitchIF.h>
#include <fsfw/devicehandlers/DeviceHandlerIF.h>
#include <fsfw/devicehandlers/CookieIF.h>
#include <fsfw/devicehandlers/DeviceHandlerIF.h>
#include <fsfw/objectmanager/SystemObject.h>
#include <fsfw/power/PowerSwitchIF.h>
#include <fsfw/returnvalues/HasReturnvaluesIF.h>
#include <fsfw/tasks/ExecutableObjectIF.h>
#include <fsfw/timemanager/Countdown.h>
#include <fsfw_hal/common/gpio/GpioIF.h>
#include <unordered_map>
#include "devices/heaterSwitcherList.h"
/**
* @brief This class intends the control of heaters.
*
* @author J. Meier
*/
class HeaterHandler: public ExecutableObjectIF,
public PowerSwitchIF,
public SystemObject,
public HasActionsIF {
public:
static const uint8_t INTERFACE_ID = CLASS_ID::HEATER_HANDLER;
class HeaterHandler : public ExecutableObjectIF,
public PowerSwitchIF,
public SystemObject,
public HasActionsIF {
public:
static const uint8_t INTERFACE_ID = CLASS_ID::HEATER_HANDLER;
static const ReturnValue_t COMMAND_NOT_SUPPORTED = MAKE_RETURN_CODE(0xA1);
static const ReturnValue_t INIT_FAILED = MAKE_RETURN_CODE(0xA2);
static const ReturnValue_t INVALID_SWITCH_NR = MAKE_RETURN_CODE(0xA3);
static const ReturnValue_t MAIN_SWITCH_SET_TIMEOUT = MAKE_RETURN_CODE(0xA4);
static const ReturnValue_t COMMAND_ALREADY_WAITING = MAKE_RETURN_CODE(0xA5);
static const ReturnValue_t COMMAND_NOT_SUPPORTED = MAKE_RETURN_CODE(0xA1);
static const ReturnValue_t INIT_FAILED = MAKE_RETURN_CODE(0xA2);
static const ReturnValue_t INVALID_SWITCH_NR = MAKE_RETURN_CODE(0xA3);
static const ReturnValue_t MAIN_SWITCH_SET_TIMEOUT = MAKE_RETURN_CODE(0xA4);
static const ReturnValue_t COMMAND_ALREADY_WAITING = MAKE_RETURN_CODE(0xA5);
/** Device command IDs */
static const DeviceCommandId_t SWITCH_HEATER = 0x0;
/** Device command IDs */
static const DeviceCommandId_t SWITCH_HEATER = 0x0;
HeaterHandler(object_id_t setObjectId, object_id_t gpioDriverId, CookieIF * gpioCookie,
object_id_t mainLineSwitcherObjectId, uint8_t mainLineSwitch);
HeaterHandler(object_id_t setObjectId, object_id_t gpioDriverId, CookieIF* gpioCookie,
object_id_t mainLineSwitcherObjectId, uint8_t mainLineSwitch);
virtual ~HeaterHandler();
virtual ~HeaterHandler();
virtual ReturnValue_t performOperation(uint8_t operationCode = 0) override;
virtual ReturnValue_t performOperation(uint8_t operationCode = 0) override;
virtual void sendSwitchCommand(uint8_t switchNr, ReturnValue_t onOff) const override;
virtual void sendFuseOnCommand(uint8_t fuseNr) const override;
/**
* @brief This function will be called from the Heater object to check
* the current switch state.
*/
virtual ReturnValue_t getSwitchState( uint8_t switchNr ) const override;
virtual ReturnValue_t getFuseState( uint8_t fuseNr ) const override;
virtual uint32_t getSwitchDelayMs(void) const override;
virtual void sendSwitchCommand(uint8_t switchNr, ReturnValue_t onOff) const override;
virtual void sendFuseOnCommand(uint8_t fuseNr) const override;
/**
* @brief This function will be called from the Heater object to check
* the current switch state.
*/
virtual ReturnValue_t getSwitchState(uint8_t switchNr) const override;
virtual ReturnValue_t getFuseState(uint8_t fuseNr) const override;
virtual uint32_t getSwitchDelayMs(void) const override;
virtual MessageQueueId_t getCommandQueue() const override;
virtual ReturnValue_t executeAction(ActionId_t actionId, MessageQueueId_t commandedBy,
const uint8_t* data, size_t size) override;
virtual ReturnValue_t initialize() override;
virtual MessageQueueId_t getCommandQueue() const override;
virtual ReturnValue_t executeAction(ActionId_t actionId, MessageQueueId_t commandedBy,
const uint8_t* data, size_t size) override;
virtual ReturnValue_t initialize() override;
private:
private:
static const uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::HEATER_HANDLER;
static const Event GPIO_PULL_HIGH_FAILED = MAKE_EVENT(0, severity::LOW);
static const Event GPIO_PULL_LOW_FAILED = MAKE_EVENT(1, severity::LOW);
static const Event SWITCH_ALREADY_ON = MAKE_EVENT(2, severity::LOW);
static const Event SWITCH_ALREADY_OFF = MAKE_EVENT(3, severity::LOW);
static const Event MAIN_SWITCH_TIMEOUT = MAKE_EVENT(4, severity::LOW);
static const uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::HEATER_HANDLER;
static const Event GPIO_PULL_HIGH_FAILED = MAKE_EVENT(0, severity::LOW);
static const Event GPIO_PULL_LOW_FAILED = MAKE_EVENT(1, severity::LOW);
static const Event SWITCH_ALREADY_ON = MAKE_EVENT(2, severity::LOW);
static const Event SWITCH_ALREADY_OFF = MAKE_EVENT(3, severity::LOW);
static const Event MAIN_SWITCH_TIMEOUT = MAKE_EVENT(4, severity::LOW);
static const MessageQueueId_t NO_COMMANDER = 0;
static const MessageQueueId_t NO_COMMANDER = 0;
enum SwitchState : bool { ON = true, OFF = false };
enum SwitchState : bool {
ON = true,
OFF = false
};
/**
* @brief Struct holding information about a heater command to execute.
*
* @param action The action to perform.
* @param replyQueue The queue of the commander to which status replies
* will be sent.
* @param active True if command is waiting for execution, otherwise false.
* @param waitSwitchOn True if the command is waiting for the main switch being set on.
* @param mainSwitchCountdown Sets timeout to wait for main switch being set on.
*/
typedef struct HeaterCommandInfo {
uint8_t action;
MessageQueueId_t replyQueue;
bool active = false;
bool waitMainSwitchOn = false;
Countdown mainSwitchCountdown;
} HeaterCommandInfo_t;
enum SwitchAction { SET_SWITCH_OFF, SET_SWITCH_ON };
/**
* @brief Struct holding information about a heater command to execute.
*
* @param action The action to perform.
* @param replyQueue The queue of the commander to which status replies
* will be sent.
* @param active True if command is waiting for execution, otherwise false.
* @param waitSwitchOn True if the command is waiting for the main switch being set on.
* @param mainSwitchCountdown Sets timeout to wait for main switch being set on.
*/
typedef struct HeaterCommandInfo {
uint8_t action;
MessageQueueId_t replyQueue;
bool active = false;
bool waitMainSwitchOn = false;
Countdown mainSwitchCountdown;
} HeaterCommandInfo_t;
using switchNr_t = uint8_t;
using HeaterMap = std::unordered_map<switchNr_t, HeaterCommandInfo_t>;
using HeaterMapIter = HeaterMap::iterator;
enum SwitchAction {
SET_SWITCH_OFF,
SET_SWITCH_ON
};
HeaterMap heaterMap;
using switchNr_t = uint8_t;
using HeaterMap = std::unordered_map<switchNr_t, HeaterCommandInfo_t>;
using HeaterMapIter = HeaterMap::iterator;
bool switchStates[heaterSwitches::NUMBER_OF_SWITCHES];
HeaterMap heaterMap;
/** Size of command queue */
size_t cmdQueueSize = 20;
bool switchStates[heaterSwitches::NUMBER_OF_SWITCHES];
/**
* The object ID of the GPIO driver which enables and disables the
* heaters.
*/
object_id_t gpioDriverId;
/** Size of command queue */
size_t cmdQueueSize = 20;
CookieIF* gpioCookie;
/**
* The object ID of the GPIO driver which enables and disables the
* heaters.
*/
object_id_t gpioDriverId;
GpioIF* gpioInterface = nullptr;
CookieIF * gpioCookie;
/** Queue to receive messages from other objects. */
MessageQueueIF* commandQueue = nullptr;
GpioIF* gpioInterface = nullptr;
object_id_t mainLineSwitcherObjectId;
/** Queue to receive messages from other objects. */
MessageQueueIF* commandQueue = nullptr;
/** Switch number of the heater power supply switch */
uint8_t mainLineSwitch;
object_id_t mainLineSwitcherObjectId;
/**
* Power switcher object which controls the 8V main line of the heater
* logic on the TCS board.
*/
PowerSwitchIF* mainLineSwitcher = nullptr;
/** Switch number of the heater power supply switch */
uint8_t mainLineSwitch;
ActionHelper actionHelper;
/**
* Power switcher object which controls the 8V main line of the heater
* logic on the TCS board.
*/
PowerSwitchIF *mainLineSwitcher = nullptr;
StorageManagerIF* IPCStore = nullptr;
ActionHelper actionHelper;
void readCommandQueue();
StorageManagerIF *IPCStore = nullptr;
/**
* @brief Returns the state of a switch (ON - true, or OFF - false).
* @param switchNr The number of the switch to check.
*/
bool checkSwitchState(int switchNr);
void readCommandQueue();
/**
* @brief Returns the ID of the GPIO related to a heater identified by the switch number
* which is defined in the heaterSwitches list.
*/
gpioId_t getGpioIdFromSwitchNr(int switchNr);
/**
* @brief Returns the state of a switch (ON - true, or OFF - false).
* @param switchNr The number of the switch to check.
*/
bool checkSwitchState(int switchNr);
/**
* @brief This function runs commands waiting for execution.
*/
void handleActiveCommands();
/**
* @brief Returns the ID of the GPIO related to a heater identified by the switch number
* which is defined in the heaterSwitches list.
*/
gpioId_t getGpioIdFromSwitchNr(int switchNr);
ReturnValue_t initializeHeaterMap();
/**
* @brief This function runs commands waiting for execution.
*/
void handleActiveCommands();
/**
* @brief Sets all switches to OFF.
*/
void setInitialSwitchStates();
ReturnValue_t initializeHeaterMap();
void handleSwitchOnCommand(HeaterMapIter heaterMapIter);
/**
* @brief Sets all switches to OFF.
*/
void setInitialSwitchStates();
void handleSwitchOnCommand(HeaterMapIter heaterMapIter);
void handleSwitchOffCommand(HeaterMapIter heaterMapIter);
/**
* @brief Checks if all switches are off.
* @return True if all switches are off, otherwise false.
*/
bool allSwitchesOff();
void handleSwitchOffCommand(HeaterMapIter heaterMapIter);
/**
* @brief Checks if all switches are off.
* @return True if all switches are off, otherwise false.
*/
bool allSwitchesOff();
};
#endif /* MISSION_DEVICES_HEATERHANDLER_H_ */

File diff suppressed because it is too large Load Diff

View File

@ -10,186 +10,188 @@
*
* @author J. Meier
*/
class IMTQHandler: public DeviceHandlerBase {
public:
class IMTQHandler : public DeviceHandlerBase {
public:
IMTQHandler(object_id_t objectId, object_id_t comIF, CookieIF* comCookie);
virtual ~IMTQHandler();
IMTQHandler(object_id_t objectId, object_id_t comIF, CookieIF * comCookie);
virtual ~IMTQHandler();
/**
* @brief Sets mode to MODE_NORMAL. Can be used for debugging.
*/
void setModeNormal();
/**
* @brief Sets mode to MODE_NORMAL. Can be used for debugging.
*/
void setModeNormal();
protected:
void doStartUp() override;
void doShutDown() override;
ReturnValue_t buildNormalDeviceCommand(DeviceCommandId_t* id) override;
ReturnValue_t buildTransitionDeviceCommand(DeviceCommandId_t* id) override;
void fillCommandAndReplyMap() override;
ReturnValue_t buildCommandFromCommand(DeviceCommandId_t deviceCommand, const uint8_t* commandData,
size_t commandDataLen) override;
ReturnValue_t scanForReply(const uint8_t* start, size_t remainingSize, DeviceCommandId_t* foundId,
size_t* foundLen) override;
ReturnValue_t interpretDeviceReply(DeviceCommandId_t id, const uint8_t* packet) override;
void setNormalDatapoolEntriesInvalid() override;
virtual LocalPoolDataSetBase* getDataSetHandle(sid_t sid) override;
uint32_t getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) override;
ReturnValue_t initializeLocalDataPool(localpool::DataPool& localDataPoolMap,
LocalDataPoolManager& poolManager) override;
protected:
void doStartUp() override;
void doShutDown() override;
ReturnValue_t buildNormalDeviceCommand(DeviceCommandId_t * id) override;
ReturnValue_t buildTransitionDeviceCommand(DeviceCommandId_t * id) override;
void fillCommandAndReplyMap() override;
ReturnValue_t buildCommandFromCommand(DeviceCommandId_t deviceCommand,
const uint8_t * commandData,size_t commandDataLen) override;
ReturnValue_t scanForReply(const uint8_t *start, size_t remainingSize,
DeviceCommandId_t *foundId, size_t *foundLen) override;
ReturnValue_t interpretDeviceReply(DeviceCommandId_t id,
const uint8_t *packet) override;
void setNormalDatapoolEntriesInvalid() override;
virtual LocalPoolDataSetBase* getDataSetHandle(sid_t sid) override;
uint32_t getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) override;
ReturnValue_t initializeLocalDataPool(localpool::DataPool& localDataPoolMap,
LocalDataPoolManager& poolManager) override;
private:
static const uint8_t INTERFACE_ID = CLASS_ID::IMTQ_HANDLER;
private:
static const ReturnValue_t INVALID_COMMAND_CODE = MAKE_RETURN_CODE(0xA0);
static const ReturnValue_t PARAMETER_MISSING = MAKE_RETURN_CODE(0xA1);
static const ReturnValue_t PARAMETER_INVALID = MAKE_RETURN_CODE(0xA2);
static const ReturnValue_t CC_UNAVAILABLE = MAKE_RETURN_CODE(0xA3);
static const ReturnValue_t INTERNAL_PROCESSING_ERROR = MAKE_RETURN_CODE(0xA4);
static const ReturnValue_t REJECTED_WITHOUT_REASON = MAKE_RETURN_CODE(0xA5);
static const ReturnValue_t CMD_ERR_UNKNOWN = MAKE_RETURN_CODE(0xA6);
//! [EXPORT] : [COMMENT] The status reply to a self test command was received but no self test
//! command has been sent. This should normally never happen.
static const ReturnValue_t UNEXPECTED_SELF_TEST_REPLY = MAKE_RETURN_CODE(0xA7);
static const uint8_t INTERFACE_ID = CLASS_ID::IMTQ_HANDLER;
static const uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::IMTQ_HANDLER;
static const ReturnValue_t INVALID_COMMAND_CODE = MAKE_RETURN_CODE(0xA0);
static const ReturnValue_t PARAMETER_MISSING = MAKE_RETURN_CODE(0xA1);
static const ReturnValue_t PARAMETER_INVALID = MAKE_RETURN_CODE(0xA2);
static const ReturnValue_t CC_UNAVAILABLE = MAKE_RETURN_CODE(0xA3);
static const ReturnValue_t INTERNAL_PROCESSING_ERROR = MAKE_RETURN_CODE(0xA4);
static const ReturnValue_t REJECTED_WITHOUT_REASON = MAKE_RETURN_CODE(0xA5);
static const ReturnValue_t CMD_ERR_UNKNOWN = MAKE_RETURN_CODE(0xA6);
//! [EXPORT] : [COMMENT] The status reply to a self test command was received but no self test command has been sent. This should normally never happen.
static const ReturnValue_t UNEXPECTED_SELF_TEST_REPLY = MAKE_RETURN_CODE(0xA7);
//! [EXPORT] : [COMMENT] Get self test result returns I2C failure
//! P1: Indicates on which axis the failure occurred. 0 -> INIT, 1 -> +X, 2 -> -X, 3 -> +Y, 4 ->
//! -Y, 5 -> +Z, 6 -> -Z, 7 -> FINA
static const Event SELF_TEST_I2C_FAILURE = MAKE_EVENT(1, severity::LOW);
//! [EXPORT] : [COMMENT] Get self test result returns SPI failure. This concerns the MTM
//! connectivity. P1: Indicates on which axis the failure occurred. 0 -> INIT, 1 -> +X, 2 -> -X, 3
//! -> +Y, 4 -> -Y, 5 -> +Z, 6 -> -Z, 7 -> FINA
static const Event SELF_TEST_SPI_FAILURE = MAKE_EVENT(2, severity::LOW);
//! [EXPORT] : [COMMENT] Get self test result returns failure in measurement of current and
//! temperature. P1: Indicates on which axis the failure occurred. 0 -> INIT, 1 -> +X, 2 -> -X, 3
//! -> +Y, 4 -> -Y, 5 -> +Z, 6 -> -Z, 7 -> FINA
static const Event SELF_TEST_ADC_FAILURE = MAKE_EVENT(3, severity::LOW);
//! [EXPORT] : [COMMENT] Get self test result returns PWM failure which concerns the coil
//! actuation. P1: Indicates on which axis the failure occurred. 0 -> INIT, 1 -> +X, 2 -> -X, 3 ->
//! +Y, 4 -> -Y, 5 -> +Z, 6 -> -Z, 7 -> FINA
static const Event SELF_TEST_PWM_FAILURE = MAKE_EVENT(4, severity::LOW);
//! [EXPORT] : [COMMENT] Get self test result returns TC failure (system failure)
//! P1: Indicates on which axis the failure occurred. 0 -> INIT, 1 -> +X, 2 -> -X, 3 -> +Y, 4 ->
//! -Y, 5 -> +Z, 6 -> -Z, 7 -> FINA
static const Event SELF_TEST_TC_FAILURE = MAKE_EVENT(5, severity::LOW);
//! [EXPORT] : [COMMENT] Get self test result returns failure that MTM values were outside of the
//! expected range. P1: Indicates on which axis the failure occurred. 0 -> INIT, 1 -> +X, 2 -> -X,
//! 3 -> +Y, 4 -> -Y, 5 -> +Z, 6 -> -Z, 7 -> FINA
static const Event SELF_TEST_MTM_RANGE_FAILURE = MAKE_EVENT(6, severity::LOW);
//! [EXPORT] : [COMMENT] Get self test result returns failure indicating that the coil current was
//! outside of the expected range P1: Indicates on which axis the failure occurred. 0 -> INIT, 1
//! -> +X, 2 -> -X, 3 -> +Y, 4 -> -Y, 5 -> +Z, 6 -> -Z, 7 -> FINA
static const Event SELF_TEST_COIL_CURRENT_FAILURE = MAKE_EVENT(7, severity::LOW);
//! [EXPORT] : [COMMENT] Received invalid error byte. This indicates an error of the communication
//! link between IMTQ and OBC.
static const Event INVALID_ERROR_BYTE = MAKE_EVENT(8, severity::LOW);
static const uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::IMTQ_HANDLER;
IMTQ::EngHkDataset engHkDataset;
IMTQ::CalibratedMtmMeasurementSet calMtmMeasurementSet;
IMTQ::RawMtmMeasurementSet rawMtmMeasurementSet;
IMTQ::PosXSelfTestSet posXselfTestDataset;
IMTQ::NegXSelfTestSet negXselfTestDataset;
IMTQ::PosYSelfTestSet posYselfTestDataset;
IMTQ::NegYSelfTestSet negYselfTestDataset;
IMTQ::PosZSelfTestSet posZselfTestDataset;
IMTQ::NegZSelfTestSet negZselfTestDataset;
//! [EXPORT] : [COMMENT] Get self test result returns I2C failure
//! P1: Indicates on which axis the failure occurred. 0 -> INIT, 1 -> +X, 2 -> -X, 3 -> +Y, 4 -> -Y, 5 -> +Z, 6 -> -Z, 7 -> FINA
static const Event SELF_TEST_I2C_FAILURE = MAKE_EVENT(1, severity::LOW);
//! [EXPORT] : [COMMENT] Get self test result returns SPI failure. This concerns the MTM connectivity.
//! P1: Indicates on which axis the failure occurred. 0 -> INIT, 1 -> +X, 2 -> -X, 3 -> +Y, 4 -> -Y, 5 -> +Z, 6 -> -Z, 7 -> FINA
static const Event SELF_TEST_SPI_FAILURE = MAKE_EVENT(2, severity::LOW);
//! [EXPORT] : [COMMENT] Get self test result returns failure in measurement of current and temperature.
//! P1: Indicates on which axis the failure occurred. 0 -> INIT, 1 -> +X, 2 -> -X, 3 -> +Y, 4 -> -Y, 5 -> +Z, 6 -> -Z, 7 -> FINA
static const Event SELF_TEST_ADC_FAILURE = MAKE_EVENT(3, severity::LOW);
//! [EXPORT] : [COMMENT] Get self test result returns PWM failure which concerns the coil actuation.
//! P1: Indicates on which axis the failure occurred. 0 -> INIT, 1 -> +X, 2 -> -X, 3 -> +Y, 4 -> -Y, 5 -> +Z, 6 -> -Z, 7 -> FINA
static const Event SELF_TEST_PWM_FAILURE = MAKE_EVENT(4, severity::LOW);
//! [EXPORT] : [COMMENT] Get self test result returns TC failure (system failure)
//! P1: Indicates on which axis the failure occurred. 0 -> INIT, 1 -> +X, 2 -> -X, 3 -> +Y, 4 -> -Y, 5 -> +Z, 6 -> -Z, 7 -> FINA
static const Event SELF_TEST_TC_FAILURE = MAKE_EVENT(5, severity::LOW);
//! [EXPORT] : [COMMENT] Get self test result returns failure that MTM values were outside of the expected range.
//! P1: Indicates on which axis the failure occurred. 0 -> INIT, 1 -> +X, 2 -> -X, 3 -> +Y, 4 -> -Y, 5 -> +Z, 6 -> -Z, 7 -> FINA
static const Event SELF_TEST_MTM_RANGE_FAILURE = MAKE_EVENT(6, severity::LOW);
//! [EXPORT] : [COMMENT] Get self test result returns failure indicating that the coil current was outside of the expected range
//! P1: Indicates on which axis the failure occurred. 0 -> INIT, 1 -> +X, 2 -> -X, 3 -> +Y, 4 -> -Y, 5 -> +Z, 6 -> -Z, 7 -> FINA
static const Event SELF_TEST_COIL_CURRENT_FAILURE = MAKE_EVENT(7, severity::LOW);
//! [EXPORT] : [COMMENT] Received invalid error byte. This indicates an error of the communication link between IMTQ and OBC.
static const Event INVALID_ERROR_BYTE = MAKE_EVENT(8, severity::LOW);
uint8_t commandBuffer[IMTQ::MAX_COMMAND_SIZE];
IMTQ::EngHkDataset engHkDataset;
IMTQ::CalibratedMtmMeasurementSet calMtmMeasurementSet;
IMTQ::RawMtmMeasurementSet rawMtmMeasurementSet;
IMTQ::PosXSelfTestSet posXselfTestDataset;
IMTQ::NegXSelfTestSet negXselfTestDataset;
IMTQ::PosYSelfTestSet posYselfTestDataset;
IMTQ::NegYSelfTestSet negYselfTestDataset;
IMTQ::PosZSelfTestSet posZselfTestDataset;
IMTQ::NegZSelfTestSet negZselfTestDataset;
enum class CommunicationStep {
GET_ENG_HK_DATA,
START_MTM_MEASUREMENT,
GET_CAL_MTM_MEASUREMENT,
GET_RAW_MTM_MEASUREMENT
};
uint8_t commandBuffer[IMTQ::MAX_COMMAND_SIZE];
CommunicationStep communicationStep = CommunicationStep::GET_ENG_HK_DATA;
enum class CommunicationStep {
GET_ENG_HK_DATA,
START_MTM_MEASUREMENT,
GET_CAL_MTM_MEASUREMENT,
GET_RAW_MTM_MEASUREMENT
};
enum class StartupStep { NONE, COMMAND_SELF_TEST, GET_SELF_TEST_RESULT };
CommunicationStep communicationStep = CommunicationStep::GET_ENG_HK_DATA;
StartupStep startupStep = StartupStep::COMMAND_SELF_TEST;
enum class StartupStep {
NONE,
COMMAND_SELF_TEST,
GET_SELF_TEST_RESULT
};
bool selfTestPerformed = false;
StartupStep startupStep = StartupStep::COMMAND_SELF_TEST;
/**
* @brief In case of a status reply to a single axis self test command, this function
* searches for the actual pending command.
*/
ReturnValue_t getSelfTestCommandId(DeviceCommandId_t* id);
bool selfTestPerformed = false;
/**
* @brief Each reply contains a status byte giving information about a request. This function
* parses this byte and returns the associated failure message.
*
* @param packet Pointer to the received message containing the status byte.
*
* @return The return code derived from the received status byte.
*/
ReturnValue_t parseStatusByte(const uint8_t* packet);
/**
* @brief In case of a status reply to a single axis self test command, this function
* searches for the actual pending command.
*/
ReturnValue_t getSelfTestCommandId(DeviceCommandId_t* id);
/**
* @brief This function fills the engineering housekeeping dataset with the received data.
/**
* @brief Each reply contains a status byte giving information about a request. This function
* parses this byte and returns the associated failure message.
*
* @param packet Pointer to the received message containing the status byte.
*
* @return The return code derived from the received status byte.
*/
ReturnValue_t parseStatusByte(const uint8_t* packet);
* @param packet Pointer to the received data.
*
*/
void fillEngHkDataset(const uint8_t* packet);
/**
* @brief This function fills the engineering housekeeping dataset with the received data.
/**
* @brief This function sends a command reply to the requesting queue.
*
* @param data Pointer to the data to send.
* @param dataSize Size of the data to send.
* @param relplyId Reply id which will be inserted at the beginning of the action message.
*/
void handleDeviceTM(const uint8_t* data, size_t dataSize, DeviceCommandId_t replyId);
* @param packet Pointer to the received data.
*
*/
void fillEngHkDataset(const uint8_t* packet);
/**
* @brief This function handles the reply containing the commanded dipole.
*
* @param packet Pointer to the reply data.
*/
void handleGetCommandedDipoleReply(const uint8_t* packet);
/**
* @brief This function sends a command reply to the requesting queue.
*
* @param data Pointer to the data to send.
* @param dataSize Size of the data to send.
* @param relplyId Reply id which will be inserted at the beginning of the action message.
*/
void handleDeviceTM(const uint8_t* data, size_t dataSize, DeviceCommandId_t replyId);
/**
* @brief This function parses the reply containing the calibrated MTM measurement and writes
* the values to the appropriate dataset.
* @param packet Pointer to the reply data.
*/
void fillCalibratedMtmDataset(const uint8_t* packet);
/**
* @brief This function handles the reply containing the commanded dipole.
*
* @param packet Pointer to the reply data.
*/
void handleGetCommandedDipoleReply(const uint8_t* packet);
/**
* @brief This function copies the raw MTM measurements to the MTM raw dataset.
* @param packet Pointer to the reply data requested with the GET_RAW_MTM_MEASUREMENTS
* command.
*/
void fillRawMtmDataset(const uint8_t* packet);
/**
* @brief This function parses the reply containing the calibrated MTM measurement and writes
* the values to the appropriate dataset.
* @param packet Pointer to the reply data.
*/
void fillCalibratedMtmDataset(const uint8_t* packet);
/**
* @brief This function handles all self test results. This comprises parsing the error byte
* and step byte and calling the function to fill the respective dataset.
*/
void handleSelfTestReply(const uint8_t* packet);
/**
* @brief This function copies the raw MTM measurements to the MTM raw dataset.
* @param packet Pointer to the reply data requested with the GET_RAW_MTM_MEASUREMENTS
* command.
*/
void fillRawMtmDataset(const uint8_t* packet);
/**
* @brief The following functions fill the respective dataset of the single axis self tests.
* @param packet Pointer to the reply data holding the self test result.
*/
void handlePositiveXSelfTestReply(const uint8_t* packet);
void handleNegativeXSelfTestReply(const uint8_t* packet);
void handlePositiveYSelfTestReply(const uint8_t* packet);
void handleNegativeYSelfTestReply(const uint8_t* packet);
void handlePositiveZSelfTestReply(const uint8_t* packet);
void handleNegativeZSelfTestReply(const uint8_t* packet);
/**
* @brief This function handles all self test results. This comprises parsing the error byte
* and step byte and calling the function to fill the respective dataset.
*/
void handleSelfTestReply(const uint8_t* packet);
/**
* @brief This function checks the error byte of a self test measurement.
*
* @param errorByte The received error byte to check
* @param step The step of the error byte.
*/
void checkErrorByte(const uint8_t errorByte, const uint8_t step);
/**
* @brief The following functions fill the respective dataset of the single axis self tests.
* @param packet Pointer to the reply data holding the self test result.
*/
void handlePositiveXSelfTestReply(const uint8_t* packet);
void handleNegativeXSelfTestReply(const uint8_t* packet);
void handlePositiveYSelfTestReply(const uint8_t* packet);
void handleNegativeYSelfTestReply(const uint8_t* packet);
void handlePositiveZSelfTestReply(const uint8_t* packet);
void handleNegativeZSelfTestReply(const uint8_t* packet);
/**
* @brief This function checks the error byte of a self test measurement.
*
* @param errorByte The received error byte to check
* @param step The step of the error byte.
*/
void checkErrorByte(const uint8_t errorByte, const uint8_t step);
std::string makeStepString(const uint8_t step);
std::string makeStepString(const uint8_t step);
};
#endif /* MISSION_DEVICES_IMTQHANDLER_H_ */

View File

@ -1,546 +1,531 @@
#include "Max31865PT1000Handler.h"
#include "fsfw/datapool/PoolReadGuard.h"
#include <bitset>
#include <cmath>
#include "fsfw/datapool/PoolReadGuard.h"
Max31865PT1000Handler::Max31865PT1000Handler(object_id_t objectId, object_id_t comIF,
CookieIF *comCookie):
DeviceHandlerBase(objectId, comIF, comCookie),
sensorDataset(this), sensorDatasetSid(sensorDataset.getSid()) {
CookieIF *comCookie)
: DeviceHandlerBase(objectId, comIF, comCookie),
sensorDataset(this),
sensorDatasetSid(sensorDataset.getSid()) {
#if OBSW_VERBOSE_LEVEL >= 1
debugDivider = new PeriodicOperationDivider(10);
debugDivider = new PeriodicOperationDivider(10);
#endif
}
Max31865PT1000Handler::~Max31865PT1000Handler() {
}
Max31865PT1000Handler::~Max31865PT1000Handler() {}
void Max31865PT1000Handler::doStartUp() {
if(internalState == InternalState::NONE) {
internalState = InternalState::WARMUP;
Clock::getUptime(&startTime);
}
if (internalState == InternalState::NONE) {
internalState = InternalState::WARMUP;
Clock::getUptime(&startTime);
}
if(internalState == InternalState::WARMUP) {
dur_millis_t timeNow = 0;
Clock::getUptime(&timeNow);
if(timeNow - startTime >= 100) {
internalState = InternalState::CONFIGURE;
}
if (internalState == InternalState::WARMUP) {
dur_millis_t timeNow = 0;
Clock::getUptime(&timeNow);
if (timeNow - startTime >= 100) {
internalState = InternalState::CONFIGURE;
}
}
if(internalState == InternalState::CONFIGURE) {
if(commandExecuted) {
commandExecuted = false;
internalState = InternalState::REQUEST_CONFIG;
}
if (internalState == InternalState::CONFIGURE) {
if (commandExecuted) {
commandExecuted = false;
internalState = InternalState::REQUEST_CONFIG;
}
}
if(internalState == InternalState::REQUEST_CONFIG) {
if (commandExecuted) {
commandExecuted = false;
internalState = InternalState::CONFIG_HIGH_THRESHOLD;
}
if (internalState == InternalState::REQUEST_CONFIG) {
if (commandExecuted) {
commandExecuted = false;
internalState = InternalState::CONFIG_HIGH_THRESHOLD;
}
}
if(internalState == InternalState::CONFIG_HIGH_THRESHOLD) {
if(commandExecuted) {
internalState = InternalState::REQUEST_HIGH_THRESHOLD;
commandExecuted = false;
}
if (internalState == InternalState::CONFIG_HIGH_THRESHOLD) {
if (commandExecuted) {
internalState = InternalState::REQUEST_HIGH_THRESHOLD;
commandExecuted = false;
}
}
if(internalState == InternalState::REQUEST_HIGH_THRESHOLD) {
if(commandExecuted) {
internalState = InternalState::CONFIG_LOW_THRESHOLD;
commandExecuted = false;
}
if (internalState == InternalState::REQUEST_HIGH_THRESHOLD) {
if (commandExecuted) {
internalState = InternalState::CONFIG_LOW_THRESHOLD;
commandExecuted = false;
}
}
if(internalState == InternalState::CONFIG_LOW_THRESHOLD) {
if(commandExecuted) {
internalState = InternalState::REQUEST_LOW_THRESHOLD;
commandExecuted = false;
}
if (internalState == InternalState::CONFIG_LOW_THRESHOLD) {
if (commandExecuted) {
internalState = InternalState::REQUEST_LOW_THRESHOLD;
commandExecuted = false;
}
}
if(internalState == InternalState::REQUEST_LOW_THRESHOLD) {
if(commandExecuted) {
internalState = InternalState::CLEAR_FAULT_BYTE;
commandExecuted = false;
}
if (internalState == InternalState::REQUEST_LOW_THRESHOLD) {
if (commandExecuted) {
internalState = InternalState::CLEAR_FAULT_BYTE;
commandExecuted = false;
}
if(internalState == InternalState::CLEAR_FAULT_BYTE) {
if(commandExecuted) {
commandExecuted = false;
internalState = InternalState::RUNNING;
if(instantNormal) {
setMode(MODE_NORMAL);
} else {
setMode(_MODE_TO_ON);
}
}
}
if (internalState == InternalState::CLEAR_FAULT_BYTE) {
if (commandExecuted) {
commandExecuted = false;
internalState = InternalState::RUNNING;
if (instantNormal) {
setMode(MODE_NORMAL);
} else {
setMode(_MODE_TO_ON);
}
}
}
}
void Max31865PT1000Handler::doShutDown() {
commandExecuted = false;
setMode(_MODE_POWER_DOWN);
commandExecuted = false;
setMode(_MODE_POWER_DOWN);
}
ReturnValue_t Max31865PT1000Handler::buildNormalDeviceCommand(
DeviceCommandId_t *id) {
if(internalState == InternalState::RUNNING) {
*id = Max31865Definitions::REQUEST_RTD;
return buildCommandFromCommand(*id, nullptr, 0);
}
else if(internalState == InternalState::REQUEST_FAULT_BYTE) {
*id = Max31865Definitions::REQUEST_FAULT_BYTE;
return buildCommandFromCommand(*id, nullptr, 0);
}
else if(internalState == InternalState::CLEAR_FAULT_BYTE) {
*id = Max31865Definitions::CLEAR_FAULT_BYTE;
return buildCommandFromCommand(*id, nullptr, 0);
}
else {
return DeviceHandlerBase::NOTHING_TO_SEND;
}
}
ReturnValue_t Max31865PT1000Handler::buildTransitionDeviceCommand(
DeviceCommandId_t *id) {
switch(internalState) {
case(InternalState::NONE):
case(InternalState::WARMUP):
case(InternalState::RUNNING):
ReturnValue_t Max31865PT1000Handler::buildNormalDeviceCommand(DeviceCommandId_t *id) {
if (internalState == InternalState::RUNNING) {
*id = Max31865Definitions::REQUEST_RTD;
return buildCommandFromCommand(*id, nullptr, 0);
} else if (internalState == InternalState::REQUEST_FAULT_BYTE) {
*id = Max31865Definitions::REQUEST_FAULT_BYTE;
return buildCommandFromCommand(*id, nullptr, 0);
} else if (internalState == InternalState::CLEAR_FAULT_BYTE) {
*id = Max31865Definitions::CLEAR_FAULT_BYTE;
return buildCommandFromCommand(*id, nullptr, 0);
} else {
return DeviceHandlerBase::NOTHING_TO_SEND;
case(InternalState::CONFIGURE): {
*id = Max31865Definitions::CONFIG_CMD;
uint8_t config[1] = {DEFAULT_CONFIG};
return buildCommandFromCommand(*id, config, 1);
}
}
ReturnValue_t Max31865PT1000Handler::buildTransitionDeviceCommand(DeviceCommandId_t *id) {
switch (internalState) {
case (InternalState::NONE):
case (InternalState::WARMUP):
case (InternalState::RUNNING):
return DeviceHandlerBase::NOTHING_TO_SEND;
case (InternalState::CONFIGURE): {
*id = Max31865Definitions::CONFIG_CMD;
uint8_t config[1] = {DEFAULT_CONFIG};
return buildCommandFromCommand(*id, config, 1);
}
case(InternalState::REQUEST_CONFIG): {
*id = Max31865Definitions::REQUEST_CONFIG;
return buildCommandFromCommand(*id, nullptr, 0);
case (InternalState::REQUEST_CONFIG): {
*id = Max31865Definitions::REQUEST_CONFIG;
return buildCommandFromCommand(*id, nullptr, 0);
}
case(InternalState::CONFIG_HIGH_THRESHOLD): {
*id = Max31865Definitions::WRITE_HIGH_THRESHOLD;
return buildCommandFromCommand(*id, nullptr, 0);
case (InternalState::CONFIG_HIGH_THRESHOLD): {
*id = Max31865Definitions::WRITE_HIGH_THRESHOLD;
return buildCommandFromCommand(*id, nullptr, 0);
}
case(InternalState::REQUEST_HIGH_THRESHOLD): {
*id = Max31865Definitions::REQUEST_HIGH_THRESHOLD;
return buildCommandFromCommand(*id, nullptr, 0);
case (InternalState::REQUEST_HIGH_THRESHOLD): {
*id = Max31865Definitions::REQUEST_HIGH_THRESHOLD;
return buildCommandFromCommand(*id, nullptr, 0);
}
case(InternalState::CONFIG_LOW_THRESHOLD): {
*id = Max31865Definitions::WRITE_LOW_THRESHOLD;
return buildCommandFromCommand(*id, nullptr, 0);
case (InternalState::CONFIG_LOW_THRESHOLD): {
*id = Max31865Definitions::WRITE_LOW_THRESHOLD;
return buildCommandFromCommand(*id, nullptr, 0);
}
case(InternalState::REQUEST_LOW_THRESHOLD): {
*id = Max31865Definitions::REQUEST_LOW_THRESHOLD;
return buildCommandFromCommand(*id, nullptr, 0);
case (InternalState::REQUEST_LOW_THRESHOLD): {
*id = Max31865Definitions::REQUEST_LOW_THRESHOLD;
return buildCommandFromCommand(*id, nullptr, 0);
}
case(InternalState::CLEAR_FAULT_BYTE): {
*id = Max31865Definitions::CLEAR_FAULT_BYTE;
return buildCommandFromCommand(*id, nullptr, 0);
case (InternalState::CLEAR_FAULT_BYTE): {
*id = Max31865Definitions::CLEAR_FAULT_BYTE;
return buildCommandFromCommand(*id, nullptr, 0);
}
default:
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "Max31865PT1000Handler: Invalid internal state" << std::endl;
sif::error << "Max31865PT1000Handler: Invalid internal state" << std::endl;
#else
sif::printError("Max31865PT1000Handler: Invalid internal state\n");
sif::printError("Max31865PT1000Handler: Invalid internal state\n");
#endif
return HasReturnvaluesIF::RETURN_FAILED;
}
return HasReturnvaluesIF::RETURN_FAILED;
}
}
ReturnValue_t Max31865PT1000Handler::buildCommandFromCommand(
DeviceCommandId_t deviceCommand, const uint8_t *commandData,
size_t commandDataLen) {
switch(deviceCommand) {
case(Max31865Definitions::CONFIG_CMD) : {
commandBuffer[0] = static_cast<uint8_t>(Max31865Definitions::CONFIG_CMD);
if(commandDataLen == 1) {
commandBuffer[1] = commandData[0];
DeviceHandlerBase::rawPacketLen = 2;
DeviceHandlerBase::rawPacket = commandBuffer.data();
return HasReturnvaluesIF::RETURN_OK;
}
else {
return DeviceHandlerIF::NO_COMMAND_DATA;
}
}
case(Max31865Definitions::CLEAR_FAULT_BYTE): {
commandBuffer[0] = static_cast<uint8_t>(Max31865Definitions::CONFIG_CMD);
commandBuffer[1] = Max31865Definitions::CLEAR_FAULT_BIT_VAL;
ReturnValue_t Max31865PT1000Handler::buildCommandFromCommand(DeviceCommandId_t deviceCommand,
const uint8_t *commandData,
size_t commandDataLen) {
switch (deviceCommand) {
case (Max31865Definitions::CONFIG_CMD): {
commandBuffer[0] = static_cast<uint8_t>(Max31865Definitions::CONFIG_CMD);
if (commandDataLen == 1) {
commandBuffer[1] = commandData[0];
DeviceHandlerBase::rawPacketLen = 2;
DeviceHandlerBase::rawPacket = commandBuffer.data();
return HasReturnvaluesIF::RETURN_OK;
} else {
return DeviceHandlerIF::NO_COMMAND_DATA;
}
}
case(Max31865Definitions::REQUEST_CONFIG): {
commandBuffer[0] = static_cast<uint8_t>(
Max31865Definitions::REQUEST_CONFIG);
commandBuffer[1] = 0x00; // dummy byte
DeviceHandlerBase::rawPacketLen = 2;
DeviceHandlerBase::rawPacket = commandBuffer.data();
return HasReturnvaluesIF::RETURN_OK;
case (Max31865Definitions::CLEAR_FAULT_BYTE): {
commandBuffer[0] = static_cast<uint8_t>(Max31865Definitions::CONFIG_CMD);
commandBuffer[1] = Max31865Definitions::CLEAR_FAULT_BIT_VAL;
DeviceHandlerBase::rawPacketLen = 2;
DeviceHandlerBase::rawPacket = commandBuffer.data();
return HasReturnvaluesIF::RETURN_OK;
}
case(Max31865Definitions::WRITE_HIGH_THRESHOLD): {
commandBuffer[0] = static_cast<uint8_t>(
Max31865Definitions::WRITE_HIGH_THRESHOLD);
commandBuffer[1] = static_cast<uint8_t>(HIGH_THRESHOLD >> 8);
commandBuffer[2] = static_cast<uint8_t>(HIGH_THRESHOLD & 0xFF);
DeviceHandlerBase::rawPacketLen = 3;
DeviceHandlerBase::rawPacket = commandBuffer.data();
return HasReturnvaluesIF::RETURN_OK;
case (Max31865Definitions::REQUEST_CONFIG): {
commandBuffer[0] = static_cast<uint8_t>(Max31865Definitions::REQUEST_CONFIG);
commandBuffer[1] = 0x00; // dummy byte
DeviceHandlerBase::rawPacketLen = 2;
DeviceHandlerBase::rawPacket = commandBuffer.data();
return HasReturnvaluesIF::RETURN_OK;
}
case(Max31865Definitions::REQUEST_HIGH_THRESHOLD): {
commandBuffer[0] = static_cast<uint8_t>(
Max31865Definitions::REQUEST_HIGH_THRESHOLD);
commandBuffer[1] = 0x00; //dummy byte
commandBuffer[2] = 0x00; //dummy byte
DeviceHandlerBase::rawPacketLen = 3;
DeviceHandlerBase::rawPacket = commandBuffer.data();
return HasReturnvaluesIF::RETURN_OK;
case (Max31865Definitions::WRITE_HIGH_THRESHOLD): {
commandBuffer[0] = static_cast<uint8_t>(Max31865Definitions::WRITE_HIGH_THRESHOLD);
commandBuffer[1] = static_cast<uint8_t>(HIGH_THRESHOLD >> 8);
commandBuffer[2] = static_cast<uint8_t>(HIGH_THRESHOLD & 0xFF);
DeviceHandlerBase::rawPacketLen = 3;
DeviceHandlerBase::rawPacket = commandBuffer.data();
return HasReturnvaluesIF::RETURN_OK;
}
case(Max31865Definitions::WRITE_LOW_THRESHOLD): {
commandBuffer[0] = static_cast<uint8_t>(
Max31865Definitions::WRITE_LOW_THRESHOLD);
commandBuffer[1] = static_cast<uint8_t>(LOW_THRESHOLD >> 8);
commandBuffer[2] = static_cast<uint8_t>(LOW_THRESHOLD & 0xFF);
DeviceHandlerBase::rawPacketLen = 3;
DeviceHandlerBase::rawPacket = commandBuffer.data();
return HasReturnvaluesIF::RETURN_OK;
case (Max31865Definitions::REQUEST_HIGH_THRESHOLD): {
commandBuffer[0] = static_cast<uint8_t>(Max31865Definitions::REQUEST_HIGH_THRESHOLD);
commandBuffer[1] = 0x00; // dummy byte
commandBuffer[2] = 0x00; // dummy byte
DeviceHandlerBase::rawPacketLen = 3;
DeviceHandlerBase::rawPacket = commandBuffer.data();
return HasReturnvaluesIF::RETURN_OK;
}
case(Max31865Definitions::REQUEST_LOW_THRESHOLD): {
commandBuffer[0] = static_cast<uint8_t>(
Max31865Definitions::REQUEST_LOW_THRESHOLD);
commandBuffer[1] = 0x00; //dummy byte
commandBuffer[2] = 0x00; //dummy byte
DeviceHandlerBase::rawPacketLen = 3;
DeviceHandlerBase::rawPacket = commandBuffer.data();
return HasReturnvaluesIF::RETURN_OK;
case (Max31865Definitions::WRITE_LOW_THRESHOLD): {
commandBuffer[0] = static_cast<uint8_t>(Max31865Definitions::WRITE_LOW_THRESHOLD);
commandBuffer[1] = static_cast<uint8_t>(LOW_THRESHOLD >> 8);
commandBuffer[2] = static_cast<uint8_t>(LOW_THRESHOLD & 0xFF);
DeviceHandlerBase::rawPacketLen = 3;
DeviceHandlerBase::rawPacket = commandBuffer.data();
return HasReturnvaluesIF::RETURN_OK;
}
case(Max31865Definitions::REQUEST_RTD): {
commandBuffer[0] = static_cast<uint8_t>(
Max31865Definitions::REQUEST_RTD);
// two dummy bytes
commandBuffer[1] = 0x00;
commandBuffer[2] = 0x00;
DeviceHandlerBase::rawPacketLen = 3;
DeviceHandlerBase::rawPacket = commandBuffer.data();
return HasReturnvaluesIF::RETURN_OK;
case (Max31865Definitions::REQUEST_LOW_THRESHOLD): {
commandBuffer[0] = static_cast<uint8_t>(Max31865Definitions::REQUEST_LOW_THRESHOLD);
commandBuffer[1] = 0x00; // dummy byte
commandBuffer[2] = 0x00; // dummy byte
DeviceHandlerBase::rawPacketLen = 3;
DeviceHandlerBase::rawPacket = commandBuffer.data();
return HasReturnvaluesIF::RETURN_OK;
}
case(Max31865Definitions::REQUEST_FAULT_BYTE): {
commandBuffer[0] = static_cast<uint8_t>(
Max31865Definitions::REQUEST_FAULT_BYTE);
commandBuffer[1] = 0x00;
DeviceHandlerBase::rawPacketLen = 2;
DeviceHandlerBase::rawPacket = commandBuffer.data();
return HasReturnvaluesIF::RETURN_OK;
case (Max31865Definitions::REQUEST_RTD): {
commandBuffer[0] = static_cast<uint8_t>(Max31865Definitions::REQUEST_RTD);
// two dummy bytes
commandBuffer[1] = 0x00;
commandBuffer[2] = 0x00;
DeviceHandlerBase::rawPacketLen = 3;
DeviceHandlerBase::rawPacket = commandBuffer.data();
return HasReturnvaluesIF::RETURN_OK;
}
case (Max31865Definitions::REQUEST_FAULT_BYTE): {
commandBuffer[0] = static_cast<uint8_t>(Max31865Definitions::REQUEST_FAULT_BYTE);
commandBuffer[1] = 0x00;
DeviceHandlerBase::rawPacketLen = 2;
DeviceHandlerBase::rawPacket = commandBuffer.data();
return HasReturnvaluesIF::RETURN_OK;
}
default:
//Unknown DeviceCommand
return DeviceHandlerIF::COMMAND_NOT_IMPLEMENTED;
}
// Unknown DeviceCommand
return DeviceHandlerIF::COMMAND_NOT_IMPLEMENTED;
}
}
void Max31865PT1000Handler::fillCommandAndReplyMap() {
insertInCommandAndReplyMap(Max31865Definitions::CONFIG_CMD, 3);
insertInCommandAndReplyMap(Max31865Definitions::REQUEST_CONFIG, 3);
insertInCommandAndReplyMap(Max31865Definitions::WRITE_LOW_THRESHOLD, 3);
insertInCommandAndReplyMap(Max31865Definitions::REQUEST_LOW_THRESHOLD, 3);
insertInCommandAndReplyMap(Max31865Definitions::WRITE_HIGH_THRESHOLD, 3);
insertInCommandAndReplyMap(Max31865Definitions::REQUEST_HIGH_THRESHOLD, 3);
insertInCommandAndReplyMap(Max31865Definitions::REQUEST_RTD, 3,
&sensorDataset);
insertInCommandAndReplyMap(Max31865Definitions::REQUEST_FAULT_BYTE, 3);
insertInCommandAndReplyMap(Max31865Definitions::CLEAR_FAULT_BYTE, 3);
insertInCommandAndReplyMap(Max31865Definitions::CONFIG_CMD, 3);
insertInCommandAndReplyMap(Max31865Definitions::REQUEST_CONFIG, 3);
insertInCommandAndReplyMap(Max31865Definitions::WRITE_LOW_THRESHOLD, 3);
insertInCommandAndReplyMap(Max31865Definitions::REQUEST_LOW_THRESHOLD, 3);
insertInCommandAndReplyMap(Max31865Definitions::WRITE_HIGH_THRESHOLD, 3);
insertInCommandAndReplyMap(Max31865Definitions::REQUEST_HIGH_THRESHOLD, 3);
insertInCommandAndReplyMap(Max31865Definitions::REQUEST_RTD, 3, &sensorDataset);
insertInCommandAndReplyMap(Max31865Definitions::REQUEST_FAULT_BYTE, 3);
insertInCommandAndReplyMap(Max31865Definitions::CLEAR_FAULT_BYTE, 3);
}
ReturnValue_t Max31865PT1000Handler::scanForReply(const uint8_t *start,
size_t remainingSize, DeviceCommandId_t *foundId, size_t *foundLen) {
size_t rtdReplySize = 3;
size_t configReplySize = 2;
if(remainingSize == rtdReplySize and
internalState == InternalState::RUNNING) {
*foundId = Max31865Definitions::REQUEST_RTD;
*foundLen = rtdReplySize;
return RETURN_OK;
}
if(remainingSize == 3) {
switch(internalState) {
case(InternalState::CONFIG_HIGH_THRESHOLD): {
*foundLen = 3;
*foundId = Max31865Definitions::WRITE_HIGH_THRESHOLD;
commandExecuted = true;
return RETURN_OK;
}
case(InternalState::REQUEST_HIGH_THRESHOLD): {
*foundLen = 3;
*foundId = Max31865Definitions::REQUEST_HIGH_THRESHOLD;
return RETURN_OK;
}
case(InternalState::CONFIG_LOW_THRESHOLD): {
*foundLen = 3;
*foundId = Max31865Definitions::WRITE_LOW_THRESHOLD;
commandExecuted = true;
return RETURN_OK;
}
case(InternalState::REQUEST_LOW_THRESHOLD): {
*foundLen = 3;
*foundId = Max31865Definitions::REQUEST_LOW_THRESHOLD;
return RETURN_OK;
}
default: {
sif::debug << "Max31865PT1000Handler::scanForReply: Unknown internal state"
<< std::endl;
return RETURN_OK;
}
}
}
if(remainingSize == configReplySize) {
if(internalState == InternalState::CONFIGURE) {
commandExecuted = true;
*foundLen = configReplySize;
*foundId = Max31865Definitions::CONFIG_CMD;
}
else if(internalState == InternalState::REQUEST_FAULT_BYTE) {
*foundId = Max31865Definitions::REQUEST_FAULT_BYTE;
*foundLen = 2;
internalState = InternalState::RUNNING;
}
else if(internalState == InternalState::CLEAR_FAULT_BYTE) {
*foundId = Max31865Definitions::CLEAR_FAULT_BYTE;
*foundLen = 2;
if(mode == _MODE_START_UP) {
commandExecuted = true;
} else {
internalState = InternalState::RUNNING;
}
}
else {
*foundId = Max31865Definitions::REQUEST_CONFIG;
*foundLen = configReplySize;
}
}
ReturnValue_t Max31865PT1000Handler::scanForReply(const uint8_t *start, size_t remainingSize,
DeviceCommandId_t *foundId, size_t *foundLen) {
size_t rtdReplySize = 3;
size_t configReplySize = 2;
if (remainingSize == rtdReplySize and internalState == InternalState::RUNNING) {
*foundId = Max31865Definitions::REQUEST_RTD;
*foundLen = rtdReplySize;
return RETURN_OK;
}
if (remainingSize == 3) {
switch (internalState) {
case (InternalState::CONFIG_HIGH_THRESHOLD): {
*foundLen = 3;
*foundId = Max31865Definitions::WRITE_HIGH_THRESHOLD;
commandExecuted = true;
return RETURN_OK;
}
case (InternalState::REQUEST_HIGH_THRESHOLD): {
*foundLen = 3;
*foundId = Max31865Definitions::REQUEST_HIGH_THRESHOLD;
return RETURN_OK;
}
case (InternalState::CONFIG_LOW_THRESHOLD): {
*foundLen = 3;
*foundId = Max31865Definitions::WRITE_LOW_THRESHOLD;
commandExecuted = true;
return RETURN_OK;
}
case (InternalState::REQUEST_LOW_THRESHOLD): {
*foundLen = 3;
*foundId = Max31865Definitions::REQUEST_LOW_THRESHOLD;
return RETURN_OK;
}
default: {
sif::debug << "Max31865PT1000Handler::scanForReply: Unknown internal state" << std::endl;
return RETURN_OK;
}
}
}
if (remainingSize == configReplySize) {
if (internalState == InternalState::CONFIGURE) {
commandExecuted = true;
*foundLen = configReplySize;
*foundId = Max31865Definitions::CONFIG_CMD;
} else if (internalState == InternalState::REQUEST_FAULT_BYTE) {
*foundId = Max31865Definitions::REQUEST_FAULT_BYTE;
*foundLen = 2;
internalState = InternalState::RUNNING;
} else if (internalState == InternalState::CLEAR_FAULT_BYTE) {
*foundId = Max31865Definitions::CLEAR_FAULT_BYTE;
*foundLen = 2;
if (mode == _MODE_START_UP) {
commandExecuted = true;
} else {
internalState = InternalState::RUNNING;
}
} else {
*foundId = Max31865Definitions::REQUEST_CONFIG;
*foundLen = configReplySize;
}
}
return RETURN_OK;
}
ReturnValue_t Max31865PT1000Handler::interpretDeviceReply(
DeviceCommandId_t id, const uint8_t *packet) {
switch(id) {
case(Max31865Definitions::REQUEST_CONFIG): {
if(packet[1] != DEFAULT_CONFIG) {
ReturnValue_t Max31865PT1000Handler::interpretDeviceReply(DeviceCommandId_t id,
const uint8_t *packet) {
switch (id) {
case (Max31865Definitions::REQUEST_CONFIG): {
if (packet[1] != DEFAULT_CONFIG) {
#if FSFW_CPP_OSTREAM_ENABLED == 1
// it propably would be better if we at least try one restart..
sif::error << "Max31865PT1000Handler: 0x" << std::hex << this->getObjectId()
<< ": Invalid configuration reply" << std::endl;
// it propably would be better if we at least try one restart..
sif::error << "Max31865PT1000Handler: 0x" << std::hex << this->getObjectId()
<< ": Invalid configuration reply" << std::endl;
#else
sif::printError("Max31865PT1000Handler: %04x: Invalid configuration reply!\n",
this->getObjectId());
sif::printError("Max31865PT1000Handler: %04x: Invalid configuration reply!\n",
this->getObjectId());
#endif
return HasReturnvaluesIF::RETURN_OK;
}
// set to true for invalid configs too for now.
if(internalState == InternalState::REQUEST_CONFIG) {
commandExecuted = true;
}
else if(internalState == InternalState::RUNNING) {
// we should propably generate a telemetry with the config byte
// as payload here.
}
break;
return HasReturnvaluesIF::RETURN_OK;
}
// set to true for invalid configs too for now.
if (internalState == InternalState::REQUEST_CONFIG) {
commandExecuted = true;
} else if (internalState == InternalState::RUNNING) {
// we should propably generate a telemetry with the config byte
// as payload here.
}
break;
}
case(Max31865Definitions::REQUEST_LOW_THRESHOLD): {
uint16_t readLowThreshold = packet[1] << 8 | packet[2];
if(readLowThreshold != LOW_THRESHOLD) {
case (Max31865Definitions::REQUEST_LOW_THRESHOLD): {
uint16_t readLowThreshold = packet[1] << 8 | packet[2];
if (readLowThreshold != LOW_THRESHOLD) {
#if FSFW_VERBOSE_LEVEL >= 1
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::warning << "Max31865PT1000Handler::interpretDeviceReply: Object ID: " <<
std::hex << this->getObjectId() << ": Missmatch between " <<
"written and readback value of low threshold register" << std::endl;
sif::warning << "Max31865PT1000Handler::interpretDeviceReply: Object ID: " << std::hex
<< this->getObjectId() << ": Missmatch between "
<< "written and readback value of low threshold register" << std::endl;
#else
sif::printWarning("Max31865PT1000Handler::interpretDeviceReply: Missmatch between "
"written and readback value of low threshold register\n");
sif::printWarning(
"Max31865PT1000Handler::interpretDeviceReply: Missmatch between "
"written and readback value of low threshold register\n");
#endif
#endif
}
commandExecuted = true;
break;
}
commandExecuted = true;
break;
}
case(Max31865Definitions::REQUEST_HIGH_THRESHOLD): {
uint16_t readHighThreshold = packet[1] << 8 | packet[2];
if(readHighThreshold != HIGH_THRESHOLD) {
case (Max31865Definitions::REQUEST_HIGH_THRESHOLD): {
uint16_t readHighThreshold = packet[1] << 8 | packet[2];
if (readHighThreshold != HIGH_THRESHOLD) {
#if FSFW_VERBOSE_LEVEL >= 1
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::warning << "Max31865PT1000Handler::interpretDeviceReply: Object ID: "
<< std::hex << this->getObjectId() << ": Missmatch between " <<
"written and readback value of high threshold register" << std::endl;
sif::warning << "Max31865PT1000Handler::interpretDeviceReply: Object ID: " << std::hex
<< this->getObjectId() << ": Missmatch between "
<< "written and readback value of high threshold register" << std::endl;
#else
sif::printWarning("Max31865PT1000Handler::interpretDeviceReply: Missmatch between "
"written and readback value of high threshold register\n");
sif::printWarning(
"Max31865PT1000Handler::interpretDeviceReply: Missmatch between "
"written and readback value of high threshold register\n");
#endif
#endif
}
commandExecuted = true;
break;
}
commandExecuted = true;
break;
}
case(Max31865Definitions::REQUEST_RTD): {
// first bit of LSB reply byte is the fault bit
uint8_t faultBit = packet[2] & 0b0000'0001;
if(resetFaultBit) {
internalState = InternalState::CLEAR_FAULT_BYTE;
resetFaultBit = false;
}
else if(faultBit == 1) {
// Maybe we should attempt to restart it?
internalState = InternalState::REQUEST_FAULT_BYTE;
resetFaultBit = true;
}
case (Max31865Definitions::REQUEST_RTD): {
// first bit of LSB reply byte is the fault bit
uint8_t faultBit = packet[2] & 0b0000'0001;
if (resetFaultBit) {
internalState = InternalState::CLEAR_FAULT_BYTE;
resetFaultBit = false;
} else if (faultBit == 1) {
// Maybe we should attempt to restart it?
internalState = InternalState::REQUEST_FAULT_BYTE;
resetFaultBit = true;
}
// RTD value consists of last seven bits of the LSB reply byte and
// the MSB reply byte
uint16_t adcCode = ((packet[1] << 8) | packet[2]) >> 1;
// do something with rtd value, will propably be stored in
// dataset.
float rtdValue = adcCode * RTD_RREF_PT1000 / INT16_MAX;
// calculate approximation
float approxTemp = adcCode / 32.0 - 256.0;
// RTD value consists of last seven bits of the LSB reply byte and
// the MSB reply byte
uint16_t adcCode = ((packet[1] << 8) | packet[2]) >> 1;
// do something with rtd value, will propably be stored in
// dataset.
float rtdValue = adcCode * RTD_RREF_PT1000 / INT16_MAX;
// calculate approximation
float approxTemp = adcCode / 32.0 - 256.0;
#if OBSW_DEBUG_RTD == 1
#if OBSW_VERBOSE_LEVEL >= 1
if(debugDivider->checkAndIncrement()) {
if (debugDivider->checkAndIncrement()) {
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::info << "Max31865: Object ID: " << std::hex << this->getObjectId()
<< ": Measured resistance is " << rtdValue << " Ohms." << std::endl;
sif::info << "Approximated temperature is " << approxTemp << " C" << std::endl;
sif::info << "Max31865: Object ID: " << std::hex << this->getObjectId()
<< ": Measured resistance is " << rtdValue << " Ohms." << std::endl;
sif::info << "Approximated temperature is " << approxTemp << " C" << std::endl;
#else
sif::printInfo("Max31685: Measured resistance is %f Ohms\n", rtdValue);
sif::printInfo("Approximated temperature is %f C\n", approxTemp);
sif::printInfo("Max31685: Measured resistance is %f Ohms\n", rtdValue);
sif::printInfo("Approximated temperature is %f C\n", approxTemp);
#endif
}
}
#endif
#endif
PoolReadGuard pg(&sensorDataset);
if(pg.getReadResult() != HasReturnvaluesIF::RETURN_OK) {
// Configuration error
PoolReadGuard pg(&sensorDataset);
if (pg.getReadResult() != HasReturnvaluesIF::RETURN_OK) {
// Configuration error
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::warning << "Max31865PT1000Handler::interpretDeviceReply: Object ID: "
<< std::hex << this->getObjectId() << ": Error reading dataset!"
<< std::endl;
sif::warning << "Max31865PT1000Handler::interpretDeviceReply: Object ID: " << std::hex
<< this->getObjectId() << ": Error reading dataset!" << std::endl;
#else
sif::printWarning("Max31865PT1000Handler::interpretDeviceReply: "
"Error reading dataset!\n");
sif::printWarning(
"Max31865PT1000Handler::interpretDeviceReply: "
"Error reading dataset!\n");
#endif
return pg.getReadResult();
}
return pg.getReadResult();
}
if(not sensorDataset.isValid()) {
sensorDataset.setValidity(true, false);
sensorDataset.rtdValue.setValid(true);
sensorDataset.temperatureCelcius.setValid(true);
}
if (not sensorDataset.isValid()) {
sensorDataset.setValidity(true, false);
sensorDataset.rtdValue.setValid(true);
sensorDataset.temperatureCelcius.setValid(true);
}
sensorDataset.rtdValue = rtdValue;
sensorDataset.temperatureCelcius = approxTemp;
break;
sensorDataset.rtdValue = rtdValue;
sensorDataset.temperatureCelcius = approxTemp;
break;
}
case(Max31865Definitions::REQUEST_FAULT_BYTE): {
faultByte = packet[1];
case (Max31865Definitions::REQUEST_FAULT_BYTE): {
faultByte = packet[1];
#if OBSW_VERBOSE_LEVEL >= 1
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::warning << "Max31865PT1000Handler::interpretDeviceReply: Object ID: "
<< std::hex << this->getObjectId() << ": Fault byte"
" is: 0b" << std::bitset<8>(faultByte) << std::endl;
sif::warning << "Max31865PT1000Handler::interpretDeviceReply: Object ID: " << std::hex
<< this->getObjectId()
<< ": Fault byte"
" is: 0b"
<< std::bitset<8>(faultByte) << std::endl;
#else
sif::printWarning("Max31865PT1000Handler::interpretDeviceReply: Fault byte"
" is: 0b" BYTE_TO_BINARY_PATTERN "\n", BYTE_TO_BINARY(faultByte));
sif::printWarning(
"Max31865PT1000Handler::interpretDeviceReply: Fault byte"
" is: 0b" BYTE_TO_BINARY_PATTERN "\n",
BYTE_TO_BINARY(faultByte));
#endif
#endif
ReturnValue_t result = sensorDataset.read();
if(result != HasReturnvaluesIF::RETURN_OK) {
// Configuration error
ReturnValue_t result = sensorDataset.read();
if (result != HasReturnvaluesIF::RETURN_OK) {
// Configuration error
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::debug << "Max31865PT1000Handler::interpretDeviceReply: Object ID: " << std::hex
<< this->getObjectId() << ":"
"Error reading dataset!" << std::endl;
sif::debug << "Max31865PT1000Handler::interpretDeviceReply: Object ID: " << std::hex
<< this->getObjectId()
<< ":"
"Error reading dataset!"
<< std::endl;
#else
sif::printDebug("Max31865PT1000Handler::interpretDeviceReply: "
"Error reading dataset!\n");
sif::printDebug(
"Max31865PT1000Handler::interpretDeviceReply: "
"Error reading dataset!\n");
#endif
return result;
}
sensorDataset.errorByte.setValid(true);
sensorDataset.errorByte = faultByte;
if(faultByte != 0) {
sensorDataset.temperatureCelcius.setValid(false);
}
return result;
}
sensorDataset.errorByte.setValid(true);
sensorDataset.errorByte = faultByte;
if (faultByte != 0) {
sensorDataset.temperatureCelcius.setValid(false);
}
result = sensorDataset.commit();
if(result != HasReturnvaluesIF::RETURN_OK) {
// Configuration error
result = sensorDataset.commit();
if (result != HasReturnvaluesIF::RETURN_OK) {
// Configuration error
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::debug << "Max31865PT1000Handler::interpretDeviceReply: Object ID: " << std::hex
<< this->getObjectId() << ": Error commiting dataset!" << std::endl;
sif::debug << "Max31865PT1000Handler::interpretDeviceReply: Object ID: " << std::hex
<< this->getObjectId() << ": Error commiting dataset!" << std::endl;
#else
sif::printDebug("Max31865PT1000Handler::interpretDeviceReply: "
"Error commiting dataset!\n");
sif::printDebug(
"Max31865PT1000Handler::interpretDeviceReply: "
"Error commiting dataset!\n");
#endif
return result;
}
return result;
}
break;
break;
}
default:
break;
}
return HasReturnvaluesIF::RETURN_OK;
break;
}
return HasReturnvaluesIF::RETURN_OK;
}
void Max31865PT1000Handler::debugInterface(uint8_t positionTracker,
object_id_t objectId, uint32_t parameter) {
void Max31865PT1000Handler::debugInterface(uint8_t positionTracker, object_id_t objectId,
uint32_t parameter) {}
uint32_t Max31865PT1000Handler::getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) {
return 25000;
}
uint32_t Max31865PT1000Handler::getTransitionDelayMs(
Mode_t modeFrom, Mode_t modeTo) {
return 25000;
ReturnValue_t Max31865PT1000Handler::getSwitches(const uint8_t **switches,
uint8_t *numberOfSwitches) {
return DeviceHandlerBase::NO_SWITCH;
}
ReturnValue_t Max31865PT1000Handler::getSwitches(
const uint8_t **switches, uint8_t *numberOfSwitches) {
return DeviceHandlerBase::NO_SWITCH;
void Max31865PT1000Handler::doTransition(Mode_t modeFrom, Submode_t subModeFrom) {
DeviceHandlerBase::doTransition(modeFrom, subModeFrom);
}
void Max31865PT1000Handler::doTransition(Mode_t modeFrom,
Submode_t subModeFrom) {
DeviceHandlerBase::doTransition(modeFrom, subModeFrom);
}
ReturnValue_t Max31865PT1000Handler::initializeLocalDataPool(localpool::DataPool& localDataPoolMap,
LocalDataPoolManager& poolManager) {
localDataPoolMap.emplace(Max31865Definitions::PoolIds::RTD_VALUE, new PoolEntry<float>({0}));
localDataPoolMap.emplace(Max31865Definitions::PoolIds::TEMPERATURE_C,
new PoolEntry<float>({0}, 1, true));
localDataPoolMap.emplace(Max31865Definitions::PoolIds::FAULT_BYTE,
new PoolEntry<uint8_t>({0}));
// poolManager.subscribeForPeriodicPacket(sensorDatasetSid,
// false, 4.0, false);
return HasReturnvaluesIF::RETURN_OK;
ReturnValue_t Max31865PT1000Handler::initializeLocalDataPool(localpool::DataPool &localDataPoolMap,
LocalDataPoolManager &poolManager) {
localDataPoolMap.emplace(Max31865Definitions::PoolIds::RTD_VALUE, new PoolEntry<float>({0}));
localDataPoolMap.emplace(Max31865Definitions::PoolIds::TEMPERATURE_C,
new PoolEntry<float>({0}, 1, true));
localDataPoolMap.emplace(Max31865Definitions::PoolIds::FAULT_BYTE, new PoolEntry<uint8_t>({0}));
// poolManager.subscribeForPeriodicPacket(sensorDatasetSid,
// false, 4.0, false);
return HasReturnvaluesIF::RETURN_OK;
}
void Max31865PT1000Handler::setInstantNormal(bool instantNormal) {
this->instantNormal = instantNormal;
this->instantNormal = instantNormal;
}
void Max31865PT1000Handler::modeChanged() {
if(mode == MODE_OFF) {
internalState = InternalState::NONE;
}
if (mode == MODE_OFF) {
internalState = InternalState::NONE;
}
}

View File

@ -2,12 +2,12 @@
#define MISSION_DEVICES_MAX31865PT1000HANDLER_H_
#include <OBSWConfig.h>
#include <fsfw/devicehandlers/DeviceHandlerBase.h>
#include <fsfw/globalfunctions/PeriodicOperationDivider.h>
#include <array>
#include <cstdint>
#include "devicedefinitions/Max31865Definitions.h"
/**
@ -28,95 +28,92 @@
* @author R. Mueller
* @ingroup devices
*/
class Max31865PT1000Handler: public DeviceHandlerBase {
public:
Max31865PT1000Handler(object_id_t objectId, object_id_t comIF, CookieIF * comCookie);
virtual~ Max31865PT1000Handler();
class Max31865PT1000Handler : public DeviceHandlerBase {
public:
Max31865PT1000Handler(object_id_t objectId, object_id_t comIF, CookieIF *comCookie);
virtual ~Max31865PT1000Handler();
// Configuration in 8 digit code:
// 1. 1 for V_BIAS enabled, 0 for disabled
// 2. 1 for Auto-conversion, 0 for off
// 3. 1 for 1-shot enabled, 0 for disabled (self-clearing bit)
// 4. 1 for 3-wire enabled, 0 for disabled (two and four wired RTD)
// 5./6. Fault detection: 00 for no action, 01 for automatic delay, 1
// 0 for run fault detection with manual delay,
// 11 for finish fault detection with manual delay
// 7. Fault status: Write 1 to reset fault status register (Bit is self cleared afterwards)
// 8. 1 for 50 Hz filter, 0 for 60 Hz filter (noise rejection filter)
static constexpr uint8_t DEFAULT_CONFIG = 0b11000001;
// Configuration in 8 digit code:
// 1. 1 for V_BIAS enabled, 0 for disabled
// 2. 1 for Auto-conversion, 0 for off
// 3. 1 for 1-shot enabled, 0 for disabled (self-clearing bit)
// 4. 1 for 3-wire enabled, 0 for disabled (two and four wired RTD)
// 5./6. Fault detection: 00 for no action, 01 for automatic delay, 1
// 0 for run fault detection with manual delay,
// 11 for finish fault detection with manual delay
// 7. Fault status: Write 1 to reset fault status register (Bit is self cleared afterwards)
// 8. 1 for 50 Hz filter, 0 for 60 Hz filter (noise rejection filter)
static constexpr uint8_t DEFAULT_CONFIG = 0b11000001;
void setInstantNormal(bool instantNormal);
/**
* Expected temperature range is -100 C and 100 C.
* If there are temperatures beyond this range there must be a fault.
* The threshold variables cause the MAX1385 to signal an error in case the measured resistance
* indicates a temperature higher than 100 C or lower than -100 C.
* Default settings of MAX13865 are 0xFFFF for the high threshold register and 0x0 for the
* low threshold register.
*/
static constexpr uint16_t HIGH_THRESHOLD = 11298; // = 100 C
static constexpr uint16_t LOW_THRESHOLD = 4902; // = -100 C
void setInstantNormal(bool instantNormal);
/**
* Expected temperature range is -100 C and 100 C.
* If there are temperatures beyond this range there must be a fault.
* The threshold variables cause the MAX1385 to signal an error in case the measured resistance
* indicates a temperature higher than 100 C or lower than -100 C.
* Default settings of MAX13865 are 0xFFFF for the high threshold register and 0x0 for the
* low threshold register.
*/
static constexpr uint16_t HIGH_THRESHOLD = 11298; // = 100 C
static constexpr uint16_t LOW_THRESHOLD = 4902; // = -100 C
static constexpr float RTD_RREF_PT1000 = 4020.0; //!< Ohm
static constexpr float RTD_RESISTANCE0_PT1000 = 1000.0; //!< Ohm
protected:
// DeviceHandlerBase abstract function implementation
void doStartUp() override;
void doShutDown() override;
ReturnValue_t buildNormalDeviceCommand(DeviceCommandId_t * id) override;
ReturnValue_t buildTransitionDeviceCommand(DeviceCommandId_t * id) override;
ReturnValue_t buildCommandFromCommand(DeviceCommandId_t deviceCommand,
const uint8_t * commandData, size_t commandDataLen) override;
void fillCommandAndReplyMap() override;
ReturnValue_t scanForReply(const uint8_t *start, size_t remainingSize,
DeviceCommandId_t *foundId, size_t *foundLen) override;
ReturnValue_t interpretDeviceReply(DeviceCommandId_t id,
const uint8_t *packet) override;
uint32_t getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) override;
ReturnValue_t getSwitches(const uint8_t **switches,
uint8_t *numberOfSwitches) override;
static constexpr float RTD_RREF_PT1000 = 4020.0; //!< Ohm
static constexpr float RTD_RESISTANCE0_PT1000 = 1000.0; //!< Ohm
protected:
// DeviceHandlerBase abstract function implementation
void doStartUp() override;
void doShutDown() override;
ReturnValue_t buildNormalDeviceCommand(DeviceCommandId_t *id) override;
ReturnValue_t buildTransitionDeviceCommand(DeviceCommandId_t *id) override;
ReturnValue_t buildCommandFromCommand(DeviceCommandId_t deviceCommand, const uint8_t *commandData,
size_t commandDataLen) override;
void fillCommandAndReplyMap() override;
ReturnValue_t scanForReply(const uint8_t *start, size_t remainingSize, DeviceCommandId_t *foundId,
size_t *foundLen) override;
ReturnValue_t interpretDeviceReply(DeviceCommandId_t id, const uint8_t *packet) override;
uint32_t getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) override;
ReturnValue_t getSwitches(const uint8_t **switches, uint8_t *numberOfSwitches) override;
void doTransition(Mode_t modeFrom, Submode_t subModeFrom) override;
void doTransition(Mode_t modeFrom, Submode_t subModeFrom) override;
void debugInterface(uint8_t positionTracker = 0,
object_id_t objectId = 0, uint32_t parameter = 0) override;
ReturnValue_t initializeLocalDataPool(localpool::DataPool& localDataPoolMap,
LocalDataPoolManager& poolManager) override;
void modeChanged() override;
void debugInterface(uint8_t positionTracker = 0, object_id_t objectId = 0,
uint32_t parameter = 0) override;
ReturnValue_t initializeLocalDataPool(localpool::DataPool &localDataPoolMap,
LocalDataPoolManager &poolManager) override;
void modeChanged() override;
private:
uint8_t switchId = 0;
bool instantNormal = true;
private:
uint8_t switchId = 0;
bool instantNormal = true;
enum class InternalState {
NONE,
WARMUP,
CONFIGURE,
CONFIG_HIGH_THRESHOLD,
REQUEST_HIGH_THRESHOLD,
CONFIG_LOW_THRESHOLD,
REQUEST_LOW_THRESHOLD,
REQUEST_CONFIG,
RUNNING,
REQUEST_FAULT_BYTE,
CLEAR_FAULT_BYTE
};
enum class InternalState {
NONE,
WARMUP,
CONFIGURE,
CONFIG_HIGH_THRESHOLD,
REQUEST_HIGH_THRESHOLD,
CONFIG_LOW_THRESHOLD,
REQUEST_LOW_THRESHOLD,
REQUEST_CONFIG,
RUNNING,
REQUEST_FAULT_BYTE,
CLEAR_FAULT_BYTE
};
InternalState internalState = InternalState::NONE;
bool commandExecuted = false;
InternalState internalState = InternalState::NONE;
bool commandExecuted = false;
bool resetFaultBit = false;
dur_millis_t startTime = 0;
uint8_t faultByte = 0;
std::array<uint8_t, 3> commandBuffer { 0 };
bool resetFaultBit = false;
dur_millis_t startTime = 0;
uint8_t faultByte = 0;
std::array<uint8_t, 3> commandBuffer{0};
Max31865Definitions::Max31865Set sensorDataset;
sid_t sensorDatasetSid;
Max31865Definitions::Max31865Set sensorDataset;
sid_t sensorDatasetSid;
#if OBSW_VERBOSE_LEVEL >= 1
PeriodicOperationDivider* debugDivider;
PeriodicOperationDivider *debugDivider;
#endif
};
#endif /* MISSION_DEVICES_MAX31865PT1000HANDLER_H_ */

View File

@ -1,480 +1,506 @@
#include <fsfw/datapool/PoolReadGuard.h>
#include "P60DockHandler.h"
#include <fsfw/datapool/PoolReadGuard.h>
#include "OBSWConfig.h"
P60DockHandler::P60DockHandler(object_id_t objectId, object_id_t comIF, CookieIF * comCookie) :
GomspaceDeviceHandler(objectId, comIF, comCookie, P60Dock::MAX_CONFIGTABLE_ADDRESS,
P60Dock::MAX_HKTABLE_ADDRESS, P60Dock::HK_TABLE_REPLY_SIZE, &p60dockHkTableDataset), p60dockHkTableDataset(
this) {
}
P60DockHandler::P60DockHandler(object_id_t objectId, object_id_t comIF, CookieIF *comCookie)
: GomspaceDeviceHandler(objectId, comIF, comCookie, P60Dock::MAX_CONFIGTABLE_ADDRESS,
P60Dock::MAX_HKTABLE_ADDRESS, P60Dock::HK_TABLE_REPLY_SIZE,
&p60dockHkTableDataset),
p60dockHkTableDataset(this) {}
P60DockHandler::~P60DockHandler() {
}
P60DockHandler::~P60DockHandler() {}
ReturnValue_t P60DockHandler::buildNormalDeviceCommand(
DeviceCommandId_t * id) {
*id = GOMSPACE::REQUEST_HK_TABLE;
return buildCommandFromCommand(*id, NULL, 0);
ReturnValue_t P60DockHandler::buildNormalDeviceCommand(DeviceCommandId_t *id) {
*id = GOMSPACE::REQUEST_HK_TABLE;
return buildCommandFromCommand(*id, NULL, 0);
}
void P60DockHandler::letChildHandleHkReply(DeviceCommandId_t id, const uint8_t *packet) {
parseHkTableReply(packet);
/**
* Hk table will be sent to the commander if hk table request was not triggered by the
* P60DockHandler itself.
*/
handleDeviceTM(&p60dockHkTableDataset, id, true);
parseHkTableReply(packet);
/**
* Hk table will be sent to the commander if hk table request was not triggered by the
* P60DockHandler itself.
*/
handleDeviceTM(&p60dockHkTableDataset, id, true);
#if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_P60DOCK == 1
p60dockHkTableDataset.read();
sif::info << "P60 Dock: ACU VCC switch: " <<
static_cast<unsigned int>(p60dockHkTableDataset.outputEnableStateAcuVcc.value) << std::endl;
sif::info << "P60 Dock: PDU1 VCC switch: " <<
static_cast<unsigned int>(p60dockHkTableDataset.outputEnableStatePdu1Vcc.value) << std::endl;
sif::info << "P60 Dock: PDU2 VCC switch: " <<
static_cast<unsigned int>(p60dockHkTableDataset.outputEnableStatePdu2Vcc.value) << std::endl;
sif::info << "P60 Dock: ACU VBAT switch: " <<
static_cast<unsigned int>(p60dockHkTableDataset.outputEnableStateAcuVbat.value) << std::endl;
sif::info << "P60 Dock: PDU1 VBAT switch: " <<
static_cast<unsigned int>(p60dockHkTableDataset.outputEnableStatePdu1Vbat.value) << std::endl;
sif::info << "P60 Dock: PDU2 VBAT switch: " <<
static_cast<unsigned int>(p60dockHkTableDataset.outputEnableStatePdu2Vbat.value) << std::endl;
sif::info << "P60 Dock: Stack VBAT switch: " <<
static_cast<unsigned int>(p60dockHkTableDataset.outputEnableStateStackVbat.value) << std::endl;
sif::info << "P60 Dock: Stack 3V3 switch: " <<
static_cast<unsigned int>(p60dockHkTableDataset.outputEnableStateStack3V3.value) << std::endl;
sif::info << "P60 Dock: Stack 5V switch: " <<
static_cast<unsigned int>(p60dockHkTableDataset.outputEnableStateStack5V.value) << std::endl;
p60dockHkTableDataset.read();
sif::info << "P60 Dock: ACU VCC switch: "
<< static_cast<unsigned int>(p60dockHkTableDataset.outputEnableStateAcuVcc.value)
<< std::endl;
sif::info << "P60 Dock: PDU1 VCC switch: "
<< static_cast<unsigned int>(p60dockHkTableDataset.outputEnableStatePdu1Vcc.value)
<< std::endl;
sif::info << "P60 Dock: PDU2 VCC switch: "
<< static_cast<unsigned int>(p60dockHkTableDataset.outputEnableStatePdu2Vcc.value)
<< std::endl;
sif::info << "P60 Dock: ACU VBAT switch: "
<< static_cast<unsigned int>(p60dockHkTableDataset.outputEnableStateAcuVbat.value)
<< std::endl;
sif::info << "P60 Dock: PDU1 VBAT switch: "
<< static_cast<unsigned int>(p60dockHkTableDataset.outputEnableStatePdu1Vbat.value)
<< std::endl;
sif::info << "P60 Dock: PDU2 VBAT switch: "
<< static_cast<unsigned int>(p60dockHkTableDataset.outputEnableStatePdu2Vbat.value)
<< std::endl;
sif::info << "P60 Dock: Stack VBAT switch: "
<< static_cast<unsigned int>(p60dockHkTableDataset.outputEnableStateStackVbat.value)
<< std::endl;
sif::info << "P60 Dock: Stack 3V3 switch: "
<< static_cast<unsigned int>(p60dockHkTableDataset.outputEnableStateStack3V3.value)
<< std::endl;
sif::info << "P60 Dock: Stack 5V switch: "
<< static_cast<unsigned int>(p60dockHkTableDataset.outputEnableStateStack5V.value)
<< std::endl;
float temperatureC = p60dockHkTableDataset.temperature1.value * 0.1;
sif::info << "P60 Dock: Temperature 1: " << temperatureC << " °C" << std::endl;
temperatureC = p60dockHkTableDataset.temperature2.value * 0.1;
sif::info << "P60 Dock: Temperature 2: " << temperatureC << " °C" << std::endl;
sif::info << "P60 Dock: Watchdog Timer seconds left before reboot: "
float temperatureC = p60dockHkTableDataset.temperature1.value * 0.1;
sif::info << "P60 Dock: Temperature 1: " << temperatureC << " °C" << std::endl;
temperatureC = p60dockHkTableDataset.temperature2.value * 0.1;
sif::info << "P60 Dock: Temperature 2: " << temperatureC << " °C" << std::endl;
sif::info << "P60 Dock: Watchdog Timer seconds left before reboot: "
<< p60dockHkTableDataset.wdtGndLeft << " seconds" << std::endl;
sif::info << "P60 Dock: CSP 1, pings left before reboot: "
<< (int) p60dockHkTableDataset.wdtCspLeft1.value << std::endl;
sif::info << "P60 Dock: CSP 2, pings left before reboot: "
<< (int) p60dockHkTableDataset.wdtCspLeft1.value << std::endl;
sif::info << "P60 Dock: CSP 1, pings left before reboot: "
<< (int)p60dockHkTableDataset.wdtCspLeft1.value << std::endl;
sif::info << "P60 Dock: CSP 2, pings left before reboot: "
<< (int)p60dockHkTableDataset.wdtCspLeft1.value << std::endl;
p60dockHkTableDataset.commit();
p60dockHkTableDataset.commit();
#endif
}
void P60DockHandler::parseHkTableReply(const uint8_t *packet) {
uint16_t dataOffset = 0;
p60dockHkTableDataset.read();
/**
* Fist 10 bytes contain the gomspace header. Each variable is preceded by the 16-bit table
* address.
*/
dataOffset += 12;
p60dockHkTableDataset.currentAcuVcc = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
p60dockHkTableDataset.currentPdu1Vcc = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
p60dockHkTableDataset.currentX3IdleVcc = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
p60dockHkTableDataset.currentPdu2Vcc = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
p60dockHkTableDataset.currentAcuVbat = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
p60dockHkTableDataset.currentPdu1Vbat = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
p60dockHkTableDataset.currentX3IdleVbat = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
p60dockHkTableDataset.currentPdu2Vbat = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
p60dockHkTableDataset.currentStackVbat = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
p60dockHkTableDataset.currentStack3V3 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
p60dockHkTableDataset.currentStack5V = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
p60dockHkTableDataset.currentGS3V3 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
p60dockHkTableDataset.currentGS5V = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
uint16_t dataOffset = 0;
p60dockHkTableDataset.read();
/**
* Fist 10 bytes contain the gomspace header. Each variable is preceded by the 16-bit table
* address.
*/
dataOffset += 12;
p60dockHkTableDataset.currentAcuVcc = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
p60dockHkTableDataset.currentPdu1Vcc = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
p60dockHkTableDataset.currentX3IdleVcc = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
p60dockHkTableDataset.currentPdu2Vcc = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
p60dockHkTableDataset.currentAcuVbat = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
p60dockHkTableDataset.currentPdu1Vbat = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
p60dockHkTableDataset.currentX3IdleVbat =
*(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
p60dockHkTableDataset.currentPdu2Vbat = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
p60dockHkTableDataset.currentStackVbat = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
p60dockHkTableDataset.currentStack3V3 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
p60dockHkTableDataset.currentStack5V = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
p60dockHkTableDataset.currentGS3V3 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
p60dockHkTableDataset.currentGS5V = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
p60dockHkTableDataset.voltageAcuVcc = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
p60dockHkTableDataset.voltageAcuVcc = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
p60dockHkTableDataset.voltagePdu1Vcc = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
p60dockHkTableDataset.voltageX3IdleVcc = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
p60dockHkTableDataset.voltagePdu2Vcc = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
p60dockHkTableDataset.voltageAcuVbat = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
p60dockHkTableDataset.voltagePdu1Vbat = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
p60dockHkTableDataset.voltageX3IdleVbat = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
p60dockHkTableDataset.voltagePdu2Vbat = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
p60dockHkTableDataset.voltageStackVbat = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
p60dockHkTableDataset.voltageStack3V3 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
p60dockHkTableDataset.voltageStack5V = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
p60dockHkTableDataset.voltageGS3V3 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
p60dockHkTableDataset.voltageAcuVcc = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
p60dockHkTableDataset.voltageAcuVcc = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
p60dockHkTableDataset.voltagePdu1Vcc = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
p60dockHkTableDataset.voltageX3IdleVcc = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
p60dockHkTableDataset.voltagePdu2Vcc = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
p60dockHkTableDataset.voltageAcuVbat = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
p60dockHkTableDataset.voltagePdu1Vbat = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
p60dockHkTableDataset.voltageX3IdleVbat =
*(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
p60dockHkTableDataset.voltagePdu2Vbat = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
p60dockHkTableDataset.voltageStackVbat = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
p60dockHkTableDataset.voltageStack3V3 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
p60dockHkTableDataset.voltageStack5V = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
p60dockHkTableDataset.voltageGS3V3 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
p60dockHkTableDataset.outputEnableStateAcuVcc = *(packet + dataOffset);
dataOffset += 3;
p60dockHkTableDataset.outputEnableStatePdu1Vcc = *(packet + dataOffset);
dataOffset += 3;
p60dockHkTableDataset.outputEnableStateX3IdleVcc = *(packet + dataOffset);
dataOffset += 3;
p60dockHkTableDataset.outputEnableStatePdu2Vcc = *(packet + dataOffset);
dataOffset += 3;
p60dockHkTableDataset.outputEnableStateAcuVbat = *(packet + dataOffset);
dataOffset += 3;
p60dockHkTableDataset.outputEnableStatePdu1Vbat = *(packet + dataOffset);
dataOffset += 3;
p60dockHkTableDataset.outputEnableStateX3IdleVbat = *(packet + dataOffset);
dataOffset += 3;
p60dockHkTableDataset.outputEnableStatePdu2Vbat = *(packet + dataOffset);
dataOffset += 3;
p60dockHkTableDataset.outputEnableStateStackVbat = *(packet + dataOffset);
dataOffset += 3;
p60dockHkTableDataset.outputEnableStateStack3V3 = *(packet + dataOffset);
dataOffset += 3;
p60dockHkTableDataset.outputEnableStateStack5V = *(packet + dataOffset);
dataOffset += 3;
p60dockHkTableDataset.outputEnableStateGS3V3 = *(packet + dataOffset);
dataOffset += 3;
p60dockHkTableDataset.outputEnableStateGS5V = *(packet + dataOffset);
dataOffset += 3;
p60dockHkTableDataset.outputEnableStateAcuVcc = *(packet + dataOffset);
dataOffset += 3;
p60dockHkTableDataset.outputEnableStatePdu1Vcc = *(packet + dataOffset);
dataOffset += 3;
p60dockHkTableDataset.outputEnableStateX3IdleVcc = *(packet + dataOffset);
dataOffset += 3;
p60dockHkTableDataset.outputEnableStatePdu2Vcc = *(packet + dataOffset);
dataOffset += 3;
p60dockHkTableDataset.outputEnableStateAcuVbat = *(packet + dataOffset);
dataOffset += 3;
p60dockHkTableDataset.outputEnableStatePdu1Vbat = *(packet + dataOffset);
dataOffset += 3;
p60dockHkTableDataset.outputEnableStateX3IdleVbat = *(packet + dataOffset);
dataOffset += 3;
p60dockHkTableDataset.outputEnableStatePdu2Vbat = *(packet + dataOffset);
dataOffset += 3;
p60dockHkTableDataset.outputEnableStateStackVbat = *(packet + dataOffset);
dataOffset += 3;
p60dockHkTableDataset.outputEnableStateStack3V3 = *(packet + dataOffset);
dataOffset += 3;
p60dockHkTableDataset.outputEnableStateStack5V = *(packet + dataOffset);
dataOffset += 3;
p60dockHkTableDataset.outputEnableStateGS3V3 = *(packet + dataOffset);
dataOffset += 3;
p60dockHkTableDataset.outputEnableStateGS5V = *(packet + dataOffset);
dataOffset += 3;
p60dockHkTableDataset.temperature1 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
p60dockHkTableDataset.temperature2 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
p60dockHkTableDataset.temperature1 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
p60dockHkTableDataset.temperature2 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
p60dockHkTableDataset.bootcause = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3);
dataOffset += 6;
p60dockHkTableDataset.bootCount = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3);
dataOffset += 6;
p60dockHkTableDataset.uptime = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3);
dataOffset += 6;
p60dockHkTableDataset.resetcause = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
p60dockHkTableDataset.battMode = *(packet + dataOffset);
dataOffset += 3;
p60dockHkTableDataset.heaterOn = *(packet + dataOffset);
/* + 13 because here begins a new gomspace csp data field */
dataOffset += 13;
p60dockHkTableDataset.converter5VStatus = *(packet + dataOffset);
dataOffset += 3;
p60dockHkTableDataset.bootcause = *(packet + dataOffset) << 24 |
*(packet + dataOffset + 1) << 16 |
*(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3);
dataOffset += 6;
p60dockHkTableDataset.bootCount = *(packet + dataOffset) << 24 |
*(packet + dataOffset + 1) << 16 |
*(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3);
dataOffset += 6;
p60dockHkTableDataset.uptime = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 |
*(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3);
dataOffset += 6;
p60dockHkTableDataset.resetcause = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
p60dockHkTableDataset.battMode = *(packet + dataOffset);
dataOffset += 3;
p60dockHkTableDataset.heaterOn = *(packet + dataOffset);
/* + 13 because here begins a new gomspace csp data field */
dataOffset += 13;
p60dockHkTableDataset.converter5VStatus = *(packet + dataOffset);
dataOffset += 3;
p60dockHkTableDataset.latchupsAcuVcc = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
p60dockHkTableDataset.latchupsAcuVcc = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
p60dockHkTableDataset.latchupsPdu1Vcc = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
p60dockHkTableDataset.latchupsX3IdleVcc = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
p60dockHkTableDataset.latchupsPdu2Vcc = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
p60dockHkTableDataset.latchupsAcuVbat = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
p60dockHkTableDataset.latchupsPdu1Vbat = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
p60dockHkTableDataset.latchupsX3IdleVbat = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
p60dockHkTableDataset.latchupsPdu2Vbat = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
p60dockHkTableDataset.latchupsStackVbat = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
p60dockHkTableDataset.latchupsStack3V3 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
p60dockHkTableDataset.latchupsStack5V = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
p60dockHkTableDataset.latchupsGS3V3 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
p60dockHkTableDataset.latchupsAcuVcc = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
p60dockHkTableDataset.latchupsAcuVcc = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
p60dockHkTableDataset.latchupsPdu1Vcc = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
p60dockHkTableDataset.latchupsX3IdleVcc =
*(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
p60dockHkTableDataset.latchupsPdu2Vcc = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
p60dockHkTableDataset.latchupsAcuVbat = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
p60dockHkTableDataset.latchupsPdu1Vbat = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
p60dockHkTableDataset.latchupsX3IdleVbat =
*(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
p60dockHkTableDataset.latchupsPdu2Vbat = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
p60dockHkTableDataset.latchupsStackVbat =
*(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
p60dockHkTableDataset.latchupsStack3V3 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
p60dockHkTableDataset.latchupsStack5V = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
p60dockHkTableDataset.latchupsGS3V3 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
p60dockHkTableDataset.vbatVoltageValue = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
p60dockHkTableDataset.vccCurrent = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
p60dockHkTableDataset.batteryCurrent = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
p60dockHkTableDataset.batteryVoltage = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
p60dockHkTableDataset.vbatVoltageValue = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
p60dockHkTableDataset.vccCurrent = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
p60dockHkTableDataset.batteryCurrent = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
p60dockHkTableDataset.batteryVoltage = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
p60dockHkTableDataset.batteryTemperature1 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
p60dockHkTableDataset.batteryTemperature2 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
p60dockHkTableDataset.batteryTemperature1 =
*(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
p60dockHkTableDataset.batteryTemperature2 =
*(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
p60dockHkTableDataset.device0 = *(packet + dataOffset);
dataOffset += 3;
p60dockHkTableDataset.device1 = *(packet + dataOffset);
dataOffset += 3;
p60dockHkTableDataset.device2 = *(packet + dataOffset);
dataOffset += 3;
p60dockHkTableDataset.device3 = *(packet + dataOffset);
dataOffset += 3;
p60dockHkTableDataset.device4 = *(packet + dataOffset);
dataOffset += 3;
p60dockHkTableDataset.device5 = *(packet + dataOffset);
dataOffset += 3;
p60dockHkTableDataset.device6 = *(packet + dataOffset);
dataOffset += 3;
p60dockHkTableDataset.device7 = *(packet + dataOffset);
dataOffset += 3;
p60dockHkTableDataset.device0 = *(packet + dataOffset);
dataOffset += 3;
p60dockHkTableDataset.device1 = *(packet + dataOffset);
dataOffset += 3;
p60dockHkTableDataset.device2 = *(packet + dataOffset);
dataOffset += 3;
p60dockHkTableDataset.device3 = *(packet + dataOffset);
dataOffset += 3;
p60dockHkTableDataset.device4 = *(packet + dataOffset);
dataOffset += 3;
p60dockHkTableDataset.device5 = *(packet + dataOffset);
dataOffset += 3;
p60dockHkTableDataset.device6 = *(packet + dataOffset);
dataOffset += 3;
p60dockHkTableDataset.device7 = *(packet + dataOffset);
dataOffset += 3;
p60dockHkTableDataset.device0Status = *(packet + dataOffset);
dataOffset += 3;
p60dockHkTableDataset.device1Status = *(packet + dataOffset);
dataOffset += 3;
p60dockHkTableDataset.device2Status = *(packet + dataOffset);
dataOffset += 3;
p60dockHkTableDataset.device3Status = *(packet + dataOffset);
dataOffset += 3;
p60dockHkTableDataset.device4Status = *(packet + dataOffset);
dataOffset += 3;
p60dockHkTableDataset.device5Status = *(packet + dataOffset);
dataOffset += 3;
p60dockHkTableDataset.device6Status = *(packet + dataOffset);
dataOffset += 3;
p60dockHkTableDataset.device7Status = *(packet + dataOffset);
dataOffset += 3;
p60dockHkTableDataset.device0Status = *(packet + dataOffset);
dataOffset += 3;
p60dockHkTableDataset.device1Status = *(packet + dataOffset);
dataOffset += 3;
p60dockHkTableDataset.device2Status = *(packet + dataOffset);
dataOffset += 3;
p60dockHkTableDataset.device3Status = *(packet + dataOffset);
dataOffset += 3;
p60dockHkTableDataset.device4Status = *(packet + dataOffset);
dataOffset += 3;
p60dockHkTableDataset.device5Status = *(packet + dataOffset);
dataOffset += 3;
p60dockHkTableDataset.device6Status = *(packet + dataOffset);
dataOffset += 3;
p60dockHkTableDataset.device7Status = *(packet + dataOffset);
dataOffset += 3;
p60dockHkTableDataset.dearmStatus = *(packet + dataOffset);
dataOffset += 3;
p60dockHkTableDataset.dearmStatus = *(packet + dataOffset);
dataOffset += 3;
p60dockHkTableDataset.wdtCntGnd = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3);
dataOffset += 6;
p60dockHkTableDataset.wdtCntI2c = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3);
dataOffset += 6;
p60dockHkTableDataset.wdtCntCan = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3);
dataOffset += 6;
p60dockHkTableDataset.wdtCntCsp1 = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3);
dataOffset += 6;
p60dockHkTableDataset.wdtCntCsp2 = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3);
dataOffset += 6;
p60dockHkTableDataset.wdtCntGnd = *(packet + dataOffset) << 24 |
*(packet + dataOffset + 1) << 16 |
*(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3);
dataOffset += 6;
p60dockHkTableDataset.wdtCntI2c = *(packet + dataOffset) << 24 |
*(packet + dataOffset + 1) << 16 |
*(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3);
dataOffset += 6;
p60dockHkTableDataset.wdtCntCan = *(packet + dataOffset) << 24 |
*(packet + dataOffset + 1) << 16 |
*(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3);
dataOffset += 6;
p60dockHkTableDataset.wdtCntCsp1 = *(packet + dataOffset) << 24 |
*(packet + dataOffset + 1) << 16 |
*(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3);
dataOffset += 6;
p60dockHkTableDataset.wdtCntCsp2 = *(packet + dataOffset) << 24 |
*(packet + dataOffset + 1) << 16 |
*(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3);
dataOffset += 6;
p60dockHkTableDataset.wdtGndLeft = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3);
dataOffset += 6;
p60dockHkTableDataset.wdtI2cLeft = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3);
dataOffset += 6;
p60dockHkTableDataset.wdtCanLeft = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3);
/* +16 because here begins a new gomspace csp packet */
dataOffset += 16;
p60dockHkTableDataset.wdtGndLeft = *(packet + dataOffset) << 24 |
*(packet + dataOffset + 1) << 16 |
*(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3);
dataOffset += 6;
p60dockHkTableDataset.wdtI2cLeft = *(packet + dataOffset) << 24 |
*(packet + dataOffset + 1) << 16 |
*(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3);
dataOffset += 6;
p60dockHkTableDataset.wdtCanLeft = *(packet + dataOffset) << 24 |
*(packet + dataOffset + 1) << 16 |
*(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3);
/* +16 because here begins a new gomspace csp packet */
dataOffset += 16;
p60dockHkTableDataset.wdtCspLeft1 = *(packet + dataOffset);
dataOffset += 3;
p60dockHkTableDataset.wdtCspLeft2 = *(packet + dataOffset);
dataOffset += 3;
p60dockHkTableDataset.wdtCspLeft1 = *(packet + dataOffset);
dataOffset += 3;
p60dockHkTableDataset.wdtCspLeft2 = *(packet + dataOffset);
dataOffset += 3;
p60dockHkTableDataset.batteryChargeCurrent = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
p60dockHkTableDataset.batteryDischargeCurrent = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
p60dockHkTableDataset.ant6Depl = *(packet + dataOffset);
dataOffset += 3;
p60dockHkTableDataset.ar6Depl = *(packet + dataOffset);
p60dockHkTableDataset.batteryChargeCurrent =
*(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
p60dockHkTableDataset.batteryDischargeCurrent =
*(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
p60dockHkTableDataset.ant6Depl = *(packet + dataOffset);
dataOffset += 3;
p60dockHkTableDataset.ar6Depl = *(packet + dataOffset);
p60dockHkTableDataset.commit();
p60dockHkTableDataset.commit();
}
ReturnValue_t P60DockHandler::initializeLocalDataPool(
localpool::DataPool &localDataPoolMap, LocalDataPoolManager &poolManager) {
ReturnValue_t P60DockHandler::initializeLocalDataPool(localpool::DataPool &localDataPoolMap,
LocalDataPoolManager &poolManager) {
localDataPoolMap.emplace(P60System::P60DOCK_CURRENT_ACU_VCC, new PoolEntry<int16_t>({0}));
localDataPoolMap.emplace(P60System::P60DOCK_CURRENT_PDU1_VCC, new PoolEntry<int16_t>({0}));
localDataPoolMap.emplace(P60System::P60DOCK_CURRENT_X3_IDLE_VCC, new PoolEntry<int16_t>({0}));
localDataPoolMap.emplace(P60System::P60DOCK_CURRENT_PDU2_VCC, new PoolEntry<int16_t>({0}));
localDataPoolMap.emplace(P60System::P60DOCK_CURRENT_ACU_VBAT, new PoolEntry<int16_t>({0}));
localDataPoolMap.emplace(P60System::P60DOCK_CURRENT_PDU1_VBAT, new PoolEntry<int16_t>({0}));
localDataPoolMap.emplace(P60System::P60DOCK_CURRENT_X3_IDLE_VBAT, new PoolEntry<int16_t>({0}));
localDataPoolMap.emplace(P60System::P60DOCK_CURRENT_PDU2_VBAT, new PoolEntry<int16_t>({0}));
localDataPoolMap.emplace(P60System::P60DOCK_CURRENT_STACK_VBAT, new PoolEntry<int16_t>({0}));
localDataPoolMap.emplace(P60System::P60DOCK_CURRENT_STACK_3V3, new PoolEntry<int16_t>({0}));
localDataPoolMap.emplace(P60System::P60DOCK_CURRENT_STACK_5V, new PoolEntry<int16_t>({0}));
localDataPoolMap.emplace(P60System::P60DOCK_CURRENT_GS3V3, new PoolEntry<int16_t>({0}));
localDataPoolMap.emplace(P60System::P60DOCK_CURRENT_GS5V, new PoolEntry<int16_t>({0}));
localDataPoolMap.emplace(P60System::P60DOCK_CURRENT_ACU_VCC, new PoolEntry<int16_t>( { 0 }));
localDataPoolMap.emplace(P60System::P60DOCK_CURRENT_PDU1_VCC, new PoolEntry<int16_t>( { 0 }));
localDataPoolMap.emplace(P60System::P60DOCK_CURRENT_X3_IDLE_VCC, new PoolEntry<int16_t>( { 0 }));
localDataPoolMap.emplace(P60System::P60DOCK_CURRENT_PDU2_VCC, new PoolEntry<int16_t>( { 0 }));
localDataPoolMap.emplace(P60System::P60DOCK_CURRENT_ACU_VBAT, new PoolEntry<int16_t>( { 0 }));
localDataPoolMap.emplace(P60System::P60DOCK_CURRENT_PDU1_VBAT, new PoolEntry<int16_t>( { 0 }));
localDataPoolMap.emplace(P60System::P60DOCK_CURRENT_X3_IDLE_VBAT, new PoolEntry<int16_t>( { 0 }));
localDataPoolMap.emplace(P60System::P60DOCK_CURRENT_PDU2_VBAT, new PoolEntry<int16_t>( { 0 }));
localDataPoolMap.emplace(P60System::P60DOCK_CURRENT_STACK_VBAT, new PoolEntry<int16_t>( { 0 }));
localDataPoolMap.emplace(P60System::P60DOCK_CURRENT_STACK_3V3, new PoolEntry<int16_t>( { 0 }));
localDataPoolMap.emplace(P60System::P60DOCK_CURRENT_STACK_5V, new PoolEntry<int16_t>( { 0 }));
localDataPoolMap.emplace(P60System::P60DOCK_CURRENT_GS3V3, new PoolEntry<int16_t>( { 0 }));
localDataPoolMap.emplace(P60System::P60DOCK_CURRENT_GS5V, new PoolEntry<int16_t>( { 0 }));
localDataPoolMap.emplace(P60System::P60DOCK_VOLTAGE_ACU_VCC, new PoolEntry<uint16_t>({0}));
localDataPoolMap.emplace(P60System::P60DOCK_VOLTAGE_PDU1_VCC, new PoolEntry<uint16_t>({0}));
localDataPoolMap.emplace(P60System::P60DOCK_VOLTAGE_X3_IDLE_VCC, new PoolEntry<uint16_t>({0}));
localDataPoolMap.emplace(P60System::P60DOCK_VOLTAGE_PDU2_VCC, new PoolEntry<uint16_t>({0}));
localDataPoolMap.emplace(P60System::P60DOCK_VOLTAGE_ACU_VBAT, new PoolEntry<uint16_t>({0}));
localDataPoolMap.emplace(P60System::P60DOCK_VOLTAGE_PDU1_VBAT, new PoolEntry<uint16_t>({0}));
localDataPoolMap.emplace(P60System::P60DOCK_VOLTAGE_X3_IDLE_VBAT, new PoolEntry<uint16_t>({0}));
localDataPoolMap.emplace(P60System::P60DOCK_VOLTAGE_PDU2_VBAT, new PoolEntry<uint16_t>({0}));
localDataPoolMap.emplace(P60System::P60DOCK_VOLTAGE_STACK_VBAT, new PoolEntry<uint16_t>({0}));
localDataPoolMap.emplace(P60System::P60DOCK_VOLTAGE_STACK_3V3, new PoolEntry<uint16_t>({0}));
localDataPoolMap.emplace(P60System::P60DOCK_VOLTAGE_STACK_5V, new PoolEntry<uint16_t>({0}));
localDataPoolMap.emplace(P60System::P60DOCK_VOLTAGE_GS3V3, new PoolEntry<uint16_t>({0}));
localDataPoolMap.emplace(P60System::P60DOCK_VOLTAGE_GS5V, new PoolEntry<uint16_t>({0}));
localDataPoolMap.emplace(P60System::P60DOCK_VOLTAGE_ACU_VCC, new PoolEntry<uint16_t>( { 0 }));
localDataPoolMap.emplace(P60System::P60DOCK_VOLTAGE_PDU1_VCC, new PoolEntry<uint16_t>( { 0 }));
localDataPoolMap.emplace(P60System::P60DOCK_VOLTAGE_X3_IDLE_VCC, new PoolEntry<uint16_t>( { 0 }));
localDataPoolMap.emplace(P60System::P60DOCK_VOLTAGE_PDU2_VCC, new PoolEntry<uint16_t>( { 0 }));
localDataPoolMap.emplace(P60System::P60DOCK_VOLTAGE_ACU_VBAT, new PoolEntry<uint16_t>( { 0 }));
localDataPoolMap.emplace(P60System::P60DOCK_VOLTAGE_PDU1_VBAT, new PoolEntry<uint16_t>( { 0 }));
localDataPoolMap.emplace(P60System::P60DOCK_VOLTAGE_X3_IDLE_VBAT, new PoolEntry<uint16_t>( { 0 }));
localDataPoolMap.emplace(P60System::P60DOCK_VOLTAGE_PDU2_VBAT, new PoolEntry<uint16_t>( { 0 }));
localDataPoolMap.emplace(P60System::P60DOCK_VOLTAGE_STACK_VBAT, new PoolEntry<uint16_t>( { 0 }));
localDataPoolMap.emplace(P60System::P60DOCK_VOLTAGE_STACK_3V3, new PoolEntry<uint16_t>( { 0 }));
localDataPoolMap.emplace(P60System::P60DOCK_VOLTAGE_STACK_5V, new PoolEntry<uint16_t>( { 0 }));
localDataPoolMap.emplace(P60System::P60DOCK_VOLTAGE_GS3V3, new PoolEntry<uint16_t>( { 0 }));
localDataPoolMap.emplace(P60System::P60DOCK_VOLTAGE_GS5V, new PoolEntry<uint16_t>( { 0 }));
localDataPoolMap.emplace(P60System::P60DOCK_OUTPUTENABLE_ACU_VCC, new PoolEntry<uint8_t>({0}));
localDataPoolMap.emplace(P60System::P60DOCK_OUTPUTENABLE_PDU1_VCC, new PoolEntry<uint8_t>({0}));
localDataPoolMap.emplace(P60System::P60DOCK_OUTPUTENABLE_X3_IDLE_VCC,
new PoolEntry<uint8_t>({0}));
localDataPoolMap.emplace(P60System::P60DOCK_OUTPUTENABLE_PDU2_VCC, new PoolEntry<uint8_t>({0}));
localDataPoolMap.emplace(P60System::P60DOCK_OUTPUTENABLE_ACU_VBAT, new PoolEntry<uint8_t>({0}));
localDataPoolMap.emplace(P60System::P60DOCK_OUTPUTENABLE_PDU1_VBAT, new PoolEntry<uint8_t>({0}));
localDataPoolMap.emplace(P60System::P60DOCK_OUTPUTENABLE_X3_IDLE_VBAT,
new PoolEntry<uint8_t>({0}));
localDataPoolMap.emplace(P60System::P60DOCK_OUTPUTENABLE_PDU2_VBAT, new PoolEntry<uint8_t>({0}));
localDataPoolMap.emplace(P60System::P60DOCK_OUTPUTENABLE_STACK_VBAT, new PoolEntry<uint8_t>({0}));
localDataPoolMap.emplace(P60System::P60DOCK_OUTPUTENABLE_STACK_3V3, new PoolEntry<uint8_t>({0}));
localDataPoolMap.emplace(P60System::P60DOCK_OUTPUTENABLE_STACK_5V, new PoolEntry<uint8_t>({0}));
localDataPoolMap.emplace(P60System::P60DOCK_OUTPUTENABLE_GS3V3, new PoolEntry<uint8_t>({0}));
localDataPoolMap.emplace(P60System::P60DOCK_OUTPUTENABLE_GS5V, new PoolEntry<uint8_t>({0}));
localDataPoolMap.emplace(P60System::P60DOCK_OUTPUTENABLE_ACU_VCC, new PoolEntry<uint8_t>( { 0 }));
localDataPoolMap.emplace(P60System::P60DOCK_OUTPUTENABLE_PDU1_VCC, new PoolEntry<uint8_t>( { 0 }));
localDataPoolMap.emplace(P60System::P60DOCK_OUTPUTENABLE_X3_IDLE_VCC, new PoolEntry<uint8_t>( { 0 }));
localDataPoolMap.emplace(P60System::P60DOCK_OUTPUTENABLE_PDU2_VCC, new PoolEntry<uint8_t>( { 0 }));
localDataPoolMap.emplace(P60System::P60DOCK_OUTPUTENABLE_ACU_VBAT, new PoolEntry<uint8_t>( { 0 }));
localDataPoolMap.emplace(P60System::P60DOCK_OUTPUTENABLE_PDU1_VBAT, new PoolEntry<uint8_t>( { 0 }));
localDataPoolMap.emplace(P60System::P60DOCK_OUTPUTENABLE_X3_IDLE_VBAT, new PoolEntry<uint8_t>( { 0 }));
localDataPoolMap.emplace(P60System::P60DOCK_OUTPUTENABLE_PDU2_VBAT, new PoolEntry<uint8_t>( { 0 }));
localDataPoolMap.emplace(P60System::P60DOCK_OUTPUTENABLE_STACK_VBAT, new PoolEntry<uint8_t>( { 0 }));
localDataPoolMap.emplace(P60System::P60DOCK_OUTPUTENABLE_STACK_3V3, new PoolEntry<uint8_t>( { 0 }));
localDataPoolMap.emplace(P60System::P60DOCK_OUTPUTENABLE_STACK_5V, new PoolEntry<uint8_t>( { 0 }));
localDataPoolMap.emplace(P60System::P60DOCK_OUTPUTENABLE_GS3V3, new PoolEntry<uint8_t>( { 0 }));
localDataPoolMap.emplace(P60System::P60DOCK_OUTPUTENABLE_GS5V, new PoolEntry<uint8_t>( { 0 }));
localDataPoolMap.emplace(P60System::P60DOCK_TEMPERATURE_1, new PoolEntry<int16_t>({0}));
localDataPoolMap.emplace(P60System::P60DOCK_TEMPERATURE_2, new PoolEntry<int16_t>({0}));
localDataPoolMap.emplace(P60System::P60DOCK_TEMPERATURE_1, new PoolEntry<int16_t>( { 0 }));
localDataPoolMap.emplace(P60System::P60DOCK_TEMPERATURE_2, new PoolEntry<int16_t>( { 0 }));
localDataPoolMap.emplace(P60System::P60DOCK_BOOT_CAUSE, new PoolEntry<uint32_t>({0}));
localDataPoolMap.emplace(P60System::P60DOCK_BOOT_CNT, new PoolEntry<uint32_t>({0}));
localDataPoolMap.emplace(P60System::P60DOCK_UPTIME, new PoolEntry<uint32_t>({0}));
localDataPoolMap.emplace(P60System::P60DOCK_RESETCAUSE, new PoolEntry<uint16_t>({0}));
localDataPoolMap.emplace(P60System::P60DOCK_BATT_MODE, new PoolEntry<uint8_t>({0}));
localDataPoolMap.emplace(P60System::P60DOCK_HEATER_ON, new PoolEntry<uint8_t>({0}));
localDataPoolMap.emplace(P60System::P60DOCK_CONV_5V_ENABLE_STATUS, new PoolEntry<uint8_t>({0}));
localDataPoolMap.emplace(P60System::P60DOCK_BOOT_CAUSE, new PoolEntry<uint32_t>( { 0 }));
localDataPoolMap.emplace(P60System::P60DOCK_BOOT_CNT, new PoolEntry<uint32_t>( { 0 }));
localDataPoolMap.emplace(P60System::P60DOCK_UPTIME, new PoolEntry<uint32_t>( { 0 }));
localDataPoolMap.emplace(P60System::P60DOCK_RESETCAUSE, new PoolEntry<uint16_t>( { 0 }));
localDataPoolMap.emplace(P60System::P60DOCK_BATT_MODE, new PoolEntry<uint8_t>( { 0 }));
localDataPoolMap.emplace(P60System::P60DOCK_HEATER_ON, new PoolEntry<uint8_t>( { 0 }));
localDataPoolMap.emplace(P60System::P60DOCK_CONV_5V_ENABLE_STATUS, new PoolEntry<uint8_t>( { 0 }));
localDataPoolMap.emplace(P60System::P60DOCK_LATCHUP_ACU_VCC, new PoolEntry<uint16_t>({0}));
localDataPoolMap.emplace(P60System::P60DOCK_LATCHUP_PDU1_VCC, new PoolEntry<uint16_t>({0}));
localDataPoolMap.emplace(P60System::P60DOCK_LATCHUP_X3_IDLE_VCC, new PoolEntry<uint16_t>({0}));
localDataPoolMap.emplace(P60System::P60DOCK_LATCHUP_PDU2_VCC, new PoolEntry<uint16_t>({0}));
localDataPoolMap.emplace(P60System::P60DOCK_LATCHUP_ACU_VBAT, new PoolEntry<uint16_t>({0}));
localDataPoolMap.emplace(P60System::P60DOCK_LATCHUP_PDU1_VBAT, new PoolEntry<uint16_t>({0}));
localDataPoolMap.emplace(P60System::P60DOCK_LATCHUP_X3_IDLE_VBAT, new PoolEntry<uint16_t>({0}));
localDataPoolMap.emplace(P60System::P60DOCK_LATCHUP_PDU2_VBAT, new PoolEntry<uint16_t>({0}));
localDataPoolMap.emplace(P60System::P60DOCK_LATCHUP_STACK_VBAT, new PoolEntry<uint16_t>({0}));
localDataPoolMap.emplace(P60System::P60DOCK_LATCHUP_STACK_3V3, new PoolEntry<uint16_t>({0}));
localDataPoolMap.emplace(P60System::P60DOCK_LATCHUP_STACK_5V, new PoolEntry<uint16_t>({0}));
localDataPoolMap.emplace(P60System::P60DOCK_LATCHUP_GS3V3, new PoolEntry<uint16_t>({0}));
localDataPoolMap.emplace(P60System::P60DOCK_LATCHUP_GS5V, new PoolEntry<uint16_t>({0}));
localDataPoolMap.emplace(P60System::P60DOCK_LATCHUP_ACU_VCC, new PoolEntry<uint16_t>( { 0 }));
localDataPoolMap.emplace(P60System::P60DOCK_LATCHUP_PDU1_VCC, new PoolEntry<uint16_t>( { 0 }));
localDataPoolMap.emplace(P60System::P60DOCK_LATCHUP_X3_IDLE_VCC, new PoolEntry<uint16_t>( { 0 }));
localDataPoolMap.emplace(P60System::P60DOCK_LATCHUP_PDU2_VCC, new PoolEntry<uint16_t>( { 0 }));
localDataPoolMap.emplace(P60System::P60DOCK_LATCHUP_ACU_VBAT, new PoolEntry<uint16_t>( { 0 }));
localDataPoolMap.emplace(P60System::P60DOCK_LATCHUP_PDU1_VBAT, new PoolEntry<uint16_t>( { 0 }));
localDataPoolMap.emplace(P60System::P60DOCK_LATCHUP_X3_IDLE_VBAT, new PoolEntry<uint16_t>( { 0 }));
localDataPoolMap.emplace(P60System::P60DOCK_LATCHUP_PDU2_VBAT, new PoolEntry<uint16_t>( { 0 }));
localDataPoolMap.emplace(P60System::P60DOCK_LATCHUP_STACK_VBAT, new PoolEntry<uint16_t>( { 0 }));
localDataPoolMap.emplace(P60System::P60DOCK_LATCHUP_STACK_3V3, new PoolEntry<uint16_t>( { 0 }));
localDataPoolMap.emplace(P60System::P60DOCK_LATCHUP_STACK_5V, new PoolEntry<uint16_t>( { 0 }));
localDataPoolMap.emplace(P60System::P60DOCK_LATCHUP_GS3V3, new PoolEntry<uint16_t>( { 0 }));
localDataPoolMap.emplace(P60System::P60DOCK_LATCHUP_GS5V, new PoolEntry<uint16_t>( { 0 }));
localDataPoolMap.emplace(P60System::P60DOCK_VBAT_VALUE, new PoolEntry<uint16_t>({0}));
localDataPoolMap.emplace(P60System::P60DOCK_VCC_CURRENT_VALUE, new PoolEntry<int16_t>({0}));
localDataPoolMap.emplace(P60System::P60DOCK_BATTERY_CURRENT, new PoolEntry<int16_t>({0}));
localDataPoolMap.emplace(P60System::P60DOCK_BATTERY_VOLTAGE, new PoolEntry<uint16_t>({0}));
localDataPoolMap.emplace(P60System::P60DOCK_VBAT_VALUE, new PoolEntry<uint16_t>( { 0 }));
localDataPoolMap.emplace(P60System::P60DOCK_VCC_CURRENT_VALUE, new PoolEntry<int16_t>( { 0 }));
localDataPoolMap.emplace(P60System::P60DOCK_BATTERY_CURRENT, new PoolEntry<int16_t>( { 0 }));
localDataPoolMap.emplace(P60System::P60DOCK_BATTERY_VOLTAGE, new PoolEntry<uint16_t>( { 0 }));
localDataPoolMap.emplace(P60System::P60DOCK_BATTERY_TEMPERATURE_1, new PoolEntry<int16_t>({0}));
localDataPoolMap.emplace(P60System::P60DOCK_BATTERY_TEMPERATURE_2, new PoolEntry<int16_t>({0}));
localDataPoolMap.emplace(P60System::P60DOCK_BATTERY_TEMPERATURE_1, new PoolEntry<int16_t>( { 0 }));
localDataPoolMap.emplace(P60System::P60DOCK_BATTERY_TEMPERATURE_2, new PoolEntry<int16_t>( { 0 }));
localDataPoolMap.emplace(P60System::P60DOCK_DEVICE_0, new PoolEntry<uint8_t>({0}));
localDataPoolMap.emplace(P60System::P60DOCK_DEVICE_1, new PoolEntry<uint8_t>({0}));
localDataPoolMap.emplace(P60System::P60DOCK_DEVICE_2, new PoolEntry<uint8_t>({0}));
localDataPoolMap.emplace(P60System::P60DOCK_DEVICE_3, new PoolEntry<uint8_t>({0}));
localDataPoolMap.emplace(P60System::P60DOCK_DEVICE_4, new PoolEntry<uint8_t>({0}));
localDataPoolMap.emplace(P60System::P60DOCK_DEVICE_5, new PoolEntry<uint8_t>({0}));
localDataPoolMap.emplace(P60System::P60DOCK_DEVICE_6, new PoolEntry<uint8_t>({0}));
localDataPoolMap.emplace(P60System::P60DOCK_DEVICE_7, new PoolEntry<uint8_t>({0}));
localDataPoolMap.emplace(P60System::P60DOCK_DEVICE_0, new PoolEntry<uint8_t>( { 0 }));
localDataPoolMap.emplace(P60System::P60DOCK_DEVICE_1, new PoolEntry<uint8_t>( { 0 }));
localDataPoolMap.emplace(P60System::P60DOCK_DEVICE_2, new PoolEntry<uint8_t>( { 0 }));
localDataPoolMap.emplace(P60System::P60DOCK_DEVICE_3, new PoolEntry<uint8_t>( { 0 }));
localDataPoolMap.emplace(P60System::P60DOCK_DEVICE_4, new PoolEntry<uint8_t>( { 0 }));
localDataPoolMap.emplace(P60System::P60DOCK_DEVICE_5, new PoolEntry<uint8_t>( { 0 }));
localDataPoolMap.emplace(P60System::P60DOCK_DEVICE_6, new PoolEntry<uint8_t>( { 0 }));
localDataPoolMap.emplace(P60System::P60DOCK_DEVICE_7, new PoolEntry<uint8_t>( { 0 }));
localDataPoolMap.emplace(P60System::P60DOCK_DEVICE_0_STATUS, new PoolEntry<uint8_t>({0}));
localDataPoolMap.emplace(P60System::P60DOCK_DEVICE_1_STATUS, new PoolEntry<uint8_t>({0}));
localDataPoolMap.emplace(P60System::P60DOCK_DEVICE_2_STATUS, new PoolEntry<uint8_t>({0}));
localDataPoolMap.emplace(P60System::P60DOCK_DEVICE_3_STATUS, new PoolEntry<uint8_t>({0}));
localDataPoolMap.emplace(P60System::P60DOCK_DEVICE_4_STATUS, new PoolEntry<uint8_t>({0}));
localDataPoolMap.emplace(P60System::P60DOCK_DEVICE_5_STATUS, new PoolEntry<uint8_t>({0}));
localDataPoolMap.emplace(P60System::P60DOCK_DEVICE_6_STATUS, new PoolEntry<uint8_t>({0}));
localDataPoolMap.emplace(P60System::P60DOCK_DEVICE_7_STATUS, new PoolEntry<uint8_t>({0}));
localDataPoolMap.emplace(P60System::P60DOCK_DEVICE_0_STATUS, new PoolEntry<uint8_t>( { 0 }));
localDataPoolMap.emplace(P60System::P60DOCK_DEVICE_1_STATUS, new PoolEntry<uint8_t>( { 0 }));
localDataPoolMap.emplace(P60System::P60DOCK_DEVICE_2_STATUS, new PoolEntry<uint8_t>( { 0 }));
localDataPoolMap.emplace(P60System::P60DOCK_DEVICE_3_STATUS, new PoolEntry<uint8_t>( { 0 }));
localDataPoolMap.emplace(P60System::P60DOCK_DEVICE_4_STATUS, new PoolEntry<uint8_t>( { 0 }));
localDataPoolMap.emplace(P60System::P60DOCK_DEVICE_5_STATUS, new PoolEntry<uint8_t>( { 0 }));
localDataPoolMap.emplace(P60System::P60DOCK_DEVICE_6_STATUS, new PoolEntry<uint8_t>( { 0 }));
localDataPoolMap.emplace(P60System::P60DOCK_DEVICE_7_STATUS, new PoolEntry<uint8_t>( { 0 }));
localDataPoolMap.emplace(P60System::P60DOCK_DEARM_STATUS, new PoolEntry<uint8_t>({0}));
localDataPoolMap.emplace(P60System::P60DOCK_DEARM_STATUS, new PoolEntry<uint8_t>( { 0 }));
localDataPoolMap.emplace(P60System::P60DOCK_WDT_CNT_GND, new PoolEntry<uint32_t>({0}));
localDataPoolMap.emplace(P60System::P60DOCK_WDT_CNT_I2C, new PoolEntry<uint32_t>({0}));
localDataPoolMap.emplace(P60System::P60DOCK_WDT_CNT_CAN, new PoolEntry<uint32_t>({0}));
localDataPoolMap.emplace(P60System::P60DOCK_WDT_CNT_CSP_1, new PoolEntry<uint32_t>({0}));
localDataPoolMap.emplace(P60System::P60DOCK_WDT_CNT_CSP_2, new PoolEntry<uint32_t>({0}));
localDataPoolMap.emplace(P60System::P60DOCK_WDT_CNT_GND, new PoolEntry<uint32_t>( { 0 }));
localDataPoolMap.emplace(P60System::P60DOCK_WDT_CNT_I2C, new PoolEntry<uint32_t>( { 0 }));
localDataPoolMap.emplace(P60System::P60DOCK_WDT_CNT_CAN, new PoolEntry<uint32_t>( { 0 }));
localDataPoolMap.emplace(P60System::P60DOCK_WDT_CNT_CSP_1, new PoolEntry<uint32_t>( { 0 }));
localDataPoolMap.emplace(P60System::P60DOCK_WDT_CNT_CSP_2, new PoolEntry<uint32_t>( { 0 }));
localDataPoolMap.emplace(P60System::P60DOCK_WDT_GND_LEFT, new PoolEntry<uint32_t>({0}));
localDataPoolMap.emplace(P60System::P60DOCK_WDT_I2C_LEFT, new PoolEntry<uint32_t>({0}));
localDataPoolMap.emplace(P60System::P60DOCK_WDT_CAN_LEFT, new PoolEntry<uint32_t>({0}));
localDataPoolMap.emplace(P60System::P60DOCK_WDT_CSP_LEFT_1, new PoolEntry<uint8_t>({0}));
localDataPoolMap.emplace(P60System::P60DOCK_WDT_CSP_LEFT_2, new PoolEntry<uint8_t>({0}));
localDataPoolMap.emplace(P60System::P60DOCK_WDT_GND_LEFT, new PoolEntry<uint32_t>( { 0 }));
localDataPoolMap.emplace(P60System::P60DOCK_WDT_I2C_LEFT, new PoolEntry<uint32_t>( { 0 }));
localDataPoolMap.emplace(P60System::P60DOCK_WDT_CAN_LEFT, new PoolEntry<uint32_t>( { 0 }));
localDataPoolMap.emplace(P60System::P60DOCK_WDT_CSP_LEFT_1, new PoolEntry<uint8_t>( { 0 }));
localDataPoolMap.emplace(P60System::P60DOCK_WDT_CSP_LEFT_2, new PoolEntry<uint8_t>( { 0 }));
localDataPoolMap.emplace(P60System::P60DOCK_BATT_CHARGE_CURRENT, new PoolEntry<int16_t>({0}));
localDataPoolMap.emplace(P60System::P60DOCK_BATT_DISCHARGE_CURRENT, new PoolEntry<int16_t>({0}));
localDataPoolMap.emplace(P60System::P60DOCK_BATT_CHARGE_CURRENT, new PoolEntry<int16_t>( { 0 }));
localDataPoolMap.emplace(P60System::P60DOCK_BATT_DISCHARGE_CURRENT, new PoolEntry<int16_t>( { 0 }));
localDataPoolMap.emplace(P60System::P60DOCK_ANT6_DEPL, new PoolEntry<int8_t>({0}));
localDataPoolMap.emplace(P60System::P60DOCK_AR6_DEPL, new PoolEntry<int8_t>({0}));
localDataPoolMap.emplace(P60System::P60DOCK_ANT6_DEPL, new PoolEntry<int8_t>( { 0 }));
localDataPoolMap.emplace(P60System::P60DOCK_AR6_DEPL, new PoolEntry<int8_t>( { 0 }));
return HasReturnvaluesIF::RETURN_OK;
return HasReturnvaluesIF::RETURN_OK;
}
ReturnValue_t P60DockHandler::printStatus(DeviceCommandId_t cmd) {
switch(cmd) {
case(GOMSPACE::PRINT_SWITCH_V_I): {
PoolReadGuard pg(&p60dockHkTableDataset);
ReturnValue_t readResult = pg.getReadResult();
if(readResult != HasReturnvaluesIF::RETURN_OK) {
sif::warning << "Reading PDU1 HK table failed!" << std::endl;
return HasReturnvaluesIF::RETURN_FAILED;
}
printHkTable();
return HasReturnvaluesIF::RETURN_OK;
switch (cmd) {
case (GOMSPACE::PRINT_SWITCH_V_I): {
PoolReadGuard pg(&p60dockHkTableDataset);
ReturnValue_t readResult = pg.getReadResult();
if (readResult != HasReturnvaluesIF::RETURN_OK) {
sif::warning << "Reading PDU1 HK table failed!" << std::endl;
return HasReturnvaluesIF::RETURN_FAILED;
}
printHkTable();
return HasReturnvaluesIF::RETURN_OK;
}
default: {
return HasReturnvaluesIF::RETURN_FAILED;
}
return HasReturnvaluesIF::RETURN_FAILED;
}
}
}
void P60DockHandler::printHkTable() {
sif::info << "P60 Dock Info: SwitchState, Currents [mA], Voltages [mV]" << std::endl;
sif::info << "P60 Dock Info: SwitchState, Currents [mA], Voltages [mV]" << std::endl;
sif::info << std::setw(30) << std::left << "ACU VCC" << std::dec << "| " <<
unsigned(p60dockHkTableDataset.outputEnableStateAcuVcc.value) << ", " <<
std::setw(4) << std::right <<
p60dockHkTableDataset.currentAcuVcc.value << ", " << std::setw(5) <<
p60dockHkTableDataset.voltageAcuVcc.value << std::endl;
sif::info << std::setw(30) << std::left << "ACU VBAT" << std::dec << "| " <<
unsigned(p60dockHkTableDataset.outputEnableStateAcuVbat.value) << ", " <<
std::setw(4) << std::right <<
p60dockHkTableDataset.currentAcuVbat.value << ", " << std::setw(5) <<
p60dockHkTableDataset.voltageAcuVbat.value << std::endl;
sif::info << std::setw(30) << std::left << "ACU VCC" << std::dec << "| "
<< unsigned(p60dockHkTableDataset.outputEnableStateAcuVcc.value) << ", " << std::setw(4)
<< std::right << p60dockHkTableDataset.currentAcuVcc.value << ", " << std::setw(5)
<< p60dockHkTableDataset.voltageAcuVcc.value << std::endl;
sif::info << std::setw(30) << std::left << "ACU VBAT" << std::dec << "| "
<< unsigned(p60dockHkTableDataset.outputEnableStateAcuVbat.value) << ", "
<< std::setw(4) << std::right << p60dockHkTableDataset.currentAcuVbat.value << ", "
<< std::setw(5) << p60dockHkTableDataset.voltageAcuVbat.value << std::endl;
sif::info << std::setw(30) << std::left << "PDU1 VCC" << std::dec << "| " <<
unsigned(p60dockHkTableDataset.outputEnableStatePdu1Vcc.value) << ", " <<
std::setw(4) << std::right <<
p60dockHkTableDataset.currentPdu1Vcc.value << ", " << std::setw(5) <<
p60dockHkTableDataset.voltagePdu1Vcc.value << std::endl;
sif::info << std::setw(30) << std::left << "PDU1 VBAT" << std::dec << "| " <<
unsigned(p60dockHkTableDataset.outputEnableStatePdu1Vbat.value) << ", " <<
std::setw(4) << std::right <<
p60dockHkTableDataset.currentPdu1Vbat.value << ", " << std::setw(5) <<
p60dockHkTableDataset.voltagePdu1Vbat.value << std::endl;
sif::info << std::setw(30) << std::left << "PDU1 VCC" << std::dec << "| "
<< unsigned(p60dockHkTableDataset.outputEnableStatePdu1Vcc.value) << ", "
<< std::setw(4) << std::right << p60dockHkTableDataset.currentPdu1Vcc.value << ", "
<< std::setw(5) << p60dockHkTableDataset.voltagePdu1Vcc.value << std::endl;
sif::info << std::setw(30) << std::left << "PDU1 VBAT" << std::dec << "| "
<< unsigned(p60dockHkTableDataset.outputEnableStatePdu1Vbat.value) << ", "
<< std::setw(4) << std::right << p60dockHkTableDataset.currentPdu1Vbat.value << ", "
<< std::setw(5) << p60dockHkTableDataset.voltagePdu1Vbat.value << std::endl;
sif::info << std::setw(30) << std::left << "PDU2 VCC" << std::dec << "| " <<
unsigned(p60dockHkTableDataset.outputEnableStatePdu2Vcc.value) << ", " <<
std::setw(4) << std::right <<
p60dockHkTableDataset.currentPdu2Vcc.value << ", " << std::setw(5) <<
p60dockHkTableDataset.voltagePdu2Vcc.value << std::endl;
sif::info << std::setw(30) << std::left << "PDU2 VBAT" << std::dec << "| " <<
unsigned(p60dockHkTableDataset.outputEnableStatePdu2Vbat.value) << ", " <<
std::setw(4) << std::right <<
p60dockHkTableDataset.currentPdu2Vbat.value << ", " << std::setw(5) <<
p60dockHkTableDataset.voltagePdu2Vbat.value << std::endl;
sif::info << std::setw(30) << std::left << "PDU2 VCC" << std::dec << "| "
<< unsigned(p60dockHkTableDataset.outputEnableStatePdu2Vcc.value) << ", "
<< std::setw(4) << std::right << p60dockHkTableDataset.currentPdu2Vcc.value << ", "
<< std::setw(5) << p60dockHkTableDataset.voltagePdu2Vcc.value << std::endl;
sif::info << std::setw(30) << std::left << "PDU2 VBAT" << std::dec << "| "
<< unsigned(p60dockHkTableDataset.outputEnableStatePdu2Vbat.value) << ", "
<< std::setw(4) << std::right << p60dockHkTableDataset.currentPdu2Vbat.value << ", "
<< std::setw(5) << p60dockHkTableDataset.voltagePdu2Vbat.value << std::endl;
sif::info << std::setw(30) << std::left << "Stack VBAT" << std::dec << "| " <<
unsigned(p60dockHkTableDataset.outputEnableStateStackVbat.value) << ", " <<
std::setw(4) << std::right <<
p60dockHkTableDataset.currentStackVbat.value << ", " << std::setw(5) <<
p60dockHkTableDataset.voltageStackVbat.value << std::endl;
sif::info << std::setw(30) << std::left << "Stack 3V3" << std::dec << "| " <<
unsigned(p60dockHkTableDataset.outputEnableStateStack3V3.value) << ", " <<
std::setw(4) << std::right <<
p60dockHkTableDataset.currentStack3V3.value << ", " << std::setw(5) <<
p60dockHkTableDataset.voltageStack3V3.value << std::endl;
sif::info << std::setw(30) << std::left << "Stack 5V" << std::dec << "| " <<
unsigned(p60dockHkTableDataset.outputEnableStateStack5V.value) << ", " <<
std::setw(4) << std::right <<
p60dockHkTableDataset.currentStack5V.value << ", " << std::setw(5) <<
p60dockHkTableDataset.voltageStack5V.value << std::endl;
sif::info << std::setw(30) << std::left << "Stack VBAT" << std::dec << "| "
<< unsigned(p60dockHkTableDataset.outputEnableStateStackVbat.value) << ", "
<< std::setw(4) << std::right << p60dockHkTableDataset.currentStackVbat.value << ", "
<< std::setw(5) << p60dockHkTableDataset.voltageStackVbat.value << std::endl;
sif::info << std::setw(30) << std::left << "Stack 3V3" << std::dec << "| "
<< unsigned(p60dockHkTableDataset.outputEnableStateStack3V3.value) << ", "
<< std::setw(4) << std::right << p60dockHkTableDataset.currentStack3V3.value << ", "
<< std::setw(5) << p60dockHkTableDataset.voltageStack3V3.value << std::endl;
sif::info << std::setw(30) << std::left << "Stack 5V" << std::dec << "| "
<< unsigned(p60dockHkTableDataset.outputEnableStateStack5V.value) << ", "
<< std::setw(4) << std::right << p60dockHkTableDataset.currentStack5V.value << ", "
<< std::setw(5) << p60dockHkTableDataset.voltageStack5V.value << std::endl;
}

View File

@ -1,47 +1,47 @@
#ifndef MISSION_DEVICES_P60DOCKHANDLER_H_
#define MISSION_DEVICES_P60DOCKHANDLER_H_
#include "GomspaceDeviceHandler.h"
#include <mission/devices/devicedefinitions/GomspaceDefinitions.h>
#include "GomspaceDeviceHandler.h"
/**
* @brief Device handler for the P60Dock. The P60Dock serves as carrier for the ACU, PDU1 and
* PDU2. Via the P60Dock each of these modules can be turned on and off individually.
*/
class P60DockHandler: public GomspaceDeviceHandler {
public:
P60DockHandler(object_id_t objectId, object_id_t comIF, CookieIF * comCookie);
virtual ~P60DockHandler();
class P60DockHandler : public GomspaceDeviceHandler {
public:
P60DockHandler(object_id_t objectId, object_id_t comIF, CookieIF* comCookie);
virtual ~P60DockHandler();
virtual ReturnValue_t initializeLocalDataPool(localpool::DataPool& localDataPoolMap,
LocalDataPoolManager& poolManager) override;
virtual ReturnValue_t initializeLocalDataPool(localpool::DataPool& localDataPoolMap,
LocalDataPoolManager& poolManager) override;
protected:
protected:
/**
* @brief As soon as the device is in MODE_NORMAL, this function is executed periodically.
*/
virtual ReturnValue_t buildNormalDeviceCommand(DeviceCommandId_t* id) override;
/**
* @brief As soon as the device is in MODE_NORMAL, this function is executed periodically.
*/
virtual ReturnValue_t buildNormalDeviceCommand(DeviceCommandId_t * id) override;
virtual void letChildHandleHkReply(DeviceCommandId_t id, const uint8_t* packet) override;
virtual void letChildHandleHkReply(DeviceCommandId_t id, const uint8_t *packet) override;
/**
* This command handles printing the HK table to the console. This is useful for debugging
* purposes
* @return
*/
ReturnValue_t printStatus(DeviceCommandId_t cmd) override;
/**
* This command handles printing the HK table to the console. This is useful for debugging
* purposes
* @return
*/
ReturnValue_t printStatus(DeviceCommandId_t cmd) override;
void printHkTable();
void printHkTable();
private:
P60Dock::HkTableDataset p60dockHkTableDataset;
private:
P60Dock::HkTableDataset p60dockHkTableDataset;
/**
* @brief Function extracts the hk table information from the received csp packet and stores
* the values in the p60dockHkTableDataset.
*/
void parseHkTableReply(const uint8_t *packet);
/**
* @brief Function extracts the hk table information from the received csp packet and stores
* the values in the p60dockHkTableDataset.
*/
void parseHkTableReply(const uint8_t* packet);
};
#endif /* MISSION_DEVICES_P60DOCKHANDLER_H_ */

View File

@ -1,506 +1,488 @@
#include "PCDUHandler.h"
#include <OBSWConfig.h>
#include <fsfw/housekeeping/HousekeepingSnapshot.h>
#include <fsfw/ipc/QueueFactory.h>
#include <mission/devices/devicedefinitions/GomSpacePackets.h>
#include <objects/systemObjectList.h>
#include <mission/devices/devicedefinitions/GomSpacePackets.h>
#include <fsfw/ipc/QueueFactory.h>
#include <fsfw/housekeeping/HousekeepingSnapshot.h>
PCDUHandler::PCDUHandler(object_id_t setObjectId, size_t cmdQueueSize) :
SystemObject(setObjectId), poolManager(this, nullptr), pdu2HkTableDataset(this), pdu1HkTableDataset(
this), cmdQueueSize(cmdQueueSize) {
commandQueue = QueueFactory::instance()->createMessageQueue(cmdQueueSize,
MessageQueueMessage::MAX_MESSAGE_SIZE);
PCDUHandler::PCDUHandler(object_id_t setObjectId, size_t cmdQueueSize)
: SystemObject(setObjectId),
poolManager(this, nullptr),
pdu2HkTableDataset(this),
pdu1HkTableDataset(this),
cmdQueueSize(cmdQueueSize) {
commandQueue = QueueFactory::instance()->createMessageQueue(
cmdQueueSize, MessageQueueMessage::MAX_MESSAGE_SIZE);
}
PCDUHandler::~PCDUHandler() {
}
PCDUHandler::~PCDUHandler() {}
ReturnValue_t PCDUHandler::performOperation(uint8_t counter) {
if (counter == DeviceHandlerIF::PERFORM_OPERATION) {
readCommandQueue();
return RETURN_OK;
}
if (counter == DeviceHandlerIF::PERFORM_OPERATION) {
readCommandQueue();
return RETURN_OK;
}
return RETURN_OK;
}
ReturnValue_t PCDUHandler::initialize() {
ReturnValue_t result;
ReturnValue_t result;
IPCStore = ObjectManager::instance()->get<StorageManagerIF>(objects::IPC_STORE);
if (IPCStore == nullptr) {
return ObjectManagerIF::CHILD_INIT_FAILED;
}
IPCStore = ObjectManager::instance()->get<StorageManagerIF>(objects::IPC_STORE);
if (IPCStore == nullptr) {
return ObjectManagerIF::CHILD_INIT_FAILED;
}
result = poolManager.initialize(commandQueue);
if (result != HasReturnvaluesIF::RETURN_OK) {
return result;
}
result = poolManager.initialize(commandQueue);
if (result != HasReturnvaluesIF::RETURN_OK) {
return result;
}
/* Subscribing for housekeeping table update messages of the PDU2 */
HasLocalDataPoolIF* pdu2Handler =
ObjectManager::instance()->get<HasLocalDataPoolIF>(objects::PDU2_HANDLER);
if (pdu2Handler == nullptr) {
sif::error << "PCDUHandler::initialize: Invalid pdu2Handler" << std::endl;
return RETURN_FAILED;
}
result = pdu2Handler->getSubscriptionInterface()->subscribeForSetUpdateMessage(
PDU2::HK_TABLE_DATA_SET_ID, this->getObjectId(), commandQueue->getId(), true);
if (result != RETURN_OK) {
sif::error << "PCDUHandler::initialize: Failed to subscribe for set update messages from "
<< "PDU2Handler" << std::endl;
return result;
}
/* Subscribing for housekeeping table update messages of the PDU2 */
HasLocalDataPoolIF* pdu2Handler = ObjectManager::instance()->get<HasLocalDataPoolIF>(
objects::PDU2_HANDLER);
if(pdu2Handler == nullptr) {
sif::error << "PCDUHandler::initialize: Invalid pdu2Handler" << std::endl;
return RETURN_FAILED;
}
result = pdu2Handler->getSubscriptionInterface()->subscribeForSetUpdateMessage(
PDU2::HK_TABLE_DATA_SET_ID, this->getObjectId(), commandQueue->getId(), true);
if (result != RETURN_OK) {
sif::error << "PCDUHandler::initialize: Failed to subscribe for set update messages from "
<< "PDU2Handler" << std::endl;
return result;
}
/* Subscribing for housekeeping table update messages of the PDU1 */
HasLocalDataPoolIF* pdu1Handler =
ObjectManager::instance()->get<HasLocalDataPoolIF>(objects::PDU1_HANDLER);
if (pdu1Handler == nullptr) {
sif::error << "PCDUHandler::initialize: Invalid pdu1Handler" << std::endl;
return RETURN_FAILED;
}
result = pdu1Handler->getSubscriptionInterface()->subscribeForSetUpdateMessage(
PDU1::HK_TABLE_DATA_SET_ID, this->getObjectId(), commandQueue->getId(), true);
if (result != RETURN_OK) {
sif::error << "PCDUHandler::initialize: Failed to subscribe for set update messages from "
<< "PDU1Handler" << std::endl;
return result;
}
/* Subscribing for housekeeping table update messages of the PDU1 */
HasLocalDataPoolIF* pdu1Handler = ObjectManager::instance()->get<HasLocalDataPoolIF>(
objects::PDU1_HANDLER);
if(pdu1Handler == nullptr) {
sif::error << "PCDUHandler::initialize: Invalid pdu1Handler" << std::endl;
return RETURN_FAILED;
}
result = pdu1Handler->getSubscriptionInterface()->subscribeForSetUpdateMessage(
PDU1::HK_TABLE_DATA_SET_ID, this->getObjectId(), commandQueue->getId(), true);
if (result != RETURN_OK) {
sif::error << "PCDUHandler::initialize: Failed to subscribe for set update messages from "
<< "PDU1Handler" << std::endl;
return result;
}
return RETURN_OK;
return RETURN_OK;
}
void PCDUHandler::initializeSwitchStates() {
switchStates[pcduSwitches::Q7S] = pcduSwitches::INIT_STATE_Q7S;
switchStates[pcduSwitches::PAYLOAD_PCDU_CH1] = pcduSwitches::INIT_STATE_PAYLOAD_PCDU_CH1;
switchStates[pcduSwitches::RW] = pcduSwitches::INIT_STATE_RW;
switchStates[pcduSwitches::TCS_BOARD_8V_HEATER_IN] = pcduSwitches::INIT_STATE_TCS_BOARD_8V_HEATER_IN;
switchStates[pcduSwitches::SUS_REDUNDANT] = pcduSwitches::INIT_STATE_SUS_REDUNDANT;
switchStates[pcduSwitches::DEPLOYMENT_MECHANISM] = pcduSwitches::INIT_STATE_DEPLOYMENT_MECHANISM;
switchStates[pcduSwitches::PAYLOAD_PCDU_CH6] = pcduSwitches::INIT_STATE_PAYLOAD_PCDU_CH6;
switchStates[pcduSwitches::ACS_BOARD_SIDE_B] = pcduSwitches::INIT_STATE_ACS_BOARD_SIDE_B;
switchStates[pcduSwitches::PAYLOAD_CAMERA] = pcduSwitches::INIT_STATE_PAYLOAD_CAMERA;
switchStates[pcduSwitches::TCS_BOARD_3V3] = pcduSwitches::INIT_STATE_TCS_BOARD_3V3;
switchStates[pcduSwitches::SYRLINKS] = pcduSwitches::INIT_STATE_SYRLINKS;
switchStates[pcduSwitches::STAR_TRACKER] = pcduSwitches::INIT_STATE_STAR_TRACKER;
switchStates[pcduSwitches::MGT] = pcduSwitches::INIT_STATE_MGT;
switchStates[pcduSwitches::SUS_NOMINAL] = pcduSwitches::INIT_STATE_SUS_NOMINAL;
switchStates[pcduSwitches::SOLAR_CELL_EXP] = pcduSwitches::INIT_STATE_SOLAR_CELL_EXP;
switchStates[pcduSwitches::PLOC] = pcduSwitches::INIT_STATE_PLOC;
switchStates[pcduSwitches::ACS_BOARD_SIDE_A] = pcduSwitches::INIT_STATE_ACS_BOARD_SIDE_A;
switchStates[pcduSwitches::Q7S] = pcduSwitches::INIT_STATE_Q7S;
switchStates[pcduSwitches::PAYLOAD_PCDU_CH1] = pcduSwitches::INIT_STATE_PAYLOAD_PCDU_CH1;
switchStates[pcduSwitches::RW] = pcduSwitches::INIT_STATE_RW;
switchStates[pcduSwitches::TCS_BOARD_8V_HEATER_IN] =
pcduSwitches::INIT_STATE_TCS_BOARD_8V_HEATER_IN;
switchStates[pcduSwitches::SUS_REDUNDANT] = pcduSwitches::INIT_STATE_SUS_REDUNDANT;
switchStates[pcduSwitches::DEPLOYMENT_MECHANISM] = pcduSwitches::INIT_STATE_DEPLOYMENT_MECHANISM;
switchStates[pcduSwitches::PAYLOAD_PCDU_CH6] = pcduSwitches::INIT_STATE_PAYLOAD_PCDU_CH6;
switchStates[pcduSwitches::ACS_BOARD_SIDE_B] = pcduSwitches::INIT_STATE_ACS_BOARD_SIDE_B;
switchStates[pcduSwitches::PAYLOAD_CAMERA] = pcduSwitches::INIT_STATE_PAYLOAD_CAMERA;
switchStates[pcduSwitches::TCS_BOARD_3V3] = pcduSwitches::INIT_STATE_TCS_BOARD_3V3;
switchStates[pcduSwitches::SYRLINKS] = pcduSwitches::INIT_STATE_SYRLINKS;
switchStates[pcduSwitches::STAR_TRACKER] = pcduSwitches::INIT_STATE_STAR_TRACKER;
switchStates[pcduSwitches::MGT] = pcduSwitches::INIT_STATE_MGT;
switchStates[pcduSwitches::SUS_NOMINAL] = pcduSwitches::INIT_STATE_SUS_NOMINAL;
switchStates[pcduSwitches::SOLAR_CELL_EXP] = pcduSwitches::INIT_STATE_SOLAR_CELL_EXP;
switchStates[pcduSwitches::PLOC] = pcduSwitches::INIT_STATE_PLOC;
switchStates[pcduSwitches::ACS_BOARD_SIDE_A] = pcduSwitches::INIT_STATE_ACS_BOARD_SIDE_A;
}
void PCDUHandler::readCommandQueue() {
ReturnValue_t result;
CommandMessage command;
ReturnValue_t result;
CommandMessage command;
result = commandQueue->receiveMessage(&command);
if (result != RETURN_OK) {
return;
}
result = commandQueue->receiveMessage(&command);
if (result != RETURN_OK) {
return;
}
result = poolManager.handleHousekeepingMessage(&command);
if (result == RETURN_OK) {
return;
}
result = poolManager.handleHousekeepingMessage(&command);
if (result == RETURN_OK) {
return;
}
}
MessageQueueId_t PCDUHandler::getCommandQueue() const {
return commandQueue->getId();
}
MessageQueueId_t PCDUHandler::getCommandQueue() const { return commandQueue->getId(); }
void PCDUHandler::handleChangedDataset(sid_t sid, store_address_t storeId) {
if (sid == sid_t(objects::PDU2_HANDLER, PDU2::HK_TABLE_DATA_SET_ID)) {
updateHkTableDataset(storeId, &pdu2HkTableDataset, &timeStampPdu2HkDataset);
updatePdu2SwitchStates();
}
else if (sid == sid_t(objects::PDU1_HANDLER, PDU1::HK_TABLE_DATA_SET_ID)) {
updateHkTableDataset(storeId, &pdu1HkTableDataset, &timeStampPdu1HkDataset);
updatePdu1SwitchStates();
}
else {
sif::error << "PCDUHandler::handleChangedDataset: Invalid sid" << std::endl;
}
if (sid == sid_t(objects::PDU2_HANDLER, PDU2::HK_TABLE_DATA_SET_ID)) {
updateHkTableDataset(storeId, &pdu2HkTableDataset, &timeStampPdu2HkDataset);
updatePdu2SwitchStates();
} else if (sid == sid_t(objects::PDU1_HANDLER, PDU1::HK_TABLE_DATA_SET_ID)) {
updateHkTableDataset(storeId, &pdu1HkTableDataset, &timeStampPdu1HkDataset);
updatePdu1SwitchStates();
} else {
sif::error << "PCDUHandler::handleChangedDataset: Invalid sid" << std::endl;
}
}
void PCDUHandler::updateHkTableDataset(store_address_t storeId,
LocalPoolDataSetBase* dataset, CCSDSTime::CDS_short* datasetTimeStamp) {
ReturnValue_t result;
void PCDUHandler::updateHkTableDataset(store_address_t storeId, LocalPoolDataSetBase* dataset,
CCSDSTime::CDS_short* datasetTimeStamp) {
ReturnValue_t result;
HousekeepingSnapshot packetUpdate(reinterpret_cast<uint8_t*>(datasetTimeStamp),
sizeof(CCSDSTime::CDS_short), dataset);
const uint8_t* packet_ptr = NULL;
size_t size;
result = IPCStore->getData(storeId, &packet_ptr, &size);
if (result != RETURN_OK) {
sif::error << "PCDUHandler::updateHkTableDataset: Failed to get data from IPCStore."
<< std::endl;
}
dataset->read();
result = packetUpdate.deSerialize(&packet_ptr, &size, SerializeIF::Endianness::MACHINE);
if (result != RETURN_OK) {
sif::error << "PCDUHandler::updateHkTableDataset: Failed to deserialize received packet "
"in hk table dataset"<< std::endl;
}
dataset->commit();
result = IPCStore->deleteData(storeId);
if (result != RETURN_OK) {
sif::error << "PCDUHandler::updateHkTableDataset: Failed to delete data in IPCStore"
<< std::endl;
}
HousekeepingSnapshot packetUpdate(reinterpret_cast<uint8_t*>(datasetTimeStamp),
sizeof(CCSDSTime::CDS_short), dataset);
const uint8_t* packet_ptr = NULL;
size_t size;
result = IPCStore->getData(storeId, &packet_ptr, &size);
if (result != RETURN_OK) {
sif::error << "PCDUHandler::updateHkTableDataset: Failed to get data from IPCStore."
<< std::endl;
}
dataset->read();
result = packetUpdate.deSerialize(&packet_ptr, &size, SerializeIF::Endianness::MACHINE);
if (result != RETURN_OK) {
sif::error << "PCDUHandler::updateHkTableDataset: Failed to deserialize received packet "
"in hk table dataset"
<< std::endl;
}
dataset->commit();
result = IPCStore->deleteData(storeId);
if (result != RETURN_OK) {
sif::error << "PCDUHandler::updateHkTableDataset: Failed to delete data in IPCStore"
<< std::endl;
}
}
void PCDUHandler::updatePdu2SwitchStates() {
//TODO: pool read helper
if (pdu2HkTableDataset.read() == RETURN_OK) {
switchStates[pcduSwitches::Q7S] = pdu2HkTableDataset.outEnabledQ7S.value;
switchStates[pcduSwitches::PAYLOAD_PCDU_CH1] = pdu2HkTableDataset.outEnabledPlPCDUCh1.value;
switchStates[pcduSwitches::RW] = pdu2HkTableDataset.outEnabledReactionWheels.value;
switchStates[pcduSwitches::TCS_BOARD_8V_HEATER_IN] = pdu2HkTableDataset.outEnabledTCSBoardHeaterIn.value;
switchStates[pcduSwitches::SUS_REDUNDANT] = pdu2HkTableDataset.outEnabledSUSRedundant.value;
switchStates[pcduSwitches::DEPLOYMENT_MECHANISM] = pdu2HkTableDataset.outEnabledDeplMechanism.value;
switchStates[pcduSwitches::PAYLOAD_PCDU_CH6] = pdu2HkTableDataset.outEnabledPlPCDUCh6.value;
switchStates[pcduSwitches::ACS_BOARD_SIDE_B] = pdu2HkTableDataset.outEnabledAcsBoardSideB.value;
switchStates[pcduSwitches::PAYLOAD_CAMERA] = pdu2HkTableDataset.outEnabledPayloadCamera.value;
}
else {
sif::debug << "PCDUHandler::updatePdu2SwitchStates: Failed to read PDU2 Hk Dataset"
<< std::endl;
}
pdu2HkTableDataset.commit();
// TODO: pool read helper
if (pdu2HkTableDataset.read() == RETURN_OK) {
switchStates[pcduSwitches::Q7S] = pdu2HkTableDataset.outEnabledQ7S.value;
switchStates[pcduSwitches::PAYLOAD_PCDU_CH1] = pdu2HkTableDataset.outEnabledPlPCDUCh1.value;
switchStates[pcduSwitches::RW] = pdu2HkTableDataset.outEnabledReactionWheels.value;
switchStates[pcduSwitches::TCS_BOARD_8V_HEATER_IN] =
pdu2HkTableDataset.outEnabledTCSBoardHeaterIn.value;
switchStates[pcduSwitches::SUS_REDUNDANT] = pdu2HkTableDataset.outEnabledSUSRedundant.value;
switchStates[pcduSwitches::DEPLOYMENT_MECHANISM] =
pdu2HkTableDataset.outEnabledDeplMechanism.value;
switchStates[pcduSwitches::PAYLOAD_PCDU_CH6] = pdu2HkTableDataset.outEnabledPlPCDUCh6.value;
switchStates[pcduSwitches::ACS_BOARD_SIDE_B] = pdu2HkTableDataset.outEnabledAcsBoardSideB.value;
switchStates[pcduSwitches::PAYLOAD_CAMERA] = pdu2HkTableDataset.outEnabledPayloadCamera.value;
} else {
sif::debug << "PCDUHandler::updatePdu2SwitchStates: Failed to read PDU2 Hk Dataset"
<< std::endl;
}
pdu2HkTableDataset.commit();
}
void PCDUHandler::updatePdu1SwitchStates() {
if (pdu1HkTableDataset.read() == RETURN_OK) {
switchStates[pcduSwitches::TCS_BOARD_3V3] = pdu1HkTableDataset.voltageOutTCSBoard3V3.value;
switchStates[pcduSwitches::SYRLINKS] = pdu1HkTableDataset.voltageOutSyrlinks.value;
switchStates[pcduSwitches::STAR_TRACKER] = pdu1HkTableDataset.voltageOutStarTracker.value;
switchStates[pcduSwitches::MGT] = pdu1HkTableDataset.voltageOutMGT.value;
switchStates[pcduSwitches::SUS_NOMINAL] = pdu1HkTableDataset.voltageOutSUSNominal.value;
switchStates[pcduSwitches::SOLAR_CELL_EXP] = pdu1HkTableDataset.voltageOutSolarCellExp.value;
switchStates[pcduSwitches::PLOC] = pdu1HkTableDataset.voltageOutPLOC.value;
switchStates[pcduSwitches::ACS_BOARD_SIDE_A] = pdu1HkTableDataset.voltageOutACSBoardSideA.value;
}
else {
sif::debug << "PCDUHandler::updatePdu1SwitchStates: Failed to read dataset" << std::endl;
}
pdu1HkTableDataset.commit();
if (pdu1HkTableDataset.read() == RETURN_OK) {
switchStates[pcduSwitches::TCS_BOARD_3V3] = pdu1HkTableDataset.voltageOutTCSBoard3V3.value;
switchStates[pcduSwitches::SYRLINKS] = pdu1HkTableDataset.voltageOutSyrlinks.value;
switchStates[pcduSwitches::STAR_TRACKER] = pdu1HkTableDataset.voltageOutStarTracker.value;
switchStates[pcduSwitches::MGT] = pdu1HkTableDataset.voltageOutMGT.value;
switchStates[pcduSwitches::SUS_NOMINAL] = pdu1HkTableDataset.voltageOutSUSNominal.value;
switchStates[pcduSwitches::SOLAR_CELL_EXP] = pdu1HkTableDataset.voltageOutSolarCellExp.value;
switchStates[pcduSwitches::PLOC] = pdu1HkTableDataset.voltageOutPLOC.value;
switchStates[pcduSwitches::ACS_BOARD_SIDE_A] = pdu1HkTableDataset.voltageOutACSBoardSideA.value;
} else {
sif::debug << "PCDUHandler::updatePdu1SwitchStates: Failed to read dataset" << std::endl;
}
pdu1HkTableDataset.commit();
}
LocalDataPoolManager* PCDUHandler::getHkManagerHandle() {
return &poolManager;
}
LocalDataPoolManager* PCDUHandler::getHkManagerHandle() { return &poolManager; }
void PCDUHandler::sendSwitchCommand(uint8_t switchNr, ReturnValue_t onOff) const {
ReturnValue_t result;
uint16_t memoryAddress;
size_t parameterValueSize = sizeof(uint8_t);
uint8_t parameterValue;
GomspaceDeviceHandler* pdu;
ReturnValue_t result;
uint16_t memoryAddress;
size_t parameterValueSize = sizeof(uint8_t);
uint8_t parameterValue;
GomspaceDeviceHandler* pdu;
switch (switchNr) {
switch (switchNr) {
case pcduSwitches::TCS_BOARD_8V_HEATER_IN:
memoryAddress = PDU2::CONFIG_ADDRESS_OUT_EN_TCS_BOARD_HEATER_IN;
pdu = ObjectManager::instance()->get<GomspaceDeviceHandler>(objects::PDU2_HANDLER);
break;
memoryAddress = PDU2::CONFIG_ADDRESS_OUT_EN_TCS_BOARD_HEATER_IN;
pdu = ObjectManager::instance()->get<GomspaceDeviceHandler>(objects::PDU2_HANDLER);
break;
case pcduSwitches::DEPLOYMENT_MECHANISM:
memoryAddress = PDU2::CONFIG_ADDRESS_OUT_EN_DEPLOYMENT_MECHANISM;
pdu = ObjectManager::instance()->get<GomspaceDeviceHandler>(objects::PDU2_HANDLER);
break;
memoryAddress = PDU2::CONFIG_ADDRESS_OUT_EN_DEPLOYMENT_MECHANISM;
pdu = ObjectManager::instance()->get<GomspaceDeviceHandler>(objects::PDU2_HANDLER);
break;
default:
sif::error << "PCDUHandler::sendSwitchCommand: Invalid switch number " << std::endl;
return;
}
sif::error << "PCDUHandler::sendSwitchCommand: Invalid switch number " << std::endl;
return;
}
switch (onOff) {
switch (onOff) {
case PowerSwitchIF::SWITCH_ON:
parameterValue = 1;
break;
parameterValue = 1;
break;
case PowerSwitchIF::SWITCH_OFF:
parameterValue = 0;
break;
parameterValue = 0;
break;
default:
sif::error << "PCDUHandler::sendSwitchCommand: Invalid state commanded" << std::endl;
return;
}
sif::error << "PCDUHandler::sendSwitchCommand: Invalid state commanded" << std::endl;
return;
}
GomspaceSetParamMessage setParamMessage(memoryAddress, &parameterValue, parameterValueSize);
GomspaceSetParamMessage setParamMessage(memoryAddress, &parameterValue, parameterValueSize);
size_t serializedLength = 0;
uint8_t command[4];
uint8_t* commandPtr = command;
size_t maxSize = sizeof(command);
setParamMessage.serialize(&commandPtr, &serializedLength, maxSize,
SerializeIF::Endianness::BIG);
size_t serializedLength = 0;
uint8_t command[4];
uint8_t* commandPtr = command;
size_t maxSize = sizeof(command);
setParamMessage.serialize(&commandPtr, &serializedLength, maxSize, SerializeIF::Endianness::BIG);
store_address_t storeAddress;
result = IPCStore->addData(&storeAddress, command,sizeof(command));
store_address_t storeAddress;
result = IPCStore->addData(&storeAddress, command, sizeof(command));
CommandMessage message;
ActionMessage::setCommand(&message, GOMSPACE::PARAM_SET, storeAddress);
CommandMessage message;
ActionMessage::setCommand(&message, GOMSPACE::PARAM_SET, storeAddress);
result = commandQueue->sendMessage(pdu->getCommandQueue(), &message, 0);
if (result != RETURN_OK) {
sif::debug << "PCDUHandler::sendSwitchCommand: Failed to send message to PDU Handler"
<< std::endl;
}
result = commandQueue->sendMessage(pdu->getCommandQueue(), &message, 0);
if (result != RETURN_OK) {
sif::debug << "PCDUHandler::sendSwitchCommand: Failed to send message to PDU Handler"
<< std::endl;
}
}
void PCDUHandler::sendFuseOnCommand(uint8_t fuseNr) const {
void PCDUHandler::sendFuseOnCommand(uint8_t fuseNr) const {}
ReturnValue_t PCDUHandler::getSwitchState(uint8_t switchNr) const {
if (switchNr >= pcduSwitches::NUMBER_OF_SWITCHES) {
sif::debug << "PCDUHandler::getSwitchState: Invalid switch number" << std::endl;
return RETURN_FAILED;
}
if (switchStates[switchNr] == 1) {
return PowerSwitchIF::SWITCH_ON;
} else {
return PowerSwitchIF::SWITCH_OFF;
}
}
ReturnValue_t PCDUHandler::getSwitchState( uint8_t switchNr ) const {
if (switchNr >= pcduSwitches::NUMBER_OF_SWITCHES) {
sif::debug << "PCDUHandler::getSwitchState: Invalid switch number" << std::endl;
return RETURN_FAILED;
}
if (switchStates[switchNr] == 1) {
return PowerSwitchIF::SWITCH_ON;
}
else {
return PowerSwitchIF::SWITCH_OFF;
}
}
ReturnValue_t PCDUHandler::getFuseState(uint8_t fuseNr) const { return RETURN_OK; }
ReturnValue_t PCDUHandler::getFuseState( uint8_t fuseNr ) const {
return RETURN_OK;
}
uint32_t PCDUHandler::getSwitchDelayMs(void) const { return 20000; }
uint32_t PCDUHandler::getSwitchDelayMs(void) const {
return 20000;
}
object_id_t PCDUHandler::getObjectId() const { return SystemObject::getObjectId(); }
object_id_t PCDUHandler::getObjectId() const {
return SystemObject::getObjectId();
}
ReturnValue_t PCDUHandler::initializeLocalDataPool(localpool::DataPool& localDataPoolMap,
LocalDataPoolManager& poolManager) {
localDataPoolMap.emplace(P60System::PDU2_CURRENT_OUT_Q7S, new PoolEntry<int16_t>({0}));
localDataPoolMap.emplace(P60System::PDU2_CURRENT_OUT_PAYLOAD_PCDU_CH1,
new PoolEntry<int16_t>({0}));
localDataPoolMap.emplace(P60System::PDU2_CURRENT_OUT_RW, new PoolEntry<int16_t>({0}));
localDataPoolMap.emplace(P60System::PDU2_CURRENT_OUT_TCS_BOARD_HEATER_IN,
new PoolEntry<int16_t>({0}));
localDataPoolMap.emplace(P60System::PDU2_CURRENT_OUT_SUS_REDUNDANT, new PoolEntry<int16_t>({0}));
localDataPoolMap.emplace(P60System::PDU2_CURRENT_OUT_DEPLOYMENT_MECHANISM,
new PoolEntry<int16_t>({0}));
localDataPoolMap.emplace(P60System::PDU2_CURRENT_OUT_PAYLOAD_PCDU_CH6,
new PoolEntry<int16_t>({0}));
localDataPoolMap.emplace(P60System::PDU2_CURRENT_OUT_ACS_BOARD_SIDE_B,
new PoolEntry<int16_t>({0}));
localDataPoolMap.emplace(P60System::PDU2_CURRENT_OUT_PAYLOAD_CAMERA, new PoolEntry<int16_t>({0}));
ReturnValue_t PCDUHandler::initializeLocalDataPool(localpool::DataPool &localDataPoolMap,
LocalDataPoolManager &poolManager) {
localDataPoolMap.emplace(P60System::PDU2_VOLTAGE_OUT_Q7S, new PoolEntry<int16_t>({0}));
localDataPoolMap.emplace(P60System::PDU2_VOLTAGE_OUT_PAYLOAD_PCDU_CH1,
new PoolEntry<int16_t>({0}));
localDataPoolMap.emplace(P60System::PDU2_VOLTAGE_OUT_RW, new PoolEntry<int16_t>({0}));
localDataPoolMap.emplace(P60System::PDU2_VOLTAGE_OUT_TCS_BOARD_HEATER_IN,
new PoolEntry<int16_t>({0}));
localDataPoolMap.emplace(P60System::PDU2_VOLTAGE_OUT_SUS_REDUNDANT, new PoolEntry<int16_t>({0}));
localDataPoolMap.emplace(P60System::PDU2_VOLTAGE_OUT_DEPLOYMENT_MECHANISM,
new PoolEntry<int16_t>({0}));
localDataPoolMap.emplace(P60System::PDU2_VOLTAGE_OUT_PAYLOAD_PCDU_CH6,
new PoolEntry<int16_t>({0}));
localDataPoolMap.emplace(P60System::PDU2_VOLTAGE_OUT_ACS_BOARD_SIDE_B,
new PoolEntry<int16_t>({0}));
localDataPoolMap.emplace(P60System::PDU2_VOLTAGE_OUT_PAYLOAD_CAMERA, new PoolEntry<int16_t>({0}));
localDataPoolMap.emplace(P60System::PDU2_CURRENT_OUT_Q7S, new PoolEntry<int16_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU2_CURRENT_OUT_PAYLOAD_PCDU_CH1,
new PoolEntry<int16_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU2_CURRENT_OUT_RW, new PoolEntry<int16_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU2_CURRENT_OUT_TCS_BOARD_HEATER_IN,
new PoolEntry<int16_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU2_CURRENT_OUT_SUS_REDUNDANT, new PoolEntry<int16_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU2_CURRENT_OUT_DEPLOYMENT_MECHANISM,
new PoolEntry<int16_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU2_CURRENT_OUT_PAYLOAD_PCDU_CH6,
new PoolEntry<int16_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU2_CURRENT_OUT_ACS_BOARD_SIDE_B,
new PoolEntry<int16_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU2_CURRENT_OUT_PAYLOAD_CAMERA, new PoolEntry<int16_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU2_VCC, new PoolEntry<int16_t>({0}));
localDataPoolMap.emplace(P60System::PDU2_VBAT, new PoolEntry<int16_t>({0}));
localDataPoolMap.emplace(P60System::PDU2_TEMPERATURE, new PoolEntry<int16_t>({0}));
localDataPoolMap.emplace(P60System::PDU2_CONV_EN_1, new PoolEntry<uint8_t>({0}));
localDataPoolMap.emplace(P60System::PDU2_CONV_EN_2, new PoolEntry<uint8_t>({0}));
localDataPoolMap.emplace(P60System::PDU2_CONV_EN_3, new PoolEntry<uint8_t>({0}));
localDataPoolMap.emplace(P60System::PDU2_VOLTAGE_OUT_Q7S, new PoolEntry<int16_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU2_VOLTAGE_OUT_PAYLOAD_PCDU_CH1,
new PoolEntry<int16_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU2_VOLTAGE_OUT_RW, new PoolEntry<int16_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU2_VOLTAGE_OUT_TCS_BOARD_HEATER_IN,
new PoolEntry<int16_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU2_VOLTAGE_OUT_SUS_REDUNDANT, new PoolEntry<int16_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU2_VOLTAGE_OUT_DEPLOYMENT_MECHANISM,
new PoolEntry<int16_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU2_VOLTAGE_OUT_PAYLOAD_PCDU_CH6,
new PoolEntry<int16_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU2_VOLTAGE_OUT_ACS_BOARD_SIDE_B,
new PoolEntry<int16_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU2_VOLTAGE_OUT_PAYLOAD_CAMERA, new PoolEntry<int16_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU2_VCC, new PoolEntry<int16_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU2_VBAT, new PoolEntry<int16_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU2_TEMPERATURE, new PoolEntry<int16_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU2_CONV_EN_1, new PoolEntry<uint8_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU2_CONV_EN_2, new PoolEntry<uint8_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU2_CONV_EN_3, new PoolEntry<uint8_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU2_OUT_EN_Q7S, new PoolEntry<uint8_t>( {
pcduSwitches::INIT_STATE_Q7S }));
localDataPoolMap.emplace(P60System::PDU2_OUT_EN_PAYLOAD_PCDU_CH1, new PoolEntry<uint8_t>( {
pcduSwitches::INIT_STATE_PAYLOAD_PCDU_CH1 }));
localDataPoolMap.emplace(P60System::PDU2_OUT_EN_RW, new PoolEntry<uint8_t>( {
pcduSwitches::INIT_STATE_RW }));
localDataPoolMap.emplace(P60System::PDU2_OUT_EN_Q7S,
new PoolEntry<uint8_t>({pcduSwitches::INIT_STATE_Q7S}));
localDataPoolMap.emplace(P60System::PDU2_OUT_EN_PAYLOAD_PCDU_CH1,
new PoolEntry<uint8_t>({pcduSwitches::INIT_STATE_PAYLOAD_PCDU_CH1}));
localDataPoolMap.emplace(P60System::PDU2_OUT_EN_RW,
new PoolEntry<uint8_t>({pcduSwitches::INIT_STATE_RW}));
#if BOARD_TE0720 == 1
localDataPoolMap.emplace(P60System::PDU2_OUT_EN_TCS_BOARD_HEATER_IN, new PoolEntry<uint8_t>( { 1 }));
localDataPoolMap.emplace(P60System::PDU2_OUT_EN_TCS_BOARD_HEATER_IN, new PoolEntry<uint8_t>({1}));
#else
localDataPoolMap.emplace(P60System::PDU2_OUT_EN_TCS_BOARD_HEATER_IN, new PoolEntry<uint8_t>( {pcduSwitches::INIT_STATE_TCS_BOARD_8V_HEATER_IN}));
localDataPoolMap.emplace(
P60System::PDU2_OUT_EN_TCS_BOARD_HEATER_IN,
new PoolEntry<uint8_t>({pcduSwitches::INIT_STATE_TCS_BOARD_8V_HEATER_IN}));
#endif
localDataPoolMap.emplace(P60System::PDU2_OUT_EN_SUS_REDUNDANT, new PoolEntry<uint8_t>( {
pcduSwitches::INIT_STATE_SUS_REDUNDANT }));
localDataPoolMap.emplace(P60System::PDU2_OUT_EN_DEPLOYMENT_MECHANISM, new PoolEntry<uint8_t>( {
pcduSwitches::INIT_STATE_DEPLOYMENT_MECHANISM }));
localDataPoolMap.emplace(P60System::PDU2_OUT_EN_PAYLOAD_PCDU_CH6, new PoolEntry<uint8_t>( {
pcduSwitches::INIT_STATE_PAYLOAD_PCDU_CH6 }));
localDataPoolMap.emplace(P60System::PDU2_OUT_EN_ACS_BOARD_SIDE_B, new PoolEntry<uint8_t>( {
pcduSwitches::INIT_STATE_ACS_BOARD_SIDE_B }));
localDataPoolMap.emplace(P60System::PDU2_OUT_EN_PAYLOAD_CAMERA, new PoolEntry<uint8_t>( {
pcduSwitches::INIT_STATE_PAYLOAD_CAMERA }));
localDataPoolMap.emplace(P60System::PDU2_OUT_EN_SUS_REDUNDANT,
new PoolEntry<uint8_t>({pcduSwitches::INIT_STATE_SUS_REDUNDANT}));
localDataPoolMap.emplace(P60System::PDU2_OUT_EN_DEPLOYMENT_MECHANISM,
new PoolEntry<uint8_t>({pcduSwitches::INIT_STATE_DEPLOYMENT_MECHANISM}));
localDataPoolMap.emplace(P60System::PDU2_OUT_EN_PAYLOAD_PCDU_CH6,
new PoolEntry<uint8_t>({pcduSwitches::INIT_STATE_PAYLOAD_PCDU_CH6}));
localDataPoolMap.emplace(P60System::PDU2_OUT_EN_ACS_BOARD_SIDE_B,
new PoolEntry<uint8_t>({pcduSwitches::INIT_STATE_ACS_BOARD_SIDE_B}));
localDataPoolMap.emplace(P60System::PDU2_OUT_EN_PAYLOAD_CAMERA,
new PoolEntry<uint8_t>({pcduSwitches::INIT_STATE_PAYLOAD_CAMERA}));
localDataPoolMap.emplace(P60System::PDU2_BOOTCAUSE, new PoolEntry<uint32_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU2_BOOTCNT, new PoolEntry<uint32_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU2_UPTIME, new PoolEntry<uint32_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU2_RESETCAUSE, new PoolEntry<uint16_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU2_BATT_MODE, new PoolEntry<uint8_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU2_BOOTCAUSE, new PoolEntry<uint32_t>({0}));
localDataPoolMap.emplace(P60System::PDU2_BOOTCNT, new PoolEntry<uint32_t>({0}));
localDataPoolMap.emplace(P60System::PDU2_UPTIME, new PoolEntry<uint32_t>({0}));
localDataPoolMap.emplace(P60System::PDU2_RESETCAUSE, new PoolEntry<uint16_t>({0}));
localDataPoolMap.emplace(P60System::PDU2_BATT_MODE, new PoolEntry<uint8_t>({0}));
localDataPoolMap.emplace(P60System::PDU2_LATCHUP_Q7S, new PoolEntry<uint16_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU2_LATCHUP_PAYLOAD_PCDU_CH1, new PoolEntry<uint16_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU2_LATCHUP_RW, new PoolEntry<uint16_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU2_LATCHUP_TCS_BOARD_HEATER_IN, new PoolEntry<uint16_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU2_LATCHUP_TCS_BOARD_HEATER_IN, new PoolEntry<uint16_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU2_LATCHUP_SUS_REDUNDANT, new PoolEntry<uint16_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU2_LATCHUP_DEPLOYMENT_MECHANISM, new PoolEntry<uint16_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU2_LATCHUP_PAYLOAD_PCDU_CH6, new PoolEntry<uint16_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU2_LATCHUP_ACS_BOARD_SIDE_B, new PoolEntry<uint16_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU2_LATCHUP_PAYLOAD_CAMERA, new PoolEntry<uint16_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU2_LATCHUP_Q7S, new PoolEntry<uint16_t>({0}));
localDataPoolMap.emplace(P60System::PDU2_LATCHUP_PAYLOAD_PCDU_CH1, new PoolEntry<uint16_t>({0}));
localDataPoolMap.emplace(P60System::PDU2_LATCHUP_RW, new PoolEntry<uint16_t>({0}));
localDataPoolMap.emplace(P60System::PDU2_LATCHUP_TCS_BOARD_HEATER_IN,
new PoolEntry<uint16_t>({0}));
localDataPoolMap.emplace(P60System::PDU2_LATCHUP_TCS_BOARD_HEATER_IN,
new PoolEntry<uint16_t>({0}));
localDataPoolMap.emplace(P60System::PDU2_LATCHUP_SUS_REDUNDANT, new PoolEntry<uint16_t>({0}));
localDataPoolMap.emplace(P60System::PDU2_LATCHUP_DEPLOYMENT_MECHANISM,
new PoolEntry<uint16_t>({0}));
localDataPoolMap.emplace(P60System::PDU2_LATCHUP_PAYLOAD_PCDU_CH6, new PoolEntry<uint16_t>({0}));
localDataPoolMap.emplace(P60System::PDU2_LATCHUP_ACS_BOARD_SIDE_B, new PoolEntry<uint16_t>({0}));
localDataPoolMap.emplace(P60System::PDU2_LATCHUP_PAYLOAD_CAMERA, new PoolEntry<uint16_t>({0}));
localDataPoolMap.emplace(P60System::PDU2_DEVICE_0, new PoolEntry<uint8_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU2_DEVICE_1, new PoolEntry<uint8_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU2_DEVICE_2, new PoolEntry<uint8_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU2_DEVICE_3, new PoolEntry<uint8_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU2_DEVICE_4, new PoolEntry<uint8_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU2_DEVICE_5, new PoolEntry<uint8_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU2_DEVICE_6, new PoolEntry<uint8_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU2_DEVICE_7, new PoolEntry<uint8_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU2_DEVICE_0, new PoolEntry<uint8_t>({0}));
localDataPoolMap.emplace(P60System::PDU2_DEVICE_1, new PoolEntry<uint8_t>({0}));
localDataPoolMap.emplace(P60System::PDU2_DEVICE_2, new PoolEntry<uint8_t>({0}));
localDataPoolMap.emplace(P60System::PDU2_DEVICE_3, new PoolEntry<uint8_t>({0}));
localDataPoolMap.emplace(P60System::PDU2_DEVICE_4, new PoolEntry<uint8_t>({0}));
localDataPoolMap.emplace(P60System::PDU2_DEVICE_5, new PoolEntry<uint8_t>({0}));
localDataPoolMap.emplace(P60System::PDU2_DEVICE_6, new PoolEntry<uint8_t>({0}));
localDataPoolMap.emplace(P60System::PDU2_DEVICE_7, new PoolEntry<uint8_t>({0}));
localDataPoolMap.emplace(P60System::PDU2_DEVICE_0_STATUS, new PoolEntry<uint8_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU2_DEVICE_1_STATUS, new PoolEntry<uint8_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU2_DEVICE_2_STATUS, new PoolEntry<uint8_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU2_DEVICE_3_STATUS, new PoolEntry<uint8_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU2_DEVICE_4_STATUS, new PoolEntry<uint8_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU2_DEVICE_5_STATUS, new PoolEntry<uint8_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU2_DEVICE_6_STATUS, new PoolEntry<uint8_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU2_DEVICE_7_STATUS, new PoolEntry<uint8_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU2_DEVICE_0_STATUS, new PoolEntry<uint8_t>({0}));
localDataPoolMap.emplace(P60System::PDU2_DEVICE_1_STATUS, new PoolEntry<uint8_t>({0}));
localDataPoolMap.emplace(P60System::PDU2_DEVICE_2_STATUS, new PoolEntry<uint8_t>({0}));
localDataPoolMap.emplace(P60System::PDU2_DEVICE_3_STATUS, new PoolEntry<uint8_t>({0}));
localDataPoolMap.emplace(P60System::PDU2_DEVICE_4_STATUS, new PoolEntry<uint8_t>({0}));
localDataPoolMap.emplace(P60System::PDU2_DEVICE_5_STATUS, new PoolEntry<uint8_t>({0}));
localDataPoolMap.emplace(P60System::PDU2_DEVICE_6_STATUS, new PoolEntry<uint8_t>({0}));
localDataPoolMap.emplace(P60System::PDU2_DEVICE_7_STATUS, new PoolEntry<uint8_t>({0}));
localDataPoolMap.emplace(P60System::PDU2_WDT_CNT_GND, new PoolEntry<uint32_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU2_WDT_CNT_I2C, new PoolEntry<uint32_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU2_WDT_CNT_CAN, new PoolEntry<uint32_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU2_WDT_CNT_CSP1, new PoolEntry<uint32_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU2_WDT_CNT_CSP2, new PoolEntry<uint32_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU2_WDT_GND_LEFT, new PoolEntry<uint32_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU2_WDT_I2C_LEFT, new PoolEntry<uint32_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU2_WDT_CAN_LEFT, new PoolEntry<uint32_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU2_WDT_CSP_LEFT1, new PoolEntry<uint8_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU2_WDT_CSP_LEFT2, new PoolEntry<uint8_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU2_WDT_CNT_GND, new PoolEntry<uint32_t>({0}));
localDataPoolMap.emplace(P60System::PDU2_WDT_CNT_I2C, new PoolEntry<uint32_t>({0}));
localDataPoolMap.emplace(P60System::PDU2_WDT_CNT_CAN, new PoolEntry<uint32_t>({0}));
localDataPoolMap.emplace(P60System::PDU2_WDT_CNT_CSP1, new PoolEntry<uint32_t>({0}));
localDataPoolMap.emplace(P60System::PDU2_WDT_CNT_CSP2, new PoolEntry<uint32_t>({0}));
localDataPoolMap.emplace(P60System::PDU2_WDT_GND_LEFT, new PoolEntry<uint32_t>({0}));
localDataPoolMap.emplace(P60System::PDU2_WDT_I2C_LEFT, new PoolEntry<uint32_t>({0}));
localDataPoolMap.emplace(P60System::PDU2_WDT_CAN_LEFT, new PoolEntry<uint32_t>({0}));
localDataPoolMap.emplace(P60System::PDU2_WDT_CSP_LEFT1, new PoolEntry<uint8_t>({0}));
localDataPoolMap.emplace(P60System::PDU2_WDT_CSP_LEFT2, new PoolEntry<uint8_t>({0}));
localDataPoolMap.emplace(P60System::PDU1_CURRENT_OUT_TCS_BOARD_3V3, new PoolEntry<int16_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU1_CURRENT_OUT_SYRLINKS, new PoolEntry<int16_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU1_CURRENT_OUT_STAR_TRACKER, new PoolEntry<int16_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU1_CURRENT_OUT_MGT, new PoolEntry<int16_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU1_CURRENT_OUT_SUS_NOMINAL, new PoolEntry<int16_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU1_CURRENT_OUT_SOLAR_CELL_EXP, new PoolEntry<int16_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU1_CURRENT_OUT_PLOC, new PoolEntry<int16_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU1_CURRENT_OUT_ACS_BOARD_SIDE_A, new PoolEntry<int16_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU1_CURRENT_OUT_CHANNEL8, new PoolEntry<int16_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU1_CURRENT_OUT_TCS_BOARD_3V3, new PoolEntry<int16_t>({0}));
localDataPoolMap.emplace(P60System::PDU1_CURRENT_OUT_SYRLINKS, new PoolEntry<int16_t>({0}));
localDataPoolMap.emplace(P60System::PDU1_CURRENT_OUT_STAR_TRACKER, new PoolEntry<int16_t>({0}));
localDataPoolMap.emplace(P60System::PDU1_CURRENT_OUT_MGT, new PoolEntry<int16_t>({0}));
localDataPoolMap.emplace(P60System::PDU1_CURRENT_OUT_SUS_NOMINAL, new PoolEntry<int16_t>({0}));
localDataPoolMap.emplace(P60System::PDU1_CURRENT_OUT_SOLAR_CELL_EXP, new PoolEntry<int16_t>({0}));
localDataPoolMap.emplace(P60System::PDU1_CURRENT_OUT_PLOC, new PoolEntry<int16_t>({0}));
localDataPoolMap.emplace(P60System::PDU1_CURRENT_OUT_ACS_BOARD_SIDE_A,
new PoolEntry<int16_t>({0}));
localDataPoolMap.emplace(P60System::PDU1_CURRENT_OUT_CHANNEL8, new PoolEntry<int16_t>({0}));
localDataPoolMap.emplace(P60System::PDU1_VOLTAGE_OUT_TCS_BOARD_3V3, new PoolEntry<int16_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU1_VOLTAGE_OUT_SYRLINKS, new PoolEntry<int16_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU1_VOLTAGE_OUT_STAR_TRACKER, new PoolEntry<int16_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU1_VOLTAGE_OUT_MGT, new PoolEntry<int16_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU1_VOLTAGE_OUT_SUS_NOMINAL, new PoolEntry<int16_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU1_VOLTAGE_OUT_SOLAR_CELL_EXP, new PoolEntry<int16_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU1_VOLTAGE_OUT_PLOC, new PoolEntry<int16_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU1_VOLTAGE_OUT_ACS_BOARD_SIDE_A, new PoolEntry<int16_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU1_VOLTAGE_OUT_CHANNEL8, new PoolEntry<int16_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU1_VOLTAGE_OUT_TCS_BOARD_3V3, new PoolEntry<int16_t>({0}));
localDataPoolMap.emplace(P60System::PDU1_VOLTAGE_OUT_SYRLINKS, new PoolEntry<int16_t>({0}));
localDataPoolMap.emplace(P60System::PDU1_VOLTAGE_OUT_STAR_TRACKER, new PoolEntry<int16_t>({0}));
localDataPoolMap.emplace(P60System::PDU1_VOLTAGE_OUT_MGT, new PoolEntry<int16_t>({0}));
localDataPoolMap.emplace(P60System::PDU1_VOLTAGE_OUT_SUS_NOMINAL, new PoolEntry<int16_t>({0}));
localDataPoolMap.emplace(P60System::PDU1_VOLTAGE_OUT_SOLAR_CELL_EXP, new PoolEntry<int16_t>({0}));
localDataPoolMap.emplace(P60System::PDU1_VOLTAGE_OUT_PLOC, new PoolEntry<int16_t>({0}));
localDataPoolMap.emplace(P60System::PDU1_VOLTAGE_OUT_ACS_BOARD_SIDE_A,
new PoolEntry<int16_t>({0}));
localDataPoolMap.emplace(P60System::PDU1_VOLTAGE_OUT_CHANNEL8, new PoolEntry<int16_t>({0}));
localDataPoolMap.emplace(P60System::PDU1_VCC, new PoolEntry<int16_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU1_VBAT, new PoolEntry<int16_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU1_TEMPERATURE, new PoolEntry<int16_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU1_CONV_EN_1, new PoolEntry<uint8_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU1_CONV_EN_2, new PoolEntry<uint8_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU1_CONV_EN_3, new PoolEntry<uint8_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU1_VCC, new PoolEntry<int16_t>({0}));
localDataPoolMap.emplace(P60System::PDU1_VBAT, new PoolEntry<int16_t>({0}));
localDataPoolMap.emplace(P60System::PDU1_TEMPERATURE, new PoolEntry<int16_t>({0}));
localDataPoolMap.emplace(P60System::PDU1_CONV_EN_1, new PoolEntry<uint8_t>({0}));
localDataPoolMap.emplace(P60System::PDU1_CONV_EN_2, new PoolEntry<uint8_t>({0}));
localDataPoolMap.emplace(P60System::PDU1_CONV_EN_3, new PoolEntry<uint8_t>({0}));
localDataPoolMap.emplace(P60System::PDU1_OUT_EN_TCS_BOARD_3V3, new PoolEntry<uint8_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU1_OUT_EN_SYRLINKS, new PoolEntry<uint8_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU1_OUT_EN_STAR_TRACKER, new PoolEntry<uint8_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU1_OUT_EN_MGT, new PoolEntry<uint8_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU1_OUT_EN_SUS_NOMINAL, new PoolEntry<uint8_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU1_OUT_EN_SOLAR_CELL_EXP, new PoolEntry<uint8_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU1_OUT_EN_PLOC, new PoolEntry<uint8_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU1_OUT_EN_ACS_BOARD_SIDE_A, new PoolEntry<uint8_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU1_OUT_EN_CHANNEL8, new PoolEntry<uint8_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU1_OUT_EN_TCS_BOARD_3V3, new PoolEntry<uint8_t>({0}));
localDataPoolMap.emplace(P60System::PDU1_OUT_EN_SYRLINKS, new PoolEntry<uint8_t>({0}));
localDataPoolMap.emplace(P60System::PDU1_OUT_EN_STAR_TRACKER, new PoolEntry<uint8_t>({0}));
localDataPoolMap.emplace(P60System::PDU1_OUT_EN_MGT, new PoolEntry<uint8_t>({0}));
localDataPoolMap.emplace(P60System::PDU1_OUT_EN_SUS_NOMINAL, new PoolEntry<uint8_t>({0}));
localDataPoolMap.emplace(P60System::PDU1_OUT_EN_SOLAR_CELL_EXP, new PoolEntry<uint8_t>({0}));
localDataPoolMap.emplace(P60System::PDU1_OUT_EN_PLOC, new PoolEntry<uint8_t>({0}));
localDataPoolMap.emplace(P60System::PDU1_OUT_EN_ACS_BOARD_SIDE_A, new PoolEntry<uint8_t>({0}));
localDataPoolMap.emplace(P60System::PDU1_OUT_EN_CHANNEL8, new PoolEntry<uint8_t>({0}));
localDataPoolMap.emplace(P60System::PDU1_BOOTCAUSE, new PoolEntry<uint32_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU1_BOOTCNT, new PoolEntry<uint32_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU1_UPTIME, new PoolEntry<uint32_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU1_RESETCAUSE, new PoolEntry<uint16_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU1_BATT_MODE, new PoolEntry<uint8_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU1_BOOTCAUSE, new PoolEntry<uint32_t>({0}));
localDataPoolMap.emplace(P60System::PDU1_BOOTCNT, new PoolEntry<uint32_t>({0}));
localDataPoolMap.emplace(P60System::PDU1_UPTIME, new PoolEntry<uint32_t>({0}));
localDataPoolMap.emplace(P60System::PDU1_RESETCAUSE, new PoolEntry<uint16_t>({0}));
localDataPoolMap.emplace(P60System::PDU1_BATT_MODE, new PoolEntry<uint8_t>({0}));
localDataPoolMap.emplace(P60System::PDU1_LATCHUP_TCS_BOARD_3V3, new PoolEntry<uint16_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU1_LATCHUP_SYRLINKS, new PoolEntry<uint16_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU1_LATCHUP_STAR_TRACKER, new PoolEntry<uint16_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU1_LATCHUP_MGT, new PoolEntry<uint16_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU1_LATCHUP_SUS_NOMINAL, new PoolEntry<uint16_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU1_LATCHUP_SOLAR_CELL_EXP, new PoolEntry<uint16_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU1_LATCHUP_PLOC, new PoolEntry<uint16_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU1_LATCHUP_ACS_BOARD_SIDE_A, new PoolEntry<uint16_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU1_LATCHUP_CHANNEL8, new PoolEntry<uint16_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU1_LATCHUP_TCS_BOARD_3V3, new PoolEntry<uint16_t>({0}));
localDataPoolMap.emplace(P60System::PDU1_LATCHUP_SYRLINKS, new PoolEntry<uint16_t>({0}));
localDataPoolMap.emplace(P60System::PDU1_LATCHUP_STAR_TRACKER, new PoolEntry<uint16_t>({0}));
localDataPoolMap.emplace(P60System::PDU1_LATCHUP_MGT, new PoolEntry<uint16_t>({0}));
localDataPoolMap.emplace(P60System::PDU1_LATCHUP_SUS_NOMINAL, new PoolEntry<uint16_t>({0}));
localDataPoolMap.emplace(P60System::PDU1_LATCHUP_SOLAR_CELL_EXP, new PoolEntry<uint16_t>({0}));
localDataPoolMap.emplace(P60System::PDU1_LATCHUP_PLOC, new PoolEntry<uint16_t>({0}));
localDataPoolMap.emplace(P60System::PDU1_LATCHUP_ACS_BOARD_SIDE_A, new PoolEntry<uint16_t>({0}));
localDataPoolMap.emplace(P60System::PDU1_LATCHUP_CHANNEL8, new PoolEntry<uint16_t>({0}));
localDataPoolMap.emplace(P60System::PDU1_DEVICE_0, new PoolEntry<uint8_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU1_DEVICE_1, new PoolEntry<uint8_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU1_DEVICE_2, new PoolEntry<uint8_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU1_DEVICE_3, new PoolEntry<uint8_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU1_DEVICE_4, new PoolEntry<uint8_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU1_DEVICE_5, new PoolEntry<uint8_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU1_DEVICE_6, new PoolEntry<uint8_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU1_DEVICE_7, new PoolEntry<uint8_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU1_DEVICE_0, new PoolEntry<uint8_t>({0}));
localDataPoolMap.emplace(P60System::PDU1_DEVICE_1, new PoolEntry<uint8_t>({0}));
localDataPoolMap.emplace(P60System::PDU1_DEVICE_2, new PoolEntry<uint8_t>({0}));
localDataPoolMap.emplace(P60System::PDU1_DEVICE_3, new PoolEntry<uint8_t>({0}));
localDataPoolMap.emplace(P60System::PDU1_DEVICE_4, new PoolEntry<uint8_t>({0}));
localDataPoolMap.emplace(P60System::PDU1_DEVICE_5, new PoolEntry<uint8_t>({0}));
localDataPoolMap.emplace(P60System::PDU1_DEVICE_6, new PoolEntry<uint8_t>({0}));
localDataPoolMap.emplace(P60System::PDU1_DEVICE_7, new PoolEntry<uint8_t>({0}));
localDataPoolMap.emplace(P60System::PDU1_DEVICE_0_STATUS, new PoolEntry<uint8_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU1_DEVICE_1_STATUS, new PoolEntry<uint8_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU1_DEVICE_2_STATUS, new PoolEntry<uint8_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU1_DEVICE_3_STATUS, new PoolEntry<uint8_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU1_DEVICE_4_STATUS, new PoolEntry<uint8_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU1_DEVICE_5_STATUS, new PoolEntry<uint8_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU1_DEVICE_6_STATUS, new PoolEntry<uint8_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU1_DEVICE_7_STATUS, new PoolEntry<uint8_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU1_DEVICE_0_STATUS, new PoolEntry<uint8_t>({0}));
localDataPoolMap.emplace(P60System::PDU1_DEVICE_1_STATUS, new PoolEntry<uint8_t>({0}));
localDataPoolMap.emplace(P60System::PDU1_DEVICE_2_STATUS, new PoolEntry<uint8_t>({0}));
localDataPoolMap.emplace(P60System::PDU1_DEVICE_3_STATUS, new PoolEntry<uint8_t>({0}));
localDataPoolMap.emplace(P60System::PDU1_DEVICE_4_STATUS, new PoolEntry<uint8_t>({0}));
localDataPoolMap.emplace(P60System::PDU1_DEVICE_5_STATUS, new PoolEntry<uint8_t>({0}));
localDataPoolMap.emplace(P60System::PDU1_DEVICE_6_STATUS, new PoolEntry<uint8_t>({0}));
localDataPoolMap.emplace(P60System::PDU1_DEVICE_7_STATUS, new PoolEntry<uint8_t>({0}));
localDataPoolMap.emplace(P60System::PDU1_WDT_CNT_GND, new PoolEntry<uint32_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU1_WDT_CNT_I2C, new PoolEntry<uint32_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU1_WDT_CNT_CAN, new PoolEntry<uint32_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU1_WDT_CNT_CSP1, new PoolEntry<uint32_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU1_WDT_CNT_CSP2, new PoolEntry<uint32_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU1_WDT_GND_LEFT, new PoolEntry<uint32_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU1_WDT_I2C_LEFT, new PoolEntry<uint32_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU1_WDT_CAN_LEFT, new PoolEntry<uint32_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU1_WDT_CSP_LEFT1, new PoolEntry<uint8_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU1_WDT_CSP_LEFT2, new PoolEntry<uint8_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU1_WDT_CNT_GND, new PoolEntry<uint32_t>({0}));
localDataPoolMap.emplace(P60System::PDU1_WDT_CNT_I2C, new PoolEntry<uint32_t>({0}));
localDataPoolMap.emplace(P60System::PDU1_WDT_CNT_CAN, new PoolEntry<uint32_t>({0}));
localDataPoolMap.emplace(P60System::PDU1_WDT_CNT_CSP1, new PoolEntry<uint32_t>({0}));
localDataPoolMap.emplace(P60System::PDU1_WDT_CNT_CSP2, new PoolEntry<uint32_t>({0}));
localDataPoolMap.emplace(P60System::PDU1_WDT_GND_LEFT, new PoolEntry<uint32_t>({0}));
localDataPoolMap.emplace(P60System::PDU1_WDT_I2C_LEFT, new PoolEntry<uint32_t>({0}));
localDataPoolMap.emplace(P60System::PDU1_WDT_CAN_LEFT, new PoolEntry<uint32_t>({0}));
localDataPoolMap.emplace(P60System::PDU1_WDT_CSP_LEFT1, new PoolEntry<uint8_t>({0}));
localDataPoolMap.emplace(P60System::PDU1_WDT_CSP_LEFT2, new PoolEntry<uint8_t>({0}));
return HasReturnvaluesIF::RETURN_OK;
return HasReturnvaluesIF::RETURN_OK;
}
ReturnValue_t PCDUHandler::initializeAfterTaskCreation() {
if (executingTask != nullptr) {
pstIntervalMs = executingTask->getPeriodMs();
}
this->poolManager.initializeAfterTaskCreation();
if(executingTask != nullptr) {
pstIntervalMs = executingTask->getPeriodMs();
}
this->poolManager.initializeAfterTaskCreation();
initializeSwitchStates();
initializeSwitchStates();
return HasReturnvaluesIF::RETURN_OK;
return HasReturnvaluesIF::RETURN_OK;
}
uint32_t PCDUHandler::getPeriodicOperationFrequency() const {
return pstIntervalMs;
}
uint32_t PCDUHandler::getPeriodicOperationFrequency() const { return pstIntervalMs; }
void PCDUHandler::setTaskIF(PeriodicTaskIF* task){
executingTask = task;
}
void PCDUHandler::setTaskIF(PeriodicTaskIF* task) { executingTask = task; }
LocalPoolDataSetBase* PCDUHandler::getDataSetHandle(sid_t sid) {
if (sid == pdu2HkTableDataset.getSid()) {
return &pdu2HkTableDataset;
} else {
sif::error << "PCDUHandler::getDataSetHandle: Invalid sid" << std::endl;
return nullptr;
}
if (sid == pdu2HkTableDataset.getSid()) {
return &pdu2HkTableDataset;
} else {
sif::error << "PCDUHandler::getDataSetHandle: Invalid sid" << std::endl;
return nullptr;
}
}

View File

@ -2,120 +2,116 @@
#define MISSION_DEVICES_PCDUHANDLER_H_
#include <devices/powerSwitcherList.h>
#include <mission/devices/devicedefinitions/GomspaceDefinitions.h>
#include <mission/devices/GomspaceDeviceHandler.h>
#include <fsfw/timemanager/CCSDSTime.h>
#include <fsfw/power/PowerSwitchIF.h>
#include <fsfw/datapoollocal/HasLocalDataPoolIF.h>
#include <fsfw/objectmanager/SystemObject.h>
#include <fsfw/power/PowerSwitchIF.h>
#include <fsfw/tasks/ExecutableObjectIF.h>
#include <fsfw/objectmanager/SystemObject.h>
#include <fsfw/timemanager/CCSDSTime.h>
#include <mission/devices/GomspaceDeviceHandler.h>
#include <mission/devices/devicedefinitions/GomspaceDefinitions.h>
/**
* @brief The PCDUHandler provides a compact interface to handle all devices related to the
* control of power. This is necessary because the fsfw manages all power related
* functionalities via one power object. This includes for example the switch on and off
* of devices.
* control of power. This is necessary because the fsfw manages all power
* related functionalities via one power object. This includes for example the switch on and off of
* devices.
*/
class PCDUHandler: public PowerSwitchIF,
public HasLocalDataPoolIF,
public SystemObject,
public ExecutableObjectIF {
public:
class PCDUHandler : public PowerSwitchIF,
public HasLocalDataPoolIF,
public SystemObject,
public ExecutableObjectIF {
public:
PCDUHandler(object_id_t setObjectId, size_t cmdQueueSize = 20);
virtual ~PCDUHandler();
PCDUHandler(object_id_t setObjectId, size_t cmdQueueSize = 20);
virtual ~PCDUHandler();
virtual ReturnValue_t initialize() override;
virtual ReturnValue_t performOperation(uint8_t counter) override;
virtual void handleChangedDataset(sid_t sid,
store_address_t storeId = storeId::INVALID_STORE_ADDRESS);
virtual ReturnValue_t initialize() override;
virtual ReturnValue_t performOperation(uint8_t counter) override;
virtual void handleChangedDataset(sid_t sid, store_address_t storeId =
storeId::INVALID_STORE_ADDRESS);
virtual void sendSwitchCommand(uint8_t switchNr, ReturnValue_t onOff) const override;
virtual void sendFuseOnCommand(uint8_t fuseNr) const override;
virtual ReturnValue_t getSwitchState(uint8_t switchNr) const override;
virtual ReturnValue_t getFuseState(uint8_t fuseNr) const override;
virtual uint32_t getSwitchDelayMs(void) const override;
virtual object_id_t getObjectId() const override;
virtual LocalDataPoolManager* getHkManagerHandle() override;
virtual void sendSwitchCommand(uint8_t switchNr, ReturnValue_t onOff) const override;
virtual void sendFuseOnCommand(uint8_t fuseNr) const override;
virtual ReturnValue_t getSwitchState( uint8_t switchNr ) const override;
virtual ReturnValue_t getFuseState( uint8_t fuseNr ) const override;
virtual uint32_t getSwitchDelayMs(void) const override;
virtual object_id_t getObjectId() const override;
virtual LocalDataPoolManager* getHkManagerHandle() override;
virtual MessageQueueId_t getCommandQueue() const override;
virtual ReturnValue_t initializeLocalDataPool(localpool::DataPool& localDataPoolMap,
LocalDataPoolManager& poolManager) override;
virtual uint32_t getPeriodicOperationFrequency() const override;
virtual ReturnValue_t initializeAfterTaskCreation() override;
virtual LocalPoolDataSetBase* getDataSetHandle(sid_t sid) override;
virtual void setTaskIF(PeriodicTaskIF* task_);
virtual MessageQueueId_t getCommandQueue() const override;
virtual ReturnValue_t initializeLocalDataPool(localpool::DataPool& localDataPoolMap,
LocalDataPoolManager& poolManager) override;
virtual uint32_t getPeriodicOperationFrequency() const override;
virtual ReturnValue_t initializeAfterTaskCreation() override;
virtual LocalPoolDataSetBase* getDataSetHandle(sid_t sid) override;
virtual void setTaskIF(PeriodicTaskIF* task_);
private:
uint32_t pstIntervalMs = 0;
private:
/** Housekeeping manager. Handles updates of local pool variables. */
LocalDataPoolManager poolManager;
uint32_t pstIntervalMs = 0;
/**
* The dataset holding the hk table of PDU2. This dataset is a copy of the PDU2 HK dataset
* of the PDU2Handler. Each time the PDU2Handler updates his HK dataset, a copy is sent
* to this object via a HousekeepingMessage.
*/
PDU2::PDU2HkTableDataset pdu2HkTableDataset;
/** The timeStamp of the current pdu2HkTableDataset */
CCSDSTime::CDS_short timeStampPdu2HkDataset;
/** Housekeeping manager. Handles updates of local pool variables. */
LocalDataPoolManager poolManager;
/** Hk table dataset of PDU1 */
PDU1::PDU1HkTableDataset pdu1HkTableDataset;
/** The timeStamp of the current pdu1HkTableDataset */
CCSDSTime::CDS_short timeStampPdu1HkDataset;
/**
* The dataset holding the hk table of PDU2. This dataset is a copy of the PDU2 HK dataset
* of the PDU2Handler. Each time the PDU2Handler updates his HK dataset, a copy is sent
* to this object via a HousekeepingMessage.
*/
PDU2::PDU2HkTableDataset pdu2HkTableDataset;
/** The timeStamp of the current pdu2HkTableDataset */
CCSDSTime::CDS_short timeStampPdu2HkDataset;
uint8_t switchStates[pcduSwitches::NUMBER_OF_SWITCHES];
/**
* Pointer to the IPCStore.
* This caches the pointer received from the objectManager in the constructor.
*/
StorageManagerIF* IPCStore = nullptr;
/** Hk table dataset of PDU1 */
PDU1::PDU1HkTableDataset pdu1HkTableDataset;
/** The timeStamp of the current pdu1HkTableDataset */
CCSDSTime::CDS_short timeStampPdu1HkDataset;
/**
* Message queue to communicate with other objetcs. Used for example to receive
* local pool messages from ACU, PDU1 and PDU2.
*/
MessageQueueIF* commandQueue = nullptr;
uint8_t switchStates[pcduSwitches::NUMBER_OF_SWITCHES];
/**
* Pointer to the IPCStore.
* This caches the pointer received from the objectManager in the constructor.
*/
StorageManagerIF *IPCStore = nullptr;
size_t cmdQueueSize;
/**
* Message queue to communicate with other objetcs. Used for example to receive
* local pool messages from ACU, PDU1 and PDU2.
*/
MessageQueueIF* commandQueue = nullptr;
PeriodicTaskIF* executingTask = nullptr;
size_t cmdQueueSize;
void readCommandQueue();
PeriodicTaskIF* executingTask = nullptr;
/**
* @brief This function sets all switchStates to the initial switch configuration of the
* two PDUs after reboot.
*/
void initializeSwitchStates();
void readCommandQueue();
/**
* @brief Updates all switchStates related to the PDU2.
* Function is called each time a new hk dataset has been received from the PDU2Handler.
*/
void updatePdu2SwitchStates();
/**
* @brief This function sets all switchStates to the initial switch configuration of the
* two PDUs after reboot.
*/
void initializeSwitchStates();
/**
* @brief Updates all switchStates related to the PDU1. Called each time the PDU1Handler
* sends a new hk dataset.
*/
void updatePdu1SwitchStates();
/**
* @brief Updates all switchStates related to the PDU2.
* Function is called each time a new hk dataset has been received from the PDU2Handler.
*/
void updatePdu2SwitchStates();
/**
* @brief Updates all switchStates related to the PDU1. Called each time the PDU1Handler
* sends a new hk dataset.
*/
void updatePdu1SwitchStates();
/**
* @brief In case of an update snapshot message this function handles the update of the
* local dataset.
* @param storeId Storage id of updated dataset.
* @param dataset Pointer to the local dataset.
* @param datasetTimeStamp Pointer to a variable which will hold the timestamp of the updated
* dataset.
*/
void updateHkTableDataset(store_address_t storeId, LocalPoolDataSetBase* dataset,
CCSDSTime::CDS_short* datasetTimeStamp);
/**
* @brief In case of an update snapshot message this function handles the update of the
* local dataset.
* @param storeId Storage id of updated dataset.
* @param dataset Pointer to the local dataset.
* @param datasetTimeStamp Pointer to a variable which will hold the timestamp of the updated
* dataset.
*/
void updateHkTableDataset(store_address_t storeId, LocalPoolDataSetBase* dataset,
CCSDSTime::CDS_short* datasetTimeStamp);
};
#endif /* MISSION_DEVICES_PCDUHANDLER_H_ */

View File

@ -1,402 +1,421 @@
#include "OBSWConfig.h"
#include "PDU1Handler.h"
#include <fsfw/datapool/PoolReadGuard.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) {
}
#include "OBSWConfig.h"
PDU1Handler::~PDU1Handler() {
}
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) {}
ReturnValue_t PDU1Handler::buildNormalDeviceCommand(
DeviceCommandId_t * id) {
*id = GOMSPACE::REQUEST_HK_TABLE;
return buildCommandFromCommand(*id, NULL, 0);
PDU1Handler::~PDU1Handler() {}
ReturnValue_t PDU1Handler::buildNormalDeviceCommand(DeviceCommandId_t *id) {
*id = GOMSPACE::REQUEST_HK_TABLE;
return buildCommandFromCommand(*id, NULL, 0);
}
void PDU1Handler::letChildHandleHkReply(DeviceCommandId_t id, const uint8_t *packet) {
parseHkTableReply(packet);
handleDeviceTM(&pdu1HkTableDataset, id, true);
parseHkTableReply(packet);
handleDeviceTM(&pdu1HkTableDataset, id, true);
#if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_PDU1 == 1
pdu1HkTableDataset.read();
sif::info << "PDU1 TCS Board voltage: " << pdu1HkTableDataset.voltageOutTCSBoard3V3
pdu1HkTableDataset.read();
sif::info << "PDU1 TCS Board voltage: " << pdu1HkTableDataset.voltageOutTCSBoard3V3 << std::endl;
sif::info << "PDU1 Syrlinks voltage: " << pdu1HkTableDataset.voltageOutSyrlinks << std::endl;
sif::info << "PDU1 star tracker voltage: " << pdu1HkTableDataset.voltageOutStarTracker
<< std::endl;
sif::info << "PDU1 Syrlinks voltage: " << pdu1HkTableDataset.voltageOutSyrlinks << std::endl;
sif::info << "PDU1 star tracker voltage: " << pdu1HkTableDataset.voltageOutStarTracker
sif::info << "PDU1 MGT voltage: " << pdu1HkTableDataset.voltageOutMGT << std::endl;
sif::info << "PDU1 SUS nominal voltage: " << pdu1HkTableDataset.voltageOutSUSNominal << std::endl;
sif::info << "PDU1 solar cell experiment voltage: " << pdu1HkTableDataset.voltageOutSolarCellExp
<< std::endl;
sif::info << "PDU1 MGT voltage: " << pdu1HkTableDataset.voltageOutMGT << std::endl;
sif::info << "PDU1 SUS nominal voltage: " << pdu1HkTableDataset.voltageOutSUSNominal
sif::info << "PDU1 PLOC voltage: " << pdu1HkTableDataset.voltageOutPLOC << std::endl;
sif::info << "PDU1 ACS Side A voltage: " << pdu1HkTableDataset.voltageOutACSBoardSideA
<< std::endl;
sif::info << "PDU1 solar cell experiment voltage: " << pdu1HkTableDataset.voltageOutSolarCellExp
<< std::endl;
sif::info << "PDU1 PLOC voltage: " << pdu1HkTableDataset.voltageOutPLOC << std::endl;
sif::info << "PDU1 ACS Side A voltage: " << pdu1HkTableDataset.voltageOutACSBoardSideA
<< std::endl;
sif::info << "PDU1 channel 8 voltage: " << pdu1HkTableDataset.voltageOutACSBoardSideA
sif::info << "PDU1 channel 8 voltage: " << pdu1HkTableDataset.voltageOutACSBoardSideA
<< std::endl;
sif::info << "PDU1 TCS Board current: " << pdu1HkTableDataset.currentOutTCSBoard3V3
sif::info << "PDU1 TCS Board current: " << pdu1HkTableDataset.currentOutTCSBoard3V3 << std::endl;
sif::info << "PDU1 Syrlinks current: " << pdu1HkTableDataset.currentOutSyrlinks << std::endl;
sif::info << "PDU1 star tracker current: " << pdu1HkTableDataset.currentOutStarTracker
<< std::endl;
sif::info << "PDU1 Syrlinks current: " << pdu1HkTableDataset.currentOutSyrlinks << std::endl;
sif::info << "PDU1 star tracker current: " << pdu1HkTableDataset.currentOutStarTracker
sif::info << "PDU1 MGT current: " << pdu1HkTableDataset.currentOutMGT << std::endl;
sif::info << "PDU1 SUS nominal current: " << pdu1HkTableDataset.currentOutSUSNominal << std::endl;
sif::info << "PDU1 solar cell experiment current: " << pdu1HkTableDataset.currentOutSolarCellExp
<< std::endl;
sif::info << "PDU1 MGT current: " << pdu1HkTableDataset.currentOutMGT << std::endl;
sif::info << "PDU1 SUS nominal current: " << pdu1HkTableDataset.currentOutSUSNominal
sif::info << "PDU1 PLOC current: " << pdu1HkTableDataset.currentOutPLOC << std::endl;
sif::info << "PDU1 ACS Side A current: " << pdu1HkTableDataset.currentOutACSBoardSideA
<< std::endl;
sif::info << "PDU1 solar cell experiment current: " << pdu1HkTableDataset.currentOutSolarCellExp
sif::info << "PDU1 channel 8 current: " << pdu1HkTableDataset.currentOutChannel8 << std::endl;
printOutputSwitchStates();
sif::info << "PDU1 battery mode: " << static_cast<unsigned int>(pdu1HkTableDataset.battMode.value)
<< std::endl;
sif::info << "PDU1 PLOC current: " << pdu1HkTableDataset.currentOutPLOC << std::endl;
sif::info << "PDU1 ACS Side A current: " << pdu1HkTableDataset.currentOutACSBoardSideA
sif::info << "PDU1 VCC: " << pdu1HkTableDataset.vcc << " mV" << std::endl;
float vbat = pdu1HkTableDataset.vbat.value * 0.001;
sif::info << "PDU1 VBAT: " << vbat << "V" << std::endl;
float temperatureC = pdu1HkTableDataset.temperature.value * 0.1;
sif::info << "PDU1 Temperature: " << temperatureC << " °C" << std::endl;
sif::info << "PDU1 csp1 watchdog pings before reboot: "
<< static_cast<unsigned int>(pdu1HkTableDataset.csp1WatchdogPingsLeft.value)
<< std::endl;
sif::info << "PDU1 channel 8 current: " << pdu1HkTableDataset.currentOutChannel8
sif::info << "PDU1 csp2 watchdog pings before reboot: "
<< static_cast<unsigned int>(pdu1HkTableDataset.csp2WatchdogPingsLeft.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;
float temperatureC = pdu1HkTableDataset.temperature.value * 0.1;
sif::info << "PDU1 Temperature: " << temperatureC << " °C" << std::endl;
sif::info << "PDU1 csp1 watchdog pings before reboot: "
<< static_cast<unsigned int>(pdu1HkTableDataset.csp1WatchdogPingsLeft.value) << std::endl;
sif::info << "PDU1 csp2 watchdog pings before reboot: "
<< static_cast<unsigned int>(pdu1HkTableDataset.csp2WatchdogPingsLeft.value) << std::endl;
pdu1HkTableDataset.commit();
pdu1HkTableDataset.commit();
#endif
}
void PDU1Handler::parseHkTableReply(const uint8_t *packet) {
uint16_t dataOffset = 0;
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;
pdu1HkTableDataset.currentOutTCSBoard3V3 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
pdu1HkTableDataset.currentOutSyrlinks = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
pdu1HkTableDataset.currentOutStarTracker = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
pdu1HkTableDataset.currentOutMGT = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
pdu1HkTableDataset.currentOutSUSNominal = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
pdu1HkTableDataset.currentOutSolarCellExp = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
pdu1HkTableDataset.currentOutPLOC = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
pdu1HkTableDataset.currentOutACSBoardSideA = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
pdu1HkTableDataset.currentOutChannel8 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
uint16_t dataOffset = 0;
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;
pdu1HkTableDataset.currentOutTCSBoard3V3 =
*(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
pdu1HkTableDataset.currentOutSyrlinks = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
pdu1HkTableDataset.currentOutStarTracker =
*(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
pdu1HkTableDataset.currentOutMGT = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
pdu1HkTableDataset.currentOutSUSNominal =
*(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
pdu1HkTableDataset.currentOutSolarCellExp =
*(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
pdu1HkTableDataset.currentOutPLOC = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
pdu1HkTableDataset.currentOutACSBoardSideA =
*(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
pdu1HkTableDataset.currentOutChannel8 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
pdu1HkTableDataset.voltageOutTCSBoard3V3 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
pdu1HkTableDataset.voltageOutSyrlinks = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
pdu1HkTableDataset.voltageOutStarTracker = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
pdu1HkTableDataset.voltageOutMGT = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
pdu1HkTableDataset.voltageOutSUSNominal = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
pdu1HkTableDataset.voltageOutSolarCellExp = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
pdu1HkTableDataset.voltageOutPLOC = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
pdu1HkTableDataset.voltageOutACSBoardSideA = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
pdu1HkTableDataset.voltageOutChannel8 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
pdu1HkTableDataset.voltageOutTCSBoard3V3 =
*(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
pdu1HkTableDataset.voltageOutSyrlinks = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
pdu1HkTableDataset.voltageOutStarTracker =
*(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
pdu1HkTableDataset.voltageOutMGT = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
pdu1HkTableDataset.voltageOutSUSNominal =
*(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
pdu1HkTableDataset.voltageOutSolarCellExp =
*(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
pdu1HkTableDataset.voltageOutPLOC = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
pdu1HkTableDataset.voltageOutACSBoardSideA =
*(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
pdu1HkTableDataset.voltageOutChannel8 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
pdu1HkTableDataset.vcc = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
pdu1HkTableDataset.vbat = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
pdu1HkTableDataset.temperature = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
pdu1HkTableDataset.vcc = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
pdu1HkTableDataset.vbat = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
pdu1HkTableDataset.temperature = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
pdu1HkTableDataset.converterEnable1 = *(packet + dataOffset);
dataOffset += 3;
pdu1HkTableDataset.converterEnable2 = *(packet + dataOffset);
dataOffset += 3;
pdu1HkTableDataset.converterEnable3 = *(packet + dataOffset);
dataOffset += 3;
pdu1HkTableDataset.converterEnable1 = *(packet + dataOffset);
dataOffset += 3;
pdu1HkTableDataset.converterEnable2 = *(packet + dataOffset);
dataOffset += 3;
pdu1HkTableDataset.converterEnable3 = *(packet + dataOffset);
dataOffset += 3;
pdu1HkTableDataset.outEnabledTCSBoard3V3 = *(packet + dataOffset);
dataOffset += 3;
pdu1HkTableDataset.outEnabledSyrlinks = *(packet + dataOffset);
dataOffset += 3;
pdu1HkTableDataset.outEnabledStarTracker = *(packet + dataOffset);
dataOffset += 3;
pdu1HkTableDataset.outEnabledMGT = *(packet + dataOffset);
dataOffset += 3;
pdu1HkTableDataset.outEnabledSUSNominal = *(packet + dataOffset);
dataOffset += 3;
pdu1HkTableDataset.outEnabledSolarCellExp = *(packet + dataOffset);
dataOffset += 3;
pdu1HkTableDataset.outEnabledPLOC = *(packet + dataOffset);
dataOffset += 3;
pdu1HkTableDataset.outEnabledAcsBoardSideA = *(packet + dataOffset);
dataOffset += 3;
pdu1HkTableDataset.outEnabledChannel8 = *(packet + dataOffset);
dataOffset += 3;
pdu1HkTableDataset.outEnabledTCSBoard3V3 = *(packet + dataOffset);
dataOffset += 3;
pdu1HkTableDataset.outEnabledSyrlinks = *(packet + dataOffset);
dataOffset += 3;
pdu1HkTableDataset.outEnabledStarTracker = *(packet + dataOffset);
dataOffset += 3;
pdu1HkTableDataset.outEnabledMGT = *(packet + dataOffset);
dataOffset += 3;
pdu1HkTableDataset.outEnabledSUSNominal = *(packet + dataOffset);
dataOffset += 3;
pdu1HkTableDataset.outEnabledSolarCellExp = *(packet + dataOffset);
dataOffset += 3;
pdu1HkTableDataset.outEnabledPLOC = *(packet + dataOffset);
dataOffset += 3;
pdu1HkTableDataset.outEnabledAcsBoardSideA = *(packet + dataOffset);
dataOffset += 3;
pdu1HkTableDataset.outEnabledChannel8 = *(packet + dataOffset);
dataOffset += 3;
pdu1HkTableDataset.bootcause = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3);
dataOffset += 6;
pdu1HkTableDataset.bootcount = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3);
dataOffset += 6;
pdu1HkTableDataset.uptime = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3);
dataOffset += 6;
pdu1HkTableDataset.resetcause = *(packet + dataOffset + 1) << 8 | *(packet + dataOffset);
dataOffset += 4;
pdu1HkTableDataset.battMode = *(packet + dataOffset);
/* +10 because here begins the second gomspace csp packet */
dataOffset += 3 + 10;
pdu1HkTableDataset.bootcause = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 |
*(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3);
dataOffset += 6;
pdu1HkTableDataset.bootcount = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 |
*(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3);
dataOffset += 6;
pdu1HkTableDataset.uptime = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 |
*(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3);
dataOffset += 6;
pdu1HkTableDataset.resetcause = *(packet + dataOffset + 1) << 8 | *(packet + dataOffset);
dataOffset += 4;
pdu1HkTableDataset.battMode = *(packet + dataOffset);
/* +10 because here begins the second gomspace csp packet */
dataOffset += 3 + 10;
pdu1HkTableDataset.latchupsTcsBoard3V3 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
pdu1HkTableDataset.latchupsSyrlinks = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
pdu1HkTableDataset.latchupsStarTracker = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
pdu1HkTableDataset.latchupsMgt = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
pdu1HkTableDataset.latchupsSusNominal = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
pdu1HkTableDataset.latchupsSolarCellExp = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
pdu1HkTableDataset.latchupsPloc = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
pdu1HkTableDataset.latchupsAcsBoardSideA = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
pdu1HkTableDataset.latchupsChannel8 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
pdu1HkTableDataset.latchupsTcsBoard3V3 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
pdu1HkTableDataset.latchupsSyrlinks = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
pdu1HkTableDataset.latchupsStarTracker = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
pdu1HkTableDataset.latchupsMgt = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
pdu1HkTableDataset.latchupsSusNominal = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
pdu1HkTableDataset.latchupsSolarCellExp =
*(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
pdu1HkTableDataset.latchupsPloc = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
pdu1HkTableDataset.latchupsAcsBoardSideA =
*(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
pdu1HkTableDataset.latchupsChannel8 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
pdu1HkTableDataset.device0 = *(packet + dataOffset);
dataOffset += 3;
pdu1HkTableDataset.device1 = *(packet + dataOffset);
dataOffset += 3;
pdu1HkTableDataset.device2 = *(packet + dataOffset);
dataOffset += 3;
pdu1HkTableDataset.device3 = *(packet + dataOffset);
dataOffset += 3;
pdu1HkTableDataset.device4 = *(packet + dataOffset);
dataOffset += 3;
pdu1HkTableDataset.device5 = *(packet + dataOffset);
dataOffset += 3;
pdu1HkTableDataset.device6 = *(packet + dataOffset);
dataOffset += 3;
pdu1HkTableDataset.device7 = *(packet + dataOffset);
dataOffset += 3;
pdu1HkTableDataset.device0 = *(packet + dataOffset);
dataOffset += 3;
pdu1HkTableDataset.device1 = *(packet + dataOffset);
dataOffset += 3;
pdu1HkTableDataset.device2 = *(packet + dataOffset);
dataOffset += 3;
pdu1HkTableDataset.device3 = *(packet + dataOffset);
dataOffset += 3;
pdu1HkTableDataset.device4 = *(packet + dataOffset);
dataOffset += 3;
pdu1HkTableDataset.device5 = *(packet + dataOffset);
dataOffset += 3;
pdu1HkTableDataset.device6 = *(packet + dataOffset);
dataOffset += 3;
pdu1HkTableDataset.device7 = *(packet + dataOffset);
dataOffset += 3;
pdu1HkTableDataset.device0Status = *(packet + dataOffset);
dataOffset += 3;
pdu1HkTableDataset.device1Status = *(packet + dataOffset);
dataOffset += 3;
pdu1HkTableDataset.device2Status = *(packet + dataOffset);
dataOffset += 3;
pdu1HkTableDataset.device3Status = *(packet + dataOffset);
dataOffset += 3;
pdu1HkTableDataset.device4Status = *(packet + dataOffset);
dataOffset += 3;
pdu1HkTableDataset.device5Status = *(packet + dataOffset);
dataOffset += 3;
pdu1HkTableDataset.device6Status = *(packet + dataOffset);
dataOffset += 3;
pdu1HkTableDataset.device7Status = *(packet + dataOffset);
dataOffset += 3;
pdu1HkTableDataset.device0Status = *(packet + dataOffset);
dataOffset += 3;
pdu1HkTableDataset.device1Status = *(packet + dataOffset);
dataOffset += 3;
pdu1HkTableDataset.device2Status = *(packet + dataOffset);
dataOffset += 3;
pdu1HkTableDataset.device3Status = *(packet + dataOffset);
dataOffset += 3;
pdu1HkTableDataset.device4Status = *(packet + dataOffset);
dataOffset += 3;
pdu1HkTableDataset.device5Status = *(packet + dataOffset);
dataOffset += 3;
pdu1HkTableDataset.device6Status = *(packet + dataOffset);
dataOffset += 3;
pdu1HkTableDataset.device7Status = *(packet + dataOffset);
dataOffset += 3;
pdu1HkTableDataset.gndWdtReboots = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3);
dataOffset += 6;
pdu1HkTableDataset.i2cWdtReboots = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3);
dataOffset += 6;
pdu1HkTableDataset.canWdtReboots = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3);
dataOffset += 6;
pdu1HkTableDataset.csp1WdtReboots = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3);
dataOffset += 6;
pdu1HkTableDataset.csp2WdtReboots = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3);
dataOffset += 6;
pdu1HkTableDataset.groundWatchdogSecondsLeft = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3);
dataOffset += 6;
pdu1HkTableDataset.i2cWatchdogSecondsLeft = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3);
dataOffset += 6;
pdu1HkTableDataset.canWatchdogSecondsLeft = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3);
dataOffset += 6;
pdu1HkTableDataset.csp1WatchdogPingsLeft = *(packet + dataOffset);
dataOffset += 3;
pdu1HkTableDataset.csp2WatchdogPingsLeft = *(packet + dataOffset);
pdu1HkTableDataset.gndWdtReboots = *(packet + dataOffset) << 24 |
*(packet + dataOffset + 1) << 16 |
*(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3);
dataOffset += 6;
pdu1HkTableDataset.i2cWdtReboots = *(packet + dataOffset) << 24 |
*(packet + dataOffset + 1) << 16 |
*(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3);
dataOffset += 6;
pdu1HkTableDataset.canWdtReboots = *(packet + dataOffset) << 24 |
*(packet + dataOffset + 1) << 16 |
*(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3);
dataOffset += 6;
pdu1HkTableDataset.csp1WdtReboots = *(packet + dataOffset) << 24 |
*(packet + dataOffset + 1) << 16 |
*(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3);
dataOffset += 6;
pdu1HkTableDataset.csp2WdtReboots = *(packet + dataOffset) << 24 |
*(packet + dataOffset + 1) << 16 |
*(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3);
dataOffset += 6;
pdu1HkTableDataset.groundWatchdogSecondsLeft =
*(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 |
*(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3);
dataOffset += 6;
pdu1HkTableDataset.i2cWatchdogSecondsLeft =
*(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 |
*(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3);
dataOffset += 6;
pdu1HkTableDataset.canWatchdogSecondsLeft =
*(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 |
*(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3);
dataOffset += 6;
pdu1HkTableDataset.csp1WatchdogPingsLeft = *(packet + dataOffset);
dataOffset += 3;
pdu1HkTableDataset.csp2WatchdogPingsLeft = *(packet + dataOffset);
pdu1HkTableDataset.setChanged(true);
if(not pdu1HkTableDataset.isValid()) {
pdu1HkTableDataset.setValidity(true, true);
}
pdu1HkTableDataset.setChanged(true);
if (not pdu1HkTableDataset.isValid()) {
pdu1HkTableDataset.setValidity(true, true);
}
}
ReturnValue_t PDU1Handler::initializeLocalDataPool(
localpool::DataPool &localDataPoolMap, LocalDataPoolManager &poolManager) {
ReturnValue_t PDU1Handler::initializeLocalDataPool(localpool::DataPool &localDataPoolMap,
LocalDataPoolManager &poolManager) {
localDataPoolMap.emplace(P60System::PDU1_CURRENT_OUT_TCS_BOARD_3V3, new PoolEntry<int16_t>({0}));
localDataPoolMap.emplace(P60System::PDU1_CURRENT_OUT_SYRLINKS, new PoolEntry<int16_t>({0}));
localDataPoolMap.emplace(P60System::PDU1_CURRENT_OUT_STAR_TRACKER, new PoolEntry<int16_t>({0}));
localDataPoolMap.emplace(P60System::PDU1_CURRENT_OUT_MGT, new PoolEntry<int16_t>({0}));
localDataPoolMap.emplace(P60System::PDU1_CURRENT_OUT_SUS_NOMINAL, new PoolEntry<int16_t>({0}));
localDataPoolMap.emplace(P60System::PDU1_CURRENT_OUT_SOLAR_CELL_EXP, new PoolEntry<int16_t>({0}));
localDataPoolMap.emplace(P60System::PDU1_CURRENT_OUT_PLOC, new PoolEntry<int16_t>({0}));
localDataPoolMap.emplace(P60System::PDU1_CURRENT_OUT_ACS_BOARD_SIDE_A,
new PoolEntry<int16_t>({0}));
localDataPoolMap.emplace(P60System::PDU1_CURRENT_OUT_CHANNEL8, new PoolEntry<int16_t>({0}));
localDataPoolMap.emplace(P60System::PDU1_CURRENT_OUT_TCS_BOARD_3V3, new PoolEntry<int16_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU1_CURRENT_OUT_SYRLINKS, new PoolEntry<int16_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU1_CURRENT_OUT_STAR_TRACKER, new PoolEntry<int16_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU1_CURRENT_OUT_MGT, new PoolEntry<int16_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU1_CURRENT_OUT_SUS_NOMINAL, new PoolEntry<int16_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU1_CURRENT_OUT_SOLAR_CELL_EXP, new PoolEntry<int16_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU1_CURRENT_OUT_PLOC, new PoolEntry<int16_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU1_CURRENT_OUT_ACS_BOARD_SIDE_A, new PoolEntry<int16_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU1_CURRENT_OUT_CHANNEL8, new PoolEntry<int16_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU1_VOLTAGE_OUT_TCS_BOARD_3V3, new PoolEntry<int16_t>({0}));
localDataPoolMap.emplace(P60System::PDU1_VOLTAGE_OUT_SYRLINKS, new PoolEntry<int16_t>({0}));
localDataPoolMap.emplace(P60System::PDU1_VOLTAGE_OUT_STAR_TRACKER, new PoolEntry<int16_t>({0}));
localDataPoolMap.emplace(P60System::PDU1_VOLTAGE_OUT_MGT, new PoolEntry<int16_t>({0}));
localDataPoolMap.emplace(P60System::PDU1_VOLTAGE_OUT_SUS_NOMINAL, new PoolEntry<int16_t>({0}));
localDataPoolMap.emplace(P60System::PDU1_VOLTAGE_OUT_SOLAR_CELL_EXP, new PoolEntry<int16_t>({0}));
localDataPoolMap.emplace(P60System::PDU1_VOLTAGE_OUT_PLOC, new PoolEntry<int16_t>({0}));
localDataPoolMap.emplace(P60System::PDU1_VOLTAGE_OUT_ACS_BOARD_SIDE_A,
new PoolEntry<int16_t>({0}));
localDataPoolMap.emplace(P60System::PDU1_VOLTAGE_OUT_CHANNEL8, new PoolEntry<int16_t>({0}));
localDataPoolMap.emplace(P60System::PDU1_VOLTAGE_OUT_TCS_BOARD_3V3, new PoolEntry<int16_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU1_VOLTAGE_OUT_SYRLINKS, new PoolEntry<int16_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU1_VOLTAGE_OUT_STAR_TRACKER, new PoolEntry<int16_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU1_VOLTAGE_OUT_MGT, new PoolEntry<int16_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU1_VOLTAGE_OUT_SUS_NOMINAL, new PoolEntry<int16_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU1_VOLTAGE_OUT_SOLAR_CELL_EXP, new PoolEntry<int16_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU1_VOLTAGE_OUT_PLOC, new PoolEntry<int16_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU1_VOLTAGE_OUT_ACS_BOARD_SIDE_A, new PoolEntry<int16_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU1_VOLTAGE_OUT_CHANNEL8, new PoolEntry<int16_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU1_VCC, new PoolEntry<int16_t>({0}));
localDataPoolMap.emplace(P60System::PDU1_VBAT, new PoolEntry<int16_t>({0}));
localDataPoolMap.emplace(P60System::PDU1_TEMPERATURE, new PoolEntry<int16_t>({0}));
localDataPoolMap.emplace(P60System::PDU1_CONV_EN_1, new PoolEntry<uint8_t>({0}));
localDataPoolMap.emplace(P60System::PDU1_CONV_EN_2, new PoolEntry<uint8_t>({0}));
localDataPoolMap.emplace(P60System::PDU1_CONV_EN_3, new PoolEntry<uint8_t>({0}));
localDataPoolMap.emplace(P60System::PDU1_VCC, new PoolEntry<int16_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU1_VBAT, new PoolEntry<int16_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU1_TEMPERATURE, new PoolEntry<int16_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU1_CONV_EN_1, new PoolEntry<uint8_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU1_CONV_EN_2, new PoolEntry<uint8_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU1_CONV_EN_3, new PoolEntry<uint8_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU1_OUT_EN_TCS_BOARD_3V3, new PoolEntry<uint8_t>({0}));
localDataPoolMap.emplace(P60System::PDU1_OUT_EN_SYRLINKS, new PoolEntry<uint8_t>({0}));
localDataPoolMap.emplace(P60System::PDU1_OUT_EN_STAR_TRACKER, new PoolEntry<uint8_t>({0}));
localDataPoolMap.emplace(P60System::PDU1_OUT_EN_MGT, new PoolEntry<uint8_t>({0}));
localDataPoolMap.emplace(P60System::PDU1_OUT_EN_SUS_NOMINAL, new PoolEntry<uint8_t>({0}));
localDataPoolMap.emplace(P60System::PDU1_OUT_EN_SOLAR_CELL_EXP, new PoolEntry<uint8_t>({0}));
localDataPoolMap.emplace(P60System::PDU1_OUT_EN_PLOC, new PoolEntry<uint8_t>({0}));
localDataPoolMap.emplace(P60System::PDU1_OUT_EN_ACS_BOARD_SIDE_A, new PoolEntry<uint8_t>({0}));
localDataPoolMap.emplace(P60System::PDU1_OUT_EN_CHANNEL8, new PoolEntry<uint8_t>({0}));
localDataPoolMap.emplace(P60System::PDU1_OUT_EN_TCS_BOARD_3V3, new PoolEntry<uint8_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU1_OUT_EN_SYRLINKS, new PoolEntry<uint8_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU1_OUT_EN_STAR_TRACKER, new PoolEntry<uint8_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU1_OUT_EN_MGT, new PoolEntry<uint8_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU1_OUT_EN_SUS_NOMINAL, new PoolEntry<uint8_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU1_OUT_EN_SOLAR_CELL_EXP, new PoolEntry<uint8_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU1_OUT_EN_PLOC, new PoolEntry<uint8_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU1_OUT_EN_ACS_BOARD_SIDE_A, new PoolEntry<uint8_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU1_OUT_EN_CHANNEL8, new PoolEntry<uint8_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU1_BOOTCAUSE, new PoolEntry<uint32_t>({0}));
localDataPoolMap.emplace(P60System::PDU1_BOOTCNT, new PoolEntry<uint32_t>({0}));
localDataPoolMap.emplace(P60System::PDU1_UPTIME, new PoolEntry<uint32_t>({0}));
localDataPoolMap.emplace(P60System::PDU1_RESETCAUSE, new PoolEntry<uint16_t>({0}));
localDataPoolMap.emplace(P60System::PDU1_BATT_MODE, new PoolEntry<uint8_t>({0}));
localDataPoolMap.emplace(P60System::PDU1_BOOTCAUSE, new PoolEntry<uint32_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU1_BOOTCNT, new PoolEntry<uint32_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU1_UPTIME, new PoolEntry<uint32_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU1_RESETCAUSE, new PoolEntry<uint16_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU1_BATT_MODE, new PoolEntry<uint8_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU1_LATCHUP_TCS_BOARD_3V3, new PoolEntry<uint16_t>({0}));
localDataPoolMap.emplace(P60System::PDU1_LATCHUP_SYRLINKS, new PoolEntry<uint16_t>({0}));
localDataPoolMap.emplace(P60System::PDU1_LATCHUP_STAR_TRACKER, new PoolEntry<uint16_t>({0}));
localDataPoolMap.emplace(P60System::PDU1_LATCHUP_MGT, new PoolEntry<uint16_t>({0}));
localDataPoolMap.emplace(P60System::PDU1_LATCHUP_SUS_NOMINAL, new PoolEntry<uint16_t>({0}));
localDataPoolMap.emplace(P60System::PDU1_LATCHUP_SOLAR_CELL_EXP, new PoolEntry<uint16_t>({0}));
localDataPoolMap.emplace(P60System::PDU1_LATCHUP_PLOC, new PoolEntry<uint16_t>({0}));
localDataPoolMap.emplace(P60System::PDU1_LATCHUP_ACS_BOARD_SIDE_A, new PoolEntry<uint16_t>({0}));
localDataPoolMap.emplace(P60System::PDU1_LATCHUP_CHANNEL8, new PoolEntry<uint16_t>({0}));
localDataPoolMap.emplace(P60System::PDU1_LATCHUP_TCS_BOARD_3V3, new PoolEntry<uint16_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU1_LATCHUP_SYRLINKS, new PoolEntry<uint16_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU1_LATCHUP_STAR_TRACKER, new PoolEntry<uint16_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU1_LATCHUP_MGT, new PoolEntry<uint16_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU1_LATCHUP_SUS_NOMINAL, new PoolEntry<uint16_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU1_LATCHUP_SOLAR_CELL_EXP, new PoolEntry<uint16_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU1_LATCHUP_PLOC, new PoolEntry<uint16_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU1_LATCHUP_ACS_BOARD_SIDE_A, new PoolEntry<uint16_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU1_LATCHUP_CHANNEL8, new PoolEntry<uint16_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU1_DEVICE_0, new PoolEntry<uint8_t>({0}));
localDataPoolMap.emplace(P60System::PDU1_DEVICE_1, new PoolEntry<uint8_t>({0}));
localDataPoolMap.emplace(P60System::PDU1_DEVICE_2, new PoolEntry<uint8_t>({0}));
localDataPoolMap.emplace(P60System::PDU1_DEVICE_3, new PoolEntry<uint8_t>({0}));
localDataPoolMap.emplace(P60System::PDU1_DEVICE_4, new PoolEntry<uint8_t>({0}));
localDataPoolMap.emplace(P60System::PDU1_DEVICE_5, new PoolEntry<uint8_t>({0}));
localDataPoolMap.emplace(P60System::PDU1_DEVICE_6, new PoolEntry<uint8_t>({0}));
localDataPoolMap.emplace(P60System::PDU1_DEVICE_7, new PoolEntry<uint8_t>({0}));
localDataPoolMap.emplace(P60System::PDU1_DEVICE_0, new PoolEntry<uint8_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU1_DEVICE_1, new PoolEntry<uint8_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU1_DEVICE_2, new PoolEntry<uint8_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU1_DEVICE_3, new PoolEntry<uint8_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU1_DEVICE_4, new PoolEntry<uint8_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU1_DEVICE_5, new PoolEntry<uint8_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU1_DEVICE_6, new PoolEntry<uint8_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU1_DEVICE_7, new PoolEntry<uint8_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU1_DEVICE_0_STATUS, new PoolEntry<uint8_t>({0}));
localDataPoolMap.emplace(P60System::PDU1_DEVICE_1_STATUS, new PoolEntry<uint8_t>({0}));
localDataPoolMap.emplace(P60System::PDU1_DEVICE_2_STATUS, new PoolEntry<uint8_t>({0}));
localDataPoolMap.emplace(P60System::PDU1_DEVICE_3_STATUS, new PoolEntry<uint8_t>({0}));
localDataPoolMap.emplace(P60System::PDU1_DEVICE_4_STATUS, new PoolEntry<uint8_t>({0}));
localDataPoolMap.emplace(P60System::PDU1_DEVICE_5_STATUS, new PoolEntry<uint8_t>({0}));
localDataPoolMap.emplace(P60System::PDU1_DEVICE_6_STATUS, new PoolEntry<uint8_t>({0}));
localDataPoolMap.emplace(P60System::PDU1_DEVICE_7_STATUS, new PoolEntry<uint8_t>({0}));
localDataPoolMap.emplace(P60System::PDU1_DEVICE_0_STATUS, new PoolEntry<uint8_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU1_DEVICE_1_STATUS, new PoolEntry<uint8_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU1_DEVICE_2_STATUS, new PoolEntry<uint8_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU1_DEVICE_3_STATUS, new PoolEntry<uint8_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU1_DEVICE_4_STATUS, new PoolEntry<uint8_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU1_DEVICE_5_STATUS, new PoolEntry<uint8_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU1_DEVICE_6_STATUS, new PoolEntry<uint8_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU1_DEVICE_7_STATUS, new PoolEntry<uint8_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU1_WDT_CNT_GND, new PoolEntry<uint32_t>({0}));
localDataPoolMap.emplace(P60System::PDU1_WDT_CNT_I2C, new PoolEntry<uint32_t>({0}));
localDataPoolMap.emplace(P60System::PDU1_WDT_CNT_CAN, new PoolEntry<uint32_t>({0}));
localDataPoolMap.emplace(P60System::PDU1_WDT_CNT_CSP1, new PoolEntry<uint32_t>({0}));
localDataPoolMap.emplace(P60System::PDU1_WDT_CNT_CSP2, new PoolEntry<uint32_t>({0}));
localDataPoolMap.emplace(P60System::PDU1_WDT_GND_LEFT, new PoolEntry<uint32_t>({0}));
localDataPoolMap.emplace(P60System::PDU1_WDT_I2C_LEFT, new PoolEntry<uint32_t>({0}));
localDataPoolMap.emplace(P60System::PDU1_WDT_CAN_LEFT, new PoolEntry<uint32_t>({0}));
localDataPoolMap.emplace(P60System::PDU1_WDT_CSP_LEFT1, new PoolEntry<uint8_t>({0}));
localDataPoolMap.emplace(P60System::PDU1_WDT_CSP_LEFT2, new PoolEntry<uint8_t>({0}));
localDataPoolMap.emplace(P60System::PDU1_WDT_CNT_GND, new PoolEntry<uint32_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU1_WDT_CNT_I2C, new PoolEntry<uint32_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU1_WDT_CNT_CAN, new PoolEntry<uint32_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU1_WDT_CNT_CSP1, new PoolEntry<uint32_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU1_WDT_CNT_CSP2, new PoolEntry<uint32_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU1_WDT_GND_LEFT, new PoolEntry<uint32_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU1_WDT_I2C_LEFT, new PoolEntry<uint32_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU1_WDT_CAN_LEFT, new PoolEntry<uint32_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU1_WDT_CSP_LEFT1, new PoolEntry<uint8_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU1_WDT_CSP_LEFT2, new PoolEntry<uint8_t>( { 0 }));
return HasReturnvaluesIF::RETURN_OK;
return HasReturnvaluesIF::RETURN_OK;
}
ReturnValue_t PDU1Handler::printStatus(DeviceCommandId_t cmd) {
switch(cmd) {
case(GOMSPACE::PRINT_SWITCH_V_I): {
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;
}
printHkTable();
return HasReturnvaluesIF::RETURN_OK;
switch (cmd) {
case (GOMSPACE::PRINT_SWITCH_V_I): {
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;
}
printHkTable();
return HasReturnvaluesIF::RETURN_OK;
}
default: {
return HasReturnvaluesIF::RETURN_FAILED;
}
return HasReturnvaluesIF::RETURN_FAILED;
}
}
}
void PDU1Handler::printHkTable() {
sif::info << "PDU1 Info: SwitchState, Currents [mA], Voltages [mV]" << std::endl;
sif::info << std::setw(30) << std::left << "TCS Board" << std::dec << "| " <<
unsigned(pdu1HkTableDataset.outEnabledTCSBoard3V3.value) << ", " <<
std::setw(4) << std::right <<
pdu1HkTableDataset.currentOutTCSBoard3V3.value << ", " << std::setw(4) <<
pdu1HkTableDataset.voltageOutTCSBoard3V3.value << std::endl;
sif::info << std::setw(30) << std::left << "Syrlinks" << std::dec << "| " <<
unsigned(pdu1HkTableDataset.outEnabledSyrlinks.value) << ", " <<
std::setw(4) << std::right <<
pdu1HkTableDataset.currentOutSyrlinks.value << ", " << std::setw(4) <<
pdu1HkTableDataset.voltageOutSyrlinks.value << std::endl;
sif::info << std::setw(30) << std::left << "Star Tracker" << std::dec << "| " <<
static_cast<unsigned int>(pdu1HkTableDataset.outEnabledStarTracker.value) << ", " <<
std::setw(4) << std::right <<
pdu1HkTableDataset.currentOutStarTracker.value << ", " << std::setw(4) <<
pdu1HkTableDataset.voltageOutStarTracker.value << std::endl;
sif::info << std::setw(30) << std::left << "MGT" << std::dec << "| " <<
static_cast<unsigned int>(pdu1HkTableDataset.outEnabledMGT.value) << ", " <<
std::setw(4) << std::right <<
pdu1HkTableDataset.currentOutMGT.value << ", " << std::setw(4) <<
pdu1HkTableDataset.voltageOutMGT.value << std::endl;
sif::info << std::setw(30) << std::left << "SuS nominal" << std::dec << "| " <<
static_cast<unsigned int>(pdu1HkTableDataset.outEnabledSUSNominal.value) << ", " <<
std::setw(4) << std::right <<
pdu1HkTableDataset.currentOutSUSNominal.value << ", " << std::setw(4) <<
pdu1HkTableDataset.voltageOutSUSNominal.value << std::endl;
sif::info << std::setw(30) << std::left << "Solar Cell Experiment" << std::dec << "| " <<
static_cast<unsigned int>(pdu1HkTableDataset.outEnabledSolarCellExp.value) << ", " <<
std::setw(4) << std::right <<
pdu1HkTableDataset.currentOutSolarCellExp.value << ", " << std::setw(4) <<
pdu1HkTableDataset.voltageOutSolarCellExp.value << std::endl;
sif::info << std::setw(30) << std::left << "PLOC" << std::dec << "| " <<
static_cast<unsigned int>(pdu1HkTableDataset.outEnabledPLOC.value) << ", " <<
std::setw(4) << std::right <<
pdu1HkTableDataset.currentOutPLOC.value << ", " << std::setw(4) <<
pdu1HkTableDataset.voltageOutPLOC.value << std::endl;
sif::info << std::setw(30) << std::left << "ACS Side A" << std::dec << "| " <<
static_cast<unsigned int>(pdu1HkTableDataset.outEnabledAcsBoardSideA.value) << ", " <<
std::setw(4) << std::right <<
pdu1HkTableDataset.currentOutACSBoardSideA.value << ", " << std::setw(4) <<
pdu1HkTableDataset.voltageOutACSBoardSideA.value << std::endl;
sif::info << std::setw(30) << std::left << "Channel 8" << std::dec << "| " <<
static_cast<unsigned int>(pdu1HkTableDataset.outEnabledChannel8.value) << ", " <<
std::setw(4) << std::right <<
pdu1HkTableDataset.currentOutChannel8.value << ", " << std::setw(4) <<
pdu1HkTableDataset.voltageOutChannel8.value << std::right << std::endl;
sif::info << "PDU1 Info: SwitchState, Currents [mA], Voltages [mV]" << std::endl;
sif::info << std::setw(30) << std::left << "TCS Board" << std::dec << "| "
<< unsigned(pdu1HkTableDataset.outEnabledTCSBoard3V3.value) << ", " << std::setw(4)
<< std::right << pdu1HkTableDataset.currentOutTCSBoard3V3.value << ", " << std::setw(4)
<< pdu1HkTableDataset.voltageOutTCSBoard3V3.value << std::endl;
sif::info << std::setw(30) << std::left << "Syrlinks" << std::dec << "| "
<< unsigned(pdu1HkTableDataset.outEnabledSyrlinks.value) << ", " << std::setw(4)
<< std::right << pdu1HkTableDataset.currentOutSyrlinks.value << ", " << std::setw(4)
<< pdu1HkTableDataset.voltageOutSyrlinks.value << std::endl;
sif::info << std::setw(30) << std::left << "Star Tracker" << std::dec << "| "
<< static_cast<unsigned int>(pdu1HkTableDataset.outEnabledStarTracker.value) << ", "
<< std::setw(4) << std::right << pdu1HkTableDataset.currentOutStarTracker.value << ", "
<< std::setw(4) << pdu1HkTableDataset.voltageOutStarTracker.value << std::endl;
sif::info << std::setw(30) << std::left << "MGT" << std::dec << "| "
<< static_cast<unsigned int>(pdu1HkTableDataset.outEnabledMGT.value) << ", "
<< std::setw(4) << std::right << pdu1HkTableDataset.currentOutMGT.value << ", "
<< std::setw(4) << pdu1HkTableDataset.voltageOutMGT.value << std::endl;
sif::info << std::setw(30) << std::left << "SuS nominal" << std::dec << "| "
<< static_cast<unsigned int>(pdu1HkTableDataset.outEnabledSUSNominal.value) << ", "
<< std::setw(4) << std::right << pdu1HkTableDataset.currentOutSUSNominal.value << ", "
<< std::setw(4) << pdu1HkTableDataset.voltageOutSUSNominal.value << std::endl;
sif::info << std::setw(30) << std::left << "Solar Cell Experiment" << std::dec << "| "
<< static_cast<unsigned int>(pdu1HkTableDataset.outEnabledSolarCellExp.value) << ", "
<< std::setw(4) << std::right << pdu1HkTableDataset.currentOutSolarCellExp.value << ", "
<< std::setw(4) << pdu1HkTableDataset.voltageOutSolarCellExp.value << std::endl;
sif::info << std::setw(30) << std::left << "PLOC" << std::dec << "| "
<< static_cast<unsigned int>(pdu1HkTableDataset.outEnabledPLOC.value) << ", "
<< std::setw(4) << std::right << pdu1HkTableDataset.currentOutPLOC.value << ", "
<< std::setw(4) << pdu1HkTableDataset.voltageOutPLOC.value << std::endl;
sif::info << std::setw(30) << std::left << "ACS Side A" << std::dec << "| "
<< static_cast<unsigned int>(pdu1HkTableDataset.outEnabledAcsBoardSideA.value) << ", "
<< std::setw(4) << std::right << pdu1HkTableDataset.currentOutACSBoardSideA.value
<< ", " << std::setw(4) << pdu1HkTableDataset.voltageOutACSBoardSideA.value
<< std::endl;
sif::info << std::setw(30) << std::left << "Channel 8" << std::dec << "| "
<< static_cast<unsigned int>(pdu1HkTableDataset.outEnabledChannel8.value) << ", "
<< std::setw(4) << std::right << pdu1HkTableDataset.currentOutChannel8.value << ", "
<< std::setw(4) << pdu1HkTableDataset.voltageOutChannel8.value << std::right
<< std::endl;
}

View File

@ -19,27 +19,28 @@
* ACS 3.3V for Side A group, channel 7
* Unoccupied, 5V, channel 8
*/
class PDU1Handler: public GomspaceDeviceHandler {
public:
PDU1Handler(object_id_t objectId, object_id_t comIF, CookieIF * comCookie);
virtual ~PDU1Handler();
class PDU1Handler : public GomspaceDeviceHandler {
public:
PDU1Handler(object_id_t objectId, object_id_t comIF, CookieIF* comCookie);
virtual ~PDU1Handler();
virtual ReturnValue_t initializeLocalDataPool(localpool::DataPool& localDataPoolMap,
LocalDataPoolManager& poolManager) override;
protected:
/**
* @brief In MODE_NORMAL, a command will be built periodically by this function.
*/
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;
virtual ReturnValue_t initializeLocalDataPool(localpool::DataPool& localDataPoolMap,
LocalDataPoolManager& poolManager) override;
private:
/** Dataset for the housekeeping table of the PDU1 */
PDU1::PDU1HkTableDataset pdu1HkTableDataset;
protected:
/**
* @brief In MODE_NORMAL, a command will be built periodically by this function.
*/
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;
void printHkTable();
void parseHkTableReply(const uint8_t *packet);
private:
/** Dataset for the housekeeping table of the PDU1 */
PDU1::PDU1HkTableDataset pdu1HkTableDataset;
void printHkTable();
void parseHkTableReply(const uint8_t* packet);
};
#endif /* MISSION_DEVICES_PDU1Handler_H_ */

View File

@ -1,378 +1,423 @@
#include "OBSWConfig.h"
#include "PDU2Handler.h"
#include <mission/devices/devicedefinitions/GomSpacePackets.h>
#include <fsfw/datapool/PoolReadGuard.h>
#include <mission/devices/devicedefinitions/GomSpacePackets.h>
PDU2Handler::PDU2Handler(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, &pdu2HkTableDataset),
pdu2HkTableDataset(this) {
}
#include "OBSWConfig.h"
PDU2Handler::~PDU2Handler() {
}
PDU2Handler::PDU2Handler(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,
&pdu2HkTableDataset),
pdu2HkTableDataset(this) {}
ReturnValue_t PDU2Handler::buildNormalDeviceCommand(
DeviceCommandId_t * id) {
*id = GOMSPACE::REQUEST_HK_TABLE;
return buildCommandFromCommand(*id, NULL, 0);
PDU2Handler::~PDU2Handler() {}
ReturnValue_t PDU2Handler::buildNormalDeviceCommand(DeviceCommandId_t *id) {
*id = GOMSPACE::REQUEST_HK_TABLE;
return buildCommandFromCommand(*id, NULL, 0);
}
void PDU2Handler::letChildHandleHkReply(DeviceCommandId_t id, const uint8_t *packet) {
parseHkTableReply(packet);
/**
* Hk table will be sent to the commander if hk table request was not triggered by the
* PDU2Handler itself.
*/
handleDeviceTM(&pdu2HkTableDataset, id, true);
parseHkTableReply(packet);
/**
* Hk table will be sent to the commander if hk table request was not triggered by the
* PDU2Handler itself.
*/
handleDeviceTM(&pdu2HkTableDataset, id, true);
#if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_PDU2 == 1
pdu2HkTableDataset.read();
sif::info << "PDU2 Q7S current voltage: " << pdu2HkTableDataset.voltageOutQ7S << " mV" << std::endl;
sif::info << "PDU2 VCC: " << pdu2HkTableDataset.vcc << " mV" << std::endl;
float vbat = pdu2HkTableDataset.vbat.value * 0.1;
sif::info << "PDU2 VBAT: " << vbat << std::endl;
float temperatureC = pdu2HkTableDataset.temperature.value * 0.1;
sif::info << "PDU2 Temperature: " << temperatureC << " °C" << std::endl;
printOutputSwitchStates();
sif::info << "PDU2 uptime: " << pdu2HkTableDataset.uptime << " seconds" << std::endl;
sif::info << "PDU2 battery mode: " << unsigned(pdu2HkTableDataset.battMode.value) << std::endl;
sif::info << "PDU2 ground watchdog reboots: " << pdu2HkTableDataset.gndWdtReboots << std::endl;
sif::info << "PDU2 ground watchdog timer seconds left: "
pdu2HkTableDataset.read();
sif::info << "PDU2 Q7S current voltage: " << pdu2HkTableDataset.voltageOutQ7S << " mV"
<< std::endl;
sif::info << "PDU2 VCC: " << pdu2HkTableDataset.vcc << " mV" << std::endl;
float vbat = pdu2HkTableDataset.vbat.value * 0.1;
sif::info << "PDU2 VBAT: " << vbat << std::endl;
float temperatureC = pdu2HkTableDataset.temperature.value * 0.1;
sif::info << "PDU2 Temperature: " << temperatureC << " °C" << std::endl;
printOutputSwitchStates();
sif::info << "PDU2 uptime: " << pdu2HkTableDataset.uptime << " seconds" << std::endl;
sif::info << "PDU2 battery mode: " << unsigned(pdu2HkTableDataset.battMode.value) << std::endl;
sif::info << "PDU2 ground watchdog reboots: " << pdu2HkTableDataset.gndWdtReboots << std::endl;
sif::info << "PDU2 ground watchdog timer seconds left: "
<< pdu2HkTableDataset.groundWatchdogSecondsLeft << " seconds" << std::endl;
sif::info << "PDU2 csp1 watchdog pings before reboot: "
sif::info << "PDU2 csp1 watchdog pings before reboot: "
<< unsigned(pdu2HkTableDataset.csp1WatchdogPingsLeft.value) << std::endl;
sif::info << "PDU2 csp2 watchdog pings before reboot: "
sif::info << "PDU2 csp2 watchdog pings before reboot: "
<< unsigned(pdu2HkTableDataset.csp2WatchdogPingsLeft.value) << std::endl;
pdu2HkTableDataset.commit();
pdu2HkTableDataset.commit();
#endif
}
void PDU2Handler::parseHkTableReply(const uint8_t *packet) {
uint16_t dataOffset = 0;
pdu2HkTableDataset.read();
/**
* Fist 10 bytes contain the gomspace header. Each variable is preceded by the 16-bit table
* address.
*/
dataOffset += 12;
pdu2HkTableDataset.currentOutQ7S = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
pdu2HkTableDataset.currentOutPayloadPCDUCh1 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
pdu2HkTableDataset.currentOutReactionWheels = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
pdu2HkTableDataset.currentOutTCSBoardHeaterIn = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
pdu2HkTableDataset.currentOutSUSRedundant = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
pdu2HkTableDataset.currentOutDeplMechanism = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
pdu2HkTableDataset.currentOutPayloadPCDUCh6 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
pdu2HkTableDataset.currentOutACSBoardSideB = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
pdu2HkTableDataset.currentOutPayloadCamera = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
uint16_t dataOffset = 0;
pdu2HkTableDataset.read();
/**
* Fist 10 bytes contain the gomspace header. Each variable is preceded by the 16-bit table
* address.
*/
dataOffset += 12;
pdu2HkTableDataset.currentOutQ7S = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
pdu2HkTableDataset.currentOutPayloadPCDUCh1 =
*(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
pdu2HkTableDataset.currentOutReactionWheels =
*(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
pdu2HkTableDataset.currentOutTCSBoardHeaterIn =
*(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
pdu2HkTableDataset.currentOutSUSRedundant =
*(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
pdu2HkTableDataset.currentOutDeplMechanism =
*(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
pdu2HkTableDataset.currentOutPayloadPCDUCh6 =
*(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
pdu2HkTableDataset.currentOutACSBoardSideB =
*(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
pdu2HkTableDataset.currentOutPayloadCamera =
*(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
pdu2HkTableDataset.voltageOutQ7S = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
pdu2HkTableDataset.voltageOutPayloadPCDUCh1 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
pdu2HkTableDataset.voltageOutReactionWheels = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
pdu2HkTableDataset.voltageOutTCSBoardHeaterIn = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
pdu2HkTableDataset.voltageOutSUSRedundant = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
pdu2HkTableDataset.voltageOutDeplMechanism = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
pdu2HkTableDataset.voltageOutPayloadPCDUCh6 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
pdu2HkTableDataset.voltageOutACSBoardSideB = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
pdu2HkTableDataset.voltageOutPayloadCamera = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
pdu2HkTableDataset.voltageOutQ7S = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
pdu2HkTableDataset.voltageOutPayloadPCDUCh1 =
*(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
pdu2HkTableDataset.voltageOutReactionWheels =
*(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
pdu2HkTableDataset.voltageOutTCSBoardHeaterIn =
*(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
pdu2HkTableDataset.voltageOutSUSRedundant =
*(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
pdu2HkTableDataset.voltageOutDeplMechanism =
*(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
pdu2HkTableDataset.voltageOutPayloadPCDUCh6 =
*(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
pdu2HkTableDataset.voltageOutACSBoardSideB =
*(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
pdu2HkTableDataset.voltageOutPayloadCamera =
*(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
pdu2HkTableDataset.vcc = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
pdu2HkTableDataset.vbat = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
pdu2HkTableDataset.temperature = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
pdu2HkTableDataset.vcc = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
pdu2HkTableDataset.vbat = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
pdu2HkTableDataset.temperature = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
pdu2HkTableDataset.converterEnable1 = *(packet + dataOffset);
dataOffset += 3;
pdu2HkTableDataset.converterEnable2 = *(packet + dataOffset);
dataOffset += 3;
pdu2HkTableDataset.converterEnable3 = *(packet + dataOffset);
dataOffset += 3;
pdu2HkTableDataset.converterEnable1 = *(packet + dataOffset);
dataOffset += 3;
pdu2HkTableDataset.converterEnable2 = *(packet + dataOffset);
dataOffset += 3;
pdu2HkTableDataset.converterEnable3 = *(packet + dataOffset);
dataOffset += 3;
pdu2HkTableDataset.outEnabledQ7S = *(packet + dataOffset);
dataOffset += 3;
pdu2HkTableDataset.outEnabledPlPCDUCh1 = *(packet + dataOffset);
dataOffset += 3;
pdu2HkTableDataset.outEnabledReactionWheels = *(packet + dataOffset);
dataOffset += 3;
pdu2HkTableDataset.outEnabledTCSBoardHeaterIn = *(packet + dataOffset);
dataOffset += 3;
pdu2HkTableDataset.outEnabledSUSRedundant = *(packet + dataOffset);
dataOffset += 3;
pdu2HkTableDataset.outEnabledDeplMechanism = *(packet + dataOffset);
dataOffset += 3;
pdu2HkTableDataset.outEnabledPlPCDUCh6 = *(packet + dataOffset);
dataOffset += 3;
pdu2HkTableDataset.outEnabledAcsBoardSideB = *(packet + dataOffset);
dataOffset += 3;
pdu2HkTableDataset.outEnabledPayloadCamera = *(packet + dataOffset);
dataOffset += 3;
pdu2HkTableDataset.outEnabledQ7S = *(packet + dataOffset);
dataOffset += 3;
pdu2HkTableDataset.outEnabledPlPCDUCh1 = *(packet + dataOffset);
dataOffset += 3;
pdu2HkTableDataset.outEnabledReactionWheels = *(packet + dataOffset);
dataOffset += 3;
pdu2HkTableDataset.outEnabledTCSBoardHeaterIn = *(packet + dataOffset);
dataOffset += 3;
pdu2HkTableDataset.outEnabledSUSRedundant = *(packet + dataOffset);
dataOffset += 3;
pdu2HkTableDataset.outEnabledDeplMechanism = *(packet + dataOffset);
dataOffset += 3;
pdu2HkTableDataset.outEnabledPlPCDUCh6 = *(packet + dataOffset);
dataOffset += 3;
pdu2HkTableDataset.outEnabledAcsBoardSideB = *(packet + dataOffset);
dataOffset += 3;
pdu2HkTableDataset.outEnabledPayloadCamera = *(packet + dataOffset);
dataOffset += 3;
pdu2HkTableDataset.bootcause = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3);
dataOffset += 6;
pdu2HkTableDataset.bootcount = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3);
dataOffset += 6;
pdu2HkTableDataset.uptime = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3);
dataOffset += 6;
pdu2HkTableDataset.resetcause = *(packet + dataOffset + 1) << 8 | *(packet + dataOffset);
dataOffset += 4;
pdu2HkTableDataset.battMode = *(packet + dataOffset);
/* +10 because here begins the second gomspace csp packet */
dataOffset += 3 + 10;
pdu2HkTableDataset.bootcause = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 |
*(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3);
dataOffset += 6;
pdu2HkTableDataset.bootcount = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 |
*(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3);
dataOffset += 6;
pdu2HkTableDataset.uptime = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 |
*(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3);
dataOffset += 6;
pdu2HkTableDataset.resetcause = *(packet + dataOffset + 1) << 8 | *(packet + dataOffset);
dataOffset += 4;
pdu2HkTableDataset.battMode = *(packet + dataOffset);
/* +10 because here begins the second gomspace csp packet */
dataOffset += 3 + 10;
pdu2HkTableDataset.latchupsQ7S = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
pdu2HkTableDataset.latchupsPayloadPcduCh1 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
pdu2HkTableDataset.latchupsRw = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
pdu2HkTableDataset.latchupsTcsBoardHeaterIn = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
pdu2HkTableDataset.latchupsSusRedundant = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
pdu2HkTableDataset.latchupsDeplMenchanism = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
pdu2HkTableDataset.latchupsPayloadPcduCh6 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
pdu2HkTableDataset.latchupsAcsBoardSideB = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
pdu2HkTableDataset.latchupsPayloadCamera = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
pdu2HkTableDataset.latchupsQ7S = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
pdu2HkTableDataset.latchupsPayloadPcduCh1 =
*(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
pdu2HkTableDataset.latchupsRw = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
pdu2HkTableDataset.latchupsTcsBoardHeaterIn =
*(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
pdu2HkTableDataset.latchupsSusRedundant =
*(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
pdu2HkTableDataset.latchupsDeplMenchanism =
*(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
pdu2HkTableDataset.latchupsPayloadPcduCh6 =
*(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
pdu2HkTableDataset.latchupsAcsBoardSideB =
*(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
pdu2HkTableDataset.latchupsPayloadCamera =
*(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
dataOffset += 4;
pdu2HkTableDataset.device0 = *(packet + dataOffset);
dataOffset += 3;
pdu2HkTableDataset.device1 = *(packet + dataOffset);
dataOffset += 3;
pdu2HkTableDataset.device2 = *(packet + dataOffset);
dataOffset += 3;
pdu2HkTableDataset.device3 = *(packet + dataOffset);
dataOffset += 3;
pdu2HkTableDataset.device4 = *(packet + dataOffset);
dataOffset += 3;
pdu2HkTableDataset.device5 = *(packet + dataOffset);
dataOffset += 3;
pdu2HkTableDataset.device6 = *(packet + dataOffset);
dataOffset += 3;
pdu2HkTableDataset.device7 = *(packet + dataOffset);
dataOffset += 3;
pdu2HkTableDataset.device0 = *(packet + dataOffset);
dataOffset += 3;
pdu2HkTableDataset.device1 = *(packet + dataOffset);
dataOffset += 3;
pdu2HkTableDataset.device2 = *(packet + dataOffset);
dataOffset += 3;
pdu2HkTableDataset.device3 = *(packet + dataOffset);
dataOffset += 3;
pdu2HkTableDataset.device4 = *(packet + dataOffset);
dataOffset += 3;
pdu2HkTableDataset.device5 = *(packet + dataOffset);
dataOffset += 3;
pdu2HkTableDataset.device6 = *(packet + dataOffset);
dataOffset += 3;
pdu2HkTableDataset.device7 = *(packet + dataOffset);
dataOffset += 3;
pdu2HkTableDataset.device0Status = *(packet + dataOffset);
dataOffset += 3;
pdu2HkTableDataset.device1Status = *(packet + dataOffset);
dataOffset += 3;
pdu2HkTableDataset.device2Status = *(packet + dataOffset);
dataOffset += 3;
pdu2HkTableDataset.device3Status = *(packet + dataOffset);
dataOffset += 3;
pdu2HkTableDataset.device4Status = *(packet + dataOffset);
dataOffset += 3;
pdu2HkTableDataset.device5Status = *(packet + dataOffset);
dataOffset += 3;
pdu2HkTableDataset.device6Status = *(packet + dataOffset);
dataOffset += 3;
pdu2HkTableDataset.device7Status = *(packet + dataOffset);
dataOffset += 3;
pdu2HkTableDataset.device0Status = *(packet + dataOffset);
dataOffset += 3;
pdu2HkTableDataset.device1Status = *(packet + dataOffset);
dataOffset += 3;
pdu2HkTableDataset.device2Status = *(packet + dataOffset);
dataOffset += 3;
pdu2HkTableDataset.device3Status = *(packet + dataOffset);
dataOffset += 3;
pdu2HkTableDataset.device4Status = *(packet + dataOffset);
dataOffset += 3;
pdu2HkTableDataset.device5Status = *(packet + dataOffset);
dataOffset += 3;
pdu2HkTableDataset.device6Status = *(packet + dataOffset);
dataOffset += 3;
pdu2HkTableDataset.device7Status = *(packet + dataOffset);
dataOffset += 3;
pdu2HkTableDataset.gndWdtReboots = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3);
dataOffset += 6;
pdu2HkTableDataset.i2cWdtReboots = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3);
dataOffset += 6;
pdu2HkTableDataset.canWdtReboots = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3);
dataOffset += 6;
pdu2HkTableDataset.csp1WdtReboots = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3);
dataOffset += 6;
pdu2HkTableDataset.csp2WdtReboots = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3);
dataOffset += 6;
pdu2HkTableDataset.groundWatchdogSecondsLeft = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3);
dataOffset += 6;
pdu2HkTableDataset.i2cWatchdogSecondsLeft = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3);
dataOffset += 6;
pdu2HkTableDataset.canWatchdogSecondsLeft = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3);
dataOffset += 6;
pdu2HkTableDataset.csp1WatchdogPingsLeft = *(packet + dataOffset);
dataOffset += 3;
pdu2HkTableDataset.csp2WatchdogPingsLeft = *(packet + dataOffset);
pdu2HkTableDataset.gndWdtReboots = *(packet + dataOffset) << 24 |
*(packet + dataOffset + 1) << 16 |
*(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3);
dataOffset += 6;
pdu2HkTableDataset.i2cWdtReboots = *(packet + dataOffset) << 24 |
*(packet + dataOffset + 1) << 16 |
*(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3);
dataOffset += 6;
pdu2HkTableDataset.canWdtReboots = *(packet + dataOffset) << 24 |
*(packet + dataOffset + 1) << 16 |
*(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3);
dataOffset += 6;
pdu2HkTableDataset.csp1WdtReboots = *(packet + dataOffset) << 24 |
*(packet + dataOffset + 1) << 16 |
*(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3);
dataOffset += 6;
pdu2HkTableDataset.csp2WdtReboots = *(packet + dataOffset) << 24 |
*(packet + dataOffset + 1) << 16 |
*(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3);
dataOffset += 6;
pdu2HkTableDataset.groundWatchdogSecondsLeft =
*(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 |
*(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3);
dataOffset += 6;
pdu2HkTableDataset.i2cWatchdogSecondsLeft =
*(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 |
*(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3);
dataOffset += 6;
pdu2HkTableDataset.canWatchdogSecondsLeft =
*(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 |
*(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3);
dataOffset += 6;
pdu2HkTableDataset.csp1WatchdogPingsLeft = *(packet + dataOffset);
dataOffset += 3;
pdu2HkTableDataset.csp2WatchdogPingsLeft = *(packet + dataOffset);
pdu2HkTableDataset.commit();
pdu2HkTableDataset.setChanged(true);
pdu2HkTableDataset.commit();
pdu2HkTableDataset.setChanged(true);
}
ReturnValue_t PDU2Handler::initializeLocalDataPool(
localpool::DataPool &localDataPoolMap, LocalDataPoolManager &poolManager) {
ReturnValue_t PDU2Handler::initializeLocalDataPool(localpool::DataPool &localDataPoolMap,
LocalDataPoolManager &poolManager) {
localDataPoolMap.emplace(P60System::PDU2_CURRENT_OUT_Q7S, new PoolEntry<int16_t>({0}));
localDataPoolMap.emplace(P60System::PDU2_CURRENT_OUT_PAYLOAD_PCDU_CH1,
new PoolEntry<int16_t>({0}));
localDataPoolMap.emplace(P60System::PDU2_CURRENT_OUT_RW, new PoolEntry<int16_t>({0}));
localDataPoolMap.emplace(P60System::PDU2_CURRENT_OUT_TCS_BOARD_HEATER_IN,
new PoolEntry<int16_t>({0}));
localDataPoolMap.emplace(P60System::PDU2_CURRENT_OUT_SUS_REDUNDANT, new PoolEntry<int16_t>({0}));
localDataPoolMap.emplace(P60System::PDU2_CURRENT_OUT_DEPLOYMENT_MECHANISM,
new PoolEntry<int16_t>({0}));
localDataPoolMap.emplace(P60System::PDU2_CURRENT_OUT_PAYLOAD_PCDU_CH6,
new PoolEntry<int16_t>({0}));
localDataPoolMap.emplace(P60System::PDU2_CURRENT_OUT_ACS_BOARD_SIDE_B,
new PoolEntry<int16_t>({0}));
localDataPoolMap.emplace(P60System::PDU2_CURRENT_OUT_PAYLOAD_CAMERA, new PoolEntry<int16_t>({0}));
localDataPoolMap.emplace(P60System::PDU2_CURRENT_OUT_Q7S, new PoolEntry<int16_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU2_CURRENT_OUT_PAYLOAD_PCDU_CH1, new PoolEntry<int16_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU2_CURRENT_OUT_RW, new PoolEntry<int16_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU2_CURRENT_OUT_TCS_BOARD_HEATER_IN, new PoolEntry<int16_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU2_CURRENT_OUT_SUS_REDUNDANT, new PoolEntry<int16_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU2_CURRENT_OUT_DEPLOYMENT_MECHANISM, new PoolEntry<int16_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU2_CURRENT_OUT_PAYLOAD_PCDU_CH6, new PoolEntry<int16_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU2_CURRENT_OUT_ACS_BOARD_SIDE_B, new PoolEntry<int16_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU2_CURRENT_OUT_PAYLOAD_CAMERA, new PoolEntry<int16_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU2_VOLTAGE_OUT_Q7S, new PoolEntry<int16_t>({0}));
localDataPoolMap.emplace(P60System::PDU2_VOLTAGE_OUT_PAYLOAD_PCDU_CH1,
new PoolEntry<int16_t>({0}));
localDataPoolMap.emplace(P60System::PDU2_VOLTAGE_OUT_RW, new PoolEntry<int16_t>({0}));
localDataPoolMap.emplace(P60System::PDU2_VOLTAGE_OUT_TCS_BOARD_HEATER_IN,
new PoolEntry<int16_t>({0}));
localDataPoolMap.emplace(P60System::PDU2_VOLTAGE_OUT_SUS_REDUNDANT, new PoolEntry<int16_t>({0}));
localDataPoolMap.emplace(P60System::PDU2_VOLTAGE_OUT_DEPLOYMENT_MECHANISM,
new PoolEntry<int16_t>({0}));
localDataPoolMap.emplace(P60System::PDU2_VOLTAGE_OUT_PAYLOAD_PCDU_CH6,
new PoolEntry<int16_t>({0}));
localDataPoolMap.emplace(P60System::PDU2_VOLTAGE_OUT_ACS_BOARD_SIDE_B,
new PoolEntry<int16_t>({0}));
localDataPoolMap.emplace(P60System::PDU2_VOLTAGE_OUT_PAYLOAD_CAMERA, new PoolEntry<int16_t>({0}));
localDataPoolMap.emplace(P60System::PDU2_VOLTAGE_OUT_Q7S, new PoolEntry<int16_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU2_VOLTAGE_OUT_PAYLOAD_PCDU_CH1, new PoolEntry<int16_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU2_VOLTAGE_OUT_RW, new PoolEntry<int16_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU2_VOLTAGE_OUT_TCS_BOARD_HEATER_IN, new PoolEntry<int16_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU2_VOLTAGE_OUT_SUS_REDUNDANT, new PoolEntry<int16_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU2_VOLTAGE_OUT_DEPLOYMENT_MECHANISM, new PoolEntry<int16_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU2_VOLTAGE_OUT_PAYLOAD_PCDU_CH6, new PoolEntry<int16_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU2_VOLTAGE_OUT_ACS_BOARD_SIDE_B, new PoolEntry<int16_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU2_VOLTAGE_OUT_PAYLOAD_CAMERA, new PoolEntry<int16_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU2_VCC, new PoolEntry<int16_t>({0}));
localDataPoolMap.emplace(P60System::PDU2_VBAT, new PoolEntry<int16_t>({0}));
localDataPoolMap.emplace(P60System::PDU2_TEMPERATURE, new PoolEntry<int16_t>({0}));
localDataPoolMap.emplace(P60System::PDU2_CONV_EN_1, new PoolEntry<uint8_t>({0}));
localDataPoolMap.emplace(P60System::PDU2_CONV_EN_2, new PoolEntry<uint8_t>({0}));
localDataPoolMap.emplace(P60System::PDU2_CONV_EN_3, new PoolEntry<uint8_t>({0}));
localDataPoolMap.emplace(P60System::PDU2_VCC, new PoolEntry<int16_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU2_VBAT, new PoolEntry<int16_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU2_TEMPERATURE, new PoolEntry<int16_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU2_CONV_EN_1, new PoolEntry<uint8_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU2_CONV_EN_2, new PoolEntry<uint8_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU2_CONV_EN_3, new PoolEntry<uint8_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU2_OUT_EN_Q7S, new PoolEntry<uint8_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU2_OUT_EN_PAYLOAD_PCDU_CH1, new PoolEntry<uint8_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU2_OUT_EN_RW, new PoolEntry<uint8_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU2_OUT_EN_Q7S, new PoolEntry<uint8_t>({0}));
localDataPoolMap.emplace(P60System::PDU2_OUT_EN_PAYLOAD_PCDU_CH1, new PoolEntry<uint8_t>({0}));
localDataPoolMap.emplace(P60System::PDU2_OUT_EN_RW, new PoolEntry<uint8_t>({0}));
#if BOARD_TE0720 == 1
localDataPoolMap.emplace(P60System::PDU2_OUT_EN_TCS_BOARD_HEATER_IN, new PoolEntry<uint8_t>( { 1 }));
localDataPoolMap.emplace(P60System::PDU2_OUT_EN_TCS_BOARD_HEATER_IN, new PoolEntry<uint8_t>({1}));
#else
localDataPoolMap.emplace(P60System::PDU2_OUT_EN_TCS_BOARD_HEATER_IN, new PoolEntry<uint8_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU2_OUT_EN_TCS_BOARD_HEATER_IN, new PoolEntry<uint8_t>({0}));
#endif
localDataPoolMap.emplace(P60System::PDU2_OUT_EN_SUS_REDUNDANT, new PoolEntry<uint8_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU2_OUT_EN_DEPLOYMENT_MECHANISM, new PoolEntry<uint8_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU2_OUT_EN_PAYLOAD_PCDU_CH6, new PoolEntry<uint8_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU2_OUT_EN_ACS_BOARD_SIDE_B, new PoolEntry<uint8_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU2_OUT_EN_PAYLOAD_CAMERA, new PoolEntry<uint8_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU2_OUT_EN_SUS_REDUNDANT, new PoolEntry<uint8_t>({0}));
localDataPoolMap.emplace(P60System::PDU2_OUT_EN_DEPLOYMENT_MECHANISM,
new PoolEntry<uint8_t>({0}));
localDataPoolMap.emplace(P60System::PDU2_OUT_EN_PAYLOAD_PCDU_CH6, new PoolEntry<uint8_t>({0}));
localDataPoolMap.emplace(P60System::PDU2_OUT_EN_ACS_BOARD_SIDE_B, new PoolEntry<uint8_t>({0}));
localDataPoolMap.emplace(P60System::PDU2_OUT_EN_PAYLOAD_CAMERA, new PoolEntry<uint8_t>({0}));
localDataPoolMap.emplace(P60System::PDU2_BOOTCAUSE, new PoolEntry<uint32_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU2_BOOTCNT, new PoolEntry<uint32_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU2_UPTIME, new PoolEntry<uint32_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU2_RESETCAUSE, new PoolEntry<uint16_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU2_BATT_MODE, new PoolEntry<uint8_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU2_BOOTCAUSE, new PoolEntry<uint32_t>({0}));
localDataPoolMap.emplace(P60System::PDU2_BOOTCNT, new PoolEntry<uint32_t>({0}));
localDataPoolMap.emplace(P60System::PDU2_UPTIME, new PoolEntry<uint32_t>({0}));
localDataPoolMap.emplace(P60System::PDU2_RESETCAUSE, new PoolEntry<uint16_t>({0}));
localDataPoolMap.emplace(P60System::PDU2_BATT_MODE, new PoolEntry<uint8_t>({0}));
localDataPoolMap.emplace(P60System::PDU2_LATCHUP_Q7S, new PoolEntry<uint16_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU2_LATCHUP_PAYLOAD_PCDU_CH1, new PoolEntry<uint16_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU2_LATCHUP_RW, new PoolEntry<uint16_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU2_LATCHUP_TCS_BOARD_HEATER_IN, new PoolEntry<uint16_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU2_LATCHUP_SUS_REDUNDANT, new PoolEntry<uint16_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU2_LATCHUP_DEPLOYMENT_MECHANISM, new PoolEntry<uint16_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU2_LATCHUP_PAYLOAD_PCDU_CH6, new PoolEntry<uint16_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU2_LATCHUP_ACS_BOARD_SIDE_B, new PoolEntry<uint16_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU2_LATCHUP_PAYLOAD_CAMERA, new PoolEntry<uint16_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU2_LATCHUP_Q7S, new PoolEntry<uint16_t>({0}));
localDataPoolMap.emplace(P60System::PDU2_LATCHUP_PAYLOAD_PCDU_CH1, new PoolEntry<uint16_t>({0}));
localDataPoolMap.emplace(P60System::PDU2_LATCHUP_RW, new PoolEntry<uint16_t>({0}));
localDataPoolMap.emplace(P60System::PDU2_LATCHUP_TCS_BOARD_HEATER_IN,
new PoolEntry<uint16_t>({0}));
localDataPoolMap.emplace(P60System::PDU2_LATCHUP_SUS_REDUNDANT, new PoolEntry<uint16_t>({0}));
localDataPoolMap.emplace(P60System::PDU2_LATCHUP_DEPLOYMENT_MECHANISM,
new PoolEntry<uint16_t>({0}));
localDataPoolMap.emplace(P60System::PDU2_LATCHUP_PAYLOAD_PCDU_CH6, new PoolEntry<uint16_t>({0}));
localDataPoolMap.emplace(P60System::PDU2_LATCHUP_ACS_BOARD_SIDE_B, new PoolEntry<uint16_t>({0}));
localDataPoolMap.emplace(P60System::PDU2_LATCHUP_PAYLOAD_CAMERA, new PoolEntry<uint16_t>({0}));
localDataPoolMap.emplace(P60System::PDU2_DEVICE_0, new PoolEntry<uint8_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU2_DEVICE_1, new PoolEntry<uint8_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU2_DEVICE_2, new PoolEntry<uint8_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU2_DEVICE_3, new PoolEntry<uint8_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU2_DEVICE_4, new PoolEntry<uint8_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU2_DEVICE_5, new PoolEntry<uint8_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU2_DEVICE_6, new PoolEntry<uint8_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU2_DEVICE_7, new PoolEntry<uint8_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU2_DEVICE_0, new PoolEntry<uint8_t>({0}));
localDataPoolMap.emplace(P60System::PDU2_DEVICE_1, new PoolEntry<uint8_t>({0}));
localDataPoolMap.emplace(P60System::PDU2_DEVICE_2, new PoolEntry<uint8_t>({0}));
localDataPoolMap.emplace(P60System::PDU2_DEVICE_3, new PoolEntry<uint8_t>({0}));
localDataPoolMap.emplace(P60System::PDU2_DEVICE_4, new PoolEntry<uint8_t>({0}));
localDataPoolMap.emplace(P60System::PDU2_DEVICE_5, new PoolEntry<uint8_t>({0}));
localDataPoolMap.emplace(P60System::PDU2_DEVICE_6, new PoolEntry<uint8_t>({0}));
localDataPoolMap.emplace(P60System::PDU2_DEVICE_7, new PoolEntry<uint8_t>({0}));
localDataPoolMap.emplace(P60System::PDU2_DEVICE_0_STATUS, new PoolEntry<uint8_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU2_DEVICE_1_STATUS, new PoolEntry<uint8_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU2_DEVICE_2_STATUS, new PoolEntry<uint8_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU2_DEVICE_3_STATUS, new PoolEntry<uint8_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU2_DEVICE_4_STATUS, new PoolEntry<uint8_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU2_DEVICE_5_STATUS, new PoolEntry<uint8_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU2_DEVICE_6_STATUS, new PoolEntry<uint8_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU2_DEVICE_7_STATUS, new PoolEntry<uint8_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU2_DEVICE_0_STATUS, new PoolEntry<uint8_t>({0}));
localDataPoolMap.emplace(P60System::PDU2_DEVICE_1_STATUS, new PoolEntry<uint8_t>({0}));
localDataPoolMap.emplace(P60System::PDU2_DEVICE_2_STATUS, new PoolEntry<uint8_t>({0}));
localDataPoolMap.emplace(P60System::PDU2_DEVICE_3_STATUS, new PoolEntry<uint8_t>({0}));
localDataPoolMap.emplace(P60System::PDU2_DEVICE_4_STATUS, new PoolEntry<uint8_t>({0}));
localDataPoolMap.emplace(P60System::PDU2_DEVICE_5_STATUS, new PoolEntry<uint8_t>({0}));
localDataPoolMap.emplace(P60System::PDU2_DEVICE_6_STATUS, new PoolEntry<uint8_t>({0}));
localDataPoolMap.emplace(P60System::PDU2_DEVICE_7_STATUS, new PoolEntry<uint8_t>({0}));
localDataPoolMap.emplace(P60System::PDU2_WDT_CNT_GND, new PoolEntry<uint32_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU2_WDT_CNT_I2C, new PoolEntry<uint32_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU2_WDT_CNT_CAN, new PoolEntry<uint32_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU2_WDT_CNT_CSP1, new PoolEntry<uint32_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU2_WDT_CNT_CSP2, new PoolEntry<uint32_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU2_WDT_GND_LEFT, new PoolEntry<uint32_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU2_WDT_I2C_LEFT, new PoolEntry<uint32_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU2_WDT_CAN_LEFT, new PoolEntry<uint32_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU2_WDT_CSP_LEFT1, new PoolEntry<uint8_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU2_WDT_CSP_LEFT2, new PoolEntry<uint8_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU2_WDT_CNT_GND, new PoolEntry<uint32_t>({0}));
localDataPoolMap.emplace(P60System::PDU2_WDT_CNT_I2C, new PoolEntry<uint32_t>({0}));
localDataPoolMap.emplace(P60System::PDU2_WDT_CNT_CAN, new PoolEntry<uint32_t>({0}));
localDataPoolMap.emplace(P60System::PDU2_WDT_CNT_CSP1, new PoolEntry<uint32_t>({0}));
localDataPoolMap.emplace(P60System::PDU2_WDT_CNT_CSP2, new PoolEntry<uint32_t>({0}));
localDataPoolMap.emplace(P60System::PDU2_WDT_GND_LEFT, new PoolEntry<uint32_t>({0}));
localDataPoolMap.emplace(P60System::PDU2_WDT_I2C_LEFT, new PoolEntry<uint32_t>({0}));
localDataPoolMap.emplace(P60System::PDU2_WDT_CAN_LEFT, new PoolEntry<uint32_t>({0}));
localDataPoolMap.emplace(P60System::PDU2_WDT_CSP_LEFT1, new PoolEntry<uint8_t>({0}));
localDataPoolMap.emplace(P60System::PDU2_WDT_CSP_LEFT2, new PoolEntry<uint8_t>({0}));
return HasReturnvaluesIF::RETURN_OK;
return HasReturnvaluesIF::RETURN_OK;
}
ReturnValue_t PDU2Handler::printStatus(DeviceCommandId_t cmd) {
switch(cmd) {
case(GOMSPACE::PRINT_SWITCH_V_I): {
PoolReadGuard pg(&pdu2HkTableDataset);
ReturnValue_t readResult = pg.getReadResult();
if(readResult != HasReturnvaluesIF::RETURN_OK) {
sif::warning << "Reading PDU1 HK table failed!" << std::endl;
return HasReturnvaluesIF::RETURN_FAILED;
}
printHkTable();
return HasReturnvaluesIF::RETURN_OK;
switch (cmd) {
case (GOMSPACE::PRINT_SWITCH_V_I): {
PoolReadGuard pg(&pdu2HkTableDataset);
ReturnValue_t readResult = pg.getReadResult();
if (readResult != HasReturnvaluesIF::RETURN_OK) {
sif::warning << "Reading PDU1 HK table failed!" << std::endl;
return HasReturnvaluesIF::RETURN_FAILED;
}
printHkTable();
return HasReturnvaluesIF::RETURN_OK;
}
default: {
return HasReturnvaluesIF::RETURN_FAILED;
}
return HasReturnvaluesIF::RETURN_FAILED;
}
}
}
void PDU2Handler::printHkTable() {
sif::info << "PDU2 Info: SwitchState, Currents [mA], Voltages [mV]" << std::endl;
sif::info << std::setw(30) << std::left << "Q7S" << std::dec << "| " <<
unsigned(pdu2HkTableDataset.outEnabledQ7S.value) << ", " <<
std::setw(4) << std::right <<
pdu2HkTableDataset.currentOutQ7S.value << ", " << std::setw(4) <<
pdu2HkTableDataset.voltageOutQ7S.value << std::endl;
sif::info << std::setw(30) << std::left << "Payload PCDU Channel 1" << std::dec << "| " <<
unsigned(pdu2HkTableDataset.outEnabledPlPCDUCh1.value) << ", " <<
std::setw(4) << std::right <<
pdu2HkTableDataset.currentOutPayloadPCDUCh1.value << ", " << std::setw(4) <<
pdu2HkTableDataset.voltageOutPayloadPCDUCh1.value << std::endl;
sif::info << std::setw(30) << std::left << "Reaction Wheels" << std::dec << "| " <<
unsigned(pdu2HkTableDataset.outEnabledReactionWheels.value) << ", " <<
std::setw(4) << std::right <<
pdu2HkTableDataset.currentOutReactionWheels.value << ", " << std::setw(4) <<
pdu2HkTableDataset.voltageOutReactionWheels.value << std::endl;
sif::info << std::setw(30) << std::left << "TCS Board 8V heater input" << std::dec << "| " <<
unsigned(pdu2HkTableDataset.outEnabledTCSBoardHeaterIn.value) << ", " <<
std::setw(4) << std::right <<
pdu2HkTableDataset.currentOutTCSBoardHeaterIn.value << ", " << std::setw(4) <<
pdu2HkTableDataset.voltageOutTCSBoardHeaterIn.value << std::endl;
sif::info << std::setw(30) << std::left << "Redundant SUS group" << std::dec << "| " <<
unsigned(pdu2HkTableDataset.outEnabledSUSRedundant.value) << ", " <<
std::setw(4) << std::right <<
pdu2HkTableDataset.currentOutSUSRedundant.value << ", " << std::setw(4) <<
pdu2HkTableDataset.voltageOutSUSRedundant.value << std::endl;
sif::info << std::setw(30) << std::left << "Deployment mechanism" << std::dec << "| " <<
unsigned(pdu2HkTableDataset.outEnabledDeplMechanism.value) << ", " <<
std::setw(4) << std::right <<
pdu2HkTableDataset.currentOutDeplMechanism.value << ", " << std::setw(4) <<
pdu2HkTableDataset.voltageOutDeplMechanism.value << std::endl;
sif::info << std::setw(30) << std::left << "Payload PCDU Channel 6" << std::dec << "| " <<
unsigned(pdu2HkTableDataset.outEnabledPlPCDUCh6.value) << ", " <<
std::setw(4) << std::right <<
pdu2HkTableDataset.currentOutPayloadPCDUCh6.value << ", " << std::setw(4) <<
pdu2HkTableDataset.voltageOutPayloadPCDUCh6.value<< std::endl;
sif::info << std::setw(30) << std::left << "ACS Board Side B" << std::dec << "| " <<
unsigned(pdu2HkTableDataset.outEnabledAcsBoardSideB.value) << ", " <<
std::setw(4) << std::right <<
pdu2HkTableDataset.currentOutACSBoardSideB.value << ", " << std::setw(4) <<
pdu2HkTableDataset.voltageOutACSBoardSideB.value << std::endl;
sif::info << std::setw(30) << std::left << "Payload Camera enable state" << std::dec << "| " <<
unsigned(pdu2HkTableDataset.outEnabledPayloadCamera.value) << ", " <<
std::setw(4) << std::right <<
pdu2HkTableDataset.currentOutPayloadCamera.value << ", " << std::setw(4) <<
pdu2HkTableDataset.voltageOutPayloadCamera.value << std::right << std::endl;
sif::info << "PDU2 Info: SwitchState, Currents [mA], Voltages [mV]" << std::endl;
sif::info << std::setw(30) << std::left << "Q7S" << std::dec << "| "
<< unsigned(pdu2HkTableDataset.outEnabledQ7S.value) << ", " << std::setw(4)
<< std::right << pdu2HkTableDataset.currentOutQ7S.value << ", " << std::setw(4)
<< pdu2HkTableDataset.voltageOutQ7S.value << std::endl;
sif::info << std::setw(30) << std::left << "Payload PCDU Channel 1" << std::dec << "| "
<< unsigned(pdu2HkTableDataset.outEnabledPlPCDUCh1.value) << ", " << std::setw(4)
<< std::right << pdu2HkTableDataset.currentOutPayloadPCDUCh1.value << ", "
<< std::setw(4) << pdu2HkTableDataset.voltageOutPayloadPCDUCh1.value << std::endl;
sif::info << std::setw(30) << std::left << "Reaction Wheels" << std::dec << "| "
<< unsigned(pdu2HkTableDataset.outEnabledReactionWheels.value) << ", " << std::setw(4)
<< std::right << pdu2HkTableDataset.currentOutReactionWheels.value << ", "
<< std::setw(4) << pdu2HkTableDataset.voltageOutReactionWheels.value << std::endl;
sif::info << std::setw(30) << std::left << "TCS Board 8V heater input" << std::dec << "| "
<< unsigned(pdu2HkTableDataset.outEnabledTCSBoardHeaterIn.value) << ", " << std::setw(4)
<< std::right << pdu2HkTableDataset.currentOutTCSBoardHeaterIn.value << ", "
<< std::setw(4) << pdu2HkTableDataset.voltageOutTCSBoardHeaterIn.value << std::endl;
sif::info << std::setw(30) << std::left << "Redundant SUS group" << std::dec << "| "
<< unsigned(pdu2HkTableDataset.outEnabledSUSRedundant.value) << ", " << std::setw(4)
<< std::right << pdu2HkTableDataset.currentOutSUSRedundant.value << ", " << std::setw(4)
<< pdu2HkTableDataset.voltageOutSUSRedundant.value << std::endl;
sif::info << std::setw(30) << std::left << "Deployment mechanism" << std::dec << "| "
<< unsigned(pdu2HkTableDataset.outEnabledDeplMechanism.value) << ", " << std::setw(4)
<< std::right << pdu2HkTableDataset.currentOutDeplMechanism.value << ", "
<< std::setw(4) << pdu2HkTableDataset.voltageOutDeplMechanism.value << std::endl;
sif::info << std::setw(30) << std::left << "Payload PCDU Channel 6" << std::dec << "| "
<< unsigned(pdu2HkTableDataset.outEnabledPlPCDUCh6.value) << ", " << std::setw(4)
<< std::right << pdu2HkTableDataset.currentOutPayloadPCDUCh6.value << ", "
<< std::setw(4) << pdu2HkTableDataset.voltageOutPayloadPCDUCh6.value << std::endl;
sif::info << std::setw(30) << std::left << "ACS Board Side B" << std::dec << "| "
<< unsigned(pdu2HkTableDataset.outEnabledAcsBoardSideB.value) << ", " << std::setw(4)
<< std::right << pdu2HkTableDataset.currentOutACSBoardSideB.value << ", "
<< std::setw(4) << pdu2HkTableDataset.voltageOutACSBoardSideB.value << std::endl;
sif::info << std::setw(30) << std::left << "Payload Camera enable state" << std::dec << "| "
<< unsigned(pdu2HkTableDataset.outEnabledPayloadCamera.value) << ", " << std::setw(4)
<< std::right << pdu2HkTableDataset.currentOutPayloadCamera.value << ", "
<< std::setw(4) << pdu2HkTableDataset.voltageOutPayloadCamera.value << std::right
<< std::endl;
}

View File

@ -1,9 +1,10 @@
#ifndef MISSION_DEVICES_PDU2HANDLER_H_
#define MISSION_DEVICES_PDU2HANDLER_H_
#include "GomspaceDeviceHandler.h"
#include <mission/devices/devicedefinitions/GomspaceDefinitions.h>
#include "GomspaceDeviceHandler.h"
/**
* @brief This is the device handler for the PDU2.
*
@ -18,30 +19,29 @@
* ACS Board (Gyro, MGMs, GPS), 3.3V channel 7
* Payload Camera, 8V, channel 8
*/
class PDU2Handler: public GomspaceDeviceHandler {
public:
PDU2Handler(object_id_t objectId, object_id_t comIF, CookieIF * comCookie);
virtual ~PDU2Handler();
class PDU2Handler : public GomspaceDeviceHandler {
public:
PDU2Handler(object_id_t objectId, object_id_t comIF, CookieIF* comCookie);
virtual ~PDU2Handler();
virtual ReturnValue_t initializeLocalDataPool(localpool::DataPool& localDataPoolMap,
LocalDataPoolManager& poolManager) override;
virtual ReturnValue_t initializeLocalDataPool(localpool::DataPool& localDataPoolMap,
LocalDataPoolManager& poolManager) override;
protected:
/**
* @brief As soon as the device is in MODE_NORMAL, this function is executed periodically.
*/
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;
protected:
/**
* @brief As soon as the device is in MODE_NORMAL, this function is executed periodically.
*/
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:
private:
/** Dataset for the housekeeping table of the PDU2 */
PDU2::PDU2HkTableDataset pdu2HkTableDataset;
/** Dataset for the housekeeping table of the PDU2 */
PDU2::PDU2HkTableDataset pdu2HkTableDataset;
void printHkTable();
void printHkTable();
void parseHkTableReply(const uint8_t *packet);
void parseHkTableReply(const uint8_t* packet);
};
#endif /* MISSION_DEVICES_PDU2HANDLER_H_ */

View File

@ -1,497 +1,473 @@
#include "PlocMPSoCHandler.h"
#include <fsfw/datapool/PoolReadGuard.h>
#include <fsfw/globalfunctions/CRC.h>
#include "OBSWConfig.h"
#include <fsfw/globalfunctions/CRC.h>
#include <fsfw/datapool/PoolReadGuard.h>
PlocMPSoCHandler::PlocMPSoCHandler(object_id_t objectId, object_id_t comIF, CookieIF* comCookie)
: DeviceHandlerBase(objectId, comIF, comCookie) {
if (comCookie == NULL) {
sif::error << "PlocMPSoCHandler: Invalid com cookie" << std::endl;
}
}
PlocMPSoCHandler::PlocMPSoCHandler(object_id_t objectId, object_id_t comIF, CookieIF * comCookie) :
DeviceHandlerBase(objectId, comIF, comCookie) {
if (comCookie == NULL) {
sif::error << "PlocMPSoCHandler: Invalid com cookie" << std::endl;
PlocMPSoCHandler::~PlocMPSoCHandler() {}
void PlocMPSoCHandler::doStartUp() {
if (mode == _MODE_START_UP) {
setMode(MODE_ON);
}
}
void PlocMPSoCHandler::doShutDown() { setMode(_MODE_POWER_DOWN); }
ReturnValue_t PlocMPSoCHandler::buildNormalDeviceCommand(DeviceCommandId_t* id) {
return RETURN_OK;
}
ReturnValue_t PlocMPSoCHandler::buildTransitionDeviceCommand(DeviceCommandId_t* id) {
return HasReturnvaluesIF::RETURN_OK;
}
ReturnValue_t PlocMPSoCHandler::buildCommandFromCommand(DeviceCommandId_t deviceCommand,
const uint8_t* commandData,
size_t commandDataLen) {
switch (deviceCommand) {
case (PLOC_MPSOC::TC_MEM_WRITE): {
return prepareTcMemWriteCommand(commandData, commandDataLen);
}
}
PlocMPSoCHandler::~PlocMPSoCHandler() {
}
void PlocMPSoCHandler::doStartUp(){
if(mode == _MODE_START_UP){
setMode(MODE_ON);
}
}
void PlocMPSoCHandler::doShutDown(){
setMode(_MODE_POWER_DOWN);
}
ReturnValue_t PlocMPSoCHandler::buildNormalDeviceCommand(
DeviceCommandId_t * id) {
return RETURN_OK;
}
ReturnValue_t PlocMPSoCHandler::buildTransitionDeviceCommand(
DeviceCommandId_t * id){
return HasReturnvaluesIF::RETURN_OK;
}
ReturnValue_t PlocMPSoCHandler::buildCommandFromCommand(
DeviceCommandId_t deviceCommand, const uint8_t * commandData,
size_t commandDataLen) {
switch(deviceCommand) {
case(PLOC_MPSOC::TC_MEM_WRITE): {
return prepareTcMemWriteCommand(commandData, commandDataLen);
}
case(PLOC_MPSOC::TC_MEM_READ): {
return prepareTcMemReadCommand(commandData, commandDataLen);
}
default:
sif::debug << "PlocMPSoCHandler::buildCommandFromCommand: Command not implemented" << std::endl;
return DeviceHandlerIF::COMMAND_NOT_IMPLEMENTED;
}
return HasReturnvaluesIF::RETURN_FAILED;
case (PLOC_MPSOC::TC_MEM_READ): {
return prepareTcMemReadCommand(commandData, commandDataLen);
}
default:
sif::debug << "PlocMPSoCHandler::buildCommandFromCommand: Command not implemented"
<< std::endl;
return DeviceHandlerIF::COMMAND_NOT_IMPLEMENTED;
}
return HasReturnvaluesIF::RETURN_FAILED;
}
void PlocMPSoCHandler::fillCommandAndReplyMap() {
this->insertInCommandMap(PLOC_MPSOC::TC_MEM_WRITE);
this->insertInCommandMap(PLOC_MPSOC::TC_MEM_READ);
this->insertInReplyMap(PLOC_MPSOC::ACK_REPORT, 1, nullptr, PLOC_MPSOC::SIZE_ACK_REPORT);
this->insertInReplyMap(PLOC_MPSOC::EXE_REPORT, 3, nullptr, PLOC_MPSOC::SIZE_EXE_REPORT);
this->insertInReplyMap(PLOC_MPSOC::TM_MEMORY_READ_REPORT, 2, nullptr, PLOC_MPSOC::SIZE_TM_MEM_READ_REPORT);
this->insertInCommandMap(PLOC_MPSOC::TC_MEM_WRITE);
this->insertInCommandMap(PLOC_MPSOC::TC_MEM_READ);
this->insertInReplyMap(PLOC_MPSOC::ACK_REPORT, 1, nullptr, PLOC_MPSOC::SIZE_ACK_REPORT);
this->insertInReplyMap(PLOC_MPSOC::EXE_REPORT, 3, nullptr, PLOC_MPSOC::SIZE_EXE_REPORT);
this->insertInReplyMap(PLOC_MPSOC::TM_MEMORY_READ_REPORT, 2, nullptr,
PLOC_MPSOC::SIZE_TM_MEM_READ_REPORT);
}
ReturnValue_t PlocMPSoCHandler::scanForReply(const uint8_t *start,
size_t remainingSize, DeviceCommandId_t *foundId, size_t *foundLen) {
ReturnValue_t PlocMPSoCHandler::scanForReply(const uint8_t* start, size_t remainingSize,
DeviceCommandId_t* foundId, size_t* foundLen) {
ReturnValue_t result = RETURN_OK;
ReturnValue_t result = RETURN_OK;
uint16_t apid = (*(start) << 8 | *(start + 1)) & APID_MASK;
uint16_t apid = (*(start) << 8 | *(start + 1)) & APID_MASK;
switch (apid) {
case (PLOC_MPSOC::APID_ACK_SUCCESS):
*foundLen = PLOC_MPSOC::SIZE_ACK_REPORT;
*foundId = PLOC_MPSOC::ACK_REPORT;
break;
case (PLOC_MPSOC::APID_ACK_FAILURE):
*foundLen = PLOC_MPSOC::SIZE_ACK_REPORT;
*foundId = PLOC_MPSOC::ACK_REPORT;
break;
case (PLOC_MPSOC::APID_TM_MEMORY_READ_REPORT):
*foundLen = PLOC_MPSOC::SIZE_TM_MEM_READ_REPORT;
*foundId = PLOC_MPSOC::TM_MEMORY_READ_REPORT;
break;
case (PLOC_MPSOC::APID_EXE_SUCCESS):
*foundLen = PLOC_MPSOC::SIZE_EXE_REPORT;
*foundId = PLOC_MPSOC::EXE_REPORT;
break;
case (PLOC_MPSOC::APID_EXE_FAILURE):
*foundLen = PLOC_MPSOC::SIZE_EXE_REPORT;
*foundId = PLOC_MPSOC::EXE_REPORT;
break;
default: {
sif::debug << "PlocMPSoCHandler::scanForReply: Reply has invalid apid" << std::endl;
*foundLen = remainingSize;
return INVALID_APID;
}
}
switch(apid) {
case(PLOC_MPSOC::APID_ACK_SUCCESS):
*foundLen = PLOC_MPSOC::SIZE_ACK_REPORT;
*foundId = PLOC_MPSOC::ACK_REPORT;
break;
case(PLOC_MPSOC::APID_ACK_FAILURE):
*foundLen = PLOC_MPSOC::SIZE_ACK_REPORT;
*foundId = PLOC_MPSOC::ACK_REPORT;
break;
case(PLOC_MPSOC::APID_TM_MEMORY_READ_REPORT):
*foundLen = PLOC_MPSOC::SIZE_TM_MEM_READ_REPORT;
*foundId = PLOC_MPSOC::TM_MEMORY_READ_REPORT;
break;
case(PLOC_MPSOC::APID_EXE_SUCCESS):
*foundLen = PLOC_MPSOC::SIZE_EXE_REPORT;
*foundId = PLOC_MPSOC::EXE_REPORT;
break;
case(PLOC_MPSOC::APID_EXE_FAILURE):
*foundLen = PLOC_MPSOC::SIZE_EXE_REPORT;
*foundId = PLOC_MPSOC::EXE_REPORT;
break;
default: {
sif::debug << "PlocMPSoCHandler::scanForReply: Reply has invalid apid" << std::endl;
*foundLen = remainingSize;
return INVALID_APID;
}
}
/**
* This should normally never fail. However, this function is also responsible for incrementing
* the packet sequence count why it is called here.
*/
result = checkPacketSequenceCount(start);
/**
* This should normally never fail. However, this function is also responsible for incrementing
* the packet sequence count why it is called here.
*/
result = checkPacketSequenceCount(start);
return result;
return result;
}
ReturnValue_t PlocMPSoCHandler::interpretDeviceReply(DeviceCommandId_t id,
const uint8_t *packet) {
ReturnValue_t PlocMPSoCHandler::interpretDeviceReply(DeviceCommandId_t id, const uint8_t* packet) {
ReturnValue_t result = RETURN_OK;
ReturnValue_t result = RETURN_OK;
switch (id) {
switch (id) {
case PLOC_MPSOC::ACK_REPORT: {
result = handleAckReport(packet);
break;
result = handleAckReport(packet);
break;
}
case (PLOC_MPSOC::TM_MEMORY_READ_REPORT): {
result = handleMemoryReadReport(packet);
break;
result = handleMemoryReadReport(packet);
break;
}
case (PLOC_MPSOC::EXE_REPORT): {
result = handleExecutionReport(packet);
break;
result = handleExecutionReport(packet);
break;
}
default: {
sif::debug << "PlocMPSoCHandler::interpretDeviceReply: Unknown device reply id" << std::endl;
return DeviceHandlerIF::UNKNOWN_DEVICE_REPLY;
}
sif::debug << "PlocMPSoCHandler::interpretDeviceReply: Unknown device reply id" << std::endl;
return DeviceHandlerIF::UNKNOWN_DEVICE_REPLY;
}
}
return result;
return result;
}
void PlocMPSoCHandler::setNormalDatapoolEntriesInvalid(){
void PlocMPSoCHandler::setNormalDatapoolEntriesInvalid() {}
}
uint32_t PlocMPSoCHandler::getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo){
return 500;
}
uint32_t PlocMPSoCHandler::getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) { return 500; }
ReturnValue_t PlocMPSoCHandler::initializeLocalDataPool(localpool::DataPool& localDataPoolMap,
LocalDataPoolManager& poolManager) {
return HasReturnvaluesIF::RETURN_OK;
LocalDataPoolManager& poolManager) {
return HasReturnvaluesIF::RETURN_OK;
}
void PlocMPSoCHandler::setModeNormal() {
mode = MODE_NORMAL;
void PlocMPSoCHandler::setModeNormal() { mode = MODE_NORMAL; }
ReturnValue_t PlocMPSoCHandler::prepareTcMemWriteCommand(const uint8_t* commandData,
size_t commandDataLen) {
const uint32_t memoryAddress = *(commandData) << 24 | *(commandData + 1) << 16 |
*(commandData + 2) << 8 | *(commandData + 3);
const uint32_t memoryData = *(commandData + 4) << 24 | *(commandData + 5) << 16 |
*(commandData + 6) << 8 | *(commandData + 7);
packetSequenceCount = (packetSequenceCount + 1) & PACKET_SEQUENCE_COUNT_MASK;
PLOC_MPSOC::TcMemWrite tcMemWrite(memoryAddress, memoryData, packetSequenceCount);
if (tcMemWrite.getFullSize() > PLOC_MPSOC::MAX_COMMAND_SIZE) {
sif::debug << "PlocMPSoCHandler::prepareTcMemWriteCommand: Command too big" << std::endl;
return RETURN_FAILED;
}
memcpy(commandBuffer, tcMemWrite.getWholeData(), tcMemWrite.getFullSize());
rawPacket = commandBuffer;
rawPacketLen = tcMemWrite.getFullSize();
nextReplyId = PLOC_MPSOC::ACK_REPORT;
return RETURN_OK;
}
ReturnValue_t PlocMPSoCHandler::prepareTcMemWriteCommand(const uint8_t * commandData,
size_t commandDataLen) {
const uint32_t memoryAddress = *(commandData) << 24 | *(commandData + 1) << 16
| *(commandData + 2) << 8 | *(commandData + 3);
const uint32_t memoryData = *(commandData + 4) << 24 | *(commandData + 5) << 16
| *(commandData + 6) << 8 | *(commandData + 7);
packetSequenceCount = (packetSequenceCount + 1) & PACKET_SEQUENCE_COUNT_MASK;
PLOC_MPSOC::TcMemWrite tcMemWrite(memoryAddress, memoryData, packetSequenceCount);
if (tcMemWrite.getFullSize() > PLOC_MPSOC::MAX_COMMAND_SIZE) {
sif::debug << "PlocMPSoCHandler::prepareTcMemWriteCommand: Command too big" << std::endl;
return RETURN_FAILED;
}
memcpy(commandBuffer, tcMemWrite.getWholeData(), tcMemWrite.getFullSize());
rawPacket = commandBuffer;
rawPacketLen = tcMemWrite.getFullSize();
nextReplyId = PLOC_MPSOC::ACK_REPORT;
return RETURN_OK;
}
ReturnValue_t PlocMPSoCHandler::prepareTcMemReadCommand(const uint8_t* commandData,
size_t commandDataLen) {
const uint32_t memoryAddress = *(commandData) << 24 | *(commandData + 1) << 16 |
*(commandData + 2) << 8 | *(commandData + 3);
packetSequenceCount = (packetSequenceCount + 1) & PACKET_SEQUENCE_COUNT_MASK;
PLOC_MPSOC::TcMemRead tcMemRead(memoryAddress, packetSequenceCount);
if (tcMemRead.getFullSize() > PLOC_MPSOC::MAX_COMMAND_SIZE) {
sif::debug << "PlocMPSoCHandler::prepareTcMemReadCommand: Command too big" << std::endl;
return RETURN_FAILED;
}
memcpy(commandBuffer, tcMemRead.getWholeData(), tcMemRead.getFullSize());
rawPacket = commandBuffer;
rawPacketLen = tcMemRead.getFullSize();
nextReplyId = PLOC_MPSOC::ACK_REPORT;
ReturnValue_t PlocMPSoCHandler::prepareTcMemReadCommand(const uint8_t * commandData,
size_t commandDataLen) {
const uint32_t memoryAddress = *(commandData) << 24 | *(commandData + 1) << 16
| *(commandData + 2) << 8 | *(commandData + 3);
packetSequenceCount = (packetSequenceCount + 1) & PACKET_SEQUENCE_COUNT_MASK;
PLOC_MPSOC::TcMemRead tcMemRead(memoryAddress, packetSequenceCount);
if (tcMemRead.getFullSize() > PLOC_MPSOC::MAX_COMMAND_SIZE) {
sif::debug << "PlocMPSoCHandler::prepareTcMemReadCommand: Command too big" << std::endl;
return RETURN_FAILED;
}
memcpy(commandBuffer, tcMemRead.getWholeData(), tcMemRead.getFullSize());
rawPacket = commandBuffer;
rawPacketLen = tcMemRead.getFullSize();
nextReplyId = PLOC_MPSOC::ACK_REPORT;
return RETURN_OK;
return RETURN_OK;
}
ReturnValue_t PlocMPSoCHandler::verifyPacket(const uint8_t* start, size_t foundLen) {
uint16_t receivedCrc = *(start + foundLen - 2) << 8 | *(start + foundLen - 1);
uint16_t receivedCrc = *(start + foundLen - 2) << 8 | *(start + foundLen - 1);
uint16_t recalculatedCrc = CRC::crc16ccitt(start, foundLen - 2);
uint16_t recalculatedCrc = CRC::crc16ccitt(start, foundLen - 2);
if (receivedCrc != recalculatedCrc) {
return CRC_FAILURE;
}
if (receivedCrc != recalculatedCrc) {
return CRC_FAILURE;
}
return RETURN_OK;
return RETURN_OK;
}
ReturnValue_t PlocMPSoCHandler::handleAckReport(const uint8_t* data) {
ReturnValue_t result = RETURN_OK;
ReturnValue_t result = RETURN_OK;
result = verifyPacket(data, PLOC_MPSOC::SIZE_ACK_REPORT);
if (result == CRC_FAILURE) {
sif::error << "PlocMPSoCHandler::handleAckReport: CRC failure" << std::endl;
nextReplyId = PLOC_MPSOC::NONE;
replyRawReplyIfnotWiretapped(data, PLOC_MPSOC::SIZE_ACK_REPORT);
triggerEvent(CRC_FAILURE_EVENT);
sendFailureReport(PLOC_MPSOC::ACK_REPORT, CRC_FAILURE);
disableAllReplies();
return IGNORE_REPLY_DATA;
}
result = verifyPacket(data, PLOC_MPSOC::SIZE_ACK_REPORT);
if(result == CRC_FAILURE) {
sif::error << "PlocMPSoCHandler::handleAckReport: CRC failure" << std::endl;
nextReplyId = PLOC_MPSOC::NONE;
replyRawReplyIfnotWiretapped(data, PLOC_MPSOC::SIZE_ACK_REPORT);
triggerEvent(CRC_FAILURE_EVENT);
sendFailureReport(PLOC_MPSOC::ACK_REPORT, CRC_FAILURE);
disableAllReplies();
return IGNORE_REPLY_DATA;
uint16_t apid = (*(data) << 8 | *(data + 1)) & APID_MASK;
switch (apid) {
case PLOC_MPSOC::APID_ACK_FAILURE: {
// TODO: Interpretation of status field in acknowledgment report
sif::debug << "PlocMPSoCHandler::handleAckReport: Received Ack failure report" << std::endl;
DeviceCommandId_t commandId = getPendingCommand();
if (commandId != DeviceHandlerIF::NO_COMMAND_ID) {
triggerEvent(ACK_FAILURE, commandId);
}
sendFailureReport(PLOC_MPSOC::ACK_REPORT, RECEIVED_ACK_FAILURE);
disableAllReplies();
nextReplyId = PLOC_MPSOC::NONE;
result = IGNORE_REPLY_DATA;
break;
}
case PLOC_MPSOC::APID_ACK_SUCCESS: {
setNextReplyId();
break;
}
default: {
sif::debug << "PlocMPSoCHandler::handleAckReport: Invalid APID in Ack report" << std::endl;
result = RETURN_FAILED;
break;
}
}
uint16_t apid = (*(data) << 8 | *(data + 1)) & APID_MASK;
switch(apid) {
case PLOC_MPSOC::APID_ACK_FAILURE: {
//TODO: Interpretation of status field in acknowledgment report
sif::debug << "PlocMPSoCHandler::handleAckReport: Received Ack failure report" << std::endl;
DeviceCommandId_t commandId = getPendingCommand();
if (commandId != DeviceHandlerIF::NO_COMMAND_ID) {
triggerEvent(ACK_FAILURE, commandId);
}
sendFailureReport(PLOC_MPSOC::ACK_REPORT, RECEIVED_ACK_FAILURE);
disableAllReplies();
nextReplyId = PLOC_MPSOC::NONE;
result = IGNORE_REPLY_DATA;
break;
}
case PLOC_MPSOC::APID_ACK_SUCCESS: {
setNextReplyId();
break;
}
default: {
sif::debug << "PlocMPSoCHandler::handleAckReport: Invalid APID in Ack report" << std::endl;
result = RETURN_FAILED;
break;
}
}
return result;
return result;
}
ReturnValue_t PlocMPSoCHandler::handleExecutionReport(const uint8_t* data) {
ReturnValue_t result = RETURN_OK;
ReturnValue_t result = RETURN_OK;
result = verifyPacket(data, PLOC_MPSOC::SIZE_EXE_REPORT);
if (result == CRC_FAILURE) {
sif::error << "PlocMPSoCHandler::handleExecutionReport: CRC failure" << std::endl;
nextReplyId = PLOC_MPSOC::NONE;
return result;
}
result = verifyPacket(data, PLOC_MPSOC::SIZE_EXE_REPORT);
if(result == CRC_FAILURE) {
sif::error << "PlocMPSoCHandler::handleExecutionReport: CRC failure" << std::endl;
nextReplyId = PLOC_MPSOC::NONE;
return result;
}
uint16_t apid = (*(data) << 8 | *(data + 1)) & APID_MASK;
uint16_t apid = (*(data) << 8 | *(data + 1)) & APID_MASK;
switch (apid) {
switch (apid) {
case (PLOC_MPSOC::APID_EXE_SUCCESS): {
break;
break;
}
case (PLOC_MPSOC::APID_EXE_FAILURE): {
//TODO: Interpretation of status field in execution report
sif::error << "PlocMPSoCHandler::handleExecutionReport: Received execution failure report"
<< std::endl;
DeviceCommandId_t commandId = getPendingCommand();
if (commandId != DeviceHandlerIF::NO_COMMAND_ID) {
triggerEvent(EXE_FAILURE, commandId);
}
else {
sif::debug << "PlocMPSoCHandler::handleExecutionReport: Unknown command id" << std::endl;
}
sendFailureReport(PLOC_MPSOC::EXE_REPORT, RECEIVED_EXE_FAILURE);
disableExeReportReply();
result = IGNORE_REPLY_DATA;
break;
// TODO: Interpretation of status field in execution report
sif::error << "PlocMPSoCHandler::handleExecutionReport: Received execution failure report"
<< std::endl;
DeviceCommandId_t commandId = getPendingCommand();
if (commandId != DeviceHandlerIF::NO_COMMAND_ID) {
triggerEvent(EXE_FAILURE, commandId);
} else {
sif::debug << "PlocMPSoCHandler::handleExecutionReport: Unknown command id" << std::endl;
}
sendFailureReport(PLOC_MPSOC::EXE_REPORT, RECEIVED_EXE_FAILURE);
disableExeReportReply();
result = IGNORE_REPLY_DATA;
break;
}
default: {
sif::error << "PlocMPSoCHandler::handleExecutionReport: Unknown APID" << std::endl;
result = RETURN_FAILED;
break;
}
sif::error << "PlocMPSoCHandler::handleExecutionReport: Unknown APID" << std::endl;
result = RETURN_FAILED;
break;
}
}
nextReplyId = PLOC_MPSOC::NONE;
nextReplyId = PLOC_MPSOC::NONE;
return result;
return result;
}
ReturnValue_t PlocMPSoCHandler::handleMemoryReadReport(const uint8_t* data) {
ReturnValue_t result = RETURN_OK;
ReturnValue_t result = RETURN_OK;
result = verifyPacket(data, PLOC_MPSOC::SIZE_TM_MEM_READ_REPORT);
result = verifyPacket(data, PLOC_MPSOC::SIZE_TM_MEM_READ_REPORT);
if (result == CRC_FAILURE) {
sif::error << "PlocMPSoCHandler::handleMemoryReadReport: Memory read report has invalid crc"
<< std::endl;
}
/** Send data to commanding queue */
handleDeviceTM(data + PLOC_MPSOC::DATA_FIELD_OFFSET, PLOC_MPSOC::SIZE_MEM_READ_REPORT_DATA,
PLOC_MPSOC::TM_MEMORY_READ_REPORT);
if(result == CRC_FAILURE) {
sif::error << "PlocMPSoCHandler::handleMemoryReadReport: Memory read report has invalid crc"
<< std::endl;
}
/** Send data to commanding queue */
handleDeviceTM(data + PLOC_MPSOC::DATA_FIELD_OFFSET, PLOC_MPSOC::SIZE_MEM_READ_REPORT_DATA,
PLOC_MPSOC::TM_MEMORY_READ_REPORT);
nextReplyId = PLOC_MPSOC::EXE_REPORT;
nextReplyId = PLOC_MPSOC::EXE_REPORT;
return result;
return result;
}
ReturnValue_t PlocMPSoCHandler::enableReplyInReplyMap(DeviceCommandMap::iterator command,
uint8_t expectedReplies, bool useAlternateId,
DeviceCommandId_t alternateReplyID) {
uint8_t expectedReplies, bool useAlternateId,
DeviceCommandId_t alternateReplyID) {
ReturnValue_t result = RETURN_OK;
ReturnValue_t result = RETURN_OK;
uint8_t enabledReplies = 0;
uint8_t enabledReplies = 0;
switch (command->first) {
switch (command->first) {
case PLOC_MPSOC::TC_MEM_WRITE:
enabledReplies = 2;
break;
enabledReplies = 2;
break;
case PLOC_MPSOC::TC_MEM_READ: {
enabledReplies = 3;
result = DeviceHandlerBase::enableReplyInReplyMap(command, enabledReplies, true,
PLOC_MPSOC::TM_MEMORY_READ_REPORT);
if (result != RETURN_OK) {
sif::debug << "PlocMPSoCHandler::enableReplyInReplyMap: Reply with id "
<< PLOC_MPSOC::TM_MEMORY_READ_REPORT << " not in replyMap" << std::endl;
}
break;
enabledReplies = 3;
result = DeviceHandlerBase::enableReplyInReplyMap(command, enabledReplies, true,
PLOC_MPSOC::TM_MEMORY_READ_REPORT);
if (result != RETURN_OK) {
sif::debug << "PlocMPSoCHandler::enableReplyInReplyMap: Reply with id "
<< PLOC_MPSOC::TM_MEMORY_READ_REPORT << " not in replyMap" << std::endl;
}
break;
}
default:
sif::debug << "PlocMPSoCHandler::enableReplyInReplyMap: Unknown command id" << std::endl;
break;
}
sif::debug << "PlocMPSoCHandler::enableReplyInReplyMap: Unknown command id" << std::endl;
break;
}
/**
* Every command causes at least one acknowledgment and one execution report. Therefore both
* replies will be enabled here.
*/
result = DeviceHandlerBase::enableReplyInReplyMap(command,
enabledReplies, true, PLOC_MPSOC::ACK_REPORT);
if (result != RETURN_OK) {
sif::debug << "PlocMPSoCHandler::enableReplyInReplyMap: Reply with id " << PLOC_MPSOC::ACK_REPORT
<< " not in replyMap" << std::endl;
}
/**
* Every command causes at least one acknowledgment and one execution report. Therefore both
* replies will be enabled here.
*/
result = DeviceHandlerBase::enableReplyInReplyMap(command, enabledReplies, true,
PLOC_MPSOC::ACK_REPORT);
if (result != RETURN_OK) {
sif::debug << "PlocMPSoCHandler::enableReplyInReplyMap: Reply with id "
<< PLOC_MPSOC::ACK_REPORT << " not in replyMap" << std::endl;
}
result = DeviceHandlerBase::enableReplyInReplyMap(command,
enabledReplies, true, PLOC_MPSOC::EXE_REPORT);
if (result != RETURN_OK) {
sif::debug << "PlocMPSoCHandler::enableReplyInReplyMap: Reply with id " << PLOC_MPSOC::EXE_REPORT
<< " not in replyMap" << std::endl;
}
result = DeviceHandlerBase::enableReplyInReplyMap(command, enabledReplies, true,
PLOC_MPSOC::EXE_REPORT);
if (result != RETURN_OK) {
sif::debug << "PlocMPSoCHandler::enableReplyInReplyMap: Reply with id "
<< PLOC_MPSOC::EXE_REPORT << " not in replyMap" << std::endl;
}
return RETURN_OK;
return RETURN_OK;
}
void PlocMPSoCHandler::setNextReplyId() {
switch(getPendingCommand()) {
switch (getPendingCommand()) {
case PLOC_MPSOC::TC_MEM_READ:
nextReplyId = PLOC_MPSOC::TM_MEMORY_READ_REPORT;
break;
nextReplyId = PLOC_MPSOC::TM_MEMORY_READ_REPORT;
break;
default:
/* If no telemetry is expected the next reply is always the execution report */
nextReplyId = PLOC_MPSOC::EXE_REPORT;
break;
}
/* If no telemetry is expected the next reply is always the execution report */
nextReplyId = PLOC_MPSOC::EXE_REPORT;
break;
}
}
size_t PlocMPSoCHandler::getNextReplyLength(DeviceCommandId_t commandId){
size_t replyLen = 0;
if (nextReplyId == PLOC_MPSOC::NONE) {
return replyLen;
}
DeviceReplyIter iter = deviceReplyMap.find(nextReplyId);
if (iter != deviceReplyMap.end()) {
if (iter->second.delayCycles == 0) {
/* Reply inactive */
return replyLen;
}
replyLen = iter->second.replyLen;
}
else {
sif::debug << "PlocMPSoCHandler::getNextReplyLength: No entry for reply with reply id "
<< std::hex << nextReplyId << " in deviceReplyMap" << std::endl;
}
size_t PlocMPSoCHandler::getNextReplyLength(DeviceCommandId_t commandId) {
size_t replyLen = 0;
if (nextReplyId == PLOC_MPSOC::NONE) {
return replyLen;
}
DeviceReplyIter iter = deviceReplyMap.find(nextReplyId);
if (iter != deviceReplyMap.end()) {
if (iter->second.delayCycles == 0) {
/* Reply inactive */
return replyLen;
}
replyLen = iter->second.replyLen;
} else {
sif::debug << "PlocMPSoCHandler::getNextReplyLength: No entry for reply with reply id "
<< std::hex << nextReplyId << " in deviceReplyMap" << std::endl;
}
return replyLen;
}
void PlocMPSoCHandler::handleDeviceTM(const uint8_t* data, size_t dataSize, DeviceCommandId_t replyId) {
void PlocMPSoCHandler::handleDeviceTM(const uint8_t* data, size_t dataSize,
DeviceCommandId_t replyId) {
ReturnValue_t result = RETURN_OK;
ReturnValue_t result = RETURN_OK;
if (wiretappingMode == RAW) {
/* Data already sent in doGetRead() */
return;
}
if (wiretappingMode == RAW) {
/* Data already sent in doGetRead() */
return;
}
DeviceReplyMap::iterator iter = deviceReplyMap.find(replyId);
if (iter == deviceReplyMap.end()) {
sif::debug << "PlocMPSoCHandler::handleDeviceTM: Unknown reply id" << std::endl;
return;
}
MessageQueueId_t queueId = iter->second.command->second.sendReplyTo;
DeviceReplyMap::iterator iter = deviceReplyMap.find(replyId);
if (iter == deviceReplyMap.end()) {
sif::debug << "PlocMPSoCHandler::handleDeviceTM: Unknown reply id" << std::endl;
return;
}
MessageQueueId_t queueId = iter->second.command->second.sendReplyTo;
if (queueId == NO_COMMANDER) {
return;
}
if (queueId == NO_COMMANDER) {
return;
}
result = actionHelper.reportData(queueId, replyId, data, dataSize);
if (result != RETURN_OK) {
sif::debug << "PlocMPSoCHandler::handleDeviceTM: Failed to report data" << std::endl;
}
result = actionHelper.reportData(queueId, replyId, data, dataSize);
if (result != RETURN_OK) {
sif::debug << "PlocMPSoCHandler::handleDeviceTM: Failed to report data" << std::endl;
}
}
void PlocMPSoCHandler::disableAllReplies() {
DeviceReplyMap::iterator iter;
DeviceReplyMap::iterator iter;
/* Disable ack reply */
iter = deviceReplyMap.find(PLOC_MPSOC::ACK_REPORT);
DeviceReplyInfo* info = &(iter->second);
info->delayCycles = 0;
info->command = deviceCommandMap.end();
/* Disable ack reply */
iter = deviceReplyMap.find(PLOC_MPSOC::ACK_REPORT);
DeviceReplyInfo *info = &(iter->second);
info->delayCycles = 0;
info->command = deviceCommandMap.end();
DeviceCommandId_t commandId = getPendingCommand();
DeviceCommandId_t commandId = getPendingCommand();
/* If the command expects a telemetry packet the appropriate tm reply will be disabled here */
switch (commandId) {
/* If the command expects a telemetry packet the appropriate tm reply will be disabled here */
switch (commandId) {
case PLOC_MPSOC::TC_MEM_WRITE:
break;
break;
case PLOC_MPSOC::TC_MEM_READ: {
iter = deviceReplyMap.find(PLOC_MPSOC::TM_MEMORY_READ_REPORT);
info = &(iter->second);
info->delayCycles = 0;
info->command = deviceCommandMap.end();
break;
iter = deviceReplyMap.find(PLOC_MPSOC::TM_MEMORY_READ_REPORT);
info = &(iter->second);
info->delayCycles = 0;
info->command = deviceCommandMap.end();
break;
}
default: {
sif::debug << "PlocMPSoCHandler::disableAllReplies: Unknown command id" << commandId
<< std::endl;
break;
}
sif::debug << "PlocMPSoCHandler::disableAllReplies: Unknown command id" << commandId
<< std::endl;
break;
}
}
/* We must always disable the execution report reply here */
disableExeReportReply();
/* We must always disable the execution report reply here */
disableExeReportReply();
}
void PlocMPSoCHandler::sendFailureReport(DeviceCommandId_t replyId, ReturnValue_t status) {
DeviceReplyIter iter = deviceReplyMap.find(replyId);
DeviceReplyIter iter = deviceReplyMap.find(replyId);
if (iter == deviceReplyMap.end()) {
sif::debug << "PlocMPSoCHandler::sendFailureReport: Reply not in reply map" << std::endl;
return;
}
if (iter == deviceReplyMap.end()) {
sif::debug << "PlocMPSoCHandler::sendFailureReport: Reply not in reply map" << std::endl;
return;
}
DeviceCommandInfo* info = &(iter->second.command->second);
DeviceCommandInfo* info = &(iter->second.command->second);
if (info == nullptr) {
sif::debug << "PlocMPSoCHandler::sendFailureReport: Reply has no active command" << std::endl;
return;
}
if (info == nullptr) {
sif::debug << "PlocMPSoCHandler::sendFailureReport: Reply has no active command" << std::endl;
return;
}
if (info->sendReplyTo != NO_COMMANDER) {
actionHelper.finish(false, info->sendReplyTo, iter->first, status);
}
info->isExecuting = false;
if (info->sendReplyTo != NO_COMMANDER) {
actionHelper.finish(false, info->sendReplyTo, iter->first, status);
}
info->isExecuting = false;
}
void PlocMPSoCHandler::disableExeReportReply() {
DeviceReplyIter iter = deviceReplyMap.find(PLOC_MPSOC::EXE_REPORT);
DeviceReplyInfo *info = &(iter->second);
info->delayCycles = 0;
info->command = deviceCommandMap.end();
/* Expected replies is set to one here. The value will set to 0 in replyToReply() */
info->command->second.expectedReplies = 0;
DeviceReplyIter iter = deviceReplyMap.find(PLOC_MPSOC::EXE_REPORT);
DeviceReplyInfo* info = &(iter->second);
info->delayCycles = 0;
info->command = deviceCommandMap.end();
/* Expected replies is set to one here. The value will set to 0 in replyToReply() */
info->command->second.expectedReplies = 0;
}
ReturnValue_t PlocMPSoCHandler::checkPacketSequenceCount(const uint8_t* data) {
uint16_t receivedSequenceCount = (*(data + 2) << 8 | *(data + 3)) & PACKET_SEQUENCE_COUNT_MASK;
uint16_t expectedPacketSequenceCount = ((packetSequenceCount + 1) & PACKET_SEQUENCE_COUNT_MASK);
if (receivedSequenceCount != expectedPacketSequenceCount) {
sif::debug
<< "PlocMPSoCHandler::checkPacketSequenceCount: Packet sequence count mismatch. "
<< std::endl;
sif::debug << "Received sequence count: " << receivedSequenceCount << ". OBSW sequence "
<< "count: " << expectedPacketSequenceCount << std::endl;
}
packetSequenceCount = receivedSequenceCount;
return RETURN_OK;
uint16_t receivedSequenceCount = (*(data + 2) << 8 | *(data + 3)) & PACKET_SEQUENCE_COUNT_MASK;
uint16_t expectedPacketSequenceCount = ((packetSequenceCount + 1) & PACKET_SEQUENCE_COUNT_MASK);
if (receivedSequenceCount != expectedPacketSequenceCount) {
sif::debug << "PlocMPSoCHandler::checkPacketSequenceCount: Packet sequence count mismatch. "
<< std::endl;
sif::debug << "Received sequence count: " << receivedSequenceCount << ". OBSW sequence "
<< "count: " << expectedPacketSequenceCount << std::endl;
}
packetSequenceCount = receivedSequenceCount;
return RETURN_OK;
}

View File

@ -3,6 +3,7 @@
#include <fsfw/devicehandlers/DeviceHandlerBase.h>
#include <mission/devices/devicedefinitions/PlocMPSoCDefinitions.h>
#include <cstring>
/**
@ -18,189 +19,194 @@
* Arbeitsdaten/08_Used%20Components/PLOC&fileid=940960
* @author J. Meier
*/
class PlocMPSoCHandler: public DeviceHandlerBase {
public:
class PlocMPSoCHandler : public DeviceHandlerBase {
public:
PlocMPSoCHandler(object_id_t objectId, object_id_t comIF, CookieIF* comCookie);
virtual ~PlocMPSoCHandler();
PlocMPSoCHandler(object_id_t objectId, object_id_t comIF, CookieIF * comCookie);
virtual ~PlocMPSoCHandler();
/**
* @brief Sets mode to MODE_NORMAL. Can be used for debugging.
*/
void setModeNormal();
/**
* @brief Sets mode to MODE_NORMAL. Can be used for debugging.
*/
void setModeNormal();
protected:
void doStartUp() override;
void doShutDown() override;
ReturnValue_t buildNormalDeviceCommand(DeviceCommandId_t* id) override;
ReturnValue_t buildTransitionDeviceCommand(DeviceCommandId_t* id) override;
void fillCommandAndReplyMap() override;
ReturnValue_t buildCommandFromCommand(DeviceCommandId_t deviceCommand, const uint8_t* commandData,
size_t commandDataLen) override;
ReturnValue_t scanForReply(const uint8_t* start, size_t remainingSize, DeviceCommandId_t* foundId,
size_t* foundLen) override;
ReturnValue_t interpretDeviceReply(DeviceCommandId_t id, const uint8_t* packet) override;
void setNormalDatapoolEntriesInvalid() override;
uint32_t getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) override;
ReturnValue_t initializeLocalDataPool(localpool::DataPool& localDataPoolMap,
LocalDataPoolManager& poolManager) override;
ReturnValue_t enableReplyInReplyMap(DeviceCommandMap::iterator command,
uint8_t expectedReplies = 1, bool useAlternateId = false,
DeviceCommandId_t alternateReplyID = 0) override;
size_t getNextReplyLength(DeviceCommandId_t deviceCommand) override;
protected:
void doStartUp() override;
void doShutDown() override;
ReturnValue_t buildNormalDeviceCommand(DeviceCommandId_t * id) override;
ReturnValue_t buildTransitionDeviceCommand(DeviceCommandId_t * id) override;
void fillCommandAndReplyMap() override;
ReturnValue_t buildCommandFromCommand(DeviceCommandId_t deviceCommand,
const uint8_t * commandData,size_t commandDataLen) override;
ReturnValue_t scanForReply(const uint8_t *start, size_t remainingSize,
DeviceCommandId_t *foundId, size_t *foundLen) override;
ReturnValue_t interpretDeviceReply(DeviceCommandId_t id,
const uint8_t *packet) override;
void setNormalDatapoolEntriesInvalid() override;
uint32_t getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) override;
ReturnValue_t initializeLocalDataPool(localpool::DataPool& localDataPoolMap,
LocalDataPoolManager& poolManager) override;
ReturnValue_t enableReplyInReplyMap(DeviceCommandMap::iterator command,
uint8_t expectedReplies = 1, bool useAlternateId = false,
DeviceCommandId_t alternateReplyID = 0) override;
size_t getNextReplyLength(DeviceCommandId_t deviceCommand) override;
private:
static const uint8_t INTERFACE_ID = CLASS_ID::PLOC_MPSOC_HANDLER;
private:
static const ReturnValue_t CRC_FAILURE =
MAKE_RETURN_CODE(0xA0); //!> Space Packet received from PLOC has invalid CRC
static const ReturnValue_t RECEIVED_ACK_FAILURE =
MAKE_RETURN_CODE(0xA1); //!> Received ACK failure reply from PLOC
static const ReturnValue_t RECEIVED_EXE_FAILURE =
MAKE_RETURN_CODE(0xA2); //!> Received execution failure reply from PLOC
static const ReturnValue_t INVALID_APID =
MAKE_RETURN_CODE(0xA3); //!> Received space packet with invalid APID from PLOC
static const uint8_t INTERFACE_ID = CLASS_ID::PLOC_MPSOC_HANDLER;
static const uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::PLOC_MPSOC_HANDLER;
static const ReturnValue_t CRC_FAILURE = MAKE_RETURN_CODE(0xA0); //!> Space Packet received from PLOC has invalid CRC
static const ReturnValue_t RECEIVED_ACK_FAILURE = MAKE_RETURN_CODE(0xA1); //!> Received ACK failure reply from PLOC
static const ReturnValue_t RECEIVED_EXE_FAILURE = MAKE_RETURN_CODE(0xA2); //!> Received execution failure reply from PLOC
static const ReturnValue_t INVALID_APID = MAKE_RETURN_CODE(0xA3); //!> Received space packet with invalid APID from PLOC
static const Event MEMORY_READ_RPT_CRC_FAILURE =
MAKE_EVENT(1, severity::LOW); //!> PLOC crc failure in telemetry packet
static const Event ACK_FAILURE =
MAKE_EVENT(2, severity::LOW); //!> PLOC receive acknowledgment failure report
static const Event EXE_FAILURE =
MAKE_EVENT(3, severity::LOW); //!> PLOC receive execution failure report
static const Event CRC_FAILURE_EVENT =
MAKE_EVENT(4, severity::LOW); //!> PLOC reply has invalid crc
static const uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::PLOC_MPSOC_HANDLER;
static const uint16_t APID_MASK = 0x7FF;
static const uint16_t PACKET_SEQUENCE_COUNT_MASK = 0x3FFF;
static const Event MEMORY_READ_RPT_CRC_FAILURE = MAKE_EVENT(1, severity::LOW); //!> PLOC crc failure in telemetry packet
static const Event ACK_FAILURE = MAKE_EVENT(2, severity::LOW); //!> PLOC receive acknowledgment failure report
static const Event EXE_FAILURE = MAKE_EVENT(3, severity::LOW); //!> PLOC receive execution failure report
static const Event CRC_FAILURE_EVENT = MAKE_EVENT(4, severity::LOW); //!> PLOC reply has invalid crc
uint8_t commandBuffer[PLOC_MPSOC::MAX_COMMAND_SIZE];
static const uint16_t APID_MASK = 0x7FF;
static const uint16_t PACKET_SEQUENCE_COUNT_MASK = 0x3FFF;
/**
* @brief This object is incremented each time a packet is sent or received. By checking the
* packet sequence count of a received packet, no packets can be lost without noticing
* it. Only the least significant 14 bits represent the packet sequence count in a
* space packet. Thus the maximum value amounts to 16383 (0x3FFF).
* @note Normally this should never happen because the PLOC replies are always sent in a
* fixed order. However, the PLOC software checks this value and will return an ACK
* failure report in case the sequence count is not incremented with each transferred
* space packet.
*/
uint16_t packetSequenceCount = 0x3FFF;
uint8_t commandBuffer[PLOC_MPSOC::MAX_COMMAND_SIZE];
/**
* This variable is used to store the id of the next reply to receive. This is necessary
* because the PLOC sends as reply to each command at least one acknowledgment and execution
* report.
*/
DeviceCommandId_t nextReplyId = PLOC_MPSOC::NONE;
/**
* @brief This object is incremented each time a packet is sent or received. By checking the
* packet sequence count of a received packet, no packets can be lost without noticing
* it. Only the least significant 14 bits represent the packet sequence count in a
* space packet. Thus the maximum value amounts to 16383 (0x3FFF).
* @note Normally this should never happen because the PLOC replies are always sent in a
* fixed order. However, the PLOC software checks this value and will return an ACK
* failure report in case the sequence count is not incremented with each transferred
* space packet.
*/
uint16_t packetSequenceCount = 0x3FFF;
/**
* @brief This function fills the commandBuffer to initiate the write memory command.
*
* @param commandData Pointer to action command data.
* @param commanDataLen Size of command data in bytes.
*
* @return RETURN_OK if successful, else RETURN_FAILURE.
*/
ReturnValue_t prepareTcMemWriteCommand(const uint8_t* commandData, size_t commandDataLen);
/**
* This variable is used to store the id of the next reply to receive. This is necessary
* because the PLOC sends as reply to each command at least one acknowledgment and execution
* report.
*/
DeviceCommandId_t nextReplyId = PLOC_MPSOC::NONE;
/**
* @brief This function fills the commandBuffer to initiate the write reads command.
*
* @param commandData Pointer to action command data.
* @param commanDataLen Size of command data in bytes.
*
* @return RETURN_OK if successful, else RETURN_FAILURE.
*/
ReturnValue_t prepareTcMemReadCommand(const uint8_t* commandData, size_t commandDataLen);
/**
* @brief This function fills the commandBuffer to initiate the write memory command.
*
* @param commandData Pointer to action command data.
* @param commanDataLen Size of command data in bytes.
*
* @return RETURN_OK if successful, else RETURN_FAILURE.
*/
ReturnValue_t prepareTcMemWriteCommand(const uint8_t * commandData, size_t commandDataLen);
/**
* @brief This function checks the crc of the received PLOC reply.
*
* @param start Pointer to the first byte of the reply.
* @param foundLen Pointer to the length of the whole packet.
*
* @return RETURN_OK if CRC is ok, otherwise CRC_FAILURE.
*/
ReturnValue_t verifyPacket(const uint8_t* start, size_t foundLen);
/**
* @brief This function fills the commandBuffer to initiate the write reads command.
*
* @param commandData Pointer to action command data.
* @param commanDataLen Size of command data in bytes.
*
* @return RETURN_OK if successful, else RETURN_FAILURE.
*/
ReturnValue_t prepareTcMemReadCommand(const uint8_t * commandData, size_t commandDataLen);
/**
* @brief This function handles the acknowledgment report.
*
* @param data Pointer to the data holding the acknowledgment report.
*
* @return RETURN_OK if successful, otherwise an error code.
*/
ReturnValue_t handleAckReport(const uint8_t* data);
/**
* @brief This function checks the crc of the received PLOC reply.
*
* @param start Pointer to the first byte of the reply.
* @param foundLen Pointer to the length of the whole packet.
*
* @return RETURN_OK if CRC is ok, otherwise CRC_FAILURE.
*/
ReturnValue_t verifyPacket(const uint8_t* start, size_t foundLen);
/**
* @brief This function handles the data of a execution report.
*
* @param data Pointer to the received data packet.
*
* @return RETURN_OK if successful, otherwise an error code.
*/
ReturnValue_t handleExecutionReport(const uint8_t* data);
/**
* @brief This function handles the acknowledgment report.
*
* @param data Pointer to the data holding the acknowledgment report.
*
* @return RETURN_OK if successful, otherwise an error code.
*/
ReturnValue_t handleAckReport(const uint8_t* data);
/**
* @brief This function handles the memory read report.
*
* @param data Pointer to the data buffer holding the memory read report.
*
* @return RETURN_OK if successful, otherwise an error code.
*/
ReturnValue_t handleMemoryReadReport(const uint8_t* data);
/**
* @brief This function handles the data of a execution report.
*
* @param data Pointer to the received data packet.
*
* @return RETURN_OK if successful, otherwise an error code.
*/
ReturnValue_t handleExecutionReport(const uint8_t* data);
/**
* @brief Depending on the current active command, this function sets the reply id of the
* next reply after a successful acknowledgment report has been received. This is
* required by the function getNextReplyLength() to identify the length of the next
* reply to read.
*/
void setNextReplyId();
/**
* @brief This function handles the memory read report.
*
* @param data Pointer to the data buffer holding the memory read report.
*
* @return RETURN_OK if successful, otherwise an error code.
*/
ReturnValue_t handleMemoryReadReport(const uint8_t* data);
/**
* @brief This function handles action message replies in case the telemetry has been
* requested by another object.
*
* @param data Pointer to the telemetry data.
* @param dataSize Size of telemetry in bytes.
* @param replyId Id of the reply. This will be added to the ActionMessage.
*/
void handleDeviceTM(const uint8_t* data, size_t dataSize, DeviceCommandId_t replyId);
/**
* @brief Depending on the current active command, this function sets the reply id of the
* next reply after a successful acknowledgment report has been received. This is
* required by the function getNextReplyLength() to identify the length of the next
* reply to read.
*/
void setNextReplyId();
/**
* @brief In case an acknowledgment failure reply has been received this function disables
* all previously enabled commands and resets the exepected replies variable of an
* active command.
*/
void disableAllReplies();
/**
* @brief This function handles action message replies in case the telemetry has been
* requested by another object.
*
* @param data Pointer to the telemetry data.
* @param dataSize Size of telemetry in bytes.
* @param replyId Id of the reply. This will be added to the ActionMessage.
*/
void handleDeviceTM(const uint8_t* data, size_t dataSize, DeviceCommandId_t replyId);
/**
* @brief This function sends a failure report if the active action was commanded by an other
* object.
*
* @param replyId The id of the reply which signals a failure.
* @param status A status byte which gives information about the failure type.
*/
void sendFailureReport(DeviceCommandId_t replyId, ReturnValue_t status);
/**
* @brief In case an acknowledgment failure reply has been received this function disables
* all previously enabled commands and resets the exepected replies variable of an
* active command.
*/
void disableAllReplies();
/**
* @brief This function disables the execution report reply. Within this function also the
* the variable expectedReplies of an active command will be set to 0.
*/
void disableExeReportReply();
/**
* @brief This function sends a failure report if the active action was commanded by an other
* object.
*
* @param replyId The id of the reply which signals a failure.
* @param status A status byte which gives information about the failure type.
*/
void sendFailureReport(DeviceCommandId_t replyId, ReturnValue_t status);
/**
* @brief This function disables the execution report reply. Within this function also the
* the variable expectedReplies of an active command will be set to 0.
*/
void disableExeReportReply();
/**
* @brief This function checks and increments the packet sequence count of a received space
* packet.
*
* @param data Pointer to a space packet.
*
* @return RETURN_OK if successful
*
* @details There should be never a case in which a wrong packet sequence count is received
* because the communication scheme between PLOC and OBC always follows a strict
* procedure. Thus this function mainly serves for debugging purposes to detected an
* invalid handling of the packet sequence count.
*/
ReturnValue_t checkPacketSequenceCount(const uint8_t* data);
/**
* @brief This function checks and increments the packet sequence count of a received space
* packet.
*
* @param data Pointer to a space packet.
*
* @return RETURN_OK if successful
*
* @details There should be never a case in which a wrong packet sequence count is received
* because the communication scheme between PLOC and OBC always follows a strict
* procedure. Thus this function mainly serves for debugging purposes to detected an
* invalid handling of the packet sequence count.
*/
ReturnValue_t checkPacketSequenceCount(const uint8_t* data);
};
#endif /* MISSION_DEVICES_PLOCMPSOCHANDLER_H_ */

View File

@ -1,196 +1,177 @@
#include <OBSWConfig.h>
#include <fsfw/datapool/PoolReadGuard.h>
#include <mission/devices/RadiationSensorHandler.h>
#include <OBSWConfig.h>
RadiationSensorHandler::RadiationSensorHandler(object_id_t objectId, object_id_t comIF,
CookieIF * comCookie) :
DeviceHandlerBase(objectId, comIF, comCookie), dataset(
this) {
if (comCookie == NULL) {
sif::error << "RadiationSensorHandler: Invalid com cookie" << std::endl;
}
CookieIF *comCookie)
: DeviceHandlerBase(objectId, comIF, comCookie), dataset(this) {
if (comCookie == NULL) {
sif::error << "RadiationSensorHandler: Invalid com cookie" << std::endl;
}
}
RadiationSensorHandler::~RadiationSensorHandler() {
}
RadiationSensorHandler::~RadiationSensorHandler() {}
void RadiationSensorHandler::doStartUp(){
if (internalState == InternalState::CONFIGURED) {
void RadiationSensorHandler::doStartUp() {
if (internalState == InternalState::CONFIGURED) {
#if OBSW_SWITCH_TO_NORMAL_MODE_AFTER_STARTUP == 1
setMode(MODE_NORMAL);
setMode(MODE_NORMAL);
#else
setMode(_MODE_TO_ON);
setMode(_MODE_TO_ON);
#endif
}
}
}
void RadiationSensorHandler::doShutDown(){
setMode(_MODE_POWER_DOWN);
}
void RadiationSensorHandler::doShutDown() { setMode(_MODE_POWER_DOWN); }
ReturnValue_t RadiationSensorHandler::buildNormalDeviceCommand(
DeviceCommandId_t * id) {
switch (communicationStep) {
ReturnValue_t RadiationSensorHandler::buildNormalDeviceCommand(DeviceCommandId_t *id) {
switch (communicationStep) {
case CommunicationStep::START_CONVERSION: {
*id = RAD_SENSOR::START_CONVERSION;
communicationStep = CommunicationStep::READ_CONVERSIONS;
break;
*id = RAD_SENSOR::START_CONVERSION;
communicationStep = CommunicationStep::READ_CONVERSIONS;
break;
}
case CommunicationStep::READ_CONVERSIONS: {
*id = RAD_SENSOR::READ_CONVERSIONS;
communicationStep = CommunicationStep::START_CONVERSION;
break;
*id = RAD_SENSOR::READ_CONVERSIONS;
communicationStep = CommunicationStep::START_CONVERSION;
break;
}
default: {
sif::debug << "RadiationSensorHandler::buildNormalDeviceCommand: Unknown communication "
<< "step" << std::endl;
return HasReturnvaluesIF::RETURN_OK;
sif::debug << "RadiationSensorHandler::buildNormalDeviceCommand: Unknown communication "
<< "step" << std::endl;
return HasReturnvaluesIF::RETURN_OK;
}
}
return buildCommandFromCommand(*id, nullptr, 0);
}
return buildCommandFromCommand(*id, nullptr, 0);
}
ReturnValue_t RadiationSensorHandler::buildTransitionDeviceCommand(
DeviceCommandId_t * id){
if (internalState == InternalState::SETUP) {
*id = RAD_SENSOR::WRITE_SETUP;
}
else {
return NOTHING_TO_SEND;
}
return buildCommandFromCommand(*id, nullptr, 0);
ReturnValue_t RadiationSensorHandler::buildTransitionDeviceCommand(DeviceCommandId_t *id) {
if (internalState == InternalState::SETUP) {
*id = RAD_SENSOR::WRITE_SETUP;
} else {
return NOTHING_TO_SEND;
}
return buildCommandFromCommand(*id, nullptr, 0);
}
ReturnValue_t RadiationSensorHandler::buildCommandFromCommand(
DeviceCommandId_t deviceCommand, const uint8_t * commandData,
size_t commandDataLen) {
switch(deviceCommand) {
case(RAD_SENSOR::WRITE_SETUP): {
cmdBuffer[0] = RAD_SENSOR::SETUP_DEFINITION;
rawPacket = cmdBuffer;
rawPacketLen = 1;
internalState = InternalState::CONFIGURED;
return RETURN_OK;
ReturnValue_t RadiationSensorHandler::buildCommandFromCommand(DeviceCommandId_t deviceCommand,
const uint8_t *commandData,
size_t commandDataLen) {
switch (deviceCommand) {
case (RAD_SENSOR::WRITE_SETUP): {
cmdBuffer[0] = RAD_SENSOR::SETUP_DEFINITION;
rawPacket = cmdBuffer;
rawPacketLen = 1;
internalState = InternalState::CONFIGURED;
return RETURN_OK;
}
case(RAD_SENSOR::START_CONVERSION): {
/* First the fifo will be reset here */
cmdBuffer[0] = RAD_SENSOR::RESET_DEFINITION;
cmdBuffer[1] = RAD_SENSOR::CONVERSION_DEFINITION;
rawPacket = cmdBuffer;
rawPacketLen = 2;
return RETURN_OK;
case (RAD_SENSOR::START_CONVERSION): {
/* First the fifo will be reset here */
cmdBuffer[0] = RAD_SENSOR::RESET_DEFINITION;
cmdBuffer[1] = RAD_SENSOR::CONVERSION_DEFINITION;
rawPacket = cmdBuffer;
rawPacketLen = 2;
return RETURN_OK;
}
case(RAD_SENSOR::READ_CONVERSIONS): {
cmdBuffer[0] = RAD_SENSOR::DUMMY_BYTE;
std::memset(cmdBuffer, RAD_SENSOR::DUMMY_BYTE, RAD_SENSOR::READ_SIZE);
rawPacket = cmdBuffer;
rawPacketLen = RAD_SENSOR::READ_SIZE;
return RETURN_OK;
case (RAD_SENSOR::READ_CONVERSIONS): {
cmdBuffer[0] = RAD_SENSOR::DUMMY_BYTE;
std::memset(cmdBuffer, RAD_SENSOR::DUMMY_BYTE, RAD_SENSOR::READ_SIZE);
rawPacket = cmdBuffer;
rawPacketLen = RAD_SENSOR::READ_SIZE;
return RETURN_OK;
}
// case(RAD_SENSOR::AIN0_AND_TMP_CONVERSION): {
// /* First the fifo will be reset here */
// cmdBuffer[0] = RAD_SENSOR::RESET_DEFINITION;
// cmdBuffer[1] = RAD_SENSOR::CONVERSION_DEFINITION;
// rawPacket = cmdBuffer;
// rawPacketLen = 2;
// return RETURN_OK;
// }
// case(RAD_SENSOR::AIN0_AND_TMP_CONVERSION): {
// /* First the fifo will be reset here */
// cmdBuffer[0] = RAD_SENSOR::RESET_DEFINITION;
// cmdBuffer[1] = RAD_SENSOR::CONVERSION_DEFINITION;
// rawPacket = cmdBuffer;
// rawPacketLen = 2;
// return RETURN_OK;
// }
default:
return DeviceHandlerIF::COMMAND_NOT_IMPLEMENTED;
}
return HasReturnvaluesIF::RETURN_FAILED;
return DeviceHandlerIF::COMMAND_NOT_IMPLEMENTED;
}
return HasReturnvaluesIF::RETURN_FAILED;
}
void RadiationSensorHandler::fillCommandAndReplyMap() {
this->insertInCommandMap(RAD_SENSOR::WRITE_SETUP);
this->insertInCommandMap(RAD_SENSOR::START_CONVERSION);
this->insertInCommandAndReplyMap(RAD_SENSOR::READ_CONVERSIONS, 1, &dataset,
RAD_SENSOR::READ_SIZE);
this->insertInCommandMap(RAD_SENSOR::WRITE_SETUP);
this->insertInCommandMap(RAD_SENSOR::START_CONVERSION);
this->insertInCommandAndReplyMap(RAD_SENSOR::READ_CONVERSIONS, 1, &dataset,
RAD_SENSOR::READ_SIZE);
}
ReturnValue_t RadiationSensorHandler::scanForReply(const uint8_t *start,
size_t remainingSize, DeviceCommandId_t *foundId, size_t *foundLen) {
*foundId = this->getPendingCommand();
ReturnValue_t RadiationSensorHandler::scanForReply(const uint8_t *start, size_t remainingSize,
DeviceCommandId_t *foundId, size_t *foundLen) {
*foundId = this->getPendingCommand();
switch (*foundId) {
switch (*foundId) {
case RAD_SENSOR::START_CONVERSION:
case RAD_SENSOR::WRITE_SETUP:
return IGNORE_REPLY_DATA;
return IGNORE_REPLY_DATA;
default:
break;
}
break;
}
*foundLen = remainingSize;
*foundLen = remainingSize;
return HasReturnvaluesIF::RETURN_OK;
return HasReturnvaluesIF::RETURN_OK;
}
ReturnValue_t RadiationSensorHandler::interpretDeviceReply(DeviceCommandId_t id,
const uint8_t *packet) {
switch (id) {
const uint8_t *packet) {
switch (id) {
case RAD_SENSOR::READ_CONVERSIONS: {
uint8_t offset = 0;
PoolReadGuard readSet(&dataset);
dataset.temperatureCelcius = (*(packet + offset) << 8 | *(packet + offset + 1)) * 0.125;
offset += 2;
dataset.ain0 = (*(packet + offset) << 8 | *(packet + offset +1));
offset += 2;
dataset.ain1 = (*(packet + offset) << 8 | *(packet + offset + 1));
offset += 6;
dataset.ain4 = (*(packet + offset) << 8 | *(packet + offset + 1));
offset += 2;
dataset.ain5 = (*(packet + offset) << 8 | *(packet + offset + 1));
offset += 2;
dataset.ain6 = (*(packet + offset) << 8 | *(packet + offset + 1));
offset += 2;
dataset.ain7 = (*(packet + offset) << 8 | *(packet + offset + 1));
uint8_t offset = 0;
PoolReadGuard readSet(&dataset);
dataset.temperatureCelcius = (*(packet + offset) << 8 | *(packet + offset + 1)) * 0.125;
offset += 2;
dataset.ain0 = (*(packet + offset) << 8 | *(packet + offset + 1));
offset += 2;
dataset.ain1 = (*(packet + offset) << 8 | *(packet + offset + 1));
offset += 6;
dataset.ain4 = (*(packet + offset) << 8 | *(packet + offset + 1));
offset += 2;
dataset.ain5 = (*(packet + offset) << 8 | *(packet + offset + 1));
offset += 2;
dataset.ain6 = (*(packet + offset) << 8 | *(packet + offset + 1));
offset += 2;
dataset.ain7 = (*(packet + offset) << 8 | *(packet + offset + 1));
#if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_RAD_SENSOR
sif::info << "Radiation sensor temperature: " << dataset.temperatureCelcius << " °C"
<< std::endl;
sif::info << "Radiation sensor ADC value channel 0: " << dataset.ain0
<< std::endl;
sif::info << "Radiation sensor ADC value channel 1: " << dataset.ain1
<< std::endl;
sif::info << "Radiation sensor ADC value channel 4: " << dataset.ain4
<< std::endl;
sif::info << "Radiation sensor ADC value channel 5: " << dataset.ain5
<< std::endl;
sif::info << "Radiation sensor ADC value channel 6: " << dataset.ain6
<< std::endl;
sif::info << "Radiation sensor ADC value channel 7: " << dataset.ain7
sif::info << "Radiation sensor temperature: " << dataset.temperatureCelcius << " °C"
<< std::endl;
sif::info << "Radiation sensor ADC value channel 0: " << dataset.ain0 << std::endl;
sif::info << "Radiation sensor ADC value channel 1: " << dataset.ain1 << std::endl;
sif::info << "Radiation sensor ADC value channel 4: " << dataset.ain4 << std::endl;
sif::info << "Radiation sensor ADC value channel 5: " << dataset.ain5 << std::endl;
sif::info << "Radiation sensor ADC value channel 6: " << dataset.ain6 << std::endl;
sif::info << "Radiation sensor ADC value channel 7: " << dataset.ain7 << std::endl;
#endif
break;
break;
}
default: {
sif::debug << "RadiationSensorHandler::interpretDeviceReply: Unknown reply id" << std::endl;
return DeviceHandlerIF::UNKNOWN_DEVICE_REPLY;
sif::debug << "RadiationSensorHandler::interpretDeviceReply: Unknown reply id" << std::endl;
return DeviceHandlerIF::UNKNOWN_DEVICE_REPLY;
}
}
return HasReturnvaluesIF::RETURN_OK;
}
return HasReturnvaluesIF::RETURN_OK;
}
void RadiationSensorHandler::setNormalDatapoolEntriesInvalid(){
void RadiationSensorHandler::setNormalDatapoolEntriesInvalid() {}
uint32_t RadiationSensorHandler::getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) {
return 5000;
}
uint32_t RadiationSensorHandler::getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo){
return 5000;
ReturnValue_t RadiationSensorHandler::initializeLocalDataPool(localpool::DataPool &localDataPoolMap,
LocalDataPoolManager &poolManager) {
localDataPoolMap.emplace(RAD_SENSOR::TEMPERATURE_C, new PoolEntry<float>({0.0}));
localDataPoolMap.emplace(RAD_SENSOR::AIN0, new PoolEntry<uint16_t>({0}));
localDataPoolMap.emplace(RAD_SENSOR::AIN1, new PoolEntry<uint16_t>({0}));
localDataPoolMap.emplace(RAD_SENSOR::AIN4, new PoolEntry<uint16_t>({0}));
localDataPoolMap.emplace(RAD_SENSOR::AIN5, new PoolEntry<uint16_t>({0}));
localDataPoolMap.emplace(RAD_SENSOR::AIN6, new PoolEntry<uint16_t>({0}));
localDataPoolMap.emplace(RAD_SENSOR::AIN7, new PoolEntry<uint16_t>({0}));
return HasReturnvaluesIF::RETURN_OK;
}
ReturnValue_t RadiationSensorHandler::initializeLocalDataPool(localpool::DataPool& localDataPoolMap,
LocalDataPoolManager& poolManager) {
localDataPoolMap.emplace(RAD_SENSOR::TEMPERATURE_C, new PoolEntry<float>( { 0.0 }));
localDataPoolMap.emplace(RAD_SENSOR::AIN0, new PoolEntry<uint16_t>( { 0 }));
localDataPoolMap.emplace(RAD_SENSOR::AIN1, new PoolEntry<uint16_t>( { 0 }));
localDataPoolMap.emplace(RAD_SENSOR::AIN4, new PoolEntry<uint16_t>( { 0 }));
localDataPoolMap.emplace(RAD_SENSOR::AIN5, new PoolEntry<uint16_t>( { 0 }));
localDataPoolMap.emplace(RAD_SENSOR::AIN6, new PoolEntry<uint16_t>( { 0 }));
localDataPoolMap.emplace(RAD_SENSOR::AIN7, new PoolEntry<uint16_t>( { 0 }));
return HasReturnvaluesIF::RETURN_OK;
}

View File

@ -5,56 +5,46 @@
#include <mission/devices/devicedefinitions/RadSensorDefinitions.h>
/**
* @brief This is the device handler class for radiation sensor on the OBC IF Board. The sensor
* is based on the MAX1227 ADC converter.
* @brief This is the device handler class for radiation sensor on the OBC IF Board. The
* sensor is based on the MAX1227 ADC converter.
*
* @details Datasheet of MAX1227: https://datasheets.maximintegrated.com/en/ds/MAX1227-MAX1231.pdf
*
* @author J. Meier
*/
class RadiationSensorHandler: public DeviceHandlerBase {
public:
class RadiationSensorHandler : public DeviceHandlerBase {
public:
RadiationSensorHandler(object_id_t objectId, object_id_t comIF, CookieIF *comCookie);
virtual ~RadiationSensorHandler();
RadiationSensorHandler(object_id_t objectId, object_id_t comIF,
CookieIF * comCookie);
virtual ~RadiationSensorHandler();
protected:
void doStartUp() override;
void doShutDown() override;
ReturnValue_t buildNormalDeviceCommand(DeviceCommandId_t *id) override;
ReturnValue_t buildTransitionDeviceCommand(DeviceCommandId_t *id) override;
void fillCommandAndReplyMap() override;
ReturnValue_t buildCommandFromCommand(DeviceCommandId_t deviceCommand, const uint8_t *commandData,
size_t commandDataLen) override;
ReturnValue_t scanForReply(const uint8_t *start, size_t remainingSize, DeviceCommandId_t *foundId,
size_t *foundLen) override;
ReturnValue_t interpretDeviceReply(DeviceCommandId_t id, const uint8_t *packet) override;
void setNormalDatapoolEntriesInvalid() override;
uint32_t getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) override;
ReturnValue_t initializeLocalDataPool(localpool::DataPool &localDataPoolMap,
LocalDataPoolManager &poolManager) override;
protected:
void doStartUp() override;
void doShutDown() override;
ReturnValue_t buildNormalDeviceCommand(DeviceCommandId_t * id) override;
ReturnValue_t buildTransitionDeviceCommand(DeviceCommandId_t * id) override;
void fillCommandAndReplyMap() override;
ReturnValue_t buildCommandFromCommand(DeviceCommandId_t deviceCommand,
const uint8_t * commandData,size_t commandDataLen) override;
ReturnValue_t scanForReply(const uint8_t *start, size_t remainingSize,
DeviceCommandId_t *foundId, size_t *foundLen) override;
ReturnValue_t interpretDeviceReply(DeviceCommandId_t id,
const uint8_t *packet) override;
void setNormalDatapoolEntriesInvalid() override;
uint32_t getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) override;
ReturnValue_t initializeLocalDataPool(localpool::DataPool& localDataPoolMap,
LocalDataPoolManager& poolManager) override;
private:
enum class CommunicationStep { START_CONVERSION, READ_CONVERSIONS };
private:
enum class InternalState { SETUP, CONFIGURED };
enum class CommunicationStep {
START_CONVERSION,
READ_CONVERSIONS
};
RAD_SENSOR::RadSensorDataset dataset;
enum class InternalState {
SETUP,
CONFIGURED
};
static const uint8_t MAX_CMD_LEN = RAD_SENSOR::READ_SIZE;
RAD_SENSOR::RadSensorDataset dataset;
static const uint8_t MAX_CMD_LEN = RAD_SENSOR::READ_SIZE;
uint8_t cmdBuffer[MAX_CMD_LEN];
InternalState internalState = InternalState::SETUP;
CommunicationStep communicationStep = CommunicationStep::START_CONVERSION;
uint8_t cmdBuffer[MAX_CMD_LEN];
InternalState internalState = InternalState::SETUP;
CommunicationStep communicationStep = CommunicationStep::START_CONVERSION;
};
#endif /* MISSION_DEVICES_RADIATIONSENSORHANDLER_H_ */

View File

@ -1,526 +1,523 @@
#include "RwHandler.h"
#include <fsfw/datapool/PoolReadGuard.h>
#include <fsfw/globalfunctions/CRC.h>
#include "OBSWConfig.h"
#include <fsfw/globalfunctions/CRC.h>
#include <fsfw/datapool/PoolReadGuard.h>
RwHandler::RwHandler(object_id_t objectId, object_id_t comIF, CookieIF * comCookie,
LinuxLibgpioIF* gpioComIF, gpioId_t enableGpio) :
DeviceHandlerBase(objectId, comIF, comCookie), gpioComIF(gpioComIF), enableGpio(enableGpio),
temperatureSet(this), statusSet(this), lastResetStatusSet(this), tmDataset(this) {
if (comCookie == NULL) {
sif::error << "RwHandler: Invalid com cookie" << std::endl;
}
if (gpioComIF == NULL) {
sif::error << "RwHandler: Invalid gpio communication interface" << std::endl;
}
RwHandler::RwHandler(object_id_t objectId, object_id_t comIF, CookieIF* comCookie,
LinuxLibgpioIF* gpioComIF, gpioId_t enableGpio)
: DeviceHandlerBase(objectId, comIF, comCookie),
gpioComIF(gpioComIF),
enableGpio(enableGpio),
temperatureSet(this),
statusSet(this),
lastResetStatusSet(this),
tmDataset(this) {
if (comCookie == NULL) {
sif::error << "RwHandler: Invalid com cookie" << std::endl;
}
if (gpioComIF == NULL) {
sif::error << "RwHandler: Invalid gpio communication interface" << std::endl;
}
}
RwHandler::~RwHandler() {
}
RwHandler::~RwHandler() {}
void RwHandler::doStartUp() {
internalState = InternalState::GET_RESET_STATUS;
internalState = InternalState::GET_RESET_STATUS;
if(gpioComIF->pullHigh(enableGpio) != RETURN_OK) {
sif::debug << "RwHandler::doStartUp: Failed to pull enable gpio to high";
}
if (gpioComIF->pullHigh(enableGpio) != RETURN_OK) {
sif::debug << "RwHandler::doStartUp: Failed to pull enable gpio to high";
}
#if OBSW_SWITCH_TO_NORMAL_MODE_AFTER_STARTUP == 1
setMode(MODE_NORMAL);
setMode(MODE_NORMAL);
#else
setMode(_MODE_TO_ON);
setMode(_MODE_TO_ON);
#endif
}
void RwHandler::doShutDown() {
if(gpioComIF->pullLow(enableGpio) != RETURN_OK) {
sif::debug << "RwHandler::doStartUp: Failed to pull enable gpio to low";
}
setMode(_MODE_POWER_DOWN);
if (gpioComIF->pullLow(enableGpio) != RETURN_OK) {
sif::debug << "RwHandler::doStartUp: Failed to pull enable gpio to low";
}
setMode(_MODE_POWER_DOWN);
}
ReturnValue_t RwHandler::buildNormalDeviceCommand(DeviceCommandId_t * id) {
switch (internalState) {
ReturnValue_t RwHandler::buildNormalDeviceCommand(DeviceCommandId_t* id) {
switch (internalState) {
case InternalState::GET_RESET_STATUS:
*id = RwDefinitions::GET_LAST_RESET_STATUS;
internalState = InternalState::READ_TEMPERATURE;
break;
*id = RwDefinitions::GET_LAST_RESET_STATUS;
internalState = InternalState::READ_TEMPERATURE;
break;
case InternalState::CLEAR_RESET_STATUS:
*id = RwDefinitions::CLEAR_LAST_RESET_STATUS;
/** After reset status is cleared, reset status will be polled again for verification */
internalState = InternalState::GET_RESET_STATUS;
break;
*id = RwDefinitions::CLEAR_LAST_RESET_STATUS;
/** After reset status is cleared, reset status will be polled again for verification */
internalState = InternalState::GET_RESET_STATUS;
break;
case InternalState::READ_TEMPERATURE:
*id = RwDefinitions::GET_TEMPERATURE;
internalState = InternalState::GET_RW_SATUS;
break;
*id = RwDefinitions::GET_TEMPERATURE;
internalState = InternalState::GET_RW_SATUS;
break;
case InternalState::GET_RW_SATUS:
*id = RwDefinitions::GET_RW_STATUS;
internalState = InternalState::GET_RESET_STATUS;
break;
*id = RwDefinitions::GET_RW_STATUS;
internalState = InternalState::GET_RESET_STATUS;
break;
default:
sif::debug << "RwHandler::buildNormalDeviceCommand: Invalid internal step"
<< std::endl;
break;
}
return buildCommandFromCommand(*id, NULL, 0);
sif::debug << "RwHandler::buildNormalDeviceCommand: Invalid internal step" << std::endl;
break;
}
return buildCommandFromCommand(*id, NULL, 0);
}
ReturnValue_t RwHandler::buildTransitionDeviceCommand(DeviceCommandId_t * id) {
return NOTHING_TO_SEND;
ReturnValue_t RwHandler::buildTransitionDeviceCommand(DeviceCommandId_t* id) {
return NOTHING_TO_SEND;
}
ReturnValue_t RwHandler::buildCommandFromCommand(DeviceCommandId_t deviceCommand,
const uint8_t * commandData, size_t commandDataLen) {
ReturnValue_t result = RETURN_OK;
const uint8_t* commandData,
size_t commandDataLen) {
ReturnValue_t result = RETURN_OK;
switch (deviceCommand) {
switch (deviceCommand) {
case (RwDefinitions::RESET_MCU): {
prepareSimpleCommand(deviceCommand);
return RETURN_OK;
prepareSimpleCommand(deviceCommand);
return RETURN_OK;
}
case (RwDefinitions::GET_LAST_RESET_STATUS): {
prepareSimpleCommand(deviceCommand);
return RETURN_OK;
prepareSimpleCommand(deviceCommand);
return RETURN_OK;
}
case (RwDefinitions::CLEAR_LAST_RESET_STATUS): {
prepareSimpleCommand(deviceCommand);
return RETURN_OK;
prepareSimpleCommand(deviceCommand);
return RETURN_OK;
}
case (RwDefinitions::GET_RW_STATUS): {
prepareSimpleCommand(deviceCommand);
return RETURN_OK;
prepareSimpleCommand(deviceCommand);
return RETURN_OK;
}
case (RwDefinitions::INIT_RW_CONTROLLER): {
prepareSimpleCommand(deviceCommand);
return RETURN_OK;
prepareSimpleCommand(deviceCommand);
return RETURN_OK;
}
case (RwDefinitions::SET_SPEED): {
if (commandDataLen != 6) {
sif::error << "RwHandler::buildCommandFromCommand: Received set speed command with"
<< " invalid length" << std::endl;
return SET_SPEED_COMMAND_INVALID_LENGTH;
}
result = checkSpeedAndRampTime(commandData, commandDataLen);
if (result != RETURN_OK) {
return result;
}
prepareSetSpeedCmd(commandData, commandDataLen);
if (commandDataLen != 6) {
sif::error << "RwHandler::buildCommandFromCommand: Received set speed command with"
<< " invalid length" << std::endl;
return SET_SPEED_COMMAND_INVALID_LENGTH;
}
result = checkSpeedAndRampTime(commandData, commandDataLen);
if (result != RETURN_OK) {
return result;
}
prepareSetSpeedCmd(commandData, commandDataLen);
return result;
}
case (RwDefinitions::GET_TEMPERATURE): {
prepareSimpleCommand(deviceCommand);
return RETURN_OK;
prepareSimpleCommand(deviceCommand);
return RETURN_OK;
}
case (RwDefinitions::GET_TM): {
prepareSimpleCommand(deviceCommand);
return RETURN_OK;
prepareSimpleCommand(deviceCommand);
return RETURN_OK;
}
default:
return DeviceHandlerIF::COMMAND_NOT_IMPLEMENTED;
}
return HasReturnvaluesIF::RETURN_FAILED;
return DeviceHandlerIF::COMMAND_NOT_IMPLEMENTED;
}
return HasReturnvaluesIF::RETURN_FAILED;
}
void RwHandler::fillCommandAndReplyMap() {
this->insertInCommandMap(RwDefinitions::RESET_MCU);
this->insertInCommandAndReplyMap(RwDefinitions::GET_LAST_RESET_STATUS, 1, &lastResetStatusSet,
RwDefinitions::SIZE_GET_RESET_STATUS);
this->insertInCommandAndReplyMap(RwDefinitions::CLEAR_LAST_RESET_STATUS, 1, nullptr,
RwDefinitions::SIZE_CLEAR_RESET_STATUS);
this->insertInCommandAndReplyMap(RwDefinitions::GET_RW_STATUS, 1, &statusSet,
RwDefinitions::SIZE_GET_RW_STATUS);
this->insertInCommandAndReplyMap(RwDefinitions::INIT_RW_CONTROLLER, 1, nullptr,
RwDefinitions::SIZE_INIT_RW);
this->insertInCommandAndReplyMap(RwDefinitions::GET_TEMPERATURE, 1, &temperatureSet,
RwDefinitions::SIZE_GET_TEMPERATURE_REPLY);
this->insertInCommandAndReplyMap(RwDefinitions::SET_SPEED, 1, nullptr,
RwDefinitions::SIZE_SET_SPEED_REPLY);
this->insertInCommandAndReplyMap(RwDefinitions::GET_TM, 1, &tmDataset,
RwDefinitions::SIZE_GET_TELEMETRY_REPLY);
this->insertInCommandMap(RwDefinitions::RESET_MCU);
this->insertInCommandAndReplyMap(RwDefinitions::GET_LAST_RESET_STATUS, 1, &lastResetStatusSet,
RwDefinitions::SIZE_GET_RESET_STATUS);
this->insertInCommandAndReplyMap(RwDefinitions::CLEAR_LAST_RESET_STATUS, 1, nullptr,
RwDefinitions::SIZE_CLEAR_RESET_STATUS);
this->insertInCommandAndReplyMap(RwDefinitions::GET_RW_STATUS, 1, &statusSet,
RwDefinitions::SIZE_GET_RW_STATUS);
this->insertInCommandAndReplyMap(RwDefinitions::INIT_RW_CONTROLLER, 1, nullptr,
RwDefinitions::SIZE_INIT_RW);
this->insertInCommandAndReplyMap(RwDefinitions::GET_TEMPERATURE, 1, &temperatureSet,
RwDefinitions::SIZE_GET_TEMPERATURE_REPLY);
this->insertInCommandAndReplyMap(RwDefinitions::SET_SPEED, 1, nullptr,
RwDefinitions::SIZE_SET_SPEED_REPLY);
this->insertInCommandAndReplyMap(RwDefinitions::GET_TM, 1, &tmDataset,
RwDefinitions::SIZE_GET_TELEMETRY_REPLY);
}
ReturnValue_t RwHandler::scanForReply(const uint8_t *start, size_t remainingSize,
DeviceCommandId_t *foundId, size_t *foundLen) {
uint8_t replyByte = *start;
switch (replyByte) {
ReturnValue_t RwHandler::scanForReply(const uint8_t* start, size_t remainingSize,
DeviceCommandId_t* foundId, size_t* foundLen) {
uint8_t replyByte = *start;
switch (replyByte) {
case (RwDefinitions::GET_LAST_RESET_STATUS): {
*foundLen = RwDefinitions::SIZE_GET_RESET_STATUS;
*foundId = RwDefinitions::GET_LAST_RESET_STATUS;
break;
*foundLen = RwDefinitions::SIZE_GET_RESET_STATUS;
*foundId = RwDefinitions::GET_LAST_RESET_STATUS;
break;
}
case (RwDefinitions::CLEAR_LAST_RESET_STATUS): {
*foundLen = RwDefinitions::SIZE_CLEAR_RESET_STATUS;
*foundId = RwDefinitions::CLEAR_LAST_RESET_STATUS;
break;
*foundLen = RwDefinitions::SIZE_CLEAR_RESET_STATUS;
*foundId = RwDefinitions::CLEAR_LAST_RESET_STATUS;
break;
}
case (RwDefinitions::GET_RW_STATUS): {
*foundLen = RwDefinitions::SIZE_GET_RW_STATUS;
*foundId = RwDefinitions::GET_RW_STATUS;
break;
*foundLen = RwDefinitions::SIZE_GET_RW_STATUS;
*foundId = RwDefinitions::GET_RW_STATUS;
break;
}
case (RwDefinitions::INIT_RW_CONTROLLER): {
*foundLen = RwDefinitions::SIZE_INIT_RW;
*foundId = RwDefinitions::INIT_RW_CONTROLLER;
break;
*foundLen = RwDefinitions::SIZE_INIT_RW;
*foundId = RwDefinitions::INIT_RW_CONTROLLER;
break;
}
case (RwDefinitions::SET_SPEED): {
*foundLen = RwDefinitions::SIZE_SET_SPEED_REPLY;
*foundId = RwDefinitions::SET_SPEED;
break;
*foundLen = RwDefinitions::SIZE_SET_SPEED_REPLY;
*foundId = RwDefinitions::SET_SPEED;
break;
}
case (RwDefinitions::GET_TEMPERATURE): {
*foundLen = RwDefinitions::SIZE_GET_TEMPERATURE_REPLY;
*foundId = RwDefinitions::GET_TEMPERATURE;
break;
*foundLen = RwDefinitions::SIZE_GET_TEMPERATURE_REPLY;
*foundId = RwDefinitions::GET_TEMPERATURE;
break;
}
case (RwDefinitions::GET_TM): {
*foundLen = RwDefinitions::SIZE_GET_TELEMETRY_REPLY;
*foundId = RwDefinitions::GET_TM;
break;
*foundLen = RwDefinitions::SIZE_GET_TELEMETRY_REPLY;
*foundId = RwDefinitions::GET_TM;
break;
}
default: {
sif::warning << "RwHandler::scanForReply: Reply contains invalid command code" <<
std::endl;
*foundLen = remainingSize;
return RETURN_FAILED;
}
sif::warning << "RwHandler::scanForReply: Reply contains invalid command code" << std::endl;
*foundLen = remainingSize;
return RETURN_FAILED;
}
}
sizeOfReply = *foundLen;
sizeOfReply = *foundLen;
return RETURN_OK;
return RETURN_OK;
}
ReturnValue_t RwHandler::interpretDeviceReply(DeviceCommandId_t id, const uint8_t *packet) {
ReturnValue_t RwHandler::interpretDeviceReply(DeviceCommandId_t id, const uint8_t* packet) {
/** Check result code */
if (*(packet + 1) == RwDefinitions::STATE_ERROR) {
sif::error << "RwHandler::interpretDeviceReply: Command execution failed. Command id: " << id
<< std::endl;
return EXECUTION_FAILED;
}
/** Check result code */
if (*(packet + 1) == RwDefinitions::STATE_ERROR) {
sif::error << "RwHandler::interpretDeviceReply: Command execution failed. Command id: "
<< id << std::endl;
return EXECUTION_FAILED;
}
/** Received in little endian byte order */
uint16_t replyCrc = *(packet + sizeOfReply - 1) << 8 | *(packet + sizeOfReply - 2);
/** Received in little endian byte order */
uint16_t replyCrc = *(packet + sizeOfReply - 1) << 8 | *(packet + sizeOfReply - 2) ;
if (CRC::crc16ccitt(packet, sizeOfReply - 2, 0xFFFF) != replyCrc) {
sif::error << "RwHandler::interpretDeviceReply: cRC error" << std::endl;
return CRC_ERROR;
}
if (CRC::crc16ccitt(packet, sizeOfReply - 2, 0xFFFF) != replyCrc) {
sif::error << "RwHandler::interpretDeviceReply: cRC error" << std::endl;
return CRC_ERROR;
}
switch (id) {
switch (id) {
case (RwDefinitions::GET_LAST_RESET_STATUS): {
handleResetStatusReply(packet);
break;
handleResetStatusReply(packet);
break;
}
case (RwDefinitions::GET_RW_STATUS): {
handleGetRwStatusReply(packet);
break;
handleGetRwStatusReply(packet);
break;
}
case (RwDefinitions::CLEAR_LAST_RESET_STATUS):
case (RwDefinitions::INIT_RW_CONTROLLER):
case (RwDefinitions::SET_SPEED):
// no reply data expected
break;
// no reply data expected
break;
case (RwDefinitions::GET_TEMPERATURE): {
handleTemperatureReply(packet);
break;
handleTemperatureReply(packet);
break;
}
case (RwDefinitions::GET_TM): {
handleGetTelemetryReply(packet);
break;
handleGetTelemetryReply(packet);
break;
}
default: {
sif::debug << "RwHandler::interpretDeviceReply: Unknown device reply id" << std::endl;
return DeviceHandlerIF::UNKNOWN_DEVICE_REPLY;
}
sif::debug << "RwHandler::interpretDeviceReply: Unknown device reply id" << std::endl;
return DeviceHandlerIF::UNKNOWN_DEVICE_REPLY;
}
}
return RETURN_OK;
return RETURN_OK;
}
void RwHandler::setNormalDatapoolEntriesInvalid() {
void RwHandler::setNormalDatapoolEntriesInvalid() {}
}
uint32_t RwHandler::getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) {
return 5000;
}
uint32_t RwHandler::getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) { return 5000; }
ReturnValue_t RwHandler::initializeLocalDataPool(localpool::DataPool& localDataPoolMap,
LocalDataPoolManager& poolManager) {
LocalDataPoolManager& poolManager) {
localDataPoolMap.emplace(RwDefinitions::TEMPERATURE_C, new PoolEntry<int32_t>({0}));
localDataPoolMap.emplace(RwDefinitions::TEMPERATURE_C, new PoolEntry<int32_t>( { 0 }));
localDataPoolMap.emplace(RwDefinitions::CURR_SPEED, new PoolEntry<int32_t>({0}));
localDataPoolMap.emplace(RwDefinitions::REFERENCE_SPEED, new PoolEntry<int32_t>({0}));
localDataPoolMap.emplace(RwDefinitions::STATE, new PoolEntry<uint8_t>({0}));
localDataPoolMap.emplace(RwDefinitions::CLC_MODE, new PoolEntry<uint8_t>({0}));
localDataPoolMap.emplace(RwDefinitions::CURR_SPEED, new PoolEntry<int32_t>( { 0 }));
localDataPoolMap.emplace(RwDefinitions::REFERENCE_SPEED, new PoolEntry<int32_t>( { 0 }));
localDataPoolMap.emplace(RwDefinitions::STATE, new PoolEntry<uint8_t>( { 0 }));
localDataPoolMap.emplace(RwDefinitions::CLC_MODE, new PoolEntry<uint8_t>( { 0 }));
localDataPoolMap.emplace(RwDefinitions::LAST_RESET_STATUS, new PoolEntry<uint8_t>({0}));
localDataPoolMap.emplace(RwDefinitions::CURRRENT_RESET_STATUS, new PoolEntry<uint8_t>({0}));
localDataPoolMap.emplace(RwDefinitions::LAST_RESET_STATUS, new PoolEntry<uint8_t>( { 0 }));
localDataPoolMap.emplace(RwDefinitions::CURRRENT_RESET_STATUS, new PoolEntry<uint8_t>( { 0 }));
localDataPoolMap.emplace(RwDefinitions::TM_LAST_RESET_STATUS, new PoolEntry<uint8_t>({0}));
localDataPoolMap.emplace(RwDefinitions::TM_MCU_TEMPERATURE, new PoolEntry<int32_t>({0}));
localDataPoolMap.emplace(RwDefinitions::PRESSURE_SENSOR_TEMPERATURE, new PoolEntry<float>({0}));
localDataPoolMap.emplace(RwDefinitions::PRESSURE, new PoolEntry<float>({0}));
localDataPoolMap.emplace(RwDefinitions::TM_RW_STATE, new PoolEntry<uint8_t>({0}));
localDataPoolMap.emplace(RwDefinitions::TM_CLC_MODE, new PoolEntry<uint8_t>({0}));
localDataPoolMap.emplace(RwDefinitions::TM_RW_CURR_SPEED, new PoolEntry<int32_t>({0}));
localDataPoolMap.emplace(RwDefinitions::TM_RW_REF_SPEED, new PoolEntry<int32_t>({0}));
localDataPoolMap.emplace(RwDefinitions::INVALID_CRC_PACKETS, new PoolEntry<uint32_t>({0}));
localDataPoolMap.emplace(RwDefinitions::INVALID_LEN_PACKETS, new PoolEntry<uint32_t>({0}));
localDataPoolMap.emplace(RwDefinitions::INVALID_CMD_PACKETS, new PoolEntry<uint32_t>({0}));
localDataPoolMap.emplace(RwDefinitions::EXECUTED_REPLIES, new PoolEntry<uint32_t>({0}));
localDataPoolMap.emplace(RwDefinitions::COMMAND_REPLIES, new PoolEntry<uint32_t>({0}));
localDataPoolMap.emplace(RwDefinitions::UART_BYTES_WRITTEN, new PoolEntry<uint32_t>({0}));
localDataPoolMap.emplace(RwDefinitions::UART_BYTES_READ, new PoolEntry<uint32_t>({0}));
localDataPoolMap.emplace(RwDefinitions::UART_PARITY_ERRORS, new PoolEntry<uint32_t>({0}));
localDataPoolMap.emplace(RwDefinitions::UART_NOISE_ERRORS, new PoolEntry<uint32_t>({0}));
localDataPoolMap.emplace(RwDefinitions::UART_FRAME_ERRORS, new PoolEntry<uint32_t>({0}));
localDataPoolMap.emplace(RwDefinitions::UART_REG_OVERRUN_ERRORS, new PoolEntry<uint32_t>({0}));
localDataPoolMap.emplace(RwDefinitions::UART_TOTAL_ERRORS, new PoolEntry<uint32_t>({0}));
localDataPoolMap.emplace(RwDefinitions::SPI_BYTES_WRITTEN, new PoolEntry<uint32_t>({0}));
localDataPoolMap.emplace(RwDefinitions::SPI_BYTES_READ, new PoolEntry<uint32_t>({0}));
localDataPoolMap.emplace(RwDefinitions::SPI_REG_OVERRUN_ERRORS, new PoolEntry<uint32_t>({0}));
localDataPoolMap.emplace(RwDefinitions::SPI_TOTAL_ERRORS, new PoolEntry<uint32_t>({0}));
localDataPoolMap.emplace(RwDefinitions::TM_LAST_RESET_STATUS, new PoolEntry<uint8_t>( { 0 }));
localDataPoolMap.emplace(RwDefinitions::TM_MCU_TEMPERATURE, new PoolEntry<int32_t>( { 0 }));
localDataPoolMap.emplace(RwDefinitions::PRESSURE_SENSOR_TEMPERATURE, new PoolEntry<float>( { 0 }));
localDataPoolMap.emplace(RwDefinitions::PRESSURE, new PoolEntry<float>( { 0 }));
localDataPoolMap.emplace(RwDefinitions::TM_RW_STATE, new PoolEntry<uint8_t>( { 0 }));
localDataPoolMap.emplace(RwDefinitions::TM_CLC_MODE, new PoolEntry<uint8_t>( { 0 }));
localDataPoolMap.emplace(RwDefinitions::TM_RW_CURR_SPEED, new PoolEntry<int32_t>( { 0 }));
localDataPoolMap.emplace(RwDefinitions::TM_RW_REF_SPEED, new PoolEntry<int32_t>( { 0 }));
localDataPoolMap.emplace(RwDefinitions::INVALID_CRC_PACKETS, new PoolEntry<uint32_t>( { 0 }));
localDataPoolMap.emplace(RwDefinitions::INVALID_LEN_PACKETS, new PoolEntry<uint32_t>( { 0 }));
localDataPoolMap.emplace(RwDefinitions::INVALID_CMD_PACKETS, new PoolEntry<uint32_t>( { 0 }));
localDataPoolMap.emplace(RwDefinitions::EXECUTED_REPLIES, new PoolEntry<uint32_t>( { 0 }));
localDataPoolMap.emplace(RwDefinitions::COMMAND_REPLIES, new PoolEntry<uint32_t>( { 0 }));
localDataPoolMap.emplace(RwDefinitions::UART_BYTES_WRITTEN, new PoolEntry<uint32_t>( { 0 }));
localDataPoolMap.emplace(RwDefinitions::UART_BYTES_READ, new PoolEntry<uint32_t>( { 0 }));
localDataPoolMap.emplace(RwDefinitions::UART_PARITY_ERRORS, new PoolEntry<uint32_t>( { 0 }));
localDataPoolMap.emplace(RwDefinitions::UART_NOISE_ERRORS, new PoolEntry<uint32_t>( { 0 }));
localDataPoolMap.emplace(RwDefinitions::UART_FRAME_ERRORS, new PoolEntry<uint32_t>( { 0 }));
localDataPoolMap.emplace(RwDefinitions::UART_REG_OVERRUN_ERRORS, new PoolEntry<uint32_t>( { 0 }));
localDataPoolMap.emplace(RwDefinitions::UART_TOTAL_ERRORS, new PoolEntry<uint32_t>( { 0 }));
localDataPoolMap.emplace(RwDefinitions::SPI_BYTES_WRITTEN, new PoolEntry<uint32_t>( { 0 }));
localDataPoolMap.emplace(RwDefinitions::SPI_BYTES_READ, new PoolEntry<uint32_t>( { 0 }));
localDataPoolMap.emplace(RwDefinitions::SPI_REG_OVERRUN_ERRORS, new PoolEntry<uint32_t>( { 0 }));
localDataPoolMap.emplace(RwDefinitions::SPI_TOTAL_ERRORS, new PoolEntry<uint32_t>( { 0 }));
return RETURN_OK;
return RETURN_OK;
}
void RwHandler::prepareSimpleCommand(DeviceCommandId_t id) {
commandBuffer[0] = static_cast<uint8_t>(id);
uint16_t crc = CRC::crc16ccitt(commandBuffer, 1, 0xFFFF);
commandBuffer[1] = static_cast<uint8_t>(crc & 0xFF);
commandBuffer[2] = static_cast<uint8_t>(crc >> 8 & 0xFF);
rawPacket = commandBuffer;
rawPacketLen = 3;
commandBuffer[0] = static_cast<uint8_t>(id);
uint16_t crc = CRC::crc16ccitt(commandBuffer, 1, 0xFFFF);
commandBuffer[1] = static_cast<uint8_t>(crc & 0xFF);
commandBuffer[2] = static_cast<uint8_t>(crc >> 8 & 0xFF);
rawPacket = commandBuffer;
rawPacketLen = 3;
}
ReturnValue_t RwHandler::checkSpeedAndRampTime(const uint8_t* commandData, size_t commandDataLen) {
int32_t speed = *commandData << 24 | *(commandData + 1) << 16 | *(commandData + 2) << 8
| *(commandData + 3);
int32_t speed =
*commandData << 24 | *(commandData + 1) << 16 | *(commandData + 2) << 8 | *(commandData + 3);
if ((speed < -65000 || speed > 65000 || (speed > -1000 && speed < 1000)) && (speed != 0)) {
sif::error << "RwHandler::checkSpeedAndRampTime: Command has invalid speed" << std::endl;
return INVALID_SPEED;
}
if ((speed < -65000 || speed > 65000 || (speed > -1000 && speed < 1000)) && (speed != 0)) {
sif::error << "RwHandler::checkSpeedAndRampTime: Command has invalid speed" << std::endl;
return INVALID_SPEED;
}
uint16_t rampTime = *(commandData + 4) << 8 | *(commandData + 5);
uint16_t rampTime = *(commandData + 4) << 8 | *(commandData + 5);
if (rampTime < 10 || rampTime > 10000) {
sif::error << "RwHandler::checkSpeedAndRampTime: Command has invalid ramp time"
<< std::endl;
return INVALID_RAMP_TIME;
}
if (rampTime < 10 || rampTime > 10000) {
sif::error << "RwHandler::checkSpeedAndRampTime: Command has invalid ramp time" << std::endl;
return INVALID_RAMP_TIME;
}
return RETURN_OK;
return RETURN_OK;
}
void RwHandler::prepareSetSpeedCmd(const uint8_t * commandData, size_t commandDataLen) {
commandBuffer[0] = static_cast<uint8_t>(RwDefinitions::SET_SPEED);
void RwHandler::prepareSetSpeedCmd(const uint8_t* commandData, size_t commandDataLen) {
commandBuffer[0] = static_cast<uint8_t>(RwDefinitions::SET_SPEED);
/** Speed (0.1 RPM) */
commandBuffer[1] = *(commandData + 3);
commandBuffer[2] = *(commandData + 2);
commandBuffer[3] = *(commandData + 1);
commandBuffer[4] = *commandData;
/** Ramp time (ms) */
commandBuffer[5] = *(commandData + 5);
commandBuffer[6] = *(commandData + 4);
/** Speed (0.1 RPM) */
commandBuffer[1] = *(commandData + 3);
commandBuffer[2] = *(commandData + 2);
commandBuffer[3] = *(commandData + 1);
commandBuffer[4] = *commandData;
/** Ramp time (ms) */
commandBuffer[5] = *(commandData + 5);
commandBuffer[6] = *(commandData + 4);
uint16_t crc = CRC::crc16ccitt(commandBuffer, 7, 0xFFFF);
commandBuffer[7] = static_cast<uint8_t>(crc & 0xFF);
commandBuffer[8] = static_cast<uint8_t>(crc >> 8 & 0xFF);
rawPacket = commandBuffer;
rawPacketLen = 9;
uint16_t crc = CRC::crc16ccitt(commandBuffer, 7, 0xFFFF);
commandBuffer[7] = static_cast<uint8_t>(crc & 0xFF);
commandBuffer[8] = static_cast<uint8_t>(crc >> 8 & 0xFF);
rawPacket = commandBuffer;
rawPacketLen = 9;
}
void RwHandler::handleResetStatusReply(const uint8_t* packet) {
PoolReadGuard rg(&lastResetStatusSet);
uint8_t offset = 2;
uint8_t resetStatus = *(packet + offset);
if (resetStatus != RwDefinitions::CLEARED) {
internalState = InternalState::CLEAR_RESET_STATUS;
lastResetStatusSet.lastResetStatus = resetStatus;
}
lastResetStatusSet.currentResetStatus = resetStatus;
PoolReadGuard rg(&lastResetStatusSet);
uint8_t offset = 2;
uint8_t resetStatus = *(packet + offset);
if (resetStatus != RwDefinitions::CLEARED) {
internalState = InternalState::CLEAR_RESET_STATUS;
lastResetStatusSet.lastResetStatus = resetStatus;
}
lastResetStatusSet.currentResetStatus = resetStatus;
#if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_RW == 1
sif::info << "RwHandler::handleResetStatusReply: Last reset status: "
sif::info << "RwHandler::handleResetStatusReply: Last reset status: "
<< static_cast<unsigned int>(lastResetStatusSet.lastResetStatus.value) << std::endl;
sif::info << "RwHandler::handleResetStatusReply: Current reset status: "
sif::info << "RwHandler::handleResetStatusReply: Current reset status: "
<< static_cast<unsigned int>(lastResetStatusSet.currentResetStatus.value) << std::endl;
#endif
}
void RwHandler::handleGetRwStatusReply(const uint8_t* packet) {
PoolReadGuard rg(&statusSet);
uint8_t offset = 2;
statusSet.currSpeed = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16
| *(packet + offset + 1) << 8 | *(packet + offset);
offset += 4;
statusSet.referenceSpeed = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16
| *(packet + offset + 1) << 8 | *(packet + offset);
offset += 4;
statusSet.state = *(packet + offset);
offset += 1;
statusSet.clcMode = *(packet + offset);
PoolReadGuard rg(&statusSet);
uint8_t offset = 2;
statusSet.currSpeed = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 |
*(packet + offset + 1) << 8 | *(packet + offset);
offset += 4;
statusSet.referenceSpeed = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 |
*(packet + offset + 1) << 8 | *(packet + offset);
offset += 4;
statusSet.state = *(packet + offset);
offset += 1;
statusSet.clcMode = *(packet + offset);
if (statusSet.state == RwDefinitions::STATE_ERROR) {
/**
* This requires the commanding of the init reaction wheel controller command to recover
* form error state which must be handled by the FDIR instance.
*/
triggerEvent(ERROR_STATE);
sif::error << "RwHandler::handleGetRwStatusReply: Reaction wheel in error state"
<< std::endl;
}
if (statusSet.state == RwDefinitions::STATE_ERROR) {
/**
* This requires the commanding of the init reaction wheel controller command to recover
* form error state which must be handled by the FDIR instance.
*/
triggerEvent(ERROR_STATE);
sif::error << "RwHandler::handleGetRwStatusReply: Reaction wheel in error state" << std::endl;
}
#if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_RW == 1
sif::info << "RwHandler::handleGetRwStatusReply: Current speed is: " << statusSet.currSpeed
sif::info << "RwHandler::handleGetRwStatusReply: Current speed is: " << statusSet.currSpeed
<< " * 0.1 RPM" << std::endl;
sif::info << "RwHandler::handleGetRwStatusReply: Reference speed is: "
<< statusSet.referenceSpeed << " * 0.1 RPM" << std::endl;
sif::info << "RwHandler::handleGetRwStatusReply: State is: "
<< (unsigned int) statusSet.state.value << std::endl;
sif::info << "RwHandler::handleGetRwStatusReply: clc mode is: "
<< (unsigned int) statusSet.clcMode.value << std::endl;
sif::info << "RwHandler::handleGetRwStatusReply: Reference speed is: " << statusSet.referenceSpeed
<< " * 0.1 RPM" << std::endl;
sif::info << "RwHandler::handleGetRwStatusReply: State is: "
<< (unsigned int)statusSet.state.value << std::endl;
sif::info << "RwHandler::handleGetRwStatusReply: clc mode is: "
<< (unsigned int)statusSet.clcMode.value << std::endl;
#endif
}
void RwHandler::handleTemperatureReply(const uint8_t* packet) {
PoolReadGuard rg(&temperatureSet);
uint8_t offset = 2;
temperatureSet.temperatureCelcius = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16
| *(packet + offset + 1) << 8 | *(packet + offset);
PoolReadGuard rg(&temperatureSet);
uint8_t offset = 2;
temperatureSet.temperatureCelcius = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 |
*(packet + offset + 1) << 8 | *(packet + offset);
#if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_RW == 1
sif::info << "RwHandler::handleTemperatureReply: Temperature: "
sif::info << "RwHandler::handleTemperatureReply: Temperature: "
<< temperatureSet.temperatureCelcius << " °C" << std::endl;
#endif
}
void RwHandler::handleGetTelemetryReply(const uint8_t* packet) {
PoolReadGuard rg(&tmDataset);
uint8_t offset = 2;
tmDataset.lastResetStatus = *(packet + offset);
offset += 1;
tmDataset.mcuTemperature = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16
| *(packet + offset + 1) << 8 | *(packet + offset);
offset += 4;
tmDataset.pressureSensorTemperature = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16
| *(packet + offset + 1) << 8 | *(packet + offset);
offset += 4;
tmDataset.pressure = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16
| *(packet + offset + 1) << 8 | *(packet + offset);
offset += 4;
tmDataset.rwState = *(packet + offset);
offset += 1;
tmDataset.rwClcMode = *(packet + offset);
offset += 1;
tmDataset.rwCurrSpeed = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16
| *(packet + offset + 1) << 8 | *(packet + offset);
offset += 4;
tmDataset.rwRefSpeed = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16
| *(packet + offset + 1) << 8 | *(packet + offset);
offset += 4;
tmDataset.numOfInvalidCrcPackets = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16
| *(packet + offset + 1) << 8 | *(packet + offset);
offset += 4;
tmDataset.numOfInvalidLenPackets = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16
| *(packet + offset + 1) << 8 | *(packet + offset);
offset += 4;
tmDataset.numOfInvalidCmdPackets = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16
| *(packet + offset + 1) << 8 | *(packet + offset);
offset += 4;
tmDataset.numOfCmdExecutedReplies = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16
| *(packet + offset + 1) << 8 | *(packet + offset);
offset += 4;
tmDataset.numOfCmdReplies = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16
| *(packet + offset + 1) << 8 | *(packet + offset);
offset += 4;
tmDataset.uartNumOfBytesWritten = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16
| *(packet + offset + 1) << 8 | *(packet + offset);
offset += 4;
tmDataset.uartNumOfBytesRead = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16
| *(packet + offset + 1) << 8 | *(packet + offset);
offset += 4;
tmDataset.uartNumOfParityErrors = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16
| *(packet + offset + 1) << 8 | *(packet + offset);
offset += 4;
tmDataset.uartNumOfNoiseErrors = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16
| *(packet + offset + 1) << 8 | *(packet + offset);
offset += 4;
tmDataset.uartNumOfFrameErrors = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16
| *(packet + offset + 1) << 8 | *(packet + offset);
offset += 4;
tmDataset.uartNumOfRegisterOverrunErrors = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16
| *(packet + offset + 1) << 8 | *(packet + offset);
offset += 4;
tmDataset.uartTotalNumOfErrors = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16
| *(packet + offset + 1) << 8 | *(packet + offset);
offset += 4;
tmDataset.spiNumOfBytesWritten = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16
| *(packet + offset + 1) << 8 | *(packet + offset);
offset += 4;
tmDataset.spiNumOfBytesRead = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16
| *(packet + offset + 1) << 8 | *(packet + offset);
offset += 4;
tmDataset.spiNumOfRegisterOverrunErrors = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16
| *(packet + offset + 1) << 8 | *(packet + offset);
offset += 4;
tmDataset.spiTotalNumOfErrors = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16
| *(packet + offset + 1) << 8 | *(packet + offset);
PoolReadGuard rg(&tmDataset);
uint8_t offset = 2;
tmDataset.lastResetStatus = *(packet + offset);
offset += 1;
tmDataset.mcuTemperature = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 |
*(packet + offset + 1) << 8 | *(packet + offset);
offset += 4;
tmDataset.pressureSensorTemperature = *(packet + offset + 3) << 24 |
*(packet + offset + 2) << 16 | *(packet + offset + 1) << 8 |
*(packet + offset);
offset += 4;
tmDataset.pressure = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 |
*(packet + offset + 1) << 8 | *(packet + offset);
offset += 4;
tmDataset.rwState = *(packet + offset);
offset += 1;
tmDataset.rwClcMode = *(packet + offset);
offset += 1;
tmDataset.rwCurrSpeed = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 |
*(packet + offset + 1) << 8 | *(packet + offset);
offset += 4;
tmDataset.rwRefSpeed = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 |
*(packet + offset + 1) << 8 | *(packet + offset);
offset += 4;
tmDataset.numOfInvalidCrcPackets = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 |
*(packet + offset + 1) << 8 | *(packet + offset);
offset += 4;
tmDataset.numOfInvalidLenPackets = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 |
*(packet + offset + 1) << 8 | *(packet + offset);
offset += 4;
tmDataset.numOfInvalidCmdPackets = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 |
*(packet + offset + 1) << 8 | *(packet + offset);
offset += 4;
tmDataset.numOfCmdExecutedReplies = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 |
*(packet + offset + 1) << 8 | *(packet + offset);
offset += 4;
tmDataset.numOfCmdReplies = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 |
*(packet + offset + 1) << 8 | *(packet + offset);
offset += 4;
tmDataset.uartNumOfBytesWritten = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 |
*(packet + offset + 1) << 8 | *(packet + offset);
offset += 4;
tmDataset.uartNumOfBytesRead = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 |
*(packet + offset + 1) << 8 | *(packet + offset);
offset += 4;
tmDataset.uartNumOfParityErrors = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 |
*(packet + offset + 1) << 8 | *(packet + offset);
offset += 4;
tmDataset.uartNumOfNoiseErrors = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 |
*(packet + offset + 1) << 8 | *(packet + offset);
offset += 4;
tmDataset.uartNumOfFrameErrors = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 |
*(packet + offset + 1) << 8 | *(packet + offset);
offset += 4;
tmDataset.uartNumOfRegisterOverrunErrors = *(packet + offset + 3) << 24 |
*(packet + offset + 2) << 16 |
*(packet + offset + 1) << 8 | *(packet + offset);
offset += 4;
tmDataset.uartTotalNumOfErrors = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 |
*(packet + offset + 1) << 8 | *(packet + offset);
offset += 4;
tmDataset.spiNumOfBytesWritten = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 |
*(packet + offset + 1) << 8 | *(packet + offset);
offset += 4;
tmDataset.spiNumOfBytesRead = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 |
*(packet + offset + 1) << 8 | *(packet + offset);
offset += 4;
tmDataset.spiNumOfRegisterOverrunErrors = *(packet + offset + 3) << 24 |
*(packet + offset + 2) << 16 |
*(packet + offset + 1) << 8 | *(packet + offset);
offset += 4;
tmDataset.spiTotalNumOfErrors = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 |
*(packet + offset + 1) << 8 | *(packet + offset);
#if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_RW == 1
sif::info << "RwHandler::handleTemperatureReply: Last reset status: "
sif::info << "RwHandler::handleTemperatureReply: Last reset status: "
<< static_cast<unsigned int>(tmDataset.lastResetStatus.value) << std::endl;
sif::info << "RwHandler::handleTemperatureReply: MCU temperature: " << tmDataset.mcuTemperature
sif::info << "RwHandler::handleTemperatureReply: MCU temperature: " << tmDataset.mcuTemperature
<< std::endl;
sif::info << "RwHandler::handleTemperatureReply: Pressure sensor temperature: "
sif::info << "RwHandler::handleTemperatureReply: Pressure sensor temperature: "
<< tmDataset.pressureSensorTemperature << std::endl;
sif::info << "RwHandler::handleTemperatureReply: Pressure "
<< tmDataset.pressure << std::endl;
sif::info << "RwHandler::handleTemperatureReply: State: "
sif::info << "RwHandler::handleTemperatureReply: Pressure " << tmDataset.pressure << std::endl;
sif::info << "RwHandler::handleTemperatureReply: State: "
<< static_cast<unsigned int>(tmDataset.rwState.value) << std::endl;
sif::info << "RwHandler::handleTemperatureReply: CLC mode: "
sif::info << "RwHandler::handleTemperatureReply: CLC mode: "
<< static_cast<unsigned int>(tmDataset.rwClcMode.value) << std::endl;
sif::info << "RwHandler::handleTemperatureReply: Current speed: " << tmDataset.rwCurrSpeed
sif::info << "RwHandler::handleTemperatureReply: Current speed: " << tmDataset.rwCurrSpeed
<< std::endl;
sif::info << "RwHandler::handleTemperatureReply: Reference speed: " << tmDataset.rwRefSpeed
sif::info << "RwHandler::handleTemperatureReply: Reference speed: " << tmDataset.rwRefSpeed
<< std::endl;
sif::info << "RwHandler::handleTemperatureReply: Number of invalid CRC packets: "
sif::info << "RwHandler::handleTemperatureReply: Number of invalid CRC packets: "
<< tmDataset.numOfInvalidCrcPackets << std::endl;
sif::info << "RwHandler::handleTemperatureReply: Number of invalid length packets: "
sif::info << "RwHandler::handleTemperatureReply: Number of invalid length packets: "
<< tmDataset.numOfInvalidLenPackets << std::endl;
sif::info << "RwHandler::handleTemperatureReply: Number of invalid command packets: "
sif::info << "RwHandler::handleTemperatureReply: Number of invalid command packets: "
<< tmDataset.numOfInvalidCmdPackets << std::endl;
sif::info << "RwHandler::handleTemperatureReply: Number of command executed replies: "
sif::info << "RwHandler::handleTemperatureReply: Number of command executed replies: "
<< tmDataset.numOfCmdExecutedReplies << std::endl;
sif::info << "RwHandler::handleTemperatureReply: Number of command replies: "
sif::info << "RwHandler::handleTemperatureReply: Number of command replies: "
<< tmDataset.numOfCmdReplies << std::endl;
sif::info << "RwHandler::handleTemperatureReply: UART number of bytes written: "
sif::info << "RwHandler::handleTemperatureReply: UART number of bytes written: "
<< tmDataset.uartNumOfBytesWritten << std::endl;
sif::info << "RwHandler::handleTemperatureReply: UART number of bytes read: "
sif::info << "RwHandler::handleTemperatureReply: UART number of bytes read: "
<< tmDataset.uartNumOfBytesRead << std::endl;
sif::info << "RwHandler::handleTemperatureReply: UART number of parity errors: "
sif::info << "RwHandler::handleTemperatureReply: UART number of parity errors: "
<< tmDataset.uartNumOfParityErrors << std::endl;
sif::info << "RwHandler::handleTemperatureReply: UART number of noise errors: "
sif::info << "RwHandler::handleTemperatureReply: UART number of noise errors: "
<< tmDataset.uartNumOfNoiseErrors << std::endl;
sif::info << "RwHandler::handleTemperatureReply: UART number of frame errors: "
sif::info << "RwHandler::handleTemperatureReply: UART number of frame errors: "
<< tmDataset.uartNumOfFrameErrors << std::endl;
sif::info << "RwHandler::handleTemperatureReply: UART number of register overrun errors: "
sif::info << "RwHandler::handleTemperatureReply: UART number of register overrun errors: "
<< tmDataset.uartNumOfRegisterOverrunErrors << std::endl;
sif::info << "RwHandler::handleTemperatureReply: UART number of total errors: "
sif::info << "RwHandler::handleTemperatureReply: UART number of total errors: "
<< tmDataset.uartTotalNumOfErrors << std::endl;
sif::info << "RwHandler::handleTemperatureReply: SPI number of bytes written: "
sif::info << "RwHandler::handleTemperatureReply: SPI number of bytes written: "
<< tmDataset.spiNumOfBytesWritten << std::endl;
sif::info << "RwHandler::handleTemperatureReply: SPI number of bytes read: "
sif::info << "RwHandler::handleTemperatureReply: SPI number of bytes read: "
<< tmDataset.spiNumOfBytesRead << std::endl;
sif::info << "RwHandler::handleTemperatureReply: SPI number of register overrun errors: "
sif::info << "RwHandler::handleTemperatureReply: SPI number of register overrun errors: "
<< tmDataset.spiNumOfRegisterOverrunErrors << std::endl;
sif::info << "RwHandler::handleTemperatureReply: SPI number of register total errors: "
sif::info << "RwHandler::handleTemperatureReply: SPI number of register total errors: "
<< tmDataset.spiTotalNumOfErrors << std::endl;
#endif
}

View File

@ -2,8 +2,8 @@
#define MISSION_DEVICES_RWHANDLER_H_
#include <fsfw/devicehandlers/DeviceHandlerBase.h>
#include <mission/devices/devicedefinitions/RwDefinitions.h>
#include <fsfw_hal/linux/gpio/LinuxLibgpioIF.h>
#include <mission/devices/devicedefinitions/RwDefinitions.h>
#include <string.h>
/**
@ -16,141 +16,135 @@
*
* @author J. Meier
*/
class RwHandler: public DeviceHandlerBase {
public:
class RwHandler : public DeviceHandlerBase {
public:
/**
* @brief Constructor
*
* @param objectId
* @param comIF
* @param comCookie
* @param gpioComIF Pointer to gpio communication interface
* @param enablePin GPIO connected to the enable pin of the reaction wheels. Must be pulled
* to high to enable the device.
*/
RwHandler(object_id_t objectId, object_id_t comIF, CookieIF* comCookie, LinuxLibgpioIF* gpioComIF,
gpioId_t enableGpio);
virtual ~RwHandler();
/**
* @brief Constructor
*
* @param objectId
* @param comIF
* @param comCookie
* @param gpioComIF Pointer to gpio communication interface
* @param enablePin GPIO connected to the enable pin of the reaction wheels. Must be pulled
* to high to enable the device.
*/
RwHandler(object_id_t objectId, object_id_t comIF, CookieIF * comCookie,
LinuxLibgpioIF* gpioComIF, gpioId_t enableGpio);
virtual ~RwHandler();
static const uint8_t INTERFACE_ID = CLASS_ID::RW_HANDLER;
static const uint8_t INTERFACE_ID = CLASS_ID::RW_HANDLER;
static const ReturnValue_t SPI_WRITE_FAILURE = MAKE_RETURN_CODE(0xB0);
//! [EXPORT] : [COMMENT] Used by the spi send function to tell a failing read call
static const ReturnValue_t SPI_READ_FAILURE = MAKE_RETURN_CODE(0xB1);
//! [EXPORT] : [COMMENT] Can be used by the HDLC decoding mechanism to inform about a missing
//! start sign 0x7E
static const ReturnValue_t MISSING_START_SIGN = MAKE_RETURN_CODE(0xB2);
//! [EXPORT] : [COMMENT] Can be used by the HDLC decoding mechanism to inform about an invalid
//! substitution combination
static const ReturnValue_t INVALID_SUBSTITUTE = MAKE_RETURN_CODE(0xB3);
//! [EXPORT] : [COMMENT] HDLC decoding mechanism never receives the end sign 0x7E
static const ReturnValue_t MISSING_END_SIGN = MAKE_RETURN_CODE(0xB4);
//! [EXPORT] : [COMMENT] Reaction wheel only responds with empty frames.
static const ReturnValue_t NO_REPLY = MAKE_RETURN_CODE(0xB5);
//! [EXPORT] : [COMMENT] Expected a start marker as first byte
static const ReturnValue_t NO_START_MARKER = MAKE_RETURN_CODE(0xB6);
static const ReturnValue_t SPI_WRITE_FAILURE = MAKE_RETURN_CODE(0xB0);
//! [EXPORT] : [COMMENT] Used by the spi send function to tell a failing read call
static const ReturnValue_t SPI_READ_FAILURE = MAKE_RETURN_CODE(0xB1);
//! [EXPORT] : [COMMENT] Can be used by the HDLC decoding mechanism to inform about a missing start sign 0x7E
static const ReturnValue_t MISSING_START_SIGN = MAKE_RETURN_CODE(0xB2);
//! [EXPORT] : [COMMENT] Can be used by the HDLC decoding mechanism to inform about an invalid substitution combination
static const ReturnValue_t INVALID_SUBSTITUTE = MAKE_RETURN_CODE(0xB3);
//! [EXPORT] : [COMMENT] HDLC decoding mechanism never receives the end sign 0x7E
static const ReturnValue_t MISSING_END_SIGN = MAKE_RETURN_CODE(0xB4);
//! [EXPORT] : [COMMENT] Reaction wheel only responds with empty frames.
static const ReturnValue_t NO_REPLY = MAKE_RETURN_CODE(0xB5);
//! [EXPORT] : [COMMENT] Expected a start marker as first byte
static const ReturnValue_t NO_START_MARKER = MAKE_RETURN_CODE(0xB6);
protected:
void doStartUp() override;
void doShutDown() override;
ReturnValue_t buildNormalDeviceCommand(DeviceCommandId_t* id) override;
ReturnValue_t buildTransitionDeviceCommand(DeviceCommandId_t* id) override;
void fillCommandAndReplyMap() override;
ReturnValue_t buildCommandFromCommand(DeviceCommandId_t deviceCommand, const uint8_t* commandData,
size_t commandDataLen) override;
ReturnValue_t scanForReply(const uint8_t* start, size_t remainingSize, DeviceCommandId_t* foundId,
size_t* foundLen) override;
ReturnValue_t interpretDeviceReply(DeviceCommandId_t id, const uint8_t* packet) override;
void setNormalDatapoolEntriesInvalid() override;
uint32_t getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) override;
ReturnValue_t initializeLocalDataPool(localpool::DataPool& localDataPoolMap,
LocalDataPoolManager& poolManager) override;
protected:
void doStartUp() override;
void doShutDown() override;
ReturnValue_t buildNormalDeviceCommand(DeviceCommandId_t * id) override;
ReturnValue_t buildTransitionDeviceCommand(DeviceCommandId_t * id) override;
void fillCommandAndReplyMap() override;
ReturnValue_t buildCommandFromCommand(DeviceCommandId_t deviceCommand,
const uint8_t * commandData,size_t commandDataLen) override;
ReturnValue_t scanForReply(const uint8_t *start, size_t remainingSize,
DeviceCommandId_t *foundId, size_t *foundLen) override;
ReturnValue_t interpretDeviceReply(DeviceCommandId_t id,
const uint8_t *packet) override;
void setNormalDatapoolEntriesInvalid() override;
uint32_t getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) override;
ReturnValue_t initializeLocalDataPool(localpool::DataPool& localDataPoolMap,
LocalDataPoolManager& poolManager) override;
private:
static const uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::RW_HANDLER;
private:
//! [EXPORT] : [COMMENT] Action Message with invalid speed was received. Valid speeds must be in
//! the range of [-65000; 1000] or [1000; 65000]
static const ReturnValue_t INVALID_SPEED = MAKE_RETURN_CODE(0xA0);
//! [EXPORT] : [COMMENT] Action Message with invalid ramp time was received.
static const ReturnValue_t INVALID_RAMP_TIME = MAKE_RETURN_CODE(0xA1);
//! [EXPORT] : [COMMENT] Received set speed command has invalid length. Should be 6.
static const ReturnValue_t SET_SPEED_COMMAND_INVALID_LENGTH = MAKE_RETURN_CODE(0xA2);
//! [EXPORT] : [COMMENT] Command execution failed
static const ReturnValue_t EXECUTION_FAILED = MAKE_RETURN_CODE(0xA3);
//! [EXPORT] : [COMMENT] Reaction wheel reply has invalid crc
static const ReturnValue_t CRC_ERROR = MAKE_RETURN_CODE(0xA4);
static const uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::RW_HANDLER;
//! [EXPORT] : [COMMENT] Reaction wheel signals an error state
static const Event ERROR_STATE = MAKE_EVENT(1, severity::HIGH);
//! [EXPORT] : [COMMENT] Action Message with invalid speed was received. Valid speeds must be in the range of [-65000; 1000] or [1000; 65000]
static const ReturnValue_t INVALID_SPEED = MAKE_RETURN_CODE(0xA0);
//! [EXPORT] : [COMMENT] Action Message with invalid ramp time was received.
static const ReturnValue_t INVALID_RAMP_TIME = MAKE_RETURN_CODE(0xA1);
//! [EXPORT] : [COMMENT] Received set speed command has invalid length. Should be 6.
static const ReturnValue_t SET_SPEED_COMMAND_INVALID_LENGTH = MAKE_RETURN_CODE(0xA2);
//! [EXPORT] : [COMMENT] Command execution failed
static const ReturnValue_t EXECUTION_FAILED = MAKE_RETURN_CODE(0xA3);
//! [EXPORT] : [COMMENT] Reaction wheel reply has invalid crc
static const ReturnValue_t CRC_ERROR = MAKE_RETURN_CODE(0xA4);
LinuxLibgpioIF* gpioComIF = nullptr;
gpioId_t enableGpio = gpio::NO_GPIO;
//! [EXPORT] : [COMMENT] Reaction wheel signals an error state
static const Event ERROR_STATE = MAKE_EVENT(1, severity::HIGH);
RwDefinitions::TemperatureSet temperatureSet;
RwDefinitions::StatusSet statusSet;
RwDefinitions::LastResetSatus lastResetStatusSet;
RwDefinitions::TmDataset tmDataset;
LinuxLibgpioIF* gpioComIF = nullptr;
gpioId_t enableGpio = gpio::NO_GPIO;
uint8_t commandBuffer[RwDefinitions::MAX_CMD_SIZE];
RwDefinitions::TemperatureSet temperatureSet;
RwDefinitions::StatusSet statusSet;
RwDefinitions::LastResetSatus lastResetStatusSet;
RwDefinitions::TmDataset tmDataset;
enum class InternalState { GET_RESET_STATUS, CLEAR_RESET_STATUS, READ_TEMPERATURE, GET_RW_SATUS };
InternalState internalState = InternalState::GET_RESET_STATUS;
uint8_t commandBuffer[RwDefinitions::MAX_CMD_SIZE];
size_t sizeOfReply = 0;
enum class InternalState {
GET_RESET_STATUS,
CLEAR_RESET_STATUS,
READ_TEMPERATURE,
GET_RW_SATUS
};
/**
* @brief This function can be used to build commands which do not contain any data apart
* from the command id and the CRC.
* @param commandId The command id of the command to build.
*/
void prepareSimpleCommand(DeviceCommandId_t id);
InternalState internalState = InternalState::GET_RESET_STATUS;
/**
* @brief This function checks if the receiced speed and ramp time to set are in a valid
* range.
* @return RETURN_OK if successful, otherwise error code.
*/
ReturnValue_t checkSpeedAndRampTime(const uint8_t* commandData, size_t commandDataLen);
size_t sizeOfReply = 0;
/**
* @brief This function prepares the set speed command from the commandData received with
* an action message.
*/
void prepareSetSpeedCmd(const uint8_t* commandData, size_t commandDataLen);
/**
* @brief This function can be used to build commands which do not contain any data apart
* from the command id and the CRC.
* @param commandId The command id of the command to build.
*/
void prepareSimpleCommand(DeviceCommandId_t id);
/**
* @brief This function writes the last reset status retrieved with the get last reset status
* command into the reset status dataset.
*
* @param packet Pointer to the buffer holding the reply data.
*/
void handleResetStatusReply(const uint8_t* packet);
/**
* @brief This function checks if the receiced speed and ramp time to set are in a valid
* range.
* @return RETURN_OK if successful, otherwise error code.
*/
ReturnValue_t checkSpeedAndRampTime(const uint8_t * commandData, size_t commandDataLen);
/**
* @brief This function handles the reply of the get temperature command.
*
* @param packet Pointer to the reply data
*/
void handleTemperatureReply(const uint8_t* packet);
/**
* @brief This function prepares the set speed command from the commandData received with
* an action message.
*/
void prepareSetSpeedCmd(const uint8_t * commandData, size_t commandDataLen);
/**
* @brief This function fills the status set with the data from the get-status-reply.
*/
void handleGetRwStatusReply(const uint8_t* packet);
/**
* @brief This function writes the last reset status retrieved with the get last reset status
* command into the reset status dataset.
*
* @param packet Pointer to the buffer holding the reply data.
*/
void handleResetStatusReply(const uint8_t* packet);
/**
* @brief This function handles the reply of the get temperature command.
*
* @param packet Pointer to the reply data
*/
void handleTemperatureReply(const uint8_t* packet);
/**
* @brief This function fills the status set with the data from the get-status-reply.
*/
void handleGetRwStatusReply(const uint8_t* packet);
/**
* @brief This function fills the tmDataset with the reply data requested with get telemetry
* command.
*/
void handleGetTelemetryReply(const uint8_t* packet);
/**
* @brief This function fills the tmDataset with the reply data requested with get telemetry
* command.
*/
void handleGetTelemetryReply(const uint8_t* packet);
};
#endif /* MISSION_DEVICES_RWHANDLER_H_ */

View File

@ -1,464 +1,451 @@
#include <fsfw/datapool/PoolReadGuard.h>
#include <fsfw/globalfunctions/CRC.h>
#include <mission/devices/SyrlinksHkHandler.h>
#include "OBSWConfig.h"
#include <mission/devices/SyrlinksHkHandler.h>
#include <fsfw/globalfunctions/CRC.h>
#include <fsfw/datapool/PoolReadGuard.h>
SyrlinksHkHandler::SyrlinksHkHandler(object_id_t objectId, object_id_t comIF, CookieIF * comCookie) :
DeviceHandlerBase(objectId, comIF, comCookie), rxDataset(this), txDataset(this) {
if (comCookie == NULL) {
sif::error << "SyrlinksHkHandler: Invalid com cookie" << std::endl;
}
SyrlinksHkHandler::SyrlinksHkHandler(object_id_t objectId, object_id_t comIF, CookieIF* comCookie)
: DeviceHandlerBase(objectId, comIF, comCookie), rxDataset(this), txDataset(this) {
if (comCookie == NULL) {
sif::error << "SyrlinksHkHandler: Invalid com cookie" << std::endl;
}
}
SyrlinksHkHandler::~SyrlinksHkHandler() {
SyrlinksHkHandler::~SyrlinksHkHandler() {}
void SyrlinksHkHandler::doStartUp() {
if (mode == _MODE_START_UP) {
setMode(MODE_ON);
}
}
void SyrlinksHkHandler::doShutDown() { setMode(_MODE_POWER_DOWN); }
void SyrlinksHkHandler::doStartUp(){
if(mode == _MODE_START_UP){
setMode(MODE_ON);
}
}
void SyrlinksHkHandler::doShutDown(){
setMode(_MODE_POWER_DOWN);
}
ReturnValue_t SyrlinksHkHandler::buildNormalDeviceCommand(
DeviceCommandId_t * id) {
switch (nextCommand) {
case(SYRLINKS::READ_RX_STATUS_REGISTERS):
*id = SYRLINKS::READ_RX_STATUS_REGISTERS;
nextCommand = SYRLINKS::READ_TX_STATUS;
break;
case(SYRLINKS::READ_TX_STATUS):
*id = SYRLINKS::READ_TX_STATUS;
nextCommand = SYRLINKS::READ_TX_WAVEFORM;
break;
case(SYRLINKS::READ_TX_WAVEFORM):
*id = SYRLINKS::READ_TX_WAVEFORM;
nextCommand = SYRLINKS::READ_TX_AGC_VALUE_HIGH_BYTE;
break;
case(SYRLINKS::READ_TX_AGC_VALUE_HIGH_BYTE):
*id = SYRLINKS::READ_TX_AGC_VALUE_HIGH_BYTE;
nextCommand = SYRLINKS::READ_TX_AGC_VALUE_LOW_BYTE;
break;
case(SYRLINKS::READ_TX_AGC_VALUE_LOW_BYTE):
*id = SYRLINKS::READ_TX_AGC_VALUE_LOW_BYTE;
nextCommand = SYRLINKS::READ_RX_STATUS_REGISTERS;
break;
ReturnValue_t SyrlinksHkHandler::buildNormalDeviceCommand(DeviceCommandId_t* id) {
switch (nextCommand) {
case (SYRLINKS::READ_RX_STATUS_REGISTERS):
*id = SYRLINKS::READ_RX_STATUS_REGISTERS;
nextCommand = SYRLINKS::READ_TX_STATUS;
break;
case (SYRLINKS::READ_TX_STATUS):
*id = SYRLINKS::READ_TX_STATUS;
nextCommand = SYRLINKS::READ_TX_WAVEFORM;
break;
case (SYRLINKS::READ_TX_WAVEFORM):
*id = SYRLINKS::READ_TX_WAVEFORM;
nextCommand = SYRLINKS::READ_TX_AGC_VALUE_HIGH_BYTE;
break;
case (SYRLINKS::READ_TX_AGC_VALUE_HIGH_BYTE):
*id = SYRLINKS::READ_TX_AGC_VALUE_HIGH_BYTE;
nextCommand = SYRLINKS::READ_TX_AGC_VALUE_LOW_BYTE;
break;
case (SYRLINKS::READ_TX_AGC_VALUE_LOW_BYTE):
*id = SYRLINKS::READ_TX_AGC_VALUE_LOW_BYTE;
nextCommand = SYRLINKS::READ_RX_STATUS_REGISTERS;
break;
default:
sif::debug << "SyrlinksHkHandler::buildNormalDeviceCommand: rememberCommandId has invalid"
<< "command id" << std::endl;
break;
sif::debug << "SyrlinksHkHandler::buildNormalDeviceCommand: rememberCommandId has invalid"
<< "command id" << std::endl;
break;
}
return buildCommandFromCommand(*id, NULL, 0);
}
ReturnValue_t SyrlinksHkHandler::buildTransitionDeviceCommand(DeviceCommandId_t* id) {
return HasReturnvaluesIF::RETURN_OK;
}
ReturnValue_t SyrlinksHkHandler::buildCommandFromCommand(DeviceCommandId_t deviceCommand,
const uint8_t* commandData,
size_t commandDataLen) {
switch (deviceCommand) {
case (SYRLINKS::RESET_UNIT): {
resetCommand.copy(reinterpret_cast<char*>(commandBuffer), resetCommand.size(), 0);
rawPacketLen = resetCommand.size();
rawPacket = commandBuffer;
return RETURN_OK;
}
return buildCommandFromCommand(*id, NULL, 0);
}
ReturnValue_t SyrlinksHkHandler::buildTransitionDeviceCommand(
DeviceCommandId_t * id){
return HasReturnvaluesIF::RETURN_OK;
}
ReturnValue_t SyrlinksHkHandler::buildCommandFromCommand(
DeviceCommandId_t deviceCommand, const uint8_t * commandData,
size_t commandDataLen) {
switch(deviceCommand) {
case(SYRLINKS::RESET_UNIT): {
resetCommand.copy(reinterpret_cast<char*>(commandBuffer), resetCommand.size(), 0);
rawPacketLen = resetCommand.size();
rawPacket = commandBuffer;
return RETURN_OK;
}
case(SYRLINKS::SET_TX_MODE_STANDBY): {
setTxModeStandby.copy(reinterpret_cast<char*>(commandBuffer), setTxModeStandby.size(), 0);
rawPacketLen = setTxModeStandby.size();
rawPacket = commandBuffer;
return RETURN_OK;
}
case(SYRLINKS::SET_TX_MODE_MODULATION): {
setTxModeModulation.copy(reinterpret_cast<char*>(commandBuffer), setTxModeModulation.size(), 0);
rawPacketLen = setTxModeModulation.size();
rawPacket = commandBuffer;
return RETURN_OK;
}
case(SYRLINKS::SET_TX_MODE_CW): {
setTxModeCw.copy(reinterpret_cast<char*>(commandBuffer), setTxModeCw.size(), 0);
rawPacketLen = setTxModeCw.size();
rawPacket = commandBuffer;
return RETURN_OK;
}
case(SYRLINKS::READ_RX_STATUS_REGISTERS): {
readRxStatusRegCommand.copy(reinterpret_cast<char*>(commandBuffer), readRxStatusRegCommand.size(), 0);
rawPacketLen = readRxStatusRegCommand.size();
rawPacket = commandBuffer;
return RETURN_OK;
}
case(SYRLINKS::READ_TX_STATUS): {
readTxStatus.copy(reinterpret_cast<char*>(commandBuffer), readTxStatus.size(), 0);
rawPacketLen = readTxStatus.size();
rememberCommandId = SYRLINKS::READ_TX_STATUS;
rawPacket = commandBuffer;
return RETURN_OK;
}
case(SYRLINKS::READ_TX_WAVEFORM): {
readTxWaveform.copy(reinterpret_cast<char*>(commandBuffer), readTxStatus.size(), 0);
rawPacketLen = readTxWaveform.size();
rememberCommandId = SYRLINKS::READ_TX_WAVEFORM;
rawPacket = commandBuffer;
return RETURN_OK;
}
case(SYRLINKS::READ_TX_AGC_VALUE_HIGH_BYTE): {
readTxAgcValueHighByte.copy(reinterpret_cast<char*>(commandBuffer), readTxStatus.size(), 0);
rawPacketLen = readTxAgcValueHighByte.size();
rememberCommandId = SYRLINKS::READ_TX_AGC_VALUE_HIGH_BYTE;
rawPacket = commandBuffer;
return RETURN_OK;
}
case(SYRLINKS::READ_TX_AGC_VALUE_LOW_BYTE): {
readTxAgcValueLowByte.copy(reinterpret_cast<char*>(commandBuffer), readTxStatus.size(), 0);
rawPacketLen = readTxAgcValueLowByte.size();
rememberCommandId = SYRLINKS::READ_TX_AGC_VALUE_LOW_BYTE;
rawPacket = commandBuffer;
return RETURN_OK;
}
default:
return DeviceHandlerIF::COMMAND_NOT_IMPLEMENTED;
}
return HasReturnvaluesIF::RETURN_FAILED;
case (SYRLINKS::SET_TX_MODE_STANDBY): {
setTxModeStandby.copy(reinterpret_cast<char*>(commandBuffer), setTxModeStandby.size(), 0);
rawPacketLen = setTxModeStandby.size();
rawPacket = commandBuffer;
return RETURN_OK;
}
case (SYRLINKS::SET_TX_MODE_MODULATION): {
setTxModeModulation.copy(reinterpret_cast<char*>(commandBuffer), setTxModeModulation.size(),
0);
rawPacketLen = setTxModeModulation.size();
rawPacket = commandBuffer;
return RETURN_OK;
}
case (SYRLINKS::SET_TX_MODE_CW): {
setTxModeCw.copy(reinterpret_cast<char*>(commandBuffer), setTxModeCw.size(), 0);
rawPacketLen = setTxModeCw.size();
rawPacket = commandBuffer;
return RETURN_OK;
}
case (SYRLINKS::READ_RX_STATUS_REGISTERS): {
readRxStatusRegCommand.copy(reinterpret_cast<char*>(commandBuffer),
readRxStatusRegCommand.size(), 0);
rawPacketLen = readRxStatusRegCommand.size();
rawPacket = commandBuffer;
return RETURN_OK;
}
case (SYRLINKS::READ_TX_STATUS): {
readTxStatus.copy(reinterpret_cast<char*>(commandBuffer), readTxStatus.size(), 0);
rawPacketLen = readTxStatus.size();
rememberCommandId = SYRLINKS::READ_TX_STATUS;
rawPacket = commandBuffer;
return RETURN_OK;
}
case (SYRLINKS::READ_TX_WAVEFORM): {
readTxWaveform.copy(reinterpret_cast<char*>(commandBuffer), readTxStatus.size(), 0);
rawPacketLen = readTxWaveform.size();
rememberCommandId = SYRLINKS::READ_TX_WAVEFORM;
rawPacket = commandBuffer;
return RETURN_OK;
}
case (SYRLINKS::READ_TX_AGC_VALUE_HIGH_BYTE): {
readTxAgcValueHighByte.copy(reinterpret_cast<char*>(commandBuffer), readTxStatus.size(), 0);
rawPacketLen = readTxAgcValueHighByte.size();
rememberCommandId = SYRLINKS::READ_TX_AGC_VALUE_HIGH_BYTE;
rawPacket = commandBuffer;
return RETURN_OK;
}
case (SYRLINKS::READ_TX_AGC_VALUE_LOW_BYTE): {
readTxAgcValueLowByte.copy(reinterpret_cast<char*>(commandBuffer), readTxStatus.size(), 0);
rawPacketLen = readTxAgcValueLowByte.size();
rememberCommandId = SYRLINKS::READ_TX_AGC_VALUE_LOW_BYTE;
rawPacket = commandBuffer;
return RETURN_OK;
}
default:
return DeviceHandlerIF::COMMAND_NOT_IMPLEMENTED;
}
return HasReturnvaluesIF::RETURN_FAILED;
}
void SyrlinksHkHandler::fillCommandAndReplyMap() {
this->insertInCommandAndReplyMap(SYRLINKS::RESET_UNIT, 1, nullptr, SYRLINKS::ACK_SIZE, false,
true, SYRLINKS::ACK_REPLY);
this->insertInCommandAndReplyMap(SYRLINKS::SET_TX_MODE_STANDBY, 1, nullptr, SYRLINKS::ACK_SIZE,
false, true, SYRLINKS::ACK_REPLY);
this->insertInCommandAndReplyMap(SYRLINKS::SET_TX_MODE_MODULATION, 1, nullptr,
SYRLINKS::ACK_SIZE, false, true, SYRLINKS::ACK_REPLY);
this->insertInCommandAndReplyMap(SYRLINKS::SET_TX_MODE_CW, 1, nullptr, SYRLINKS::ACK_SIZE,
false, true, SYRLINKS::ACK_REPLY);
this->insertInCommandAndReplyMap(SYRLINKS::READ_TX_STATUS, 1, &txDataset,
SYRLINKS::READ_ONE_REGISTER_REPLY_SIE);
this->insertInCommandAndReplyMap(SYRLINKS::READ_TX_WAVEFORM, 1, &txDataset,
SYRLINKS::READ_ONE_REGISTER_REPLY_SIE);
this->insertInCommandAndReplyMap(SYRLINKS::READ_TX_AGC_VALUE_HIGH_BYTE, 1, &txDataset,
SYRLINKS::READ_ONE_REGISTER_REPLY_SIE);
this->insertInCommandAndReplyMap(SYRLINKS::READ_TX_AGC_VALUE_LOW_BYTE, 1, &txDataset,
SYRLINKS::READ_ONE_REGISTER_REPLY_SIE);
this->insertInCommandAndReplyMap(SYRLINKS::READ_RX_STATUS_REGISTERS, 1, &rxDataset,
SYRLINKS::RX_STATUS_REGISTERS_REPLY_SIZE);
this->insertInCommandAndReplyMap(SYRLINKS::RESET_UNIT, 1, nullptr, SYRLINKS::ACK_SIZE, false,
true, SYRLINKS::ACK_REPLY);
this->insertInCommandAndReplyMap(SYRLINKS::SET_TX_MODE_STANDBY, 1, nullptr, SYRLINKS::ACK_SIZE,
false, true, SYRLINKS::ACK_REPLY);
this->insertInCommandAndReplyMap(SYRLINKS::SET_TX_MODE_MODULATION, 1, nullptr, SYRLINKS::ACK_SIZE,
false, true, SYRLINKS::ACK_REPLY);
this->insertInCommandAndReplyMap(SYRLINKS::SET_TX_MODE_CW, 1, nullptr, SYRLINKS::ACK_SIZE, false,
true, SYRLINKS::ACK_REPLY);
this->insertInCommandAndReplyMap(SYRLINKS::READ_TX_STATUS, 1, &txDataset,
SYRLINKS::READ_ONE_REGISTER_REPLY_SIE);
this->insertInCommandAndReplyMap(SYRLINKS::READ_TX_WAVEFORM, 1, &txDataset,
SYRLINKS::READ_ONE_REGISTER_REPLY_SIE);
this->insertInCommandAndReplyMap(SYRLINKS::READ_TX_AGC_VALUE_HIGH_BYTE, 1, &txDataset,
SYRLINKS::READ_ONE_REGISTER_REPLY_SIE);
this->insertInCommandAndReplyMap(SYRLINKS::READ_TX_AGC_VALUE_LOW_BYTE, 1, &txDataset,
SYRLINKS::READ_ONE_REGISTER_REPLY_SIE);
this->insertInCommandAndReplyMap(SYRLINKS::READ_RX_STATUS_REGISTERS, 1, &rxDataset,
SYRLINKS::RX_STATUS_REGISTERS_REPLY_SIZE);
}
ReturnValue_t SyrlinksHkHandler::scanForReply(const uint8_t *start,
size_t remainingSize, DeviceCommandId_t *foundId, size_t *foundLen) {
ReturnValue_t SyrlinksHkHandler::scanForReply(const uint8_t* start, size_t remainingSize,
DeviceCommandId_t* foundId, size_t* foundLen) {
ReturnValue_t result = RETURN_OK;
ReturnValue_t result = RETURN_OK;
if (*start != '<') {
sif::error << "SyrlinksHkHandler::scanForReply: Missing start frame character" << std::endl;
return MISSING_START_FRAME_CHARACTER;
}
if(*start != '<') {
sif::error << "SyrlinksHkHandler::scanForReply: Missing start frame character" << std::endl;
return MISSING_START_FRAME_CHARACTER;
}
switch (*(start + 1)) {
case ('A'):
*foundLen = SYRLINKS::ACK_SIZE;
*foundId = SYRLINKS::ACK_REPLY;
break;
case ('E'):
*foundLen = SYRLINKS::RX_STATUS_REGISTERS_REPLY_SIZE;
*foundId = SYRLINKS::READ_RX_STATUS_REGISTERS;
break;
case ('R'):
*foundId = rememberCommandId;
*foundLen = SYRLINKS::READ_ONE_REGISTER_REPLY_SIE;
break;
default:
sif::error << "SyrlinksHkHandler::scanForReply: Unknown reply identifier" << std::endl;
result = IGNORE_REPLY_DATA;
break;
}
switch(*(start + 1)) {
case('A'):
*foundLen = SYRLINKS::ACK_SIZE;
*foundId = SYRLINKS::ACK_REPLY;
break;
case('E'):
*foundLen = SYRLINKS::RX_STATUS_REGISTERS_REPLY_SIZE;
*foundId = SYRLINKS::READ_RX_STATUS_REGISTERS;
break;
case('R'):
*foundId = rememberCommandId;
*foundLen = SYRLINKS::READ_ONE_REGISTER_REPLY_SIE;
break;
default:
sif::error << "SyrlinksHkHandler::scanForReply: Unknown reply identifier" << std::endl;
result = IGNORE_REPLY_DATA;
break;
}
return result;
return result;
}
ReturnValue_t SyrlinksHkHandler::interpretDeviceReply(DeviceCommandId_t id,
const uint8_t *packet) {
ReturnValue_t SyrlinksHkHandler::interpretDeviceReply(DeviceCommandId_t id, const uint8_t* packet) {
ReturnValue_t result;
ReturnValue_t result;
switch (id) {
switch (id) {
case (SYRLINKS::ACK_REPLY):
result = verifyReply(packet, SYRLINKS::ACK_SIZE);
if (result != RETURN_OK) {
sif::error << "SyrlinksHkHandler::interpretDeviceReply: Acknowledgement reply has "
"invalid crc" << std::endl;
return CRC_FAILURE;
}
result = parseReplyStatus(reinterpret_cast<const char*>(packet + SYRLINKS::MESSAGE_HEADER_SIZE));
if (result != RETURN_OK) {
return result;
}
break;
case(SYRLINKS::READ_RX_STATUS_REGISTERS):
result = verifyReply(packet, SYRLINKS::RX_STATUS_REGISTERS_REPLY_SIZE);
if (result != RETURN_OK) {
sif::error << "SyrlinksHkHandler::interpretDeviceReply: Read rx status registers reply "
<< "has invalid crc" << std::endl;
return CRC_FAILURE;
}
parseRxStatusRegistersReply(packet);
break;
case(SYRLINKS::READ_TX_STATUS):
result = verifyReply(packet, SYRLINKS::READ_ONE_REGISTER_REPLY_SIE);
if (result != RETURN_OK) {
sif::error << "SyrlinksHkHandler::interpretDeviceReply: Read tx status reply "
<< "has invalid crc" << std::endl;
return CRC_FAILURE;
}
parseTxStatusReply(packet);
break;
case(SYRLINKS::READ_TX_WAVEFORM):
result = verifyReply(packet, SYRLINKS::READ_ONE_REGISTER_REPLY_SIE);
if (result != RETURN_OK) {
sif::error << "SyrlinksHkHandler::interpretDeviceReply: Read tx waveform reply "
<< "has invalid crc" << std::endl;
return CRC_FAILURE;
}
parseTxWaveformReply(packet);
break;
case(SYRLINKS::READ_TX_AGC_VALUE_HIGH_BYTE):
result = verifyReply(packet, SYRLINKS::READ_ONE_REGISTER_REPLY_SIE);
if (result != RETURN_OK) {
sif::error << "SyrlinksHkHandler::interpretDeviceReply: Read tx AGC high byte reply "
<< "has invalid crc" << std::endl;
return CRC_FAILURE;
}
parseAgcHighByte(packet);
break;
case(SYRLINKS::READ_TX_AGC_VALUE_LOW_BYTE):
result = verifyReply(packet, SYRLINKS::READ_ONE_REGISTER_REPLY_SIE);
if (result != RETURN_OK) {
sif::error << "SyrlinksHkHandler::interpretDeviceReply: Read tx AGC low byte reply "
<< "has invalid crc" << std::endl;
return CRC_FAILURE;
}
parseAgcLowByte(packet);
break;
default: {
sif::debug << "SyrlinksHkHandler::interpretDeviceReply: Unknown device reply id"
<< std::endl;
return DeviceHandlerIF::UNKNOWN_DEVICE_REPLY;
}
}
result = verifyReply(packet, SYRLINKS::ACK_SIZE);
if (result != RETURN_OK) {
sif::error << "SyrlinksHkHandler::interpretDeviceReply: Acknowledgement reply has "
"invalid crc"
<< std::endl;
return CRC_FAILURE;
}
result =
parseReplyStatus(reinterpret_cast<const char*>(packet + SYRLINKS::MESSAGE_HEADER_SIZE));
if (result != RETURN_OK) {
return result;
}
break;
case (SYRLINKS::READ_RX_STATUS_REGISTERS):
result = verifyReply(packet, SYRLINKS::RX_STATUS_REGISTERS_REPLY_SIZE);
if (result != RETURN_OK) {
sif::error << "SyrlinksHkHandler::interpretDeviceReply: Read rx status registers reply "
<< "has invalid crc" << std::endl;
return CRC_FAILURE;
}
parseRxStatusRegistersReply(packet);
break;
case (SYRLINKS::READ_TX_STATUS):
result = verifyReply(packet, SYRLINKS::READ_ONE_REGISTER_REPLY_SIE);
if (result != RETURN_OK) {
sif::error << "SyrlinksHkHandler::interpretDeviceReply: Read tx status reply "
<< "has invalid crc" << std::endl;
return CRC_FAILURE;
}
parseTxStatusReply(packet);
break;
case (SYRLINKS::READ_TX_WAVEFORM):
result = verifyReply(packet, SYRLINKS::READ_ONE_REGISTER_REPLY_SIE);
if (result != RETURN_OK) {
sif::error << "SyrlinksHkHandler::interpretDeviceReply: Read tx waveform reply "
<< "has invalid crc" << std::endl;
return CRC_FAILURE;
}
parseTxWaveformReply(packet);
break;
case (SYRLINKS::READ_TX_AGC_VALUE_HIGH_BYTE):
result = verifyReply(packet, SYRLINKS::READ_ONE_REGISTER_REPLY_SIE);
if (result != RETURN_OK) {
sif::error << "SyrlinksHkHandler::interpretDeviceReply: Read tx AGC high byte reply "
<< "has invalid crc" << std::endl;
return CRC_FAILURE;
}
parseAgcHighByte(packet);
break;
case (SYRLINKS::READ_TX_AGC_VALUE_LOW_BYTE):
result = verifyReply(packet, SYRLINKS::READ_ONE_REGISTER_REPLY_SIE);
if (result != RETURN_OK) {
sif::error << "SyrlinksHkHandler::interpretDeviceReply: Read tx AGC low byte reply "
<< "has invalid crc" << std::endl;
return CRC_FAILURE;
}
parseAgcLowByte(packet);
break;
default: {
sif::debug << "SyrlinksHkHandler::interpretDeviceReply: Unknown device reply id" << std::endl;
return DeviceHandlerIF::UNKNOWN_DEVICE_REPLY;
}
}
return RETURN_OK;
return RETURN_OK;
}
LocalPoolDataSetBase* SyrlinksHkHandler::getDataSetHandle(sid_t sid) {
if (sid == rxDataset.getSid()) {
return &rxDataset;
}
else if (sid== txDataset.getSid()) {
return &txDataset;
}
else {
sif::error << "SyrlinksHkHandler::getDataSetHandle: Invalid sid" << std::endl;
return nullptr;
}
if (sid == rxDataset.getSid()) {
return &rxDataset;
} else if (sid == txDataset.getSid()) {
return &txDataset;
} else {
sif::error << "SyrlinksHkHandler::getDataSetHandle: Invalid sid" << std::endl;
return nullptr;
}
}
std::string SyrlinksHkHandler::convertUint16ToHexString(uint16_t intValue) {
std::stringstream stream;
stream << std::setfill('0') << std::setw(4) << std::hex << std::uppercase << intValue;
return stream.str();
std::stringstream stream;
stream << std::setfill('0') << std::setw(4) << std::hex << std::uppercase << intValue;
return stream.str();
}
uint8_t SyrlinksHkHandler::convertHexStringToUint8(const char* twoChars) {
uint32_t value;
std::string hexString(twoChars, 2);
std::stringstream stream;
stream << std::hex << hexString;
stream >> value;
return static_cast<uint8_t>(value);
uint32_t value;
std::string hexString(twoChars, 2);
std::stringstream stream;
stream << std::hex << hexString;
stream >> value;
return static_cast<uint8_t>(value);
}
uint16_t SyrlinksHkHandler::convertHexStringToUint16(const char* fourChars) {
uint16_t value = 0;
value = convertHexStringToUint8(fourChars) << 8 | convertHexStringToUint8(fourChars+2);
return value;
uint16_t value = 0;
value = convertHexStringToUint8(fourChars) << 8 | convertHexStringToUint8(fourChars + 2);
return value;
}
uint32_t SyrlinksHkHandler::convertHexStringToUint32(const char* characters, uint8_t numberOfChars) {
uint32_t SyrlinksHkHandler::convertHexStringToUint32(const char* characters,
uint8_t numberOfChars) {
uint32_t value = 0;
uint32_t value = 0;
switch (numberOfChars) {
switch (numberOfChars) {
case 6:
value = convertHexStringToUint8(characters) << 16
| convertHexStringToUint8(characters + 2) << 8
| convertHexStringToUint8(characters + 4);
return value;
value = convertHexStringToUint8(characters) << 16 |
convertHexStringToUint8(characters + 2) << 8 |
convertHexStringToUint8(characters + 4);
return value;
case 8:
value = convertHexStringToUint8(characters) << 24
| convertHexStringToUint8(characters + 2) << 16
| convertHexStringToUint8(characters + 4) << 8
| convertHexStringToUint8(characters + 4);
return value;
value = convertHexStringToUint8(characters) << 24 |
convertHexStringToUint8(characters + 2) << 16 |
convertHexStringToUint8(characters + 4) << 8 |
convertHexStringToUint8(characters + 4);
return value;
default:
sif::debug << "SyrlinksHkHandler::convertHexStringToUint32: Invalid number of characters. "
<< "Must be either 6 or 8" << std::endl;
return 0;
}
sif::debug << "SyrlinksHkHandler::convertHexStringToUint32: Invalid number of characters. "
<< "Must be either 6 or 8" << std::endl;
return 0;
}
}
ReturnValue_t SyrlinksHkHandler::parseReplyStatus(const char* status) {
switch (*status) {
switch (*status) {
case '0':
return RETURN_OK;
return RETURN_OK;
case '1':
sif::debug << "SyrlinksHkHandler::parseReplyStatus: Uart faming or parity error"
<< std::endl;
return UART_FRAMIN_OR_PARITY_ERROR_ACK;
sif::debug << "SyrlinksHkHandler::parseReplyStatus: Uart faming or parity error" << std::endl;
return UART_FRAMIN_OR_PARITY_ERROR_ACK;
case '2':
sif::debug << "SyrlinksHkHandler::parseReplyStatus: Bad character detected" << std::endl;
return BAD_CHARACTER_ACK;
sif::debug << "SyrlinksHkHandler::parseReplyStatus: Bad character detected" << std::endl;
return BAD_CHARACTER_ACK;
case '3':
sif::debug << "SyrlinksHkHandler::parseReplyStatus: Bad parameter value (unexpected value "
<< "detected" << std::endl;
return BAD_PARAMETER_VALUE_ACK;
sif::debug << "SyrlinksHkHandler::parseReplyStatus: Bad parameter value (unexpected value "
<< "detected" << std::endl;
return BAD_PARAMETER_VALUE_ACK;
case '4':
sif::debug << "SyrlinksHkHandler::parseReplyStatus: Bad end of frame" << std::endl;
return BAD_END_OF_FRAME_ACK;
sif::debug << "SyrlinksHkHandler::parseReplyStatus: Bad end of frame" << std::endl;
return BAD_END_OF_FRAME_ACK;
case '5':
sif::debug << "SyrlinksHkHandler::parseReplyStatus: Unknown command id or attempt to access"
<< " a protected register" << std::endl;
return UNKNOWN_COMMAND_ID_ACK;
sif::debug << "SyrlinksHkHandler::parseReplyStatus: Unknown command id or attempt to access"
<< " a protected register" << std::endl;
return UNKNOWN_COMMAND_ID_ACK;
case '6':
sif::debug << "SyrlinksHkHandler::parseReplyStatus: Bad CRC" << std::endl;
return BAD_CRC_ACK;
sif::debug << "SyrlinksHkHandler::parseReplyStatus: Bad CRC" << std::endl;
return BAD_CRC_ACK;
default:
sif::debug << "SyrlinksHkHandler::parseReplyStatus: Status reply contains an invalid "
<< "status id" << std::endl;
return RETURN_FAILED;
}
sif::debug << "SyrlinksHkHandler::parseReplyStatus: Status reply contains an invalid "
<< "status id" << std::endl;
return RETURN_FAILED;
}
}
ReturnValue_t SyrlinksHkHandler::verifyReply(const uint8_t* packet, uint8_t size) {
int result = 0;
/* Calculate crc from received packet */
uint16_t crc = CRC::crc16ccitt(packet, size - SYRLINKS::SIZE_CRC_AND_TERMINATION,
CRC_INITIAL_VALUE);
std::string recalculatedCrc = convertUint16ToHexString(crc);
int result = 0;
/* Calculate crc from received packet */
uint16_t crc =
CRC::crc16ccitt(packet, size - SYRLINKS::SIZE_CRC_AND_TERMINATION, CRC_INITIAL_VALUE);
std::string recalculatedCrc = convertUint16ToHexString(crc);
const char* startOfCrc = reinterpret_cast<const char*>(packet + size - SYRLINKS::SIZE_CRC_AND_TERMINATION);
const char* endOfCrc = reinterpret_cast<const char*>(packet + size - 1);
const char* startOfCrc =
reinterpret_cast<const char*>(packet + size - SYRLINKS::SIZE_CRC_AND_TERMINATION);
const char* endOfCrc = reinterpret_cast<const char*>(packet + size - 1);
std::string replyCrc(startOfCrc, endOfCrc);
std::string replyCrc(startOfCrc, endOfCrc);
result = recalculatedCrc.compare(replyCrc);
if (result != 0) {
return RETURN_FAILED;
}
return RETURN_OK;
result = recalculatedCrc.compare(replyCrc);
if (result != 0) {
return RETURN_FAILED;
}
return RETURN_OK;
}
void SyrlinksHkHandler::parseRxStatusRegistersReply(const uint8_t* packet) {
PoolReadGuard readHelper(&rxDataset);
uint16_t offset = SYRLINKS::MESSAGE_HEADER_SIZE;
rxDataset.rxStatus = convertHexStringToUint8(reinterpret_cast<const char*>(packet + offset));
offset += 2;
rxDataset.rxSensitivity = convertHexStringToUint32(reinterpret_cast<const char*>(packet + offset), 6);
offset += 6;
rxDataset.rxFrequencyShift = convertHexStringToUint32(reinterpret_cast<const char*>(packet + offset), 6);
offset += 6;
rxDataset.rxIqPower = convertHexStringToUint16(reinterpret_cast<const char*>(packet + offset));
offset += 4;
rxDataset.rxAgcValue = convertHexStringToUint16(reinterpret_cast<const char*>(packet + offset));
offset += 4;
offset += 2; // reserved register
rxDataset.rxDemodEb= convertHexStringToUint32(reinterpret_cast<const char*>(packet + offset), 6);
offset += 6;
rxDataset.rxDemodN0= convertHexStringToUint32(reinterpret_cast<const char*>(packet + offset), 6);
offset += 6;
rxDataset.rxDataRate = convertHexStringToUint8(reinterpret_cast<const char*>(packet + offset));
PoolReadGuard readHelper(&rxDataset);
uint16_t offset = SYRLINKS::MESSAGE_HEADER_SIZE;
rxDataset.rxStatus = convertHexStringToUint8(reinterpret_cast<const char*>(packet + offset));
offset += 2;
rxDataset.rxSensitivity =
convertHexStringToUint32(reinterpret_cast<const char*>(packet + offset), 6);
offset += 6;
rxDataset.rxFrequencyShift =
convertHexStringToUint32(reinterpret_cast<const char*>(packet + offset), 6);
offset += 6;
rxDataset.rxIqPower = convertHexStringToUint16(reinterpret_cast<const char*>(packet + offset));
offset += 4;
rxDataset.rxAgcValue = convertHexStringToUint16(reinterpret_cast<const char*>(packet + offset));
offset += 4;
offset += 2; // reserved register
rxDataset.rxDemodEb = convertHexStringToUint32(reinterpret_cast<const char*>(packet + offset), 6);
offset += 6;
rxDataset.rxDemodN0 = convertHexStringToUint32(reinterpret_cast<const char*>(packet + offset), 6);
offset += 6;
rxDataset.rxDataRate = convertHexStringToUint8(reinterpret_cast<const char*>(packet + offset));
#if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_SYRLINKS == 1
sif::info << "Syrlinks RX Status: 0x" << std::hex << (unsigned int)rxDataset.rxStatus.value << std::endl;
sif::info << "Syrlinks RX Sensitivity: " << std::dec << rxDataset.rxSensitivity << std::endl;
sif::info << "Syrlinks RX Frequency Shift: " << rxDataset.rxFrequencyShift << std::endl;
sif::info << "Syrlinks RX IQ Power: " << rxDataset.rxIqPower << std::endl;
sif::info << "Syrlinks RX AGC Value: " << rxDataset.rxAgcValue << std::endl;
sif::info << "Syrlinks RX Demod Eb: " << rxDataset.rxDemodEb << std::endl;
sif::info << "Syrlinks RX Demod N0: " << rxDataset.rxDemodN0 << std::endl;
sif::info << "Syrlinks RX Datarate: " << (unsigned int)rxDataset.rxDataRate.value << std::endl;
sif::info << "Syrlinks RX Status: 0x" << std::hex << (unsigned int)rxDataset.rxStatus.value
<< std::endl;
sif::info << "Syrlinks RX Sensitivity: " << std::dec << rxDataset.rxSensitivity << std::endl;
sif::info << "Syrlinks RX Frequency Shift: " << rxDataset.rxFrequencyShift << std::endl;
sif::info << "Syrlinks RX IQ Power: " << rxDataset.rxIqPower << std::endl;
sif::info << "Syrlinks RX AGC Value: " << rxDataset.rxAgcValue << std::endl;
sif::info << "Syrlinks RX Demod Eb: " << rxDataset.rxDemodEb << std::endl;
sif::info << "Syrlinks RX Demod N0: " << rxDataset.rxDemodN0 << std::endl;
sif::info << "Syrlinks RX Datarate: " << (unsigned int)rxDataset.rxDataRate.value << std::endl;
#endif
}
void SyrlinksHkHandler::parseTxStatusReply(const uint8_t* packet) {
PoolReadGuard readHelper(&txDataset);
uint16_t offset = SYRLINKS::MESSAGE_HEADER_SIZE;
txDataset.txStatus = convertHexStringToUint8(reinterpret_cast<const char*>(packet + offset));
PoolReadGuard readHelper(&txDataset);
uint16_t offset = SYRLINKS::MESSAGE_HEADER_SIZE;
txDataset.txStatus = convertHexStringToUint8(reinterpret_cast<const char*>(packet + offset));
#if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_SYRLINKS == 1
sif::info << "Syrlinks TX Status: 0x" << std::hex << (unsigned int) txDataset.txStatus.value
sif::info << "Syrlinks TX Status: 0x" << std::hex << (unsigned int)txDataset.txStatus.value
<< std::endl;
#endif
}
void SyrlinksHkHandler::parseTxWaveformReply(const uint8_t* packet) {
PoolReadGuard readHelper(&txDataset);
uint16_t offset = SYRLINKS::MESSAGE_HEADER_SIZE;
txDataset.txWaveform = convertHexStringToUint8(reinterpret_cast<const char*>(packet + offset));
PoolReadGuard readHelper(&txDataset);
uint16_t offset = SYRLINKS::MESSAGE_HEADER_SIZE;
txDataset.txWaveform = convertHexStringToUint8(reinterpret_cast<const char*>(packet + offset));
#if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_SYRLINKS == 1
sif::info << "Syrlinks TX Waveform: 0x" << std::hex << (unsigned int) txDataset.txWaveform.value
sif::info << "Syrlinks TX Waveform: 0x" << std::hex << (unsigned int)txDataset.txWaveform.value
<< std::endl;
#endif
}
void SyrlinksHkHandler::parseAgcLowByte(const uint8_t* packet) {
PoolReadGuard readHelper(&txDataset);
uint16_t offset = SYRLINKS::MESSAGE_HEADER_SIZE;
txDataset.txAgcValue = agcValueHighByte << 8 | convertHexStringToUint8(reinterpret_cast<const char*>(packet + offset));
PoolReadGuard readHelper(&txDataset);
uint16_t offset = SYRLINKS::MESSAGE_HEADER_SIZE;
txDataset.txAgcValue = agcValueHighByte << 8 |
convertHexStringToUint8(reinterpret_cast<const char*>(packet + offset));
#if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_SYRLINKS == 1
sif::info << "Syrlinks TX AGC Value: " << txDataset.txAgcValue << std::endl;
sif::info << "Syrlinks TX AGC Value: " << txDataset.txAgcValue << std::endl;
#endif
}
void SyrlinksHkHandler::parseAgcHighByte(const uint8_t* packet) {
PoolReadGuard readHelper(&txDataset);
uint16_t offset = SYRLINKS::MESSAGE_HEADER_SIZE;
agcValueHighByte = convertHexStringToUint8(reinterpret_cast<const char*>(packet + offset));
PoolReadGuard readHelper(&txDataset);
uint16_t offset = SYRLINKS::MESSAGE_HEADER_SIZE;
agcValueHighByte = convertHexStringToUint8(reinterpret_cast<const char*>(packet + offset));
}
void SyrlinksHkHandler::setNormalDatapoolEntriesInvalid(){
void SyrlinksHkHandler::setNormalDatapoolEntriesInvalid() {}
}
uint32_t SyrlinksHkHandler::getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo){
return 500;
}
uint32_t SyrlinksHkHandler::getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) { return 500; }
ReturnValue_t SyrlinksHkHandler::initializeLocalDataPool(localpool::DataPool& localDataPoolMap,
LocalDataPoolManager& poolManager) {
LocalDataPoolManager& poolManager) {
localDataPoolMap.emplace(SYRLINKS::RX_STATUS, new PoolEntry<uint8_t>({0}));
localDataPoolMap.emplace(SYRLINKS::RX_SENSITIVITY, new PoolEntry<uint32_t>({0}));
localDataPoolMap.emplace(SYRLINKS::RX_FREQUENCY_SHIFT, new PoolEntry<uint32_t>({0}));
localDataPoolMap.emplace(SYRLINKS::RX_IQ_POWER, new PoolEntry<uint16_t>({0}));
localDataPoolMap.emplace(SYRLINKS::RX_AGC_VALUE, new PoolEntry<uint16_t>({0}));
localDataPoolMap.emplace(SYRLINKS::RX_DEMOD_EB, new PoolEntry<uint32_t>({0}));
localDataPoolMap.emplace(SYRLINKS::RX_DEMOD_N0, new PoolEntry<uint32_t>({0}));
localDataPoolMap.emplace(SYRLINKS::RX_DATA_RATE, new PoolEntry<uint8_t>({0}));
localDataPoolMap.emplace(SYRLINKS::RX_STATUS, new PoolEntry<uint8_t>( { 0 }));
localDataPoolMap.emplace(SYRLINKS::RX_SENSITIVITY, new PoolEntry<uint32_t>( { 0 }));
localDataPoolMap.emplace(SYRLINKS::RX_FREQUENCY_SHIFT, new PoolEntry<uint32_t>( { 0 }));
localDataPoolMap.emplace(SYRLINKS::RX_IQ_POWER, new PoolEntry<uint16_t>( { 0 }));
localDataPoolMap.emplace(SYRLINKS::RX_AGC_VALUE, new PoolEntry<uint16_t>( { 0 }));
localDataPoolMap.emplace(SYRLINKS::RX_DEMOD_EB, new PoolEntry<uint32_t>( { 0 }));
localDataPoolMap.emplace(SYRLINKS::RX_DEMOD_N0, new PoolEntry<uint32_t>( { 0 }));
localDataPoolMap.emplace(SYRLINKS::RX_DATA_RATE, new PoolEntry<uint8_t>( { 0 }));
localDataPoolMap.emplace(SYRLINKS::TX_STATUS, new PoolEntry<uint8_t>({0}));
localDataPoolMap.emplace(SYRLINKS::TX_WAVEFORM, new PoolEntry<uint8_t>({0}));
localDataPoolMap.emplace(SYRLINKS::TX_AGC_VALUE, new PoolEntry<uint16_t>({0}));
localDataPoolMap.emplace(SYRLINKS::TX_STATUS, new PoolEntry<uint8_t>( { 0 }));
localDataPoolMap.emplace(SYRLINKS::TX_WAVEFORM, new PoolEntry<uint8_t>( { 0 }));
localDataPoolMap.emplace(SYRLINKS::TX_AGC_VALUE, new PoolEntry<uint16_t>( { 0 }));
return HasReturnvaluesIF::RETURN_OK;
}
void SyrlinksHkHandler::setModeNormal() {
mode = MODE_NORMAL;
return HasReturnvaluesIF::RETURN_OK;
}
void SyrlinksHkHandler::setModeNormal() { mode = MODE_NORMAL; }

View File

@ -13,166 +13,162 @@
*
* @author J. Meier
*/
class SyrlinksHkHandler: public DeviceHandlerBase {
public:
class SyrlinksHkHandler : public DeviceHandlerBase {
public:
SyrlinksHkHandler(object_id_t objectId, object_id_t comIF, CookieIF* comCookie);
virtual ~SyrlinksHkHandler();
SyrlinksHkHandler(object_id_t objectId, object_id_t comIF,
CookieIF * comCookie);
virtual ~SyrlinksHkHandler();
/**
* @brief Sets mode to MODE_NORMAL. Can be used for debugging.
*/
void setModeNormal();
/**
* @brief Sets mode to MODE_NORMAL. Can be used for debugging.
*/
void setModeNormal();
protected:
void doStartUp() override;
void doShutDown() override;
ReturnValue_t buildNormalDeviceCommand(DeviceCommandId_t* id) override;
ReturnValue_t buildTransitionDeviceCommand(DeviceCommandId_t* id) override;
void fillCommandAndReplyMap() override;
ReturnValue_t buildCommandFromCommand(DeviceCommandId_t deviceCommand, const uint8_t* commandData,
size_t commandDataLen) override;
ReturnValue_t scanForReply(const uint8_t* start, size_t remainingSize, DeviceCommandId_t* foundId,
size_t* foundLen) override;
ReturnValue_t interpretDeviceReply(DeviceCommandId_t id, const uint8_t* packet) override;
void setNormalDatapoolEntriesInvalid() override;
uint32_t getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) override;
ReturnValue_t initializeLocalDataPool(localpool::DataPool& localDataPoolMap,
LocalDataPoolManager& poolManager) override;
LocalPoolDataSetBase* getDataSetHandle(sid_t sid) override;
protected:
void doStartUp() override;
void doShutDown() override;
ReturnValue_t buildNormalDeviceCommand(DeviceCommandId_t * id) override;
ReturnValue_t buildTransitionDeviceCommand(DeviceCommandId_t * id) override;
void fillCommandAndReplyMap() override;
ReturnValue_t buildCommandFromCommand(DeviceCommandId_t deviceCommand,
const uint8_t * commandData,size_t commandDataLen) override;
ReturnValue_t scanForReply(const uint8_t *start, size_t remainingSize,
DeviceCommandId_t *foundId, size_t *foundLen) override;
ReturnValue_t interpretDeviceReply(DeviceCommandId_t id,
const uint8_t *packet) override;
void setNormalDatapoolEntriesInvalid() override;
uint32_t getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) override;
ReturnValue_t initializeLocalDataPool(localpool::DataPool& localDataPoolMap,
LocalDataPoolManager& poolManager) override;
LocalPoolDataSetBase* getDataSetHandle(sid_t sid) override;
private:
static const uint8_t INTERFACE_ID = CLASS_ID::SYRLINKS_HANDLER;
private:
static const ReturnValue_t CRC_FAILURE = MAKE_RETURN_CODE(0xA0);
static const ReturnValue_t UART_FRAMIN_OR_PARITY_ERROR_ACK = MAKE_RETURN_CODE(0xA1);
static const ReturnValue_t BAD_CHARACTER_ACK = MAKE_RETURN_CODE(0xA2);
static const ReturnValue_t BAD_PARAMETER_VALUE_ACK = MAKE_RETURN_CODE(0xA3);
static const ReturnValue_t BAD_END_OF_FRAME_ACK = MAKE_RETURN_CODE(0xA4);
static const ReturnValue_t UNKNOWN_COMMAND_ID_ACK = MAKE_RETURN_CODE(0xA5);
static const ReturnValue_t BAD_CRC_ACK = MAKE_RETURN_CODE(0xA6);
static const ReturnValue_t REPLY_WRONG_SIZE = MAKE_RETURN_CODE(0xA7);
static const ReturnValue_t MISSING_START_FRAME_CHARACTER = MAKE_RETURN_CODE(0xA8);
static const uint8_t INTERFACE_ID = CLASS_ID::SYRLINKS_HANDLER;
static const uint8_t CRC_INITIAL_VALUE = 0x0;
static const ReturnValue_t CRC_FAILURE = MAKE_RETURN_CODE(0xA0);
static const ReturnValue_t UART_FRAMIN_OR_PARITY_ERROR_ACK = MAKE_RETURN_CODE(0xA1);
static const ReturnValue_t BAD_CHARACTER_ACK = MAKE_RETURN_CODE(0xA2);
static const ReturnValue_t BAD_PARAMETER_VALUE_ACK = MAKE_RETURN_CODE(0xA3);
static const ReturnValue_t BAD_END_OF_FRAME_ACK = MAKE_RETURN_CODE(0xA4);
static const ReturnValue_t UNKNOWN_COMMAND_ID_ACK = MAKE_RETURN_CODE(0xA5);
static const ReturnValue_t BAD_CRC_ACK = MAKE_RETURN_CODE(0xA6);
static const ReturnValue_t REPLY_WRONG_SIZE = MAKE_RETURN_CODE(0xA7);
static const ReturnValue_t MISSING_START_FRAME_CHARACTER = MAKE_RETURN_CODE(0xA8);
std::string resetCommand = "<C04:5A5A:FF41>";
std::string readRxStatusRegCommand = "<E00::825B>";
std::string setTxModeStandby = "<W04:4000:7E58>";
/** W - write, 04 - 4 bytes in data field, 01 - value, 40 register to write value */
std::string setTxModeModulation = "<W04:4001:4D69>";
std::string setTxModeCw = "<W04:4010:4968>";
std::string readTxStatus = "<R02:40:7555>";
std::string readTxWaveform = "<R02:44:B991>";
std::string readTxAgcValueHighByte = "<R02:46:DFF3>";
std::string readTxAgcValueLowByte = "<R02:47:ECC2>";
static const uint8_t CRC_INITIAL_VALUE = 0x0;
/**
* In some cases it is not possible to extract from the received reply the information about
* the associated command. This variable is thus used to remember the command id.
*/
DeviceCommandId_t rememberCommandId = SYRLINKS::NONE;
std::string resetCommand = "<C04:5A5A:FF41>";
std::string readRxStatusRegCommand = "<E00::825B>";
std::string setTxModeStandby = "<W04:4000:7E58>";
/** W - write, 04 - 4 bytes in data field, 01 - value, 40 register to write value */
std::string setTxModeModulation = "<W04:4001:4D69>";
std::string setTxModeCw = "<W04:4010:4968>";
std::string readTxStatus = "<R02:40:7555>";
std::string readTxWaveform = "<R02:44:B991>";
std::string readTxAgcValueHighByte = "<R02:46:DFF3>";
std::string readTxAgcValueLowByte = "<R02:47:ECC2>";
SYRLINKS::RxDataset rxDataset;
SYRLINKS::TxDataset txDataset;
/**
* In some cases it is not possible to extract from the received reply the information about
* the associated command. This variable is thus used to remember the command id.
*/
DeviceCommandId_t rememberCommandId = SYRLINKS::NONE;
uint8_t agcValueHighByte;
SYRLINKS::RxDataset rxDataset;
SYRLINKS::TxDataset txDataset;
uint8_t commandBuffer[SYRLINKS::MAX_COMMAND_SIZE];
uint8_t agcValueHighByte;
/**
* This object is used to store the id of the next command to execute. This controls the
* read out of multiple registers which can not be fetched with one single command.
*/
DeviceCommandId_t nextCommand = SYRLINKS::READ_RX_STATUS_REGISTERS;
uint8_t commandBuffer[SYRLINKS::MAX_COMMAND_SIZE];
/**
* @brief This function converts an uint16_t into its hexadecimal string representation.
*
* @param intValue The value to convert.
*
* @return An std::string object containing the hex representation of intValue.
*/
std::string convertUint16ToHexString(uint16_t intValue);
/**
* This object is used to store the id of the next command to execute. This controls the
* read out of multiple registers which can not be fetched with one single command.
*/
DeviceCommandId_t nextCommand = SYRLINKS::READ_RX_STATUS_REGISTERS;
/**
* @brief This function converts a hex number represented by to chars to an 8-bit integer.
*
* @param twoChars Pointer to the two characters representing the hex value.
*
* @details E.g. when twoChars points to an array with the two characters "A5" then the function
* will return 0xA5.
* @return The converted integer.
*/
uint8_t convertHexStringToUint8(const char* twoChars);
/**
* @brief This function converts an uint16_t into its hexadecimal string representation.
*
* @param intValue The value to convert.
*
* @return An std::string object containing the hex representation of intValue.
*/
std::string convertUint16ToHexString(uint16_t intValue);
/**
* @brief This function converts a hex number represented by 4 chars to an uint16_t.
*
* @param Pointer to the fourCharacters representing the 16-bit integer.
*
* @return The uint16_t result.
*/
uint16_t convertHexStringToUint16(const char* fourChars);
/**
* @brief This function converts a hex number represented by to chars to an 8-bit integer.
*
* @param twoChars Pointer to the two characters representing the hex value.
*
* @details E.g. when twoChars points to an array with the two characters "A5" then the function
* will return 0xA5.
* @return The converted integer.
*/
uint8_t convertHexStringToUint8(const char* twoChars);
/**
* @brief Function converts a hex number represented by 6 or 8 characters to an uint32_t.
*
* @param characters Pointer to the hex characters array.
* @param numberOfChars Number of characters representing the hex value. Must be 6 or 8.
*
* @return The uint32_t value.
*/
uint32_t convertHexStringToUint32(const char* characters, uint8_t numberOfChars);
/**
* @brief This function converts a hex number represented by 4 chars to an uint16_t.
*
* @param Pointer to the fourCharacters representing the 16-bit integer.
*
* @return The uint16_t result.
*/
uint16_t convertHexStringToUint16(const char* fourChars);
/**
* @brief This function parses the status reply
* @param status Pointer to the status information.
*
* @details Some commands reply with a status message giving information about the preceding
* command transmission and/or execution was successful.
*/
ReturnValue_t parseReplyStatus(const char* status);
/**
* @brief Function converts a hex number represented by 6 or 8 characters to an uint32_t.
*
* @param characters Pointer to the hex characters array.
* @param numberOfChars Number of characters representing the hex value. Must be 6 or 8.
*
* @return The uint32_t value.
*/
uint32_t convertHexStringToUint32(const char* characters, uint8_t numberOfChars);
/**
* @brief Function verifies the received reply from the syrlinks by recalculating and
* comparing the crc.
*
* @param packet Pointer to the received reply.
* @param size Size of the whole packet including the crc and the packet termination
* character '>'.
*
* @return RETURN_OK if successful, otherwise RETURN_FAILED.
*/
ReturnValue_t verifyReply(const uint8_t* packet, uint8_t size);
/**
* @brief This function parses the status reply
* @param status Pointer to the status information.
*
* @details Some commands reply with a status message giving information about the preceding
* command transmission and/or execution was successful.
*/
ReturnValue_t parseReplyStatus(const char* status);
/**
* @brief This function extracts the data from a rx status registers reply and writes the
* information to the status registers dataset.
* @param packet Pointer to the reply packet.
*/
void parseRxStatusRegistersReply(const uint8_t* packet);
/**
* @brief Function verifies the received reply from the syrlinks by recalculating and
* comparing the crc.
*
* @param packet Pointer to the received reply.
* @param size Size of the whole packet including the crc and the packet termination
* character '>'.
*
* @return RETURN_OK if successful, otherwise RETURN_FAILED.
*/
ReturnValue_t verifyReply(const uint8_t* packet, uint8_t size);
/**
* @brief This function writes the read tx status register to the txStatusDataset.
* @param packet Pointer to the received packet.
*/
void parseTxStatusReply(const uint8_t* packet);
/**
* @brief This function extracts the data from a rx status registers reply and writes the
* information to the status registers dataset.
* @param packet Pointer to the reply packet.
*/
void parseRxStatusRegistersReply(const uint8_t* packet);
/**
* @brief This function writes the received waveform configuration to the txDataset.
*/
void parseTxWaveformReply(const uint8_t* packet);
/**
* @brief This function writes the read tx status register to the txStatusDataset.
* @param packet Pointer to the received packet.
*/
void parseTxStatusReply(const uint8_t* packet);
/**
* @brief This function writes the received waveform configuration to the txDataset.
*/
void parseTxWaveformReply(const uint8_t* packet);
/**
* @brief The agc value is split over two registers. The parse agc functions are used to get
* the values from the received reply and write them into the txDataset.
*/
void parseAgcLowByte(const uint8_t* packet);
void parseAgcHighByte(const uint8_t* packet);
/**
* @brief The agc value is split over two registers. The parse agc functions are used to get
* the values from the received reply and write them into the txDataset.
*/
void parseAgcLowByte(const uint8_t* packet);
void parseAgcHighByte(const uint8_t* packet);
};
#endif /* MISSION_DEVICES_SYRLINKSHKHANDLER_H_ */

View File

@ -1,145 +1,124 @@
#include <OBSWConfig.h>
#include <mission/devices/Tmp1075Handler.h>
#include <mission/devices/devicedefinitions/Tmp1075Definitions.h>
#include <OBSWConfig.h>
Tmp1075Handler::Tmp1075Handler(object_id_t objectId, object_id_t comIF,
CookieIF * comCookie) :
DeviceHandlerBase(objectId, comIF, comCookie), dataset(
this) {
if (comCookie == NULL) {
sif::error << "Tmp1075Handler: Invalid com cookie" << std::endl;
}
Tmp1075Handler::Tmp1075Handler(object_id_t objectId, object_id_t comIF, CookieIF *comCookie)
: DeviceHandlerBase(objectId, comIF, comCookie), dataset(this) {
if (comCookie == NULL) {
sif::error << "Tmp1075Handler: Invalid com cookie" << std::endl;
}
}
Tmp1075Handler::~Tmp1075Handler() {
Tmp1075Handler::~Tmp1075Handler() {}
void Tmp1075Handler::doStartUp() {
if (mode == _MODE_START_UP) {
setMode(MODE_ON);
}
}
void Tmp1075Handler::doShutDown() { setMode(_MODE_POWER_DOWN); }
void Tmp1075Handler::doStartUp(){
if(mode == _MODE_START_UP){
setMode(MODE_ON);
}
ReturnValue_t Tmp1075Handler::buildNormalDeviceCommand(DeviceCommandId_t *id) {
if (communicationStep == CommunicationStep::START_ADC_CONVERSION) {
*id = TMP1075::START_ADC_CONVERSION;
communicationStep = CommunicationStep::GET_TEMPERATURE;
return buildCommandFromCommand(*id, NULL, 0);
} else {
*id = TMP1075::GET_TEMP;
communicationStep = CommunicationStep::START_ADC_CONVERSION;
return buildCommandFromCommand(*id, NULL, 0);
}
return HasReturnvaluesIF::RETURN_OK;
}
void Tmp1075Handler::doShutDown(){
setMode(_MODE_POWER_DOWN);
ReturnValue_t Tmp1075Handler::buildTransitionDeviceCommand(DeviceCommandId_t *id) {
return HasReturnvaluesIF::RETURN_OK;
}
ReturnValue_t Tmp1075Handler::buildNormalDeviceCommand(
DeviceCommandId_t * id) {
if(communicationStep == CommunicationStep::START_ADC_CONVERSION) {
*id = TMP1075::START_ADC_CONVERSION;
communicationStep = CommunicationStep::GET_TEMPERATURE;
return buildCommandFromCommand(*id, NULL, 0);
}
else {
*id = TMP1075::GET_TEMP;
communicationStep = CommunicationStep::START_ADC_CONVERSION;
return buildCommandFromCommand(*id, NULL, 0);
}
return HasReturnvaluesIF::RETURN_OK;
ReturnValue_t Tmp1075Handler::buildCommandFromCommand(DeviceCommandId_t deviceCommand,
const uint8_t *commandData,
size_t commandDataLen) {
switch (deviceCommand) {
case (TMP1075::START_ADC_CONVERSION): {
std::memset(cmdBuffer, 0, sizeof(cmdBuffer));
prepareAdcConversionCommand();
rawPacket = cmdBuffer;
rawPacketLen = TMP1075::CFGR_CMD_SIZE;
return RETURN_OK;
}
case (TMP1075::GET_TEMP): {
std::memset(cmdBuffer, 0, sizeof(cmdBuffer));
prepareGetTempCommand();
rawPacket = cmdBuffer;
rawPacketLen = TMP1075::POINTER_REG_SIZE;
rememberCommandId = TMP1075::GET_TEMP;
return RETURN_OK;
}
default:
return DeviceHandlerIF::COMMAND_NOT_IMPLEMENTED;
}
return HasReturnvaluesIF::RETURN_FAILED;
}
ReturnValue_t Tmp1075Handler::buildTransitionDeviceCommand(
DeviceCommandId_t * id){
return HasReturnvaluesIF::RETURN_OK;
void Tmp1075Handler::fillCommandAndReplyMap() {
this->insertInCommandMap(TMP1075::START_ADC_CONVERSION);
this->insertInCommandAndReplyMap(TMP1075::GET_TEMP, 1, &dataset, TMP1075::GET_TEMP_REPLY_SIZE);
}
ReturnValue_t Tmp1075Handler::buildCommandFromCommand(
DeviceCommandId_t deviceCommand, const uint8_t * commandData,
size_t commandDataLen) {
switch(deviceCommand) {
case(TMP1075::START_ADC_CONVERSION): {
std::memset(cmdBuffer, 0, sizeof(cmdBuffer));
prepareAdcConversionCommand();
rawPacket = cmdBuffer;
rawPacketLen = TMP1075::CFGR_CMD_SIZE;
return RETURN_OK;
}
case(TMP1075::GET_TEMP): {
std::memset(cmdBuffer, 0, sizeof(cmdBuffer));
prepareGetTempCommand();
rawPacket = cmdBuffer;
rawPacketLen = TMP1075::POINTER_REG_SIZE;
rememberCommandId = TMP1075::GET_TEMP;
return RETURN_OK;
}
default:
return DeviceHandlerIF::COMMAND_NOT_IMPLEMENTED;
}
return HasReturnvaluesIF::RETURN_FAILED;
ReturnValue_t Tmp1075Handler::scanForReply(const uint8_t *start, size_t remainingSize,
DeviceCommandId_t *foundId, size_t *foundLen) {
switch (rememberCommandId) {
case (TMP1075::GET_TEMP):
*foundId = TMP1075::GET_TEMP;
*foundLen = TMP1075::GET_TEMP_REPLY_SIZE;
rememberCommandId = TMP1075::NONE;
break;
default:
return IGNORE_REPLY_DATA;
}
return HasReturnvaluesIF::RETURN_OK;
}
void Tmp1075Handler::fillCommandAndReplyMap(){
this->insertInCommandMap(TMP1075::START_ADC_CONVERSION);
this->insertInCommandAndReplyMap(TMP1075::GET_TEMP, 1, &dataset,
TMP1075::GET_TEMP_REPLY_SIZE);
}
ReturnValue_t Tmp1075Handler::scanForReply(const uint8_t *start,
size_t remainingSize, DeviceCommandId_t *foundId, size_t *foundLen) {
switch(rememberCommandId) {
case(TMP1075::GET_TEMP):
*foundId = TMP1075::GET_TEMP;
*foundLen = TMP1075::GET_TEMP_REPLY_SIZE;
rememberCommandId = TMP1075::NONE;
break;
default:
return IGNORE_REPLY_DATA;
}
return HasReturnvaluesIF::RETURN_OK;
}
ReturnValue_t Tmp1075Handler::interpretDeviceReply(DeviceCommandId_t id,
const uint8_t *packet) {
switch (id) {
case TMP1075::GET_TEMP: {
int16_t tempValueRaw = 0;
tempValueRaw = packet[0] << 4 | packet[1] >> 4;
float tempValue = ((static_cast<float>(tempValueRaw)) * 0.0625);
ReturnValue_t Tmp1075Handler::interpretDeviceReply(DeviceCommandId_t id, const uint8_t *packet) {
switch (id) {
case TMP1075::GET_TEMP: {
int16_t tempValueRaw = 0;
tempValueRaw = packet[0] << 4 | packet[1] >> 4;
float tempValue = ((static_cast<float>(tempValueRaw)) * 0.0625);
#if OBSW_VERBOSE_LEVEL >= 1
sif::info << "Tmp1075 with object id: 0x" << std::hex << getObjectId()
<< ": Temperature: " << tempValue<< " °C"
<< std::endl;
sif::info << "Tmp1075 with object id: 0x" << std::hex << getObjectId()
<< ": Temperature: " << tempValue << " °C" << std::endl;
#endif
ReturnValue_t result = dataset.read();
if(result == HasReturnvaluesIF::RETURN_OK) {
dataset.temperatureCelcius = tempValue;
dataset.commit();
}
break;
}
ReturnValue_t result = dataset.read();
if (result == HasReturnvaluesIF::RETURN_OK) {
dataset.temperatureCelcius = tempValue;
dataset.commit();
}
break;
}
default: {
return DeviceHandlerIF::UNKNOWN_DEVICE_REPLY;
}
}
return HasReturnvaluesIF::RETURN_OK;
default: {
return DeviceHandlerIF::UNKNOWN_DEVICE_REPLY;
}
}
return HasReturnvaluesIF::RETURN_OK;
}
void Tmp1075Handler::setNormalDatapoolEntriesInvalid(){
void Tmp1075Handler::setNormalDatapoolEntriesInvalid() {}
void Tmp1075Handler::prepareAdcConversionCommand() {
cmdBuffer[0] = TMP1075::CFGR_ADDR;
cmdBuffer[1] = TMP1075::ONE_SHOT_MODE >> 8;
cmdBuffer[2] = TMP1075::ONE_SHOT_MODE & 0xFF;
}
void Tmp1075Handler::prepareAdcConversionCommand(){
cmdBuffer[0] = TMP1075::CFGR_ADDR;
cmdBuffer[1] = TMP1075::ONE_SHOT_MODE >> 8;
cmdBuffer[2] = TMP1075::ONE_SHOT_MODE & 0xFF;
}
void Tmp1075Handler::prepareGetTempCommand() { cmdBuffer[0] = TMP1075::TEMP_REG_ADDR; }
void Tmp1075Handler::prepareGetTempCommand(){
cmdBuffer[0] = TMP1075::TEMP_REG_ADDR;
}
uint32_t Tmp1075Handler::getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) { return 500; }
uint32_t Tmp1075Handler::getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo){
return 500;
ReturnValue_t Tmp1075Handler::initializeLocalDataPool(localpool::DataPool &localDataPoolMap,
LocalDataPoolManager &poolManager) {
localDataPoolMap.emplace(TMP1075::TEMPERATURE_C_TMP1075_1, new PoolEntry<float>({0.0}));
return HasReturnvaluesIF::RETURN_OK;
}
ReturnValue_t Tmp1075Handler::initializeLocalDataPool(localpool::DataPool& localDataPoolMap,
LocalDataPoolManager& poolManager) {
localDataPoolMap.emplace(TMP1075::TEMPERATURE_C_TMP1075_1, new PoolEntry<float>( { 0.0 }));
return HasReturnvaluesIF::RETURN_OK;
}

View File

@ -15,54 +15,46 @@
*
* @author J. Meier
*/
class Tmp1075Handler: public DeviceHandlerBase {
public:
class Tmp1075Handler : public DeviceHandlerBase {
public:
Tmp1075Handler(object_id_t objectId, object_id_t comIF, CookieIF *comCookie);
virtual ~Tmp1075Handler();
Tmp1075Handler(object_id_t objectId, object_id_t comIF,
CookieIF * comCookie);
virtual ~Tmp1075Handler();
protected:
void doStartUp() override;
void doShutDown() override;
ReturnValue_t buildNormalDeviceCommand(DeviceCommandId_t *id) override;
ReturnValue_t buildTransitionDeviceCommand(DeviceCommandId_t *id) override;
void fillCommandAndReplyMap() override;
ReturnValue_t buildCommandFromCommand(DeviceCommandId_t deviceCommand, const uint8_t *commandData,
size_t commandDataLen) override;
ReturnValue_t scanForReply(const uint8_t *start, size_t remainingSize, DeviceCommandId_t *foundId,
size_t *foundLen) override;
ReturnValue_t interpretDeviceReply(DeviceCommandId_t id, const uint8_t *packet) override;
void setNormalDatapoolEntriesInvalid() override;
uint32_t getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) override;
ReturnValue_t initializeLocalDataPool(localpool::DataPool &localDataPoolMap,
LocalDataPoolManager &poolManager) override;
protected:
void doStartUp() override;
void doShutDown() override;
ReturnValue_t buildNormalDeviceCommand(DeviceCommandId_t * id) override;
ReturnValue_t buildTransitionDeviceCommand(DeviceCommandId_t * id) override;
void fillCommandAndReplyMap() override;
ReturnValue_t buildCommandFromCommand(DeviceCommandId_t deviceCommand,
const uint8_t * commandData,size_t commandDataLen) override;
ReturnValue_t scanForReply(const uint8_t *start, size_t remainingSize,
DeviceCommandId_t *foundId, size_t *foundLen) override;
ReturnValue_t interpretDeviceReply(DeviceCommandId_t id,
const uint8_t *packet) override;
void setNormalDatapoolEntriesInvalid() override;
uint32_t getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) override;
ReturnValue_t initializeLocalDataPool(localpool::DataPool& localDataPoolMap,
LocalDataPoolManager& poolManager) override;
private:
/**
* @brief Function fills cmdBuffer with command to start the adc
* conversion for a new temperature value.
*/
void prepareAdcConversionCommand();
private:
void prepareGetTempCommand();
/**
* @brief Function fills cmdBuffer with command to start the adc
* conversion for a new temperature value.
*/
void prepareAdcConversionCommand();
enum class CommunicationStep { START_ADC_CONVERSION, GET_TEMPERATURE };
void prepareGetTempCommand();
TMP1075::Tmp1075Dataset dataset;
enum class CommunicationStep {
START_ADC_CONVERSION,
GET_TEMPERATURE
};
static const uint8_t MAX_CMD_LEN = 3;
TMP1075::Tmp1075Dataset dataset;
static const uint8_t MAX_CMD_LEN = 3;
uint8_t rememberRequestedSize = 0;
uint8_t rememberCommandId = TMP1075::NONE;
uint8_t cmdBuffer[MAX_CMD_LEN];
CommunicationStep communicationStep =
CommunicationStep::START_ADC_CONVERSION;
uint8_t rememberRequestedSize = 0;
uint8_t rememberCommandId = TMP1075::NONE;
uint8_t cmdBuffer[MAX_CMD_LEN];
CommunicationStep communicationStep = CommunicationStep::START_ADC_CONVERSION;
};
#endif /* MISSION_DEVICES_TMP1075HANDLER_H_ */

View File

@ -1,8 +1,8 @@
#ifndef MISSION_DEVICES_DEVICEDEFINITIONS_GPSDEFINITIONS_H_
#define MISSION_DEVICES_DEVICEDEFINITIONS_GPSDEFINITIONS_H_
#include "fsfw/devicehandlers/DeviceHandlerIF.h"
#include "fsfw/datapoollocal/StaticLocalDataSet.h"
#include "fsfw/devicehandlers/DeviceHandlerIF.h"
namespace GpsHyperion {
@ -11,60 +11,53 @@ static constexpr DeviceCommandId_t TRIGGER_RESET_PIN = 5;
static constexpr uint32_t DATASET_ID = 0;
enum GpsPoolIds: lp_id_t {
LATITUDE = 0,
LONGITUDE = 1,
ALTITUDE = 2,
SPEED = 3,
FIX_MODE = 4,
SATS_IN_USE = 5,
SATS_IN_VIEW = 6,
UNIX_SECONDS = 7,
YEAR = 8,
MONTH = 9,
DAY = 10,
HOURS = 11,
MINUTES = 12,
SECONDS = 13
enum GpsPoolIds : lp_id_t {
LATITUDE = 0,
LONGITUDE = 1,
ALTITUDE = 2,
SPEED = 3,
FIX_MODE = 4,
SATS_IN_USE = 5,
SATS_IN_VIEW = 6,
UNIX_SECONDS = 7,
YEAR = 8,
MONTH = 9,
DAY = 10,
HOURS = 11,
MINUTES = 12,
SECONDS = 13
};
enum GpsFixModes: uint8_t {
INVALID = 0,
NO_FIX = 1,
FIX_2D = 2,
FIX_3D = 3
};
enum GpsFixModes : uint8_t { INVALID = 0, NO_FIX = 1, FIX_2D = 2, FIX_3D = 3 };
}
} // namespace GpsHyperion
class GpsPrimaryDataset: public StaticLocalDataSet<18> {
public:
GpsPrimaryDataset(object_id_t gpsId):
StaticLocalDataSet(sid_t(gpsId, GpsHyperion::DATASET_ID)) {
setAllVariablesReadOnly();
}
class GpsPrimaryDataset : public StaticLocalDataSet<18> {
public:
GpsPrimaryDataset(object_id_t gpsId) : StaticLocalDataSet(sid_t(gpsId, GpsHyperion::DATASET_ID)) {
setAllVariablesReadOnly();
}
lp_var_t<double> latitude = lp_var_t<double>(sid.objectId,
GpsHyperion::LATITUDE, this);
lp_var_t<double> longitude = lp_var_t<double>(sid.objectId,
GpsHyperion::LONGITUDE, this);
lp_var_t<double> altitude = lp_var_t<double>(sid.objectId, GpsHyperion::ALTITUDE, this);
lp_var_t<double> speed = lp_var_t<double>(sid.objectId, GpsHyperion::SPEED, this);
lp_var_t<uint8_t> fixMode = lp_var_t<uint8_t>(sid.objectId, GpsHyperion::FIX_MODE, this);
lp_var_t<uint8_t> satInUse = lp_var_t<uint8_t>(sid.objectId, GpsHyperion::SATS_IN_USE, this);
lp_var_t<uint8_t> satInView = lp_var_t<uint8_t>(sid.objectId, GpsHyperion::SATS_IN_VIEW, this);
lp_var_t<uint16_t> year = lp_var_t<uint16_t>(sid.objectId, GpsHyperion::YEAR, this);
lp_var_t<uint8_t> month = lp_var_t<uint8_t>(sid.objectId, GpsHyperion::MONTH, this);
lp_var_t<uint8_t> day = lp_var_t<uint8_t>(sid.objectId, GpsHyperion::DAY, this);
lp_var_t<uint8_t> hours = lp_var_t<uint8_t>(sid.objectId, GpsHyperion::HOURS, this);
lp_var_t<uint8_t> minutes = lp_var_t<uint8_t>(sid.objectId, GpsHyperion::MINUTES, this);
lp_var_t<uint8_t> seconds = lp_var_t<uint8_t>(sid.objectId, GpsHyperion::SECONDS, this);
lp_var_t<uint32_t> unixSeconds = lp_var_t<uint32_t>(sid.objectId,
GpsHyperion::UNIX_SECONDS, this);
private:
friend class GPSHyperionHandler;
GpsPrimaryDataset(HasLocalDataPoolIF* hkOwner):
StaticLocalDataSet(hkOwner, GpsHyperion::DATASET_ID) {}
lp_var_t<double> latitude = lp_var_t<double>(sid.objectId, GpsHyperion::LATITUDE, this);
lp_var_t<double> longitude = lp_var_t<double>(sid.objectId, GpsHyperion::LONGITUDE, this);
lp_var_t<double> altitude = lp_var_t<double>(sid.objectId, GpsHyperion::ALTITUDE, this);
lp_var_t<double> speed = lp_var_t<double>(sid.objectId, GpsHyperion::SPEED, this);
lp_var_t<uint8_t> fixMode = lp_var_t<uint8_t>(sid.objectId, GpsHyperion::FIX_MODE, this);
lp_var_t<uint8_t> satInUse = lp_var_t<uint8_t>(sid.objectId, GpsHyperion::SATS_IN_USE, this);
lp_var_t<uint8_t> satInView = lp_var_t<uint8_t>(sid.objectId, GpsHyperion::SATS_IN_VIEW, this);
lp_var_t<uint16_t> year = lp_var_t<uint16_t>(sid.objectId, GpsHyperion::YEAR, this);
lp_var_t<uint8_t> month = lp_var_t<uint8_t>(sid.objectId, GpsHyperion::MONTH, this);
lp_var_t<uint8_t> day = lp_var_t<uint8_t>(sid.objectId, GpsHyperion::DAY, this);
lp_var_t<uint8_t> hours = lp_var_t<uint8_t>(sid.objectId, GpsHyperion::HOURS, this);
lp_var_t<uint8_t> minutes = lp_var_t<uint8_t>(sid.objectId, GpsHyperion::MINUTES, this);
lp_var_t<uint8_t> seconds = lp_var_t<uint8_t>(sid.objectId, GpsHyperion::SECONDS, this);
lp_var_t<uint32_t> unixSeconds =
lp_var_t<uint32_t>(sid.objectId, GpsHyperion::UNIX_SECONDS, this);
private:
friend class GPSHyperionHandler;
GpsPrimaryDataset(HasLocalDataPoolIF* hkOwner)
: StaticLocalDataSet(hkOwner, GpsHyperion::DATASET_ID) {}
};
#endif /* MISSION_DEVICES_DEVICEDEFINITIONS_GPSDEFINITIONS_H_ */

View File

@ -2,37 +2,32 @@
#define MISSION_DEVICES_DEVICEDEFINITIONS_GOMSPACEPACKETS_H_
#include <fsfw/serialize/SerialBufferAdapter.h>
#include <fsfw/serialize/SerializeElement.h>
#include <fsfw/serialize/SerialLinkedListAdapter.h>
#include <fsfw/serialize/SerialFixedArrayListAdapter.h>
#include <fsfw/serialize/SerialLinkedListAdapter.h>
#include <fsfw/serialize/SerializeElement.h>
#include <mission/devices/devicedefinitions/GomspaceDefinitions.h>
/**
* @brief This class can be used to generated the command for the CspComIF
* to reset the watchdog in a gomspace device.
*/
class WatchdogResetCommand : public SerialLinkedListAdapter<SerializeIF> {
public:
public:
WatchdogResetCommand() { setLinks(); }
WatchdogResetCommand() {
setLinks();
}
private:
WatchdogResetCommand(const WatchdogResetCommand &command);
void setLinks() {
setStart(&cspPort);
cspPort.setNext(&querySize);
querySize.setNext(&magic);
}
SerializeElement<uint8_t> cspPort = GOMSPACE::P60_PORT_GNDWDT_RESET;
SerializeElement<uint16_t> querySize = 1;
/* Sending 0x78 to port 9 of a gomspace device resets the ground watchdog */
SerializeElement<uint8_t> magic = 0x78;
private:
WatchdogResetCommand(const WatchdogResetCommand &command);
void setLinks() {
setStart(&cspPort);
cspPort.setNext(&querySize);
querySize.setNext(&magic);
}
SerializeElement<uint8_t> cspPort = GOMSPACE::P60_PORT_GNDWDT_RESET;
SerializeElement<uint16_t> querySize = 1;
/* Sending 0x78 to port 9 of a gomspace device resets the ground watchdog */
SerializeElement<uint8_t> magic = 0x78;
};
/**
* @brief A serial linked list adapter implementation to generate ping
* commands for devices supporting the CSP protocol. This command can
@ -44,33 +39,32 @@ private:
* transmitted to the target device.
*/
class CspPingCommand : public SerialLinkedListAdapter<SerializeIF> {
public:
/**
* @brief Constructor
*
* @param querySize_ The size of bytes replied by the ping request.
* Amounts to the number of bytes send.
* @param data_ Pointer to data which should be sent to the device.
* All data will be sent back by the ping target.
*/
CspPingCommand(const uint8_t* data_, uint16_t querySize_) :
querySize(querySize_), data(data_, querySize_) {
setLinks();
}
public:
/**
* @brief Constructor
*
* @param querySize_ The size of bytes replied by the ping request.
* Amounts to the number of bytes send.
* @param data_ Pointer to data which should be sent to the device.
* All data will be sent back by the ping target.
*/
CspPingCommand(const uint8_t *data_, uint16_t querySize_)
: querySize(querySize_), data(data_, querySize_) {
setLinks();
}
private:
CspPingCommand(const CspPingCommand &command);
void setLinks() {
setStart(&cspPort);
cspPort.setNext(&querySize);
querySize.setNext(&data);
}
SerializeElement<uint8_t> cspPort = GOMSPACE::PING_PORT;
SerializeElement<uint16_t> querySize;
SerializeElement<SerialBufferAdapter<uint8_t>> data;
private:
CspPingCommand(const CspPingCommand &command);
void setLinks() {
setStart(&cspPort);
cspPort.setNext(&querySize);
querySize.setNext(&data);
}
SerializeElement<uint8_t> cspPort = GOMSPACE::PING_PORT;
SerializeElement<uint16_t> querySize;
SerializeElement<SerialBufferAdapter<uint8_t>> data;
};
/**
* @brief A serial linked list adapter implementation of the gs_rparam_query_t
* struct defined in rparam.h. Can be used to build the message to set
@ -81,47 +75,49 @@ private:
* and the size to query.
*/
class CspSetParamCommand : public SerialLinkedListAdapter<SerializeIF> {
public:
public:
CspSetParamCommand(uint16_t querySize_, uint16_t payloadlength_, uint16_t checksum_,
uint16_t seq_, uint16_t total_, uint16_t addr_, const uint8_t *parameter_,
uint8_t parameterCount_)
: querySize(querySize_),
payloadlength(payloadlength_),
checksum(checksum_),
seq(seq_),
total(total_),
addr(addr_),
parameter(parameter_, parameterCount_) {
setLinks();
}
CspSetParamCommand(uint16_t querySize_, uint16_t payloadlength_,
uint16_t checksum_, uint16_t seq_, uint16_t total_, uint16_t addr_,
const uint8_t* parameter_, uint8_t parameterCount_) :
querySize(querySize_), payloadlength(
payloadlength_), checksum(checksum_), seq(seq_), total(
total_), addr(addr_), parameter(parameter_, parameterCount_) {
setLinks();
}
private:
CspSetParamCommand(const CspSetParamCommand &command);
void setLinks() {
setStart(&cspPort);
cspPort.setNext(&querySize);
querySize.setNext(&action);
action.setNext(&tableId);
tableId.setNext(&payloadlength);
payloadlength.setNext(&checksum);
checksum.setNext(&seq);
seq.setNext(&total);
total.setNext(&addr);
addr.setNext(&parameter);
}
SerializeElement<uint8_t> cspPort = GOMSPACE::PARAM_PORT;
/* Only a parameter will be set. No data will be queried with this command */
SerializeElement<uint16_t> querySize;
SerializeElement<uint8_t> action = 0xFF; // param set
/* We will never set a parameter in a table other than the configuration
* table */
SerializeElement<uint8_t> tableId = 1;
SerializeElement<uint16_t> payloadlength;
SerializeElement<uint16_t> checksum;
SerializeElement<uint16_t> seq;
SerializeElement<uint16_t> total;
SerializeElement<uint16_t> addr;
SerializeElement<SerialBufferAdapter<uint8_t>> parameter;
private:
CspSetParamCommand(const CspSetParamCommand &command);
void setLinks() {
setStart(&cspPort);
cspPort.setNext(&querySize);
querySize.setNext(&action);
action.setNext(&tableId);
tableId.setNext(&payloadlength);
payloadlength.setNext(&checksum);
checksum.setNext(&seq);
seq.setNext(&total);
total.setNext(&addr);
addr.setNext(&parameter);
}
SerializeElement<uint8_t> cspPort = GOMSPACE::PARAM_PORT;
/* Only a parameter will be set. No data will be queried with this command */
SerializeElement<uint16_t> querySize;
SerializeElement<uint8_t> action = 0xFF; // param set
/* We will never set a parameter in a table other than the configuration
* table */
SerializeElement<uint8_t> tableId = 1;
SerializeElement<uint16_t> payloadlength;
SerializeElement<uint16_t> checksum;
SerializeElement<uint16_t> seq;
SerializeElement<uint16_t> total;
SerializeElement<uint16_t> addr;
SerializeElement<SerialBufferAdapter<uint8_t>> parameter;
};
/**
* @brief This class can be used to generate a get param command for the
* gomspace devices which will be sent to the device communication
@ -131,50 +127,50 @@ private:
* and will not be transmitted physically to the target device.
*/
class CspGetParamCommand : public SerialLinkedListAdapter<SerializeIF> {
public:
/* The size of the header of a gomspace CSP packet. */
static const uint8_t GS_HDR_LENGTH = 12;
public:
/* The size of the header of a gomspace CSP packet. */
static const uint8_t GS_HDR_LENGTH = 12;
CspGetParamCommand(uint16_t querySize_, uint8_t tableId_,
uint16_t addresslength_, uint16_t checksum_, uint16_t seq_,
uint16_t total_, uint16_t addr_) :
querySize(querySize_), tableId(tableId_), addresslength(
addresslength_), checksum(checksum_), seq(seq_), total(
total_), addr(addr_) {
fixedValuesInit();
setLinks();
}
CspGetParamCommand(uint16_t querySize_, uint8_t tableId_, uint16_t addresslength_,
uint16_t checksum_, uint16_t seq_, uint16_t total_, uint16_t addr_)
: querySize(querySize_),
tableId(tableId_),
addresslength(addresslength_),
checksum(checksum_),
seq(seq_),
total(total_),
addr(addr_) {
fixedValuesInit();
setLinks();
}
private:
CspGetParamCommand(const CspGetParamCommand &command);
void setLinks() {
setStart(&cspPort);
cspPort.setNext(&querySize);
querySize.setNext(&action);
action.setNext(&tableId);
tableId.setNext(&addresslength);
addresslength.setNext(&checksum);
checksum.setNext(&seq);
seq.setNext(&total);
total.setNext(&addr);
}
void fixedValuesInit(){
cspPort.entry = GOMSPACE::PARAM_PORT;
}
SerializeElement<uint8_t> cspPort;
SerializeElement<uint16_t> querySize; // size of bytes to query
/* Following information will also be physically transmitted to the target
* device*/
SerializeElement<uint8_t> action = 0x00; // get param
SerializeElement<uint8_t> tableId;
SerializeElement<uint16_t> addresslength;
SerializeElement<uint16_t> checksum;
SerializeElement<uint16_t> seq;
SerializeElement<uint16_t> total;
SerializeElement<uint16_t> addr;
private:
CspGetParamCommand(const CspGetParamCommand &command);
void setLinks() {
setStart(&cspPort);
cspPort.setNext(&querySize);
querySize.setNext(&action);
action.setNext(&tableId);
tableId.setNext(&addresslength);
addresslength.setNext(&checksum);
checksum.setNext(&seq);
seq.setNext(&total);
total.setNext(&addr);
}
void fixedValuesInit() { cspPort.entry = GOMSPACE::PARAM_PORT; }
SerializeElement<uint8_t> cspPort;
SerializeElement<uint16_t> querySize; // size of bytes to query
/* Following information will also be physically transmitted to the target
* device*/
SerializeElement<uint8_t> action = 0x00; // get param
SerializeElement<uint8_t> tableId;
SerializeElement<uint16_t> addresslength;
SerializeElement<uint16_t> checksum;
SerializeElement<uint16_t> seq;
SerializeElement<uint16_t> total;
SerializeElement<uint16_t> addr;
};
/**
* @brief This class can be used to generate a get param command for the
* gomspace devices which will be sent to the device communication
@ -184,205 +180,186 @@ private:
* and will not be transmitted physically to the target device.
*/
class RequestFullTableCommand : public SerialLinkedListAdapter<SerializeIF> {
public:
public:
RequestFullTableCommand(uint16_t querySize_, uint8_t tableId_)
: querySize(querySize_), tableId(tableId_) {
setLinks();
}
RequestFullTableCommand(uint16_t querySize_, uint8_t tableId_) :
querySize(querySize_), tableId(tableId_) {
setLinks();
}
private:
RequestFullTableCommand(const RequestFullTableCommand &command);
void setLinks() {
setStart(&cspPort);
cspPort.setNext(&querySize);
querySize.setNext(&action);
action.setNext(&tableId);
tableId.setNext(&addresslength);
addresslength.setNext(&checksum);
checksum.setNext(&seq);
seq.setNext(&total);
}
SerializeElement<uint8_t> cspPort = GOMSPACE::PARAM_PORT;
/** Size of bytes to query (size of csp header + size of table) */
SerializeElement<uint16_t> querySize;
/* Following information will also be physically transmitted to the target
* device*/
SerializeElement<uint8_t> action = 0x00; // get param
SerializeElement<uint8_t> tableId;
/* Size of address. Set to 0 to get full table */
SerializeElement<uint16_t> addresslength = 0;
SerializeElement<uint16_t> checksum = GOMSPACE::IGNORE_CHECKSUM;
SerializeElement<uint16_t> seq = 0;
SerializeElement<uint16_t> total = 0;
private:
RequestFullTableCommand(const RequestFullTableCommand &command);
void setLinks() {
setStart(&cspPort);
cspPort.setNext(&querySize);
querySize.setNext(&action);
action.setNext(&tableId);
tableId.setNext(&addresslength);
addresslength.setNext(&checksum);
checksum.setNext(&seq);
seq.setNext(&total);
}
SerializeElement<uint8_t> cspPort = GOMSPACE::PARAM_PORT;
/** Size of bytes to query (size of csp header + size of table) */
SerializeElement<uint16_t> querySize;
/* Following information will also be physically transmitted to the target
* device*/
SerializeElement<uint8_t> action = 0x00; // get param
SerializeElement<uint8_t> tableId;
/* Size of address. Set to 0 to get full table */
SerializeElement<uint16_t> addresslength = 0;
SerializeElement<uint16_t> checksum = GOMSPACE::IGNORE_CHECKSUM;
SerializeElement<uint16_t> seq = 0;
SerializeElement<uint16_t> total = 0;
};
/**
* @brief This class can be used to deserialize replies from gomspace devices
* and extract the relevant data.
*/
class CspGetParamReply : public SerialLinkedListAdapter<SerializeIF> {
public:
/**
* @brief Constructor
*
* @param payloadBuffer Pointer to a buffer to store the payload data of
* the CSP packet.
* @param payloadBufferSz The size of the payload buffer where the payload
* data will be stored.
*/
CspGetParamReply(uint8_t* payloadBuffer_, uint8_t payloadBufferSz_) :
payload(payloadBuffer_, payloadBufferSz_) {
setLinks();
}
public:
/**
* @brief Constructor
*
* @param payloadBuffer Pointer to a buffer to store the payload data of
* the CSP packet.
* @param payloadBufferSz The size of the payload buffer where the payload
* data will be stored.
*/
CspGetParamReply(uint8_t *payloadBuffer_, uint8_t payloadBufferSz_)
: payload(payloadBuffer_, payloadBufferSz_) {
setLinks();
}
uint8_t getAction(){
return action;
}
uint8_t getAction() { return action; }
uint8_t getTableId(){
return tableId;
}
uint8_t getTableId() { return tableId; }
uint16_t getLength(){
return length;
}
uint16_t getLength() { return length; }
uint16_t getAddress(){
return addr;
}
uint16_t getAddress() { return addr; }
private:
CspGetParamReply(const CspGetParamReply &reply);
void setLinks() {
setStart(&action);
action.setNext(&tableId);
tableId.setNext(&length);
length.setNext(&checksum);
checksum.setNext(&seq);
seq.setNext(&total);
total.setNext(&addr);
addr.setNext(&payload);
}
private:
CspGetParamReply(const CspGetParamReply &reply);
void setLinks() {
setStart(&action);
action.setNext(&tableId);
tableId.setNext(&length);
length.setNext(&checksum);
checksum.setNext(&seq);
seq.setNext(&total);
total.setNext(&addr);
addr.setNext(&payload);
}
SerializeElement<uint8_t> action;
SerializeElement<uint8_t> tableId;
SerializeElement<uint16_t> length; //length of address field + payload data
SerializeElement<uint16_t> checksum;
SerializeElement<uint16_t> seq;
SerializeElement<uint16_t> total;
SerializeElement<uint16_t> addr;
SerializeElement<SerialBufferAdapter<uint8_t>> payload;
SerializeElement<uint8_t> action;
SerializeElement<uint8_t> tableId;
SerializeElement<uint16_t> length; // length of address field + payload data
SerializeElement<uint16_t> checksum;
SerializeElement<uint16_t> seq;
SerializeElement<uint16_t> total;
SerializeElement<uint16_t> addr;
SerializeElement<SerialBufferAdapter<uint8_t>> payload;
};
/**
* @brief This class generates telemetry packets containing data from
* CSP get-parameter-replies.
*/
class ParamReply : public SerialLinkedListAdapter<SerializeIF> {
public:
/**
* @brief Constructor
*
* @param payloadBuffer Pointer to a buffer to store the payload data of
* the CSP packet.
* @param payloadBufferSz The size of the payload buffer where the payload
* data will be stored.
*/
ParamReply(uint8_t action_, uint8_t tableId_, uint16_t addr_,
uint16_t payloadLength_, uint8_t* payloadBuffer_) :
action(action_), tableId(tableId_), addr(addr_), payloadLength(
payloadLength_), payload(payloadBuffer_, payloadLength) {
setLinks();
}
public:
/**
* @brief Constructor
*
* @param payloadBuffer Pointer to a buffer to store the payload data of
* the CSP packet.
* @param payloadBufferSz The size of the payload buffer where the payload
* data will be stored.
*/
ParamReply(uint8_t action_, uint8_t tableId_, uint16_t addr_, uint16_t payloadLength_,
uint8_t *payloadBuffer_)
: action(action_),
tableId(tableId_),
addr(addr_),
payloadLength(payloadLength_),
payload(payloadBuffer_, payloadLength) {
setLinks();
}
private:
ParamReply(const CspGetParamReply &reply);
void setLinks() {
setStart(&action);
action.setNext(&tableId);
tableId.setNext(&addr);
addr.setNext(&payloadLength);
payloadLength.setNext(&payload);
}
SerializeElement<uint8_t> action;
SerializeElement<uint8_t> tableId;
SerializeElement<uint16_t> addr;
SerializeElement<uint16_t> payloadLength;
SerializeElement<SerialBufferAdapter<uint16_t>> payload;
private:
ParamReply(const CspGetParamReply &reply);
void setLinks() {
setStart(&action);
action.setNext(&tableId);
tableId.setNext(&addr);
addr.setNext(&payloadLength);
payloadLength.setNext(&payload);
}
SerializeElement<uint8_t> action;
SerializeElement<uint8_t> tableId;
SerializeElement<uint16_t> addr;
SerializeElement<uint16_t> payloadLength;
SerializeElement<SerialBufferAdapter<uint16_t>> payload;
};
/**
* @brief This class generates the reply containing data from a full housekeeping table request
* of the PDU2.
* @brief This class generates the reply containing data from a full housekeeping table
* request of the PDU2.
*/
class Pdu2FullTableReply : public SerialLinkedListAdapter<SerializeIF> {
public:
/**
* @brief Constructor
*
* @param action_ The command which triggered the full table request.
* @param tableId_ The id of the requested table.
* @param tableDataset_ The dataset holding the table data.
*/
Pdu2FullTableReply(uint8_t action_, uint8_t tableId_, SerializeIF* tableDataset_) :
action(action_), tableId(tableId_), dataset(tableDataset_) {
setLinks();
}
public:
/**
* @brief Constructor
*
* @param action_ The command which triggered the full table request.
* @param tableId_ The id of the requested table.
* @param tableDataset_ The dataset holding the table data.
*/
Pdu2FullTableReply(uint8_t action_, uint8_t tableId_, SerializeIF *tableDataset_)
: action(action_), tableId(tableId_), dataset(tableDataset_) {
setLinks();
}
private:
Pdu2FullTableReply(const Pdu2FullTableReply &reply);
void setLinks() {
setStart(&action);
action.setNext(&tableId);
tableId.setNext(&dataset);
}
SerializeElement<uint8_t> action;
SerializeElement<uint8_t> tableId;
LinkedElement<SerializeIF> dataset;
private:
Pdu2FullTableReply(const Pdu2FullTableReply &reply);
void setLinks() {
setStart(&action);
action.setNext(&tableId);
tableId.setNext(&dataset);
}
SerializeElement<uint8_t> action;
SerializeElement<uint8_t> tableId;
LinkedElement<SerializeIF> dataset;
};
/**
* @brief This class helps to unpack information from an action message
* to set a parameter in gomspace devices. The action message can be
* for example received from the PUS Service 8.
*/
class SetParamMessageUnpacker: public SerialLinkedListAdapter<SerializeIF> {
public:
/* Largest parameter is a uint32_t */
static const uint32_t MAX_SIZE = 4;
class SetParamMessageUnpacker : public SerialLinkedListAdapter<SerializeIF> {
public:
/* Largest parameter is a uint32_t */
static const uint32_t MAX_SIZE = 4;
SetParamMessageUnpacker() {
setLinks();
}
SetParamMessageUnpacker() { setLinks(); }
uint16_t getAddress() {
return address;
}
uint16_t getAddress() { return address; }
uint8_t* getParameter() {
return parameter->front();
}
uint8_t *getParameter() { return parameter->front(); }
uint8_t getParameterSize(){
return parameter->size;
}
uint8_t getParameterSize() { return parameter->size; }
private:
void setLinks() {
setStart(&address);
address.setNext(&parameter);
}
SetParamMessageUnpacker(const SetParamMessageUnpacker &message);
SerializeElement<uint16_t> address;
SerializeElement<SerialFixedArrayListAdapter<uint8_t, MAX_SIZE, uint8_t>> parameter;
private:
void setLinks() {
setStart(&address);
address.setNext(&parameter);
}
SetParamMessageUnpacker(const SetParamMessageUnpacker &message);
SerializeElement<uint16_t> address;
SerializeElement<SerialFixedArrayListAdapter<uint8_t, MAX_SIZE, uint8_t>> parameter;
};
/**
* @brief This class generates a message which can be sent to the GomspaceDeviceHandler to
* command a parameter change.
@ -391,76 +368,64 @@ private:
* | memory address | size of parameter value | parameter value |
*/
class GomspaceSetParamMessage : public SerialLinkedListAdapter<SerializeIF> {
public:
public:
/* The size of the largest parameter */
static const uint8_t MAX_SIZE = 4;
/* The size of the largest parameter */
static const uint8_t MAX_SIZE = 4;
/**
* @brief Constructor
*
* @param memoryAddress The address of the parameter to change in the configuration table.
* @param parameterValue Pointer to the parameter value to set.
* @param parameterSize The size of the parameter.
*
*/
GomspaceSetParamMessage(uint16_t memoryAddress, const uint8_t *parameterValue,
uint8_t parameterSize)
: memoryAddress(memoryAddress), parameterValueBuffer(parameterValue, parameterSize, true) {
setLinks();
}
/**
* @brief Constructor
*
* @param memoryAddress The address of the parameter to change in the configuration table.
* @param parameterValue Pointer to the parameter value to set.
* @param parameterSize The size of the parameter.
*
*/
GomspaceSetParamMessage(uint16_t memoryAddress, const uint8_t* parameterValue,
uint8_t parameterSize) :
memoryAddress(memoryAddress), parameterValueBuffer(parameterValue, parameterSize, true) {
setLinks();
}
private:
GomspaceSetParamMessage(const GomspaceSetParamMessage &reply);
void setLinks() {
setStart(&memoryAddress);
memoryAddress.setNext(&parameterValueBuffer);
}
SerializeElement<uint16_t> memoryAddress;
/**
* Parameter can be uint8_t, uint16_t or uint32_t. Thus max size of parameterValueBuffer is
* four bytes.
*/
SerializeElement<SerialBufferAdapter<uint8_t>> parameterValueBuffer;
private:
GomspaceSetParamMessage(const GomspaceSetParamMessage &reply);
void setLinks() {
setStart(&memoryAddress);
memoryAddress.setNext(&parameterValueBuffer);
}
SerializeElement<uint16_t> memoryAddress;
/**
* Parameter can be uint8_t, uint16_t or uint32_t. Thus max size of parameterValueBuffer is
* four bytes.
*/
SerializeElement<SerialBufferAdapter<uint8_t>> parameterValueBuffer;
};
/**
* @brief This class helps to unpack information from an action message
* to get a parameter from gomspace devices. The action message can be
* for example received from the PUS Service 8.
*/
class GetParamMessageUnpacker: public SerialLinkedListAdapter<SerializeIF> {
public:
class GetParamMessageUnpacker : public SerialLinkedListAdapter<SerializeIF> {
public:
GetParamMessageUnpacker() { setLinks(); }
GetParamMessageUnpacker() {
setLinks();
}
uint8_t getTableId() { return tableId; }
uint8_t getTableId() {
return tableId;
}
uint16_t getAddress() { return address; }
uint16_t getAddress() {
return address;
}
uint8_t getParameterSize() { return parameterSize; }
uint8_t getParameterSize(){
return parameterSize;
}
private:
GetParamMessageUnpacker(const GetParamMessageUnpacker &message);
void setLinks() {
setStart(&tableId);
tableId.setNext(&address);
address.setNext(&parameterSize);
}
SerializeElement<uint8_t> tableId;
SerializeElement<uint16_t> address; //The memory address offset within the table
/* The size of the requested value (e.g. temperature is a uint16_t value) */
SerializeElement<uint8_t> parameterSize;
private:
GetParamMessageUnpacker(const GetParamMessageUnpacker &message);
void setLinks() {
setStart(&tableId);
tableId.setNext(&address);
address.setNext(&parameterSize);
}
SerializeElement<uint8_t> tableId;
SerializeElement<uint16_t> address; // The memory address offset within the table
/* The size of the requested value (e.g. temperature is a uint16_t value) */
SerializeElement<uint8_t> parameterSize;
};
#endif /* MISSION_DEVICES_DEVICEDEFINITIONS_GOMSPACEPACKETS_H_ */

File diff suppressed because it is too large Load Diff

View File

@ -1,17 +1,14 @@
#ifndef MISSION_DEVICES_DEVICEDEFINITIONS_GYROADIS16507DEFINITIONS_H_
#define MISSION_DEVICES_DEVICEDEFINITIONS_GYROADIS16507DEFINITIONS_H_
#include "fsfw/devicehandlers/DeviceHandlerIF.h"
#include "fsfw/datapoollocal/StaticLocalDataSet.h"
#include <cstddef>
#include "fsfw/datapoollocal/StaticLocalDataSet.h"
#include "fsfw/devicehandlers/DeviceHandlerIF.h"
namespace ADIS1650X {
enum class Type {
ADIS16505,
ADIS16507
};
enum class Type { ADIS16505, ADIS16507 };
static constexpr size_t MAXIMUM_REPLY_SIZE = 64;
static constexpr uint8_t WRITE_MASK = 0b1000'0000;
@ -63,91 +60,82 @@ static constexpr size_t SENSOR_READOUT_SIZE = 20 + 2;
static constexpr uint32_t ADIS_DATASET_ID = READ_SENSOR_DATA;
static constexpr uint32_t ADIS_CFG_DATASET_ID = READ_OUT_CONFIG;
enum GlobCmds: uint8_t {
FACTORY_CALIBRATION = 0b0000'0010,
SENSOR_SELF_TEST = 0b0000'0100,
FLASH_MEMORY_UPDATE = 0b0000'1000,
FLASH_MEMORY_TEST = 0b0001'0000,
SOFTWARE_RESET = 0b1000'0000
enum GlobCmds : uint8_t {
FACTORY_CALIBRATION = 0b0000'0010,
SENSOR_SELF_TEST = 0b0000'0100,
FLASH_MEMORY_UPDATE = 0b0000'1000,
FLASH_MEMORY_TEST = 0b0001'0000,
SOFTWARE_RESET = 0b1000'0000
};
enum PrimaryPoolIds: lp_id_t {
ANG_VELOC_X,
ANG_VELOC_Y,
ANG_VELOC_Z,
ACCELERATION_X,
ACCELERATION_Y,
ACCELERATION_Z,
TEMPERATURE,
DIAG_STAT_REGISTER,
FILTER_SETTINGS,
MSC_CTRL_REGISTER,
DEC_RATE_REGISTER,
enum PrimaryPoolIds : lp_id_t {
ANG_VELOC_X,
ANG_VELOC_Y,
ANG_VELOC_Z,
ACCELERATION_X,
ACCELERATION_Y,
ACCELERATION_Z,
TEMPERATURE,
DIAG_STAT_REGISTER,
FILTER_SETTINGS,
MSC_CTRL_REGISTER,
DEC_RATE_REGISTER,
};
enum FilterSettings: uint8_t {
NO_FILTER = 0,
TWO_TAPS = 1,
FOUR_TAPS = 2,
EIGHT_TAPS = 3,
SIXTEEN_TAPS = 4,
THIRTYTWO_TAPS = 5,
SIXTYFOUR_TAPS = 6
enum FilterSettings : uint8_t {
NO_FILTER = 0,
TWO_TAPS = 1,
FOUR_TAPS = 2,
EIGHT_TAPS = 3,
SIXTEEN_TAPS = 4,
THIRTYTWO_TAPS = 5,
SIXTYFOUR_TAPS = 6
};
}
} // namespace ADIS1650X
class AdisGyroPrimaryDataset: public StaticLocalDataSet<8> {
public:
class AdisGyroPrimaryDataset : public StaticLocalDataSet<8> {
public:
/** Constructor for data users like controllers */
AdisGyroPrimaryDataset(object_id_t adisId)
: StaticLocalDataSet(sid_t(adisId, ADIS1650X::ADIS_DATASET_ID)) {
setAllVariablesReadOnly();
}
/** Constructor for data users like controllers */
AdisGyroPrimaryDataset(object_id_t adisId):
StaticLocalDataSet(sid_t(adisId, ADIS1650X::ADIS_DATASET_ID)) {
setAllVariablesReadOnly();
}
/* Angular velocities in degrees per second (DPS) */
lp_var_t<double> angVelocX = lp_var_t<double>(sid.objectId, ADIS1650X::ANG_VELOC_X, this);
lp_var_t<double> angVelocY = lp_var_t<double>(sid.objectId, ADIS1650X::ANG_VELOC_Y, this);
lp_var_t<double> angVelocZ = lp_var_t<double>(sid.objectId, ADIS1650X::ANG_VELOC_Z, this);
lp_var_t<double> accelX = lp_var_t<double>(sid.objectId, ADIS1650X::ACCELERATION_X, this);
lp_var_t<double> accelY = lp_var_t<double>(sid.objectId, ADIS1650X::ACCELERATION_Y, this);
lp_var_t<double> accelZ = lp_var_t<double>(sid.objectId, ADIS1650X::ACCELERATION_Z, this);
lp_var_t<float> temperature = lp_var_t<float>(sid.objectId, ADIS1650X::TEMPERATURE, this);
/* Angular velocities in degrees per second (DPS) */
lp_var_t<double> angVelocX = lp_var_t<double>(sid.objectId,
ADIS1650X::ANG_VELOC_X, this);
lp_var_t<double> angVelocY = lp_var_t<double>(sid.objectId,
ADIS1650X::ANG_VELOC_Y, this);
lp_var_t<double> angVelocZ = lp_var_t<double>(sid.objectId,
ADIS1650X::ANG_VELOC_Z, this);
lp_var_t<double> accelX = lp_var_t<double>(sid.objectId,
ADIS1650X::ACCELERATION_X, this);
lp_var_t<double> accelY = lp_var_t<double>(sid.objectId,
ADIS1650X::ACCELERATION_Y, this);
lp_var_t<double> accelZ = lp_var_t<double>(sid.objectId,
ADIS1650X::ACCELERATION_Z, this);
lp_var_t<float> temperature = lp_var_t<float>(sid.objectId,
ADIS1650X::TEMPERATURE, this);
private:
friend class GyroADIS1650XHandler;
/** Constructor for the data creator */
AdisGyroPrimaryDataset(HasLocalDataPoolIF* hkOwner):
StaticLocalDataSet(hkOwner, ADIS1650X::ADIS_DATASET_ID) {}
private:
friend class GyroADIS1650XHandler;
/** Constructor for the data creator */
AdisGyroPrimaryDataset(HasLocalDataPoolIF* hkOwner)
: StaticLocalDataSet(hkOwner, ADIS1650X::ADIS_DATASET_ID) {}
};
class AdisGyroConfigDataset: public StaticLocalDataSet<5> {
public:
class AdisGyroConfigDataset : public StaticLocalDataSet<5> {
public:
/** Constructor for data users like controllers */
AdisGyroConfigDataset(object_id_t adisId)
: StaticLocalDataSet(sid_t(adisId, ADIS1650X::ADIS_CFG_DATASET_ID)) {
setAllVariablesReadOnly();
}
/** Constructor for data users like controllers */
AdisGyroConfigDataset(object_id_t adisId):
StaticLocalDataSet(sid_t(adisId, ADIS1650X::ADIS_CFG_DATASET_ID)) {
setAllVariablesReadOnly();
}
lp_var_t<uint16_t> diagStatReg = lp_var_t<uint16_t>(sid.objectId, ADIS1650X::DIAG_STAT_REGISTER);
lp_var_t<uint8_t> filterSetting = lp_var_t<uint8_t>(sid.objectId, ADIS1650X::FILTER_SETTINGS);
lp_var_t<uint16_t> mscCtrlReg = lp_var_t<uint16_t>(sid.objectId, ADIS1650X::MSC_CTRL_REGISTER);
lp_var_t<uint16_t> decRateReg = lp_var_t<uint16_t>(sid.objectId, ADIS1650X::DEC_RATE_REGISTER);
lp_var_t<uint16_t> diagStatReg = lp_var_t<uint16_t>(sid.objectId,
ADIS1650X::DIAG_STAT_REGISTER);
lp_var_t<uint8_t> filterSetting = lp_var_t<uint8_t>(sid.objectId, ADIS1650X::FILTER_SETTINGS);
lp_var_t<uint16_t> mscCtrlReg = lp_var_t<uint16_t>(sid.objectId, ADIS1650X::MSC_CTRL_REGISTER);
lp_var_t<uint16_t> decRateReg = lp_var_t<uint16_t>(sid.objectId, ADIS1650X::DEC_RATE_REGISTER);
private:
friend class GyroADIS1650XHandler;
/** Constructor for the data creator */
AdisGyroConfigDataset(HasLocalDataPoolIF* hkOwner):
StaticLocalDataSet(hkOwner, ADIS1650X::ADIS_CFG_DATASET_ID) {}
private:
friend class GyroADIS1650XHandler;
/** Constructor for the data creator */
AdisGyroConfigDataset(HasLocalDataPoolIF* hkOwner)
: StaticLocalDataSet(hkOwner, ADIS1650X::ADIS_CFG_DATASET_ID) {}
};
#endif /* MISSION_DEVICES_DEVICEDEFINITIONS_GYROADIS16507DEFINITIONS_H_ */

View File

@ -3,6 +3,7 @@
#include <fsfw/datapoollocal/StaticLocalDataSet.h>
#include <fsfw/devicehandlers/DeviceHandlerIF.h>
#include <cstdint>
namespace L3GD20H {
@ -36,8 +37,8 @@ static constexpr uint8_t SET_Z_ENABLE = 1 << 2;
static constexpr uint8_t SET_X_ENABLE = 1 << 1;
static constexpr uint8_t SET_Y_ENABLE = 1;
static constexpr uint8_t CTRL_REG_1_VAL = SET_POWER_NORMAL_MODE | SET_Z_ENABLE |
SET_Y_ENABLE | SET_X_ENABLE;
static constexpr uint8_t CTRL_REG_1_VAL =
SET_POWER_NORMAL_MODE | SET_Z_ENABLE | SET_Y_ENABLE | SET_X_ENABLE;
/* Register 2 */
static constexpr uint8_t EXTERNAL_EDGE_ENB = 1 << 7;
@ -101,40 +102,29 @@ static constexpr DeviceCommandId_t READ_CTRL_REGS = 2;
static constexpr uint32_t GYRO_DATASET_ID = READ_REGS;
enum GyroPoolIds: lp_id_t {
ANG_VELOC_X,
ANG_VELOC_Y,
ANG_VELOC_Z,
TEMPERATURE
enum GyroPoolIds : lp_id_t { ANG_VELOC_X, ANG_VELOC_Y, ANG_VELOC_Z, TEMPERATURE };
} // namespace L3GD20H
class GyroPrimaryDataset : public StaticLocalDataSet<5> {
public:
/** Constructor for data users like controllers */
GyroPrimaryDataset(object_id_t mgmId)
: StaticLocalDataSet(sid_t(mgmId, L3GD20H::GYRO_DATASET_ID)) {
setAllVariablesReadOnly();
}
/* Angular velocities in degrees per second (DPS) */
lp_var_t<float> angVelocX = lp_var_t<float>(sid.objectId, L3GD20H::ANG_VELOC_X, this);
lp_var_t<float> angVelocY = lp_var_t<float>(sid.objectId, L3GD20H::ANG_VELOC_Y, this);
lp_var_t<float> angVelocZ = lp_var_t<float>(sid.objectId, L3GD20H::ANG_VELOC_Z, this);
lp_var_t<float> temperature = lp_var_t<float>(sid.objectId, L3GD20H::TEMPERATURE, this);
private:
friend class GyroHandlerL3GD20H;
/** Constructor for the data creator */
GyroPrimaryDataset(HasLocalDataPoolIF* hkOwner)
: StaticLocalDataSet(hkOwner, L3GD20H::GYRO_DATASET_ID) {}
};
}
class GyroPrimaryDataset: public StaticLocalDataSet<5> {
public:
/** Constructor for data users like controllers */
GyroPrimaryDataset(object_id_t mgmId):
StaticLocalDataSet(sid_t(mgmId, L3GD20H::GYRO_DATASET_ID)) {
setAllVariablesReadOnly();
}
/* Angular velocities in degrees per second (DPS) */
lp_var_t<float> angVelocX = lp_var_t<float>(sid.objectId,
L3GD20H::ANG_VELOC_X, this);
lp_var_t<float> angVelocY = lp_var_t<float>(sid.objectId,
L3GD20H::ANG_VELOC_Y, this);
lp_var_t<float> angVelocZ = lp_var_t<float>(sid.objectId,
L3GD20H::ANG_VELOC_Z, this);
lp_var_t<float> temperature = lp_var_t<float>(sid.objectId,
L3GD20H::TEMPERATURE, this);
private:
friend class GyroHandlerL3GD20H;
/** Constructor for the data creator */
GyroPrimaryDataset(HasLocalDataPoolIF* hkOwner):
StaticLocalDataSet(hkOwner, L3GD20H::GYRO_DATASET_ID) {}
};
#endif /* MISSION_DEVICES_DEVICEDEFINITIONS_GYROL3GD20DEFINITIONS_H_ */

File diff suppressed because it is too large Load Diff

View File

@ -1,18 +1,15 @@
#ifndef MISSION_DEVICES_DEVICEDEFINITIONS_MAX13865DEFINITIONS_H_
#define MISSION_DEVICES_DEVICEDEFINITIONS_MAX13865DEFINITIONS_H_
#include <fsfw/datapoollocal/StaticLocalDataSet.h>
#include <fsfw/datapoollocal/LocalPoolVariable.h>
#include <fsfw/datapoollocal/StaticLocalDataSet.h>
#include <fsfw/devicehandlers/DeviceHandlerIF.h>
#include "objects/systemObjectList.h"
namespace Max31865Definitions {
enum PoolIds: lp_id_t {
RTD_VALUE,
TEMPERATURE_C,
FAULT_BYTE
};
enum PoolIds : lp_id_t { RTD_VALUE, TEMPERATURE_C, FAULT_BYTE };
static constexpr DeviceCommandId_t CONFIG_CMD = 0x80;
static constexpr DeviceCommandId_t WRITE_HIGH_THRESHOLD = 0x83;
@ -31,35 +28,26 @@ static constexpr uint8_t CLEAR_FAULT_BIT_VAL = 0b0000'0010;
static constexpr size_t MAX_REPLY_SIZE = 5;
class Max31865Set:
public StaticLocalDataSet<sizeof(float) + sizeof(uint8_t)> {
public:
/**
* Constructor used by owner and data creators like device handlers.
* @param owner
* @param setId
*/
Max31865Set(HasLocalDataPoolIF* owner):
StaticLocalDataSet(owner, MAX31865_SET_ID) {
}
class Max31865Set : public StaticLocalDataSet<sizeof(float) + sizeof(uint8_t)> {
public:
/**
* Constructor used by owner and data creators like device handlers.
* @param owner
* @param setId
*/
Max31865Set(HasLocalDataPoolIF* owner) : StaticLocalDataSet(owner, MAX31865_SET_ID) {}
/**
* Constructor used by data users like controllers.
* @param sid
*/
Max31865Set(object_id_t objectId):
StaticLocalDataSet(sid_t(objectId, MAX31865_SET_ID)) {
}
/**
* Constructor used by data users like controllers.
* @param sid
*/
Max31865Set(object_id_t objectId) : StaticLocalDataSet(sid_t(objectId, MAX31865_SET_ID)) {}
lp_var_t<float> rtdValue = lp_var_t<float>(sid.objectId,
PoolIds::RTD_VALUE, this);
lp_var_t<float> temperatureCelcius = lp_var_t<float>(sid.objectId,
PoolIds::TEMPERATURE_C, this);
lp_var_t<uint8_t> errorByte = lp_var_t<uint8_t>(sid.objectId,
PoolIds::FAULT_BYTE, this);
lp_var_t<float> rtdValue = lp_var_t<float>(sid.objectId, PoolIds::RTD_VALUE, this);
lp_var_t<float> temperatureCelcius = lp_var_t<float>(sid.objectId, PoolIds::TEMPERATURE_C, this);
lp_var_t<uint8_t> errorByte = lp_var_t<uint8_t>(sid.objectId, PoolIds::FAULT_BYTE, this);
};
}
} // namespace Max31865Definitions
#endif /* MISSION_DEVICES_DEVICEDEFINITIONS_MAX13865DEFINITIONS_H_ */

View File

@ -1,172 +1,166 @@
#ifndef MISSION_DEVICES_DEVICEDEFINITIONS_PLOCMPSOCDEFINITIONS_H_
#define MISSION_DEVICES_DEVICEDEFINITIONS_PLOCMPSOCDEFINITIONS_H_
#include <fsfw/tmtcpacket/SpacePacket.h>
#include <fsfw/globalfunctions/CRC.h>
#include <fsfw/serialize/SerializeAdapter.h>
#include <fsfw/tmtcpacket/SpacePacket.h>
namespace PLOC_MPSOC {
static const DeviceCommandId_t NONE = 0x0;
static const DeviceCommandId_t TC_MEM_WRITE = 0x1;
static const DeviceCommandId_t TC_MEM_READ = 0x2;
static const DeviceCommandId_t ACK_REPORT = 0x3;
static const DeviceCommandId_t EXE_REPORT = 0x5;
static const DeviceCommandId_t TM_MEMORY_READ_REPORT = 0x6;
static const DeviceCommandId_t NONE = 0x0;
static const DeviceCommandId_t TC_MEM_WRITE = 0x1;
static const DeviceCommandId_t TC_MEM_READ = 0x2;
static const DeviceCommandId_t ACK_REPORT = 0x3;
static const DeviceCommandId_t EXE_REPORT = 0x5;
static const DeviceCommandId_t TM_MEMORY_READ_REPORT = 0x6;
static const uint16_t SIZE_ACK_REPORT = 14;
static const uint16_t SIZE_EXE_REPORT = 14;
static const uint16_t SIZE_TM_MEM_READ_REPORT = 18;
static const uint16_t SIZE_ACK_REPORT = 14;
static const uint16_t SIZE_EXE_REPORT = 14;
static const uint16_t SIZE_TM_MEM_READ_REPORT = 18;
/**
* SpacePacket apids of PLOC telecommands and telemetry.
*/
static const uint16_t APID_TC_MEM_WRITE = 0x714;
static const uint16_t APID_TC_MEM_READ = 0x715;
static const uint16_t APID_TM_MEMORY_READ_REPORT = 0x404;
static const uint16_t APID_ACK_SUCCESS = 0x400;
static const uint16_t APID_ACK_FAILURE = 0x401;
static const uint16_t APID_EXE_SUCCESS = 0x402;
static const uint16_t APID_EXE_FAILURE = 0x403;
/**
* SpacePacket apids of PLOC telecommands and telemetry.
*/
static const uint16_t APID_TC_MEM_WRITE = 0x714;
static const uint16_t APID_TC_MEM_READ = 0x715;
static const uint16_t APID_TM_MEMORY_READ_REPORT = 0x404;
static const uint16_t APID_ACK_SUCCESS = 0x400;
static const uint16_t APID_ACK_FAILURE = 0x401;
static const uint16_t APID_EXE_SUCCESS = 0x402;
static const uint16_t APID_EXE_FAILURE = 0x403;
/** Offset from first byte in Space packet to first byte of data field */
static const uint8_t DATA_FIELD_OFFSET = 6;
/** Offset from first byte in Space packet to first byte of data field */
static const uint8_t DATA_FIELD_OFFSET = 6;
/**
* The size of payload data which will be forwarded to the requesting object. e.g. PUS Service
* 8.
*/
static const uint8_t SIZE_MEM_READ_REPORT_DATA = 10;
/**
* The size of payload data which will be forwarded to the requesting object. e.g. PUS Service
* 8.
*/
static const uint8_t SIZE_MEM_READ_REPORT_DATA = 10;
/**
* PLOC space packet length for fixed size packets. This is the size of the whole packet data
* field. For the length field in the space packet this size will be substracted by one.
*/
static const uint16_t LENGTH_TC_MEM_WRITE = 12;
static const uint16_t LENGTH_TC_MEM_READ = 8;
/**
* PLOC space packet length for fixed size packets. This is the size of the whole packet data
* field. For the length field in the space packet this size will be substracted by one.
*/
static const uint16_t LENGTH_TC_MEM_WRITE = 12;
static const uint16_t LENGTH_TC_MEM_READ = 8;
static const size_t MAX_REPLY_SIZE = SIZE_TM_MEM_READ_REPORT;
static const size_t MAX_COMMAND_SIZE = 18;
static const size_t MAX_REPLY_SIZE = SIZE_TM_MEM_READ_REPORT;
static const size_t MAX_COMMAND_SIZE = 18;
/**
* @brief This class helps to build the memory read command for the PLOC.
*
* @details The last two bytes of the packet data field contain a CRC calculated over the whole
* space packet. This is the CRC-16-CCITT as specified in
* ECSS-E-ST-70-41C Telemetry and telecommand packet utilization.
*/
class TcMemRead : public SpacePacket {
public:
/**
* @brief This class helps to build the memory read command for the PLOC.
*
* @details The last two bytes of the packet data field contain a CRC calculated over the whole
* space packet. This is the CRC-16-CCITT as specified in
* ECSS-E-ST-70-41C Telemetry and telecommand packet utilization.
*/
class TcMemRead : public SpacePacket {
public:
/**
* @brief Constructor
*
* @param memAddr The memory address to read from.
*/
TcMemRead(const uint32_t memAddr, uint16_t sequenceCount)
: SpacePacket(LENGTH_TC_MEM_READ - 1, true, APID_TC_MEM_READ, sequenceCount) {
fillPacketDataField(&memAddr);
}
/**
* @brief Constructor
*
* @param memAddr The memory address to read from.
*/
TcMemRead(const uint32_t memAddr, uint16_t sequenceCount) :
SpacePacket(LENGTH_TC_MEM_READ - 1, true, APID_TC_MEM_READ, sequenceCount) {
fillPacketDataField(&memAddr);
}
private:
/**
* @brief This function builds the packet data field for the mem read command.
*
* @param memAddrPtr Pointer to the memory address to read from.
*/
void fillPacketDataField(const uint32_t* memAddrPtr) {
/* Add memAddr to packet data field */
size_t serializedSize = 0;
uint8_t* memoryAddressPos = this->localData.fields.buffer;
SerializeAdapter::serialize<uint32_t>(memAddrPtr, &memoryAddressPos, &serializedSize,
sizeof(*memAddrPtr), SerializeIF::Endianness::LITTLE);
private:
/* Add memLen to packet data field */
this->localData.fields.buffer[OFFSET_MEM_LEN_FIELD] = 1;
this->localData.fields.buffer[OFFSET_MEM_LEN_FIELD + 1] = 0;
/**
* @brief This function builds the packet data field for the mem read command.
*
* @param memAddrPtr Pointer to the memory address to read from.
*/
void fillPacketDataField(const uint32_t* memAddrPtr) {
/* Add memAddr to packet data field */
size_t serializedSize = 0;
uint8_t* memoryAddressPos = this->localData.fields.buffer;
SerializeAdapter::serialize<uint32_t>(memAddrPtr, &memoryAddressPos, &serializedSize,
sizeof(*memAddrPtr), SerializeIF::Endianness::LITTLE);
/* Calculate crc */
uint16_t crc = CRC::crc16ccitt(this->localData.byteStream,
sizeof(CCSDSPrimaryHeader) + LENGTH_TC_MEM_READ - CRC_SIZE);
/* Add memLen to packet data field */
this->localData.fields.buffer[OFFSET_MEM_LEN_FIELD] = 1;
this->localData.fields.buffer[OFFSET_MEM_LEN_FIELD + 1] = 0;
/* Add crc to packet data field of space packet */
serializedSize = 0;
uint8_t* crcPos = this->localData.fields.buffer + CRC_OFFSET;
SerializeAdapter::serialize<uint16_t>(&crc, &crcPos, &serializedSize, sizeof(crc),
SerializeIF::Endianness::BIG);
}
/* Calculate crc */
uint16_t crc = CRC::crc16ccitt(this->localData.byteStream,
sizeof(CCSDSPrimaryHeader) + LENGTH_TC_MEM_READ - CRC_SIZE);
static const uint8_t OFFSET_MEM_LEN_FIELD = 4;
static const uint8_t CRC_OFFSET = 6;
};
/* Add crc to packet data field of space packet */
serializedSize = 0;
uint8_t* crcPos = this->localData.fields.buffer + CRC_OFFSET;
SerializeAdapter::serialize<uint16_t>(&crc, &crcPos, &serializedSize,
sizeof(crc), SerializeIF::Endianness::BIG);
}
/**
* @brief This class helps to generate the space packet to write to a memory address within
* the PLOC.
* @details The last two bytes of the packet data field contain a CRC calculated over the whole
* space packet. This is the CRC-16-CCITT as specified in
* ECSS-E-ST-70-41C Telemetry and telecommand packet utilization.
*/
class TcMemWrite : public SpacePacket {
public:
/**
* @brief Constructor
*
* @param memAddr The PLOC memory address where to write to.
* @param memoryData The data to write to the specified memory address.
* @param sequenceCount The subsequence count. Must be incremented with each new packet.
*/
TcMemWrite(const uint32_t memAddr, const uint32_t memoryData, uint16_t sequenceCount)
: SpacePacket(LENGTH_TC_MEM_WRITE - 1, true, APID_TC_MEM_WRITE, sequenceCount) {
fillPacketDataField(&memAddr, &memoryData);
}
static const uint8_t OFFSET_MEM_LEN_FIELD = 4;
static const uint8_t CRC_OFFSET = 6;
private:
/**
* @brief This function builds the packet data field for the mem write command.
*
* @param memAddrPtr Pointer to the PLOC memory address where to write to.
* @param memoryDataPtr Pointer to the memoryData to write
*/
void fillPacketDataField(const uint32_t* memAddrPtr, const uint32_t* memoryDataPtr) {
/* Add memAddr to packet data field */
size_t serializedSize = 0;
uint8_t* memoryAddressPos = this->localData.fields.buffer;
SerializeAdapter::serialize<uint32_t>(memAddrPtr, &memoryAddressPos, &serializedSize,
sizeof(*memAddrPtr), SerializeIF::Endianness::BIG);
};
/* Add memLen to packet data field */
this->localData.fields.buffer[OFFSET_MEM_LEN_FIELD] = 1;
this->localData.fields.buffer[OFFSET_MEM_LEN_FIELD + 1] = 0;
/**
* @brief This class helps to generate the space packet to write to a memory address within
* the PLOC.
* @details The last two bytes of the packet data field contain a CRC calculated over the whole
* space packet. This is the CRC-16-CCITT as specified in
* ECSS-E-ST-70-41C Telemetry and telecommand packet utilization.
*/
class TcMemWrite : public SpacePacket {
public:
/**
* @brief Constructor
*
* @param memAddr The PLOC memory address where to write to.
* @param memoryData The data to write to the specified memory address.
* @param sequenceCount The subsequence count. Must be incremented with each new packet.
*/
TcMemWrite(const uint32_t memAddr, const uint32_t memoryData, uint16_t sequenceCount) :
SpacePacket(LENGTH_TC_MEM_WRITE - 1, true, APID_TC_MEM_WRITE, sequenceCount) {
fillPacketDataField(&memAddr, &memoryData);
}
/* Add memData to packet data field */
serializedSize = 0;
uint8_t* memoryDataPos = this->localData.fields.buffer + OFFSET_MEM_DATA_FIELD;
SerializeAdapter::serialize<uint32_t>(memoryDataPtr, &memoryDataPos, &serializedSize,
sizeof(*memoryDataPtr), SerializeIF::Endianness::BIG);
private:
/* Calculate crc */
uint16_t crc = CRC::crc16ccitt(this->localData.byteStream,
sizeof(CCSDSPrimaryHeader) + LENGTH_TC_MEM_WRITE - CRC_SIZE);
/**
* @brief This function builds the packet data field for the mem write command.
*
* @param memAddrPtr Pointer to the PLOC memory address where to write to.
* @param memoryDataPtr Pointer to the memoryData to write
*/
void fillPacketDataField(const uint32_t* memAddrPtr, const uint32_t* memoryDataPtr) {
serializedSize = 0;
uint8_t* crcPos = this->localData.fields.buffer + CRC_OFFSET;
/* Add crc to packet data field of space packet */
SerializeAdapter::serialize<uint16_t>(&crc, &crcPos, &serializedSize, sizeof(crc),
SerializeIF::Endianness::BIG);
}
/* Add memAddr to packet data field */
size_t serializedSize = 0;
uint8_t* memoryAddressPos = this->localData.fields.buffer;
SerializeAdapter::serialize<uint32_t>(memAddrPtr, &memoryAddressPos, &serializedSize,
sizeof(*memAddrPtr), SerializeIF::Endianness::BIG);
/* Add memLen to packet data field */
this->localData.fields.buffer[OFFSET_MEM_LEN_FIELD] = 1;
this->localData.fields.buffer[OFFSET_MEM_LEN_FIELD + 1] = 0;
/* Add memData to packet data field */
serializedSize = 0;
uint8_t* memoryDataPos = this->localData.fields.buffer + OFFSET_MEM_DATA_FIELD;
SerializeAdapter::serialize<uint32_t>(memoryDataPtr, &memoryDataPos, &serializedSize,
sizeof(*memoryDataPtr), SerializeIF::Endianness::BIG);
/* Calculate crc */
uint16_t crc = CRC::crc16ccitt(this->localData.byteStream,
sizeof(CCSDSPrimaryHeader) + LENGTH_TC_MEM_WRITE - CRC_SIZE);
serializedSize = 0;
uint8_t* crcPos = this->localData.fields.buffer + CRC_OFFSET;
/* Add crc to packet data field of space packet */
SerializeAdapter::serialize<uint16_t>(&crc, &crcPos, &serializedSize,
sizeof(crc), SerializeIF::Endianness::BIG);
}
/** Offsets from base address of packet data field */
static const uint8_t OFFSET_MEM_LEN_FIELD = 4;
static const uint8_t OFFSET_MEM_DATA_FIELD = 6;
static const uint8_t CRC_OFFSET = 10;
};
}
/** Offsets from base address of packet data field */
static const uint8_t OFFSET_MEM_LEN_FIELD = 4;
static const uint8_t OFFSET_MEM_DATA_FIELD = 6;
static const uint8_t CRC_OFFSET = 10;
};
} // namespace PLOC_MPSOC
#endif /* MISSION_DEVICES_DEVICEDEFINITIONS_PLOCMPSOCDEFINITIONS_H_ */

View File

@ -3,84 +3,79 @@
namespace RAD_SENSOR {
static const DeviceCommandId_t NONE = 0x0; // Set when no command is pending
static const DeviceCommandId_t NONE = 0x0; // Set when no command is pending
/**
* This command initiates the ADC conversion for all channels including the internal
* temperature sensor.
*/
static const DeviceCommandId_t WRITE_SETUP = 0x1;
static const DeviceCommandId_t START_CONVERSION = 0x2;
static const DeviceCommandId_t READ_CONVERSIONS = 0x3;
/**
* This command initiates the ADC conversion for all channels including the internal
* temperature sensor.
*/
static const DeviceCommandId_t WRITE_SETUP = 0x1;
static const DeviceCommandId_t START_CONVERSION = 0x2;
static const DeviceCommandId_t READ_CONVERSIONS = 0x3;
/**
* @brief This is the configuration byte which will be written to the setup register after
* power on.
*
* @note Bit1 (DIFFSEL1) - Bit0 (DIFFSEL0): 0b00, no data follows the setup byte
* Bit3 (REFSEL1) - Bit2 (REFSEL0): 0b10, internal reference, no wake-up delay
* Bit5 (CLKSEL1) - Bit4 (CLKSEL0): 0b10, MAX1227 uses internal oscillator for timing
* Bit7 - Bit6: 0b01, tells MAX1227 that this is the setup register
*
*/
static const uint8_t SETUP_DEFINITION = 0b01101000;
/**
* @brief This is the configuration byte which will be written to the setup register after
* power on.
*
* @note Bit1 (DIFFSEL1) - Bit0 (DIFFSEL0): 0b00, no data follows the setup byte
* Bit3 (REFSEL1) - Bit2 (REFSEL0): 0b10, internal reference, no wake-up delay
* Bit5 (CLKSEL1) - Bit4 (CLKSEL0): 0b10, MAX1227 uses internal oscillator for timing
* Bit7 - Bit6: 0b01, tells MAX1227 that this is the setup register
*
*/
static const uint8_t SETUP_DEFINITION = 0b01101000;
/**
* @brief This value will always be written to the ADC conversion register to specify the
* conversions to perform.
* @details Bit0: 1 - Enables temperature conversion
* Bit2 (SCAN1) and Bit1 (SCAN0): 0b00 (channel conversion from 0 to N)
* Bit6 - Bit3 defines N: 0b0111 (N = 7)
* Bit7: Always 1. Tells the ADC that this is the conversion register.
*/
static const uint8_t CONVERSION_DEFINITION = 0b10111001;
/**
* @brief This value will always be written to the ADC conversion register to specify the
* conversions to perform.
* @details Bit0: 1 - Enables temperature conversion
* Bit2 (SCAN1) and Bit1 (SCAN0): 0b00 (channel conversion from 0 to N)
* Bit6 - Bit3 defines N: 0b0111 (N = 7)
* Bit7: Always 1. Tells the ADC that this is the conversion register.
*/
static const uint8_t CONVERSION_DEFINITION = 0b10111001;
// static const uint8_t CONVERSION_DEFINITION = 0b10111111;
/**
* @brief Writing this value resets the fifo of the MAX1227.
*/
static const uint8_t RESET_DEFINITION = 0b00011000;
/**
* @brief Writing this value resets the fifo of the MAX1227.
*/
static const uint8_t RESET_DEFINITION = 0b00011000;
static const uint8_t DUMMY_BYTE = 0xFF;
static const uint8_t DUMMY_BYTE = 0xFF;
static const uint8_t RAD_SENSOR_DATA_SET_ID = READ_CONVERSIONS;
static const uint8_t RAD_SENSOR_DATA_SET_ID = READ_CONVERSIONS;
static const uint8_t DATASET_ENTRIES = 7;
/**
* One temperature value and conversions for AIN0 - AIN7
*/
static const uint8_t READ_SIZE = 18;
static const uint8_t DATASET_ENTRIES = 7;
/**
* One temperature value and conversions for AIN0 - AIN7
*/
static const uint8_t READ_SIZE = 18;
enum Max1227PoolIds: lp_id_t {
TEMPERATURE_C,
AIN0,
AIN1,
AIN4,
AIN5,
AIN6,
AIN7,
};
class RadSensorDataset: public StaticLocalDataSet<DATASET_ENTRIES> {
public:
RadSensorDataset(HasLocalDataPoolIF* owner) :
StaticLocalDataSet(owner, RAD_SENSOR_DATA_SET_ID) {
}
RadSensorDataset(object_id_t objectId) :
StaticLocalDataSet(sid_t(objectId, RAD_SENSOR_DATA_SET_ID)) {
}
lp_var_t<float> temperatureCelcius = lp_var_t<float>(sid.objectId, TEMPERATURE_C, this);
lp_var_t<uint16_t> ain0 = lp_var_t<uint16_t>(sid.objectId, AIN0, this);
lp_var_t<uint16_t> ain1 = lp_var_t<uint16_t>(sid.objectId, AIN1, this);
lp_var_t<uint16_t> ain4 = lp_var_t<uint16_t>(sid.objectId, AIN4, this);
lp_var_t<uint16_t> ain5 = lp_var_t<uint16_t>(sid.objectId, AIN5, this);
lp_var_t<uint16_t> ain6 = lp_var_t<uint16_t>(sid.objectId, AIN6, this);
lp_var_t<uint16_t> ain7 = lp_var_t<uint16_t>(sid.objectId, AIN7, this);
enum Max1227PoolIds : lp_id_t {
TEMPERATURE_C,
AIN0,
AIN1,
AIN4,
AIN5,
AIN6,
AIN7,
};
}
class RadSensorDataset : public StaticLocalDataSet<DATASET_ENTRIES> {
public:
RadSensorDataset(HasLocalDataPoolIF* owner) : StaticLocalDataSet(owner, RAD_SENSOR_DATA_SET_ID) {}
RadSensorDataset(object_id_t objectId)
: StaticLocalDataSet(sid_t(objectId, RAD_SENSOR_DATA_SET_ID)) {}
lp_var_t<float> temperatureCelcius = lp_var_t<float>(sid.objectId, TEMPERATURE_C, this);
lp_var_t<uint16_t> ain0 = lp_var_t<uint16_t>(sid.objectId, AIN0, this);
lp_var_t<uint16_t> ain1 = lp_var_t<uint16_t>(sid.objectId, AIN1, this);
lp_var_t<uint16_t> ain4 = lp_var_t<uint16_t>(sid.objectId, AIN4, this);
lp_var_t<uint16_t> ain5 = lp_var_t<uint16_t>(sid.objectId, AIN5, this);
lp_var_t<uint16_t> ain6 = lp_var_t<uint16_t>(sid.objectId, AIN6, this);
lp_var_t<uint16_t> ain7 = lp_var_t<uint16_t>(sid.objectId, AIN7, this);
};
} // namespace RAD_SENSOR
#endif /* MISSION_DEVICES_DEVICEDEFINITIONS_RADSENSOR_H_ */

View File

@ -1,66 +1,61 @@
#ifndef MISSION_DEVICES_DEVICEDEFINITIONS_RWDEFINITIONS_H_
#define MISSION_DEVICES_DEVICEDEFINITIONS_RWDEFINITIONS_H_
#include <fsfw/datapoollocal/StaticLocalDataSet.h>
#include <fsfw/datapoollocal/LocalPoolVariable.h>
#include <fsfw/datapoollocal/StaticLocalDataSet.h>
#include <fsfw/devicehandlers/DeviceHandlerIF.h>
#include "objects/systemObjectList.h"
namespace RwDefinitions {
static const uint32_t SPI_REPLY_DELAY = 70000; //us
static const uint32_t SPI_REPLY_DELAY = 70000; // us
enum PoolIds: lp_id_t {
TEMPERATURE_C,
CURR_SPEED,
REFERENCE_SPEED,
STATE,
CLC_MODE,
LAST_RESET_STATUS,
CURRRENT_RESET_STATUS,
TM_LAST_RESET_STATUS,
TM_MCU_TEMPERATURE,
PRESSURE_SENSOR_TEMPERATURE,
PRESSURE,
TM_RW_STATE,
TM_CLC_MODE,
TM_RW_CURR_SPEED,
TM_RW_REF_SPEED,
INVALID_CRC_PACKETS,
INVALID_LEN_PACKETS,
INVALID_CMD_PACKETS,
EXECUTED_REPLIES,
COMMAND_REPLIES,
UART_BYTES_WRITTEN,
UART_BYTES_READ,
UART_PARITY_ERRORS,
UART_NOISE_ERRORS,
UART_FRAME_ERRORS,
UART_REG_OVERRUN_ERRORS,
UART_TOTAL_ERRORS,
TOTAL_ERRORS,
SPI_BYTES_WRITTEN,
SPI_BYTES_READ,
SPI_REG_OVERRUN_ERRORS,
SPI_TOTAL_ERRORS
enum PoolIds : lp_id_t {
TEMPERATURE_C,
CURR_SPEED,
REFERENCE_SPEED,
STATE,
CLC_MODE,
LAST_RESET_STATUS,
CURRRENT_RESET_STATUS,
TM_LAST_RESET_STATUS,
TM_MCU_TEMPERATURE,
PRESSURE_SENSOR_TEMPERATURE,
PRESSURE,
TM_RW_STATE,
TM_CLC_MODE,
TM_RW_CURR_SPEED,
TM_RW_REF_SPEED,
INVALID_CRC_PACKETS,
INVALID_LEN_PACKETS,
INVALID_CMD_PACKETS,
EXECUTED_REPLIES,
COMMAND_REPLIES,
UART_BYTES_WRITTEN,
UART_BYTES_READ,
UART_PARITY_ERRORS,
UART_NOISE_ERRORS,
UART_FRAME_ERRORS,
UART_REG_OVERRUN_ERRORS,
UART_TOTAL_ERRORS,
TOTAL_ERRORS,
SPI_BYTES_WRITTEN,
SPI_BYTES_READ,
SPI_REG_OVERRUN_ERRORS,
SPI_TOTAL_ERRORS
};
enum States: uint8_t {
STATE_ERROR,
IDLE,
COASTING,
RUNNING_SPEED_STABLE,
RUNNING_SPEED_CHANGING
};
enum States : uint8_t { STATE_ERROR, IDLE, COASTING, RUNNING_SPEED_STABLE, RUNNING_SPEED_CHANGING };
enum LastResetStatus: uint8_t {
CLEARED = 0,
PIN_RESET = 1,
POR_PDR_BOR_RESET = 2,
SOFTWARE_RESET = 4,
INDEPENDENT_WATCHDOG_RESET = 8,
WINDOW_WATCHDOG_RESET = 16,
LOW_POWER_RESET = 32
enum LastResetStatus : uint8_t {
CLEARED = 0,
PIN_RESET = 1,
POR_PDR_BOR_RESET = 2,
SOFTWARE_RESET = 4,
INDEPENDENT_WATCHDOG_RESET = 8,
WINDOW_WATCHDOG_RESET = 16,
LOW_POWER_RESET = 32
};
static const DeviceCommandId_t RESET_MCU = 1;
@ -103,66 +98,45 @@ static const uint8_t TM_SET_ENTRIES = 24;
/**
* @brief This dataset can be used to store the temperature of a reaction wheel.
*/
class TemperatureSet:
public StaticLocalDataSet<TEMPERATURE_SET_ENTRIES> {
public:
class TemperatureSet : public StaticLocalDataSet<TEMPERATURE_SET_ENTRIES> {
public:
TemperatureSet(HasLocalDataPoolIF* owner) : StaticLocalDataSet(owner, TEMPERATURE_SET_ID) {}
TemperatureSet(HasLocalDataPoolIF* owner):
StaticLocalDataSet(owner, TEMPERATURE_SET_ID) {
}
TemperatureSet(object_id_t objectId) : StaticLocalDataSet(sid_t(objectId, TEMPERATURE_SET_ID)) {}
TemperatureSet(object_id_t objectId):
StaticLocalDataSet(sid_t(objectId, TEMPERATURE_SET_ID)) {
}
lp_var_t<int32_t> temperatureCelcius = lp_var_t<int32_t>(sid.objectId,
PoolIds::TEMPERATURE_C, this);
lp_var_t<int32_t> temperatureCelcius =
lp_var_t<int32_t>(sid.objectId, PoolIds::TEMPERATURE_C, this);
};
/**
* @brief This dataset can be used to store the reaction wheel status.
*/
class StatusSet:
public StaticLocalDataSet<STATUS_SET_ENTRIES> {
public:
class StatusSet : public StaticLocalDataSet<STATUS_SET_ENTRIES> {
public:
StatusSet(HasLocalDataPoolIF* owner) : StaticLocalDataSet(owner, STATUS_SET_ID) {}
StatusSet(HasLocalDataPoolIF* owner):
StaticLocalDataSet(owner, STATUS_SET_ID) {
}
StatusSet(object_id_t objectId) : StaticLocalDataSet(sid_t(objectId, STATUS_SET_ID)) {}
StatusSet(object_id_t objectId):
StaticLocalDataSet(sid_t(objectId, STATUS_SET_ID)) {
}
lp_var_t<int32_t> currSpeed = lp_var_t<int32_t>(sid.objectId,
PoolIds::CURR_SPEED, this);
lp_var_t<int32_t> referenceSpeed = lp_var_t<int32_t>(sid.objectId,
PoolIds::REFERENCE_SPEED, this);
lp_var_t<uint8_t> state = lp_var_t<uint8_t>(sid.objectId,
PoolIds::STATE, this);
lp_var_t<uint8_t> clcMode = lp_var_t<uint8_t>(sid.objectId,
PoolIds::CLC_MODE, this);
lp_var_t<int32_t> currSpeed = lp_var_t<int32_t>(sid.objectId, PoolIds::CURR_SPEED, this);
lp_var_t<int32_t> referenceSpeed =
lp_var_t<int32_t>(sid.objectId, PoolIds::REFERENCE_SPEED, this);
lp_var_t<uint8_t> state = lp_var_t<uint8_t>(sid.objectId, PoolIds::STATE, this);
lp_var_t<uint8_t> clcMode = lp_var_t<uint8_t>(sid.objectId, PoolIds::CLC_MODE, this);
};
/**
* @brief This dataset stores the last reset status.
*/
class LastResetSatus:
public StaticLocalDataSet<LAST_RESET_ENTRIES> {
public:
class LastResetSatus : public StaticLocalDataSet<LAST_RESET_ENTRIES> {
public:
LastResetSatus(HasLocalDataPoolIF* owner) : StaticLocalDataSet(owner, LAST_RESET_ID) {}
LastResetSatus(HasLocalDataPoolIF* owner):
StaticLocalDataSet(owner, LAST_RESET_ID) {
}
LastResetSatus(object_id_t objectId) : StaticLocalDataSet(sid_t(objectId, LAST_RESET_ID)) {}
LastResetSatus(object_id_t objectId):
StaticLocalDataSet(sid_t(objectId, LAST_RESET_ID)) {
}
lp_var_t<uint8_t> lastResetStatus = lp_var_t<uint8_t>(sid.objectId,
PoolIds::LAST_RESET_STATUS, this);
lp_var_t<uint8_t> currentResetStatus = lp_var_t<uint8_t>(sid.objectId,
PoolIds::CURRRENT_RESET_STATUS, this);
lp_var_t<uint8_t> lastResetStatus =
lp_var_t<uint8_t>(sid.objectId, PoolIds::LAST_RESET_STATUS, this);
lp_var_t<uint8_t> currentResetStatus =
lp_var_t<uint8_t>(sid.objectId, PoolIds::CURRRENT_RESET_STATUS, this);
};
/**
@ -170,69 +144,57 @@ public:
* reaction wheels. https://eive-cloud.irs.uni-stuttgart.de/index.php/apps/files/?dir=/
* EIVE_IRS/Arbeitsdaten/08_Used%20Components/Nanoavionics_Reactionwheels&fileid=181622
*/
class TmDataset:
public StaticLocalDataSet<TM_SET_ENTRIES> {
public:
class TmDataset : public StaticLocalDataSet<TM_SET_ENTRIES> {
public:
TmDataset(HasLocalDataPoolIF* owner) : StaticLocalDataSet(owner, TM_SET_ID) {}
TmDataset(HasLocalDataPoolIF* owner):
StaticLocalDataSet(owner, TM_SET_ID) {
}
TmDataset(object_id_t objectId) : StaticLocalDataSet(sid_t(objectId, TM_SET_ID)) {}
TmDataset(object_id_t objectId):
StaticLocalDataSet(sid_t(objectId, TM_SET_ID)) {
}
lp_var_t<uint8_t> lastResetStatus = lp_var_t<uint8_t>(sid.objectId,
PoolIds::TM_LAST_RESET_STATUS, this);
lp_var_t<int32_t> mcuTemperature = lp_var_t<int32_t>(sid.objectId,
PoolIds::TM_MCU_TEMPERATURE, this);
lp_var_t<float> pressureSensorTemperature = lp_var_t<float>(sid.objectId,
PoolIds::PRESSURE_SENSOR_TEMPERATURE, this);
lp_var_t<float> pressure = lp_var_t<float>(sid.objectId,
PoolIds::PRESSURE, this);
lp_var_t<uint8_t> rwState = lp_var_t<uint8_t>(sid.objectId,
PoolIds::TM_RW_STATE, this);
lp_var_t<uint8_t> rwClcMode = lp_var_t<uint8_t>(sid.objectId,
PoolIds::TM_CLC_MODE, this);
lp_var_t<int32_t> rwCurrSpeed = lp_var_t<int32_t>(sid.objectId,
PoolIds::TM_RW_CURR_SPEED, this);
lp_var_t<int32_t> rwRefSpeed = lp_var_t<int32_t>(sid.objectId,
PoolIds::TM_RW_REF_SPEED, this);
lp_var_t<uint32_t> numOfInvalidCrcPackets = lp_var_t<uint32_t>(sid.objectId,
PoolIds::INVALID_CRC_PACKETS, this);
lp_var_t<uint32_t> numOfInvalidLenPackets = lp_var_t<uint32_t>(sid.objectId,
PoolIds::INVALID_LEN_PACKETS, this);
lp_var_t<uint32_t> numOfInvalidCmdPackets = lp_var_t<uint32_t>(sid.objectId,
PoolIds::INVALID_CMD_PACKETS, this);
lp_var_t<uint32_t> numOfCmdExecutedReplies = lp_var_t<uint32_t>(sid.objectId,
PoolIds::EXECUTED_REPLIES, this);
lp_var_t<uint32_t> numOfCmdReplies = lp_var_t<uint32_t>(sid.objectId,
PoolIds::COMMAND_REPLIES, this);
lp_var_t<uint32_t> uartNumOfBytesWritten = lp_var_t<uint32_t>(sid.objectId,
PoolIds::UART_BYTES_WRITTEN, this);
lp_var_t<uint32_t> uartNumOfBytesRead = lp_var_t<uint32_t>(sid.objectId,
PoolIds::UART_BYTES_READ, this);
lp_var_t<uint32_t> uartNumOfParityErrors = lp_var_t<uint32_t>(sid.objectId,
PoolIds::UART_PARITY_ERRORS, this);
lp_var_t<uint32_t> uartNumOfNoiseErrors = lp_var_t<uint32_t>(sid.objectId,
PoolIds::UART_NOISE_ERRORS, this);
lp_var_t<uint32_t> uartNumOfFrameErrors = lp_var_t<uint32_t>(sid.objectId,
PoolIds::UART_FRAME_ERRORS, this);
lp_var_t<uint32_t> uartNumOfRegisterOverrunErrors = lp_var_t<uint32_t>(sid.objectId,
PoolIds::UART_REG_OVERRUN_ERRORS, this);
lp_var_t<uint32_t> uartTotalNumOfErrors = lp_var_t<uint32_t>(sid.objectId,
PoolIds::UART_TOTAL_ERRORS, this);
lp_var_t<uint32_t> spiNumOfBytesWritten = lp_var_t<uint32_t>(sid.objectId,
PoolIds::SPI_BYTES_WRITTEN, this);
lp_var_t<uint32_t> spiNumOfBytesRead = lp_var_t<uint32_t>(sid.objectId,
PoolIds::SPI_BYTES_READ, this);
lp_var_t<uint32_t> spiNumOfRegisterOverrunErrors = lp_var_t<uint32_t>(sid.objectId,
PoolIds::SPI_REG_OVERRUN_ERRORS, this);
lp_var_t<uint32_t> spiTotalNumOfErrors = lp_var_t<uint32_t>(sid.objectId,
PoolIds::SPI_TOTAL_ERRORS, this);
lp_var_t<uint8_t> lastResetStatus =
lp_var_t<uint8_t>(sid.objectId, PoolIds::TM_LAST_RESET_STATUS, this);
lp_var_t<int32_t> mcuTemperature =
lp_var_t<int32_t>(sid.objectId, PoolIds::TM_MCU_TEMPERATURE, this);
lp_var_t<float> pressureSensorTemperature =
lp_var_t<float>(sid.objectId, PoolIds::PRESSURE_SENSOR_TEMPERATURE, this);
lp_var_t<float> pressure = lp_var_t<float>(sid.objectId, PoolIds::PRESSURE, this);
lp_var_t<uint8_t> rwState = lp_var_t<uint8_t>(sid.objectId, PoolIds::TM_RW_STATE, this);
lp_var_t<uint8_t> rwClcMode = lp_var_t<uint8_t>(sid.objectId, PoolIds::TM_CLC_MODE, this);
lp_var_t<int32_t> rwCurrSpeed = lp_var_t<int32_t>(sid.objectId, PoolIds::TM_RW_CURR_SPEED, this);
lp_var_t<int32_t> rwRefSpeed = lp_var_t<int32_t>(sid.objectId, PoolIds::TM_RW_REF_SPEED, this);
lp_var_t<uint32_t> numOfInvalidCrcPackets =
lp_var_t<uint32_t>(sid.objectId, PoolIds::INVALID_CRC_PACKETS, this);
lp_var_t<uint32_t> numOfInvalidLenPackets =
lp_var_t<uint32_t>(sid.objectId, PoolIds::INVALID_LEN_PACKETS, this);
lp_var_t<uint32_t> numOfInvalidCmdPackets =
lp_var_t<uint32_t>(sid.objectId, PoolIds::INVALID_CMD_PACKETS, this);
lp_var_t<uint32_t> numOfCmdExecutedReplies =
lp_var_t<uint32_t>(sid.objectId, PoolIds::EXECUTED_REPLIES, this);
lp_var_t<uint32_t> numOfCmdReplies =
lp_var_t<uint32_t>(sid.objectId, PoolIds::COMMAND_REPLIES, this);
lp_var_t<uint32_t> uartNumOfBytesWritten =
lp_var_t<uint32_t>(sid.objectId, PoolIds::UART_BYTES_WRITTEN, this);
lp_var_t<uint32_t> uartNumOfBytesRead =
lp_var_t<uint32_t>(sid.objectId, PoolIds::UART_BYTES_READ, this);
lp_var_t<uint32_t> uartNumOfParityErrors =
lp_var_t<uint32_t>(sid.objectId, PoolIds::UART_PARITY_ERRORS, this);
lp_var_t<uint32_t> uartNumOfNoiseErrors =
lp_var_t<uint32_t>(sid.objectId, PoolIds::UART_NOISE_ERRORS, this);
lp_var_t<uint32_t> uartNumOfFrameErrors =
lp_var_t<uint32_t>(sid.objectId, PoolIds::UART_FRAME_ERRORS, this);
lp_var_t<uint32_t> uartNumOfRegisterOverrunErrors =
lp_var_t<uint32_t>(sid.objectId, PoolIds::UART_REG_OVERRUN_ERRORS, this);
lp_var_t<uint32_t> uartTotalNumOfErrors =
lp_var_t<uint32_t>(sid.objectId, PoolIds::UART_TOTAL_ERRORS, this);
lp_var_t<uint32_t> spiNumOfBytesWritten =
lp_var_t<uint32_t>(sid.objectId, PoolIds::SPI_BYTES_WRITTEN, this);
lp_var_t<uint32_t> spiNumOfBytesRead =
lp_var_t<uint32_t>(sid.objectId, PoolIds::SPI_BYTES_READ, this);
lp_var_t<uint32_t> spiNumOfRegisterOverrunErrors =
lp_var_t<uint32_t>(sid.objectId, PoolIds::SPI_REG_OVERRUN_ERRORS, this);
lp_var_t<uint32_t> spiTotalNumOfErrors =
lp_var_t<uint32_t>(sid.objectId, PoolIds::SPI_TOTAL_ERRORS, this);
};
}
} // namespace RwDefinitions
#endif /* MISSION_DEVICES_DEVICEDEFINITIONS_RWDEFINITIONS_H_ */

View File

@ -1,101 +1,88 @@
#ifndef MISSION_DEVICES_DEVICEDEFINITIONS_SYRLINKSDEFINITIONS_H_
#define MISSION_DEVICES_DEVICEDEFINITIONS_SYRLINKSDEFINITIONS_H_
namespace SYRLINKS {
static const DeviceCommandId_t NONE = 0x0;
static const DeviceCommandId_t RESET_UNIT = 0x01;
/** Reads out all status registers */
static const DeviceCommandId_t READ_RX_STATUS_REGISTERS = 0x02;
/** Sets Tx mode to standby */
static const DeviceCommandId_t SET_TX_MODE_STANDBY = 0x03;
/** Starts transmission mode. Only reached when clock signal is applying to the data tx input */
static const DeviceCommandId_t SET_TX_MODE_MODULATION = 0x04;
/** Sends out a single carrier wave for testing purpose */
static const DeviceCommandId_t SET_TX_MODE_CW = 0x05;
static const DeviceCommandId_t ACK_REPLY = 0x06;
static const DeviceCommandId_t READ_TX_STATUS = 0x07;
static const DeviceCommandId_t READ_TX_WAVEFORM = 0x08;
static const DeviceCommandId_t READ_TX_AGC_VALUE_HIGH_BYTE = 0x09;
static const DeviceCommandId_t READ_TX_AGC_VALUE_LOW_BYTE = 0x0A;
static const DeviceCommandId_t NONE = 0x0;
static const DeviceCommandId_t RESET_UNIT = 0x01;
/** Reads out all status registers */
static const DeviceCommandId_t READ_RX_STATUS_REGISTERS = 0x02;
/** Sets Tx mode to standby */
static const DeviceCommandId_t SET_TX_MODE_STANDBY = 0x03;
/** Starts transmission mode. Only reached when clock signal is applying to the data tx input */
static const DeviceCommandId_t SET_TX_MODE_MODULATION = 0x04;
/** Sends out a single carrier wave for testing purpose */
static const DeviceCommandId_t SET_TX_MODE_CW = 0x05;
static const DeviceCommandId_t ACK_REPLY = 0x06;
static const DeviceCommandId_t READ_TX_STATUS = 0x07;
static const DeviceCommandId_t READ_TX_WAVEFORM = 0x08;
static const DeviceCommandId_t READ_TX_AGC_VALUE_HIGH_BYTE = 0x09;
static const DeviceCommandId_t READ_TX_AGC_VALUE_LOW_BYTE = 0x0A;
/** Size of a simple transmission success response */
static const uint8_t ACK_SIZE = 12;
static const uint8_t SIZE_CRC_AND_TERMINATION = 5;
/** The size of the header with the message identifier and the payload size field */
static const uint8_t MESSAGE_HEADER_SIZE = 5;
/** Size of reply to an rx status registers request */
static const uint8_t RX_STATUS_REGISTERS_REPLY_SIZE = 49;
static const uint8_t READ_ONE_REGISTER_REPLY_SIE = 13;
/** Size of a simple transmission success response */
static const uint8_t ACK_SIZE = 12;
static const uint8_t SIZE_CRC_AND_TERMINATION = 5;
/** The size of the header with the message identifier and the payload size field */
static const uint8_t MESSAGE_HEADER_SIZE = 5;
/** Size of reply to an rx status registers request */
static const uint8_t RX_STATUS_REGISTERS_REPLY_SIZE = 49;
static const uint8_t READ_ONE_REGISTER_REPLY_SIE = 13;
static const uint8_t RX_DATASET_ID = 0x1;
static const uint8_t TX_DATASET_ID = 0x2;
static const uint8_t RX_DATASET_ID = 0x1;
static const uint8_t TX_DATASET_ID = 0x2;
static const size_t MAX_REPLY_SIZE = RX_STATUS_REGISTERS_REPLY_SIZE;
static const size_t MAX_COMMAND_SIZE = 15;
static const size_t MAX_REPLY_SIZE = RX_STATUS_REGISTERS_REPLY_SIZE;
static const size_t MAX_COMMAND_SIZE = 15;
static const size_t CRC_FIELD_SIZE = 4;
static const size_t CRC_FIELD_SIZE = 4;
static const uint8_t RX_DATASET_SIZE = 8;
static const uint8_t TX_DATASET_SIZE = 3;
static const uint8_t RX_DATASET_SIZE = 8;
static const uint8_t TX_DATASET_SIZE = 3;
enum SyrlinksPoolIds: lp_id_t {
RX_STATUS,
RX_SENSITIVITY,
RX_FREQUENCY_SHIFT,
RX_IQ_POWER,
RX_AGC_VALUE,
RX_DEMOD_EB,
RX_DEMOD_N0,
RX_DATA_RATE,
TX_STATUS,
TX_CONV_DIFF,
TX_CONV_FILTER,
TX_WAVEFORM,
TX_PCM_INDEX,
TX_AGC_VALUE,
};
class RxDataset: public StaticLocalDataSet<RX_DATASET_SIZE> {
public:
RxDataset(HasLocalDataPoolIF* owner) :
StaticLocalDataSet(owner, RX_DATASET_ID) {
}
RxDataset(object_id_t objectId) :
StaticLocalDataSet(sid_t(objectId, RX_DATASET_ID)) {
}
lp_var_t<uint8_t> rxStatus = lp_var_t<uint8_t>(sid.objectId, RX_STATUS, this);
lp_var_t<uint32_t> rxSensitivity = lp_var_t<uint32_t>(sid.objectId, RX_SENSITIVITY, this);
lp_var_t<uint32_t> rxFrequencyShift = lp_var_t<uint32_t>(sid.objectId, RX_FREQUENCY_SHIFT, this);
lp_var_t<uint16_t> rxIqPower = lp_var_t<uint16_t>(sid.objectId, RX_IQ_POWER, this);
lp_var_t<uint16_t> rxAgcValue = lp_var_t<uint16_t>(sid.objectId, RX_AGC_VALUE, this);
lp_var_t<uint32_t> rxDemodEb = lp_var_t<uint32_t>(sid.objectId, RX_DEMOD_EB, this);
lp_var_t<uint32_t> rxDemodN0 = lp_var_t<uint32_t>(sid.objectId, RX_DEMOD_N0, this);
lp_var_t<uint8_t> rxDataRate = lp_var_t<uint8_t>(sid.objectId, RX_DATA_RATE, this);
enum SyrlinksPoolIds : lp_id_t {
RX_STATUS,
RX_SENSITIVITY,
RX_FREQUENCY_SHIFT,
RX_IQ_POWER,
RX_AGC_VALUE,
RX_DEMOD_EB,
RX_DEMOD_N0,
RX_DATA_RATE,
TX_STATUS,
TX_CONV_DIFF,
TX_CONV_FILTER,
TX_WAVEFORM,
TX_PCM_INDEX,
TX_AGC_VALUE,
};
class RxDataset : public StaticLocalDataSet<RX_DATASET_SIZE> {
public:
RxDataset(HasLocalDataPoolIF* owner) : StaticLocalDataSet(owner, RX_DATASET_ID) {}
class TxDataset: public StaticLocalDataSet<TX_DATASET_SIZE> {
public:
RxDataset(object_id_t objectId) : StaticLocalDataSet(sid_t(objectId, RX_DATASET_ID)) {}
TxDataset(HasLocalDataPoolIF* owner) :
StaticLocalDataSet(owner, TX_DATASET_ID) {
}
TxDataset(object_id_t objectId) :
StaticLocalDataSet(sid_t(objectId, TX_DATASET_ID)) {
}
lp_var_t<uint8_t> txStatus = lp_var_t<uint8_t>(sid.objectId, TX_STATUS, this);
lp_var_t<uint8_t> txWaveform = lp_var_t<uint8_t>(sid.objectId, TX_WAVEFORM, this);
lp_var_t<uint16_t> txAgcValue = lp_var_t<uint16_t>(sid.objectId, TX_AGC_VALUE, this);
lp_var_t<uint8_t> rxStatus = lp_var_t<uint8_t>(sid.objectId, RX_STATUS, this);
lp_var_t<uint32_t> rxSensitivity = lp_var_t<uint32_t>(sid.objectId, RX_SENSITIVITY, this);
lp_var_t<uint32_t> rxFrequencyShift = lp_var_t<uint32_t>(sid.objectId, RX_FREQUENCY_SHIFT, this);
lp_var_t<uint16_t> rxIqPower = lp_var_t<uint16_t>(sid.objectId, RX_IQ_POWER, this);
lp_var_t<uint16_t> rxAgcValue = lp_var_t<uint16_t>(sid.objectId, RX_AGC_VALUE, this);
lp_var_t<uint32_t> rxDemodEb = lp_var_t<uint32_t>(sid.objectId, RX_DEMOD_EB, this);
lp_var_t<uint32_t> rxDemodN0 = lp_var_t<uint32_t>(sid.objectId, RX_DEMOD_N0, this);
lp_var_t<uint8_t> rxDataRate = lp_var_t<uint8_t>(sid.objectId, RX_DATA_RATE, this);
};
}
class TxDataset : public StaticLocalDataSet<TX_DATASET_SIZE> {
public:
TxDataset(HasLocalDataPoolIF* owner) : StaticLocalDataSet(owner, TX_DATASET_ID) {}
TxDataset(object_id_t objectId) : StaticLocalDataSet(sid_t(objectId, TX_DATASET_ID)) {}
lp_var_t<uint8_t> txStatus = lp_var_t<uint8_t>(sid.objectId, TX_STATUS, this);
lp_var_t<uint8_t> txWaveform = lp_var_t<uint8_t>(sid.objectId, TX_WAVEFORM, this);
lp_var_t<uint16_t> txAgcValue = lp_var_t<uint16_t>(sid.objectId, TX_AGC_VALUE, this);
};
} // namespace SYRLINKS
#endif /* MISSION_DEVICES_DEVICEDEFINITIONS_SYRLINKSDEFINITIONS_H_ */

View File

@ -2,46 +2,35 @@
#define MISSION_DEVICES_DEVICEDEFINITIONS_TMP1075DEFINITIONS_H_
namespace TMP1075 {
static const uint8_t TEMP_REG_ADDR = 0x0;
static const uint8_t CFGR_ADDR = 0x1;
static const uint8_t TEMP_REG_ADDR = 0x0;
static const uint8_t CFGR_ADDR = 0x1;
/* Writing this information to the configuration register sets the tmp1075
* to shutdown mode and starts a single temperature conversion */
static const uint16_t ONE_SHOT_MODE = 0x8100;
/* Writing this information to the configuration register sets the tmp1075
* to shutdown mode and starts a single temperature conversion */
static const uint16_t ONE_SHOT_MODE = 0x8100;
static const DeviceCommandId_t NONE = 0x0; // Set when no command is pending
static const DeviceCommandId_t GET_TEMP = 0x1;
static const DeviceCommandId_t START_ADC_CONVERSION = 0x2;
static const DeviceCommandId_t NONE = 0x0; // Set when no command is pending
static const DeviceCommandId_t GET_TEMP = 0x1;
static const DeviceCommandId_t START_ADC_CONVERSION = 0x2;
static const uint8_t GET_TEMP_REPLY_SIZE = 2;
static const uint8_t CFGR_CMD_SIZE = 3;
static const uint8_t POINTER_REG_SIZE = 1;
static const uint8_t GET_TEMP_REPLY_SIZE = 2;
static const uint8_t CFGR_CMD_SIZE = 3;
static const uint8_t POINTER_REG_SIZE = 1;
static const uint32_t TMP1075_DATA_SET_ID = GET_TEMP;
static const uint32_t TMP1075_DATA_SET_ID = GET_TEMP;
static const uint8_t MAX_REPLY_LENGTH = GET_TEMP_REPLY_SIZE;
static const uint8_t MAX_REPLY_LENGTH = GET_TEMP_REPLY_SIZE;
enum Tmp1075PoolIds: lp_id_t {
TEMPERATURE_C_TMP1075_1,
TEMPERATURE_C_TMP1075_2
};
enum Tmp1075PoolIds : lp_id_t { TEMPERATURE_C_TMP1075_1, TEMPERATURE_C_TMP1075_2 };
class Tmp1075Dataset:
public StaticLocalDataSet<sizeof(float)> {
public:
class Tmp1075Dataset : public StaticLocalDataSet<sizeof(float)> {
public:
Tmp1075Dataset(HasLocalDataPoolIF* owner) : StaticLocalDataSet(owner, TMP1075_DATA_SET_ID) {}
Tmp1075Dataset(HasLocalDataPoolIF* owner):
StaticLocalDataSet(owner, TMP1075_DATA_SET_ID) {
}
Tmp1075Dataset(object_id_t objectId) : StaticLocalDataSet(sid_t(objectId, TMP1075_DATA_SET_ID)) {}
Tmp1075Dataset(object_id_t objectId):
StaticLocalDataSet(sid_t(objectId, TMP1075_DATA_SET_ID)) {
}
lp_var_t<float> temperatureCelcius = lp_var_t<float>(sid.objectId,
TEMPERATURE_C_TMP1075_1, this);
lp_var_t<float> temperatureCelcius = lp_var_t<float>(sid.objectId, TEMPERATURE_C_TMP1075_1, this);
};
}
} // namespace TMP1075
#endif /* MISSION_DEVICES_DEVICEDEFINITIONS_TMP1075DEFINITIONS_H_ */

View File

@ -1,50 +1,44 @@
#include "NVMParameterBase.h"
#include "fsfw/memory/HasFileSystemIF.h"
#include "fsfw/serviceinterface/ServiceInterface.h"
#include <fstream>
NVMParameterBase::NVMParameterBase(std::string fullName): fullName(fullName) {
}
#include "fsfw/memory/HasFileSystemIF.h"
#include "fsfw/serviceinterface/ServiceInterface.h"
NVMParameterBase::NVMParameterBase(std::string fullName) : fullName(fullName) {}
ReturnValue_t NVMParameterBase::readJsonFile() {
if(std::filesystem::exists(fullName)) {
// Read JSON file content into object
std::ifstream i(fullName);
i >> json;
return HasReturnvaluesIF::RETURN_OK;
}
return HasFileSystemIF::FILE_DOES_NOT_EXIST;
if (std::filesystem::exists(fullName)) {
// Read JSON file content into object
std::ifstream i(fullName);
i >> json;
return HasReturnvaluesIF::RETURN_OK;
}
return HasFileSystemIF::FILE_DOES_NOT_EXIST;
}
ReturnValue_t NVMParameterBase::writeJsonFile() {
std::ofstream o(fullName);
o << std::setw(4) << json;
return HasReturnvaluesIF::RETURN_OK;
std::ofstream o(fullName);
o << std::setw(4) << json;
return HasReturnvaluesIF::RETURN_OK;
}
void NVMParameterBase::setFullName(std::string fullName) {
this->fullName = fullName;
}
void NVMParameterBase::setFullName(std::string fullName) { this->fullName = fullName; }
std::string NVMParameterBase::getFullName() const {
return fullName;
}
std::string NVMParameterBase::getFullName() const { return fullName; }
bool NVMParameterBase::getJsonFileExists() {
return std::filesystem::exists(fullName);
}
bool NVMParameterBase::getJsonFileExists() { return std::filesystem::exists(fullName); }
void NVMParameterBase::printKeys() const {
sif::info << "Printing keys for JSON file " << fullName << std::endl;
for(const auto& key: keys) {
sif::info << key << std::endl;
}
sif::info << "Printing keys for JSON file " << fullName << std::endl;
for (const auto& key : keys) {
sif::info << key << std::endl;
}
}
void NVMParameterBase::print() const {
sif::info << "Printing JSON file " << fullName << std::endl;
for(const auto& key: keys) {
sif::info << key << ": " << json[key] << std::endl;
}
sif::info << "Printing JSON file " << fullName << std::endl;
for (const auto& key : keys) {
sif::info << key << ": " << json[key] << std::endl;
}
}

View File

@ -1,79 +1,78 @@
#ifndef BSP_Q7S_CORE_NVMPARAMS_NVMPARAMIF_H_
#define BSP_Q7S_CORE_NVMPARAMS_NVMPARAMIF_H_
#include "fsfw/returnvalues/HasReturnvaluesIF.h"
#include <filesystem>
#include <nlohmann/json.hpp>
#include <string>
#include <filesystem>
#include "fsfw/returnvalues/HasReturnvaluesIF.h"
class NVMParameterBase : public HasReturnvaluesIF {
public:
virtual~ NVMParameterBase() {}
public:
virtual ~NVMParameterBase() {}
NVMParameterBase(std::string fullName);
NVMParameterBase(std::string fullName);
bool getJsonFileExists();
bool getJsonFileExists();
/**
* Returns RETURN_OK on successfull read and HasFileSystemIF::FILE_DOES_NOT_EXIST if
* file does not exist yet.
* @return
*/
virtual ReturnValue_t readJsonFile();
/**
* Returns RETURN_OK on successfull read and HasFileSystemIF::FILE_DOES_NOT_EXIST if
* file does not exist yet.
* @return
*/
virtual ReturnValue_t readJsonFile();
virtual ReturnValue_t writeJsonFile();
virtual ReturnValue_t writeJsonFile();
void setFullName(std::string fullName);
std::string getFullName() const;
void setFullName(std::string fullName);
std::string getFullName() const;
template<typename T>
ReturnValue_t insertValue(std::string key, T value);
template <typename T>
ReturnValue_t insertValue(std::string key, T value);
template<typename T>
ReturnValue_t setValue(std::string key, T value);
template <typename T>
ReturnValue_t setValue(std::string key, T value);
template<typename T>
ReturnValue_t getValue(std::string key, T* value) const;
template <typename T>
ReturnValue_t getValue(std::string key, T* value) const;
void printKeys() const;
void print() const;
void printKeys() const;
void print() const;
private:
private:
static const uint8_t INTERFACE_ID = CLASS_ID::NVM_PARAM_BASE;
static const uint8_t INTERFACE_ID = CLASS_ID::NVM_PARAM_BASE;
//! [EXPORT] : [COMMENT] Specified key does not exist in json file
static const ReturnValue_t KEY_NOT_EXISTS = MAKE_RETURN_CODE(0xA0);
//! [EXPORT] : [COMMENT] Specified key does not exist in json file
static const ReturnValue_t KEY_NOT_EXISTS = MAKE_RETURN_CODE(0xA0);
nlohmann::json json;
std::vector<std::string> keys;
std::string fullName;
nlohmann::json json;
std::vector<std::string> keys;
std::string fullName;
};
template<typename T>
template <typename T>
inline ReturnValue_t NVMParameterBase::insertValue(std::string key, T value) {
// Check whether key already exists. If it does not, insert it
if (std::find(keys.begin(), keys.end(), key) == keys.end()) {
keys.push_back(key);
}
json[key] = value;
return HasReturnvaluesIF::RETURN_OK;
// Check whether key already exists. If it does not, insert it
if (std::find(keys.begin(), keys.end(), key) == keys.end()) {
keys.push_back(key);
}
json[key] = value;
return HasReturnvaluesIF::RETURN_OK;
}
template<typename T>
template <typename T>
inline ReturnValue_t NVMParameterBase::setValue(std::string key, T value) {
json[key] = value;
return HasReturnvaluesIF::RETURN_OK;
json[key] = value;
return HasReturnvaluesIF::RETURN_OK;
}
template<typename T>
template <typename T>
inline ReturnValue_t NVMParameterBase::getValue(std::string key, T* value) const {
if (!json.contains(key)) {
return KEY_NOT_EXISTS;
}
*value = json[key];
return RETURN_OK;
if (!json.contains(key)) {
return KEY_NOT_EXISTS;
}
*value = json[key];
return RETURN_OK;
}
#endif /* BSP_Q7S_CORE_NVMPARAMS_NVMPARAMIF_H_ */

View File

@ -1,303 +1,301 @@
#include "fsfw/serviceinterface/ServiceInterface.h"
#include "fsfw/serviceinterface/serviceInterfaceDefintions.h"
#include "fsfw/objectmanager/ObjectManager.h"
#include "fsfw/ipc/QueueFactory.h"
#include "fsfw/events/EventManagerIF.h"
#include "CCSDSHandler.h"
#include <linux/obc/PdecHandler.h>
#include "CCSDSHandler.h"
#include "fsfw/events/EventManagerIF.h"
#include "fsfw/ipc/QueueFactory.h"
#include "fsfw/objectmanager/ObjectManager.h"
#include "fsfw/serviceinterface/ServiceInterface.h"
#include "fsfw/serviceinterface/serviceInterfaceDefintions.h"
CCSDSHandler::CCSDSHandler(object_id_t objectId, object_id_t ptmeId, object_id_t tcDestination,
TxRateSetterIF* txRateSetterIF, GpioIF* gpioIF, gpioId_t enTxClock, gpioId_t enTxData) :
SystemObject(objectId), ptmeId(ptmeId), tcDestination(tcDestination), parameterHelper(this), actionHelper(
this, nullptr), txRateSetterIF(txRateSetterIF), gpioIF(gpioIF), enTxClock(
enTxClock), enTxData(enTxData) {
commandQueue = QueueFactory::instance()->createMessageQueue(QUEUE_SIZE);
eventQueue = QueueFactory::instance()->createMessageQueue(EventMessage::EVENT_MESSAGE_SIZE * 2);
TxRateSetterIF* txRateSetterIF, GpioIF* gpioIF, gpioId_t enTxClock,
gpioId_t enTxData)
: SystemObject(objectId),
ptmeId(ptmeId),
tcDestination(tcDestination),
parameterHelper(this),
actionHelper(this, nullptr),
txRateSetterIF(txRateSetterIF),
gpioIF(gpioIF),
enTxClock(enTxClock),
enTxData(enTxData) {
commandQueue = QueueFactory::instance()->createMessageQueue(QUEUE_SIZE);
eventQueue = QueueFactory::instance()->createMessageQueue(EventMessage::EVENT_MESSAGE_SIZE * 2);
}
CCSDSHandler::~CCSDSHandler() {
}
CCSDSHandler::~CCSDSHandler() {}
ReturnValue_t CCSDSHandler::performOperation(uint8_t operationCode) {
checkEvents();
readCommandQueue();
handleTelemetry();
handleTelecommands();
checkTxTimer();
return RETURN_OK;
checkEvents();
readCommandQueue();
handleTelemetry();
handleTelecommands();
checkTxTimer();
return RETURN_OK;
}
void CCSDSHandler::handleTelemetry() {
VirtualChannelMapIter iter;
for (iter = virtualChannelMap.begin(); iter != virtualChannelMap.end(); iter++) {
iter->second->performOperation();
}
VirtualChannelMapIter iter;
for (iter = virtualChannelMap.begin(); iter != virtualChannelMap.end(); iter++) {
iter->second->performOperation();
}
}
void CCSDSHandler::handleTelecommands() {
}
void CCSDSHandler::handleTelecommands() {}
ReturnValue_t CCSDSHandler::initialize() {
ReturnValue_t result = RETURN_OK;
PtmeIF* ptme = ObjectManager::instance()->get<PtmeIF>(ptmeId);
if (ptme == nullptr) {
sif::warning << "Invalid PTME object" << std::endl;
return ObjectManagerIF::CHILD_INIT_FAILED;
}
ReturnValue_t result = RETURN_OK;
PtmeIF* ptme = ObjectManager::instance()->get<PtmeIF>(ptmeId);
if (ptme == nullptr) {
sif::warning << "Invalid PTME object" << std::endl;
return ObjectManagerIF::CHILD_INIT_FAILED;
}
AcceptsTelecommandsIF* tcDistributor =
ObjectManager::instance()->get<AcceptsTelecommandsIF>(tcDestination);
if (tcDistributor == nullptr) {
AcceptsTelecommandsIF* tcDistributor =
ObjectManager::instance()->get<AcceptsTelecommandsIF>(tcDestination);
if (tcDistributor == nullptr) {
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "CCSDSHandler::initialize: Invalid TC Distributor object" << std::endl;
sif::error << "CCSDSHandler::initialize: Invalid TC Distributor object" << std::endl;
#endif
return ObjectManagerIF::CHILD_INIT_FAILED;
}
return ObjectManagerIF::CHILD_INIT_FAILED;
}
tcDistributorQueueId = tcDistributor->getRequestQueue();
tcDistributorQueueId = tcDistributor->getRequestQueue();
result = parameterHelper.initialize();
if (result != HasReturnvaluesIF::RETURN_OK) {
return result;
}
result = parameterHelper.initialize();
if (result != HasReturnvaluesIF::RETURN_OK) {
return result;
}
result = actionHelper.initialize(commandQueue);
result = actionHelper.initialize(commandQueue);
if (result != RETURN_OK) {
return result;
}
VirtualChannelMapIter iter;
for (iter = virtualChannelMap.begin(); iter != virtualChannelMap.end(); iter++) {
result = iter->second->initialize();
if (result != RETURN_OK) {
return result;
return result;
}
iter->second->setPtmeObject(ptme);
}
VirtualChannelMapIter iter;
for (iter = virtualChannelMap.begin(); iter != virtualChannelMap.end(); iter++) {
result = iter->second->initialize();
if (result != RETURN_OK) {
return result;
}
iter->second->setPtmeObject(ptme);
}
EventManagerIF* manager = ObjectManager::instance()->get<EventManagerIF>(
objects::EVENT_MANAGER);
if (manager == nullptr) {
EventManagerIF* manager = ObjectManager::instance()->get<EventManagerIF>(objects::EVENT_MANAGER);
if (manager == nullptr) {
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "CCSDSHandler::initialize: Invalid event manager" << std::endl;
sif::error << "CCSDSHandler::initialize: Invalid event manager" << std::endl;
#endif
return ObjectManagerIF::CHILD_INIT_FAILED;
}
result = manager->registerListener(eventQueue->getId());
if (result != HasReturnvaluesIF::RETURN_OK) {
return ObjectManagerIF::CHILD_INIT_FAILED;
}
result = manager->registerListener(eventQueue->getId());
if (result != HasReturnvaluesIF::RETURN_OK) {
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::warning << "CCSDSHandler::initialize: Failed to register CCSDS handler as event "
"listener" << std::endl;
sif::warning << "CCSDSHandler::initialize: Failed to register CCSDS handler as event "
"listener"
<< std::endl;
#endif
return ObjectManagerIF::CHILD_INIT_FAILED;;
}
result = manager->subscribeToEventRange(eventQueue->getId(),
event::getEventId(PdecHandler::CARRIER_LOCK),
event::getEventId(PdecHandler::BIT_LOCK_PDEC));
if (result != HasReturnvaluesIF::RETURN_OK) {
return ObjectManagerIF::CHILD_INIT_FAILED;
;
}
result = manager->subscribeToEventRange(eventQueue->getId(),
event::getEventId(PdecHandler::CARRIER_LOCK),
event::getEventId(PdecHandler::BIT_LOCK_PDEC));
if (result != HasReturnvaluesIF::RETURN_OK) {
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "CCSDSHandler::initialize: Failed to subscribe to events from PDEC "
"handler" << std::endl;
sif::error << "CCSDSHandler::initialize: Failed to subscribe to events from PDEC "
"handler"
<< std::endl;
#endif
return result;
}
return result;
return result;
}
return result;
}
void CCSDSHandler::readCommandQueue(void) {
CommandMessage commandMessage;
ReturnValue_t result = RETURN_FAILED;
CommandMessage commandMessage;
ReturnValue_t result = RETURN_FAILED;
result = commandQueue->receiveMessage(&commandMessage);
result = commandQueue->receiveMessage(&commandMessage);
if (result == RETURN_OK) {
result = parameterHelper.handleParameterMessage(&commandMessage);
if (result == RETURN_OK) {
result = parameterHelper.handleParameterMessage(&commandMessage);
if (result == RETURN_OK) {
return;
}
result = actionHelper.handleActionMessage(&commandMessage);
if (result == RETURN_OK) {
return;
}
CommandMessage reply;
reply.setReplyRejected(CommandMessage::UNKNOWN_COMMAND,
commandMessage.getCommand());
commandQueue->reply(&reply);
return;
return;
}
result = actionHelper.handleActionMessage(&commandMessage);
if (result == RETURN_OK) {
return;
}
CommandMessage reply;
reply.setReplyRejected(CommandMessage::UNKNOWN_COMMAND, commandMessage.getCommand());
commandQueue->reply(&reply);
return;
}
}
MessageQueueId_t CCSDSHandler::getCommandQueue() const {
return commandQueue->getId();
}
MessageQueueId_t CCSDSHandler::getCommandQueue() const { return commandQueue->getId(); }
void CCSDSHandler::addVirtualChannel(VcId_t vcId, VirtualChannel* virtualChannel) {
if (vcId > common::NUMBER_OF_VIRTUAL_CHANNELS) {
sif::warning << "CCSDSHandler::addVirtualChannel: Invalid virtual channel ID" << std::endl;
return;
}
if (vcId > common::NUMBER_OF_VIRTUAL_CHANNELS) {
sif::warning << "CCSDSHandler::addVirtualChannel: Invalid virtual channel ID" << std::endl;
return;
}
if (virtualChannel == nullptr) {
sif::warning << "CCSDSHandler::addVirtualChannel: Invalid virtual channel interface" << std::endl;
return;
}
if (virtualChannel == nullptr) {
sif::warning << "CCSDSHandler::addVirtualChannel: Invalid virtual channel interface"
<< std::endl;
return;
}
auto status = virtualChannelMap.emplace(vcId, virtualChannel);
if (status.second == false) {
sif::warning << "CCSDSHandler::addVirtualChannel: Failed to add virtual channel to "
"virtual channel map" << std::endl;
return;
}
auto status = virtualChannelMap.emplace(vcId, virtualChannel);
if (status.second == false) {
sif::warning << "CCSDSHandler::addVirtualChannel: Failed to add virtual channel to "
"virtual channel map"
<< std::endl;
return;
}
}
MessageQueueId_t CCSDSHandler::getReportReceptionQueue(uint8_t virtualChannel) {
if (virtualChannel < common::NUMBER_OF_VIRTUAL_CHANNELS) {
VirtualChannelMapIter iter = virtualChannelMap.find(virtualChannel);
if (iter != virtualChannelMap.end()) {
return iter->second->getReportReceptionQueue();
}
else {
sif::warning << "CCSDSHandler::getReportReceptionQueue: Virtual channel with ID "
<< static_cast<unsigned int>(virtualChannel) << " not in virtual channel map"
<< std::endl;
return MessageQueueIF::NO_QUEUE;
}
} else {
sif::debug << "CCSDSHandler::getReportReceptionQueue: Invalid virtual channel requested";
}
return MessageQueueIF::NO_QUEUE;
if (virtualChannel < common::NUMBER_OF_VIRTUAL_CHANNELS) {
VirtualChannelMapIter iter = virtualChannelMap.find(virtualChannel);
if (iter != virtualChannelMap.end()) {
return iter->second->getReportReceptionQueue();
} else {
sif::warning << "CCSDSHandler::getReportReceptionQueue: Virtual channel with ID "
<< static_cast<unsigned int>(virtualChannel) << " not in virtual channel map"
<< std::endl;
return MessageQueueIF::NO_QUEUE;
}
} else {
sif::debug << "CCSDSHandler::getReportReceptionQueue: Invalid virtual channel requested";
}
return MessageQueueIF::NO_QUEUE;
}
ReturnValue_t CCSDSHandler::getParameter(uint8_t domainId, uint8_t uniqueIdentifier,
ParameterWrapper *parameterWrapper, const ParameterWrapper *newValues,
uint16_t startAtIndex) {
return RETURN_OK;
ParameterWrapper* parameterWrapper,
const ParameterWrapper* newValues, uint16_t startAtIndex) {
return RETURN_OK;
}
uint16_t CCSDSHandler::getIdentifier() {
return 0;
}
uint16_t CCSDSHandler::getIdentifier() { return 0; }
MessageQueueId_t CCSDSHandler::getRequestQueue() {
// Forward packets directly to TC distributor
return tcDistributorQueueId;
// Forward packets directly to TC distributor
return tcDistributorQueueId;
}
ReturnValue_t CCSDSHandler::executeAction(ActionId_t actionId,
MessageQueueId_t commandedBy, const uint8_t* data, size_t size) {
switch(actionId) {
ReturnValue_t CCSDSHandler::executeAction(ActionId_t actionId, MessageQueueId_t commandedBy,
const uint8_t* data, size_t size) {
switch (actionId) {
case SET_LOW_RATE: {
txRateSetterIF->setRate(BitRates::RATE_400KHZ);
return EXECUTION_FINISHED;
txRateSetterIF->setRate(BitRates::RATE_400KHZ);
return EXECUTION_FINISHED;
}
case SET_HIGH_RATE: {
txRateSetterIF->setRate(BitRates::RATE_2000KHZ);
return EXECUTION_FINISHED;
txRateSetterIF->setRate(BitRates::RATE_2000KHZ);
return EXECUTION_FINISHED;
}
case EN_TRANSMITTER: {
enableTransmit();
return EXECUTION_FINISHED;
enableTransmit();
return EXECUTION_FINISHED;
}
case DIS_TRANSMITTER: {
disableTransmit();
return EXECUTION_FINISHED;
disableTransmit();
return EXECUTION_FINISHED;
}
default:
return COMMAND_NOT_IMPLEMENTED;
}
return COMMAND_NOT_IMPLEMENTED;
}
}
void CCSDSHandler::checkEvents() {
EventMessage event;
for (ReturnValue_t result = eventQueue->receiveMessage(&event);
result == RETURN_OK; result = eventQueue->receiveMessage(&event)) {
switch (event.getMessageId()) {
case EventMessage::EVENT_MESSAGE:
handleEvent(&event);
break;
default:
sif::debug << "CCSDSHandler::checkEvents: Did not subscribe to this event message"
<< std::endl;
break;
}
EventMessage event;
for (ReturnValue_t result = eventQueue->receiveMessage(&event); result == RETURN_OK;
result = eventQueue->receiveMessage(&event)) {
switch (event.getMessageId()) {
case EventMessage::EVENT_MESSAGE:
handleEvent(&event);
break;
default:
sif::debug << "CCSDSHandler::checkEvents: Did not subscribe to this event message"
<< std::endl;
break;
}
}
}
void CCSDSHandler::handleEvent(EventMessage* eventMessage) {
Event event = eventMessage->getEvent();
switch(event){
Event event = eventMessage->getEvent();
switch (event) {
case PdecHandler::BIT_LOCK_PDEC: {
handleBitLockEvent();
break;
handleBitLockEvent();
break;
}
case PdecHandler::CARRIER_LOCK: {
handleCarrierLockEvent();
break;
handleCarrierLockEvent();
break;
}
default:
sif::debug << "CCSDSHandler::handleEvent: Did not subscribe to this event"
<< std::endl;
break;
}
sif::debug << "CCSDSHandler::handleEvent: Did not subscribe to this event" << std::endl;
break;
}
}
void CCSDSHandler::handleBitLockEvent() {
if(transmitterCountdown.isBusy()) {
// Transmitter already enabled
return;
}
enableTransmit();
if (transmitterCountdown.isBusy()) {
// Transmitter already enabled
return;
}
enableTransmit();
}
void CCSDSHandler::handleCarrierLockEvent() {
if (!enableTxWhenCarrierLock) {
return;
}
enableTransmit();
if (!enableTxWhenCarrierLock) {
return;
}
enableTransmit();
}
void CCSDSHandler::forwardLinkstate() {
VirtualChannelMapIter iter;
for(iter = virtualChannelMap.begin(); iter != virtualChannelMap.end(); iter++) {
iter->second->setLinkState(linkState);
}
VirtualChannelMapIter iter;
for (iter = virtualChannelMap.begin(); iter != virtualChannelMap.end(); iter++) {
iter->second->setLinkState(linkState);
}
}
void CCSDSHandler::enableTransmit() {
if(transmitterCountdown.isBusy()) {
// Transmitter already enabled
return;
}
transmitterCountdown.setTimeout(TRANSMITTER_TIMEOUT);
if (transmitterCountdown.isBusy()) {
// Transmitter already enabled
return;
}
transmitterCountdown.setTimeout(TRANSMITTER_TIMEOUT);
#if BOARD_TE0720 == 0
gpioIF->pullHigh(enTxClock);
gpioIF->pullHigh(enTxData);
gpioIF->pullHigh(enTxClock);
gpioIF->pullHigh(enTxData);
#endif /* BOARD_TE0720 == 0 */
linkState = UP;
// Set link state of all virtual channels to link up
forwardLinkstate();
linkState = UP;
// Set link state of all virtual channels to link up
forwardLinkstate();
}
void CCSDSHandler::checkTxTimer() {
if(linkState == DOWN) {
return;
}
if (transmitterCountdown.hasTimedOut()) {
disableTransmit();
}
if (linkState == DOWN) {
return;
}
if (transmitterCountdown.hasTimedOut()) {
disableTransmit();
}
}
void CCSDSHandler::disableTransmit() {
#if BOARD_TE0720 == 0
gpioIF->pullLow(enTxClock);
gpioIF->pullLow(enTxData);
gpioIF->pullLow(enTxClock);
gpioIF->pullLow(enTxData);
#endif /* BOARD_TE0720 == 0 */
linkState = DOWN;
forwardLinkstate();
transmitterCountdown.setTimeout(0);
linkState = DOWN;
forwardLinkstate();
transmitterCountdown.setTimeout(0);
}

View File

@ -1,22 +1,23 @@
#ifndef CCSDSHANDLER_H_
#define CCSDSHANDLER_H_
#include <unordered_map>
#include "OBSWConfig.h"
#include "fsfw/objectmanager/SystemObject.h"
#include "fsfw/tasks/ExecutableObjectIF.h"
#include "fsfw/returnvalues/HasReturnvaluesIF.h"
#include "fsfw/tmtcservices/AcceptsTelemetryIF.h"
#include "fsfw/tmtcservices/AcceptsTelecommandsIF.h"
#include "fsfw/parameters/ParameterHelper.h"
#include "VirtualChannel.h"
#include "fsfw/action/ActionHelper.h"
#include "fsfw/action/HasActionsIF.h"
#include "fsfw/timemanager/Countdown.h"
#include "fsfw/events/EventMessage.h"
#include "linux/obc/TxRateSetterIF.h"
#include "fsfw_hal/common/gpio/gpioDefinitions.h"
#include "fsfw/objectmanager/SystemObject.h"
#include "fsfw/parameters/ParameterHelper.h"
#include "fsfw/returnvalues/HasReturnvaluesIF.h"
#include "fsfw/tasks/ExecutableObjectIF.h"
#include "fsfw/timemanager/Countdown.h"
#include "fsfw/tmtcservices/AcceptsTelecommandsIF.h"
#include "fsfw/tmtcservices/AcceptsTelemetryIF.h"
#include "fsfw_hal/common/gpio/GpioIF.h"
#include "VirtualChannel.h"
#include <unordered_map>
#include "fsfw_hal/common/gpio/gpioDefinitions.h"
#include "linux/obc/TxRateSetterIF.h"
/**
* @brief This class handles the data exchange with the CCSDS IP cores implemented in the
@ -24,70 +25,69 @@
*
* @author J. Meier
*/
class CCSDSHandler: public SystemObject,
public ExecutableObjectIF,
public AcceptsTelemetryIF,
public AcceptsTelecommandsIF,
public HasReturnvaluesIF,
public ReceivesParameterMessagesIF,
public HasActionsIF {
public:
class CCSDSHandler : public SystemObject,
public ExecutableObjectIF,
public AcceptsTelemetryIF,
public AcceptsTelecommandsIF,
public HasReturnvaluesIF,
public ReceivesParameterMessagesIF,
public HasActionsIF {
public:
using VcId_t = uint8_t;
using VcId_t = uint8_t;
/**
* @brief Constructor
*
* @param objectId Object ID of the CCSDS handler
* @param ptmeId Object ID of the PTME object providing access to the PTME IP Core.
* @param tcDestination Object ID of object handling received TC space packets
* @param txRateSetter Object providing the functionality to switch the input bitrate of
* the S-Band transceiver.
* @param gpioIF Required to enable TX data and TX clock RS485 transceiver chips.
* @param enTxClock GPIO ID of RS485 tx clock enable
* @param enTxData GPIO ID of RS485 tx data enable
*/
CCSDSHandler(object_id_t objectId, object_id_t ptmeId, object_id_t tcDestination,
TxRateSetterIF* txRateSetterIF, GpioIF* gpioIF, gpioId_t enTxClock,
gpioId_t enTxData);
/**
* @brief Constructor
*
* @param objectId Object ID of the CCSDS handler
* @param ptmeId Object ID of the PTME object providing access to the PTME IP Core.
* @param tcDestination Object ID of object handling received TC space packets
* @param txRateSetter Object providing the functionality to switch the input bitrate of
* the S-Band transceiver.
* @param gpioIF Required to enable TX data and TX clock RS485 transceiver chips.
* @param enTxClock GPIO ID of RS485 tx clock enable
* @param enTxData GPIO ID of RS485 tx data enable
*/
CCSDSHandler(object_id_t objectId, object_id_t ptmeId, object_id_t tcDestination,
TxRateSetterIF* txRateSetterIF, GpioIF* gpioIF, gpioId_t enTxClock, gpioId_t enTxData);
~CCSDSHandler();
~CCSDSHandler();
ReturnValue_t performOperation(uint8_t operationCode = 0) override;
ReturnValue_t initialize();
MessageQueueId_t getCommandQueue() const;
ReturnValue_t performOperation(uint8_t operationCode = 0) override;
ReturnValue_t initialize();
MessageQueueId_t getCommandQueue() const;
/**
* @brief Function to add a virtual channel
*
* @param virtualChannelId ID of the virtual channel to add
* @param virtualChannel Pointer to virtual channel object
*/
void addVirtualChannel(VcId_t virtualChannelId, VirtualChannel* virtualChannel);
/**
* @brief Function to add a virtual channel
*
* @param virtualChannelId ID of the virtual channel to add
* @param virtualChannel Pointer to virtual channel object
*/
void addVirtualChannel(VcId_t virtualChannelId, VirtualChannel* virtualChannel);
MessageQueueId_t getReportReceptionQueue(uint8_t virtualChannel = 0);
ReturnValue_t getParameter(uint8_t domainId, uint8_t uniqueIdentifier,
ParameterWrapper* parameterWrapper, const ParameterWrapper* newValues,
uint16_t startAtIndex);
MessageQueueId_t getReportReceptionQueue(uint8_t virtualChannel = 0);
ReturnValue_t getParameter(uint8_t domainId, uint8_t uniqueIdentifier,
ParameterWrapper *parameterWrapper, const ParameterWrapper *newValues,
uint16_t startAtIndex);
uint16_t getIdentifier() override;
MessageQueueId_t getRequestQueue() override;
uint16_t getIdentifier() override;
MessageQueueId_t getRequestQueue() override;
virtual ReturnValue_t executeAction(ActionId_t actionId, MessageQueueId_t commandedBy,
const uint8_t* data, size_t size);
virtual ReturnValue_t executeAction(ActionId_t actionId, MessageQueueId_t commandedBy,
const uint8_t* data, size_t size);
private:
static const uint8_t INTERFACE_ID = CLASS_ID::CCSDS_HANDLER;
private:
static const uint32_t QUEUE_SIZE = common::CCSDS_HANDLER_QUEUE_SIZE;
static const uint8_t INTERFACE_ID = CLASS_ID::CCSDS_HANDLER;
static const ActionId_t SET_LOW_RATE = 0;
static const ActionId_t SET_HIGH_RATE = 1;
static const ActionId_t EN_TRANSMITTER = 2;
static const ActionId_t DIS_TRANSMITTER = 3;
static const uint32_t QUEUE_SIZE = common::CCSDS_HANDLER_QUEUE_SIZE;
static const ActionId_t SET_LOW_RATE = 0;
static const ActionId_t SET_HIGH_RATE = 1;
static const ActionId_t EN_TRANSMITTER = 2;
static const ActionId_t DIS_TRANSMITTER = 3;
//! [EXPORT] : [COMMENT] Received action message with unknown action id
static const ReturnValue_t COMMAND_NOT_IMPLEMENTED = MAKE_RETURN_CODE(0xA0);
//! [EXPORT] : [COMMENT] Received action message with unknown action id
static const ReturnValue_t COMMAND_NOT_IMPLEMENTED = MAKE_RETURN_CODE(0xA0);
#if OBSW_ENABLE_SYRLINKS_TRANSMIT_TIMEOUT == 1
// syrlinks must not be transmitting more than 15 minutes (according to datasheet)
@ -97,72 +97,72 @@ private:
static const uint32_t TRANSMITTER_TIMEOUT = 86400000; // 1 day
#endif /* OBSW_SYRLINKS_DOWNLINK == 0 */
static const bool UP = true;
static const bool DOWN = false;
static const bool UP = true;
static const bool DOWN = false;
using VirtualChannelMap = std::unordered_map<VcId_t, VirtualChannel*>;
using VirtualChannelMapIter = VirtualChannelMap::iterator;
using VirtualChannelMap = std::unordered_map<VcId_t, VirtualChannel*>;
using VirtualChannelMapIter = VirtualChannelMap::iterator;
VirtualChannelMap virtualChannelMap;
VirtualChannelMap virtualChannelMap;
// Object ID of PTME object
object_id_t ptmeId;
// Object ID of PTME object
object_id_t ptmeId;
object_id_t tcDestination;
object_id_t tcDestination;
MessageQueueIF* commandQueue = nullptr;
MessageQueueIF* eventQueue = nullptr;
MessageQueueIF* commandQueue = nullptr;
MessageQueueIF* eventQueue = nullptr;
ParameterHelper parameterHelper;
ParameterHelper parameterHelper;
ActionHelper actionHelper;
ActionHelper actionHelper;
MessageQueueId_t tcDistributorQueueId;
MessageQueueId_t tcDistributorQueueId;
TxRateSetterIF* txRateSetterIF = nullptr;
TxRateSetterIF* txRateSetterIF = nullptr;
GpioIF* gpioIF = nullptr;
gpioId_t enTxClock = gpio::NO_GPIO;
gpioId_t enTxData = gpio::NO_GPIO;
GpioIF* gpioIF = nullptr;
gpioId_t enTxClock = gpio::NO_GPIO;
gpioId_t enTxData = gpio::NO_GPIO;
// Countdown to disable transmitter after 15 minutes
Countdown transmitterCountdown;
// Countdown to disable transmitter after 15 minutes
Countdown transmitterCountdown;
// When true transmitting is started as soon as carrier lock has been detected
bool enableTxWhenCarrierLock = false;
// When true transmitting is started as soon as carrier lock has been detected
bool enableTxWhenCarrierLock = false;
bool linkState = DOWN;
bool linkState = DOWN;
void readCommandQueue(void);
void handleTelemetry();
void handleTelecommands();
void checkEvents();
void handleEvent(EventMessage* eventMessage);
void readCommandQueue(void);
void handleTelemetry();
void handleTelecommands();
void checkEvents();
void handleEvent(EventMessage* eventMessage);
void handleBitLockEvent();
void handleCarrierLockEvent();
void handleBitLockEvent();
void handleCarrierLockEvent();
/**
* @brief Forward link state to virtual channels.
*/
void forwardLinkstate();
/**
* @brief Forward link state to virtual channels.
*/
void forwardLinkstate();
/**
* @brief Starts transmit timer and enables transmitter.
*/
void enableTransmit();
/**
* @brief Starts transmit timer and enables transmitter.
*/
void enableTransmit();
/**
* @brief Checks Tx timer for timeout and disables RS485 tx clock and tx data in case
* timer has expired.
*/
void checkTxTimer();
/**
* @brief Checks Tx timer for timeout and disables RS485 tx clock and tx data in case
* timer has expired.
*/
void checkTxTimer();
/**
* @brief Disables the transmitter by pulling the enable tx clock and tx data pin of the
* RS485 transceiver chips to high.
*/
void disableTransmit();
/**
* @brief Disables the transmitter by pulling the enable tx clock and tx data pin of the
* RS485 transceiver chips to high.
*/
void disableTransmit();
};
#endif /* CCSDSHANDLER_H_ */

View File

@ -1,69 +1,65 @@
#include "CCSDSHandler.h"
#include "VirtualChannel.h"
#include "CCSDSHandler.h"
#include "OBSWConfig.h"
#include "fsfw/serviceinterface/ServiceInterfaceStream.h"
#include "fsfw/objectmanager/ObjectManager.h"
#include "fsfw/tmtcservices/TmTcMessage.h"
#include "fsfw/ipc/QueueFactory.h"
#include "fsfw/objectmanager/ObjectManager.h"
#include "fsfw/serviceinterface/ServiceInterfaceStream.h"
#include "fsfw/tmtcservices/TmTcMessage.h"
VirtualChannel::VirtualChannel(uint8_t vcId, uint32_t tmQueueDepth) :
vcId(vcId) {
tmQueue = QueueFactory::instance()->createMessageQueue(tmQueueDepth,
MessageQueueMessage::MAX_MESSAGE_SIZE);
VirtualChannel::VirtualChannel(uint8_t vcId, uint32_t tmQueueDepth) : vcId(vcId) {
tmQueue = QueueFactory::instance()->createMessageQueue(tmQueueDepth,
MessageQueueMessage::MAX_MESSAGE_SIZE);
}
ReturnValue_t VirtualChannel::initialize() {
tmStore = ObjectManager::instance()->get<StorageManagerIF>(objects::TM_STORE);
if(tmStore == nullptr) {
sif::error << "VirtualChannel::initialize: Failed to get tm store" << std::endl;
return RETURN_FAILED;
}
return RETURN_OK;
tmStore = ObjectManager::instance()->get<StorageManagerIF>(objects::TM_STORE);
if (tmStore == nullptr) {
sif::error << "VirtualChannel::initialize: Failed to get tm store" << std::endl;
return RETURN_FAILED;
}
return RETURN_OK;
}
ReturnValue_t VirtualChannel::performOperation() {
ReturnValue_t result = RETURN_OK;
TmTcMessage message;
ReturnValue_t result = RETURN_OK;
TmTcMessage message;
while(tmQueue->receiveMessage(&message) == RETURN_OK) {
store_address_t storeId = message.getStorageId();
const uint8_t* data = nullptr;
size_t size = 0;
result = tmStore->getData(storeId, &data, &size);
if (result != RETURN_OK) {
sif::warning << "VirtualChannel::performOperation: Failed to read data from IPC store"
<< std::endl;
tmStore->deleteData(storeId);
return result;
}
while (tmQueue->receiveMessage(&message) == RETURN_OK) {
store_address_t storeId = message.getStorageId();
const uint8_t* data = nullptr;
size_t size = 0;
result = tmStore->getData(storeId, &data, &size);
if (result != RETURN_OK) {
sif::warning << "VirtualChannel::performOperation: Failed to read data from IPC store"
<< std::endl;
tmStore->deleteData(storeId);
return result;
}
if (linkIsUp) {
result = ptme->writeToVc(vcId, data, size);
}
if (linkIsUp) {
result = ptme->writeToVc(vcId, data, size);
}
tmStore->deleteData(storeId);
tmStore->deleteData(storeId);
if (result != RETURN_OK) {
return result;
}
}
return result;
if (result != RETURN_OK) {
return result;
}
}
return result;
}
MessageQueueId_t VirtualChannel::getReportReceptionQueue(uint8_t virtualChannel) {
return tmQueue->getId();
return tmQueue->getId();
}
void VirtualChannel::setPtmeObject(PtmeIF* ptme_) {
if (ptme_ == nullptr) {
sif::warning << "VirtualChannel::setPtmeObject: Invalid ptme object" << std::endl;
return;
}
ptme = ptme_;
if (ptme_ == nullptr) {
sif::warning << "VirtualChannel::setPtmeObject: Invalid ptme object" << std::endl;
return;
}
ptme = ptme_;
}
void VirtualChannel::setLinkState(bool linkIsUp_) {
linkIsUp = linkIsUp_;
}
void VirtualChannel::setLinkState(bool linkIsUp_) { linkIsUp = linkIsUp_; }

View File

@ -1,12 +1,13 @@
#ifndef VIRTUALCHANNEL_H_
#define VIRTUALCHANNEL_H_
#include "OBSWConfig.h"
#include "fsfw/tmtcservices/AcceptsTelemetryIF.h"
#include "fsfw/returnvalues/HasReturnvaluesIF.h"
#include <fsfw/ipc/MessageQueueIF.h>
#include <linux/obc/PtmeIF.h>
#include "OBSWConfig.h"
#include "fsfw/returnvalues/HasReturnvaluesIF.h"
#include "fsfw/tmtcservices/AcceptsTelemetryIF.h"
class StorageManagerIF;
/**
@ -15,42 +16,41 @@ class StorageManagerIF;
*
* @author J. Meier
*/
class VirtualChannel: public AcceptsTelemetryIF, public HasReturnvaluesIF {
public:
/**
* @brief Constructor
*
* @param vcId The virtual channel id assigned to this object
* @param tmQueueDepth Queue depth of queue receiving telemetry from other objects
*/
VirtualChannel(uint8_t vcId, uint32_t tmQueueDepth);
class VirtualChannel : public AcceptsTelemetryIF, public HasReturnvaluesIF {
public:
/**
* @brief Constructor
*
* @param vcId The virtual channel id assigned to this object
* @param tmQueueDepth Queue depth of queue receiving telemetry from other objects
*/
VirtualChannel(uint8_t vcId, uint32_t tmQueueDepth);
ReturnValue_t initialize();
MessageQueueId_t getReportReceptionQueue(uint8_t virtualChannel = 0) override;
ReturnValue_t performOperation();
ReturnValue_t initialize();
MessageQueueId_t getReportReceptionQueue(uint8_t virtualChannel = 0) override;
ReturnValue_t performOperation();
/**
* @brief Sets the PTME object which handles access to the PTME IP Core.
*
* @param ptme Pointer to ptme object
*/
void setPtmeObject(PtmeIF* ptme_);
/**
* @brief Sets the PTME object which handles access to the PTME IP Core.
*
* @param ptme Pointer to ptme object
*/
void setPtmeObject(PtmeIF* ptme_);
/**
* @brief Can be used by the owner to set the link state. Packets will be discarded if link
* to ground station is down.
*/
void setLinkState(bool linkIsUp_);
/**
* @brief Can be used by the owner to set the link state. Packets will be discarded if link
* to ground station is down.
*/
void setLinkState(bool linkIsUp_);
private:
private:
PtmeIF* ptme = nullptr;
MessageQueueIF* tmQueue = nullptr;
uint8_t vcId;
PtmeIF* ptme = nullptr;
MessageQueueIF* tmQueue = nullptr;
uint8_t vcId;
bool linkIsUp = false;
bool linkIsUp = false;
StorageManagerIF* tmStore = nullptr;
StorageManagerIF* tmStore = nullptr;
};
#endif /* VIRTUALCHANNEL_H_ */

View File

@ -8,15 +8,15 @@ namespace initmission {
void printAddObjectError(const char* name, object_id_t objectId) {
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "InitMission::printAddError: Adding object " << name << " with object ID 0x"
<< std::hex << std::setfill('0') << std::setw(8) << objectId
<< " failed!" << std::dec << std::endl;
sif::error << "InitMission::printAddError: Adding object " << name << " with object ID 0x"
<< std::hex << std::setfill('0') << std::setw(8) << objectId << " failed!" << std::dec
<< std::endl;
#else
sif::printError("InitMission::printAddError: Adding object %s with object ID 0x%08x failed!\n" ,
name, objectId);
sif::printError("InitMission::printAddError: Adding object %s with object ID 0x%08x failed!\n",
name, objectId);
#endif /* FSFW_CPP_OSTREAM_ENABLED == 1 */
}
}
} // namespace initmission
#endif /* MISSION_UTILITY_INITMISSION_H_ */

View File

@ -1,28 +1,22 @@
#include "Timestamp.h"
#include "fsfw/serviceinterface/ServiceInterfaceStream.h"
Timestamp::Timestamp() {
ReturnValue_t result = Clock::getDateAndTime(&time);
if (result != RETURN_OK) {
sif::warning << "Timestamp::Timestamp: Failed to get time" << std::endl;
}
ReturnValue_t result = Clock::getDateAndTime(&time);
if (result != RETURN_OK) {
sif::warning << "Timestamp::Timestamp: Failed to get time" << std::endl;
}
}
Timestamp::~Timestamp() {
}
Timestamp::~Timestamp() {}
std::string Timestamp::str() {
timestamp << std::to_string(time.year) << "-"
<< std::setw(2) << std::setfill('0')
<< std::to_string(time.month) << "-"
<< std::setw(2) << std::setfill('0')
<< std::to_string(time.day) << "--"
<< std::setw(2) << std::setfill('0')
<< std::to_string(time.hour) << "-"
<< std::setw(2) << std::setfill('0')
<< std::to_string(time.minute) << "-"
<< std::setw(2) << std::setfill('0')
<< std::to_string(time.second) << "--";
return timestamp.str();
timestamp << std::to_string(time.year) << "-" << std::setw(2) << std::setfill('0')
<< std::to_string(time.month) << "-" << std::setw(2) << std::setfill('0')
<< std::to_string(time.day) << "--" << std::setw(2) << std::setfill('0')
<< std::to_string(time.hour) << "-" << std::setw(2) << std::setfill('0')
<< std::to_string(time.minute) << "-" << std::setw(2) << std::setfill('0')
<< std::to_string(time.second) << "--";
return timestamp.str();
}

View File

@ -1,11 +1,12 @@
#ifndef MISSION_UTILITY_TIMESTAMP_H_
#define MISSION_UTILITY_TIMESTAMP_H_
#include <string>
#include <sstream>
#include <iomanip>
#include "fsfw/timemanager/Clock.h"
#include <sstream>
#include <string>
#include "fsfw/returnvalues/HasReturnvaluesIF.h"
#include "fsfw/timemanager/Clock.h"
/**
* @brief This class generates timestamps for files.
@ -13,18 +14,18 @@
* @author J. Meier
*/
class Timestamp : public HasReturnvaluesIF {
public:
Timestamp();
virtual ~Timestamp();
public:
Timestamp();
virtual ~Timestamp();
/**
* @brief Returns the timestamp string
*/
std::string str();
/**
* @brief Returns the timestamp string
*/
std::string str();
private:
std::stringstream timestamp;
Clock::TimeOfDay_t time;
private:
std::stringstream timestamp;
Clock::TimeOfDay_t time;
};
#endif /* MISSION_UTILITY_TIMESTAMP_H_ */

View File

@ -1,122 +1,118 @@
#include "OBSWConfig.h"
#include <fsfw/ipc/QueueFactory.h>
#include <fsfw/tmtcpacket/pus/tm.h>
#include <fsfw/objectmanager/ObjectManager.h>
#include <fsfw/serviceinterface/ServiceInterfaceStream.h>
#include <fsfw/tmtcpacket/pus/tm.h>
#include <mission/utility/TmFunnel.h>
#include "OBSWConfig.h"
object_id_t TmFunnel::downlinkDestination = objects::NO_OBJECT;
object_id_t TmFunnel::storageDestination = objects::NO_OBJECT;
TmFunnel::TmFunnel(object_id_t objectId, uint32_t messageDepth):
SystemObject(objectId), messageDepth(messageDepth) {
tmQueue = QueueFactory::instance()->createMessageQueue(messageDepth,
MessageQueueMessage::MAX_MESSAGE_SIZE);
storageQueue = QueueFactory::instance()->createMessageQueue(messageDepth,
MessageQueueMessage::MAX_MESSAGE_SIZE);
TmFunnel::TmFunnel(object_id_t objectId, uint32_t messageDepth)
: SystemObject(objectId), messageDepth(messageDepth) {
tmQueue = QueueFactory::instance()->createMessageQueue(messageDepth,
MessageQueueMessage::MAX_MESSAGE_SIZE);
storageQueue = QueueFactory::instance()->createMessageQueue(
messageDepth, MessageQueueMessage::MAX_MESSAGE_SIZE);
}
TmFunnel::~TmFunnel() {
}
TmFunnel::~TmFunnel() {}
MessageQueueId_t TmFunnel::getReportReceptionQueue(uint8_t virtualChannel) {
return tmQueue->getId();
return tmQueue->getId();
}
ReturnValue_t TmFunnel::performOperation(uint8_t operationCode) {
TmTcMessage currentMessage;
ReturnValue_t status = tmQueue->receiveMessage(&currentMessage);
while(status == HasReturnvaluesIF::RETURN_OK)
{
status = handlePacket(&currentMessage);
if(status != HasReturnvaluesIF::RETURN_OK){
break;
}
status = tmQueue->receiveMessage(&currentMessage);
}
TmTcMessage currentMessage;
ReturnValue_t status = tmQueue->receiveMessage(&currentMessage);
while (status == HasReturnvaluesIF::RETURN_OK) {
status = handlePacket(&currentMessage);
if (status != HasReturnvaluesIF::RETURN_OK) {
break;
}
status = tmQueue->receiveMessage(&currentMessage);
}
if (status == MessageQueueIF::EMPTY) {
return HasReturnvaluesIF::RETURN_OK;
}
else {
return status;
}
if (status == MessageQueueIF::EMPTY) {
return HasReturnvaluesIF::RETURN_OK;
} else {
return status;
}
}
ReturnValue_t TmFunnel::handlePacket(TmTcMessage* message) {
uint8_t* packetData = nullptr;
size_t size = 0;
ReturnValue_t result = tmStore->modifyData(message->getStorageId(),
&packetData, &size);
if(result != HasReturnvaluesIF::RETURN_OK){
return result;
}
TmPacketPusC packet(packetData);
packet.setPacketSequenceCount(this->sourceSequenceCount);
sourceSequenceCount++;
sourceSequenceCount = sourceSequenceCount %
SpacePacketBase::LIMIT_SEQUENCE_COUNT;
packet.setErrorControl();
uint8_t* packetData = nullptr;
size_t size = 0;
ReturnValue_t result = tmStore->modifyData(message->getStorageId(), &packetData, &size);
if (result != HasReturnvaluesIF::RETURN_OK) {
return result;
}
TmPacketPusC packet(packetData);
packet.setPacketSequenceCount(this->sourceSequenceCount);
sourceSequenceCount++;
sourceSequenceCount = sourceSequenceCount % SpacePacketBase::LIMIT_SEQUENCE_COUNT;
packet.setErrorControl();
result = tmQueue->sendToDefault(message);
if(result != HasReturnvaluesIF::RETURN_OK){
tmStore->deleteData(message->getStorageId());
sif::error << "TmFunnel::handlePacket: Error sending to downlink "
"handler" << std::endl;
return result;
}
result = tmQueue->sendToDefault(message);
if (result != HasReturnvaluesIF::RETURN_OK) {
tmStore->deleteData(message->getStorageId());
sif::error << "TmFunnel::handlePacket: Error sending to downlink "
"handler"
<< std::endl;
return result;
}
if(storageDestination != objects::NO_OBJECT) {
result = storageQueue->sendToDefault(message);
if(result != HasReturnvaluesIF::RETURN_OK){
tmStore->deleteData(message->getStorageId());
sif::error << "TmFunnel::handlePacket: Error sending to storage "
"handler" << std::endl;
return result;
}
}
return result;
if (storageDestination != objects::NO_OBJECT) {
result = storageQueue->sendToDefault(message);
if (result != HasReturnvaluesIF::RETURN_OK) {
tmStore->deleteData(message->getStorageId());
sif::error << "TmFunnel::handlePacket: Error sending to storage "
"handler"
<< std::endl;
return result;
}
}
return result;
}
ReturnValue_t TmFunnel::initialize() {
tmStore = ObjectManager::instance()->get<StorageManagerIF>(objects::TM_STORE);
if (tmStore == nullptr) {
sif::error << "TmFunnel::initialize: TM store not set." << std::endl;
sif::error << "Make sure the tm store is set up properly"
" and implements StorageManagerIF"
<< std::endl;
return ObjectManagerIF::CHILD_INIT_FAILED;
}
tmStore = ObjectManager::instance()->get<StorageManagerIF>(objects::TM_STORE);
if(tmStore == nullptr) {
sif::error << "TmFunnel::initialize: TM store not set."
<< std::endl;
sif::error << "Make sure the tm store is set up properly"
" and implements StorageManagerIF" << std::endl;
return ObjectManagerIF::CHILD_INIT_FAILED;
}
AcceptsTelemetryIF* tmTarget =
ObjectManager::instance()->get<AcceptsTelemetryIF>(downlinkDestination);
if(tmTarget == nullptr){
sif::error << "TmFunnel::initialize: Downlink Destination not set."
<< std::endl;
sif::error << "Make sure the downlink destination object is set up "
"properly and implements AcceptsTelemetryIF" << std::endl;
return ObjectManagerIF::CHILD_INIT_FAILED;
}
AcceptsTelemetryIF* tmTarget =
ObjectManager::instance()->get<AcceptsTelemetryIF>(downlinkDestination);
if (tmTarget == nullptr) {
sif::error << "TmFunnel::initialize: Downlink Destination not set." << std::endl;
sif::error << "Make sure the downlink destination object is set up "
"properly and implements AcceptsTelemetryIF"
<< std::endl;
return ObjectManagerIF::CHILD_INIT_FAILED;
}
#if OBSW_TM_TO_PTME == 1
// Live TM will be sent via the virtual channel 0
tmQueue->setDefaultDestination(tmTarget->getReportReceptionQueue(config::LIVE_TM));
// Live TM will be sent via the virtual channel 0
tmQueue->setDefaultDestination(tmTarget->getReportReceptionQueue(config::LIVE_TM));
#else
tmQueue->setDefaultDestination(tmTarget->getReportReceptionQueue());
tmQueue->setDefaultDestination(tmTarget->getReportReceptionQueue());
#endif /* OBSW_TM_TO_PTME == 1 */
// Storage destination is optional.
if(storageDestination == objects::NO_OBJECT) {
return SystemObject::initialize();
}
// Storage destination is optional.
if (storageDestination == objects::NO_OBJECT) {
return SystemObject::initialize();
}
AcceptsTelemetryIF* storageTarget =
ObjectManager::instance()->get<AcceptsTelemetryIF>(storageDestination);
if(storageTarget != nullptr) {
storageQueue->setDefaultDestination(
storageTarget->getReportReceptionQueue());
}
AcceptsTelemetryIF* storageTarget =
ObjectManager::instance()->get<AcceptsTelemetryIF>(storageDestination);
if (storageTarget != nullptr) {
storageQueue->setDefaultDestination(storageTarget->getReportReceptionQueue());
}
return SystemObject::initialize();
return SystemObject::initialize();
}

View File

@ -1,13 +1,13 @@
#ifndef MISSION_UTILITY_TMFUNNEL_H_
#define MISSION_UTILITY_TMFUNNEL_H_
#include <fsfw/ipc/MessageQueueIF.h>
#include <fsfw/objectmanager/SystemObject.h>
#include <fsfw/tasks/ExecutableObjectIF.h>
#include <fsfw/tmtcservices/AcceptsTelemetryIF.h>
#include <fsfw/ipc/MessageQueueIF.h>
#include <fsfw/tmtcservices/TmTcMessage.h>
namespace Factory{
namespace Factory {
void setStaticFrameworkObjectIds();
}
@ -19,32 +19,30 @@ void setStaticFrameworkObjectIds();
* @ingroup utility
* @author J. Meier
*/
class TmFunnel: public AcceptsTelemetryIF,
public ExecutableObjectIF,
public SystemObject {
friend void (Factory::setStaticFrameworkObjectIds)();
public:
TmFunnel(object_id_t objectId, uint32_t messageDepth = 20);
virtual ~TmFunnel();
class TmFunnel : public AcceptsTelemetryIF, public ExecutableObjectIF, public SystemObject {
friend void(Factory::setStaticFrameworkObjectIds)();
virtual MessageQueueId_t getReportReceptionQueue(
uint8_t virtualChannel = 0) override;
virtual ReturnValue_t performOperation(uint8_t operationCode = 0) override;
virtual ReturnValue_t initialize() override;
public:
TmFunnel(object_id_t objectId, uint32_t messageDepth = 20);
virtual ~TmFunnel();
protected:
static object_id_t downlinkDestination;
static object_id_t storageDestination;
virtual MessageQueueId_t getReportReceptionQueue(uint8_t virtualChannel = 0) override;
virtual ReturnValue_t performOperation(uint8_t operationCode = 0) override;
virtual ReturnValue_t initialize() override;
private:
uint16_t sourceSequenceCount = 0;
MessageQueueIF* tmQueue = nullptr;
MessageQueueIF* storageQueue = nullptr;
protected:
static object_id_t downlinkDestination;
static object_id_t storageDestination;
StorageManagerIF* tmStore = nullptr;
uint32_t messageDepth = 0;
private:
uint16_t sourceSequenceCount = 0;
MessageQueueIF* tmQueue = nullptr;
MessageQueueIF* storageQueue = nullptr;
ReturnValue_t handlePacket(TmTcMessage* message);
StorageManagerIF* tmStore = nullptr;
uint32_t messageDepth = 0;
ReturnValue_t handlePacket(TmTcMessage* message);
};
#endif /* MISSION_UTILITY_TMFUNNEL_H_ */