diff options
author | Gerhard Sittig <gerhard.sittig@gmx.net> | 2017-03-14 19:15:31 +0100 |
---|---|---|
committer | Gerhard Sittig <gerhard.sittig@gmx.net> | 2017-03-14 19:32:39 +0100 |
commit | 080b528200abe354412aba63ddee5d76ac9c8e14 (patch) | |
tree | 21b769516f9f436e8ce74af95fe09b8b8386d185 /decoders/uart | |
parent | 7d62e5b33a3404d319f42c81f3344240d430746a (diff) | |
download | libsigrokdecode-080b528200abe354412aba63ddee5d76ac9c8e14.tar.gz libsigrokdecode-080b528200abe354412aba63ddee5d76ac9c8e14.zip |
uart: Remove redundant "reached bit" checks
After the decode() method got adjusted to call wait() with custom made
conditions and to check .matched[] before inspecting samples, the check
whether a bit time's sample point was reached has become obsolete.
Diffstat (limited to 'decoders/uart')
-rw-r--r-- | decoders/uart/pd.py | 31 |
1 files changed, 0 insertions, 31 deletions
diff --git a/decoders/uart/pd.py b/decoders/uart/pd.py index c6e47ca..6a0dff9 100644 --- a/decoders/uart/pd.py +++ b/decoders/uart/pd.py @@ -195,30 +195,13 @@ class Decoder(srd.Decoder): bitpos += bitnum * self.bit_width return bitpos - # Return true if we reached the middle of the desired bit, false otherwise. - def reached_bit(self, rxtx, bitnum): - bitpos = self.get_sample_point(rxtx, bitnum) - if self.samplenum >= bitpos: - return True - return False - def wait_for_start_bit(self, rxtx, signal): - # The caller already has detected an edge. Strictly speaking this - # check on the current signal level is redundant. But it does not - # harm either. - if signal != 0: - return - # Save the sample number where the start bit begins. self.frame_start[rxtx] = self.samplenum self.state[rxtx] = 'GET START BIT' def get_start_bit(self, rxtx, signal): - # Skip samples until we're in the middle of the start bit. - if not self.reached_bit(rxtx, 0): - return - self.startbit[rxtx] = signal # The startbit must be 0. If not, we report an error and wait @@ -239,10 +222,6 @@ class Decoder(srd.Decoder): self.putg([rxtx + 2, ['Start bit', 'Start', 'S']]) def get_data_bits(self, rxtx, signal): - # Skip samples until we're in the middle of the desired data bit. - if not self.reached_bit(rxtx, 1 + self.cur_data_bit[rxtx]): - return - # Save the sample number of the middle of the first data bit. if self.startsample[rxtx] == -1: self.startsample[rxtx] = self.samplenum @@ -330,10 +309,6 @@ class Decoder(srd.Decoder): return None def get_parity_bit(self, rxtx, signal): - # Skip samples until we're in the middle of the parity bit. - if not self.reached_bit(rxtx, 1 + self.options['num_data_bits']): - return - self.paritybit[rxtx] = signal self.state[rxtx] = 'GET STOP BITS' @@ -349,12 +324,6 @@ class Decoder(srd.Decoder): # TODO: Currently only supports 1 stop bit. def get_stop_bits(self, rxtx, signal): - # Skip samples until we're in the middle of the stop bit(s). - skip_parity = 0 if self.options['parity_type'] == 'none' else 1 - b = 1 + self.options['num_data_bits'] + skip_parity - if not self.reached_bit(rxtx, b): - return - self.stopbit1[rxtx] = signal # Stop bits must be 1. If not, we report an error. |