diff --git a/inc/Message.hpp b/inc/Message.hpp index cc4d448e8a44175b2d3942b5c77df578cd3e9240..8ce47f8dd5bc0a021f30ad18035ac7c4ea90151d 100644 --- a/inc/Message.hpp +++ b/inc/Message.hpp @@ -23,6 +23,12 @@ class Message { public: Message () = default; + + bool operator==(const Message &msg) const { + return (this->packetType == msg.packetType) && (this->data == msg.data) && + (this->messageType == msg.messageType) && (this->serviceType == msg.serviceType); + } + enum PacketType { TM = 0, // Telemetry TC = 1 // Telecommand diff --git a/inc/Services/TimeBasedSchedulingService.hpp b/inc/Services/TimeBasedSchedulingService.hpp index 6a510a0271bf3923003540eb347eea433746fbac..e7c802ad4b7182c9e7426e669b6e406d3c2e4ed5 100644 --- a/inc/Services/TimeBasedSchedulingService.hpp +++ b/inc/Services/TimeBasedSchedulingService.hpp @@ -22,7 +22,7 @@ namespace unit_test { struct Tester; -} +} // namespace unit_test class TimeBasedSchedulingService : public Service { public: diff --git a/src/Services/TimeBasedSchedulingService.cpp b/src/Services/TimeBasedSchedulingService.cpp index 294363d607be4f59c4d43c09aefb6003a1fa4a9b..37814c7851666b4dca181e9f0eabe7b7ddbdcc45 100644 --- a/src/Services/TimeBasedSchedulingService.cpp +++ b/src/Services/TimeBasedSchedulingService.cpp @@ -50,9 +50,10 @@ void TimeBasedSchedulingService::insertActivities(Message &request) { (currentTime + TIME_MARGIN_FOR_ACTIVATION))) { // todo: Send a failed start of execution + request.readPosition += ECSS_EVENT_SERVICE_STRING_SIZE; } else { // Get the TC packet request - uint8_t requestData[ECSS_EVENT_SERVICE_STRING_SIZE]; + uint8_t requestData[ECSS_EVENT_SERVICE_STRING_SIZE] = {0}; request.readString(requestData, ECSS_EVENT_SERVICE_STRING_SIZE); Message receivedTCPacket = msgParser.parseRequestTC(requestData); ScheduledActivity newActivity; // Create the new activity diff --git a/test/Services/TimeBasedSchedulingService.cpp b/test/Services/TimeBasedSchedulingService.cpp index de64571b25238e8d25a4f0e7e926acfba2944741..684e322f0bef7ed106204204077b78d0ffd68f85 100644 --- a/test/Services/TimeBasedSchedulingService.cpp +++ b/test/Services/TimeBasedSchedulingService.cpp @@ -38,17 +38,16 @@ TEST_CASE("TC[11,2]", "[service][st11]") { TimeBasedSchedulingService timeSchedulingService; timeSchedulingService.disableScheduleExecution(receivedMessage); CHECK(not unit_test::Tester::executionFunctionStatus(timeSchedulingService)); - auto sch = unit_test::Tester::scheduledActivities(timeSchedulingService); } TEST_CASE("TC[11,4]", "[service][st11]") { Message receivedMessage(11, 4, Message::TC, 1), - testMessage1(6, 5, Message::TC, 4), testMessage2(6, 5, Message::TC, 6), - testMessage3(6, 5, Message::TC, 7); + testMessage1(6, 5, Message::TC, 4), testMessage2(4, 5, Message::TC, 6), + testMessage3(3, 2, Message::TC, 7); MessageParser msgParser; - receivedMessage.appendUint16(3); + receivedMessage.appendUint16(3); // Number od instructions // Test activity 1 testMessage1.appendUint16(4253); // todo: Append dummy data @@ -57,12 +56,12 @@ TEST_CASE("TC[11,4]", "[service][st11]") { // Test activity 2 testMessage2.appendUint16(45667); // todo: Append dummy data - receivedMessage.appendUint32(1556435); // todo: Append actual time + receivedMessage.appendUint32(1); // todo: Append actual time receivedMessage.appendString(msgParser.convertTCToStr(testMessage2)); // Test activity 3 testMessage3.appendUint16(456); // todo: Append dummy data - receivedMessage.appendUint32(1556435); // todo: Append actual time + receivedMessage.appendUint32(1726435); // todo: Append actual time receivedMessage.appendString(msgParser.convertTCToStr(testMessage3)); @@ -70,9 +69,15 @@ TEST_CASE("TC[11,4]", "[service][st11]") { timeBasedSchedulingService.insertActivities(receivedMessage); auto scheduledActivities = unit_test::Tester::scheduledActivities(timeBasedSchedulingService); - // std::cout << scheduledActivities.size() << std::endl; + CHECK(scheduledActivities.size() == 2); // Two will be inserted (Second is invalid) REQUIRE(scheduledActivities.at(0).requestReleaseTime == 1556435); - REQUIRE(scheduledActivities.at(1).requestReleaseTime == 1556435); - REQUIRE(scheduledActivities.at(2).requestReleaseTime == 1556435); + REQUIRE(scheduledActivities.at(1).requestReleaseTime == 1726435); + //CHECK(memcmp(&scheduledActivities.at(0).request, &testMessage2, sizeof(Message))); + std::cout << scheduledActivities.at(0).request.data << " " << testMessage1.data << std::endl; + if (scheduledActivities.at(0).request == testMessage1) { + std::cout << "Message are the same!!" << std::endl; + } + //CHECK(scheduledActivities.at(0).request == testMessage1); + //REQUIRE(scheduledActivities.at(2).requestReleaseTime == 1556435); //REQUIRE(scheduledActivities.at(0).requestID.applicationID == 45); }