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

Serial port baud rates are dependent and restricted by the version of asio #2014

Open
slovak194 opened this issue Jan 2, 2025 · 3 comments

Comments

@slovak194
Copy link

Issue details

Serial port baud rates are dependent and restricted by the version of asio. Particularly, in the serial_port_base.ipp some baud rates might be missing but still supported by the OS with termios/termios2/ioctl. In my case, it is the 1500000 baud rate which throws the Device exceptio within MAVROS but works fine if set manually. In the latest asio master it is still missing.
https://github.com/chriskohlhoff/asio/blob/62481a25be6cf78cbe714419a4462fd89bd84ab9/asio/include/asio/impl/serial_port_base.ipp#L93C8-L101C40

# ifdef B1000000
  case 1000000: baud = B1000000; break;
# endif
# ifdef B1152000
  case 1152000: baud = B1152000; break;
# endif
# ifdef B2000000
  case 2000000: baud = B2000000; break;

A proposed solution might be to split the try-catch in the serial device constructor into sections and try one more time with serial_dev.native_handle() and ioctl if the baud rate option causes an exception.

MAVROS version and platform

Mavros: N/A
ROS: N/A
Ubuntu: 22.04

Best regards,
Alex

@vooon
Copy link
Member

vooon commented Jan 2, 2025

I'd rather not to reinvent the wheel with that termios (as it were here at early days...).
Also are you sure, your UART works fine on such high rates?

@slovak194
Copy link
Author

I'd rather not to reinvent the wheel with that termios (as it were here at early days...).

That is true, but what is the alternative if we have to deal with hardcoded baud rates in ASIO? It worked well for me until now.

Also are you sure, your UART works fine on such high rates?

Ardupilot specifies literaly "Most stm32-based boards can support rates of up to 1500". Hardware-wise serial ports on modern controllers might work at 12.5 MBaud/s in PPP mode. On my end 1500000 bps and 2000000 bps work fine even with finicky cables.

@vooon
Copy link
Member

vooon commented Jan 3, 2025

Well, you can just package up fresh version of the ASIO, or make a patched version.

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

No branches or pull requests

2 participants