Gedare Bloom created an issue: 
https://gitlab.rtems.org/rtems/rtos/rtems/-/issues/5202

Assignee: Jan Sommer

## Summary
<!--
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/5202
You're receiving this email because of your account on gitlab.rtems.org.


_______________________________________________
bugs mailing list
bugs@rtems.org
http://lists.rtems.org/mailman/listinfo/bugs

Reply via email to