breaking everything, WIP
fsfw/fsfw/pipeline/head There was a failure building this commit Details

This commit is contained in:
Ulrich Mohr 2023-06-19 17:27:25 +02:00
parent 0da490481e
commit e831ba11d2
8 changed files with 86 additions and 108 deletions

View File

@ -10,8 +10,7 @@ ActionHelper::~ActionHelper() = default;
ReturnValue_t ActionHelper::handleActionMessage(CommandMessage* command) {
if (command->getCommand() == ActionMessage::EXECUTE_ACTION) {
ActionId_t currentAction = ActionMessage::getActionId(command);
prepareExecution(command->getSender(), currentAction, ActionMessage::getStoreId(command));
prepareExecution(command->getSender(), ActionMessage::getOffset(command), ActionMessage::getStoreId(command));
return returnvalue::OK;
} else {
return CommandMessage::UNKNOWN_COMMAND;
@ -61,7 +60,7 @@ MessageQueueIF const * ActionHelper::getQueue() const {
return queueToUse;
}
void ActionHelper::prepareExecution(MessageQueueId_t commandedBy, ActionId_t actionId,
void ActionHelper::prepareExecution(MessageQueueId_t commandedBy, size_t offset,
store_address_t dataAddress) {
const uint8_t* dataPtr = nullptr;
size_t size = 0;
@ -73,6 +72,10 @@ void ActionHelper::prepareExecution(MessageQueueId_t commandedBy, ActionId_t act
ipcStore->deleteData(dataAddress);
return;
}
//add offset, deserialize action
auto actionIter = actionMap.find(actionId);
if (actionIter == actionMap.end()){
CommandMessage reply;
@ -82,6 +85,8 @@ void ActionHelper::prepareExecution(MessageQueueId_t commandedBy, ActionId_t act
return;
}
Action* action = actionIter->second;
dataPtr +=6;
size -=6;
result = action->deSerialize(&dataPtr, &size, SerializeIF::Endianness::NETWORK);
if ((result != returnvalue::OK) || (size != 0)){ //TODO write unittest for second condition
CommandMessage reply;

View File

@ -127,7 +127,7 @@ class ActionHelper {
* @param actionId ID of action to be done
* @param dataAddress Address of additional data in IPC Store
*/
virtual void prepareExecution(MessageQueueId_t commandedBy, ActionId_t actionId,
virtual void prepareExecution(MessageQueueId_t commandedBy, size_t offset,
store_address_t dataAddress);
/**
* @brief Default implementation is empty.

View File

@ -6,14 +6,14 @@ ActionMessage::ActionMessage() = default;
ActionMessage::~ActionMessage() = default;
void ActionMessage::setCommand(CommandMessage* message, ActionId_t fid,
void ActionMessage::setCommand(CommandMessage* message, size_t offset,
store_address_t parameters) {
message->setCommand(EXECUTE_ACTION);
message->setParameter(fid);
message->setParameter(offset);
message->setParameter2(parameters.raw);
}
ActionId_t ActionMessage::getActionId(const CommandMessage* message) {
size_t ActionMessage::getOffset(const CommandMessage* message) {
return ActionId_t(message->getParameter());
}

View File

@ -27,9 +27,9 @@ class ActionMessage {
static const Command_t COMPLETION_FAILED = MAKE_COMMAND_ID(6);
virtual ~ActionMessage();
static void setCommand(CommandMessage* message, ActionId_t fid, store_address_t parameters);
static void setCommand(CommandMessage* message, size_t offset, store_address_t parameters);
static ActionId_t getActionId(const CommandMessage* message);
static size_t getOffset(const CommandMessage* message);
static store_address_t getStoreId(const CommandMessage* message);
static void setStepReply(CommandMessage* message, ActionId_t fid, uint8_t step,

View File

@ -216,10 +216,10 @@ ReturnValue_t DeviceHandlerBase::initialize() {
return result;
}
result = poolManager.initialize(commandQueue);
if (result != returnvalue::OK) {
return result;
}
// result = poolManager.initialize(commandQueue);
// if (result != returnvalue::OK) {
// return result;
// }
fillCommandAndReplyMap();

View File

@ -312,37 +312,10 @@ class DeviceHandlerBase : public DeviceHandlerIF,
* - Anything else triggers an even with the returnvalue as a parameter
*/
virtual ReturnValue_t buildTransitionDeviceCommand(DeviceCommandId_t *id) = 0;
//TODO Remove and update documentation
/**
* @brief Build a device command packet from data supplied by a direct
* command (PUS Service 8)
* @details
* This will be called if an functional command via PUS Service 8 is received and is
* the primary interface for functional command instead of #executeAction for users. The
* supplied ActionId_t action ID will be converted to a DeviceCommandId_t command ID after
* an internal check whether the action ID is a key in the device command map.
*
* #rawPacket and #rawPacketLen should be set by this method to the packet to be sent.
* The existence of the command in the command map and the command size check against 0 are
* done by the base class.
*
* @param deviceCommand The command to build, already checked against deviceCommandMap
* @param commandData Pointer to the data from the direct command
* @param commandDataLen Length of commandData
* @return
* - @c returnvalue::OK to send command after #rawPacket and #rawPacketLen
* have been set.
* - @c HasActionsIF::EXECUTION_COMPLETE to generate a finish reply immediately. This can
* be used if no reply is expected
* - Anything else triggers an event with the return code as a parameter as well as a
* step reply failed with the return code
*/
virtual ReturnValue_t buildCommandFromCommand(DeviceCommandId_t deviceCommand,
const uint8_t *commandData,
size_t commandDataLen) {return returnvalue::FAILED;}
/* Reply handling */
//TODO add way to say, not enough data in buffer, try again later
//ComIF needs to decide if buffer will be appended or overwritten
/**
* @brief Scans a buffer for a valid reply.
* @details

View File

@ -61,7 +61,7 @@ ReturnValue_t TestDevice::buildNormalDeviceCommand(DeviceCommandId_t* id) {
if (DeviceHandlerBase::isAwaitingReply()) {
return NOTHING_TO_SEND;
}
return buildCommandFromCommand(*id, nullptr, 0);
return 0; //buildCommandFromCommand(*id, nullptr, 0);
}
ReturnValue_t TestDevice::buildTransitionDeviceCommand(DeviceCommandId_t* id) {
@ -135,74 +135,74 @@ void TestDevice::doTransition(Mode_t modeFrom, Submode_t submodeFrom) {
}
}
ReturnValue_t TestDevice::buildCommandFromCommand(DeviceCommandId_t deviceCommand,
const uint8_t* commandData,
size_t commandDataLen) {
using namespace testdevice;
ReturnValue_t result = returnvalue::OK;
switch (deviceCommand) {
case (TEST_NORMAL_MODE_CMD): {
commandSent = true;
result = buildNormalModeCommand(deviceCommand, commandData, commandDataLen);
break;
}
// ReturnValue_t TestDevice::buildCommandFromCommand(DeviceCommandId_t deviceCommand,
// const uint8_t* commandData,
// size_t commandDataLen) {
// using namespace testdevice;
// ReturnValue_t result = returnvalue::OK;
// switch (deviceCommand) {
// case (TEST_NORMAL_MODE_CMD): {
// commandSent = true;
// result = buildNormalModeCommand(deviceCommand, commandData, commandDataLen);
// break;
// }
case (TEST_COMMAND_0): {
commandSent = true;
result = buildTestCommand0(deviceCommand, commandData, commandDataLen);
break;
}
// case (TEST_COMMAND_0): {
// commandSent = true;
// result = buildTestCommand0(deviceCommand, commandData, commandDataLen);
// break;
// }
case (TEST_COMMAND_1): {
commandSent = true;
result = buildTestCommand1(deviceCommand, commandData, commandDataLen);
break;
}
case (TEST_NOTIF_SNAPSHOT_VAR): {
if (changingDatasets) {
changingDatasets = false;
}
// case (TEST_COMMAND_1): {
// commandSent = true;
// result = buildTestCommand1(deviceCommand, commandData, commandDataLen);
// break;
// }
// case (TEST_NOTIF_SNAPSHOT_VAR): {
// if (changingDatasets) {
// changingDatasets = false;
// }
PoolReadGuard readHelper(&dataset.testUint8Var);
if (deviceIdx == testdevice::DeviceIndex::DEVICE_0) {
/* This will trigger a variable notification to the demo controller */
dataset.testUint8Var = 220;
dataset.testUint8Var.setValid(true);
} else if (deviceIdx == testdevice::DeviceIndex::DEVICE_1) {
/* This will trigger a variable snapshot to the demo controller */
dataset.testUint8Var = 30;
dataset.testUint8Var.setValid(true);
}
// PoolReadGuard readHelper(&dataset.testUint8Var);
// if (deviceIdx == testdevice::DeviceIndex::DEVICE_0) {
// /* This will trigger a variable notification to the demo controller */
// dataset.testUint8Var = 220;
// dataset.testUint8Var.setValid(true);
// } else if (deviceIdx == testdevice::DeviceIndex::DEVICE_1) {
// /* This will trigger a variable snapshot to the demo controller */
// dataset.testUint8Var = 30;
// dataset.testUint8Var.setValid(true);
// }
break;
}
case (TEST_NOTIF_SNAPSHOT_SET): {
if (changingDatasets) {
changingDatasets = false;
}
// break;
// }
// case (TEST_NOTIF_SNAPSHOT_SET): {
// if (changingDatasets) {
// changingDatasets = false;
// }
PoolReadGuard readHelper(&dataset.testFloat3Vec);
// PoolReadGuard readHelper(&dataset.testFloat3Vec);
if (deviceIdx == testdevice::DeviceIndex::DEVICE_0) {
/* This will trigger a variable notification to the demo controller */
dataset.testFloat3Vec.value[0] = 60;
dataset.testFloat3Vec.value[1] = 70;
dataset.testFloat3Vec.value[2] = 55;
dataset.testFloat3Vec.setValid(true);
} else if (deviceIdx == testdevice::DeviceIndex::DEVICE_1) {
/* This will trigger a variable notification to the demo controller */
dataset.testFloat3Vec.value[0] = -60;
dataset.testFloat3Vec.value[1] = -70;
dataset.testFloat3Vec.value[2] = -55;
dataset.testFloat3Vec.setValid(true);
}
break;
}
default:
result = DeviceHandlerIF::COMMAND_NOT_SUPPORTED;
}
return result;
}
// if (deviceIdx == testdevice::DeviceIndex::DEVICE_0) {
// /* This will trigger a variable notification to the demo controller */
// dataset.testFloat3Vec.value[0] = 60;
// dataset.testFloat3Vec.value[1] = 70;
// dataset.testFloat3Vec.value[2] = 55;
// dataset.testFloat3Vec.setValid(true);
// } else if (deviceIdx == testdevice::DeviceIndex::DEVICE_1) {
// /* This will trigger a variable notification to the demo controller */
// dataset.testFloat3Vec.value[0] = -60;
// dataset.testFloat3Vec.value[1] = -70;
// dataset.testFloat3Vec.value[2] = -55;
// dataset.testFloat3Vec.setValid(true);
// }
// break;
// }
// default:
// result = DeviceHandlerIF::COMMAND_NOT_SUPPORTED;
// }
// return result;
// }
ReturnValue_t TestDevice::buildNormalModeCommand(DeviceCommandId_t deviceCommand,
const uint8_t* commandData,

View File

@ -72,9 +72,9 @@ class TestDevice : public DeviceHandlerBase {
virtual ReturnValue_t buildNormalDeviceCommand(DeviceCommandId_t* id) override;
virtual ReturnValue_t buildTransitionDeviceCommand(DeviceCommandId_t* id) override;
virtual ReturnValue_t buildCommandFromCommand(DeviceCommandId_t deviceCommand,
const uint8_t* commandData,
size_t commandDataLen) override;
// virtual ReturnValue_t buildCommandFromCommand(DeviceCommandId_t deviceCommand,
// const uint8_t* commandData,
// size_t commandDataLen) override;
virtual void fillCommandAndReplyMap() override;