diff --git a/src/Services/Parameter.cpp b/src/Services/Parameter.cpp index 7c825324c83744bf342d7afef7402ca525b0c496..fae8917119ab250cfcb7a4d4545fc122a4bb9d0e 100644 --- a/src/Services/Parameter.cpp +++ b/src/Services/Parameter.cpp @@ -17,7 +17,7 @@ Parameter::Parameter(uint8_t newPtc, uint8_t newPfc, ValueType initialValue, Upd void Parameter::setCurrentValue(ValueType newVal) { // set the value only if the parameter can be updated manually - if (flags[2]) { + if (flags[1]) { currentValue = newVal; } } diff --git a/test/Services/ParameterService.cpp b/test/Services/ParameterService.cpp index 65bb50b322b0b44b9bebfb44cb6581730e26732b..25188e30e91887015ebac16f81d72aafd31accef 100644 --- a/test/Services/ParameterService.cpp +++ b/test/Services/ParameterService.cpp @@ -10,8 +10,7 @@ void foo(ValueType* bar) { // sample function } /* test ideas: -* parameter setting while flag is active -* requesting only invalid parameter IDs +* * */ @@ -49,9 +48,29 @@ TEST_CASE("Parameter Service - General") { } TEST_CASE("Parameter Report Subservice") { -// SECTION("All requested parameters invalid") { -// -// } + SECTION("All requested parameters invalid") { + Message request = Message(20, 1, Message::TC, 1); + request.appendUint16(3); + request.appendUint16(54432); + request.appendUint16(60000); + request.appendUint16(65535); + + MessageParser::execute(request); + CHECK(ServiceTests::get(0).serviceType == 1); + CHECK(ServiceTests::get(0).messageType == 4); + CHECK(ServiceTests::get(1).serviceType == 1); + CHECK(ServiceTests::get(1).messageType == 4); + CHECK(ServiceTests::get(2).serviceType == 1); + CHECK(ServiceTests::get(2).messageType == 4); + + Message report = ServiceTests::get(3); + CHECK(report.serviceType == 20); + CHECK(report.messageType == 2); + CHECK(report.readUint16() == 0); // the message shall be empty + + ServiceTests::reset(); + Services.reset(); + } SECTION("Faulty instruction handling") { Parameter param0 = Parameter(3, 14); @@ -137,4 +156,31 @@ TEST_CASE("Parameter Setting Subservice") { ServiceTests::reset(); Services.reset(); } + + SECTION("Attempt to set parameter with no manual update availability") { + Parameter param1 = Parameter(1, 7, 12); + pserv.addNewParameter(1, param1, "100"); + + Message setRequest = Message(20, 3, Message::TC, 1); + setRequest.appendUint16(1); + setRequest.appendUint16(1); + setRequest.appendUint32(0xBAAAAAAD); + + MessageParser::execute(setRequest); + + Message infoRequest = Message(20, 1, Message::TC, 1); + infoRequest.appendUint16(1); + infoRequest.appendUint16(1); + + MessageParser::execute(infoRequest); + + Message report = ServiceTests::get(0); + + CHECK(report.readUint16() == 1); + CHECK(report.readUint16() == 1); + CHECK_FALSE(report.readUint32() == 0xBAAAAAAD); + + ServiceTests::reset(); + Services.reset(); + } }