RTEMS | Backport 5.4: (#5220)
Jan Sommer (@thesummer)
gitlab at rtems.org
Thu Feb 20 10:29:41 UTC 2025
Jan Sommer created an issue: https://gitlab.rtems.org/rtems/rtos/rtems/-/issues/5220
## Summary
Backport of https://gitlab.rtems.org/rtems/rtos/rtems/-/issues/5162
`rtems_termios_set_best_baud()` cannot set all Baudrates, because `rtems_termios_baud_table` is unsorted.
## Steps to reproduce
https://gitlab.rtems.org/rtems/rtos/rtems/-/blob/main/cpukit/libcsupport/src/termios_baudtable.c?ref_type=heads
https://gitlab.rtems.org/rtems/rtos/rtems/-/blob/main/cpukit/libcsupport/src/termios_setbestbaud.c?ref_type=heads#L43
The algorithm in `rtems_termios_set_best_baud()` successively iterates over the elements of the `rtems_termios_baud_table` and searches for a fitting baud rate (checking by "is element lower than the `baud` parameter, then checks the next element, ...).
The table of baud rates is not sorted correctly from a certain point on, therefore the algorithm for choosing the optimal baud rate does not work for every baud rate.
e.g. if the input is `7200` (which is in the table) the search terminates at `9600` as that is larger, the last entry was `4800`, so in the check it sets it to either of those, but not the `7200`.
We observed it when we entered `38401` (due to measurement errors on the hardware was a bit larger).
We identified the search ending at `57600` and it ended using the `last = 28800`.
### Pre-set options
--
View it on GitLab: https://gitlab.rtems.org/rtems/rtos/rtems/-/issues/5220
You're receiving this email because of your account on gitlab.rtems.org.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rtems.org/pipermail/bugs/attachments/20250220/a1b429ea/attachment.htm>
More information about the bugs
mailing list