Added custom Message functionality
This commit is contained in:
@@ -164,3 +164,12 @@
|
||||
LogPort = 8082
|
||||
StreamIP = "127.0.0.1"
|
||||
}
|
||||
|
||||
+LoggerService = {
|
||||
Class = LoggerService
|
||||
CPUs = 0x1
|
||||
+DebugConsumer = {
|
||||
Class = TcpLogger
|
||||
Port = 8082
|
||||
}
|
||||
}
|
||||
|
||||
@@ -86,6 +86,10 @@ int main() {
|
||||
printf("\n--- Test 6: TREE Command Enhancement ---\n");
|
||||
TestTreeCommand();
|
||||
Sleep::MSec(1000);
|
||||
|
||||
printf("\n--- Test 7: Custom MARTe Message (MSG) ---\n");
|
||||
TestMessageCommand();
|
||||
Sleep::MSec(1000);
|
||||
|
||||
printf("\nAll Integration Tests Finished.\n");
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
OBJSX = SchedulerTest.x TraceTest.x ValidationTest.x ConfigCommandTest.x TreeCommandTest.x TestCommon.x
|
||||
OBJSX = SchedulerTest.x TraceTest.x ValidationTest.x ConfigCommandTest.x TreeCommandTest.x MessageCommandTest.x TestCommon.x
|
||||
|
||||
PACKAGE = Test/Integration
|
||||
|
||||
|
||||
@@ -0,0 +1,72 @@
|
||||
#include "TestCommon.h"
|
||||
#include "ObjectRegistryDatabase.h"
|
||||
#include "DebugService.h"
|
||||
#include "StandardParser.h"
|
||||
#include "GlobalObjectsDatabase.h"
|
||||
#include <stdio.h>
|
||||
|
||||
using namespace MARTe;
|
||||
|
||||
namespace MARTe {
|
||||
|
||||
void TestMessageCommand() {
|
||||
printf("--- Test: Custom MARTe Message (MSG) ---\n");
|
||||
|
||||
ObjectRegistryDatabase::Instance()->Purge();
|
||||
Sleep::MSec(1000);
|
||||
|
||||
ConfigurationDatabase cdb;
|
||||
const char8 * const msg_test_config =
|
||||
"DebugService = {"
|
||||
" Class = DebugService "
|
||||
" ControlPort = 8120 "
|
||||
" UdpPort = 8121 "
|
||||
" StreamIP = \"127.0.0.1\" "
|
||||
"}";
|
||||
|
||||
StreamString ss = msg_test_config;
|
||||
ss.Seek(0);
|
||||
StandardParser parser(ss, cdb);
|
||||
if (!parser.Parse()) {
|
||||
printf("ERROR: Failed to parse config\n");
|
||||
return;
|
||||
}
|
||||
|
||||
// Initialize Service
|
||||
ReferenceT<DebugService> service("DebugService", GlobalObjectsDatabase::Instance()->GetStandardHeap());
|
||||
service->SetName("DebugService");
|
||||
|
||||
cdb.MoveToRoot();
|
||||
if (cdb.MoveRelative("DebugService")) {
|
||||
if (!service->Initialise(cdb)) {
|
||||
printf("ERROR: Failed to initialize DebugService\n");
|
||||
return;
|
||||
}
|
||||
}
|
||||
ObjectRegistryDatabase::Instance()->Insert(service);
|
||||
|
||||
if (ObjectRegistryDatabase::Instance()->Find("DebugService").IsValid()) {
|
||||
printf("DebugService successfully registered in ORD.\n");
|
||||
} else {
|
||||
printf("ERROR: DebugService NOT found in ORD.\n");
|
||||
}
|
||||
|
||||
printf("Service initialized on port 8120.\n");
|
||||
Sleep::MSec(500);
|
||||
|
||||
StreamString reply;
|
||||
if (SendCommandGAM(8120, "MSG DebugService UnknownFunc 0 Key1=Val1\\nKey2=Val2\n", reply)) {
|
||||
printf("MSG response received: %s", reply.Buffer());
|
||||
if (StringHelper::SearchString(reply.Buffer(), "OK MSG") != NULL_PTR(const char8 *)) {
|
||||
printf("SUCCESS: Asynchronous message dispatched correctly.\n");
|
||||
} else {
|
||||
printf("FAILURE: MSG command returned error.\n");
|
||||
}
|
||||
} else {
|
||||
printf("ERROR: MSG command communication failed\n");
|
||||
}
|
||||
|
||||
ObjectRegistryDatabase::Instance()->Purge();
|
||||
}
|
||||
|
||||
} // namespace MARTe
|
||||
@@ -7,6 +7,7 @@
|
||||
namespace MARTe {
|
||||
extern const char8 * const debug_test_config;
|
||||
bool SendCommandGAM(uint16 port, const char8* cmd, StreamString &reply);
|
||||
void TestMessageCommand();
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -55,6 +55,7 @@ public:
|
||||
service.HandleCommand("RESUME", NULL_PTR(BasicTCPSocket*));
|
||||
service.HandleCommand("LS /", NULL_PTR(BasicTCPSocket*));
|
||||
service.HandleCommand("INFO X.Y.Z", NULL_PTR(BasicTCPSocket*));
|
||||
service.HandleCommand("MSG DebugService DummyFunc 0 K=V", NULL_PTR(BasicTCPSocket*));
|
||||
|
||||
// 3. Broker Active Status
|
||||
volatile bool active = false;
|
||||
|
||||
Reference in New Issue
Block a user