Share memory only setting

4 posts / 0 new
Last post
Offline
Last seen: 3 years 3 months ago
Joined: 04/23/2013
Posts: 17
Share memory only setting

I have the following code, but it is still sending UDP4 through ethernet. Does anybody know why? And how do I set it share memory only? 

struct DDS_DomainParticipantQos *participant_qos = &DDS_PARTICIPANT_QOS_DEFAULT;

DDS_DomainParticipantFactory_get_default_participant_qos(DDS_TheParticipantFactory, participant_qos);
participant_qos->transport_builtin.mask = DDS_TRANSPORTBUILTIN_SHMEM;

participant = DDS_DomainParticipantFactory_create_participant( 
    DDS_TheParticipantFactory, domainId, participant_qos, NULL, DDS_STATUS_MASK_NONE);
if (participant == NULL)
{
    printf("create_participant error\n");
    publisher_shutdown(participant);
    return -1;
}
Organization:
Keywords:
Fernando Garcia's picture
Offline
Last seen: 1 day 20 hours ago
Joined: 05/18/2011
Posts: 197

Hello,

If you want to disable UDPv4 transport programatically to use just Shared Memory, use the following snippet:

    struct DDS_DomainParticipantQos participant_qos =
            DDS_DomainParticipantQos_INITIALIZER;
    retcode = DDS_DomainParticipantFactory_get_default_participant_qos(
            DDS_TheParticipantFactory, &participant_qos);
    if (retcode != DDS_RETCODE_OK) {
        printf("get_default_participant_qos error\n");
        return -1;
    }

    participant_qos.transport_builtin.mask = DDS_TRANSPORTBUILTIN_SHMEM;

    participant = DDS_DomainParticipantFactory_create_participant(
            DDS_TheParticipantFactory, domainId, &participant_qos,
            NULL, DDS_STATUS_MASK_NONE);
    if (participant == NULL) {
        printf("create_participant error\n");
        return -1;
    }

You may also change these QoS settings via XML:

<participant_qos>
  <transport_builtin>
    <mask>SHMEM</mask>
  </transport_builtin>
</participant_qos>

Please let me know if it works for you.

Fernando

Offline
Last seen: 3 years 3 months ago
Joined: 04/23/2013
Posts: 17

I think it is working. I have one question though. What is the difference between DDS_PARTICIPANT_QOS_DEFAULT and DDS_DomainParticipantQos_INITIALIZER?

I get the DDS_PARTICIPANT_QOS_DEFAULT from the rti code generator.

Thanks

Gerardo Pardo's picture
Offline
Last seen: 1 month 2 weeks ago
Joined: 06/02/2010
Posts: 589

Hi,

DDS_DomainParticipantQos_INITIALIZERis a constant that can be used to initialize DDS_DomainParticipantQos variables when you declare them in the stack or "malloc" them. The purpose is to give them some values that are not the random ones that you would get from the compiler (which can cause problems if you try to display the variable. For example a member that is a pointer could be set by the compiler to point to a random value and if you tried to print it you would get an error). Initializing a variable with DDS_DomainParticipantQos_INITIALIZER does not set the variable to the DDS defaults. Just some non-random values. You can initialize variables as in this:

struct DDS_DomainParticipantQos participant_qos = DDS_DomainParticipantQos_INITIALIZER; 

But you should not pass it to functions that expect a DDS_DomainParticipantQos because the actual values set are not so useful. The only real thing you can do after assigning DDS_DomainParticipantQos_INITIALIZER to variable is to do a get_qos() or similar operation that fills it completely with some useful values.

DDS_PARTICIPANT_QOS_DEFAULTrepresents an actual variable that is pre-defined to contain the "default DDS values". The purpose is to have a pre-defined QoS that you can pass to functions that expect a DDS_DomainParticipantQos (e.g. the create_participant()) when you want to create it using the default QoS. However you cannot initialize a value using the DDS_PARTICIPANT_QOS_DEFAULT because the byte-by-byte copy that the C compiler would give you as a result of the assignment does not work well for nested structures that contain pointers and such.

Gerardo