continued BPX handler
All checks were successful
EIVE/eive-obsw/pipeline/head This commit looks good
All checks were successful
EIVE/eive-obsw/pipeline/head This commit looks good
This commit is contained in:
parent
dd822f9c44
commit
89bbf98b4a
2
fsfw
2
fsfw
@ -1 +1 @@
|
|||||||
Subproject commit 33386550cf81e47f4a3c95cd063349442dd83d09
|
Subproject commit 6698d283b6576bc867b28d06ff772e4b3bb5c33f
|
@ -5,12 +5,28 @@ BpxBatteryHandler::BpxBatteryHandler(object_id_t objectId, object_id_t comIF, Co
|
|||||||
|
|
||||||
BpxBatteryHandler::~BpxBatteryHandler() {}
|
BpxBatteryHandler::~BpxBatteryHandler() {}
|
||||||
|
|
||||||
void BpxBatteryHandler::doStartUp() {}
|
void BpxBatteryHandler::doStartUp() {
|
||||||
|
if(state == States::CHECK_COM) {
|
||||||
|
if(commandExecuted) {
|
||||||
|
state = States::IDLE;
|
||||||
|
commandExecuted = false;
|
||||||
|
if(goToNormalModeImmediately) {
|
||||||
|
setMode(MODE_NORMAL);
|
||||||
|
} else {
|
||||||
|
setMode(_MODE_TO_ON);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void BpxBatteryHandler::doShutDown() {}
|
void BpxBatteryHandler::doShutDown() {
|
||||||
|
// Perform a COM check on reboot
|
||||||
|
state = States::CHECK_COM;
|
||||||
|
}
|
||||||
|
|
||||||
ReturnValue_t BpxBatteryHandler::buildNormalDeviceCommand(DeviceCommandId_t* id) {
|
ReturnValue_t BpxBatteryHandler::buildNormalDeviceCommand(DeviceCommandId_t* id) {
|
||||||
return HasReturnvaluesIF::RETURN_OK;
|
*id = BpxBattery::GET_HK;
|
||||||
|
return buildCommandFromCommand(*id, nullptr, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
ReturnValue_t BpxBatteryHandler::buildTransitionDeviceCommand(DeviceCommandId_t* id) {
|
ReturnValue_t BpxBatteryHandler::buildTransitionDeviceCommand(DeviceCommandId_t* id) {
|
||||||
@ -18,34 +34,165 @@ ReturnValue_t BpxBatteryHandler::buildTransitionDeviceCommand(DeviceCommandId_t*
|
|||||||
}
|
}
|
||||||
|
|
||||||
void BpxBatteryHandler::fillCommandAndReplyMap() {
|
void BpxBatteryHandler::fillCommandAndReplyMap() {
|
||||||
insertInCommandAndReplyMap(BpxBattery::READ_HK, 1, &hkSet);
|
insertInCommandAndReplyMap(BpxBattery::GET_HK, 1, &hkSet);
|
||||||
insertInCommandAndReplyMap(BpxBattery::PING, 1);
|
insertInCommandAndReplyMap(BpxBattery::PING, 1);
|
||||||
insertInCommandAndReplyMap(BpxBattery::REBOOT, 1);
|
insertInCommandAndReplyMap(BpxBattery::REBOOT, 1);
|
||||||
insertInCommandAndReplyMap(BpxBattery::RESET_COUNTERS, 1);
|
insertInCommandAndReplyMap(BpxBattery::RESET_COUNTERS, 1);
|
||||||
insertInCommandAndReplyMap(BpxBattery::RESTORE_DEFAULT_CONFIG, 1);
|
insertInCommandAndReplyMap(BpxBattery::CONFIG_CMD, 1);
|
||||||
insertInCommandAndReplyMap(BpxBattery::READ_CONFIG, 1);
|
insertInCommandAndReplyMap(BpxBattery::CONFIG_GET, 1, &cfgSet);
|
||||||
}
|
}
|
||||||
|
|
||||||
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) {
|
||||||
|
case(BpxBattery::PING): {
|
||||||
|
if(commandDataLen == 1) {
|
||||||
|
sentPingByte = commandData[0];
|
||||||
|
} else {
|
||||||
|
sentPingByte = BpxBattery::DEFAULT_PING_SENT_BYTE;
|
||||||
|
}
|
||||||
|
|
||||||
|
cmdBuf[0] = BpxBattery::PORT_PING;
|
||||||
|
cmdBuf[1] = sentPingByte;
|
||||||
|
this->rawPacketLen = 2;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case(BpxBattery::REBOOT): {
|
||||||
|
cmdBuf[0] = BpxBattery::PORT_REBOOT;
|
||||||
|
cmdBuf[1] = 0x80;
|
||||||
|
cmdBuf[2] = 0x07;
|
||||||
|
cmdBuf[3] = 0x80;
|
||||||
|
cmdBuf[4] = 0x07;
|
||||||
|
this->rawPacketLen = 5;
|
||||||
|
triggerEvent(DeviceHandlerIF::DEVICE_WANTS_HARD_REBOOT);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case(BpxBattery::RESET_COUNTERS): {
|
||||||
|
cmdBuf[0] = BpxBattery::PORT_RESET_COUNTERS;
|
||||||
|
cmdBuf[1] = BpxBattery::RESET_COUNTERS_MAGIC_VALUE;
|
||||||
|
this->rawPacketLen = 2;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case(BpxBattery::CONFIG_CMD): {
|
||||||
|
cmdBuf[0] = BpxBattery::PORT_CONFIG_CMD;
|
||||||
|
// Needs to be set to 0x01 according to datasheet
|
||||||
|
cmdBuf[1] = 0x01;
|
||||||
|
this->rawPacketLen = 2;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case(BpxBattery::CONFIG_GET): {
|
||||||
|
cmdBuf[0] = BpxBattery::PORT_CONFIG_GET;
|
||||||
|
this->rawPacketLen = 1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case(BpxBattery::CONFIG_SET): {
|
||||||
|
cmdBuf[0] = BpxBattery::PORT_CONFIG_SET;
|
||||||
|
if(commandDataLen != 3) {
|
||||||
|
return DeviceHandlerIF::INVALID_NUMBER_OR_LENGTH_OF_PARAMETERS;
|
||||||
|
}
|
||||||
|
for(uint8_t idx = 0; idx < 3; idx ++) {
|
||||||
|
cmdBuf[idx + 1] = commandData[idx];
|
||||||
|
}
|
||||||
|
this->rawPacketLen = 4;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case(BpxBattery::MAN_HEAT_ON): {
|
||||||
|
cmdBuf[0] = BpxBattery::PORT_MAN_HEAT_ON;
|
||||||
|
if(commandDataLen != 2) {
|
||||||
|
return DeviceHandlerIF::INVALID_NUMBER_OR_LENGTH_OF_PARAMETERS;
|
||||||
|
}
|
||||||
|
for(uint8_t idx = 0; idx < 2; idx++) {
|
||||||
|
cmdBuf[idx + 1] = commandData[idx];
|
||||||
|
}
|
||||||
|
this->rawPacketLen = 3;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case(BpxBattery::MAN_HEAT_OFF): {
|
||||||
|
cmdBuf[0] = BpxBattery::PORT_MAN_HEAT_OFF;
|
||||||
|
this->rawPacketLen = 1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default: {
|
||||||
|
return DeviceHandlerIF::COMMAND_NOT_SUPPORTED;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this->rawPacket = cmdBuf.data();
|
||||||
|
|
||||||
|
lastCmd = deviceCommand;
|
||||||
return HasReturnvaluesIF::RETURN_OK;
|
return HasReturnvaluesIF::RETURN_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
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) {
|
||||||
|
switch(lastCmd) {
|
||||||
|
case(BpxBattery::GET_HK): {
|
||||||
|
if(remainingSize != 21) {
|
||||||
|
return DeviceHandlerIF::LENGTH_MISSMATCH;
|
||||||
|
}
|
||||||
|
*foundLen = 21;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case(BpxBattery::PING):
|
||||||
|
case(BpxBattery::MAN_HEAT_ON):
|
||||||
|
case(BpxBattery::MAN_HEAT_OFF): {
|
||||||
|
if(remainingSize != 1) {
|
||||||
|
return DeviceHandlerIF::LENGTH_MISSMATCH;
|
||||||
|
}
|
||||||
|
*foundLen = 1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case(BpxBattery::REBOOT):
|
||||||
|
case(BpxBattery::RESET_COUNTERS):
|
||||||
|
case(BpxBattery::CONFIG_CMD):
|
||||||
|
case(BpxBattery::CONFIG_SET): {
|
||||||
|
if(remainingSize != 0) {
|
||||||
|
return DeviceHandlerIF::LENGTH_MISSMATCH;
|
||||||
|
}
|
||||||
|
*foundLen = 0;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case(BpxBattery::CONFIG_GET): {
|
||||||
|
if(remainingSize != 3) {
|
||||||
|
return DeviceHandlerIF::LENGTH_MISSMATCH;
|
||||||
|
}
|
||||||
|
*foundLen = 3;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default: {
|
||||||
|
return DeviceHandlerIF::UNKNOWN_DEVICE_REPLY;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
*foundId = lastCmd;
|
||||||
return HasReturnvaluesIF::RETURN_OK;
|
return HasReturnvaluesIF::RETURN_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
ReturnValue_t BpxBatteryHandler::interpretDeviceReply(DeviceCommandId_t ixd,
|
ReturnValue_t BpxBatteryHandler::interpretDeviceReply(DeviceCommandId_t id,
|
||||||
const uint8_t* packet) {
|
const uint8_t* packet) {
|
||||||
|
switch(id) {
|
||||||
|
case(BpxBattery::GET_HK): {
|
||||||
|
ReturnValue_t result = hkSet.parseRawHk(packet, 21);
|
||||||
|
if(result != HasReturnvaluesIF::RETURN_OK) {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case(BpxBattery::PING): {
|
||||||
|
if (packet[0] != sentPingByte) {
|
||||||
|
return DeviceHandlerIF::INVALID_DATA;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case(BpxBattery::RESET_COUNTERS): {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default: {
|
||||||
|
return DeviceHandlerIF::UNKNOWN_DEVICE_REPLY;
|
||||||
|
}
|
||||||
|
}
|
||||||
return HasReturnvaluesIF::RETURN_OK;
|
return HasReturnvaluesIF::RETURN_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
void BpxBatteryHandler::setNormalDatapoolEntriesInvalid() {}
|
|
||||||
|
|
||||||
LocalPoolDataSetBase* BpxBatteryHandler::getDataSetHandle(sid_t sid) { return nullptr; }
|
|
||||||
|
|
||||||
uint32_t BpxBatteryHandler::getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) { return 10000; }
|
uint32_t BpxBatteryHandler::getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) { return 10000; }
|
||||||
|
|
||||||
ReturnValue_t BpxBatteryHandler::initializeLocalDataPool(localpool::DataPool& localDataPoolMap,
|
ReturnValue_t BpxBatteryHandler::initializeLocalDataPool(localpool::DataPool& localDataPoolMap,
|
||||||
|
@ -11,8 +11,19 @@ class BpxBatteryHandler : public DeviceHandlerBase {
|
|||||||
virtual ~BpxBatteryHandler();
|
virtual ~BpxBatteryHandler();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
enum class States {
|
||||||
|
CHECK_COM = 0,
|
||||||
|
IDLE = 1,
|
||||||
|
};
|
||||||
|
|
||||||
|
States state = States::CHECK_COM;
|
||||||
|
bool commandExecuted = false;
|
||||||
|
bool goToNormalModeImmediately = false;
|
||||||
|
uint8_t sentPingByte = BpxBattery::DEFAULT_PING_SENT_BYTE;
|
||||||
BpxBatteryHk hkSet;
|
BpxBatteryHk hkSet;
|
||||||
|
DeviceCommandId_t lastCmd = DeviceHandlerIF::NO_COMMAND_ID;
|
||||||
BpxBatteryCfg cfgSet;
|
BpxBatteryCfg cfgSet;
|
||||||
|
std::array<uint8_t, 8> cmdBuf = {};
|
||||||
|
|
||||||
void doStartUp() override;
|
void doStartUp() override;
|
||||||
void doShutDown() override;
|
void doShutDown() override;
|
||||||
@ -23,8 +34,7 @@ class BpxBatteryHandler : public DeviceHandlerBase {
|
|||||||
size_t commandDataLen) override;
|
size_t commandDataLen) override;
|
||||||
ReturnValue_t scanForReply(const uint8_t* start, size_t remainingSize, DeviceCommandId_t* foundId,
|
ReturnValue_t scanForReply(const uint8_t* start, size_t remainingSize, DeviceCommandId_t* foundId,
|
||||||
size_t* foundLen) override;
|
size_t* foundLen) override;
|
||||||
ReturnValue_t interpretDeviceReply(DeviceCommandId_t ixd, const uint8_t* packet) override;
|
ReturnValue_t interpretDeviceReply(DeviceCommandId_t id, const uint8_t* packet) override;
|
||||||
void setNormalDatapoolEntriesInvalid() override;
|
|
||||||
virtual LocalPoolDataSetBase* getDataSetHandle(sid_t sid) override;
|
virtual LocalPoolDataSetBase* getDataSetHandle(sid_t sid) override;
|
||||||
uint32_t getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) override;
|
uint32_t getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) override;
|
||||||
ReturnValue_t initializeLocalDataPool(localpool::DataPool& localDataPoolMap,
|
ReturnValue_t initializeLocalDataPool(localpool::DataPool& localDataPoolMap,
|
||||||
|
@ -23,16 +23,20 @@ enum HkPoolIds {
|
|||||||
|
|
||||||
enum CfgPoolIds { BATTERY_HEATER_MODE = 0, BATTHEAT_LOW_LIMIT = 1, BATTHEAT_HIGH_LIMIT = 2 };
|
enum CfgPoolIds { BATTERY_HEATER_MODE = 0, BATTHEAT_LOW_LIMIT = 1, BATTHEAT_HIGH_LIMIT = 2 };
|
||||||
|
|
||||||
static constexpr DeviceCommandId_t READ_HK = 0;
|
static constexpr DeviceCommandId_t GET_HK = 0;
|
||||||
static constexpr DeviceCommandId_t PING = 1;
|
static constexpr DeviceCommandId_t PING = 1;
|
||||||
static constexpr DeviceCommandId_t REBOOT = 2;
|
static constexpr DeviceCommandId_t REBOOT = 2;
|
||||||
static constexpr DeviceCommandId_t RESET_COUNTERS = 3;
|
static constexpr DeviceCommandId_t RESET_COUNTERS = 3;
|
||||||
static constexpr DeviceCommandId_t RESTORE_DEFAULT_CONFIG = 4;
|
// This is the mnemonic GomSpace chose, but this command actually restores the default config
|
||||||
static constexpr DeviceCommandId_t READ_CONFIG = 5;
|
static constexpr DeviceCommandId_t CONFIG_CMD = 4;
|
||||||
static constexpr DeviceCommandId_t WRITE_CONFIG = 6;
|
static constexpr DeviceCommandId_t CONFIG_GET = 5;
|
||||||
|
static constexpr DeviceCommandId_t CONFIG_SET = 6;
|
||||||
|
|
||||||
static constexpr DeviceCommandId_t MANUAL_HEATER_ON = 10;
|
static constexpr DeviceCommandId_t MAN_HEAT_ON = 10;
|
||||||
static constexpr DeviceCommandId_t MANUAL_HEATER_OFF = 11;
|
static constexpr DeviceCommandId_t MAN_HEAT_OFF = 11;
|
||||||
|
|
||||||
|
static constexpr uint8_t RESET_COUNTERS_MAGIC_VALUE = 0x42;
|
||||||
|
static constexpr uint8_t DEFAULT_PING_SENT_BYTE = 0x07;
|
||||||
|
|
||||||
static constexpr uint32_t HK_SET_ID = 0;
|
static constexpr uint32_t HK_SET_ID = 0;
|
||||||
static constexpr uint32_t CFG_SET_ID = 1;
|
static constexpr uint32_t CFG_SET_ID = 1;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user