From e4f4fcbf4e8b73eeae11307287ee950e1b2db4e8 Mon Sep 17 00:00:00 2001 From: athatheo <athatheoc@gmail.com> Date: Fri, 27 May 2022 17:56:21 +0200 Subject: [PATCH] Split TCs of ST17 into some TMs --- inc/Services/TestService.hpp | 15 +++++++++++---- src/Services/TestService.cpp | 16 ++++++++++------ test/Services/TestService.cpp | 23 +++++++++++++++++++++-- 3 files changed, 42 insertions(+), 12 deletions(-) diff --git a/inc/Services/TestService.hpp b/inc/Services/TestService.hpp index 82156b23..af37e9ff 100644 --- a/inc/Services/TestService.hpp +++ b/inc/Services/TestService.hpp @@ -10,8 +10,6 @@ */ class TestService : public Service { public: - - inline static const uint8_t ServiceType = 17; enum MessageType : uint8_t { @@ -30,19 +28,28 @@ public: */ void areYouAlive(Message& request); + /** + * TM[17,2] are-you-alive connection test report to show that the MCU is alive and well + */ + void areYouAliveReport(); + /** * TC[17,3] perform an on-board connection test * - * @todo Only respond if we have the correct APID */ void onBoardConnection(Message& request); + /** + * TM[17,4] on-board connection test report to show that the MCU is connected to the on-board + * @param applicationProcessId + */ + void onBoardConnectionReport(uint16_t applicationProcessId); + /** * It is responsible to call the suitable function that execute the proper subservice. The * way that the subservices are selected is for the time being based on the messageType(class * member of class Message) of the param message * - * @todo Error handling for the switch() in the implementation of this execute function */ void execute(Message& message); }; diff --git a/src/Services/TestService.cpp b/src/Services/TestService.cpp index 93c1ebee..d85d0206 100644 --- a/src/Services/TestService.cpp +++ b/src/Services/TestService.cpp @@ -5,19 +5,23 @@ void TestService::areYouAlive(Message& request) { request.assertTC(TestService::ServiceType, TestService::MessageType::AreYouAliveTest); - // TM[17,2] are-you-alive connection test report - Message report = createTM(TestService::MessageType::AreYouAliveTestReport); + areYouAliveReport(); +} +void TestService::areYouAliveReport() { + Message report = createTM(TestService::MessageType::AreYouAliveTestReport); storeMessage(report); } void TestService::onBoardConnection(Message& request) { request.assertTC(TestService::ServiceType, TestService::MessageType::OnBoardConnectionTest); - // TM[17,4] on-board connection test report - Message report = createTM(TestService::MessageType::OnBoardConnectionTestReport); + uint16_t applicationProcessId = request.readUint16(); + onBoardConnectionReport(applicationProcessId); +} - report.appendUint16(request.readUint16()); - // just print it on the screen +void TestService::onBoardConnectionReport(uint16_t applicationProcessId) { + Message report = createTM(TestService::MessageType::OnBoardConnectionTestReport); + report.appendUint16(applicationProcessId); storeMessage(report); } diff --git a/test/Services/TestService.cpp b/test/Services/TestService.cpp index 3424f95a..3a772b28 100644 --- a/test/Services/TestService.cpp +++ b/test/Services/TestService.cpp @@ -5,7 +5,7 @@ TestService& testService = Services.testService; -TEST_CASE("TM[17,1]", "[service][st17]") { +TEST_CASE("TC[17,1]", "[service][st17]") { Message receivedPacket = Message(TestService::ServiceType, TestService::MessageType::AreYouAliveTest, Message::TC, 1); MessageParser::execute(receivedPacket); REQUIRE(ServiceTests::hasOneMessage()); @@ -16,7 +16,16 @@ TEST_CASE("TM[17,1]", "[service][st17]") { REQUIRE(response.dataSize == 0); } -TEST_CASE("TM[17,3]", "[service][st17]") { +TEST_CASE("TM[17,2]", "[service][st17]") { + testService.areYouAliveReport(); + + Message response = ServiceTests::get(0); + CHECK(response.serviceType == TestService::ServiceType); + CHECK(response.messageType == TestService::MessageType::AreYouAliveTestReport); + REQUIRE(response.dataSize == 0); +} + +TEST_CASE("TC[17,3]", "[service][st17]") { Message receivedPacket = Message(TestService::ServiceType, TestService::MessageType::OnBoardConnectionTest, Message::TC, 1); receivedPacket.appendEnum16(40); MessageParser::execute(receivedPacket); @@ -28,3 +37,13 @@ TEST_CASE("TM[17,3]", "[service][st17]") { REQUIRE(response.dataSize == 2); CHECK(response.readEnum16() == 40); } + +TEST_CASE("TM[17,4]", "[service][st17]") { + testService.onBoardConnectionReport(40); + + Message response = ServiceTests::get(0); + CHECK(response.serviceType == TestService::ServiceType); + CHECK(response.messageType == TestService::MessageType::OnBoardConnectionTestReport); + REQUIRE(response.dataSize == 2); + CHECK(response.readEnum16() == 40); +} -- GitLab