minor improvement, bugfix for reboot cmd
All checks were successful
EIVE/eive-obsw/pipeline/head This commit looks good

This commit is contained in:
Robin Müller 2022-02-03 16:04:06 +01:00
parent a77d5f3669
commit 3250a9f489
No known key found for this signature in database
GPG Key ID: 71B58F8A3CDFA9AC
3 changed files with 25 additions and 12 deletions

View File

@ -42,12 +42,13 @@ ReturnValue_t BpxBatteryHandler::buildTransitionDeviceCommand(DeviceCommandId_t*
} }
void BpxBatteryHandler::fillCommandAndReplyMap() { void BpxBatteryHandler::fillCommandAndReplyMap() {
insertInCommandAndReplyMap(BpxBattery::GET_HK, 1, &hkSet, 23); using namespace BpxBattery;
insertInCommandAndReplyMap(BpxBattery::PING, 1, nullptr, 3); insertInCommandAndReplyMap(GET_HK, 1, &hkSet, GET_HK_REPLY_LEN);
insertInCommandAndReplyMap(BpxBattery::PING, 1, nullptr, PING_REPLY_LEN);
insertInCommandAndReplyMap(BpxBattery::REBOOT, 1, nullptr, 0); insertInCommandAndReplyMap(BpxBattery::REBOOT, 1, nullptr, 0);
insertInCommandAndReplyMap(BpxBattery::RESET_COUNTERS, 1, nullptr, 2); insertInCommandAndReplyMap(BpxBattery::RESET_COUNTERS, 1, nullptr,EMPTY_REPLY_LEN);
insertInCommandAndReplyMap(BpxBattery::CONFIG_CMD, 1, nullptr, 2); insertInCommandAndReplyMap(BpxBattery::CONFIG_CMD, 1, nullptr, EMPTY_REPLY_LEN);
insertInCommandAndReplyMap(BpxBattery::CONFIG_GET, 1, &cfgSet, 5); insertInCommandAndReplyMap(BpxBattery::CONFIG_GET, 1, &cfgSet, CONFIG_GET_REPLY_LEN);
} }
ReturnValue_t BpxBatteryHandler::buildCommandFromCommand(DeviceCommandId_t deviceCommand, ReturnValue_t BpxBatteryHandler::buildCommandFromCommand(DeviceCommandId_t deviceCommand,
@ -140,9 +141,10 @@ 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;
switch (lastCmd) { switch (lastCmd) {
case (BpxBattery::GET_HK): { case (BpxBattery::GET_HK): {
if (remainingSize != 23) { if (remainingSize != GET_HK_REPLY_LEN) {
return DeviceHandlerIF::LENGTH_MISSMATCH; return DeviceHandlerIF::LENGTH_MISSMATCH;
} }
break; break;
@ -150,22 +152,25 @@ ReturnValue_t BpxBatteryHandler::scanForReply(const uint8_t* start, size_t remai
case (BpxBattery::PING): case (BpxBattery::PING):
case (BpxBattery::MAN_HEAT_ON): case (BpxBattery::MAN_HEAT_ON):
case (BpxBattery::MAN_HEAT_OFF): { case (BpxBattery::MAN_HEAT_OFF): {
if (remainingSize != 3) { if (remainingSize != PING_REPLY_LEN) {
return DeviceHandlerIF::LENGTH_MISSMATCH; return DeviceHandlerIF::LENGTH_MISSMATCH;
} }
break; break;
} }
case (BpxBattery::REBOOT): case (BpxBattery::REBOOT): {
// Ignore
break;
}
case (BpxBattery::RESET_COUNTERS): case (BpxBattery::RESET_COUNTERS):
case (BpxBattery::CONFIG_CMD): case (BpxBattery::CONFIG_CMD):
case (BpxBattery::CONFIG_SET): { case (BpxBattery::CONFIG_SET): {
if (remainingSize != 2) { if (remainingSize != EMPTY_REPLY_LEN) {
return DeviceHandlerIF::LENGTH_MISSMATCH; return DeviceHandlerIF::LENGTH_MISSMATCH;
} }
break; break;
} }
case (BpxBattery::CONFIG_GET): { case (BpxBattery::CONFIG_GET): {
if (remainingSize != 5) { if (remainingSize != CONFIG_GET_REPLY_LEN) {
return DeviceHandlerIF::LENGTH_MISSMATCH; return DeviceHandlerIF::LENGTH_MISSMATCH;
} }
@ -181,7 +186,7 @@ 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 (packet[1] != 0) { if (id != BpxBattery::REBOOT and packet[1] != 0) {
return DeviceHandlerIF::DEVICE_REPORTED_ERROR; return DeviceHandlerIF::DEVICE_REPORTED_ERROR;
} }
switch (id) { switch (id) {
@ -237,6 +242,9 @@ ReturnValue_t BpxBatteryHandler::interpretDeviceReply(DeviceCommandId_t id, cons
cfgSet.setValidity(true, true); cfgSet.setValidity(true, true);
break; break;
} }
case(BpxBattery::REBOOT): {
break;
}
default: { default: {
return DeviceHandlerIF::UNKNOWN_DEVICE_REPLY; return DeviceHandlerIF::UNKNOWN_DEVICE_REPLY;
} }

View File

@ -45,6 +45,11 @@ static constexpr uint8_t DEFAULT_PING_SENT_BYTE = 0x07;
static constexpr uint32_t HK_SET_ID = GET_HK; static constexpr uint32_t HK_SET_ID = GET_HK;
static constexpr uint32_t CFG_SET_ID = CONFIG_GET; static constexpr uint32_t CFG_SET_ID = CONFIG_GET;
static constexpr size_t GET_HK_REPLY_LEN = 23;
static constexpr size_t PING_REPLY_LEN = 3;
static constexpr size_t EMPTY_REPLY_LEN = 2;
static constexpr size_t CONFIG_GET_REPLY_LEN = 5;
static constexpr uint8_t PORT_PING = 1; static constexpr uint8_t PORT_PING = 1;
static constexpr uint8_t PORT_REBOOT = 4; static constexpr uint8_t PORT_REBOOT = 4;
static constexpr uint8_t PORT_GET_HK = 9; static constexpr uint8_t PORT_GET_HK = 9;

2
tmtc

@ -1 +1 @@
Subproject commit 890a20a07895bc1d06ad49f281a107a042a5dd03 Subproject commit 2b89a7f2697a21e9fc9101ca320afb7bf49c8e9d