Skip to content

After reconnecting to the agent, data cannot be received normally for a period of time #434

@chrisjaxy

Description

@chrisjaxy

Issue template

  • Hardware description: STM32F103
  • RTOS: freertos
  • Installation type: micro_ros_setup
  • Version or commit hash: foxy

Steps to reproduce the issue

We created a subscriber on stm32f103, and created a publisher on another machine to publish the same topic at a frequency of 50hz. When stm32f103 successfully reconnects to the agent, it cannot subscribe to this topic for a certain period of time.
After debugging, it was found that the problem appeared in the function "uxr_create_session_retries" of the file "session.c". After calling the function "uxr_reset_stream_storage", calling "wait_session_status" to receive data may cause "uxr_reset_stream_storage" to become invalid and cause problems.
We try to call "uxr_reset_stream_storage" again after calling "wait_session_status" to avoid the problem, but I don't know if this modification is feasible. I want to ask your suggestions?

bool uxr_create_session_retries(
        uxrSession* session,
        size_t retries)
{
    uxr_reset_stream_storage(&session->streams);

    uint8_t create_session_buffer[CREATE_SESSION_MAX_MSG_SIZE];
    ucdrBuffer ub;
    ucdr_init_buffer_origin_offset(&ub, create_session_buffer, CREATE_SESSION_MAX_MSG_SIZE, 0u, uxr_session_header_offset(
                &session->info));

    uxr_buffer_create_session(&session->info, &ub, (uint16_t)(session->comm->mtu - INTERNAL_RELIABLE_BUFFER_OFFSET));
    uxr_stamp_create_session_header(&session->info, ub.init);

    bool received = wait_session_status(session, create_session_buffer, ucdr_buffer_length(&ub), (size_t) retries);
    bool created = received && UXR_STATUS_OK == session->info.last_requested_status;
    
    printf("uxr_reset_stream_storage again\r\n");
    uxr_reset_stream_storage(&session->streams);

    return created;
}

Expected behavior

When we reconnect the agent successfully, the MCU can subscribe and respond to data normally.

Actual behavior

Additional information

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions