(self)
Read the leader / pilot wave.
Read the leader / pilot wave.
Read the leader / pilot wave .
def read_leader(self):
        """Read the leader / pilot wave."""
        try:
            while True:
                while self.read_bit() != 1:
                    pass
                counter = 0
                pulse = (0,0)
                while True:
                    last = pulse
                    half = next(self.read_half)
                    if not self._is_leader_halfpulse(half):
                        if counter > self.min_leader_halves:
                            #  zero bit; try to sync
                            half = next(self.read_half)
                        break
                    counter += 1
                # sync bit 0 has been read, check sync byte
                if counter >= self.min_leader_halves:
                    # read rest of first byte
                    try:
                        self.last_error_bit = None
                        self.dropbit = None
                        sync = self.read_byte(skip_start=True)
                        if sync == self.sync_byte:
                            return True
                        else:
                            logging.debug(
                                '%s Incorrect sync byte after %d pulses: %02x',
                                timestamp(self.counter()), counter, sync
                            )
                    except (PulseError, FramingError) as e:
                        logging.debug(
                            '%s Error in sync byte after %d pulses: %s',
                            timestamp(self.counter()), counter, e
                        )
        except (EndOfTape, StopIteration):
            self.read_half = self._gen_read_halfpulse()
            return False
def read_leader ( self ) : try : while True : while self . read_bit ( ) != 1 : pass counter = 0 pulse = ( 0 , 0 ) while True : last = pulse half = next ( self . read_half ) if not self . _is_leader_halfpulse ( half ) : if counter > self . min_leader_halves : #  zero bit; try to sync half = next ( self . read_half ) break counter += 1 # sync bit 0 has been read, check sync byte if counter >= self . min_leader_halves : # read rest of first byte try : self . last_error_bit = None self . dropbit = None sync = self . read_byte ( skip_start = True ) if sync == self . sync_byte : return True else : logging . debug ( '%s Incorrect sync byte after %d pulses: %02x' , timestamp ( self . counter ( ) ) , counter , sync ) except ( PulseError , FramingError ) as e : logging . debug ( '%s Error in sync byte after %d pulses: %s' , timestamp ( self . counter ( ) ) , counter , e ) except ( EndOfTape , StopIteration ) : self . read_half = self . _gen_read_halfpulse ( ) return False