eProsima / Micro-XRCE-DDS-Client

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

How to use the "uxr_buffer_create_requester_bin" function #329

Closed GarMingLi closed 1 year ago

GarMingLi commented 1 year ago

A client uses the "uxr_buffer_create_replier_xml" function to create a replier. Another client uses the "uxr_buffer_create_requester_bin" function to create a requester. The "uxr_buffer_create_requester_bin" function contains two parameters: "request_topic_name" and "reply_topic_name". If they are set to "", the entity cannot be created successfully. How to use this function to create a requester to communicate with the replier?

pablogs9 commented 1 year ago

Well, as stated in the documentation, those two arguments represent the name of the pair of topics used to generate the service. They cannot be empty.

GarMingLi commented 1 year ago

But in the example, these two parameters are empty。

pablogs9 commented 1 year ago

Hello @GarMingLi could you point out where is this example? This should be fixed.

GarMingLi commented 1 year ago

Hello @pablogs9 On“On“ https://github.com/eProsima/Micro-XRCE-DDS-Client/blob/master/examples/SharedMemoryReqRep/main.c ”In this link”In this link.

    // Create requester
    uxrObjectId requester_id = uxr_object_id(0x01, UXR_REQUESTER_ID);
    uxrQoS_t qos = {
        .reliability = UXR_RELIABILITY_RELIABLE, .durability = UXR_DURABILITY_TRANSIENT_LOCAL,
        .history = UXR_HISTORY_KEEP_LAST, .depth = 1
    };

    uxr_buffer_create_requester_bin(&session, output_besteffort, requester_id, participant_id, "shared_memory_reqres",
            "req_type", "res_type", "", "", qos, UXR_REPLACE);
    uxr_set_request_callback(&session, on_request, NULL);

    // Create replier
    replier_id = uxr_object_id(0x01, UXR_REPLIER_ID);
    uxr_buffer_create_replier_bin(&session, reliable_in, replier_id, participant_id, "shared_memory_reqres", "req_type",
            "res_type", "", "", qos, UXR_REPLACE);
pablogs9 commented 1 year ago

You are using the shared memory feature, in this case, no topics are being created, so those strings can be empty. Have you built the library with UCLIENT_PROFILE_SHARED_MEMORY set to ON?

GarMingLi commented 1 year ago

I am not using the "UCLIENT_PROFILE_SHARED_MEMORY" feature. I understand now, thanks! @pablogs9