diff --git a/fsfwconfig/OBSWConfig.h b/fsfwconfig/OBSWConfig.h index ed3ee6f5..37df8150 100644 --- a/fsfwconfig/OBSWConfig.h +++ b/fsfwconfig/OBSWConfig.h @@ -12,10 +12,11 @@ // debugging. #define OBSW_ENHANCED_PRINTOUT 1 -#define TE0720 0 +#define TE0720 0 -#define PDU2_DEBUG 1 -#define PDU1_DEBUG 0 +#define P60DOCK_DEBUG 1 +#define PDU1_DEBUG 0 +#define PDU2_DEBUG 0 #include "OBSWVersion.h" diff --git a/mission/devices/GomspaceDeviceHandler.h b/mission/devices/GomspaceDeviceHandler.h index bd67f989..76ef8226 100644 --- a/mission/devices/GomspaceDeviceHandler.h +++ b/mission/devices/GomspaceDeviceHandler.h @@ -33,7 +33,7 @@ public: */ GomspaceDeviceHandler(object_id_t objectId, object_id_t comIF, CookieIF * comCookie, uint16_t maxConfigTableAddress, uint16_t maxHkTableAddress, - uint16_t hkTableSize, LocalPoolDataSetBase* hkTableDataset); + uint16_t hkTableReplySize, LocalPoolDataSetBase* hkTableDataset); virtual ~GomspaceDeviceHandler(); protected: diff --git a/mission/devices/P60DockHandler.cpp b/mission/devices/P60DockHandler.cpp index 9f9c42c1..4c504f9a 100644 --- a/mission/devices/P60DockHandler.cpp +++ b/mission/devices/P60DockHandler.cpp @@ -1,15 +1,388 @@ #include "P60DockHandler.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_SIZE, &p60dockHkTableDataset), p60dockHkTableDataset( + P60Dock::MAX_HKTABLE_ADDRESS, P60Dock::HK_TABLE_REPLY_SIZE, &p60dockHkTableDataset), p60dockHkTableDataset( this) { } P60DockHandler::~P60DockHandler() { } +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); + +#if OBSW_ENHANCED_PRINTOUT == 1 && P60DOCK_DEBUG == 1 + p60dockHkTableDataset.read(); + + 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; + + 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; + + 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.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.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.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.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.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.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.commit(); +} + +ReturnValue_t P60DockHandler::initializeLocalDataPool( + localpool::DataPool &localDataPoolMap, LocalDataPoolManager &poolManager) { + + localDataPoolMap.emplace(P60System::P60DOCK_CURRENT_ACU_VCC, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::P60DOCK_CURRENT_PDU1_VCC, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::P60DOCK_CURRENT_X3_IDLE_VCC, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::P60DOCK_CURRENT_PDU2_VCC, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::P60DOCK_CURRENT_ACU_VBAT, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::P60DOCK_CURRENT_PDU1_VBAT, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::P60DOCK_CURRENT_X3_IDLE_VBAT, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::P60DOCK_CURRENT_PDU2_VBAT, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::P60DOCK_CURRENT_STACK_VBAT, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::P60DOCK_CURRENT_STACK_3V3, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::P60DOCK_CURRENT_STACK_5V, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::P60DOCK_CURRENT_GS3V3, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::P60DOCK_CURRENT_GS5V, new PoolEntry( { 0 })); + + localDataPoolMap.emplace(P60System::P60DOCK_VOLTAGE_ACU_VCC, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::P60DOCK_VOLTAGE_PDU1_VCC, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::P60DOCK_VOLTAGE_X3_IDLE_VCC, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::P60DOCK_VOLTAGE_PDU2_VCC, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::P60DOCK_VOLTAGE_ACU_VBAT, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::P60DOCK_VOLTAGE_PDU1_VBAT, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::P60DOCK_VOLTAGE_X3_IDLE_VBAT, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::P60DOCK_VOLTAGE_PDU2_VBAT, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::P60DOCK_VOLTAGE_STACK_VBAT, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::P60DOCK_VOLTAGE_STACK_3V3, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::P60DOCK_VOLTAGE_STACK_5V, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::P60DOCK_VOLTAGE_GS3V3, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::P60DOCK_VOLTAGE_GS5V, new PoolEntry( { 0 })); + + localDataPoolMap.emplace(P60System::P60DOCK_OUTPUTENABLE_ACU_VCC, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::P60DOCK_OUTPUTENABLE_PDU1_VCC, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::P60DOCK_OUTPUTENABLE_X3_IDLE_VCC, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::P60DOCK_OUTPUTENABLE_PDU2_VCC, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::P60DOCK_OUTPUTENABLE_ACU_VBAT, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::P60DOCK_OUTPUTENABLE_PDU1_VBAT, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::P60DOCK_OUTPUTENABLE_X3_IDLE_VBAT, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::P60DOCK_OUTPUTENABLE_PDU2_VBAT, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::P60DOCK_OUTPUTENABLE_STACK_VBAT, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::P60DOCK_OUTPUTENABLE_STACK_3V3, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::P60DOCK_OUTPUTENABLE_STACK_5V, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::P60DOCK_OUTPUTENABLE_GS3V3, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::P60DOCK_OUTPUTENABLE_GS5V, new PoolEntry( { 0 })); + + localDataPoolMap.emplace(P60System::P60DOCK_TEMPERATURE_1, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::P60DOCK_TEMPERATURE_2, new PoolEntry( { 0 })); + + localDataPoolMap.emplace(P60System::P60DOCK_BOOT_CAUSE, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::P60DOCK_BOOT_CNT, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::P60DOCK_UPTIME, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::P60DOCK_RESETCAUSE, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::P60DOCK_BATT_MODE, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::P60DOCK_HEATER_ON, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::P60DOCK_CONV_5V_ENABLE_STATUS, new PoolEntry( { 0 })); + + localDataPoolMap.emplace(P60System::P60DOCK_LATCHUP_ACU_VCC, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::P60DOCK_LATCHUP_PDU1_VCC, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::P60DOCK_LATCHUP_X3_IDLE_VCC, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::P60DOCK_LATCHUP_PDU2_VCC, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::P60DOCK_LATCHUP_ACU_VBAT, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::P60DOCK_LATCHUP_PDU1_VBAT, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::P60DOCK_LATCHUP_X3_IDLE_VBAT, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::P60DOCK_LATCHUP_PDU2_VBAT, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::P60DOCK_LATCHUP_STACK_VBAT, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::P60DOCK_LATCHUP_STACK_3V3, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::P60DOCK_LATCHUP_STACK_5V, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::P60DOCK_LATCHUP_GS3V3, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::P60DOCK_LATCHUP_GS5V, new PoolEntry( { 0 })); + + localDataPoolMap.emplace(P60System::P60DOCK_VBAT_VALUE, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::P60DOCK_VCC_CURRENT_VALUE, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::P60DOCK_BATTERY_CURRENT, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::P60DOCK_BATTERY_VOLTAGE, new PoolEntry( { 0 })); + + localDataPoolMap.emplace(P60System::P60DOCK_BATTERY_TEMPERATURE_1, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::P60DOCK_BATTERY_TEMPERATURE_2, new PoolEntry( { 0 })); + + localDataPoolMap.emplace(P60System::P60DOCK_DEVICE_0, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::P60DOCK_DEVICE_1, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::P60DOCK_DEVICE_2, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::P60DOCK_DEVICE_3, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::P60DOCK_DEVICE_4, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::P60DOCK_DEVICE_5, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::P60DOCK_DEVICE_6, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::P60DOCK_DEVICE_7, new PoolEntry( { 0 })); + + localDataPoolMap.emplace(P60System::P60DOCK_DEVICE_0_STATUS, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::P60DOCK_DEVICE_1_STATUS, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::P60DOCK_DEVICE_2_STATUS, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::P60DOCK_DEVICE_3_STATUS, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::P60DOCK_DEVICE_4_STATUS, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::P60DOCK_DEVICE_5_STATUS, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::P60DOCK_DEVICE_6_STATUS, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::P60DOCK_DEVICE_7_STATUS, new PoolEntry( { 0 })); + + localDataPoolMap.emplace(P60System::P60DOCK_DEARM_STATUS, new PoolEntry( { 0 })); + + localDataPoolMap.emplace(P60System::P60DOCK_WDT_CNT_GND, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::P60DOCK_WDT_CNT_I2C, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::P60DOCK_WDT_CNT_CAN, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::P60DOCK_WDT_CNT_CSP_1, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::P60DOCK_WDT_CNT_CSP_2, new PoolEntry( { 0 })); + + localDataPoolMap.emplace(P60System::P60DOCK_WDT_GND_LEFT, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::P60DOCK_WDT_I2C_LEFT, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::P60DOCK_WDT_CAN_LEFT, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::P60DOCK_WDT_CSP_LEFT_1, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::P60DOCK_WDT_CSP_LEFT_2, new PoolEntry( { 0 })); + + localDataPoolMap.emplace(P60System::P60DOCK_BATT_CHARGE_CURRENT, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::P60DOCK_BATT_DISCHARGE_CURRENT, new PoolEntry( { 0 })); + + localDataPoolMap.emplace(P60System::P60DOCK_ANT6_DEPL, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::P60DOCK_AR6_DEPL, new PoolEntry( { 0 })); + + + return HasReturnvaluesIF::RETURN_OK; } diff --git a/mission/devices/P60DockHandler.h b/mission/devices/P60DockHandler.h index 49d2e6a8..6326e407 100644 --- a/mission/devices/P60DockHandler.h +++ b/mission/devices/P60DockHandler.h @@ -14,11 +14,26 @@ public: P60DockHandler(object_id_t objectId, object_id_t comIF, CookieIF * comCookie); virtual ~P60DockHandler(); + 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; 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); }; #endif /* MISSION_DEVICES_P60DOCKHANDLER_H_ */ diff --git a/mission/devices/PDU2Handler.cpp b/mission/devices/PDU2Handler.cpp index 343c3919..117ae646 100644 --- a/mission/devices/PDU2Handler.cpp +++ b/mission/devices/PDU2Handler.cpp @@ -20,6 +20,10 @@ ReturnValue_t PDU2Handler::buildNormalDeviceCommand( 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); #if OBSW_ENHANCED_PRINTOUT == 1 && PDU2_DEBUG == 1 @@ -63,8 +67,10 @@ void PDU2Handler::letChildHandleHkReply(DeviceCommandId_t id, const uint8_t *pac 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. */ + /** + * 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; diff --git a/mission/devices/devicedefinitions/GomspaceDefinitions.h b/mission/devices/devicedefinitions/GomspaceDefinitions.h index 43bf60b1..7ff13d21 100644 --- a/mission/devices/devicedefinitions/GomspaceDefinitions.h +++ b/mission/devices/devicedefinitions/GomspaceDefinitions.h @@ -369,6 +369,12 @@ namespace P60Dock { static const uint8_t HK_TABLE_DATA_SET_ID = 0x3; static const uint8_t HK_TABLE_ENTRIES = 100; + /** + * Requesting the full housekeeping table from the P60 dock will generate a reply comprising + * 402 bytes of data. + */ + static const uint16_t HK_TABLE_REPLY_SIZE = 407; + /** * @brief This class defines a dataset for the hk table of the P60 Dock. */ @@ -401,7 +407,7 @@ namespace P60Dock { P60System::P60DOCK_CURRENT_X3_IDLE_VBAT, this); lp_var_t currentPdu2Vbat = lp_var_t(sid.objectId, P60System::P60DOCK_CURRENT_PDU2_VBAT, this); - lp_var_t currentStackVbata = lp_var_t(sid.objectId, + lp_var_t currentStackVbat = lp_var_t(sid.objectId, P60System::P60DOCK_CURRENT_STACK_VBAT, this); lp_var_t currentStack3V3 = lp_var_t(sid.objectId, P60System::P60DOCK_CURRENT_STACK_3V3, this); @@ -429,7 +435,7 @@ namespace P60Dock { P60System::P60DOCK_VOLTAGE_X3_IDLE_VBAT, this); lp_var_t voltagePdu2Vbat = lp_var_t(sid.objectId, P60System::P60DOCK_VOLTAGE_PDU2_VBAT, this); - lp_var_t voltageStackVbata = lp_var_t(sid.objectId, + lp_var_t voltageStackVbat = lp_var_t(sid.objectId, P60System::P60DOCK_VOLTAGE_STACK_VBAT, this); lp_var_t voltageStack3V3 = lp_var_t(sid.objectId, P60System::P60DOCK_VOLTAGE_STACK_3V3, this); @@ -457,7 +463,7 @@ namespace P60Dock { P60System::P60DOCK_OUTPUTENABLE_X3_IDLE_VBAT, this); lp_var_t outputEnableStatePdu2Vbat = lp_var_t(sid.objectId, P60System::P60DOCK_OUTPUTENABLE_PDU2_VBAT, this); - lp_var_t outputEnableStateStackVbata = lp_var_t(sid.objectId, + lp_var_t outputEnableStateStackVbat = lp_var_t(sid.objectId, P60System::P60DOCK_OUTPUTENABLE_STACK_VBAT, this); lp_var_t outputEnableStateStack3V3 = lp_var_t(sid.objectId, P60System::P60DOCK_OUTPUTENABLE_STACK_3V3, this); @@ -506,7 +512,7 @@ namespace P60Dock { P60System::P60DOCK_LATCHUP_X3_IDLE_VBAT, this); lp_var_t latchupsPdu2Vbat = lp_var_t(sid.objectId, P60System::P60DOCK_LATCHUP_PDU2_VBAT, this); - lp_var_t latchupsStackVbata = lp_var_t(sid.objectId, + lp_var_t latchupsStackVbat = lp_var_t(sid.objectId, P60System::P60DOCK_LATCHUP_STACK_VBAT, this); lp_var_t latchupsStack3V3 = lp_var_t(sid.objectId, P60System::P60DOCK_LATCHUP_STACK_3V3, this); @@ -567,6 +573,8 @@ namespace P60Dock { lp_var_t dearmStatus = lp_var_t(sid.objectId, P60System::P60DOCK_DEARM_STATUS, this); + + /** Number of reboots due to gnd, i2c, csp watchdog timeout */ lp_var_t wdtCntGnd = lp_var_t(sid.objectId, P60System::P60DOCK_WDT_CNT_GND, this); lp_var_t wdtCntI2c = lp_var_t(sid.objectId, @@ -577,6 +585,7 @@ namespace P60Dock { P60System::P60DOCK_WDT_CNT_CSP_1, this); lp_var_t wdtCntCsp2 = lp_var_t(sid.objectId, P60System::P60DOCK_WDT_CNT_CSP_2, this); + lp_var_t wdtGndLeft = lp_var_t(sid.objectId, P60System::P60DOCK_WDT_GND_LEFT, this); lp_var_t wdtI2cLeft = lp_var_t(sid.objectId, @@ -589,7 +598,7 @@ namespace P60Dock { P60System::P60DOCK_WDT_CSP_LEFT_2, this); lp_var_t batteryChargeCurrent = lp_var_t(sid.objectId, P60System::P60DOCK_BATT_CHARGE_CURRENT, this); - lp_var_t batteryDishargeCurrent = lp_var_t(sid.objectId, + lp_var_t batteryDischargeCurrent = lp_var_t(sid.objectId, P60System::P60DOCK_BATT_DISCHARGE_CURRENT, this); lp_var_t ant6Depl = lp_var_t(sid.objectId, P60System::P60DOCK_ANT6_DEPL, this);