Get data writer's name in received sample

9 posts / 0 new
Last post
Offline
Last seen: 4 years 4 months ago
Joined: 08/13/2014
Posts: 55
Get data writer's name in received sample

Hi,

I want to get data writer's name in received sample same as what we have in admin console tool (e.g. participant name in sample log). I'm using rti connext modern c++ API version 5.2.0. I search all member functions of sample info class but cannot find anything useful. I know that every writer has an unique ID but it does not help me in this case. Thanks in advance for your help.

Bonjefir

Offline
Last seen: 2 months 2 weeks ago
Joined: 02/11/2016
Posts: 144

Hey Bonjefir,

Could you explain what you need the name for?

I think for most uses the guid should do just fine.

Roy.

Offline
Last seen: 4 years 4 months ago
Joined: 08/13/2014
Posts: 55

Hi Roy,

I want to show in my application that who send the data. I know that I can put a string in my IDL indicating the name but I think this is an extra work and I can extract it from the received data. Anyway, GUIDs are changing when you close datawriter's application (At least I think. I did not try it, so please correct me if I am thinking wrong), so there are not unique somehow.

Bonjefir

Offline
Last seen: 2 months 2 weeks ago
Joined: 02/11/2016
Posts: 144

Hey Bonejefir,

"Who sent the data" is a braod question.

In its core DDS is designed for anonymous publish subscribe.

That being said, there are many ways to get various information about a sample that you've received:

The guid is the best identifier for a writer (as it nearly guarantess uniqueness) but as you've mentioned, it doesn't have a "meaning" on its own.

You may want to know:

1. IP of the sender ( https://community.rti.com/content/forum-topic/get-ip-sample-sender handles this topic specifically)

2. Process id / application name of the sending application

3. Some other identifier

 

Unless you explain your need more specifically, it'll be hard to give a good answer.

 

Good luck,

Roy.

Offline
Last seen: 4 years 4 months ago
Joined: 08/13/2014
Posts: 55

Hi Roy,

First I want to thank you for the time answering my question. Second, you are right. My question is general. What I mean was the application name of sending application.

Bonjefir

Offline
Last seen: 2 months 2 weeks ago
Joined: 02/11/2016
Posts: 144

Hey Bonejfir,

Since your application name isn't something that rti is aware of (unless you write it down as a field in your messages) it is not something that rti can report on.

IP of the sending application can be extracted as mentioned in my previous post.

Hopefully this answers your questions.

 

Good luck,

Roy.

Offline
Last seen: 4 years 4 months ago
Joined: 08/13/2014
Posts: 55

Dear Roy,

Thanks for your answer. But I am wondering how RTI Administration Console shows the application name of a subscribed topic as "Participant Name" on sample log. Is it based on process id or something?

Sincerely,

Bonjefir

Offline
Last seen: 2 months 2 weeks ago
Joined: 02/11/2016
Posts: 144

Hey Bonejfir,

What you are referring to is the participant name which you can set in the QoS of the participant.

for example:

<qos_profile name="DefaultPingProfile" is_default_qos="false">

    <participant_qos>

        <participant_name>

            <name>Your application name goes here</name> 

        </participant_name>

    </participant_qos>

</qos_profile>

It will not allow you to identify specific writers but will let you know which participant they are in.

You could also set it before creating your participant (in the code) so that you don't need to have multiple xml files.

I guess maybe that's what you needed?

Good luck,

Roy.

Offline
Last seen: 4 years 4 months ago
Joined: 08/13/2014
Posts: 55

Hi Roy,

I found a solution and put it here for further uses. You can extract the participant name like below:

for (const auto& index : lnSamples)
{
 if (index.info().valid())
 {
 std::cout << "Participant Name ->" << rti::sub::matched_publication_participant_data(dr,index.info().publication_handle())->participant_name().name().get() << std::endl;
 ...
 }
}

As I am setting a participant name for each of my applications, it's unique. Thanks for your nice helps Roy.

Best Regards

Bonjefir