diff options
author | Gerhard Sittig <gerhard.sittig@gmx.net> | 2019-12-17 11:48:23 +0100 |
---|---|---|
committer | Gerhard Sittig <gerhard.sittig@gmx.net> | 2019-12-17 11:48:23 +0100 |
commit | 3d2d91e0b30e2e421bf693f7f9f8aad0634084b3 (patch) | |
tree | 76d1f08e1d153372d03cecd6c84c82bb0cd8bfc1 /decoders/uart | |
parent | bd50ceb314e4607e596c98c534aafcfe142a73b6 (diff) | |
download | libsigrokdecode-3d2d91e0b30e2e421bf693f7f9f8aad0634084b3.tar.gz libsigrokdecode-3d2d91e0b30e2e421bf693f7f9f8aad0634084b3.zip |
uart: sample position nits, fix typo, float calculation awareness
This commit amends bd50ceb314e4. Fix a typo in a comment. Rephrase the
bit width percentage calculation such that readers remain aware of the
necessity for floating point math in sample position calculations. This
commit does not change behaviour, Python 3 always yields float results
for divisions. It's about raising awareness.
Diffstat (limited to 'decoders/uart')
-rw-r--r-- | decoders/uart/pd.py | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/decoders/uart/pd.py b/decoders/uart/pd.py index 9ffcb56..fd8254c 100644 --- a/decoders/uart/pd.py +++ b/decoders/uart/pd.py @@ -227,12 +227,13 @@ class Decoder(srd.Decoder): # Determine absolute sample number of a bit slot's sample point. # Counts for UART bits start from 0 (0 = start bit, 1..x = data, # x+1 = parity bit (if used) or the first stop bit, and so on). - # Accept a position in the range of 1.99% of the full bit width. + # Accept a position in the range of 1-99% of the full bit width. # Assume 50% for invalid input specs for backwards compatibility. perc = self.options['sample_point'] or 50 if not perc or perc not in range(1, 100): perc = 50 - bitpos = (self.bit_width - 1) * perc / 100 + perc /= 100.0 + bitpos = (self.bit_width - 1) * perc bitpos += self.frame_start[rxtx] bitpos += bitnum * self.bit_width return bitpos |