micro-ros agent only starts for the second time after uC manual reset
Hello,
I am building a launcher for a Micro-ROS application running Zephyr RTOS on STM32. I stumbled upon a situation that happens when the agent is started by the second time after being interrupted by a ctrl+c
or by a $ killall micro_ros_agent
. It freezes in the logger setup line, just before the initialization of topics, publishers, subscribers, and services, like this:
$ ros2 run micro_ros_agent micro_ros_agent serial --dev /dev/ttyACM0
[1639862248.302385] info | TermiosAgentLinux.cpp | init | running... | fd: 3
[1639862248.302663] info | Root.cpp | set_verbose_level | logger setup | verbose_level: 4
It only resumes if the microcontroller reset button is pressed:
[1639862662.431163] info | TermiosAgentLinux.cpp | fini | server stopped | fd: 3
[1639862662.443154] info | TermiosAgentLinux.cpp | init | Serial port not found. | device: /dev/ttyACM0, error 2, waiting for connection...
[1639862663.140021] info | TermiosAgentLinux.cpp | init | running... | fd: 3
[1639862664.207718] info | Root.cpp | create_client | create | client_key: 0x59B06063, session_id: 0x81
[1639862664.208181] info | SessionManager.hpp | establish_session | session established | client_key: 0x59B06063, address: 0
[1639862664.254578] info | ProxyClient.cpp | create_participant | participant created | client_key: 0x59B06063, participant_id: 0x000(1)
[1639862664.257543] info | ProxyClient.cpp | create_replier | replier created | client_key: 0x59B06063, requester_id: 0x000(7), participant_id: 0x000(1)
[1639862664.260180] info | ProxyClient.cpp | create_replier | replier created | client_key: 0x59B06063, requester_id: 0x001(7), participant_id: 0x000(1)
[1639862664.262102] info | ProxyClient.cpp | create_topic | topic created | client_key: 0x59B06063, topic_id: 0x000(2), participant_id: 0x000(1)
[1639862664.263761] info | ProxyClient.cpp | create_publisher | publisher created | client_key: 0x59B06063, publisher_id: 0x000(3), participant_id: 0x000(1)
[1639862664.265743] info | ProxyClient.cpp | create_datawriter | datawriter created | client_key: 0x59B06063, datawriter_id: 0x000(5), publisher_id: 0x000(3)
[1639862664.271523] info | ProxyClient.cpp | create_topic | topic created | client_key: 0x59B06063, topic_id: 0x001(2), participant_id: 0x000(1)
[1639862664.273199] info | ProxyClient.cpp | create_publisher | publisher created | client_key: 0x59B06063, publisher_id: 0x001(3), participant_id: 0x000(1)
[1639862664.275206] info | ProxyClient.cpp | create_datawriter | datawriter created | client_key: 0x59B06063, datawriter_id: 0x001(5), publisher_id: 0x001(3)
[1639862664.280842] info | ProxyClient.cpp | create_topic | topic created | client_key: 0x59B06063, topic_id: 0x002(2), participant_id: 0x000(1)
[1639862664.286361] info | ProxyClient.cpp | create_publisher | publisher created | client_key: 0x59B06063, publisher_id: 0x002(3), participant_id: 0x000(1)
[1639862664.288642] info | ProxyClient.cpp | create_datawriter | datawriter created | client_key: 0x59B06063, datawriter_id: 0x002(5), publisher_id: 0x002(3)
The necessity of resetting the board every time I need to restart the agent is too inconvenient since the board is inside the robot. Is there a way to prevent it or a way to reset the microcontroller automatically after an agent interruption?