I2C reboot procedure for EIVE system #578

Merged
muellerr merged 17 commits from feature_i2c_reboot_procedure into develop 2023-04-07 11:07:05 +02:00
12 changed files with 184 additions and 154 deletions
Showing only changes of commit 2968856d71 - Show all commits

View File

@ -37,19 +37,19 @@ uint32_t BpxDummy::getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) { return
ReturnValue_t BpxDummy::initializeLocalDataPool(localpool::DataPool &localDataPoolMap, ReturnValue_t BpxDummy::initializeLocalDataPool(localpool::DataPool &localDataPoolMap,
LocalDataPoolManager &poolManager) { LocalDataPoolManager &poolManager) {
localDataPoolMap.emplace(BpxBattery::BATT_TEMP_1, &battTemp1); localDataPoolMap.emplace(bpxBat::BATT_TEMP_1, &battTemp1);
localDataPoolMap.emplace(BpxBattery::BATT_TEMP_2, &battTemp2); localDataPoolMap.emplace(bpxBat::BATT_TEMP_2, &battTemp2);
localDataPoolMap.emplace(BpxBattery::BATT_TEMP_3, &battTemp3); localDataPoolMap.emplace(bpxBat::BATT_TEMP_3, &battTemp3);
localDataPoolMap.emplace(BpxBattery::BATT_TEMP_4, &battTemp4); localDataPoolMap.emplace(bpxBat::BATT_TEMP_4, &battTemp4);
localDataPoolMap.emplace(BpxBattery::CHARGE_CURRENT, &chargeCurrent); localDataPoolMap.emplace(bpxBat::CHARGE_CURRENT, &chargeCurrent);
localDataPoolMap.emplace(BpxBattery::DISCHARGE_CURRENT, &dischargeCurrent); localDataPoolMap.emplace(bpxBat::DISCHARGE_CURRENT, &dischargeCurrent);
localDataPoolMap.emplace(BpxBattery::HEATER_CURRENT, &heaterCurrent); localDataPoolMap.emplace(bpxBat::HEATER_CURRENT, &heaterCurrent);
localDataPoolMap.emplace(BpxBattery::BATT_VOLTAGE, &battVolt); localDataPoolMap.emplace(bpxBat::BATT_VOLTAGE, &battVolt);
localDataPoolMap.emplace(BpxBattery::REBOOT_COUNTER, &rebootCounter); localDataPoolMap.emplace(bpxBat::REBOOT_COUNTER, &rebootCounter);
localDataPoolMap.emplace(BpxBattery::BOOTCAUSE, &bootCause); localDataPoolMap.emplace(bpxBat::BOOTCAUSE, &bootCause);
localDataPoolMap.emplace(BpxBattery::BATTERY_HEATER_MODE, &battheatMode); localDataPoolMap.emplace(bpxBat::BATTERY_HEATER_MODE, &battheatMode);
localDataPoolMap.emplace(BpxBattery::BATTHEAT_LOW_LIMIT, &battheatLow); localDataPoolMap.emplace(bpxBat::BATTHEAT_LOW_LIMIT, &battheatLow);
localDataPoolMap.emplace(BpxBattery::BATTHEAT_HIGH_LIMIT, &battheatHigh); localDataPoolMap.emplace(bpxBat::BATTHEAT_HIGH_LIMIT, &battheatHigh);
return returnvalue::OK; return returnvalue::OK;
} }

2
fsfw

@ -1 +1 @@
Subproject commit 6650c293da09d8851c2bd6c4d6e6c5a8390d003e Subproject commit 5a9304765f670685b6ca27cc9e6064012a17bab7

View File

@ -37,7 +37,7 @@ void I2cTestClass::battInit() {
if (ioctl(bpxInfo.fd, I2C_SLAVE, bpxInfo.addr) < 0) { if (ioctl(bpxInfo.fd, I2C_SLAVE, bpxInfo.addr) < 0) {
sif::error << "Failed to acquire bus access and/or talk to slave" << std::endl; sif::error << "Failed to acquire bus access and/or talk to slave" << std::endl;
} }
cmdBuf[0] = BpxBattery::PORT_PING; cmdBuf[0] = bpxBat::PORT_PING;
cmdBuf[1] = 0x42; cmdBuf[1] = 0x42;
sendLen = 2; sendLen = 2;
ReturnValue_t result = i2cWrite(bpxInfo.fd, cmdBuf.data(), sendLen); ReturnValue_t result = i2cWrite(bpxInfo.fd, cmdBuf.data(), sendLen);
@ -66,7 +66,7 @@ void I2cTestClass::battPeriodic() {
if (ioctl(bpxInfo.fd, I2C_SLAVE, bpxInfo.addr) < 0) { if (ioctl(bpxInfo.fd, I2C_SLAVE, bpxInfo.addr) < 0) {
sif::error << "Failed to acquire bus access and/or talk to slave" << std::endl; sif::error << "Failed to acquire bus access and/or talk to slave" << std::endl;
} }
cmdBuf[0] = BpxBattery::PORT_GET_HK; cmdBuf[0] = bpxBat::PORT_GET_HK;
sendLen = 1; sendLen = 1;
ReturnValue_t result = i2cWrite(bpxInfo.fd, cmdBuf.data(), sendLen); ReturnValue_t result = i2cWrite(bpxInfo.fd, cmdBuf.data(), sendLen);
if (result != returnvalue::OK) { if (result != returnvalue::OK) {

View File

@ -182,14 +182,10 @@ class ThermalController : public ExtendedControllerBase {
susMax1227::SusDataset susSet11; susMax1227::SusDataset susSet11;
lp_var_t<float> tempQ7s = lp_var_t<float>(objects::CORE_CONTROLLER, core::PoolIds::TEMPERATURE); lp_var_t<float> tempQ7s = lp_var_t<float>(objects::CORE_CONTROLLER, core::PoolIds::TEMPERATURE);
lp_var_t<int16_t> battTemp1 = lp_var_t<int16_t> battTemp1 = lp_var_t<int16_t>(objects::BPX_BATT_HANDLER, bpxBat::BATT_TEMP_1);
lp_var_t<int16_t>(objects::BPX_BATT_HANDLER, BpxBattery::BATT_TEMP_1); lp_var_t<int16_t> battTemp2 = lp_var_t<int16_t>(objects::BPX_BATT_HANDLER, bpxBat::BATT_TEMP_2);
lp_var_t<int16_t> battTemp2 = lp_var_t<int16_t> battTemp3 = lp_var_t<int16_t>(objects::BPX_BATT_HANDLER, bpxBat::BATT_TEMP_3);
lp_var_t<int16_t>(objects::BPX_BATT_HANDLER, BpxBattery::BATT_TEMP_2); lp_var_t<int16_t> battTemp4 = lp_var_t<int16_t>(objects::BPX_BATT_HANDLER, bpxBat::BATT_TEMP_4);
lp_var_t<int16_t> battTemp3 =
lp_var_t<int16_t>(objects::BPX_BATT_HANDLER, BpxBattery::BATT_TEMP_3);
lp_var_t<int16_t> battTemp4 =
lp_var_t<int16_t>(objects::BPX_BATT_HANDLER, BpxBattery::BATT_TEMP_4);
lp_var_t<int32_t> tempRw1 = lp_var_t<int32_t>(objects::RW1, rws::TEMPERATURE_C); lp_var_t<int32_t> tempRw1 = lp_var_t<int32_t>(objects::RW1, rws::TEMPERATURE_C);
lp_var_t<int32_t> tempRw2 = lp_var_t<int32_t>(objects::RW2, rws::TEMPERATURE_C); lp_var_t<int32_t> tempRw2 = lp_var_t<int32_t>(objects::RW2, rws::TEMPERATURE_C);
lp_var_t<int32_t> tempRw3 = lp_var_t<int32_t>(objects::RW3, rws::TEMPERATURE_C); lp_var_t<int32_t> tempRw3 = lp_var_t<int32_t>(objects::RW3, rws::TEMPERATURE_C);

View File

@ -27,54 +27,56 @@ void BpxBatteryHandler::doStartUp() {
void BpxBatteryHandler::doShutDown() { void BpxBatteryHandler::doShutDown() {
// Perform a COM check on reboot // Perform a COM check on reboot
state = States::CHECK_COM; state = States::CHECK_COM;
setMode(MODE_OFF);
} }
ReturnValue_t BpxBatteryHandler::buildNormalDeviceCommand(DeviceCommandId_t* id) { ReturnValue_t BpxBatteryHandler::buildNormalDeviceCommand(DeviceCommandId_t* id) {
*id = BpxBattery::GET_HK; *id = bpxBat::GET_HK;
return buildCommandFromCommand(*id, nullptr, 0); return buildCommandFromCommand(*id, nullptr, 0);
} }
ReturnValue_t BpxBatteryHandler::buildTransitionDeviceCommand(DeviceCommandId_t* id) { ReturnValue_t BpxBatteryHandler::buildTransitionDeviceCommand(DeviceCommandId_t* id) {
if (state == States::CHECK_COM) { if (state == States::CHECK_COM) {
*id = BpxBattery::PING; *id = bpxBat::PING;
return buildCommandFromCommand(*id, nullptr, 0); return buildCommandFromCommand(*id, nullptr, 0);
} }
return returnvalue::OK; return returnvalue::OK;
} }
void BpxBatteryHandler::fillCommandAndReplyMap() { void BpxBatteryHandler::fillCommandAndReplyMap() {
using namespace BpxBattery; using namespace bpxBat;
insertInCommandAndReplyMap(GET_HK, 1, &hkSet, GET_HK_REPLY_LEN); insertInCommandAndReplyMap(GET_HK, 1, &hkSet, GET_HK_REPLY_LEN);
insertInCommandAndReplyMap(BpxBattery::PING, 1, nullptr, PING_REPLY_LEN); insertInCommandAndReplyMap(bpxBat::PING, 1, nullptr, PING_REPLY_LEN);
insertInCommandAndReplyMap(BpxBattery::REBOOT, 1, nullptr, 0); insertInCommandAndReplyMap(bpxBat::REBOOT, 1, nullptr, 0);
insertInCommandAndReplyMap(BpxBattery::RESET_COUNTERS, 1, nullptr, EMPTY_REPLY_LEN); insertInCommandAndReplyMap(bpxBat::RESET_COUNTERS, 1, nullptr, EMPTY_REPLY_LEN);
insertInCommandAndReplyMap(BpxBattery::CONFIG_CMD, 1, nullptr, EMPTY_REPLY_LEN); insertInCommandAndReplyMap(bpxBat::CONFIG_CMD, 1, nullptr, EMPTY_REPLY_LEN);
insertInCommandAndReplyMap(BpxBattery::CONFIG_GET, 1, &cfgSet, CONFIG_GET_REPLY_LEN); insertInCommandAndReplyMap(bpxBat::CONFIG_GET, 1, &cfgSet, CONFIG_GET_REPLY_LEN);
} }
ReturnValue_t BpxBatteryHandler::buildCommandFromCommand(DeviceCommandId_t deviceCommand, ReturnValue_t BpxBatteryHandler::buildCommandFromCommand(DeviceCommandId_t deviceCommand,
const uint8_t* commandData, const uint8_t* commandData,
size_t commandDataLen) { size_t commandDataLen) {
switch (deviceCommand) { switch (deviceCommand) {
case (BpxBattery::GET_HK): { case (bpxBat::GET_HK): {
cmdBuf[0] = BpxBattery::PORT_GET_HK; cmdBuf[0] = bpxBat::PORT_GET_HK;
this->rawPacketLen = 1; this->rawPacketLen = 1;
break; break;
} }
case (BpxBattery::PING): { case (bpxBat::PING): {
if (commandDataLen == 1 and commandData != nullptr) { if (commandDataLen == 1 and commandData != nullptr) {
sentPingByte = commandData[0]; sentPingByte = commandData[0];
} else { } else {
sentPingByte = BpxBattery::DEFAULT_PING_SENT_BYTE; sentPingByte = bpxBat::DEFAULT_PING_SENT_BYTE;
} }
cmdBuf[0] = BpxBattery::PORT_PING; cmdBuf[0] = bpxBat::PORT_PING;
cmdBuf[1] = sentPingByte; cmdBuf[1] = sentPingByte;
this->rawPacketLen = 2; this->rawPacketLen = 2;
break; break;
} }
case (BpxBattery::REBOOT): { case (bpxBat::REBOOT): {
cmdBuf[0] = BpxBattery::PORT_REBOOT; sif::info << "BPX BATT: Executing reboot command" << std::endl;
cmdBuf[0] = bpxBat::PORT_REBOOT;
cmdBuf[1] = 0x80; cmdBuf[1] = 0x80;
cmdBuf[2] = 0x07; cmdBuf[2] = 0x07;
cmdBuf[3] = 0x80; cmdBuf[3] = 0x80;
@ -85,26 +87,26 @@ ReturnValue_t BpxBatteryHandler::buildCommandFromCommand(DeviceCommandId_t devic
triggerEvent(DeviceHandlerIF::DEVICE_WANTS_HARD_REBOOT); triggerEvent(DeviceHandlerIF::DEVICE_WANTS_HARD_REBOOT);
break; break;
} }
case (BpxBattery::RESET_COUNTERS): { case (bpxBat::RESET_COUNTERS): {
cmdBuf[0] = BpxBattery::PORT_RESET_COUNTERS; cmdBuf[0] = bpxBat::PORT_RESET_COUNTERS;
cmdBuf[1] = BpxBattery::RESET_COUNTERS_MAGIC_VALUE; cmdBuf[1] = bpxBat::RESET_COUNTERS_MAGIC_VALUE;
this->rawPacketLen = 2; this->rawPacketLen = 2;
break; break;
} }
case (BpxBattery::CONFIG_CMD): { case (bpxBat::CONFIG_CMD): {
cmdBuf[0] = BpxBattery::PORT_CONFIG_CMD; cmdBuf[0] = bpxBat::PORT_CONFIG_CMD;
// Needs to be set to 0x01 according to datasheet // Needs to be set to 0x01 according to datasheet
cmdBuf[1] = 0x01; cmdBuf[1] = 0x01;
this->rawPacketLen = 2; this->rawPacketLen = 2;
break; break;
} }
case (BpxBattery::CONFIG_GET): { case (bpxBat::CONFIG_GET): {
cmdBuf[0] = BpxBattery::PORT_CONFIG_GET; cmdBuf[0] = bpxBat::PORT_CONFIG_GET;
this->rawPacketLen = 1; this->rawPacketLen = 1;
break; break;
} }
case (BpxBattery::CONFIG_SET): { case (bpxBat::CONFIG_SET): {
cmdBuf[0] = BpxBattery::PORT_CONFIG_SET; cmdBuf[0] = bpxBat::PORT_CONFIG_SET;
if (commandDataLen != 3) { if (commandDataLen != 3) {
return DeviceHandlerIF::INVALID_NUMBER_OR_LENGTH_OF_PARAMETERS; return DeviceHandlerIF::INVALID_NUMBER_OR_LENGTH_OF_PARAMETERS;
} }
@ -114,8 +116,8 @@ ReturnValue_t BpxBatteryHandler::buildCommandFromCommand(DeviceCommandId_t devic
this->rawPacketLen = 4; this->rawPacketLen = 4;
break; break;
} }
case (BpxBattery::MAN_HEAT_ON): { case (bpxBat::MAN_HEAT_ON): {
cmdBuf[0] = BpxBattery::PORT_MAN_HEAT_ON; cmdBuf[0] = bpxBat::PORT_MAN_HEAT_ON;
if (commandDataLen != 2) { if (commandDataLen != 2) {
return DeviceHandlerIF::INVALID_NUMBER_OR_LENGTH_OF_PARAMETERS; return DeviceHandlerIF::INVALID_NUMBER_OR_LENGTH_OF_PARAMETERS;
} }
@ -125,8 +127,8 @@ ReturnValue_t BpxBatteryHandler::buildCommandFromCommand(DeviceCommandId_t devic
this->rawPacketLen = 3; this->rawPacketLen = 3;
break; break;
} }
case (BpxBattery::MAN_HEAT_OFF): { case (bpxBat::MAN_HEAT_OFF): {
cmdBuf[0] = BpxBattery::PORT_MAN_HEAT_OFF; cmdBuf[0] = bpxBat::PORT_MAN_HEAT_OFF;
this->rawPacketLen = 1; this->rawPacketLen = 1;
break; break;
} }
@ -142,35 +144,35 @@ ReturnValue_t BpxBatteryHandler::buildCommandFromCommand(DeviceCommandId_t devic
ReturnValue_t BpxBatteryHandler::scanForReply(const uint8_t* start, size_t remainingSize, ReturnValue_t BpxBatteryHandler::scanForReply(const uint8_t* start, size_t remainingSize,
DeviceCommandId_t* foundId, size_t* foundLen) { DeviceCommandId_t* foundId, size_t* foundLen) {
using namespace BpxBattery; using namespace bpxBat;
switch (lastCmd) { switch (lastCmd) {
case (BpxBattery::GET_HK): { case (bpxBat::GET_HK): {
if (remainingSize != GET_HK_REPLY_LEN) { if (remainingSize != GET_HK_REPLY_LEN) {
return DeviceHandlerIF::LENGTH_MISSMATCH; return DeviceHandlerIF::LENGTH_MISSMATCH;
} }
break; break;
} }
case (BpxBattery::PING): case (bpxBat::PING):
case (BpxBattery::MAN_HEAT_ON): case (bpxBat::MAN_HEAT_ON):
case (BpxBattery::MAN_HEAT_OFF): { case (bpxBat::MAN_HEAT_OFF): {
if (remainingSize != PING_REPLY_LEN) { if (remainingSize != PING_REPLY_LEN) {
return DeviceHandlerIF::LENGTH_MISSMATCH; return DeviceHandlerIF::LENGTH_MISSMATCH;
} }
break; break;
} }
case (BpxBattery::REBOOT): { case (bpxBat::REBOOT): {
// Ignore // Ignore
break; break;
} }
case (BpxBattery::RESET_COUNTERS): case (bpxBat::RESET_COUNTERS):
case (BpxBattery::CONFIG_CMD): case (bpxBat::CONFIG_CMD):
case (BpxBattery::CONFIG_SET): { case (bpxBat::CONFIG_SET): {
if (remainingSize != EMPTY_REPLY_LEN) { if (remainingSize != EMPTY_REPLY_LEN) {
return DeviceHandlerIF::LENGTH_MISSMATCH; return DeviceHandlerIF::LENGTH_MISSMATCH;
} }
break; break;
} }
case (BpxBattery::CONFIG_GET): { case (bpxBat::CONFIG_GET): {
if (remainingSize != CONFIG_GET_REPLY_LEN) { if (remainingSize != CONFIG_GET_REPLY_LEN) {
return DeviceHandlerIF::LENGTH_MISSMATCH; return DeviceHandlerIF::LENGTH_MISSMATCH;
} }
@ -187,11 +189,11 @@ ReturnValue_t BpxBatteryHandler::scanForReply(const uint8_t* start, size_t remai
} }
ReturnValue_t BpxBatteryHandler::interpretDeviceReply(DeviceCommandId_t id, const uint8_t* packet) { ReturnValue_t BpxBatteryHandler::interpretDeviceReply(DeviceCommandId_t id, const uint8_t* packet) {
if (id != BpxBattery::REBOOT and packet[1] != 0) { if (id != bpxBat::REBOOT and packet[1] != 0) {
return DeviceHandlerIF::DEVICE_REPORTED_ERROR; return DeviceHandlerIF::DEVICE_REPORTED_ERROR;
} }
switch (id) { switch (id) {
case (BpxBattery::GET_HK): { case (bpxBat::GET_HK): {
PoolReadGuard rg(&hkSet); PoolReadGuard rg(&hkSet);
ReturnValue_t result = hkSet.parseRawHk(packet + 2, 21); ReturnValue_t result = hkSet.parseRawHk(packet + 2, 21);
hkSet.setValidity(true, true); hkSet.setValidity(true, true);
@ -213,7 +215,7 @@ ReturnValue_t BpxBatteryHandler::interpretDeviceReply(DeviceCommandId_t id, cons
} }
break; break;
} }
case (BpxBattery::PING): { case (bpxBat::PING): {
if (packet[2] != sentPingByte) { if (packet[2] != sentPingByte) {
return DeviceHandlerIF::INVALID_DATA; return DeviceHandlerIF::INVALID_DATA;
} }
@ -222,19 +224,19 @@ ReturnValue_t BpxBatteryHandler::interpretDeviceReply(DeviceCommandId_t id, cons
} }
break; break;
} }
case (BpxBattery::RESET_COUNTERS): case (bpxBat::RESET_COUNTERS):
case (BpxBattery::CONFIG_CMD): case (bpxBat::CONFIG_CMD):
case (BpxBattery::CONFIG_SET): { case (bpxBat::CONFIG_SET): {
break; break;
} }
case (BpxBattery::MAN_HEAT_ON): case (bpxBat::MAN_HEAT_ON):
case (BpxBattery::MAN_HEAT_OFF): { case (bpxBat::MAN_HEAT_OFF): {
if (packet[2] != 0x01) { if (packet[2] != 0x01) {
return DeviceHandlerIF::DEVICE_DID_NOT_EXECUTE; return DeviceHandlerIF::DEVICE_DID_NOT_EXECUTE;
} }
break; break;
} }
case (BpxBattery::CONFIG_GET): { case (bpxBat::CONFIG_GET): {
PoolReadGuard rg(&cfgSet); PoolReadGuard rg(&cfgSet);
ReturnValue_t result = cfgSet.parseRawHk(packet + 2, 3); ReturnValue_t result = cfgSet.parseRawHk(packet + 2, 3);
if (result != returnvalue::OK) { if (result != returnvalue::OK) {
@ -243,7 +245,7 @@ ReturnValue_t BpxBatteryHandler::interpretDeviceReply(DeviceCommandId_t id, cons
cfgSet.setValidity(true, true); cfgSet.setValidity(true, true);
break; break;
} }
case (BpxBattery::REBOOT): { case (bpxBat::REBOOT): {
break; break;
} }
default: { default: {
@ -257,20 +259,20 @@ uint32_t BpxBatteryHandler::getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo)
ReturnValue_t BpxBatteryHandler::initializeLocalDataPool(localpool::DataPool& localDataPoolMap, ReturnValue_t BpxBatteryHandler::initializeLocalDataPool(localpool::DataPool& localDataPoolMap,
LocalDataPoolManager& poolManager) { LocalDataPoolManager& poolManager) {
localDataPoolMap.emplace(BpxBattery::BATT_TEMP_1, &battTemp1); localDataPoolMap.emplace(bpxBat::BATT_TEMP_1, &battTemp1);
localDataPoolMap.emplace(BpxBattery::BATT_TEMP_2, &battTemp2); localDataPoolMap.emplace(bpxBat::BATT_TEMP_2, &battTemp2);
localDataPoolMap.emplace(BpxBattery::BATT_TEMP_3, &battTemp3); localDataPoolMap.emplace(bpxBat::BATT_TEMP_3, &battTemp3);
localDataPoolMap.emplace(BpxBattery::BATT_TEMP_4, &battTemp4); localDataPoolMap.emplace(bpxBat::BATT_TEMP_4, &battTemp4);
localDataPoolMap.emplace(BpxBattery::CHARGE_CURRENT, &chargeCurrent); localDataPoolMap.emplace(bpxBat::CHARGE_CURRENT, &chargeCurrent);
localDataPoolMap.emplace(BpxBattery::DISCHARGE_CURRENT, &dischargeCurrent); localDataPoolMap.emplace(bpxBat::DISCHARGE_CURRENT, &dischargeCurrent);
localDataPoolMap.emplace(BpxBattery::HEATER_CURRENT, &heaterCurrent); localDataPoolMap.emplace(bpxBat::HEATER_CURRENT, &heaterCurrent);
localDataPoolMap.emplace(BpxBattery::BATT_VOLTAGE, &battVolt); localDataPoolMap.emplace(bpxBat::BATT_VOLTAGE, &battVolt);
localDataPoolMap.emplace(BpxBattery::REBOOT_COUNTER, &rebootCounter); localDataPoolMap.emplace(bpxBat::REBOOT_COUNTER, &rebootCounter);
localDataPoolMap.emplace(BpxBattery::BOOTCAUSE, &bootCause); localDataPoolMap.emplace(bpxBat::BOOTCAUSE, &bootCause);
localDataPoolMap.emplace(BpxBattery::BATTERY_HEATER_MODE, &battheatMode); localDataPoolMap.emplace(bpxBat::BATTERY_HEATER_MODE, &battheatMode);
localDataPoolMap.emplace(BpxBattery::BATTHEAT_LOW_LIMIT, &battheatLow); localDataPoolMap.emplace(bpxBat::BATTHEAT_LOW_LIMIT, &battheatLow);
localDataPoolMap.emplace(BpxBattery::BATTHEAT_HIGH_LIMIT, &battheatHigh); localDataPoolMap.emplace(bpxBat::BATTHEAT_HIGH_LIMIT, &battheatHigh);
poolManager.subscribeForRegularPeriodicPacket( poolManager.subscribeForRegularPeriodicPacket(
subdp::RegularHkPeriodicParams(hkSet.getSid(), enableHkSets, 20.0)); subdp::RegularHkPeriodicParams(hkSet.getSid(), enableHkSets, 20.0));

View File

@ -25,7 +25,7 @@ class BpxBatteryHandler : public DeviceHandlerBase {
bool commandExecuted = false; bool commandExecuted = false;
bool debugMode = false; bool debugMode = false;
bool goToNormalModeImmediately = false; bool goToNormalModeImmediately = false;
uint8_t sentPingByte = BpxBattery::DEFAULT_PING_SENT_BYTE; uint8_t sentPingByte = bpxBat::DEFAULT_PING_SENT_BYTE;
#if OBSW_THREAD_TRACING == 1 #if OBSW_THREAD_TRACING == 1
uint32_t opCounter = 0; uint32_t opCounter = 0;
#endif #endif

View File

@ -8,7 +8,7 @@
#include "fsfw/devicehandlers/DeviceHandlerIF.h" #include "fsfw/devicehandlers/DeviceHandlerIF.h"
namespace BpxBattery { namespace bpxBat {
enum LocalPoolIds { enum LocalPoolIds {
CHARGE_CURRENT = 0, CHARGE_CURRENT = 0,
@ -114,18 +114,18 @@ class BpxHkDeserializer : public SerialLinkedListAdapter<SerializeIF> {
} }
}; };
}; // namespace BpxBattery }; // namespace bpxBat
/** /**
* @brief BPX HK data holder * @brief BPX HK data holder
*/ */
class BpxBatteryHk : public StaticLocalDataSet<BpxBattery::HK_ENTRIES> { class BpxBatteryHk : public StaticLocalDataSet<bpxBat::HK_ENTRIES> {
public: public:
/** /**
* Constructor for data users * Constructor for data users
* @param gyroId * @param gyroId
*/ */
BpxBatteryHk(object_id_t bpxId) : StaticLocalDataSet(sid_t(bpxId, BpxBattery::HK_SET_ID)) { BpxBatteryHk(object_id_t bpxId) : StaticLocalDataSet(sid_t(bpxId, bpxBat::HK_SET_ID)) {
setAllVariablesReadOnly(); setAllVariablesReadOnly();
} }
@ -176,28 +176,25 @@ class BpxBatteryHk : public StaticLocalDataSet<BpxBattery::HK_ENTRIES> {
} }
//! Charge current in mA //! Charge current in mA
lp_var_t<uint16_t> chargeCurrent = lp_var_t<uint16_t> chargeCurrent = lp_var_t<uint16_t>(sid.objectId, bpxBat::CHARGE_CURRENT, this);
lp_var_t<uint16_t>(sid.objectId, BpxBattery::CHARGE_CURRENT, this);
//! Discharge current in mA //! Discharge current in mA
lp_var_t<uint16_t> dischargeCurrent = lp_var_t<uint16_t> dischargeCurrent =
lp_var_t<uint16_t>(sid.objectId, BpxBattery::DISCHARGE_CURRENT, this); lp_var_t<uint16_t>(sid.objectId, bpxBat::DISCHARGE_CURRENT, this);
//! Heater current in mA //! Heater current in mA
lp_var_t<uint16_t> heaterCurrent = lp_var_t<uint16_t> heaterCurrent = lp_var_t<uint16_t>(sid.objectId, bpxBat::HEATER_CURRENT, this);
lp_var_t<uint16_t>(sid.objectId, BpxBattery::HEATER_CURRENT, this);
//! Battery voltage in mV //! Battery voltage in mV
lp_var_t<uint16_t> battVoltage = lp_var_t<uint16_t>(sid.objectId, BpxBattery::BATT_VOLTAGE, this); lp_var_t<uint16_t> battVoltage = lp_var_t<uint16_t>(sid.objectId, bpxBat::BATT_VOLTAGE, this);
//! Battery temperature 1 in degC //! Battery temperature 1 in degC
lp_var_t<int16_t> battTemp1 = lp_var_t<int16_t>(sid.objectId, BpxBattery::BATT_TEMP_1, this); lp_var_t<int16_t> battTemp1 = lp_var_t<int16_t>(sid.objectId, bpxBat::BATT_TEMP_1, this);
//! Battery temperature 2 in degC //! Battery temperature 2 in degC
lp_var_t<int16_t> battTemp2 = lp_var_t<int16_t>(sid.objectId, BpxBattery::BATT_TEMP_2, this); lp_var_t<int16_t> battTemp2 = lp_var_t<int16_t>(sid.objectId, bpxBat::BATT_TEMP_2, this);
//! Battery temperature 3 in degC //! Battery temperature 3 in degC
lp_var_t<int16_t> battTemp3 = lp_var_t<int16_t>(sid.objectId, BpxBattery::BATT_TEMP_3, this); lp_var_t<int16_t> battTemp3 = lp_var_t<int16_t>(sid.objectId, bpxBat::BATT_TEMP_3, this);
//! Battery temperature 4 in degC //! Battery temperature 4 in degC
lp_var_t<int16_t> battTemp4 = lp_var_t<int16_t>(sid.objectId, BpxBattery::BATT_TEMP_4, this); lp_var_t<int16_t> battTemp4 = lp_var_t<int16_t>(sid.objectId, bpxBat::BATT_TEMP_4, this);
lp_var_t<uint32_t> rebootCounter = lp_var_t<uint32_t> rebootCounter = lp_var_t<uint32_t>(sid.objectId, bpxBat::REBOOT_COUNTER, this);
lp_var_t<uint32_t>(sid.objectId, BpxBattery::REBOOT_COUNTER, this); lp_var_t<uint8_t> bootcause = lp_var_t<uint8_t>(sid.objectId, bpxBat::BOOTCAUSE, this);
lp_var_t<uint8_t> bootcause = lp_var_t<uint8_t>(sid.objectId, BpxBattery::BOOTCAUSE, this);
private: private:
friend class BpxBatteryHandler; friend class BpxBatteryHandler;
@ -205,16 +202,16 @@ class BpxBatteryHk : public StaticLocalDataSet<BpxBattery::HK_ENTRIES> {
* Constructor for data creator * Constructor for data creator
* @param hkOwner * @param hkOwner
*/ */
BpxBatteryHk(HasLocalDataPoolIF* hkOwner) : StaticLocalDataSet(hkOwner, BpxBattery::HK_SET_ID) {} BpxBatteryHk(HasLocalDataPoolIF* hkOwner) : StaticLocalDataSet(hkOwner, bpxBat::HK_SET_ID) {}
}; };
class BpxBatteryCfg : public StaticLocalDataSet<BpxBattery::CFG_ENTRIES> { class BpxBatteryCfg : public StaticLocalDataSet<bpxBat::CFG_ENTRIES> {
public: public:
/** /**
* Constructor for data users * Constructor for data users
* @param gyroId * @param gyroId
*/ */
BpxBatteryCfg(object_id_t bpxId) : StaticLocalDataSet(sid_t(bpxId, BpxBattery::CFG_SET_ID)) { BpxBatteryCfg(object_id_t bpxId) : StaticLocalDataSet(sid_t(bpxId, bpxBat::CFG_SET_ID)) {
setAllVariablesReadOnly(); setAllVariablesReadOnly();
} }
@ -230,13 +227,12 @@ class BpxBatteryCfg : public StaticLocalDataSet<BpxBattery::CFG_ENTRIES> {
//! Mode for battheater [0=OFF,1=Auto] //! Mode for battheater [0=OFF,1=Auto]
lp_var_t<uint8_t> battheatermode = lp_var_t<uint8_t> battheatermode =
lp_var_t<uint8_t>(sid.objectId, BpxBattery::BATTERY_HEATER_MODE, this); lp_var_t<uint8_t>(sid.objectId, bpxBat::BATTERY_HEATER_MODE, this);
//! Turn heater on at [degC] //! Turn heater on at [degC]
lp_var_t<int8_t> battheaterLow = lp_var_t<int8_t> battheaterLow = lp_var_t<int8_t>(sid.objectId, bpxBat::BATTHEAT_LOW_LIMIT, this);
lp_var_t<int8_t>(sid.objectId, BpxBattery::BATTHEAT_LOW_LIMIT, this);
//! Turn heater off at [degC] //! Turn heater off at [degC]
lp_var_t<int8_t> battheaterHigh = lp_var_t<int8_t> battheaterHigh =
lp_var_t<int8_t>(sid.objectId, BpxBattery::BATTHEAT_HIGH_LIMIT, this); lp_var_t<int8_t>(sid.objectId, bpxBat::BATTHEAT_HIGH_LIMIT, this);
private: private:
friend class BpxBatteryHandler; friend class BpxBatteryHandler;
@ -244,8 +240,7 @@ class BpxBatteryCfg : public StaticLocalDataSet<BpxBattery::CFG_ENTRIES> {
* Constructor for data creator * Constructor for data creator
* @param hkOwner * @param hkOwner
*/ */
BpxBatteryCfg(HasLocalDataPoolIF* hkOwner) BpxBatteryCfg(HasLocalDataPoolIF* hkOwner) : StaticLocalDataSet(hkOwner, bpxBat::CFG_SET_ID) {}
: StaticLocalDataSet(hkOwner, BpxBattery::CFG_SET_ID) {}
}; };
#endif /* MISSION_POWER_BPXBATTDEFS_H_ */ #endif /* MISSION_POWER_BPXBATTDEFS_H_ */

View File

@ -73,11 +73,19 @@ ReturnValue_t EiveSystem::initialize() {
if (result != returnvalue::OK) { if (result != returnvalue::OK) {
return result; return result;
} }
auto* bpxDest = ObjectManager::instance()->get<HasActionsIF>(objects::BPX_BATT_HANDLER); auto* bpxDest = ObjectManager::instance()->get<HasActionsIF>(objects::BPX_BATT_HANDLER);
if (bpxDest == nullptr) { if (bpxDest == nullptr) {
return ObjectManager::CHILD_INIT_FAILED; return ObjectManager::CHILD_INIT_FAILED;
} }
bpxBattQueueId = bpxDest->getCommandQueue(); bpxBattQueueId = bpxDest->getCommandQueue();
auto* coreCtrl = ObjectManager::instance()->get<HasActionsIF>(objects::CORE_CONTROLLER);
if (coreCtrl == nullptr) {
return ObjectManager::CHILD_INIT_FAILED;
}
coreCtrlQueueId = coreCtrl->getCommandQueue();
auto* manager = ObjectManager::instance()->get<EventManagerIF>(objects::EVENT_MANAGER); auto* manager = ObjectManager::instance()->get<EventManagerIF>(objects::EVENT_MANAGER);
if (manager == nullptr) { if (manager == nullptr) {
#if FSFW_CPP_OSTREAM_ENABLED == 1 #if FSFW_CPP_OSTREAM_ENABLED == 1
@ -178,11 +186,19 @@ void EiveSystem::i2cRecoveryLogic() {
} }
} }
if (not isInTransition and performI2cReboot) { if (not isInTransition and performI2cReboot) {
if (i2cRebootState == I2cRebootState::SYSTEM_MODE_BOOT) { switch (i2cRebootState) {
case (I2cRebootState::NONE): {
break;
}
case (I2cRebootState::SYSTEM_MODE_BOOT): {
sif::debug << "going to boot mode" << std::endl;
startTransition(satsystem::Mode::BOOT, 0); startTransition(satsystem::Mode::BOOT, 0);
i2cRebootState = I2cRebootState::SWITCH_3V3_STACK_OFF_AND_BATT_REBOOT; i2cRebootState = I2cRebootState::SWITCH_3V3_STACK_OFF_AND_BATT_REBOOT;
i2cRebootHandlingCountdown.resetTimer(); i2cRebootHandlingCountdown.resetTimer();
} else if (i2cRebootState == I2cRebootState::SWITCH_3V3_STACK_OFF_AND_BATT_REBOOT) { break;
}
case (I2cRebootState::SWITCH_3V3_STACK_OFF_AND_BATT_REBOOT): {
sif::debug << "3v3 stack off and batt reboot" << std::endl;
if (mode == satsystem::Mode::BOOT) { if (mode == satsystem::Mode::BOOT) {
result = powerSwitcher->sendSwitchCommand(power::Switches::P60_DOCK_3V3_STACK, result = powerSwitcher->sendSwitchCommand(power::Switches::P60_DOCK_3V3_STACK,
PowerSwitchIF::SWITCH_OFF); PowerSwitchIF::SWITCH_OFF);
@ -192,20 +208,24 @@ void EiveSystem::i2cRecoveryLogic() {
return; return;
} }
CommandMessage msg; CommandMessage msg;
ActionMessage::setCommand(&msg, BpxBattery::REBOOT, store_address_t()); store_address_t dummy{};
ActionMessage::setCommand(&msg, bpxBat::REBOOT, dummy);
result = commandQueue->sendMessage(bpxBattQueueId, &msg); result = commandQueue->sendMessage(bpxBattQueueId, &msg);
if (result != returnvalue::OK) { if (result != returnvalue::OK) {
actionHelper.finish(false, actionCommandedBy, EXECUTE_I2C_REBOOT, result); actionHelper.finish(false, actionCommandedBy, EXECUTE_I2C_REBOOT, result);
commonI2cRecoverySequenceFinish(); commonI2cRecoverySequenceFinish();
return; return;
} }
i2cRebootState = I2cRebootState::WAIT_CYCLE;
}
break;
}
case (I2cRebootState::WAIT_CYCLE): {
i2cRebootState = I2cRebootState::SWITCH_3V3_STACK_ON; i2cRebootState = I2cRebootState::SWITCH_3V3_STACK_ON;
break;
} }
if (i2cRebootHandlingCountdown.hasTimedOut()) { case (I2cRebootState::SWITCH_3V3_STACK_ON): {
actionHelper.finish(false, actionCommandedBy, EXECUTE_I2C_REBOOT, returnvalue::FAILED); sif::debug << "3v3 stack on" << std::endl;
performI2cReboot = false;
}
} else if (i2cRebootState == I2cRebootState::SWITCH_3V3_STACK_ON) {
result = powerSwitcher->sendSwitchCommand(power::Switches::P60_DOCK_3V3_STACK, result = powerSwitcher->sendSwitchCommand(power::Switches::P60_DOCK_3V3_STACK,
PowerSwitchIF::SWITCH_ON); PowerSwitchIF::SWITCH_ON);
if (result != returnvalue::OK) { if (result != returnvalue::OK) {
@ -214,15 +234,23 @@ void EiveSystem::i2cRecoveryLogic() {
return; return;
} }
i2cRebootState = I2cRebootState::SYSTEM_MODE_SAFE; i2cRebootState = I2cRebootState::SYSTEM_MODE_SAFE;
} else if (i2cRebootState == I2cRebootState::SYSTEM_MODE_SAFE) { break;
}
case (I2cRebootState::SYSTEM_MODE_SAFE): {
if (powerSwitcher->getSwitchState(power::Switches::P60_DOCK_3V3_STACK) == if (powerSwitcher->getSwitchState(power::Switches::P60_DOCK_3V3_STACK) ==
PowerSwitchIF::SWITCH_ON) { PowerSwitchIF::SWITCH_ON) {
// This should always be accepted // This should always be accepted
commonI2cRecoverySequenceFinish(); commonI2cRecoverySequenceFinish();
sif::debug << "going back to safe" << std::endl;
actionHelper.finish(true, actionCommandedBy, EXECUTE_I2C_REBOOT); actionHelper.finish(true, actionCommandedBy, EXECUTE_I2C_REBOOT);
} }
break;
}
default: {
sif::error << "EiveSystem: Unexpected I2C reboot state" << std::endl;
break;
}
} }
// Timeout handling for the internal procedure. // Timeout handling for the internal procedure.
if (i2cRebootState != I2cRebootState::NONE and i2cRebootHandlingCountdown.hasTimedOut()) { if (i2cRebootState != I2cRebootState::NONE and i2cRebootHandlingCountdown.hasTimedOut()) {
actionHelper.finish(false, actionCommandedBy, EXECUTE_I2C_REBOOT, returnvalue::FAILED); actionHelper.finish(false, actionCommandedBy, EXECUTE_I2C_REBOOT, returnvalue::FAILED);
@ -247,3 +275,10 @@ void EiveSystem::commonI2cRecoverySequenceFinish() {
// This should always be accepted // This should always be accepted
commandSelfToSafe(); commandSelfToSafe();
} }
ReturnValue_t EiveSystem::handleCommandMessage(CommandMessage* message) {
if (message->getMessageType() == messagetypes::ACTION) {
return actionHelper.handleActionMessage(message);
}
return Subsystem::handleCommandMessage(message);
}

View File

@ -23,6 +23,7 @@ class EiveSystem : public Subsystem, public HasActionsIF {
NONE, NONE,
SYSTEM_MODE_BOOT, SYSTEM_MODE_BOOT,
SWITCH_3V3_STACK_OFF_AND_BATT_REBOOT, SWITCH_3V3_STACK_OFF_AND_BATT_REBOOT,
WAIT_CYCLE,
SWITCH_3V3_STACK_ON, SWITCH_3V3_STACK_ON,
SYSTEM_MODE_SAFE SYSTEM_MODE_SAFE
} i2cRebootState = I2cRebootState::NONE; } i2cRebootState = I2cRebootState::NONE;
@ -49,6 +50,8 @@ class EiveSystem : public Subsystem, public HasActionsIF {
ReturnValue_t executeAction(ActionId_t actionId, MessageQueueId_t commandedBy, ReturnValue_t executeAction(ActionId_t actionId, MessageQueueId_t commandedBy,
const uint8_t* data, size_t size) override; const uint8_t* data, size_t size) override;
ReturnValue_t handleCommandMessage(CommandMessage* message) override;
void i2cRecoveryLogic(); void i2cRecoveryLogic();
void handleEventMessages(); void handleEventMessages();
void commandSelfToSafe(); void commandSelfToSafe();

View File

@ -331,7 +331,6 @@ void HeaterHandler::handleSwitchOffCommand(heater::Switchers heaterIdx) {
} }
} }
} else { } else {
sif::info << "HeaterHandler::handleSwitchOffCommand: Switch already off" << std::endl;
triggerEvent(SWITCH_ALREADY_OFF, heaterIdx); triggerEvent(SWITCH_ALREADY_OFF, heaterIdx);
} }
if (heater.replyQueue != NO_COMMANDER) { if (heater.replyQueue != NO_COMMANDER) {

View File

@ -101,8 +101,8 @@ class HeaterHandler : public ExecutableObjectIF,
static constexpr Event GPIO_PULL_LOW_FAILED = MAKE_EVENT(1, severity::LOW); static constexpr Event GPIO_PULL_LOW_FAILED = MAKE_EVENT(1, severity::LOW);
static constexpr Event HEATER_WENT_ON = event::makeEvent(SUBSYSTEM_ID, 2, severity::INFO); static constexpr Event HEATER_WENT_ON = event::makeEvent(SUBSYSTEM_ID, 2, severity::INFO);
static constexpr Event HEATER_WENT_OFF = event::makeEvent(SUBSYSTEM_ID, 3, severity::INFO); static constexpr Event HEATER_WENT_OFF = event::makeEvent(SUBSYSTEM_ID, 3, severity::INFO);
static constexpr Event SWITCH_ALREADY_ON = MAKE_EVENT(4, severity::LOW); static constexpr Event SWITCH_ALREADY_ON = MAKE_EVENT(4, severity::INFO);
static constexpr Event SWITCH_ALREADY_OFF = MAKE_EVENT(5, severity::LOW); static constexpr Event SWITCH_ALREADY_OFF = MAKE_EVENT(5, severity::INFO);
static constexpr Event MAIN_SWITCH_TIMEOUT = MAKE_EVENT(6, severity::MEDIUM); static constexpr Event MAIN_SWITCH_TIMEOUT = MAKE_EVENT(6, severity::MEDIUM);
//! A faulty heater was one. The SW will autonomously attempt to shut it down. P1: Heater Index //! A faulty heater was one. The SW will autonomously attempt to shut it down. P1: Heater Index
static constexpr Event FAULTY_HEATER_WAS_ON = event::makeEvent(SUBSYSTEM_ID, 7, severity::LOW); static constexpr Event FAULTY_HEATER_WAS_ON = event::makeEvent(SUBSYSTEM_ID, 7, severity::LOW);

2
tmtc

@ -1 +1 @@
Subproject commit 7e5fa2e61a3f2b50860fe2e3427f31f7ebaf854f Subproject commit ad0827607958d0bfbe3dfb903cdd8a65a71e0e7a