Properly using PRESENTATION QOS

2 posts / 0 new
Last post
Offline
Last seen: 6 years 8 months ago
Joined: 08/21/2014
Posts: 1
Properly using PRESENTATION QOS

Hi. I would like to know how to use PRESENTATION QOS with listener properly.

I know that there are 3 ways to receive data.

1. explicitly call read() or take()

2. listener call back ( on_data_available() )

3. waitset

 

I use 2nd way to receive data.

If I configured PRESENTATION QOS with access_scope=GROUP and ordered_access=TRUE, can I use 2nd listener call back function on_data_available() with begin_access() and end_access()? or not?

or I have to use 1st or 3rd way?

I ultimately hope that the subscriber receive data in the order that the publisher sent.

I have multiple datawriters and one publisher.

 

I'm looking forward any help.

Thanks.

Howard's picture
Online
Last seen: 2 min 54 sec ago
Joined: 11/29/2012
Posts: 190

No, you cannot call DDSSubscriber::being_access() or end_access() within a DDSDataReaderListener callback.  It is not allowed and you will get an Exclusive Area error message.

And it does not make sense to use a listener callback on a specific DataReader when using PRESENTATION QOS with GROUP ordered access.  I assume that you want to use the GROUP access scope because you want order access across multiple topics being sent by the DataWriters of a DDSPublisher in the remote application.

If so, then when you receive data, you need to access all of the datareaders that received data so that you can process them in the order that they were sent.  You cannot do so from the context of a callback for a single datareader.

You can use the SubscriberListener::on_data_on_readers() callback if you want to use a listener-based method to process data received with GROUP presentation ordered access.

What you need to do is to use DDSSubscriber::begin_access(), DDSSubscriber::get_datareaders() and DDSSubscriber::end_access in the DDSSubscriber listener (or your own thread via  polling or using a waitset blocked on the receipt of data from any of the datareaders).

In any case, the logic in your code should look like

subscriber->begin_access()

subscriber->get_datareaders(datareaderSeq)

  foreach datareader in datareadersSeq
       
       reader->get_listener()->on_data_available(reader)

subscriber->end_access()


Please read the html documentation for DDSSubscriber::get_datareaders, as well as Chapter 7.2.5 and 7.2.7 in the users manual.


Best regards,

--Howard