unmanaged listeners C++ and managed listeners managed c++

6 posts / 0 new
Last post
Offline
Last seen: 10 years 6 months ago
Joined: 08/25/2013
Posts: 3
unmanaged listeners C++ and managed listeners managed c++

I have been trying to get a unmanaged C++ listener to work.  I have use the same parameters in a unmanaged listener and it is recieving events. 

Basically, in unmanged C++, I create a participant, create a publisher and subscriber and a data reader, in this datareader, I set a pointer to my C++ Event Listener.


When I run the application, I send a request via the publisher, and no events come in the data available function of my listener.

Any ideas? 

Thanks

Eric

rip
rip's picture
Offline
Last seen: 1 day 7 hours ago
Joined: 04/06/2012
Posts: 324

Bring up Analyzer and look at the QoS settings.  You want match analysis on all readers and writers.

It also sounds like you are trying to write and read from the same participant, and I believe this is disabled by default.  It isn't clear because you don't say "create a datawriter", and the terms publisher, Publisher etc are overloaded and can mean different things based on context. 

regards,

rip

Gerardo Pardo's picture
Offline
Last seen: 1 day 7 hours ago
Joined: 06/02/2010
Posts: 601

Hello Eric,

Are you creating the DataReader and the DataWriter on the same DomainParticipant, that is within the same process or are they in different applications/processes? If in two applications/processes are they running on the same computer or on different computers?

Are you writing only one 'request' or are you publishing a continuous stream of requests?

Are you using the default, out-of-the-box QoS or changing the QoS?

If you are creating DataWriter and the DataReader and immediately writing, then losing this "first" sample can be the consequence of the out-of-the-box QoS settings and the timing of discovery. These links explain it and also how to change the configuration to make it not miss the first sample:

http://community.rti.com/kb/why-does-my-dds-datareader-miss-first-few-samples

http://community.rti.com/content/forum-topic/subscriber-does-not-receive-first-sample

If the above links do not explain your problem, then one has to look deeper at the precise entities you are creating.  For a DataWriter to communicate with a DataReader they have to match the DomainId, the Topic name, the associated data-type, and also have compatible QoS.  One way to see what you are creating anch check whether they match is to use the rtiddspy command-line tool. Alternatively you can also use the RTI Analyzer tool which will show you all the DDS DataWriters and DataReaders and analyze whether they are configured properly to communicate with each other.

Gerardo

 

Offline
Last seen: 10 years 6 months ago
Joined: 08/25/2013
Posts: 3

Hello Gerado,

I am running the datareader and datawriter in the same process.  I have created the datareader and the datawriter from the same dds_participant.  What is a little suspicious is that I have converted C sharp code (dotnet libraries) (events work and retrieval is fast) version rti version 4.3 to C++ unmanaged dds libraries (events do not work) converted to managed C++ (events works, but reponses are very slow ) (rti version 5.0).

 

Here is an example of a C Sharp event.  This is an event that is not a request / response event.

m_ddsparticipant = DDS.Factory.get_instance().create_participant(domainid, qos, null, StatusMaskNone);

m_ddssubscriber = m_ddsparticipant.create_subscriber(dds.domainparticipant.SUBSCRIBER_QOS_DEFUALT, null, STATUS_MASK_NONE);

m_ddspublisher = m_ddsparticipant.create_publisher(dds.domainparticipant.PUBLISHER_QOS_DEFUALT, null, STATUS_MASK_NONE);

System.String cudEventType = TrackCUDEventTypeSupport.get_type_name();

TrackCUDEventTypeSupport.register_type(m_ddsparticipant, cudEventType); 

DDS.Topic cudEventTopic = ddsParticipant.create_topic(TRACK_CUD_EVENT_TOPIC.VALUE,  cudEventType, DDS.DomainParticipant.TOPIC_QOS_DEFAULT,  null/* listener */, DDS.StatusMask.STATUS_MASK_NONE);

m_TrackDDSListener = newTrackEnumerationListener();

m_TrackCUDEventReader = (TrackCUDEventDataReader)ddsSubscriber.create_datareader_with_profile( cudEventTopic, Constants.QOS_LIBRARY_NAME, Constants.QOS_PROFILE_NAME_TRACKEVENTS, m_TrackDDSListener, DDS.StatusMask.STATUS_MASK_ALL);

 

The above code works in C Sharp dds version 4.3 and managed C++ dds version 5.0, but very slow.

 

I tried to convert the above code to unmanged C++ with no success.  I do not get any events to come through.

sample code umanaged C++:

 m_ddsparticipant = DDS_Factory::get_instance()->create_participant(domainid, qos, null, StatusMaskNone);

 m_ddssubscriber = m_ddsparticipant->create_subscriber(dds::domainparticipant::SUBSCRIBER_QOS_DEFAULT, null, STATUS_MASK_NONE);

What should I put in the first parameter of the create?

m_ddspublisher = m_ddsparticipant->create_publisher(dds.domainparticipant.PUBLISHER_QOS_DEFAULT, null, STATUS_MASK_NONE);

What should I put in the first parameter of the create?

std::string cudEventType = TrackCUDEventTypeSupport::get_type_name();

 TrackCUDEventTypeSupport::register_type(m_ddsparticipant, cudEventType);

DDS.Topic* cudEventTopic = ddsParticipant->create_topic(TRACK_CUD_EVENT_TOPIC,  cudEventType, DDS::DomainParticipant.TOPIC_QOS_DEFAULT,  null/* listener */, STATUS_MASK_NONE);

What should be the value of the 3rd parameter?

m_TrackDDSListener - in C++, it is a member variable of the class.

 m_TrackCUDEventReader = (TrackCUDEventDataReader*)ddsSubscriber->create_datareader_with_profile( cudEventTopic, Constants.QOS_LIBRARY_NAME, Constants.QOS_PROFILE_NAME_TRACKEVENTS, m_TrackDDSListener, DDS.StatusMask.STATUS_MASK_ALL);

 

I am sorry, but I am very new to rti.

Any ideas?

Thanks

Eric

 

 

 

Gerardo Pardo's picture
Offline
Last seen: 1 day 7 hours ago
Joined: 06/02/2010
Posts: 601

Hi Eric,

This is odd. It should work fine. I tried a simple application that publishes and subscribes to data in a single prcess and it works as expected. See the attached TrackCUDEEvent_example.cxx file.

I did not understand what you mean by:

m_TrackDDSListener - in C++, it is a member variable of the class.

The listener should be an object  of a class that extends DataReaderListener, see for example the TrackCUDEEventListener in the attached example.

Can you post herethe sorce code for a simple but complete reproducer of the unmanaged C++ application simiular to what I posted?

Gerardo

Offline
Last seen: 10 years 6 months ago
Joined: 08/25/2013
Posts: 3

Hi Gerardo,


Sorry for not getting back to you sooner..  I am uploading the test project and also the xml files and idl files.  The m_TrackDDSListener is a member variable and inherits from DDS::DataReaderListener.

 

Thanks

 

Eric