Issues with CommandMessage / MessageQeueueMessage #102
Labels
No Label
API Change
Breaking API Change
bug
build
cosmetics
Documentation
duplicate
feature
help wanted
hotfix
invalid
question
Refactor
Tests
wontfix
No Milestone
No Assignees
1 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: fsfw/fsfw#102
Loading…
Reference in New Issue
No description provided.
Delete Branch "%!s(<nil>)"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
I am trying to implement the message forwarding for Housekeeping message. Unfortunately, I have issues with the current handling of messages.
I can't cast the command message to another message type.
I basically want to have a third uint32_t parameter for the HK messages. The command message only offers two uint32_t parameters.
There are 3 possible solutions.
Add
getParameter3()
to the command message interface or inherit from command message and add getParameter3 there. I'm not happy with that. The command message should not change just because I need one more parameter, especially because most queues will just use these regular command messages (and can have the smaller size therefore). Dynamic casting does not work in for simply casting to another message type.The second solution is to instantiate my new message (which is almost identical to CommandMessage) and copy the content of the command message into the new message. Not ideal. Unnecessary copying, the data is already there, I just cant access it.
The clean solution requires a little bit more work. To increase the flexibility, CommandMessage should operate on the buffer instead of owning it. This can be achieved
by only owning a pointer to the MessageQueueMessage instead of inheriting from it. That way, I can simply pass that pointer to another message type (like HK message with 3 parameters) to access the third parameter. Or a fourth. Or do some other magic.
Unfortunately, this means a little bit more writing work and a lot of changes in existing code. For example, the command message instantiations would change (for every command message instantiation):
The MQM owns the internalBuffer. The command message then operates on that buffer. And now the only thing I have to do is to pass the message address to another message type which operates on the internal buffer.
I also encountered another issue: The message queue IF is coupled to the MAX_MESSAGE_SIZ (24 bytes). MQM pointers are used. This would be a perfect place for an interface. All functions the message queue implementations use can mostly be specified in an interface.
This new MQM IF would have most of the interface of MQM as abstract functions. But now I could pass messages with different sizes, and access their size with the abstract function.
UPDATE: I had another look at MQM: An additional
getMaximumMessageSize()
function andgetMessageSize()
would propably be necessary in the interface.All messages would implement this interface, for example the CommandMessage implements the interface too, but just calls the MQM functions by using the pointer to the MQM to implement all abstract functions.
I implemented these changes and tested them, and everything worked as before. Unfortunately, I can not test all parts of the FSFW right now, and this changed a lot of files, because command mesages are used in many places. But DHB/CSB/PSB were tested and worked as before.
UPDATE: First solution was now chosen:
getParameter3
is used now.