def process_bits(): while True: cur_bits = [] # while the last two characters are not the sigil while len(cur_bits) < 2 or cur_bits[-len(sigil):len(cur_bits)] != sigil: try: cur_bits.append(bits.get(False)) except Queue.Empty: time.sleep(wait_for_byte_timeout) sys.stdout.write(psk.decode(cur_bits[:-len(sigil)])) sys.stdout.flush()
if not points.empty(): next_point = points.get(False) if next_point > bottom_threshold: bits.put(0) bits.put(0) cur_points = [cur_points[-1]] break print("") last_bits = [] while True: if len(cur_points) == frame_length: bit = int( quietnet.get_bit(cur_points, frame_length) > bottom_threshold) cur_points = [] bits.put(bit) last_bits.append(bit) if len(last_bits) > 3: if sum(last_bits) == 0: break last_bits = last_bits[1:] cur_points.append(points.get(False)) cur_bits = [] while len(cur_bits) < 2 or cur_bits[-len(sigil):len(cur_bits)] != sigil: cur_bits.append(bits.get(False)) sys.stdout.write(psk.decode(cur_bits[:-len(sigil)])) sys.stdout.flush()