Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Baud rate is not set in SerialAgent on macOS #340

Open
srmainwaring opened this issue Aug 17, 2023 · 4 comments
Open

Baud rate is not set in SerialAgent on macOS #340

srmainwaring opened this issue Aug 17, 2023 · 4 comments

Comments

@srmainwaring
Copy link
Contributor

Overview

The Micro-XRCE-DDS-Agent does not support a hardware serial transport on macOS because the baudrate is not set correctly due to the linux specific conditional compilation flags:

  • _HAVE_STRUCT_TERMIOS_C_ISPEED
  • _HAVE_STRUCT_TERMIOS_C_OSPEED

which are set in:

#if _HAVE_STRUCT_TERMIOS_C_ISPEED
attr.c_ispeed = baudrate;
#endif
#if _HAVE_STRUCT_TERMIOS_C_OSPEED
attr.c_ospeed = baudrate;
#endif

#if _HAVE_STRUCT_TERMIOS_C_ISPEED
cfsetispeed(&new_attrs, termios_attrs_.c_ispeed);
#endif
#if _HAVE_STRUCT_TERMIOS_C_OSPEED
cfsetospeed(&new_attrs, termios_attrs_.c_ospeed);
#endif

#if _HAVE_STRUCT_TERMIOS_C_ISPEED
cfsetispeed(&new_attrs, termios_attrs_.c_ispeed);
#endif
#if _HAVE_STRUCT_TERMIOS_C_OSPEED
cfsetospeed(&new_attrs, termios_attrs_.c_ospeed);
#endif

The macOS implementation of termios.h does not define _HAVE_STRUCT_TERMIOS_C_ISPEED etc. One fix would be to modify the #if #endif check to:

#if _HAVE_STRUCT_TERMIOS_C_ISPEED || __APPLE__
            cfsetispeed(&new_attrs, termios_attrs_.c_ispeed);
#endif
#if _HAVE_STRUCT_TERMIOS_C_OSPEED || __APPLE__
            cfsetospeed(&new_attrs, termios_attrs_.c_ospeed);
#endif

Issue template

  • Hardware description: MacPro 2019 and MacBook Pro M1

  • OS: macOS Ventura 13.5

  • Installation type: build from source

  • Version or commit hash:

  • Compile flags:

    Unlink spdlog as the brew version conflicts:

    brew unlink spdlog

    Build with logging (do not use system logger).

    colcon build --symlink-install --cmake-args -DCMAKE_BUILD_TYPE=RelWithDebInfo - 
    DCMAKE_MACOSX_RPATH=FALSE -DUAGENT_SOCKETCAN_PROFILE=OFF -DUAGENT_LOGGER_PROFILE=ON  - 
    DUAGENT_USE_SYSTEM_LOGGER=OFF -DUAGENT_USE_SYSTEM_FASTDDS=ON - 
    DUAGENT_USE_SYSTEM_FASTCDR=ON --packages-select micro_ros_agent --cmake-force

Steps to reproduce the issue

  • Install the int32_publisher_custom_transport from https://github.com/micro-ROS/micro_ros_espidf_component on an esp32.

  • Run the micro-ROS agent from the project workspace with verbose logging enabled:

    ./build/micro_ros_agent/micro_ros_agent serial -D /dev/cu.usbserial-0001 -b 115200 -v6
    [1692281492.147983] info     | TermiosAgentLinux.cpp | init                     | running...             | fd: 3
    [1692281492.148393] info     | Root.cpp           | set_verbose_level        | logger setup           | verbose_level: 6

Expected behavior

  • The client connection is established.
  • The topics are visible:
    $ ros2 topic list                          
    /freertos_int32_publisher
    /parameter_events
    /rosout
    

Actual behavior

  • The client does not connect
  • The topics and node are not visible

Additional information

  • Running on a slightly customised version of the humble branch.
  • The test works on an Ubuntu 22.04 VM hosted on macOS.
@pablogs9
Copy link
Member

Hello Micro XRCE-DDS Agent does not provide support for macOS: https://micro-xrce-dds.docs.eprosima.com/en/latest/agent.html

If this is a small fix, please open a PR with your required changes, but we do not have plans for maintaining macOS platform.

@srmainwaring
Copy link
Contributor Author

If this is a small fix, please open a PR with your required changes

Will do, it's a small change to the three files listed above.

but we do not have plans for maintaining macOS platform.

It's not a great deal of work to run the entire eProsima suite on macOS (micro-ROS agent, integration services, fast-dds spy etc). Mostly small fixes here and there such as eProsima/Integration-Service#196. I have working branches with the required changes which I'd be happy to contribute.

@pablogs9
Copy link
Member

which I'd be happy to contribute.

That would be nice thanks!

@srmainwaring
Copy link
Contributor Author

That would be nice thanks!

I've posted PRs for fixes to support Fast DDS spy and Fast DDS monitor on macOS. It's very useful to have the tools available natively on macs as docker networking is complicated to set up on macOS (because there is an extra VM involved).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants