def __init__(self, packlen=0, sync='00011010110011111111110000011101', threshold=4): gr.hier_block2.__init__( self, 'Sync and create packed PDU', gr.io_signature(1, 1, gr.sizeof_char * 1), gr.io_signature(0, 0, 0), ) self.message_port_register_hier_out('out') ################################################## # Parameters ################################################## self.packlen = packlen self.sync = sync self.threshold = threshold ################################################## # Blocks ################################################## self.satellites_fixedlen_tagger_0_0_0 = (satellites.fixedlen_tagger( 'syncword', 'packet_len', packlen * 8, numpy.byte)) self.digital_correlate_access_code_tag_bb_0_0_0 = ( digital.correlate_access_code_tag_bb(sync, threshold, 'syncword')) self.blocks_unpacked_to_packed_xx_0 = (blocks.unpacked_to_packed_bb( 1, gr.GR_MSB_FIRST)) self.blocks_tagged_stream_to_pdu_0_0_0 = (tagged_stream_to_pdu( byte_t, 'packet_len')) self.blocks_tagged_stream_multiply_length_0 = ( blocks.tagged_stream_multiply_length(gr.sizeof_char * 1, 'packet_len', 1 / 8.0)) ################################################## # Connections ################################################## self.msg_connect((self.blocks_tagged_stream_to_pdu_0_0_0, 'pdus'), (self, 'out')) self.connect((self.blocks_tagged_stream_multiply_length_0, 0), (self.blocks_tagged_stream_to_pdu_0_0_0, 0)) self.connect((self.blocks_unpacked_to_packed_xx_0, 0), (self.blocks_tagged_stream_multiply_length_0, 0)) self.connect((self.digital_correlate_access_code_tag_bb_0_0_0, 0), (self.satellites_fixedlen_tagger_0_0_0, 0)) self.connect((self, 0), (self.digital_correlate_access_code_tag_bb_0_0_0, 0)) self.connect((self.satellites_fixedlen_tagger_0_0_0, 0), (self.blocks_unpacked_to_packed_xx_0, 0))
def setUp(self): self.syncword_tag = 'syncword' self.packetlen_tag = 'packet_len' self.packet_len = 100 self.data = np.arange(3000, dtype='uint8') self.tag_positions = [50, 213, 217, 230, 1530, 1531] tags = [gr.python_to_tag((j, pmt.intern(self.syncword_tag), pmt.intern('sync'), pmt.intern('test_src'))) for j in self.tag_positions] self.source = blocks.vector_source_b(self.data, False, 1, tags) self.tag2pdu = blocks.tagged_stream_to_pdu(byte_t, self.packetlen_tag) self.debug = blocks.message_debug() self.tagger = fixedlen_tagger(self.syncword_tag, self.packetlen_tag, self.packet_len, np.byte) self.tb = gr.top_block() self.tb.connect(self.source, self.tagger, self.tag2pdu) self.tb.msg_connect((self.tag2pdu, 'pdus'), (self.debug, 'store'))
def __init__(self, packlen=0, sync='00011010110011111111110000011101', threshold=4): gr.hier_block2.__init__( self, 'Sync and create PDU soft', gr.io_signature(1, 1, gr.sizeof_float*1), gr.io_signature(0, 0, 0), ) self.message_port_register_hier_out('out') ################################################## # Parameters ################################################## self.packlen = packlen self.sync = sync self.threshold = threshold ################################################## # Blocks ################################################## self.satellites_fixedlen_tagger_0_0_0 = ( satellites.fixedlen_tagger('syncword', 'packet_len', packlen, numpy.float32)) self.digital_correlate_access_code_tag_bb_0_0_0 = ( digital.correlate_access_code_tag_ff(sync, threshold, 'syncword')) self.blocks_tagged_stream_to_pdu_0_0_0 = ( tagged_stream_to_pdu(float_t, 'packet_len')) ################################################## # Connections ################################################## self.msg_connect( (self.blocks_tagged_stream_to_pdu_0_0_0, 'pdus'), (self, 'out')) self.connect( (self.digital_correlate_access_code_tag_bb_0_0_0, 0), (self.satellites_fixedlen_tagger_0_0_0, 0)) self.connect( (self, 0), (self.digital_correlate_access_code_tag_bb_0_0_0, 0)) self.connect( (self.satellites_fixedlen_tagger_0_0_0, 0), (self.blocks_tagged_stream_to_pdu_0_0_0, 0))
def __init__(self, packlen=0, sync="00011010110011111111110000011101", threshold=4): gr.hier_block2.__init__( self, "Sync and create PDU", gr.io_signature(1, 1, gr.sizeof_char * 1), gr.io_signature(0, 0, 0), ) self.message_port_register_hier_out("out") ################################################## # Parameters ################################################## self.packlen = packlen self.sync = sync self.threshold = threshold ################################################## # Blocks ################################################## self.satellites_fixedlen_tagger_0_0_0 = satellites.fixedlen_tagger( 'syncword', 'packet_len', packlen, numpy.byte) self.digital_correlate_access_code_tag_bb_0_0_0 = digital.correlate_access_code_tag_bb( sync, threshold, 'syncword') self.blocks_tagged_stream_to_pdu_0_0_0 = blocks.tagged_stream_to_pdu( blocks.byte_t, 'packet_len') ################################################## # Connections ################################################## self.msg_connect((self.blocks_tagged_stream_to_pdu_0_0_0, 'pdus'), (self, 'out')) self.connect((self.digital_correlate_access_code_tag_bb_0_0_0, 0), (self.satellites_fixedlen_tagger_0_0_0, 0)) self.connect((self, 0), (self.digital_correlate_access_code_tag_bb_0_0_0, 0)) self.connect((self.satellites_fixedlen_tagger_0_0_0, 0), (self.blocks_tagged_stream_to_pdu_0_0_0, 0))
def __init__(self): gr.top_block.__init__(self, "SUCHAI 1 Decoder") ################################################## # Variables ################################################## self.threshold = threshold = 2 self.sync = sync = "11000011101010100110011001010101" self.samples_symbol = samples_symbol = 20 self.samp_rate = samp_rate = 48000 self.packlen = packlen = (255+3)*8 self.demod_freq = demod_freq = -1800 self.cutoff_freq = cutoff_freq = 1400 ################################################## # Blocks ################################################## self.zeromq_pub_msg_sink_0 = zeromq.pub_msg_sink('tcp://127.0.0.1:5556', 100) self.satellites_u482c_decode_0 = satellites.u482c_decode(False, 0, 1, 1) self.satellites_suchai_telemetry_0 = satellites.suchai_telemetry() self.satellites_print_timestamp_0 = satellites.print_timestamp('%Y-%m-%d %H:%M:%S') self.satellites_print_csp_message_0 = satellites.print_csp_message() self.satellites_fixedlen_tagger_0_0_0 = satellites.fixedlen_tagger('syncword', 'packet_len', packlen, numpy.byte) self.low_pass_filter_0 = filter.fir_filter_ccf(1, firdes.low_pass( 1, samp_rate, cutoff_freq, 1000, firdes.WIN_HAMMING, 6.76)) self.digital_gmsk_demod_0 = digital.gmsk_demod( samples_per_symbol=samples_symbol, gain_mu=0.175, mu=0.5, omega_relative_limit=0.005, freq_error=0.0, verbose=False, log=False, ) self.digital_correlate_access_code_tag_bb_0_0_0 = digital.correlate_access_code_tag_bb(sync, threshold, 'syncword') self.blocks_wavfile_source_0 = blocks.wavfile_source('/home/carlos/Descargas/suchai_test.wav', False) self.blocks_unpacked_to_packed_xx_0 = blocks.unpacked_to_packed_bb(1, gr.GR_MSB_FIRST) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_float*1, samp_rate,True) self.blocks_tagged_stream_to_pdu_0_0_0 = blocks.tagged_stream_to_pdu(blocks.byte_t, 'packet_len') self.blocks_tagged_stream_multiply_length_0 = blocks.tagged_stream_multiply_length(gr.sizeof_char*1, 'packet_len', 1/8.0) self.blocks_multiply_xx_0 = blocks.multiply_vcc(1) self.blocks_float_to_complex_0 = blocks.float_to_complex(1) self.blocks_conjugate_cc_0 = blocks.conjugate_cc() self.analog_sig_source_x_0 = analog.sig_source_c(samp_rate, analog.GR_COS_WAVE, demod_freq, 1, 0) ################################################## # Connections ################################################## self.msg_connect((self.blocks_tagged_stream_to_pdu_0_0_0, 'pdus'), (self.satellites_u482c_decode_0, 'in')) self.msg_connect((self.satellites_print_timestamp_0, 'out'), (self.satellites_print_csp_message_0, 'in')) self.msg_connect((self.satellites_print_timestamp_0, 'out'), (self.satellites_suchai_telemetry_0, 'in')) self.msg_connect((self.satellites_suchai_telemetry_0, 'out'), (self.zeromq_pub_msg_sink_0, 'in')) self.msg_connect((self.satellites_u482c_decode_0, 'out'), (self.satellites_print_timestamp_0, 'in')) self.connect((self.analog_sig_source_x_0, 0), (self.blocks_multiply_xx_0, 0)) self.connect((self.blocks_conjugate_cc_0, 0), (self.low_pass_filter_0, 0)) self.connect((self.blocks_float_to_complex_0, 0), (self.blocks_multiply_xx_0, 1)) self.connect((self.blocks_multiply_xx_0, 0), (self.blocks_conjugate_cc_0, 0)) self.connect((self.blocks_tagged_stream_multiply_length_0, 0), (self.blocks_tagged_stream_to_pdu_0_0_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.blocks_float_to_complex_0, 0)) self.connect((self.blocks_unpacked_to_packed_xx_0, 0), (self.blocks_tagged_stream_multiply_length_0, 0)) self.connect((self.blocks_wavfile_source_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.digital_correlate_access_code_tag_bb_0_0_0, 0), (self.satellites_fixedlen_tagger_0_0_0, 0)) self.connect((self.digital_gmsk_demod_0, 0), (self.digital_correlate_access_code_tag_bb_0_0_0, 0)) self.connect((self.low_pass_filter_0, 0), (self.digital_gmsk_demod_0, 0)) self.connect((self.satellites_fixedlen_tagger_0_0_0, 0), (self.blocks_unpacked_to_packed_xx_0, 0))