eProsima / Micro-XRCE-DDS-Client

Micro XRCE-DDS Client repository. Looking for commercial support? Contact info@eprosima.com
Apache License 2.0
134 stars 84 forks source link

How to create a shared memory example single session with multiple topics for pulishers and subscriber #338

Closed ManvithRaj closed 1 year ago

ManvithRaj commented 1 year ago

Hi @pablogs9,

This is thread is created to discuss issues facing on shared memory which i am trying .

How to create a shared memory example single session with multiple topics for pulishers and subscriber ?

I am able to publish but subscriber with different topic is not able to receive data .

Here is my Initializations of publisher and subscriber . Could you please check and let me know if i am missing anything ?

code :

uxr_init_session(&sessionnew, &comm3, 0xCCCCDDDD);      
uxrStreamId output_besteffort3 =uxr_create_output_best_effort_stream(&sessionnew, output_besteffort_buffer3, BUFFER_SIZE);
reliable_in3 = uxr_create_input_reliable_stream(&sessionnew, input_reliable_stream_buffer3, BUFFER_SIZE,
                   HISTORY_SIZE);

 **// Publisher on topic "shared_memory_topicpub"**

uxr_buffer_create_topic_bin(&sessionnew, output_besteffort3, topic_id4, participant_id4,"shared_memory_topicpub","shared_memory_type", UXR_REPLACE);      
topic_id4 = uxr_object_id(0x04, UXR_TOPIC_ID);
uxrObjectId publisher_id4 = uxr_object_id(0x04, UXR_PUBLISHER_ID);
uxrObjectId datawriter_id4 = uxr_object_id(0x04, UXR_DATAWRITER_ID);
  uxr_buffer_create_datawriter_bin(&sessionnew, output_besteffort3, datawriter_id4, publisher_id4, topic_id4, qos,
          UXR_REPLACE);

 **//Subscriber on topic  shared_memory_topicnew**

  uxr_buffer_create_topic_bin(&sessionnew, output_besteffort3, topic_id3, participant_id3,"shared_memory_topicnew","shared_memory_type", UXR_REPLACE);  
  uxrObjectId subscriber_id3 = uxr_object_id(0x03, UXR_SUBSCRIBER_ID);
  uxrObjectId datareader_id3 = uxr_object_id(0x03, UXR_DATAREADER_ID);

  uxr_buffer_create_datareader_bin(&sessionnew, reliable_in3, datareader_id3, subscriber_id3, topic_id3, qos2, UXR_REPLACE);
  uxr_set_topic_callback(&sessionnew,on_topic3, NULL);

  const size_t data_lenght3 = 255;
  ucdrBuffer ub3;
   uint32_t i3 = 0;
    while (1)
    {
        i3++;
       uxr_prepare_output_stream(&sessionnew, output_besteffort3, datawriter_id4,   &ub3, data_lenght3);
       ucdr_serialize_string(&ub3, message3[0]);
        printf("Publishing @ pub3 : %s :%d\n", message3[0],i3);
       uxr_run_session_time(&sessionnew, 1000);
        vTaskDelay(1000);
    }

    // Delete resources
    uxr_delete_session(&sessionnew);
pablogs9 commented 1 year ago

Not an issue, if you need support please write to support@eProsima.com