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

Multiple Clients cannot connect to same CAN Agent #374

Closed PeterRose710 closed 9 months ago

PeterRose710 commented 9 months ago

The use of CAN bus as transport suggests that there can be more than two participants on the network, this ought to be possible per XRCE-DDS spec, however trying to add a second client results in failure where the initial client gets deleted when a session was already initialized.
The result is that name of second client is shown at ros2 host but none of the topics list up.
Client_Dropout

pablogs9 commented 9 months ago

Please share the Micro XRCE-DDS Agent as text and using the -v6 flag. Indicate when are you connecting the first and the second CAN XRCE Client

PeterRose710 commented 9 months ago

Here we go... CanAgent-Client-Drop.txt 2nd client started at line #395
Thanks

pablogs9 commented 9 months ago

It seems that this is an Agent issue related with assigning the same identity to two different clients. If should be a matter of checking the XRCE CAN transport to see what is happening there. My first try would be checking if the CanEndpoint is the same for the two clients: https://github.com/eProsima/Micro-XRCE-DDS-Agent/blob/40954c2379dfcb2bfa9f6ba22146c57c6742b5b7/src/cpp/transport/can/CanAgentLinux.cpp#L174

I will keep this in my TODO list but I'm afraid I not gonna have much time to debug in the next weeks. Please let us know if you make any progress.

PeterRose710 commented 9 months ago

it seems it's not an agent issue. I got it working now, the issue was that on my test code can frame ID was always the same number, thus causing a conflict since the ID sets the endpoint at session manager CanEndPoint(can_id) which sets a map at https://github.com/eProsima/Micro-XRCE-DDS-Agent/blob/40954c2379dfcb2bfa9f6ba22146c57c6742b5b7/include/uxr/agent/transport/SessionManager.hpp#L62 So using individual can ID separated the sessions and now agents handles both clients simultaneously.

pablogs9 commented 9 months ago

Nice to hear that, should I close the issue as solved?

PeterRose710 commented 9 months ago

I think so, there is still an issue with sequencing of the initialization, if both clients start simultaneously, only one starts correctly, the other has to reset to get initialized. But this might be not related to this.

pablogs9 commented 9 months ago

Ok, please open a new issue if you find that this init error is related to XRCE.

Thanks!