My question : is there a way for me to publish data using C++ API and to subscribe to that same data using the Lua prototype?
Background –
I am using RTI Connext 5.0.0.30 , for my publishers set up I am making an IDL file that looks like the following
Test.idl
-----------------------------------------------------------
typedef long ArrayType[2];
module MyModule {
struct PhoneCall2 {
string<256> Caller;
string<256> Message;
long Time;
long Member3[6];
string<256> Diferent;
ArrayType Member1[52];
};
};
-----------------------------------------------------------
And using Rrtiddsgen to generate the publisher C++ file.
After writing data to the types
--- instance ->Member1[1][1] = 11;
and recompiling the publisher file using the generated makefile, I am using the publisher executable I get to publish the data.
On the subscriber side I am using an xml file with the following type tag field
USER_QOS_PROFILE.xml
-----------------------------------------------------------
<typedef name= 'ArrayType' type='long' arrayDimensions='2'/>
<module name="MyModule">
<struct name ="PhoneCall2" >
<member name ="Caller" type ="string" key ="true" stringMaxLength= "256"/>
<member name ="Message" type ="string" stringMaxLength= "256"/>
<member name ="Time" type ="long"/>
<member name ="Member3" type ="long" arrayDimensions='6'/>
<member name ="Diferent" type ="string" stringMaxLength= "256"/>
<member name ="Member1" type ="nonBasic" nonBasicTypeName='ArrayType' arrayDimensions='52'/>
</struct>
</module>
-----------------------------------------------------------
I am calling a lua file through the USER_QOS_PROFILE.xml participant library tag , and through the Lua file I am reading and printing the data
With this setup is it possible to have communications between this C++ publisher and Lua subscriber, and if not is there a way to have a similar setup, where Lua based subscribers are used to read data from a C++ API publisher.?
Hello Kenny,
Yes: it is possible to publish in C++ and subscribe in Lua! With RTI Connext DDS you can pick many languages (C/C++/Java/Ada/Lua/C#) and all your application will communicate with each other seamlessly!!
Let’s go to your specific example. It is very easy and you did almost all the steps:
Publisher in C++:
Let's now move to the subscriber in Lua:
a test.xml file is created that contains your type definition.
Now, run!!!
Please let me know if this answer your question,
Best,
Gianpiero Napoli
Thank you this worked out, but I do have another quick question. I have 2 subscriber codes, One in C++ and one in Lua that will both read information from a Publisher in C++ code. In my Subscriber in C++ I have the following code
participant->add_peer("4@builtin.udpv4://3.88.82.1");
participant->add_peer("4@builtin.udpv4://3.88.82.101");
participant->add_peer("4@builtin.udpv4://127.1.2.3");
participant->enable();
I want to double check, for my second subscriber if the equivalent in XML is the following, and if there is anything else I would need to include in the xnl file or in the Lua code.
<dds>
<qos_library name="MyLibrary">
<qos_profile name="DefaultProfile">
<participant_qos>
<discovery>
<initial_peers>
<element>4@builtin.udpv4://3.88.82.1</element>
<element>4@builtin.udpv4://3.88.82.101</element>
<element>4@builtin.udpv4://127.1.2.3</element>
</initial_peers>
</discovery>
</participant_qos>
</qos_profile>
</qos_library>
</dds>
Hello Ken,
I am glad I could help. Now, for your next question: what you are doing in XML should be equivalent to what you are doing in C++. As described in the documentation here, if the add_peer() method is called before the DomainParticipant is enabled, the peer description will simply be added to the list that was populated by DDS_DiscoveryQosPolicy::initial_peers;
So what you are doing should be equivalent.
I would like to add, that even writing in C++ (or any other language) you can still use the XML file for QoS configuration!
Let me know if you have more doubts.
Best,
Gianpiero