Skip to content
Snippets Groups Projects
Unverified Commit 5e323989 authored by Grigoris Pavlakis's avatar Grigoris Pavlakis
Browse files

Fix an off-by-one in the safeguard's bit index

Other changes: Add a couple more tests
parent 9bc44384
No related branches found
No related tags found
No related merge requests found
......@@ -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;
}
}
......
......@@ -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();
}
}
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