def __init__(self, encoder_list_0, input_size, output_size): gr.hier_block2.__init__( self, "Threaded Encoder", gr.io_signature(1, 1, input_size * 1), gr.io_signature(1, 1, output_size * 1), ) ################################################## # Parameters ################################################## self.encoder_list_0 = encoder_list_0 ################################################## # Variables ################################################## ################################################## # Blocks ################################################## self.fec_deinterleave_0 = fec.deinterleave( input_size, fec.get_encoder_input_size(encoder_list_0[0])) self.generic_encoders_0 = [] for i in range(len(encoder_list_0)): self.generic_encoders_0.append( fec.encoder(encoder_list_0[i], input_size, output_size)) self.fec_interleave_0 = fec.interleave( output_size, fec.get_encoder_output_size(encoder_list_0[0])) ################################################## # Connections ################################################## for i in range(len(encoder_list_0)): self.connect((self.fec_deinterleave_0, i), (self.generic_encoders_0[i], 0)) for i in range(len(encoder_list_0)): self.connect((self.generic_encoders_0[i], 0), (self.fec_interleave_0, i)) self.connect((self, 0), (self.fec_deinterleave_0, 0)) self.connect((self.fec_interleave_0, 0), (self, 0))
def __init__(self, encoder_list_0, input_size, output_size): gr.hier_block2.__init__( self, "Threaded Encoder", gr.io_signature(1, 1, input_size*1), gr.io_signature(1, 1, output_size*1), ) ################################################## # Parameters ################################################## self.encoder_list_0 = encoder_list_0 ################################################## # Variables ################################################## ################################################## # Blocks ################################################## self.fec_deinterleave_0 = fec.deinterleave(input_size, fec.get_encoder_input_size(encoder_list_0[0])) self.generic_encoders_0 = []; for i in range(len(encoder_list_0)): self.generic_encoders_0.append(fec.encoder(encoder_list_0[i], input_size, output_size)) self.fec_interleave_0 = fec.interleave(output_size, fec.get_encoder_output_size(encoder_list_0[0])) ################################################## # Connections ################################################## for i in range(len(encoder_list_0)): self.connect((self.fec_deinterleave_0, i), (self.generic_encoders_0[i], 0)) for i in range(len(encoder_list_0)): self.connect((self.generic_encoders_0[i], 0), (self.fec_interleave_0, i)) self.connect((self, 0), (self.fec_deinterleave_0, 0)) self.connect((self.fec_interleave_0, 0), (self, 0))
def unmake_packet(whitened_payload_with_crc, whitener_offset=0, debug=False, dewhitening=True, check_crc=True, repeat=1, interleave=None): """ Return (ok, payload) Args: whitened_payload_with_crc: string whitener_offset: integer offset into whitener table dewhitening: True if we should run this through the dewhitener check_crc: True if we should check the CRC of the packet """ if dewhitening: payload_with_crc = dewhiten(whitened_payload_with_crc, whitener_offset) else: payload_with_crc = (whitened_payload_with_crc) if repeat > 1: if interleave == 1: payload_with_crc = fec.deinterleave(payload_with_crc, repeat) elif interleave == 2: payload_with_crc = fec.shuffle_decode(payload_with_crc) payload_with_crc = fec.repeat_decode(payload_with_crc, repeat) if check_crc: ok, payload = crc.check_crc32(payload_with_crc) else: payload = payload_with_crc ok = True if debug: print "" print "payload_with_crc =", string_to_hex_list(payload_with_crc) print "ok = %r, len(payload) = %d" % (ok, len(payload)) print "payload =", string_to_hex_list(payload) print "" return ok, payload
def __init__(self, decoder_list_0, input_size, output_size): gr.hier_block2.__init__( self, "Capillary Threaded Decoder", gr.io_signature(1, 1, input_size*1), gr.io_signature(1, 1, output_size*1), ) ################################################## # Parameters ################################################## self.decoder_list_0 = decoder_list_0 ################################################## # Variables ################################################## ################################################## # Blocks ################################################## self.fec_deinterleaves_0 = []; for i in range(int(math.log(len(decoder_list_0), 2))): for j in range(int(math.pow(2, i))): self.fec_deinterleaves_0.append(fec.deinterleave(input_size, fec.get_decoder_input_size(decoder_list_0[0]))) self.generic_decoders_0 = []; for i in range(len(decoder_list_0)): self.generic_decoders_0.append(fec.decoder(decoder_list_0[i], input_size, output_size)) self.fec_interleaves_0 = []; for i in range(int(math.log(len(decoder_list_0), 2))): for j in range(int(math.pow(2, i))): self.fec_interleaves_0.append(fec.interleave(output_size, fec.get_decoder_output_size(decoder_list_0[0]))) ################################################## # Connections ################################################## rootcount = 0; branchcount = 1; for i in range(int(math.log(len(decoder_list_0), 2)) - 1): for j in range(int(math.pow(2, i))): self.connect((self.fec_deinterleaves_0[rootcount], 0), (self.fec_deinterleaves_0[branchcount], 0)) self.connect((self.fec_deinterleaves_0[rootcount], 1), (self.fec_deinterleaves_0[branchcount + 1], 0)) rootcount += 1; branchcount += 2; codercount = 0; for i in range(len(decoder_list_0)/2): self.connect((self.fec_deinterleaves_0[rootcount], 0), (self.generic_decoders_0[codercount], 0)) self.connect((self.fec_deinterleaves_0[rootcount], 1), (self.generic_decoders_0[codercount + 1], 0)) rootcount += 1; codercount += 2; rootcount = 0; branchcount = 1; for i in range(int(math.log(len(decoder_list_0), 2)) - 1): for j in range(int(math.pow(2, i))): self.connect((self.fec_interleaves_0[branchcount], 0), (self.fec_interleaves_0[rootcount], 0)) self.connect((self.fec_interleaves_0[branchcount + 1], 0), (self.fec_interleaves_0[rootcount], 1)) rootcount += 1; branchcount += 2; codercount = 0; for i in range(len(decoder_list_0)/2): self.connect((self.generic_decoders_0[codercount], 0), (self.fec_interleaves_0[rootcount], 0)) self.connect((self.generic_decoders_0[codercount + 1], 0), (self.fec_interleaves_0[rootcount], 1)) rootcount += 1; codercount += 2; if ((len(self.decoder_list_0)) > 1): self.connect((self, 0), (self.fec_deinterleaves_0[0], 0)) self.connect((self.fec_interleaves_0[0], 0), (self, 0)) else: self.connect((self, 0), (self.generic_decoders_0[0], 0)) self.connect((self.generic_decoders_0[0], 0), (self, 0))
def __init__(self, encoder_list_0, input_size=gr.sizeof_char, output_size=gr.sizeof_float): gr.hier_block2.__init__( self, "Capillary Threaded Encoder", gr.io_signature(1, 1, input_size), gr.io_signature(1, 1, output_size), ) ################################################## # Parameters ################################################## self.encoder_list_0 = encoder_list_0 ################################################## # Variables ################################################## ################################################## # Blocks ################################################## self.fec_deinterleaves_0 = [] for i in range(int(math.log(len(encoder_list_0), 2))): for j in range(int(math.pow(2, i))): self.fec_deinterleaves_0.append( fec.deinterleave( input_size, fec.get_encoder_input_size(encoder_list_0[0]))) self.generic_encoders_0 = [] for i in range(len(encoder_list_0)): self.generic_encoders_0.append( fec.encoder(encoder_list_0[i], input_size, output_size)) self.fec_interleaves_0 = [] for i in range(int(math.log(len(encoder_list_0), 2))): for j in range(int(math.pow(2, i))): self.fec_interleaves_0.append( fec.interleave( output_size, fec.get_encoder_output_size(encoder_list_0[0]))) ################################################## # Connections ################################################## rootcount = 0 branchcount = 1 for i in range(int(math.log(len(encoder_list_0), 2)) - 1): for j in range(int(math.pow(2, i))): self.connect((self.fec_deinterleaves_0[rootcount], 0), (self.fec_deinterleaves_0[branchcount], 0)) self.connect((self.fec_deinterleaves_0[rootcount], 1), (self.fec_deinterleaves_0[branchcount + 1], 0)) rootcount += 1 branchcount += 2 codercount = 0 for i in range(len(encoder_list_0) / 2): self.connect((self.fec_deinterleaves_0[rootcount], 0), (self.generic_encoders_0[codercount], 0)) self.connect((self.fec_deinterleaves_0[rootcount], 1), (self.generic_encoders_0[codercount + 1], 0)) rootcount += 1 codercount += 2 rootcount = 0 branchcount = 1 for i in range(int(math.log(len(encoder_list_0), 2)) - 1): for j in range(int(math.pow(2, i))): self.connect((self.fec_interleaves_0[branchcount], 0), (self.fec_interleaves_0[rootcount], 0)) self.connect((self.fec_interleaves_0[branchcount + 1], 0), (self.fec_interleaves_0[rootcount], 1)) rootcount += 1 branchcount += 2 codercount = 0 for i in range(len(encoder_list_0) / 2): self.connect((self.generic_encoders_0[codercount], 0), (self.fec_interleaves_0[rootcount], 0)) self.connect((self.generic_encoders_0[codercount + 1], 0), (self.fec_interleaves_0[rootcount], 1)) rootcount += 1 codercount += 2 if ((len(self.encoder_list_0)) > 1): self.connect((self, 0), (self.fec_deinterleaves_0[0], 0)) self.connect((self.fec_interleaves_0[0], 0), (self, 0)) else: self.connect((self, 0), (self.generic_encoders_0[0], 0)) self.connect((self.generic_encoders_0[0], 0), (self, 0))
def __init__(self, decoder_list_0, input_size, output_size): gr.hier_block2.__init__( self, "Capillary Threaded Decoder", gr.io_signature(1, 1, input_size * 1), gr.io_signature(1, 1, output_size * 1), ) ################################################## # Parameters ################################################## self.decoder_list_0 = decoder_list_0 ################################################## # Variables ################################################## ################################################## # Blocks ################################################## self.fec_deinterleaves_0 = [] for i in range(int(math.log(len(decoder_list_0), 2))): for j in range(int(math.pow(2, i))): self.fec_deinterleaves_0.append( fec.deinterleave(input_size, fec.get_decoder_input_size(decoder_list_0[0])) ) self.generic_decoders_0 = [] for i in range(len(decoder_list_0)): self.generic_decoders_0.append(fec.decoder(decoder_list_0[i], input_size, output_size)) self.fec_interleaves_0 = [] for i in range(int(math.log(len(decoder_list_0), 2))): for j in range(int(math.pow(2, i))): self.fec_interleaves_0.append( fec.interleave(output_size, fec.get_decoder_output_size(decoder_list_0[0])) ) ################################################## # Connections ################################################## rootcount = 0 branchcount = 1 for i in range(int(math.log(len(decoder_list_0), 2)) - 1): for j in range(int(math.pow(2, i))): self.connect((self.fec_deinterleaves_0[rootcount], 0), (self.fec_deinterleaves_0[branchcount], 0)) self.connect((self.fec_deinterleaves_0[rootcount], 1), (self.fec_deinterleaves_0[branchcount + 1], 0)) rootcount += 1 branchcount += 2 codercount = 0 for i in range(len(decoder_list_0) / 2): self.connect((self.fec_deinterleaves_0[rootcount], 0), (self.generic_decoders_0[codercount], 0)) self.connect((self.fec_deinterleaves_0[rootcount], 1), (self.generic_decoders_0[codercount + 1], 0)) rootcount += 1 codercount += 2 rootcount = 0 branchcount = 1 for i in range(int(math.log(len(decoder_list_0), 2)) - 1): for j in range(int(math.pow(2, i))): self.connect((self.fec_interleaves_0[branchcount], 0), (self.fec_interleaves_0[rootcount], 0)) self.connect((self.fec_interleaves_0[branchcount + 1], 0), (self.fec_interleaves_0[rootcount], 1)) rootcount += 1 branchcount += 2 codercount = 0 for i in range(len(decoder_list_0) / 2): self.connect((self.generic_decoders_0[codercount], 0), (self.fec_interleaves_0[rootcount], 0)) self.connect((self.generic_decoders_0[codercount + 1], 0), (self.fec_interleaves_0[rootcount], 1)) rootcount += 1 codercount += 2 if (len(self.decoder_list_0)) > 1: self.connect((self, 0), (self.fec_deinterleaves_0[0], 0)) self.connect((self.fec_interleaves_0[0], 0), (self, 0)) else: self.connect((self, 0), (self.generic_decoders_0[0], 0)) self.connect((self.generic_decoders_0[0], 0), (self, 0))
def __init__(self, encoder_list_0, input_size=gr.sizeof_char, output_size=gr.sizeof_float): gr.hier_block2.__init__( self, "Capillary Threaded Encoder", gr.io_signature(1, 1, input_size), gr.io_signature(1, 1, output_size), ) ################################################## # Parameters ################################################## self.encoder_list_0 = encoder_list_0 ################################################## # Variables ################################################## ################################################## # Blocks ################################################## self.fec_deinterleaves_0 = []; for i in range(int(math.log(len(encoder_list_0), 2))): for j in range(int(math.pow(2, i))): self.fec_deinterleaves_0.append(fec.deinterleave(input_size, fec.get_encoder_input_size(encoder_list_0[0]))) self.generic_encoders_0 = []; for i in range(len(encoder_list_0)): self.generic_encoders_0.append(fec.encoder(encoder_list_0[i], input_size, output_size)) self.fec_interleaves_0 = []; for i in range(int(math.log(len(encoder_list_0), 2))): for j in range(int(math.pow(2, i))): self.fec_interleaves_0.append(fec.interleave(output_size, fec.get_encoder_output_size(encoder_list_0[0]))) ################################################## # Connections ################################################## rootcount = 0; branchcount = 1; for i in range(int(math.log(len(encoder_list_0), 2)) - 1): for j in range(int(math.pow(2, i))): self.connect((self.fec_deinterleaves_0[rootcount], 0), (self.fec_deinterleaves_0[branchcount], 0)) self.connect((self.fec_deinterleaves_0[rootcount], 1), (self.fec_deinterleaves_0[branchcount + 1], 0)) rootcount += 1; branchcount += 2; codercount = 0; for i in range(len(encoder_list_0)/2): self.connect((self.fec_deinterleaves_0[rootcount], 0), (self.generic_encoders_0[codercount], 0)) self.connect((self.fec_deinterleaves_0[rootcount], 1), (self.generic_encoders_0[codercount + 1], 0)) rootcount += 1; codercount += 2; rootcount = 0; branchcount = 1; for i in range(int(math.log(len(encoder_list_0), 2)) - 1): for j in range(int(math.pow(2, i))): self.connect((self.fec_interleaves_0[branchcount], 0), (self.fec_interleaves_0[rootcount], 0)) self.connect((self.fec_interleaves_0[branchcount + 1], 0), (self.fec_interleaves_0[rootcount], 1)) rootcount += 1; branchcount += 2; codercount = 0; for i in range(len(encoder_list_0)/2): self.connect((self.generic_encoders_0[codercount], 0), (self.fec_interleaves_0[rootcount], 0)) self.connect((self.generic_encoders_0[codercount + 1], 0), (self.fec_interleaves_0[rootcount], 1)) rootcount += 1; codercount += 2; if ((len(self.encoder_list_0)) > 1): self.connect((self, 0), (self.fec_deinterleaves_0[0], 0)) self.connect((self.fec_interleaves_0[0], 0), (self, 0)) else: self.connect((self, 0), (self.generic_encoders_0[0], 0)) self.connect((self.generic_encoders_0[0], 0), (self, 0))