Skip to content
Snippets Groups Projects
Commit be71f15b authored by athatheo's avatar athatheo
Browse files

Merge branch 'st17-tc-tm-split' into 'master'

Split TCs of ST17 into some TMs

Closes #164

See merge request acubesat/obc/ecss-services!97
parents 520e1fa7 e4f4fcbf
No related branches found
No related tags found
No related merge requests found
...@@ -10,8 +10,6 @@ ...@@ -10,8 +10,6 @@
*/ */
class TestService : public Service { class TestService : public Service {
public: public:
inline static const uint8_t ServiceType = 17; inline static const uint8_t ServiceType = 17;
enum MessageType : uint8_t { enum MessageType : uint8_t {
...@@ -30,19 +28,28 @@ public: ...@@ -30,19 +28,28 @@ public:
*/ */
void areYouAlive(Message& request); 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 * TC[17,3] perform an on-board connection test
* *
* @todo Only respond if we have the correct APID
*/ */
void onBoardConnection(Message& request); 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 * 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 * way that the subservices are selected is for the time being based on the messageType(class
* member of class Message) of the param message * 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); void execute(Message& message);
}; };
......
...@@ -5,19 +5,23 @@ ...@@ -5,19 +5,23 @@
void TestService::areYouAlive(Message& request) { void TestService::areYouAlive(Message& request) {
request.assertTC(TestService::ServiceType, TestService::MessageType::AreYouAliveTest); request.assertTC(TestService::ServiceType, TestService::MessageType::AreYouAliveTest);
// TM[17,2] are-you-alive connection test report areYouAliveReport();
Message report = createTM(TestService::MessageType::AreYouAliveTestReport); }
void TestService::areYouAliveReport() {
Message report = createTM(TestService::MessageType::AreYouAliveTestReport);
storeMessage(report); storeMessage(report);
} }
void TestService::onBoardConnection(Message& request) { void TestService::onBoardConnection(Message& request) {
request.assertTC(TestService::ServiceType, TestService::MessageType::OnBoardConnectionTest); request.assertTC(TestService::ServiceType, TestService::MessageType::OnBoardConnectionTest);
// TM[17,4] on-board connection test report uint16_t applicationProcessId = request.readUint16();
Message report = createTM(TestService::MessageType::OnBoardConnectionTestReport); onBoardConnectionReport(applicationProcessId);
}
report.appendUint16(request.readUint16()); void TestService::onBoardConnectionReport(uint16_t applicationProcessId) {
// just print it on the screen Message report = createTM(TestService::MessageType::OnBoardConnectionTestReport);
report.appendUint16(applicationProcessId);
storeMessage(report); storeMessage(report);
} }
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
TestService& testService = Services.testService; 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); Message receivedPacket = Message(TestService::ServiceType, TestService::MessageType::AreYouAliveTest, Message::TC, 1);
MessageParser::execute(receivedPacket); MessageParser::execute(receivedPacket);
REQUIRE(ServiceTests::hasOneMessage()); REQUIRE(ServiceTests::hasOneMessage());
...@@ -16,7 +16,16 @@ TEST_CASE("TM[17,1]", "[service][st17]") { ...@@ -16,7 +16,16 @@ TEST_CASE("TM[17,1]", "[service][st17]") {
REQUIRE(response.dataSize == 0); 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); Message receivedPacket = Message(TestService::ServiceType, TestService::MessageType::OnBoardConnectionTest, Message::TC, 1);
receivedPacket.appendEnum16(40); receivedPacket.appendEnum16(40);
MessageParser::execute(receivedPacket); MessageParser::execute(receivedPacket);
...@@ -28,3 +37,13 @@ TEST_CASE("TM[17,3]", "[service][st17]") { ...@@ -28,3 +37,13 @@ TEST_CASE("TM[17,3]", "[service][st17]") {
REQUIRE(response.dataSize == 2); REQUIRE(response.dataSize == 2);
CHECK(response.readEnum16() == 40); 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);
}
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