Skip to content

Commit

Permalink
applet.interface.uart: only report baud updates when outside a +/- 5%…
Browse files Browse the repository at this point in the history
… window

Because we are now updating the bit time whenever it changes, it is
possible to get a lot of "switched to __ baud" messages, even if the
change is minor and well within tolerance.

This patch will only report baudrate changes when they exceed a +/- 5%
window vs the previously reported baudrate.
  • Loading branch information
attie-argentum committed Jan 7, 2021
1 parent 15f0d1d commit f6ebade
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion software/glasgow/applet/interface/uart/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,11 @@ async def _monitor_errors(self, device):
self.logger.warning("%d frame or parity errors detected", delta)

new_bit_cyc = await device.read_register(self.__addr_bit_cyc, width=4)
if new_bit_cyc != cur_bit_cyc:

cur_bit_cyc_lo = cur_bit_cyc * 0.95
cur_bit_cyc_hi = cur_bit_cyc * 1.05

if new_bit_cyc < cur_bit_cyc_lo or new_bit_cyc > cur_bit_cyc_hi:
self.logger.info("switched to %d baud",
self.__sys_clk_freq // (new_bit_cyc + 1))
cur_bit_cyc = new_bit_cyc
Expand Down

0 comments on commit f6ebade

Please sign in to comment.