def test_001(self): #test complementary operation of framer & deframer #want to frame some random data that has enough consecutive bits to #stuff at least a few bits npkts = 20 src_data = [0xFE, 0xDA, 0xAC, 0x29, 0x7F, 0xA2, 0x90, 0x0F, 0xF8] frame = digital.hdlc_framer_pb("wat") corr = digital.correlate_access_code_tag_bb("01111110", 0, "frame") deframe = digital.hdlc_deframer_bp("frame", 32, 500) debug = blocks.message_debug() self.tb.connect(frame, corr, deframe) self.tb.msg_connect(deframe, "out", debug, "store") self.tb.start() msg = pmt.cons(pmt.PMT_NIL, pmt.init_u8vector(len(src_data),src_data)) for i in xrange(npkts): frame.to_basic_block()._post(pmt.intern("in"), msg) sleep(0.2) self.tb.stop() self.tb.wait() rxmsg = debug.get_message(0) result_len = pmt.blob_length(pmt.cdr(rxmsg)) msg_data = [] for j in xrange(result_len): msg_data.append(pmt.u8vector_ref(pmt.cdr(rxmsg), j)) self.assertEqual(src_data, msg_data)
def test_001(self): #test complementary operation of framer & deframer #want to frame some random data that has enough consecutive bits to #stuff at least a few bits npkts = 20 src_data = [0xFE, 0xDA, 0xAC, 0x29, 0x7F, 0xA2, 0x90, 0x0F, 0xF8] frame = digital.hdlc_framer_pb("wat") corr = digital.correlate_access_code_tag_bb("01111110", 0, "frame") deframe = digital.hdlc_deframer_bp("frame", 32, 500) debug = blocks.message_debug() self.tb.connect(frame, corr, deframe) self.tb.msg_connect(deframe, "out", debug, "store") self.tb.start() msg = pmt.cons(pmt.PMT_NIL, pmt.init_u8vector(len(src_data), src_data)) for i in xrange(npkts): frame.to_basic_block()._post(pmt.intern("in"), msg) sleep(0.2) self.tb.stop() self.tb.wait() rxmsg = debug.get_message(0) result_len = pmt.blob_length(pmt.cdr(rxmsg)) msg_data = [] for j in xrange(result_len): msg_data.append(pmt.u8vector_ref(pmt.cdr(rxmsg), j)) self.assertEqual(src_data, msg_data)
def __init__(self): gr.top_block.__init__(self, "Hdlc Frame") Qt.QWidget.__init__(self) self.setWindowTitle("Hdlc Frame") try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "hdlc_Frame") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.samp_rate = samp_rate = 48e3 self.message = message = 'a', 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0 ################################################## # Blocks ################################################## self.satellites_pdu_to_kiss_0 = satellites.pdu_to_kiss() self.qtgui_edit_box_msg_0 = qtgui.edit_box_msg(qtgui.STRING, '', '', False, False, '') self._qtgui_edit_box_msg_0_win = sip.wrapinstance( self.qtgui_edit_box_msg_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_edit_box_msg_0_win) self.epy_block_0 = epy_block_0.blk() self.digital_hdlc_framer_pb_0 = digital.hdlc_framer_pb('packet_len') self.digital_hdlc_deframer_bp_0 = digital.hdlc_deframer_bp(32, 500) self.blocks_random_pdu_0 = blocks.random_pdu(16, 64, chr(0xFF), 2) self.blocks_message_strobe_random_0 = blocks.message_strobe_random( pmt.intern("TEST"), blocks.STROBE_POISSON, 10000, 500) self.blocks_message_debug_1 = blocks.message_debug() self.blocks_message_debug_0 = blocks.message_debug() ################################################## # Connections ################################################## self.msg_connect((self.blocks_message_strobe_random_0, 'strobe'), (self.blocks_random_pdu_0, 'generate')) self.msg_connect((self.blocks_random_pdu_0, 'pdus'), (self.satellites_pdu_to_kiss_0, 'in')) self.msg_connect((self.digital_hdlc_deframer_bp_0, 'out'), (self.blocks_message_debug_0, 'print_pdu')) self.msg_connect((self.satellites_pdu_to_kiss_0, 'out'), (self.digital_hdlc_framer_pb_0, 'in')) self.connect((self.digital_hdlc_framer_pb_0, 0), (self.digital_hdlc_deframer_bp_0, 0))
def __init__(self): gr.top_block.__init__(self, "Ask Tx Top Raspi") ################################################## # Variables ################################################## self.sound_card_sample_rate = sound_card_sample_rate = 44000 self.samples_per_symbol = samples_per_symbol = 19 self.symbol_rate = symbol_rate = sound_card_sample_rate / samples_per_symbol self.bits_per_symbol = bits_per_symbol = 1 self.variable_rrc_filter_taps = variable_rrc_filter_taps = firdes.root_raised_cosine( 15, sound_card_sample_rate, symbol_rate, 0.5, 70) self.bit_rate = bit_rate = symbol_rate / bits_per_symbol ################################################## # Blocks ################################################## self.interp_fir_filter_xxx_0 = filter.interp_fir_filter_fff( samples_per_symbol, (variable_rrc_filter_taps)) self.interp_fir_filter_xxx_0.declare_sample_delay(0) self.digital_hdlc_framer_pb_0 = digital.hdlc_framer_pb('packet_len') self.digital_chunks_to_symbols_xx_0 = digital.chunks_to_symbols_bf( ([-1, 1]), 1) self.blocks_throttle_1 = blocks.throttle(gr.sizeof_char * 1, bit_rate, True) self.blocks_tagged_stream_to_pdu_0 = blocks.tagged_stream_to_pdu( blocks.byte_t, 'packet_len') self.blocks_stream_to_tagged_stream_0 = blocks.stream_to_tagged_stream( gr.sizeof_char, 1, 32, "packet_len") self.blocks_file_source_0 = blocks.file_source(gr.sizeof_char * 1, './test_src_file.txt', True) self.audio_sink_0 = audio.sink(int(sound_card_sample_rate), '', True) ################################################## # Connections ################################################## self.msg_connect((self.blocks_tagged_stream_to_pdu_0, 'pdus'), (self.digital_hdlc_framer_pb_0, 'in')) self.connect((self.blocks_file_source_0, 0), (self.blocks_throttle_1, 0)) self.connect((self.blocks_stream_to_tagged_stream_0, 0), (self.blocks_tagged_stream_to_pdu_0, 0)) self.connect((self.blocks_throttle_1, 0), (self.blocks_stream_to_tagged_stream_0, 0)) self.connect((self.digital_chunks_to_symbols_xx_0, 0), (self.interp_fir_filter_xxx_0, 0)) self.connect((self.digital_hdlc_framer_pb_0, 0), (self.digital_chunks_to_symbols_xx_0, 0)) self.connect((self.interp_fir_filter_xxx_0, 0), (self.audio_sink_0, 0))
def __init__(self, frameTag="packet_len", numRevs=20): gr.hier_block2.__init__( self, "AX.25 Packet Formatter", gr.io_signature(0, 0, 0), gr.io_signature(0, 0, 0), ) self.message_port_register_hier_in("in") self.message_port_register_hier_out("out") ################################################## # Parameters ################################################## self.frameTag = frameTag self.numRevs = numRevs ################################################## # Blocks ################################################## self.digital_hdlc_framer_pb_0 = digital.hdlc_framer_pb(frameTag) self.blocks_vector_source_x_0 = blocks.vector_source_b( tuple([0, 1, 1, 1, 1, 1, 1, 0] * numRevs), True, 1, []) self.blocks_tagged_stream_to_pdu_0 = blocks.tagged_stream_to_pdu( blocks.byte_t, frameTag) self.blocks_tagged_stream_mux_0 = blocks.tagged_stream_mux( gr.sizeof_char * 1, frameTag, 0) self.blocks_stream_to_tagged_stream_0 = blocks.stream_to_tagged_stream( gr.sizeof_char, 1, numRevs * 8, frameTag) self.amateur_Tagged_Nrzi_Encoder_0 = amateur.Tagged_Nrzi_Encoder( frameTag, 1) self.amateur_AX25_Packet_Encoder_0 = amateur.AX25_Packet_Encoder() ################################################## # Connections ################################################## self.msg_connect((self.amateur_AX25_Packet_Encoder_0, 'pkt'), (self.digital_hdlc_framer_pb_0, 'in')) self.msg_connect((self.blocks_tagged_stream_to_pdu_0, 'pdus'), (self, 'out')) self.msg_connect((self, 'in'), (self.amateur_AX25_Packet_Encoder_0, 'data')) self.connect((self.amateur_Tagged_Nrzi_Encoder_0, 0), (self.blocks_tagged_stream_to_pdu_0, 0)) self.connect((self.blocks_stream_to_tagged_stream_0, 0), (self.blocks_tagged_stream_mux_0, 0)) self.connect((self.blocks_tagged_stream_mux_0, 0), (self.amateur_Tagged_Nrzi_Encoder_0, 0)) self.connect((self.blocks_vector_source_x_0, 0), (self.blocks_stream_to_tagged_stream_0, 0)) self.connect((self.digital_hdlc_framer_pb_0, 0), (self.blocks_tagged_stream_mux_0, 1))
def __init__(self, tx_file, bits_per_symbol=2, rolloff=0.5, sound_card_sample_rate=22000): gr.top_block.__init__(self, "If Psk Tx Rpi") ################################################## # Variables ################################################## self.sound_card_sample_rate = sound_card_sample_rate self.samples_per_symbol = samples_per_symbol = 16 self.symbol_rate = symbol_rate = sound_card_sample_rate / samples_per_symbol self.bits_per_symbol = bits_per_symbol self.hdlc_packet_overhead = hdlc_packet_overhead = 6 * 8 self.hdlc_packet_length = hdlc_packet_length = 16 * 8 self.channel_bit_rate = channel_bit_rate = symbol_rate * bits_per_symbol self.source_bit_rate = source_bit_rate = channel_bit_rate * hdlc_packet_length / ( hdlc_packet_overhead + hdlc_packet_length) self.rolloff = rolloff self.quantization_depth = quantization_depth = 16 self.if_frequency = if_frequency = sound_card_sample_rate / 4 ################################################## # Blocks ################################################## self.digital_psk_mod_0 = digital.psk.psk_mod( constellation_points=pow(2, bits_per_symbol), mod_code="gray", differential=True, samples_per_symbol=samples_per_symbol, excess_bw=rolloff, verbose=False, log=False, ) self.digital_hdlc_framer_pb_0 = digital.hdlc_framer_pb("packet_len") self.blocks_unpacked_to_packed_xx_0 = blocks.unpacked_to_packed_bb( 1, gr.GR_MSB_FIRST) self.blocks_tagged_stream_to_pdu_0 = blocks.tagged_stream_to_pdu( blocks.byte_t, "packet_len") self.blocks_stream_to_tagged_stream_0 = blocks.stream_to_tagged_stream( gr.sizeof_char, 1, hdlc_packet_length / 8, "packet_len") self.blocks_multiply_xx_0_0_1 = blocks.multiply_vff(1) self.blocks_multiply_xx_0_0_0 = blocks.multiply_vff(1) self.blocks_file_source_0 = blocks.file_source(gr.sizeof_char * 1, tx_file, False) self.blocks_complex_to_float_0 = blocks.complex_to_float(1) self.blocks_add_xx_0 = blocks.add_vff(1) self.audio_sink_0 = audio.sink(int(sound_card_sample_rate), "", True) self.analog_sig_source_x_0_0 = analog.sig_source_f( sound_card_sample_rate, analog.GR_COS_WAVE, if_frequency, 1, 0) self.analog_sig_source_x_0 = analog.sig_source_f( sound_card_sample_rate, analog.GR_SIN_WAVE, if_frequency, 1, 0) ################################################## # Connections ################################################## self.msg_connect((self.blocks_tagged_stream_to_pdu_0, 'pdus'), (self.digital_hdlc_framer_pb_0, 'in')) self.connect((self.analog_sig_source_x_0, 0), (self.blocks_multiply_xx_0_0_1, 1)) self.connect((self.analog_sig_source_x_0_0, 0), (self.blocks_multiply_xx_0_0_0, 0)) self.connect((self.blocks_add_xx_0, 0), (self.audio_sink_0, 0)) self.connect((self.blocks_complex_to_float_0, 0), (self.blocks_multiply_xx_0_0_0, 1)) self.connect((self.blocks_complex_to_float_0, 1), (self.blocks_multiply_xx_0_0_1, 0)) self.connect((self.blocks_file_source_0, 0), (self.blocks_stream_to_tagged_stream_0, 0)) self.connect((self.blocks_multiply_xx_0_0_0, 0), (self.blocks_add_xx_0, 0)) self.connect((self.blocks_multiply_xx_0_0_1, 0), (self.blocks_add_xx_0, 1)) self.connect((self.blocks_stream_to_tagged_stream_0, 0), (self.blocks_tagged_stream_to_pdu_0, 0)) self.connect((self.blocks_unpacked_to_packed_xx_0, 0), (self.digital_psk_mod_0, 0)) self.connect((self.digital_hdlc_framer_pb_0, 0), (self.blocks_unpacked_to_packed_xx_0, 0)) self.connect((self.digital_psk_mod_0, 0), (self.blocks_complex_to_float_0, 0))
def __init__(self): gr.top_block.__init__(self, "Tx Top") Qt.QWidget.__init__(self) self.setWindowTitle("Tx Top") try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "tx_top") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.sound_card_sample_rate = sound_card_sample_rate = 96000 self.samples_per_symbol = samples_per_symbol = 19 self.symbol_rate = symbol_rate = sound_card_sample_rate/samples_per_symbol self.variable_rrc_filter_taps = variable_rrc_filter_taps = firdes.root_raised_cosine(15, sound_card_sample_rate, symbol_rate, 0.5, 70) self.bits_per_symbol = bits_per_symbol = 1 ################################################## # Blocks ################################################## self.qtgui_time_sink_x_0 = qtgui.time_sink_f( 500, #size sound_card_sample_rate, #samp_rate "Baseband TX signal", #name 1 #number of inputs ) self.qtgui_time_sink_x_0.set_update_time(0.10) self.qtgui_time_sink_x_0.set_y_axis(-2, 2) self.qtgui_time_sink_x_0.set_y_label('Amplitude', "") self.qtgui_time_sink_x_0.enable_tags(-1, True) self.qtgui_time_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_0.enable_autoscale(True) self.qtgui_time_sink_x_0.enable_grid(False) self.qtgui_time_sink_x_0.enable_axis_labels(True) self.qtgui_time_sink_x_0.enable_control_panel(False) if not True: self.qtgui_time_sink_x_0.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue"] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_time_sink_x_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_win = sip.wrapinstance(self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_time_sink_x_0_win) self.interp_fir_filter_xxx_0 = filter.interp_fir_filter_fff(samples_per_symbol, (variable_rrc_filter_taps)) self.interp_fir_filter_xxx_0.declare_sample_delay(0) self.digital_hdlc_framer_pb_0 = digital.hdlc_framer_pb('packet_len') self.digital_chunks_to_symbols_xx_0 = digital.chunks_to_symbols_bf(([-1,1]), 1) self.blocks_wavfile_sink_0 = blocks.wavfile_sink('tx_signal.wav', 1, sound_card_sample_rate, 8) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_float*1, sound_card_sample_rate,True) self.blocks_tagged_stream_to_pdu_0 = blocks.tagged_stream_to_pdu(blocks.byte_t, 'packet_len') self.blocks_stream_to_tagged_stream_0 = blocks.stream_to_tagged_stream(gr.sizeof_char, 1, 32, "packet_len") self.blocks_file_source_0 = blocks.file_source(gr.sizeof_char*1, '/usr/src/app/test_src_file.txt', True) ################################################## # Connections ################################################## self.msg_connect((self.blocks_tagged_stream_to_pdu_0, 'pdus'), (self.digital_hdlc_framer_pb_0, 'in')) self.connect((self.blocks_file_source_0, 0), (self.blocks_stream_to_tagged_stream_0, 0)) self.connect((self.blocks_stream_to_tagged_stream_0, 0), (self.blocks_tagged_stream_to_pdu_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.qtgui_time_sink_x_0, 0)) self.connect((self.digital_chunks_to_symbols_xx_0, 0), (self.interp_fir_filter_xxx_0, 0)) self.connect((self.digital_hdlc_framer_pb_0, 0), (self.digital_chunks_to_symbols_xx_0, 0)) self.connect((self.interp_fir_filter_xxx_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.interp_fir_filter_xxx_0, 0), (self.blocks_wavfile_sink_0, 0))
def __init__(self): gr.top_block.__init__(self, "If Psk Tx") Qt.QWidget.__init__(self) self.setWindowTitle("If Psk Tx") try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "if_psk_tx") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.sound_card_sample_rate = sound_card_sample_rate = 11025 self.samples_per_symbol = samples_per_symbol = 16 self.symbol_rate = symbol_rate = sound_card_sample_rate/samples_per_symbol self.bits_per_symbol = bits_per_symbol = 2 self.hdlc_packet_overhead = hdlc_packet_overhead = 6*8 self.hdlc_packet_length = hdlc_packet_length = 16*8 self.channel_bit_rate = channel_bit_rate = symbol_rate*bits_per_symbol self.source_bit_rate = source_bit_rate = channel_bit_rate*hdlc_packet_length/(hdlc_packet_overhead+hdlc_packet_length) self.rolloff = rolloff = 0.5 self.quantization_depth = quantization_depth = 16 self.if_frequency = if_frequency = sound_card_sample_rate/4 ################################################## # Blocks ################################################## self.final_0 = qtgui.sink_f( 1024, #fftsize firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc sound_card_sample_rate, #bw "IF modulated signal", #name True, #plotfreq True, #plotwaterfall True, #plottime False, #plotconst ) self.final_0.set_update_time(1.0/10) self._final_0_win = sip.wrapinstance(self.final_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._final_0_win) self.final_0.enable_rf_freq(False) self.final = qtgui.sink_c( 1024, #fftsize firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc sound_card_sample_rate, #bw "Baseband signal", #name True, #plotfreq True, #plotwaterfall True, #plottime True, #plotconst ) self.final.set_update_time(1.0/10) self._final_win = sip.wrapinstance(self.final.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._final_win) self.final.enable_rf_freq(False) self.digital_psk_mod_0 = digital.psk.psk_mod( constellation_points=pow(2,bits_per_symbol), mod_code="gray", differential=True, samples_per_symbol=samples_per_symbol, excess_bw=rolloff, verbose=False, log=False, ) self.digital_hdlc_framer_pb_0 = digital.hdlc_framer_pb("packet_len") self.blocks_wavfile_sink_0 = blocks.wavfile_sink("tx_signal.wav", 1, sound_card_sample_rate, quantization_depth) self.blocks_unpacked_to_packed_xx_0 = blocks.unpacked_to_packed_bb(1, gr.GR_MSB_FIRST) self.blocks_throttle_0_0 = blocks.throttle(gr.sizeof_char*1, source_bit_rate/8,True) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_float*1, sound_card_sample_rate,True) self.blocks_tagged_stream_to_pdu_0 = blocks.tagged_stream_to_pdu(blocks.byte_t, "packet_len") self.blocks_stream_to_tagged_stream_0 = blocks.stream_to_tagged_stream(gr.sizeof_char, 1, hdlc_packet_length/8, "packet_len") self.blocks_multiply_xx_0_0_1 = blocks.multiply_vff(1) self.blocks_multiply_xx_0_0_0 = blocks.multiply_vff(1) self.blocks_file_source_0 = blocks.file_source(gr.sizeof_char*1, "test_tx_file_ordered.csv", False) self.blocks_complex_to_float_0 = blocks.complex_to_float(1) self.blocks_add_xx_0 = blocks.add_vff(1) self.analog_sig_source_x_0_0 = analog.sig_source_f(sound_card_sample_rate, analog.GR_COS_WAVE, if_frequency, 1, 0) self.analog_sig_source_x_0 = analog.sig_source_f(sound_card_sample_rate, analog.GR_SIN_WAVE, if_frequency, 1, 0) ################################################## # Connections ################################################## self.msg_connect((self.blocks_tagged_stream_to_pdu_0, 'pdus'), (self.digital_hdlc_framer_pb_0, 'in')) self.connect((self.analog_sig_source_x_0, 0), (self.blocks_multiply_xx_0_0_1, 1)) self.connect((self.analog_sig_source_x_0_0, 0), (self.blocks_multiply_xx_0_0_0, 0)) self.connect((self.blocks_add_xx_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.blocks_add_xx_0, 0), (self.final_0, 0)) self.connect((self.blocks_complex_to_float_0, 0), (self.blocks_multiply_xx_0_0_0, 1)) self.connect((self.blocks_complex_to_float_0, 1), (self.blocks_multiply_xx_0_0_1, 0)) self.connect((self.blocks_file_source_0, 0), (self.blocks_throttle_0_0, 0)) self.connect((self.blocks_multiply_xx_0_0_0, 0), (self.blocks_add_xx_0, 0)) self.connect((self.blocks_multiply_xx_0_0_1, 0), (self.blocks_add_xx_0, 1)) self.connect((self.blocks_stream_to_tagged_stream_0, 0), (self.blocks_tagged_stream_to_pdu_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.blocks_wavfile_sink_0, 0)) self.connect((self.blocks_throttle_0_0, 0), (self.blocks_stream_to_tagged_stream_0, 0)) self.connect((self.blocks_unpacked_to_packed_xx_0, 0), (self.digital_psk_mod_0, 0)) self.connect((self.digital_hdlc_framer_pb_0, 0), (self.blocks_unpacked_to_packed_xx_0, 0)) self.connect((self.digital_psk_mod_0, 0), (self.blocks_complex_to_float_0, 0)) self.connect((self.digital_psk_mod_0, 0), (self.final, 0))
def __init__(self, baud_rate=1200, mark_freq=1200, offset=50e3, postamble_len=4, preamble_len=.1, rf_samp_rate=2.4e6, space_freq=2200): gr.hier_block2.__init__( self, "afsk_ax25_mod", gr.io_signature(0, 0, 0), # Input signature gr.io_signature(1, 1, gr.sizeof_gr_complex)) # Output signature self.message_port_register_hier_in("packets") ################################################## # Parameters ################################################## self.baud_rate = baud_rate self.mark_freq = mark_freq self.offset = offset self.postamble_len = postamble_len self.preamble_len = preamble_len self.rf_samp_rate = rf_samp_rate self.space_freq = space_freq ################################################## # Variables ################################################## self.samp_rate = samp_rate = 48000 self.sps = sps = samp_rate / baud_rate ################################################## # Blocks ################################################## self.rational_resampler_xxx_0 = filter.rational_resampler_ccc( interpolation=int(rf_samp_rate), decimation=int(samp_rate), taps=None, fractional_bw=None, ) self.hsl_ptt_cc_0 = hsl.ptt_cc() self.digital_hdlc_framer_pb_0 = digital.hdlc_framer_pb('packet_len') self.digital_diff_encoder_bb_0 = digital.diff_encoder_bb(2) self.digital_chunks_to_symbols_xx_1 = digital.chunks_to_symbols_bf( ([mark_freq, space_freq]), 1) self.blocks_vector_source_x_0_0 = blocks.vector_source_b([0x7e], True, 1, []) self.blocks_vector_source_x_0 = blocks.vector_source_b([0x7e], True, 1, []) self.blocks_vco_f_0 = blocks.vco_f(samp_rate, 2 * math.pi, .95) self.blocks_tagged_stream_mux_0 = blocks.tagged_stream_mux( gr.sizeof_char * 1, 'packet_len', 0) self.blocks_stream_to_tagged_stream_0_0 = blocks.stream_to_tagged_stream( gr.sizeof_char, 1, postamble_len * 8, "packet_len") self.blocks_stream_to_tagged_stream_0 = blocks.stream_to_tagged_stream( gr.sizeof_char, 1, int(baud_rate * preamble_len), "packet_len") self.blocks_repeat_0 = blocks.repeat(gr.sizeof_char * 1, sps) self.blocks_packed_to_unpacked_xx_0_0 = blocks.packed_to_unpacked_bb( 1, gr.GR_LSB_FIRST) self.blocks_packed_to_unpacked_xx_0 = blocks.packed_to_unpacked_bb( 1, gr.GR_LSB_FIRST) self.blocks_not_xx_0_0_0_0 = blocks.not_bb() self.blocks_multiply_xx_0 = blocks.multiply_vcc(1) self.blocks_and_const_xx_0_0_0_0 = blocks.and_const_bb(1) self.analog_sig_source_x_0 = analog.sig_source_c( rf_samp_rate, analog.GR_COS_WAVE, offset, 1, 0) self.analog_nbfm_tx_0 = analog.nbfm_tx( audio_rate=samp_rate, quad_rate=samp_rate, tau=75e-6, max_dev=5e3, fh=-1.0, ) ################################################## # Connections ################################################## self.msg_connect((self, 'packets'), (self.digital_hdlc_framer_pb_0, 'in')) self.connect((self.analog_nbfm_tx_0, 0), (self.hsl_ptt_cc_0, 0)) self.connect((self.analog_sig_source_x_0, 0), (self.blocks_multiply_xx_0, 0)) self.connect((self.blocks_and_const_xx_0_0_0_0, 0), (self.digital_diff_encoder_bb_0, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self, 0)) self.connect((self.blocks_not_xx_0_0_0_0, 0), (self.blocks_and_const_xx_0_0_0_0, 0)) self.connect((self.blocks_packed_to_unpacked_xx_0, 0), (self.blocks_stream_to_tagged_stream_0, 0)) self.connect((self.blocks_packed_to_unpacked_xx_0_0, 0), (self.blocks_stream_to_tagged_stream_0_0, 0)) self.connect((self.blocks_repeat_0, 0), (self.digital_chunks_to_symbols_xx_1, 0)) self.connect((self.blocks_stream_to_tagged_stream_0, 0), (self.blocks_tagged_stream_mux_0, 0)) self.connect((self.blocks_stream_to_tagged_stream_0_0, 0), (self.blocks_tagged_stream_mux_0, 2)) self.connect((self.blocks_tagged_stream_mux_0, 0), (self.blocks_not_xx_0_0_0_0, 0)) self.connect((self.blocks_vco_f_0, 0), (self.analog_nbfm_tx_0, 0)) self.connect((self.blocks_vco_f_0, 0), (self.hsl_ptt_cc_0, 1)) self.connect((self.blocks_vector_source_x_0, 0), (self.blocks_packed_to_unpacked_xx_0, 0)) self.connect((self.blocks_vector_source_x_0_0, 0), (self.blocks_packed_to_unpacked_xx_0_0, 0)) self.connect((self.digital_chunks_to_symbols_xx_1, 0), (self.blocks_vco_f_0, 0)) self.connect((self.digital_diff_encoder_bb_0, 0), (self.blocks_repeat_0, 0)) self.connect((self.digital_hdlc_framer_pb_0, 0), (self.blocks_tagged_stream_mux_0, 1)) self.connect((self.hsl_ptt_cc_0, 0), (self.rational_resampler_xxx_0, 0)) self.connect((self.rational_resampler_xxx_0, 0), (self.blocks_multiply_xx_0, 1))