Skip to content
Snippets Groups Projects
Commit 7650a178 authored by Grigoris Pavlakis's avatar Grigoris Pavlakis
Browse files

Update reportParameterIds() to be void and store the message instead of returning

parent f7236902
No related branches found
No related tags found
No related merge requests found
...@@ -35,7 +35,6 @@ struct Parameter { ...@@ -35,7 +35,6 @@ struct Parameter {
* for parameter reporting and modification. * for parameter reporting and modification.
* *
* @todo Ensure that the parameter list is sorted by ID * @todo Ensure that the parameter list is sorted by ID
* @todo Convert reportParameterIds() to void when storeMessage() stores and doesn't print
*/ */
class ParameterService : public Service { class ParameterService : public Service {
...@@ -56,11 +55,11 @@ public: ...@@ -56,11 +55,11 @@ public:
* **for the parameters specified in the carried valid IDs**. * **for the parameters specified in the carried valid IDs**.
* *
* No sophisticated error checking for now, just whether the package is of the correct type * No sophisticated error checking for now, just whether the package is of the correct type
* and whether the requested IDs are valid, ignoring the invalid ones. * and whether the requested IDs are valid, ignoring the invalid ones. If no IDs are correct,
* the returned message shall be empty.
* *
* @param paramId: a valid TC[20, 1] packet carrying the requested parameter IDs * @param paramId: a valid TC[20, 1] packet carrying the requested parameter IDs
* @return A TM[20, 2] packet containing the valid parameter IDs and their settings. * @return None (messages are stored using storeMessage())
* @return Empty TM[20, 2] packet on wrong type.
* *
* @todo Generate failure notifs where needed when ST[01] is ready * @todo Generate failure notifs where needed when ST[01] is ready
* *
...@@ -70,7 +69,7 @@ public: ...@@ -70,7 +69,7 @@ public:
* *
* Everything apart from the setting data is uint16 (setting data are uint32 for now) * Everything apart from the setting data is uint16 (setting data are uint32 for now)
*/ */
Message reportParameterIds(Message paramIds); void reportParameterIds(Message paramIds);
/** /**
* This function receives a TC[20, 3] message and after checking whether its type is correct, * This function receives a TC[20, 3] message and after checking whether its type is correct,
......
...@@ -28,7 +28,7 @@ ParameterService::ParameterService() { ...@@ -28,7 +28,7 @@ ParameterService::ParameterService() {
#endif #endif
} }
Message ParameterService::reportParameterIds(Message paramIds) { void ParameterService::reportParameterIds(Message paramIds) {
Message reqParam(20, 2, Message::TM, 1); // empty TM[20, 2] parameter report message Message reqParam(20, 2, Message::TM, 1); // empty TM[20, 2] parameter report message
if (paramIds.packetType == Message::TC && paramIds.serviceType == 20 && if (paramIds.packetType == Message::TC && paramIds.serviceType == 20 &&
...@@ -50,7 +50,6 @@ Message ParameterService::reportParameterIds(Message paramIds) { ...@@ -50,7 +50,6 @@ Message ParameterService::reportParameterIds(Message paramIds) {
} }
storeMessage(reqParam); storeMessage(reqParam);
return reqParam; // this has to stay for now because no other way for testing
} }
void ParameterService::setParameterIds(Message newParamValues) { void ParameterService::setParameterIds(Message newParamValues) {
......
#include "catch2/catch.hpp" #include "catch2/catch.hpp"
#include "Services/ParameterService.hpp" #include "Services/ParameterService.hpp"
#include "Message.hpp" #include "Message.hpp"
#include "ServiceTests.hpp"
#define CATCH_CONFIG_MAIN #define CATCH_CONFIG_MAIN
...@@ -19,7 +20,8 @@ TEST_CASE("Parameter Report Subservice") { ...@@ -19,7 +20,8 @@ TEST_CASE("Parameter Report Subservice") {
request.appendUint16(34672); // faulty ID in this context request.appendUint16(34672); // faulty ID in this context
request.appendUint16(3); // valid request.appendUint16(3); // valid
report = pserv.reportParameterIds(request); pserv.reportParameterIds(request);
report = ServiceTests::get(0);
request.resetRead(); request.resetRead();
uint16_t repIdCount = report.readUint16(); uint16_t repIdCount = report.readUint16();
...@@ -33,7 +35,9 @@ TEST_CASE("Parameter Report Subservice") { ...@@ -33,7 +35,9 @@ TEST_CASE("Parameter Report Subservice") {
SECTION("Wrong Message Type Handling Test") { SECTION("Wrong Message Type Handling Test") {
Message falseRequest(15, 3, Message::TM, 1); //a totally wrong message Message falseRequest(15, 3, Message::TM, 1); //a totally wrong message
Message response = pserv.reportParameterIds(falseRequest);
pserv.reportParameterIds(falseRequest);
Message response = ServiceTests::get(0);
CHECK(response.messageType == 2); CHECK(response.messageType == 2);
CHECK(response.serviceType == 20); CHECK(response.serviceType == 20);
CHECK(response.packetType == Message::TM); CHECK(response.packetType == Message::TM);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment