diff --git a/examples/Frame_Sync_Example.grc b/examples/Frame_Sync_Example.grc new file mode 100644 index 0000000..5d503d2 --- /dev/null +++ b/examples/Frame_Sync_Example.grc @@ -0,0 +1,1311 @@ + + + + Sun Sep 4 20:59:56 2016 + + options + + author + Aaron Scher + + + window_size + 2000,2000 + + + category + [GRC Hier Blocks] + + + comment + + + + description + This example shows the basics of frame syncing. + + + _enabled + True + + + _coordinate + (8, 8) + + + _rotation + 0 + + + generate_options + qt_gui + + + hier_block_src_path + .: + + + id + top_block + + + max_nouts + 0 + + + qt_qss_theme + + + + realtime_scheduling + + + + run_command + {python} -u {filename} + + + run_options + prompt + + + run + True + + + sizing_mode + fixed + + + thread_safe_setters + + + + title + Frame Sync Example + + + placement + (0,0) + + + + variable + + comment + + + + _enabled + True + + + _coordinate + (8, 92) + + + _rotation + 0 + + + id + samp_rate + + + value + 32000 + + + + blocks_message_debug + + alias + + + + comment + Display the message that was sent. + + + affinity + + + + _enabled + 1 + + + _coordinate + (896, 208) + + + _rotation + 0 + + + id + blocks_message_debug_0 + + + + blocks_message_strobe + + alias + + + + comment + Generate hello world message + + + affinity + + + + _enabled + 1 + + + _coordinate + (192, 20) + + + _rotation + 0 + + + id + blocks_message_strobe_0_0 + + + maxoutbuf + 0 + + + msg + pmt.cons(pmt.make_dict(), pmt.pmt_to_python.numpy_to_uvector(numpy.array([ord(c) for c in "Hello world!"], numpy.uint8))) + + + minoutbuf + 0 + + + period + 500 + + + + blocks_pdu_to_tagged_stream + + alias + + + + comment + + + + affinity + + + + _enabled + True + + + _coordinate + (216, 124) + + + _rotation + 0 + + + id + blocks_pdu_to_tagged_stream_1 + + + type + byte + + + tag + len_key + + + maxoutbuf + 0 + + + minoutbuf + 0 + + + + blocks_repack_bits_bb + + k + 8 + + + l + hdr_const.bits_per_symbol() + + + alias + + + + comment + Access code block up ahead needs 1 byte +per bit + + + affinity + + + + _enabled + 1 + + + endianness + gr.GR_MSB_FIRST + + + _coordinate + (872, 84) + + + _rotation + 0 + + + id + blocks_repack_bits_bb_0_0 + + + len_tag_key + len_key + + + maxoutbuf + 0 + + + minoutbuf + 0 + + + align_output + False + + + + blocks_repack_bits_bb + + k + 1 + + + l + 8 + + + alias + + + + comment + Tagged Stream to PDU block up ahead needs packed bytes + + + affinity + + + + _enabled + 1 + + + endianness + gr.GR_MSB_FIRST + + + _coordinate + (456, 260) + + + _rotation + 0 + + + id + blocks_repack_bits_bb_0_0_0 + + + len_tag_key + len_key2 + + + maxoutbuf + 0 + + + minoutbuf + 0 + + + align_output + False + + + + blocks_tag_gate + + alias + + + + comment + Simulate the "channel'... removes tags + + + affinity + + + + _enabled + 1 + + + _coordinate + (216, 204) + + + _rotation + 0 + + + id + blocks_tag_gate_0_0 + + + type + byte + + + maxoutbuf + 0 + + + minoutbuf + 0 + + + propagate_tags + False + + + single_key + "" + + + vlen + 1 + + + + blocks_tagged_stream_mux + + alias + + + + comment + Append header to payload + + + affinity + + + + _enabled + True + + + _coordinate + (608, 80) + + + _rotation + 0 + + + id + blocks_tagged_stream_mux_0 + + + type + byte + + + lengthtagname + len_key + + + maxoutbuf + 0 + + + minoutbuf + 0 + + + ninputs + 2 + + + tag_preserve_head_pos + 0 + + + vlen + 1 + + + + blocks_tagged_stream_to_pdu + + alias + + + + comment + + + + affinity + + + + _enabled + 1 + + + _coordinate + (680, 268) + + + _rotation + 0 + + + id + blocks_tagged_stream_to_pdu_0 + + + type + byte + + + tag + len_key2 + + + maxoutbuf + 0 + + + minoutbuf + 0 + + + + blocks_throttle + + alias + + + + comment + Slow things down :) + + + affinity + + + + _enabled + True + + + _coordinate + (728, 4) + + + _rotation + 0 + + + id + blocks_throttle_0 + + + ignoretag + True + + + maxoutbuf + 0 + + + minoutbuf + 0 + + + samples_per_second + samp_rate + + + type + byte + + + vlen + 1 + + + + digital_chunks_to_symbols_xx + + alias + + + + comment + To display in time domain we map individual +bits to (complex) symbols + + + affinity + + + + dimension + 1 + + + _enabled + 1 + + + _coordinate + (504, 356) + + + _rotation + 0 + + + id + digital_chunks_to_symbols_xx_0_0_0 + + + in_type + byte + + + maxoutbuf + 0 + + + minoutbuf + 0 + + + num_ports + 1 + + + out_type + complex + + + symbol_table + hdr_const.points() + + + + digital_correlate_access_code_xx_ts + + access_code + digital.packet_utils.default_access_code + + + alias + + + + comment + Correlates with access code to extract the payload. + + + affinity + + + + _enabled + 1 + + + _coordinate + (208, 320) + + + _rotation + 0 + + + id + digital_correlate_access_code_xx_ts_1 + + + type + byte + + + maxoutbuf + 0 + + + minoutbuf + 0 + + + tagname + len_key2 + + + threshold + 0 + + + + digital_protocol_formatter_bb + + alias + + + + comment + Generate header + + + affinity + + + + _enabled + True + + + format + hdr_format + + + _coordinate + (464, 4) + + + _rotation + 0 + + + id + digital_protocol_formatter_bb_0 + + + len_tag_key + len_key + + + maxoutbuf + 0 + + + minoutbuf + 0 + + + + parameter + + alias + + + + comment + + + + _enabled + 1 + + + _coordinate + (8, 184) + + + _rotation + 0 + + + id + hdr_const + + + label + Header constellation + + + short_id + + + + hide + none + + + type + + + + value + digital.constellation_calcdist((digital.psk_2()[0]), (digital.psk_2()[1]), 2, 1).base() + + + + parameter + + alias + + + + comment + + + + _enabled + 1 + + + _coordinate + (8, 248) + + + _rotation + 0 + + + id + hdr_format + + + label + Header Formatter + + + short_id + + + + hide + none + + + type + + + + value + digital.header_format_default(digital.packet_utils.default_access_code, 0) + + + + import + + alias + + + + comment + + + + _enabled + True + + + _coordinate + (8, 148) + + + _rotation + 0 + + + id + import_0 + + + import + import numpy + + + + qtgui_time_sink_x + + autoscale + True + + + axislabels + True + + + alias + + + + comment + Display payloud in time domain + + + ctrlpanel + False + + + affinity + + + + entags + True + + + _enabled + 1 + + + _coordinate + (760, 352) + + + gui_hint + + + + _rotation + 0 + + + grid + False + + + id + qtgui_time_sink_x_0_1_0 + + + legend + True + + + alpha1 + 1.0 + + + color1 + "blue" + + + label1 + + + + marker1 + -1 + + + style1 + 1 + + + width1 + 1 + + + alpha10 + 1.0 + + + color10 + "blue" + + + label10 + + + + marker10 + -1 + + + style10 + 1 + + + width10 + 1 + + + alpha2 + 1.0 + + + color2 + "red" + + + label2 + + + + marker2 + -1 + + + style2 + 1 + + + width2 + 1 + + + alpha3 + 1.0 + + + color3 + "green" + + + label3 + + + + marker3 + -1 + + + style3 + 1 + + + width3 + 1 + + + alpha4 + 1.0 + + + color4 + "black" + + + label4 + + + + marker4 + -1 + + + style4 + 1 + + + width4 + 1 + + + alpha5 + 1.0 + + + color5 + "cyan" + + + label5 + + + + marker5 + -1 + + + style5 + 1 + + + width5 + 1 + + + alpha6 + 1.0 + + + color6 + "magenta" + + + label6 + + + + marker6 + -1 + + + style6 + 1 + + + width6 + 1 + + + alpha7 + 1.0 + + + color7 + "yellow" + + + label7 + + + + marker7 + -1 + + + style7 + 1 + + + width7 + 1 + + + alpha8 + 1.0 + + + color8 + "dark red" + + + label8 + + + + marker8 + -1 + + + style8 + 1 + + + width8 + 1 + + + alpha9 + 1.0 + + + color9 + "dark green" + + + label9 + + + + marker9 + -1 + + + style9 + 1 + + + width9 + 1 + + + name + "" + + + nconnections + 1 + + + size + 1024 + + + srate + samp_rate + + + stemplot + False + + + tr_chan + 0 + + + tr_delay + 0 + + + tr_level + 0.0 + + + tr_mode + qtgui.TRIG_MODE_FREE + + + tr_slope + qtgui.TRIG_SLOPE_POS + + + tr_tag + "" + + + type + complex + + + update_time + 0.10 + + + ylabel + Amplitude + + + yunit + "" + + + ymax + 1 + + + ymin + -1 + + + + blocks_message_strobe_0_0 + blocks_pdu_to_tagged_stream_1 + strobe + pdus + + + blocks_pdu_to_tagged_stream_1 + blocks_tagged_stream_mux_0 + 0 + 1 + + + blocks_pdu_to_tagged_stream_1 + digital_protocol_formatter_bb_0 + 0 + 0 + + + blocks_repack_bits_bb_0_0 + blocks_tag_gate_0_0 + 0 + 0 + + + blocks_repack_bits_bb_0_0_0 + blocks_tagged_stream_to_pdu_0 + 0 + 0 + + + blocks_tag_gate_0_0 + digital_correlate_access_code_xx_ts_1 + 0 + 0 + + + blocks_tagged_stream_mux_0 + blocks_throttle_0 + 0 + 0 + + + blocks_tagged_stream_to_pdu_0 + blocks_message_debug_0 + pdus + print + + + blocks_throttle_0 + blocks_repack_bits_bb_0_0 + 0 + 0 + + + digital_chunks_to_symbols_xx_0_0_0 + qtgui_time_sink_x_0_1_0 + 0 + 0 + + + digital_correlate_access_code_xx_ts_1 + blocks_repack_bits_bb_0_0_0 + 0 + 0 + + + digital_correlate_access_code_xx_ts_1 + digital_chunks_to_symbols_xx_0_0_0 + 0 + 0 + + + digital_protocol_formatter_bb_0 + blocks_tagged_stream_mux_0 + 0 + 0 + + diff --git a/examples/HackRF_RTLSDR_loopback_test.grc b/examples/HackRF_RTLSDR_loopback_test.grc new file mode 100644 index 0000000..8e3ff2a --- /dev/null +++ b/examples/HackRF_RTLSDR_loopback_test.grc @@ -0,0 +1,5622 @@ + + + + Sun Sep 4 20:59:56 2016 + + options + + author + Aaron Scher + + + window_size + 2000,2000 + + + category + [GRC Hier Blocks] + + + comment + + + + description + Transmit and receive example + + + _enabled + True + + + _coordinate + (8, 8) + + + _rotation + 0 + + + generate_options + qt_gui + + + hier_block_src_path + .: + + + id + top_block + + + max_nouts + 0 + + + qt_qss_theme + + + + realtime_scheduling + + + + run_command + {python} -u {filename} + + + run_options + prompt + + + run + True + + + sizing_mode + fixed + + + thread_safe_setters + + + + title + HackRF - RTLSDR loop back test + + + placement + (0,0) + + + + variable + + comment + + + + _enabled + True + + + _coordinate + (872, 4) + + + _rotation + 0 + + + id + EBW + + + value + .35 + + + + variable_rrc_filter_taps + + comment + Root raised cosine definition. + + + _enabled + 1 + + + alpha + EBW + + + _coordinate + (760, 4) + + + _rotation + 0 + + + gain + nfilts + + + id + RRC_filter_taps + + + ntaps + 5*sps_TX*nfilts + + + samp_rate + nfilts + + + sym_rate + 1.0 + + + + variable + + comment + RF carrier frequency + + + _enabled + True + + + _coordinate + (472, 4) + + + _rotation + 0 + + + id + center_freq + + + value + 430E6 + + + + variable + + comment + Digitally upcovert transmitted +signal by this value to avoid +DC spurs, etc. +At the receiver end, we will +need to downconvert signal +by this value. + + + _enabled + True + + + _coordinate + (312, 4) + + + _rotation + 0 + + + id + freq_offset_value + + + value + 30E3 + + + + variable + + comment + + + + _enabled + True + + + _coordinate + (872, 60) + + + _rotation + 0 + + + id + nfilts + + + value + 32 + + + + variable + + comment + Sample rate - +determines BW +of transmitter and receiver. +This should be larger +than BW of signal itself. + + + _enabled + True + + + _coordinate + (160, 4) + + + _rotation + 0 + + + id + samp_rate + + + value + 1e6 + + + + variable + + comment + Samples per +signal at +receiver + + + _enabled + True + + + _coordinate + (88, 108) + + + _rotation + 0 + + + id + sps_RX + + + value + 40/10 + + + + variable + + comment + Samples +per signal +at transmitter + + + _enabled + True + + + _coordinate + (8, 108) + + + _rotation + 0 + + + id + sps_TX + + + value + 40 + + + + analog_feedforward_agc_cc + + alias + + + + comment + Optional AGC + + + affinity + + + + _enabled + 2 + + + _coordinate + (432, 972) + + + _rotation + 0 + + + id + analog_feedforward_agc_cc_0 + + + maxoutbuf + 0 + + + minoutbuf + 0 + + + num_samples + 1024/2 + + + reference + 1.0 + + + + analog_pwr_squelch_xx + + alpha + .01 + + + alias + + + + comment + Optional power squelch + + + affinity + + + + _enabled + 2 + + + _coordinate + (224, 888) + + + _rotation + 0 + + + gate + True + + + id + analog_pwr_squelch_xx_0 + + + maxoutbuf + 0 + + + minoutbuf + 0 + + + ramp + 0 + + + threshold + -20 + + + type + complex + + + + analog_sig_source_x + + amp + 1 + + + alias + + + + comment + Local oscillator + + + affinity + + + + _enabled + 1 + + + freq + freq_offset_value + + + _coordinate + (840, 632) + + + _rotation + 90 + + + id + analog_sig_source_x_0 + + + maxoutbuf + 0 + + + minoutbuf + 0 + + + offset + 0 + + + type + complex + + + samp_rate + samp_rate + + + waveform + analog.GR_COS_WAVE + + + + analog_sig_source_x + + amp + 1 + + + alias + + + + comment + local oscillator + + + affinity + + + + _enabled + True + + + freq + -freq_offset_value + + + _coordinate + (24, 1132) + + + _rotation + 0 + + + id + analog_sig_source_x_1 + + + maxoutbuf + 0 + + + minoutbuf + 0 + + + offset + 0 + + + type + complex + + + samp_rate + samp_rate + + + waveform + analog.GR_COS_WAVE + + + + blocks_message_debug + + alias + + + + comment + Display recovered +message + + + affinity + + + + _enabled + 1 + + + _coordinate + (1008, 1160) + + + _rotation + 0 + + + id + blocks_message_debug_0 + + + + blocks_message_strobe + + alias + + + + comment + Generate hello world message + + + affinity + + + + _enabled + 0 + + + _coordinate + (24, 276) + + + _rotation + 0 + + + id + blocks_message_strobe_0_0 + + + maxoutbuf + 0 + + + msg + pmt.cons(pmt.make_dict(), pmt.pmt_to_python.numpy_to_uvector(numpy.array([ord(c) for c in "Hello world!"], numpy.uint8))) + + + minoutbuf + 0 + + + period + 500 + + + + blocks_multiply_const_vxx + + alias + + + + comment + + + + const + 0.5 + + + affinity + + + + _enabled + 1 + + + _coordinate + (640, 564) + + + _rotation + 0 + + + id + blocks_multiply_const_vxx_0 + + + type + complex + + + maxoutbuf + 0 + + + minoutbuf + 0 + + + vlen + 1 + + + + blocks_multiply_xx + + alias + + + + comment + Perform frequency tranlation +(up convert) + + + affinity + + + + _enabled + 1 + + + _coordinate + (952, 472) + + + _rotation + 0 + + + id + blocks_multiply_xx_0 + + + type + complex + + + maxoutbuf + 0 + + + minoutbuf + 0 + + + num_inputs + 2 + + + vlen + 1 + + + + blocks_multiply_xx + + alias + + + + comment + Perform frequency translation +(down convert) + + + affinity + + + + _enabled + True + + + _coordinate + (216, 1128) + + + _rotation + 0 + + + id + blocks_multiply_xx_1 + + + type + complex + + + maxoutbuf + 0 + + + minoutbuf + 0 + + + num_inputs + 2 + + + vlen + 1 + + + + blocks_pdu_to_tagged_stream + + alias + + + + comment + + + + affinity + + + + _enabled + 1 + + + _coordinate + (120, 620) + + + _rotation + 0 + + + id + blocks_pdu_to_tagged_stream_1 + + + type + byte + + + tag + len_key + + + maxoutbuf + 0 + + + minoutbuf + 0 + + + + blocks_repack_bits_bb + + k + 8 + + + l + my_const.bits_per_symbol() + + + alias + + + + comment + Unpack bytes + + + affinity + + + + _enabled + 1 + + + endianness + gr.GR_MSB_FIRST + + + _coordinate + (432, 452) + + + _rotation + 0 + + + id + blocks_repack_bits_bb_0_0 + + + len_tag_key + len_key + + + maxoutbuf + 0 + + + minoutbuf + 0 + + + align_output + False + + + + blocks_repack_bits_bb + + k + 1 + + + l + 8 + + + alias + + + + comment + Tagged Stream to PDU block up ahead needs +packed bytes + + + affinity + + + + _enabled + 1 + + + endianness + gr.GR_MSB_FIRST + + + _coordinate + (872, 972) + + + _rotation + 0 + + + id + blocks_repack_bits_bb_0_0_0 + + + len_tag_key + len_key2 + + + maxoutbuf + 0 + + + minoutbuf + 0 + + + align_output + False + + + + blocks_tagged_stream_multiply_length + + alias + + + + comment + Fix length tag to reflect the resampling + + + affinity + + + + _enabled + 1 + + + _coordinate + (576, 624) + + + _rotation + 0 + + + id + blocks_tagged_stream_multiply_length_0 + + + type + complex + + + c + sps_TX + + + lengthtagname + len_key + + + maxoutbuf + 0 + + + minoutbuf + 0 + + + vlen + 1 + + + + blocks_tagged_stream_mux + + alias + + + + comment + Append header to payload + + + affinity + + + + _enabled + 1 + + + _coordinate + (352, 552) + + + _rotation + 0 + + + id + blocks_tagged_stream_mux_0 + + + type + byte + + + lengthtagname + len_key + + + maxoutbuf + 0 + + + minoutbuf + 0 + + + ninputs + 2 + + + tag_preserve_head_pos + 0 + + + vlen + 1 + + + + blocks_tagged_stream_to_pdu + + alias + + + + comment + + + + affinity + + + + _enabled + 1 + + + _coordinate + (888, 1100) + + + _rotation + 0 + + + id + blocks_tagged_stream_to_pdu_0 + + + type + byte + + + tag + len_key2 + + + maxoutbuf + 0 + + + minoutbuf + 0 + + + + digital_binary_slicer_fb + + alias + + + + comment + + + + affinity + + + + _enabled + True + + + _coordinate + (632, 880) + + + _rotation + 270 + + + id + digital_binary_slicer_fb_0 + + + maxoutbuf + 0 + + + minoutbuf + 0 + + + + digital_burst_shaper_xx + + alias + burst_shaper0 + + + comment + Zero pad, etc. + + + affinity + + + + _enabled + 1 + + + _coordinate + (688, 272) + + + _rotation + 0 + + + id + digital_burst_shaper_xx_0 + + + insert_phasing + True + + + length_tag_name + len_key + + + maxoutbuf + 0 + + + minoutbuf + 0 + + + post_padding + 4000 + + + pre_padding + 4000 + + + type + complex + + + window + numpy.ones(500) + + + + digital_chunks_to_symbols_xx + + alias + + + + comment + Binary 1's and 0's to symbols. + + + affinity + + + + dimension + 1 + + + _enabled + 1 + + + _coordinate + (464, 324) + + + _rotation + 0 + + + id + digital_chunks_to_symbols_xx_0_0 + + + in_type + byte + + + maxoutbuf + 0 + + + minoutbuf + 0 + + + num_ports + 1 + + + out_type + complex + + + symbol_table + my_const.points() + + + + digital_cma_equalizer_cc + + alias + + + + comment + Channel equalizer + + + affinity + + + + _enabled + 1 + + + _coordinate + (656, 1088) + + + _rotation + 0 + + + mu + .01 + + + id + digital_cma_equalizer_cc_0 + + + maxoutbuf + 0 + + + minoutbuf + 0 + + + modulus + 1 + + + num_taps + 11 + + + sps + 1 + + + + digital_constellation_soft_decoder_cf + + alias + + + + comment + Decision + + + constellation + my_const + + + affinity + + + + _enabled + True + + + _coordinate + (648, 1020) + + + _rotation + 180 + + + id + digital_constellation_soft_decoder_cf_0 + + + maxoutbuf + 0 + + + minoutbuf + 0 + + + + digital_correlate_access_code_xx_ts + + access_code + digital.packet_utils.default_access_code + + + alias + + + + comment + Correlates with access code to extract the payload. + + + affinity + + + + _enabled + 1 + + + _coordinate + (800, 844) + + + _rotation + 0 + + + id + digital_correlate_access_code_xx_ts_1_0 + + + type + byte + + + maxoutbuf + 0 + + + minoutbuf + 0 + + + tagname + len_key2 + + + threshold + 2 + + + + digital_costas_loop_cc + + alias + + + + comment + Fine carrier frequency and phase sync + + + affinity + + + + _enabled + True + + + _coordinate + (656, 1208) + + + _rotation + 0 + + + id + digital_costas_loop_cc_0 + + + w + .01 + + + maxoutbuf + 0 + + + minoutbuf + 0 + + + order + 2 + + + use_snr + False + + + + digital_crc32_async_bb + + alias + + + + comment + Error detection + + + affinity + + + + _enabled + 1 + + + _coordinate + (848, 1156) + + + _rotation + 0 + + + id + digital_crc32_async_bb_0 + + + maxoutbuf + 0 + + + minoutbuf + 0 + + + check + True + + + + digital_crc32_async_bb + + alias + + + + comment + Apply +error +correction + + + affinity + + + + _enabled + 1 + + + _coordinate + (108, 440) + + + _rotation + 270 + + + id + digital_crc32_async_bb_1 + + + maxoutbuf + 0 + + + minoutbuf + 0 + + + check + False + + + + digital_diff_decoder_bb + + alias + + + + comment + + + + affinity + + + + _enabled + 1 + + + _coordinate + (700, 856) + + + _rotation + 90 + + + id + digital_diff_decoder_bb_0 + + + maxoutbuf + 0 + + + minoutbuf + 0 + + + modulus + 2 + + + + digital_diff_encoder_bb + + alias + + + + comment + + + + affinity + + + + _enabled + 1 + + + _coordinate + (272, 364) + + + _rotation + 0 + + + id + digital_diff_encoder_bb_0 + + + maxoutbuf + 0 + + + minoutbuf + 0 + + + modulus + 2 + + + + digital_fll_band_edge_cc + + alias + + + + comment + Carrier frequency sync + + + affinity + + + + _enabled + 1 + + + rolloff + EBW + + + _coordinate + (448, 1064) + + + _rotation + 0 + + + id + digital_fll_band_edge_cc_0 + + + w + .02 + + + maxoutbuf + 0 + + + minoutbuf + 0 + + + filter_size + 45 + + + samps_per_sym + sps_RX + + + type + cc + + + + digital_pfb_clock_sync_xxx + + alias + + + + comment + Timing recovery (sync) + + + affinity + + + + _enabled + True + + + filter_size + nfilts + + + _coordinate + (432, 800) + + + _rotation + 0 + + + id + digital_pfb_clock_sync_xxx_0 + + + init_phase + nfilts/2 + + + loop_bw + 6.28/400.0*2 + + + maxoutbuf + 0 + + + max_dev + 1.5 + + + minoutbuf + 0 + + + osps + 1 + + + sps + sps_RX + + + taps + RRC_filter_taps + + + type + ccf + + + + digital_protocol_formatter_bb + + alias + + + + comment + Generate header + + + affinity + + + + _enabled + 1 + + + format + hdr_format + + + _coordinate + (208, 476) + + + _rotation + 0 + + + id + digital_protocol_formatter_bb_0 + + + len_tag_key + len_key + + + maxoutbuf + 0 + + + minoutbuf + 0 + + + + epy_block + + alias + + + + _io_cache + ('Embedded Python Block', 'msg_block', [], [('msg_in', 'message', 1)], [('msg_out', 'message', 1)], 'Convert strings to uint8 vectors', []) + + + _source_code + """ +Embedded Python Blocks: + +Each time this file is saved, GRC will instantiate the first class it finds +to get ports and parameters of your block. The arguments to __init__ will +be the parameters. All of them are required to have default values! +""" + +import numpy as np +import pylab +from gnuradio import gr +import pmt + + +class msg_block(gr.basic_block): # other base classes are basic_block, decim_block, interp_block + """Convert strings to uint8 vectors""" + + def __init__(self): # only default arguments here + """arguments to this function show up as parameters in GRC""" + gr.basic_block.__init__( + self, + name='Embedded Python Block', # will show up in GRC + in_sig=None, + out_sig=None + ) + self.message_port_register_out(pmt.intern('msg_out')) + self.message_port_register_in(pmt.intern('msg_in')) + self.set_msg_handler(pmt.intern('msg_in'), self.handle_msg) + + def handle_msg(self, msg): + + nvec = pmt.to_python(msg) + + self.message_port_pub(pmt.intern('msg_out'), pmt.cons(pmt.make_dict(), pmt.pmt_to_python.numpy_to_uvector(np.array([ord(c) for c in nvec], np.uint8)))) + + + def work(self, input_items, output_items): + pass + + + + comment + Convert strings from previous block +to uint8 vectors + + + _enabled + 1 + + + _coordinate + (56, 344) + + + _rotation + 0 + + + id + epy_block_0 + + + + parameter + + alias + + + + comment + Header format definition + + + _enabled + 1 + + + _coordinate + (584, 120) + + + _rotation + 0 + + + id + hdr_format + + + label + Header Formatter + + + short_id + + + + hide + none + + + type + + + + value + digital.header_format_default(digital.packet_utils.default_access_code, 0) + + + + import + + alias + + + + comment + Custom Embedded +Python Block uses +this library. + + + _enabled + True + + + _coordinate + (472, 116) + + + _rotation + 0 + + + id + import_0 + + + import + import numpy + + + + parameter + + alias + + + + comment + Constellation definition + + + _enabled + 1 + + + _coordinate + (592, 0) + + + _rotation + 0 + + + id + my_const + + + label + Constellation + + + short_id + + + + hide + none + + + type + + + + value + digital.constellation_calcdist((digital.psk_2()[0]), (digital.psk_2()[1]), 2, 1).base() + + + + osmosdr_sink + + alias + + + + ant0 + + + + bb_gain0 + 20 + + + bw0 + 0 + + + corr0 + 0 + + + freq0 + center_freq + + + if_gain0 + 10 + + + gain0 + 30 + + + ant10 + + + + bb_gain10 + 20 + + + bw10 + 0 + + + corr10 + 0 + + + freq10 + 100e6 + + + if_gain10 + 20 + + + gain10 + 10 + + + ant11 + + + + bb_gain11 + 20 + + + bw11 + 0 + + + corr11 + 0 + + + freq11 + 100e6 + + + if_gain11 + 20 + + + gain11 + 10 + + + ant12 + + + + bb_gain12 + 20 + + + bw12 + 0 + + + corr12 + 0 + + + freq12 + 100e6 + + + if_gain12 + 20 + + + gain12 + 10 + + + ant13 + + + + bb_gain13 + 20 + + + bw13 + 0 + + + corr13 + 0 + + + freq13 + 100e6 + + + if_gain13 + 20 + + + gain13 + 10 + + + ant14 + + + + bb_gain14 + 20 + + + bw14 + 0 + + + corr14 + 0 + + + freq14 + 100e6 + + + if_gain14 + 20 + + + gain14 + 10 + + + ant15 + + + + bb_gain15 + 20 + + + bw15 + 0 + + + corr15 + 0 + + + freq15 + 100e6 + + + if_gain15 + 20 + + + gain15 + 10 + + + ant16 + + + + bb_gain16 + 20 + + + bw16 + 0 + + + corr16 + 0 + + + freq16 + 100e6 + + + if_gain16 + 20 + + + gain16 + 10 + + + ant17 + + + + bb_gain17 + 20 + + + bw17 + 0 + + + corr17 + 0 + + + freq17 + 100e6 + + + if_gain17 + 20 + + + gain17 + 10 + + + ant18 + + + + bb_gain18 + 20 + + + bw18 + 0 + + + corr18 + 0 + + + freq18 + 100e6 + + + if_gain18 + 20 + + + gain18 + 10 + + + ant19 + + + + bb_gain19 + 20 + + + bw19 + 0 + + + corr19 + 0 + + + freq19 + 100e6 + + + if_gain19 + 20 + + + gain19 + 10 + + + ant1 + + + + bb_gain1 + 20 + + + bw1 + 0 + + + corr1 + 0 + + + freq1 + 100e6 + + + if_gain1 + 20 + + + gain1 + 10 + + + ant20 + + + + bb_gain20 + 20 + + + bw20 + 0 + + + corr20 + 0 + + + freq20 + 100e6 + + + if_gain20 + 20 + + + gain20 + 10 + + + ant21 + + + + bb_gain21 + 20 + + + bw21 + 0 + + + corr21 + 0 + + + freq21 + 100e6 + + + if_gain21 + 20 + + + gain21 + 10 + + + ant22 + + + + bb_gain22 + 20 + + + bw22 + 0 + + + corr22 + 0 + + + freq22 + 100e6 + + + if_gain22 + 20 + + + gain22 + 10 + + + ant23 + + + + bb_gain23 + 20 + + + bw23 + 0 + + + corr23 + 0 + + + freq23 + 100e6 + + + if_gain23 + 20 + + + gain23 + 10 + + + ant24 + + + + bb_gain24 + 20 + + + bw24 + 0 + + + corr24 + 0 + + + freq24 + 100e6 + + + if_gain24 + 20 + + + gain24 + 10 + + + ant25 + + + + bb_gain25 + 20 + + + bw25 + 0 + + + corr25 + 0 + + + freq25 + 100e6 + + + if_gain25 + 20 + + + gain25 + 10 + + + ant26 + + + + bb_gain26 + 20 + + + bw26 + 0 + + + corr26 + 0 + + + freq26 + 100e6 + + + if_gain26 + 20 + + + gain26 + 10 + + + ant27 + + + + bb_gain27 + 20 + + + bw27 + 0 + + + corr27 + 0 + + + freq27 + 100e6 + + + if_gain27 + 20 + + + gain27 + 10 + + + ant28 + + + + bb_gain28 + 20 + + + bw28 + 0 + + + corr28 + 0 + + + freq28 + 100e6 + + + if_gain28 + 20 + + + gain28 + 10 + + + ant29 + + + + bb_gain29 + 20 + + + bw29 + 0 + + + corr29 + 0 + + + freq29 + 100e6 + + + if_gain29 + 20 + + + gain29 + 10 + + + ant2 + + + + bb_gain2 + 20 + + + bw2 + 0 + + + corr2 + 0 + + + freq2 + 100e6 + + + if_gain2 + 20 + + + gain2 + 10 + + + ant30 + + + + bb_gain30 + 20 + + + bw30 + 0 + + + corr30 + 0 + + + freq30 + 100e6 + + + if_gain30 + 20 + + + gain30 + 10 + + + ant31 + + + + bb_gain31 + 20 + + + bw31 + 0 + + + corr31 + 0 + + + freq31 + 100e6 + + + if_gain31 + 20 + + + gain31 + 10 + + + ant3 + + + + bb_gain3 + 20 + + + bw3 + 0 + + + corr3 + 0 + + + freq3 + 100e6 + + + if_gain3 + 20 + + + gain3 + 10 + + + ant4 + + + + bb_gain4 + 20 + + + bw4 + 0 + + + corr4 + 0 + + + freq4 + 100e6 + + + if_gain4 + 20 + + + gain4 + 10 + + + ant5 + + + + bb_gain5 + 20 + + + bw5 + 0 + + + corr5 + 0 + + + freq5 + 100e6 + + + if_gain5 + 20 + + + gain5 + 10 + + + ant6 + + + + bb_gain6 + 20 + + + bw6 + 0 + + + corr6 + 0 + + + freq6 + 100e6 + + + if_gain6 + 20 + + + gain6 + 10 + + + ant7 + + + + bb_gain7 + 20 + + + bw7 + 0 + + + corr7 + 0 + + + freq7 + 100e6 + + + if_gain7 + 20 + + + gain7 + 10 + + + ant8 + + + + bb_gain8 + 20 + + + bw8 + 0 + + + corr8 + 0 + + + freq8 + 100e6 + + + if_gain8 + 20 + + + gain8 + 10 + + + ant9 + + + + bb_gain9 + 20 + + + bw9 + 0 + + + corr9 + 0 + + + freq9 + 100e6 + + + if_gain9 + 20 + + + gain9 + 10 + + + comment + Send our little packet of information out +into the wild, luminiferous aether + + + affinity + + + + args + + + + _enabled + 1 + + + _coordinate + (1096, 264) + + + _rotation + 0 + + + id + osmosdr_sink_0_0 + + + type + fc32 + + + clock_source0 + + + + time_source0 + + + + clock_source1 + + + + time_source1 + + + + clock_source2 + + + + time_source2 + + + + clock_source3 + + + + time_source3 + + + + clock_source4 + + + + time_source4 + + + + clock_source5 + + + + time_source5 + + + + clock_source6 + + + + time_source6 + + + + clock_source7 + + + + time_source7 + + + + nchan + 1 + + + num_mboards + 1 + + + sample_rate + samp_rate + + + sync + + + + + pfb_arb_resampler_xxx + + alias + + + + comment + Resample. Apply RRC filter + + + affinity + + + + _enabled + 1 + + + _coordinate + (624, 440) + + + _rotation + 0 + + + id + pfb_arb_resampler_xxx_0 + + + maxoutbuf + 0 + + + minoutbuf + 0 + + + nfilts + nfilts + + + rrate + sps_TX + + + samp_delay + 0 + + + atten + 100 + + + taps + RRC_filter_taps + + + type + ccf + + + + pluto_source + + bbdc + True + + + alias + + + + buffer_size + 0x8000 + + + comment + + + + affinity + + + + uri + + + + _enabled + True + + + auto_filter + True + + + filter + + + + _coordinate + (264, 656) + + + _rotation + 0 + + + gain + "manual" + + + id + pluto_source_0 + + + frequency + center_freq-40E3 + + + manual_gain + 60.0 + + + maxoutbuf + 0 + + + minoutbuf + 0 + + + quadrature + True + + + rfdc + True + + + bandwidth + 1000000 + + + samplerate + samp_rate + + + + qtgui_edit_box_msg + + alias + + + + comment + + + + affinity + + + + _enabled + 1 + + + _coordinate + (12, 424) + + + gui_hint + + + + _rotation + 90 + + + id + qtgui_edit_box_msg_0 + + + key + + + + label + + + + maxoutbuf + 0 + + + minoutbuf + 0 + + + is_pair + False + + + is_static + False + + + type + string + + + value + + + + + qtgui_freq_sink_x + + autoscale + False + + + average + 1.0 + + + axislabels + True + + + bw + samp_rate/int(sps_TX/sps_RX) + + + alias + + + + fc + 0 + + + comment + + + + ctrlpanel + False + + + affinity + + + + _enabled + True + + + fftsize + 1024 + + + _coordinate + (48, 848) + + + gui_hint + + + + _rotation + 180 + + + grid + False + + + id + qtgui_freq_sink_x_0 + + + legend + True + + + alpha1 + 1.0 + + + color1 + "blue" + + + label1 + + + + width1 + 1 + + + alpha10 + 1.0 + + + color10 + "dark blue" + + + label10 + + + + width10 + 1 + + + alpha2 + 1.0 + + + color2 + "red" + + + label2 + + + + width2 + 1 + + + alpha3 + 1.0 + + + color3 + "green" + + + label3 + + + + width3 + 1 + + + alpha4 + 1.0 + + + color4 + "black" + + + label4 + + + + width4 + 1 + + + alpha5 + 1.0 + + + color5 + "cyan" + + + label5 + + + + width5 + 1 + + + alpha6 + 1.0 + + + color6 + "magenta" + + + label6 + + + + width6 + 1 + + + alpha7 + 1.0 + + + color7 + "yellow" + + + label7 + + + + width7 + 1 + + + alpha8 + 1.0 + + + color8 + "dark red" + + + label8 + + + + width8 + 1 + + + alpha9 + 1.0 + + + color9 + "dark green" + + + label9 + + + + width9 + 1 + + + maxoutbuf + 0 + + + minoutbuf + 0 + + + name + "" + + + nconnections + 1 + + + showports + True + + + freqhalf + True + + + tr_chan + 0 + + + tr_level + 0.0 + + + tr_mode + qtgui.TRIG_MODE_FREE + + + tr_tag + "" + + + type + complex + + + update_time + 0.10 + + + wintype + firdes.WIN_BLACKMAN_hARRIS + + + label + Relative Gain + + + ymax + 10 + + + ymin + -140 + + + units + dB + + + + qtgui_time_sink_x + + autoscale + False + + + axislabels + True + + + alias + + + + comment + + + + ctrlpanel + False + + + affinity + + + + entags + True + + + _enabled + True + + + _coordinate + (1096, 580) + + + gui_hint + + + + _rotation + 0 + + + grid + False + + + id + qtgui_time_sink_x_0 + + + legend + True + + + alpha1 + 1.0 + + + color1 + "blue" + + + label1 + + + + marker1 + -1 + + + style1 + 1 + + + width1 + 1 + + + alpha10 + 1.0 + + + color10 + "blue" + + + label10 + + + + marker10 + -1 + + + style10 + 1 + + + width10 + 1 + + + alpha2 + 1.0 + + + color2 + "red" + + + label2 + + + + marker2 + -1 + + + style2 + 1 + + + width2 + 1 + + + alpha3 + 1.0 + + + color3 + "green" + + + label3 + + + + marker3 + -1 + + + style3 + 1 + + + width3 + 1 + + + alpha4 + 1.0 + + + color4 + "black" + + + label4 + + + + marker4 + -1 + + + style4 + 1 + + + width4 + 1 + + + alpha5 + 1.0 + + + color5 + "cyan" + + + label5 + + + + marker5 + -1 + + + style5 + 1 + + + width5 + 1 + + + alpha6 + 1.0 + + + color6 + "magenta" + + + label6 + + + + marker6 + -1 + + + style6 + 1 + + + width6 + 1 + + + alpha7 + 1.0 + + + color7 + "yellow" + + + label7 + + + + marker7 + -1 + + + style7 + 1 + + + width7 + 1 + + + alpha8 + 1.0 + + + color8 + "dark red" + + + label8 + + + + marker8 + -1 + + + style8 + 1 + + + width8 + 1 + + + alpha9 + 1.0 + + + color9 + "dark green" + + + label9 + + + + marker9 + -1 + + + style9 + 1 + + + width9 + 1 + + + name + "" + + + nconnections + 1 + + + size + 1024*256 + + + srate + samp_rate + + + stemplot + False + + + tr_chan + 0 + + + tr_delay + 0 + + + tr_level + 0.0 + + + tr_mode + qtgui.TRIG_MODE_FREE + + + tr_slope + qtgui.TRIG_SLOPE_POS + + + tr_tag + "len_key" + + + type + complex + + + update_time + 0.10 + + + ylabel + Amplitude + + + yunit + "" + + + ymax + 1 + + + ymin + -1 + + + + rational_resampler_xxx + + alias + + + + comment + Downsample and LPF + + + affinity + + + + decim + int(sps_TX/sps_RX) + + + _enabled + True + + + fbw + 0 + + + _coordinate + (240, 1016) + + + _rotation + 0 + + + id + rational_resampler_xxx_0 + + + interp + 1 + + + maxoutbuf + 0 + + + minoutbuf + 0 + + + taps + + + + type + ccc + + + + rtlsdr_source + + alias + + + + ant0 + + + + bb_gain0 + 0 + + + bw0 + 0 + + + dc_offset_mode0 + 2 + + + corr0 + 0 + + + freq0 + center_freq-40E3 + + + gain_mode0 + True + + + if_gain0 + 0 + + + iq_balance_mode0 + 2 + + + gain0 + 40 + + + ant10 + + + + bb_gain10 + 20 + + + bw10 + 0 + + + dc_offset_mode10 + 0 + + + corr10 + 0 + + + freq10 + 100e6 + + + gain_mode10 + False + + + if_gain10 + 20 + + + iq_balance_mode10 + 0 + + + gain10 + 10 + + + ant11 + + + + bb_gain11 + 20 + + + bw11 + 0 + + + dc_offset_mode11 + 0 + + + corr11 + 0 + + + freq11 + 100e6 + + + gain_mode11 + False + + + if_gain11 + 20 + + + iq_balance_mode11 + 0 + + + gain11 + 10 + + + ant12 + + + + bb_gain12 + 20 + + + bw12 + 0 + + + dc_offset_mode12 + 0 + + + corr12 + 0 + + + freq12 + 100e6 + + + gain_mode12 + False + + + if_gain12 + 20 + + + iq_balance_mode12 + 0 + + + gain12 + 10 + + + ant13 + + + + bb_gain13 + 20 + + + bw13 + 0 + + + dc_offset_mode13 + 0 + + + corr13 + 0 + + + freq13 + 100e6 + + + gain_mode13 + False + + + if_gain13 + 20 + + + iq_balance_mode13 + 0 + + + gain13 + 10 + + + ant14 + + + + bb_gain14 + 20 + + + bw14 + 0 + + + dc_offset_mode14 + 0 + + + corr14 + 0 + + + freq14 + 100e6 + + + gain_mode14 + False + + + if_gain14 + 20 + + + iq_balance_mode14 + 0 + + + gain14 + 10 + + + ant15 + + + + bb_gain15 + 20 + + + bw15 + 0 + + + dc_offset_mode15 + 0 + + + corr15 + 0 + + + freq15 + 100e6 + + + gain_mode15 + False + + + if_gain15 + 20 + + + iq_balance_mode15 + 0 + + + gain15 + 10 + + + ant16 + + + + bb_gain16 + 20 + + + bw16 + 0 + + + dc_offset_mode16 + 0 + + + corr16 + 0 + + + freq16 + 100e6 + + + gain_mode16 + False + + + if_gain16 + 20 + + + iq_balance_mode16 + 0 + + + gain16 + 10 + + + ant17 + + + + bb_gain17 + 20 + + + bw17 + 0 + + + dc_offset_mode17 + 0 + + + corr17 + 0 + + + freq17 + 100e6 + + + gain_mode17 + False + + + if_gain17 + 20 + + + iq_balance_mode17 + 0 + + + gain17 + 10 + + + ant18 + + + + bb_gain18 + 20 + + + bw18 + 0 + + + dc_offset_mode18 + 0 + + + corr18 + 0 + + + freq18 + 100e6 + + + gain_mode18 + False + + + if_gain18 + 20 + + + iq_balance_mode18 + 0 + + + gain18 + 10 + + + ant19 + + + + bb_gain19 + 20 + + + bw19 + 0 + + + dc_offset_mode19 + 0 + + + corr19 + 0 + + + freq19 + 100e6 + + + gain_mode19 + False + + + if_gain19 + 20 + + + iq_balance_mode19 + 0 + + + gain19 + 10 + + + ant1 + + + + bb_gain1 + 20 + + + bw1 + 0 + + + dc_offset_mode1 + 0 + + + corr1 + 0 + + + freq1 + 100e6 + + + gain_mode1 + False + + + if_gain1 + 20 + + + iq_balance_mode1 + 0 + + + gain1 + 1 + + + ant20 + + + + bb_gain20 + 20 + + + bw20 + 0 + + + dc_offset_mode20 + 0 + + + corr20 + 0 + + + freq20 + 100e6 + + + gain_mode20 + False + + + if_gain20 + 20 + + + iq_balance_mode20 + 0 + + + gain20 + 10 + + + ant21 + + + + bb_gain21 + 20 + + + bw21 + 0 + + + dc_offset_mode21 + 0 + + + corr21 + 0 + + + freq21 + 100e6 + + + gain_mode21 + False + + + if_gain21 + 20 + + + iq_balance_mode21 + 0 + + + gain21 + 10 + + + ant22 + + + + bb_gain22 + 20 + + + bw22 + 0 + + + dc_offset_mode22 + 0 + + + corr22 + 0 + + + freq22 + 100e6 + + + gain_mode22 + False + + + if_gain22 + 20 + + + iq_balance_mode22 + 0 + + + gain22 + 10 + + + ant23 + + + + bb_gain23 + 20 + + + bw23 + 0 + + + dc_offset_mode23 + 0 + + + corr23 + 0 + + + freq23 + 100e6 + + + gain_mode23 + False + + + if_gain23 + 20 + + + iq_balance_mode23 + 0 + + + gain23 + 10 + + + ant24 + + + + bb_gain24 + 20 + + + bw24 + 0 + + + dc_offset_mode24 + 0 + + + corr24 + 0 + + + freq24 + 100e6 + + + gain_mode24 + False + + + if_gain24 + 20 + + + iq_balance_mode24 + 0 + + + gain24 + 10 + + + ant25 + + + + bb_gain25 + 20 + + + bw25 + 0 + + + dc_offset_mode25 + 0 + + + corr25 + 0 + + + freq25 + 100e6 + + + gain_mode25 + False + + + if_gain25 + 20 + + + iq_balance_mode25 + 0 + + + gain25 + 10 + + + ant26 + + + + bb_gain26 + 20 + + + bw26 + 0 + + + dc_offset_mode26 + 0 + + + corr26 + 0 + + + freq26 + 100e6 + + + gain_mode26 + False + + + if_gain26 + 20 + + + iq_balance_mode26 + 0 + + + gain26 + 10 + + + ant27 + + + + bb_gain27 + 20 + + + bw27 + 0 + + + dc_offset_mode27 + 0 + + + corr27 + 0 + + + freq27 + 100e6 + + + gain_mode27 + False + + + if_gain27 + 20 + + + iq_balance_mode27 + 0 + + + gain27 + 10 + + + ant28 + + + + bb_gain28 + 20 + + + bw28 + 0 + + + dc_offset_mode28 + 0 + + + corr28 + 0 + + + freq28 + 100e6 + + + gain_mode28 + False + + + if_gain28 + 20 + + + iq_balance_mode28 + 0 + + + gain28 + 10 + + + ant29 + + + + bb_gain29 + 20 + + + bw29 + 0 + + + dc_offset_mode29 + 0 + + + corr29 + 0 + + + freq29 + 100e6 + + + gain_mode29 + False + + + if_gain29 + 20 + + + iq_balance_mode29 + 0 + + + gain29 + 10 + + + ant2 + + + + bb_gain2 + 20 + + + bw2 + 0 + + + dc_offset_mode2 + 0 + + + corr2 + 0 + + + freq2 + 100e6 + + + gain_mode2 + False + + + if_gain2 + 20 + + + iq_balance_mode2 + 0 + + + gain2 + 10 + + + ant30 + + + + bb_gain30 + 20 + + + bw30 + 0 + + + dc_offset_mode30 + 0 + + + corr30 + 0 + + + freq30 + 100e6 + + + gain_mode30 + False + + + if_gain30 + 20 + + + iq_balance_mode30 + 0 + + + gain30 + 10 + + + ant31 + + + + bb_gain31 + 20 + + + bw31 + 0 + + + dc_offset_mode31 + 0 + + + corr31 + 0 + + + freq31 + 100e6 + + + gain_mode31 + False + + + if_gain31 + 20 + + + iq_balance_mode31 + 0 + + + gain31 + 10 + + + ant3 + + + + bb_gain3 + 20 + + + bw3 + 0 + + + dc_offset_mode3 + 0 + + + corr3 + 0 + + + freq3 + 100e6 + + + gain_mode3 + False + + + if_gain3 + 20 + + + iq_balance_mode3 + 0 + + + gain3 + 10 + + + ant4 + + + + bb_gain4 + 20 + + + bw4 + 0 + + + dc_offset_mode4 + 0 + + + corr4 + 0 + + + freq4 + 100e6 + + + gain_mode4 + False + + + if_gain4 + 20 + + + iq_balance_mode4 + 0 + + + gain4 + 10 + + + ant5 + + + + bb_gain5 + 20 + + + bw5 + 0 + + + dc_offset_mode5 + 0 + + + corr5 + 0 + + + freq5 + 100e6 + + + gain_mode5 + False + + + if_gain5 + 20 + + + iq_balance_mode5 + 0 + + + gain5 + 10 + + + ant6 + + + + bb_gain6 + 20 + + + bw6 + 0 + + + dc_offset_mode6 + 0 + + + corr6 + 0 + + + freq6 + 100e6 + + + gain_mode6 + False + + + if_gain6 + 20 + + + iq_balance_mode6 + 0 + + + gain6 + 10 + + + ant7 + + + + bb_gain7 + 20 + + + bw7 + 0 + + + dc_offset_mode7 + 0 + + + corr7 + 0 + + + freq7 + 100e6 + + + gain_mode7 + False + + + if_gain7 + 20 + + + iq_balance_mode7 + 0 + + + gain7 + 10 + + + ant8 + + + + bb_gain8 + 20 + + + bw8 + 0 + + + dc_offset_mode8 + 0 + + + corr8 + 0 + + + freq8 + 100e6 + + + gain_mode8 + False + + + if_gain8 + 20 + + + iq_balance_mode8 + 0 + + + gain8 + 10 + + + ant9 + + + + bb_gain9 + 20 + + + bw9 + 0 + + + dc_offset_mode9 + 0 + + + corr9 + 0 + + + freq9 + 100e6 + + + gain_mode9 + False + + + if_gain9 + 20 + + + iq_balance_mode9 + 0 + + + gain9 + 10 + + + comment + Electromagnetic dream catcher + + + affinity + + + + args + + + + _enabled + 0 + + + _coordinate + (16, 668) + + + _rotation + 0 + + + id + rtlsdr_source_1 + + + maxoutbuf + 0 + + + clock_source0 + + + + time_source0 + + + + clock_source1 + + + + time_source1 + + + + clock_source2 + + + + time_source2 + + + + clock_source3 + + + + time_source3 + + + + clock_source4 + + + + time_source4 + + + + clock_source5 + + + + time_source5 + + + + clock_source6 + + + + time_source6 + + + + clock_source7 + + + + time_source7 + + + + minoutbuf + 0 + + + nchan + 1 + + + num_mboards + 1 + + + type + fc32 + + + sample_rate + samp_rate + + + sync + + + + + analog_feedforward_agc_cc_0 + digital_pfb_clock_sync_xxx_0 + 0 + 0 + + + analog_pwr_squelch_xx_0 + digital_fll_band_edge_cc_0 + 0 + 0 + + + analog_pwr_squelch_xx_0 + qtgui_freq_sink_x_0 + 0 + 0 + + + analog_sig_source_x_0 + blocks_multiply_xx_0 + 0 + 1 + + + analog_sig_source_x_1 + blocks_multiply_xx_1 + 0 + 1 + + + blocks_multiply_const_vxx_0 + blocks_multiply_xx_0 + 0 + 0 + + + blocks_multiply_const_vxx_0 + qtgui_time_sink_x_0 + 0 + 0 + + + blocks_multiply_xx_0 + osmosdr_sink_0_0 + 0 + 0 + + + blocks_multiply_xx_1 + rational_resampler_xxx_0 + 0 + 0 + + + blocks_pdu_to_tagged_stream_1 + blocks_tagged_stream_mux_0 + 0 + 1 + + + blocks_pdu_to_tagged_stream_1 + digital_protocol_formatter_bb_0 + 0 + 0 + + + blocks_repack_bits_bb_0_0 + digital_diff_encoder_bb_0 + 0 + 0 + + + blocks_repack_bits_bb_0_0_0 + blocks_tagged_stream_to_pdu_0 + 0 + 0 + + + blocks_tagged_stream_multiply_length_0 + blocks_multiply_const_vxx_0 + 0 + 0 + + + blocks_tagged_stream_mux_0 + blocks_repack_bits_bb_0_0 + 0 + 0 + + + blocks_tagged_stream_to_pdu_0 + digital_crc32_async_bb_0 + pdus + in + + + digital_binary_slicer_fb_0 + digital_diff_decoder_bb_0 + 0 + 0 + + + digital_burst_shaper_xx_0 + pfb_arb_resampler_xxx_0 + 0 + 0 + + + digital_chunks_to_symbols_xx_0_0 + digital_burst_shaper_xx_0 + 0 + 0 + + + digital_cma_equalizer_cc_0 + digital_constellation_soft_decoder_cf_0 + 0 + 0 + + + digital_constellation_soft_decoder_cf_0 + digital_binary_slicer_fb_0 + 0 + 0 + + + digital_correlate_access_code_xx_ts_1_0 + blocks_repack_bits_bb_0_0_0 + 0 + 0 + + + digital_costas_loop_cc_0 + digital_cma_equalizer_cc_0 + 0 + 0 + + + digital_crc32_async_bb_0 + blocks_message_debug_0 + out + print + + + digital_crc32_async_bb_1 + blocks_pdu_to_tagged_stream_1 + out + pdus + + + digital_diff_decoder_bb_0 + digital_correlate_access_code_xx_ts_1_0 + 0 + 0 + + + digital_diff_encoder_bb_0 + digital_chunks_to_symbols_xx_0_0 + 0 + 0 + + + digital_fll_band_edge_cc_0 + analog_feedforward_agc_cc_0 + 0 + 0 + + + digital_pfb_clock_sync_xxx_0 + digital_costas_loop_cc_0 + 0 + 0 + + + digital_protocol_formatter_bb_0 + blocks_tagged_stream_mux_0 + 0 + 0 + + + epy_block_0 + digital_crc32_async_bb_1 + msg_out + in + + + pfb_arb_resampler_xxx_0 + blocks_tagged_stream_multiply_length_0 + 0 + 0 + + + pluto_source_0 + blocks_multiply_xx_1 + 0 + 0 + + + qtgui_edit_box_msg_0 + epy_block_0 + msg + msg_in + + + rational_resampler_xxx_0 + analog_pwr_squelch_xx_0 + 0 + 0 + + diff --git a/examples/epy_block_0.py b/examples/epy_block_0.py new file mode 100644 index 0000000..6e9ae11 --- /dev/null +++ b/examples/epy_block_0.py @@ -0,0 +1,38 @@ +""" +Embedded Python Blocks: + +Each time this file is saved, GRC will instantiate the first class it finds +to get ports and parameters of your block. The arguments to __init__ will +be the parameters. All of them are required to have default values! +""" + +import numpy as np +import pylab +from gnuradio import gr +import pmt + + +class msg_block(gr.basic_block): # other base classes are basic_block, decim_block, interp_block + """Convert strings to uint8 vectors""" + + def __init__(self): # only default arguments here + """arguments to this function show up as parameters in GRC""" + gr.basic_block.__init__( + self, + name='Embedded Python Block', # will show up in GRC + in_sig=None, + out_sig=None + ) + self.message_port_register_out(pmt.intern('msg_out')) + self.message_port_register_in(pmt.intern('msg_in')) + self.set_msg_handler(pmt.intern('msg_in'), self.handle_msg) + + def handle_msg(self, msg): + + nvec = pmt.to_python(msg) + + self.message_port_pub(pmt.intern('msg_out'), pmt.cons(pmt.make_dict(), pmt.pmt_to_python.numpy_to_uvector(np.array([ord(c) for c in nvec], np.uint8)))) + + + def work(self, input_items, output_items): + pass diff --git a/examples/fmmod.dat b/examples/fmmod.dat new file mode 100644 index 0000000..a1b19dd Binary files /dev/null and b/examples/fmmod.dat differ diff --git a/examples/gaussian_filter.dat b/examples/gaussian_filter.dat new file mode 100644 index 0000000..c8f7610 Binary files /dev/null and b/examples/gaussian_filter.dat differ diff --git a/examples/microsoft_mouse_sniffer.py b/examples/microsoft_mouse_sniffer.py old mode 100755 new mode 100644 diff --git a/examples/nordic_auto_ack.py b/examples/nordic_auto_ack.py old mode 100755 new mode 100644 diff --git a/examples/nordic_channelized_receiver.py b/examples/nordic_channelized_receiver.py old mode 100755 new mode 100644 index af9179d..fdc15dc --- a/examples/nordic_channelized_receiver.py +++ b/examples/nordic_channelized_receiver.py @@ -2,6 +2,7 @@ from gnuradio import gr, blocks, digital, filter from gnuradio.filter import firdes +from gnuradio import iio import thread import nordic import pmt @@ -34,11 +35,13 @@ def __init__(self, args): dr = 2 # 2M # SDR source (gr-osmosdr source) - self.osmosdr_source = osmosdr.source() - self.osmosdr_source.set_sample_rate(self.sample_rate * channel_count) - self.osmosdr_source.set_center_freq(self.freq) - self.osmosdr_source.set_gain(self.gain) - self.osmosdr_source.set_antenna('TX/RX') + #self.osmosdr_source = osmosdr.source() + #self.osmosdr_source.set_sample_rate(self.sample_rate * channel_count) + #self.osmosdr_source.set_center_freq(self.freq) + #self.osmosdr_source.set_gain(self.gain) + #self.osmosdr_source.set_antenna('TX/RX') + self.pluto_source = iio.pluto_source('', int(self.freq), int(int(self.sample_rate * channel_count)), int(2e6), 0x8000, True, True, True, "manual", 64.0, '', True) + #self.pluto_sink = iio.pluto_sink('192.168.2.1', int(self.freq), int(int(self.sample_rate * channel_count)), int(2e6), 0x8000, False, 10.0, '', True) # PFB channelizer taps = firdes.low_pass_2( @@ -48,7 +51,7 @@ def __init__(self, args): # Stream to streams (PFB channelizer input) self.s2ss = blocks.stream_to_streams( gr.sizeof_gr_complex, channel_count) - self.connect(self.osmosdr_source, self.s2ss) + self.connect(self.pluto_source, self.s2ss) # Demodulators and packet deframers self.nordictap_printer = nordictap_printer() diff --git a/examples/nordic_channelized_transmitter.py b/examples/nordic_channelized_transmitter.py old mode 100755 new mode 100644 index bdf5462..319efff --- a/examples/nordic_channelized_transmitter.py +++ b/examples/nordic_channelized_transmitter.py @@ -11,6 +11,7 @@ import array import random import osmosdr +from gnuradio import iio import argparse from bitstring import BitArray from gnuradio import uhd @@ -40,6 +41,7 @@ def __init__(self, args): self.osmosdr_sink.set_center_freq(self.freq) self.osmosdr_sink.set_gain(self.gain) self.osmosdr_sink.set_antenna('TX/RX') + #self.pluto_sink = iio.pluto_sink('192.168.2.1', int(self.freq), int(int(self.sample_rate * channel_count)), int(2e6), 0x8000, False, 10.0, '', True) # PFB channelizer taps = firdes.low_pass_2( @@ -47,52 +49,27 @@ def __init__(self, args): self.synthesizer = filter.pfb_synthesizer_ccf(channel_count, taps) # Modulators and packet framers - self.nordictap_transmitter = nordictap_transmitter(channel_map) + self.nordictap_transmitter = nordic.nordictap_transmitter(channel_map) self.mods = [] self.tx = nordic.nordic_tx(channel_count) for x in range(channel_count): - self.mods.append(digital.gfsk_mod()) + self.mods.append(digital.gfsk_mod( + samples_per_symbol=2, + sensitivity=1.0, + bt=0.35, + verbose=True, + log=True,)) self.connect((self.tx, x), self.mods[x]) self.connect(self.mods[x], (self.synthesizer, x)) self.connect(self.synthesizer, self.osmosdr_sink) - # Wire up output packet connection + self.blocks_message_debug = blocks.message_debug() + + # Wire up output packet connection self.msg_connect(self.nordictap_transmitter, "nordictap_out", self.tx, "nordictap_in") - - -# Nordic transmitter strobe -class nordictap_transmitter(gr.sync_block): - - # Constructor - - def __init__(self, channel_map): - gr.sync_block.__init__( - self, name="Nordictap Printer/Transmitter", in_sig=None, out_sig=None) - - self.channel_map = channel_map - - # Packet output port - self.message_port_register_out(pmt.intern("nordictap_out")) - - # Transmit a packet - def transmit(self, address, payload, channel_index, sequence_number): - - channel = self.channel_map[channel_index] - - # Build a payload - nordictap = [channel_index] + [ - channel, 2, len(address), len(payload), sequence_number, 0, 2] - for c in address: - nordictap.append(ord(c)) - for c in payload: - nordictap.append(ord(c)) - - # Transmit packet - vec = pmt.make_u8vector(len(nordictap), 0) - for x in range(len(nordictap)): - pmt.u8vector_set(vec, x, nordictap[x]) - self.message_port_pub(pmt.intern("nordictap_out"), vec) + self.msg_connect(self.nordictap_transmitter, + "nordictap_out", self.blocks_message_debug, "print") def main(): @@ -109,8 +86,8 @@ def main(): tb.start() # Transmit some packets, hopping between three channels - address = '\x11\x22\x11\x22\x11' - payload = '\x55\x44\x33\x22\x11' + address = '\x55\x55\x55\x55\x55' + payload = '\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA' sequence_number = 0 while True: for x in range(3): @@ -119,7 +96,7 @@ def main(): sequence_number += 1 if sequence_number > 3: sequence_number = 0 - time.sleep(0.1) + time.sleep(0.2) try: raw_input('Press Enter to quit: ') diff --git a/examples/nordic_receiver.py b/examples/nordic_receiver.py old mode 100755 new mode 100644 index e362e78..d411b14 --- a/examples/nordic_receiver.py +++ b/examples/nordic_receiver.py @@ -2,6 +2,7 @@ from gnuradio import gr, blocks, digital, filter from gnuradio.filter import firdes +from gnuradio import iio import thread import nordic import pmt @@ -13,7 +14,7 @@ import argparse from bitstring import BitArray from gnuradio import uhd -from Queue import Queue +#from Queue import Queue class top_block(gr.top_block): @@ -28,11 +29,12 @@ def __init__(self, args): self.sample_rate = args.data_rate * args.samples_per_symbol # SDR source (gr-osmosdr source)_tx_queue.push(msg); - self.osmosdr_source = osmosdr.source() - self.osmosdr_source.set_sample_rate(self.sample_rate) - self.osmosdr_source.set_center_freq(self.freq) - self.osmosdr_source.set_gain(self.gain) - self.osmosdr_source.set_antenna('TX/RX') + #self.osmosdr_source = osmosdr.source() + #self.osmosdr_source.set_sample_rate(self.sample_rate) + #self.osmosdr_source.set_center_freq(self.freq) + #self.osmosdr_source.set_gain(self.gain) + #self.osmosdr_source.set_antenna('TX/RX') + self.pluto_source = iio.pluto_source('', int(self.freq), int(self.sample_rate), int(2e6), 0x8000, True, True, True, "manual", 60.0, '', True) # Receive chain dr = 0 @@ -45,8 +47,8 @@ def __init__(self, args): self.gfsk_demod = digital.gfsk_demod( samples_per_symbol=args.samples_per_symbol) self.lpf = filter.fir_filter_ccf( - 1, firdes.low_pass_2(1, self.sample_rate, self.symbol_rate / 2, 50e3, 50)) - self.connect(self.osmosdr_source, self.lpf) + 1, firdes.low_pass_2(1, self.sample_rate, self.symbol_rate / 2, 100e3, 50)) + self.connect(self.pluto_source, self.lpf) self.connect(self.lpf, self.gfsk_demod) self.connect(self.gfsk_demod, self.rx) @@ -56,7 +58,7 @@ def __init__(self, args): self.rx, "nordictap_out", self.nordictap_printer, "nordictap_in") -# Nordic Printer +# Nordic Printeror class nordictap_printer(gr.sync_block): # Constructor diff --git a/examples/nordic_sniffer_scanner.py b/examples/nordic_sniffer_scanner.py old mode 100755 new mode 100644 index 897e57b..345a0fd --- a/examples/nordic_sniffer_scanner.py +++ b/examples/nordic_sniffer_scanner.py @@ -17,7 +17,7 @@ def __init__(self): # SDR configuration self.freq = 2402e6 - self.gain = 70 + self.gain = 60 self.symbol_rate = 2e6 self.sample_rate = 4e6 @@ -30,7 +30,7 @@ def __init__(self): # Low pass filter self.lpf = filter.fir_filter_ccf( - 1, firdes.low_pass_2(1, self.sample_rate, self.symbol_rate / 2, 50e3, 50)) + 1, firdes.low_pass_2(1, self.sample_rate, self.symbol_rate / 2, 100e3, 50)) # GFSK demod, defaults to 2 samples per symbol self.gfsk_demod = digital.gfsk_demod() @@ -76,7 +76,7 @@ def __init__(self, tb): thread.start_new_thread(self.tick, ()) # Channels and channel groups - self.channels = range(2, 84) + self.channels = range(2, 102) # 10ms tick def tick(self): diff --git a/examples/nordic_transmitter.py b/examples/nordic_transmitter.py new file mode 100644 index 0000000..c6de5ac --- /dev/null +++ b/examples/nordic_transmitter.py @@ -0,0 +1,148 @@ +#!/usr/bin/env python2 +from PyQt4 import QtGui +from gnuradio import gr, blocks, digital, filter +from gnuradio.filter import firdes +import thread +import nordic +import pmt +import struct +import time +import numpy +import array +import random +import osmosdr +import sip, sys +from gnuradio import iio, qtgui +import argparse +from bitstring import BitArray +from gnuradio import uhd +from Queue import Queue + + +class top_block(gr.top_block): + + def __init__(self, args): + gr.top_block.__init__(self, "Nordic Single-Channel Receiver Example") + + self.qapp = QtGui.QApplication(sys.argv) + + # SDR configuration + self.freq = 2400e6 + args.channel * 1e6 + self.gain = args.gain + self.symbol_rate = args.data_rate + self.sample_rate = args.data_rate * args.samples_per_symbol + + + dr = 0 + if args.data_rate == 1e6: + dr = 1 + elif args.data_rate == 2e6: + dr = 2 + + # SDR sink (gr-osmosdr sink) + #self.osmosdr_sink_0 = osmosdr.sink( args="numchan=" + str(1) + " " + '' ) + #self.osmosdr_sink_0.set_sample_rate(self.sample_rate * channel_count) + #self.osmosdr_sink_0.set_center_freq(self.freq, 0) + #self.osmosdr_sink_0.set_freq_corr(0, 0) + #self.osmosdr_sink_0.set_gain(self.gain, 0) + #self.osmosdr_sink_0.set_if_gain(20, 0) + #self.osmosdr_sink_0.set_bb_gain(20, 0) + #self.osmosdr_sink_0.set_antenna('TX/RX', 0) + #self.osmosdr_sink_0.set_bandwidth(0, 0) + #self.pluto_sink = iio.pluto_sink('192.168.2.1', int(self.freq), int(int(self.sample_rate)), int(2e6), 0x8000, False, 10.0, '', True) + self.osmosdr_sink = osmosdr.sink() + self.osmosdr_sink.set_sample_rate(self.sample_rate) + self.osmosdr_sink.set_center_freq(self.freq) + self.osmosdr_sink.set_gain(self.gain) + self.osmosdr_sink.set_antenna('TX/RX') + + self.snk = qtgui.sink_c( + 1024, #fftsize + firdes.WIN_BLACKMAN_hARRIS, #wintype + 0, #fc + self.sample_rate, #bw + "", #name + True, #plotfreq + False, #plotwaterfall + True, #plottime + False, #plotconst + ) + + # Low Pass filter + self.lpf = filter.fir_filter_ccf( + 1, firdes.low_pass_2(1, self.sample_rate, self.symbol_rate / 2, 100e3, 50)) + + # Modulators and packet framers + self.nordictap_transmitter = nordic.nordictap_transmitter([args.channel]) + self.gfsk_mod = digital.gfsk_mod( + samples_per_symbol=2, + sensitivity=0.78, + bt=0.5, + verbose=True, + log=True, + ) + self.tx = nordic.nordic_tx(1) + + #self.connect(self.nordictap_transmitter, self.tx) + self.connect(self.tx, self.gfsk_mod) + self.connect(self.gfsk_mod, self.lpf) + self.connect(self.lpf, self.osmosdr_sink) + #self.connect(self.lpf, self.snk) + + # Tell the sink we want it displayed + self.pyobj = sip.wrapinstance(self.snk.pyqwidget(), QtGui.QWidget) + self.pyobj.show() + + #self.blocks_message_debug = blocks.message_debug() + + # Wire up output packet connection + self.msg_connect(self.nordictap_transmitter, + "nordictap_out", self.tx, "nordictap_in") + #self.msg_connect(self.nordictap_transmitter, + # "nordictap_out", self.blocks_message_debug, "print") + + +def main(): + + # Parse command line arguments + parser = argparse.ArgumentParser('Nordic Single Channel Transmitter Example', + formatter_class=lambda prog: argparse.HelpFormatter(prog, max_help_position=50, width=120)) + + parser.add_argument( + '-c', '--channel', type=int, help='RF channel (0-125)', default=85) + parser.add_argument('-r', '--data_rate', type=float, + help='Data Rate (250e3, 1e6 or 2e6', default=2e6, choices=[250e3, 1e6, 2e6]) + parser.add_argument('-l', '--crc_length', type=int, + help='CRC Length (1-2)', default=2, choices=[1, 2]) + parser.add_argument('-a', '--address_length', type=int, + help='Address Length (3-5)', default=5, choices=[3, 4, 5]) + parser.add_argument('-s', '--samples_per_symbol', + type=int, help='Samples Per Symbol', default=2) + + parser.add_argument( + '-g', '--gain', type=float, help='Radio Gain', default=30) + + args = parser.parse_args() + + tb = top_block(args) + tb.start() + #tb.qapp.exec_() + # Transmit some packets, hopping between three channels + address = '\x55\x55\x55\x55\x55' + payload = '\x20\x20\x20\x20\x32\x30\x2E\x32' + sequence_number = 0 + while True: + tb.nordictap_transmitter.transmit( + address, payload, 0, sequence_number) + time.sleep(0.5) + + try: + raw_input('Press Enter to quit: ') + except EOFError: + pass + tb.stop() + tb.wait() + + +if __name__ == '__main__': + main() diff --git a/examples/nordictap_test.grc b/examples/nordictap_test.grc new file mode 100644 index 0000000..5e1f91e --- /dev/null +++ b/examples/nordictap_test.grc @@ -0,0 +1,215 @@ + + + + Mon May 27 21:35:02 2019 + + options + + author + + + + window_size + + + + category + [GRC Hier Blocks] + + + comment + + + + description + + + + _enabled + True + + + _coordinate + (8, 8) + + + _rotation + 0 + + + generate_options + qt_gui + + + hier_block_src_path + .: + + + id + nordictap_test + + + max_nouts + 0 + + + qt_qss_theme + + + + realtime_scheduling + + + + run_command + {python} -u {filename} + + + run_options + prompt + + + run + True + + + sizing_mode + fixed + + + thread_safe_setters + + + + title + + + + placement + (0,0) + + + + variable + + comment + + + + _enabled + True + + + _coordinate + (8, 160) + + + _rotation + 0 + + + id + samp_rate + + + value + 32000 + + + + blocks_message_debug + + alias + + + + comment + + + + affinity + + + + _enabled + True + + + _coordinate + (648, 152) + + + _rotation + 0 + + + id + blocks_message_debug_0 + + + + nordic_nordictap_transmitter + + address + \x55\x55\x55\x55\x55 + + + alias + + + + channel_count + 1 + + + channel_index + 0 + + + comment + + + + affinity + + + + _enabled + True + + + _coordinate + (280, 184) + + + _rotation + 0 + + + id + nordic_nordictap_transmitter_0 + + + maxoutbuf + 0 + + + minoutbuf + 0 + + + payload + \x55\x55\x55\x55\x55 + + + sequence_number + 0 + + + + nordic_nordictap_transmitter_0 + blocks_message_debug_0 + nordictap_out + print_pdu + + diff --git a/examples/nordictap_test.py b/examples/nordictap_test.py new file mode 100644 index 0000000..7932bcf --- /dev/null +++ b/examples/nordictap_test.py @@ -0,0 +1,108 @@ +#!/usr/bin/env python2 +# -*- coding: utf-8 -*- +################################################## +# GNU Radio Python Flow Graph +# Title: Nordictap Test +# Generated: Mon May 27 22:08:53 2019 +################################################## + +if __name__ == '__main__': + import ctypes + import sys + if sys.platform.startswith('linux'): + try: + x11 = ctypes.cdll.LoadLibrary('libX11.so') + x11.XInitThreads() + except: + print "Warning: failed to XInitThreads()" + +from PyQt4 import Qt +from gnuradio import blocks +from gnuradio import eng_notation +from gnuradio import gr +from gnuradio.eng_option import eng_option +from gnuradio.filter import firdes +from optparse import OptionParser +import nordic +import sys +from gnuradio import qtgui + + +class nordictap_test(gr.top_block, Qt.QWidget): + + def __init__(self): + gr.top_block.__init__(self, "Nordictap Test") + Qt.QWidget.__init__(self) + self.setWindowTitle("Nordictap Test") + qtgui.util.check_set_qss() + 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", "nordictap_test") + self.restoreGeometry(self.settings.value("geometry").toByteArray()) + + + ################################################## + # Variables + ################################################## + self.samp_rate = samp_rate = 32000 + + ################################################## + # Blocks + ################################################## + self.nordic_nordictap_transmitter_0 = nordic.nordictap_transmitter(1) + self.blocks_message_debug_0 = blocks.message_debug() + + + + ################################################## + # Connections + ################################################## + self.msg_connect((self.nordic_nordictap_transmitter_0, 'nordictap_out'), (self.blocks_message_debug_0, 'print_pdu')) + + def closeEvent(self, event): + self.settings = Qt.QSettings("GNU Radio", "nordictap_test") + self.settings.setValue("geometry", self.saveGeometry()) + event.accept() + + def get_samp_rate(self): + return self.samp_rate + + def set_samp_rate(self, samp_rate): + self.samp_rate = samp_rate + + +def main(top_block_cls=nordictap_test, options=None): + + from distutils.version import StrictVersion + if StrictVersion(Qt.qVersion()) >= StrictVersion("4.5.0"): + style = gr.prefs().get_string('qtgui', 'style', 'raster') + Qt.QApplication.setGraphicsSystem(style) + qapp = Qt.QApplication(sys.argv) + + tb = top_block_cls() + tb.start() + tb.show() + + def quitting(): + tb.stop() + tb.wait() + qapp.connect(qapp, Qt.SIGNAL("aboutToQuit()"), quitting) + qapp.exec_() + + +if __name__ == '__main__': + main() diff --git a/examples/nrf24_receiver.grc b/examples/nrf24_receiver.grc new file mode 100644 index 0000000..7bcc00e --- /dev/null +++ b/examples/nrf24_receiver.grc @@ -0,0 +1,3276 @@ + + + + Thu May 30 09:04:23 2019 + + options + + author + + + + window_size + + + + category + [GRC Hier Blocks] + + + comment + + + + description + + + + _enabled + True + + + _coordinate + (8, 8) + + + _rotation + 0 + + + generate_options + qt_gui + + + hier_block_src_path + .: + + + id + nrf24_receiver + + + max_nouts + 0 + + + qt_qss_theme + + + + realtime_scheduling + + + + run_command + {python} -u {filename} + + + run_options + prompt + + + run + True + + + sizing_mode + fixed + + + thread_safe_setters + + + + title + + + + placement + (0,0) + + + + variable + + comment + + + + _enabled + True + + + _coordinate + (8, 160) + + + _rotation + 0 + + + id + samp_rate + + + value + 4e6 + + + + analog_pwr_squelch_xx + + alpha + 5e-4 + + + alias + + + + comment + + + + affinity + + + + _enabled + 1 + + + _coordinate + (240, 360) + + + _rotation + 0 + + + gate + False + + + id + analog_pwr_squelch_xx_0 + + + maxoutbuf + 0 + + + minoutbuf + 0 + + + ramp + 0 + + + threshold + -35 + + + type + complex + + + + analog_quadrature_demod_cf + + alias + + + + comment + + + + affinity + + + + _enabled + 1 + + + _coordinate + (448, 524) + + + _rotation + 0 + + + gain + 1/((3.1415/2)/2) + + + id + analog_quadrature_demod_cf_0 + + + maxoutbuf + 0 + + + minoutbuf + 0 + + + + analog_quadrature_demod_cf + + alias + + + + comment + + + + affinity + + + + _enabled + 0 + + + _coordinate + (296, 604) + + + _rotation + 0 + + + gain + samp_rate/(2*math.pi*320e3/8.0) + + + id + analog_quadrature_demod_cf_1 + + + maxoutbuf + 0 + + + minoutbuf + 0 + + + + analog_sig_source_x + + amp + 1 + + + alias + + + + comment + + + + affinity + + + + _enabled + 0 + + + freq + 40 + + + _coordinate + (392, 904) + + + _rotation + 0 + + + id + analog_sig_source_x_0 + + + maxoutbuf + 0 + + + minoutbuf + 0 + + + offset + 0 + + + type + short + + + samp_rate + samp_rate + + + waveform + analog.GR_COS_WAVE + + + + blocks_burst_tagger + + alias + + + + comment + + + + affinity + + + + _enabled + 0 + + + false_key + burst + + + false_value + False + + + _coordinate + (656, 896) + + + _rotation + 0 + + + id + blocks_burst_tagger_0 + + + maxoutbuf + 0 + + + minoutbuf + 0 + + + type + byte + + + true_key + + + + true_value + True + + + + blocks_char_to_float + + alias + + + + comment + + + + affinity + + + + _enabled + 0 + + + _coordinate + (896, 212) + + + _rotation + 0 + + + id + blocks_char_to_float_0 + + + maxoutbuf + 0 + + + minoutbuf + 0 + + + scale + 1 + + + vlen + 1 + + + + blocks_char_to_float + + alias + + + + comment + + + + affinity + + + + _enabled + 0 + + + _coordinate + (944, 636) + + + _rotation + 0 + + + id + blocks_char_to_float_0_0 + + + maxoutbuf + 0 + + + minoutbuf + 0 + + + scale + 1 + + + vlen + 1 + + + + blocks_char_to_float + + alias + + + + comment + + + + affinity + + + + _enabled + 0 + + + _coordinate + (824, 916) + + + _rotation + 0 + + + id + blocks_char_to_float_0_1 + + + maxoutbuf + 0 + + + minoutbuf + 0 + + + scale + 1 + + + vlen + 1 + + + + blocks_char_to_float + + alias + + + + comment + + + + affinity + + + + _enabled + 1 + + + _coordinate + (664, 716) + + + _rotation + 0 + + + id + blocks_char_to_float_0_2 + + + maxoutbuf + 0 + + + minoutbuf + 0 + + + scale + 1 + + + vlen + 1 + + + + blocks_file_sink + + append + False + + + alias + + + + comment + + + + affinity + + + + _enabled + 0 + + + file + /home/herve/nrf24_rcv_gr.dat + + + _coordinate + (1104, 452) + + + _rotation + 0 + + + id + blocks_file_sink_0 + + + type + float + + + unbuffered + False + + + vlen + 1 + + + + blocks_file_sink + + append + False + + + alias + + + + comment + + + + affinity + + + + _enabled + 0 + + + file + /home/herve/nrf24_rcv_gr_bits.dat + + + _coordinate + (1104, 532) + + + _rotation + 0 + + + id + blocks_file_sink_0_0 + + + type + byte + + + unbuffered + False + + + vlen + 1 + + + + blocks_message_debug + + alias + + + + comment + Display recovered +message + + + affinity + + + + _enabled + 0 + + + _coordinate + (1112, 728) + + + _rotation + 0 + + + id + blocks_message_debug_0 + + + + blocks_repack_bits_bb + + k + 1 + + + l + 8 + + + alias + + + + comment + Tagged Stream to PDU block up ahead needs +packed bytes + + + affinity + + + + _enabled + 0 + + + endianness + gr.GR_MSB_FIRST + + + _coordinate + (640, 780) + + + _rotation + 0 + + + id + blocks_repack_bits_bb_0_0_0 + + + len_tag_key + len_key + + + maxoutbuf + 0 + + + minoutbuf + 0 + + + align_output + False + + + + blocks_tagged_stream_to_pdu + + alias + + + + comment + + + + affinity + + + + _enabled + 0 + + + _coordinate + (872, 788) + + + _rotation + 0 + + + id + blocks_tagged_stream_to_pdu_0 + + + type + byte + + + tag + len_key + + + maxoutbuf + 0 + + + minoutbuf + 0 + + + + digital_binary_slicer_fb + + alias + + + + comment + + + + affinity + + + + _enabled + True + + + _coordinate + (904, 528) + + + _rotation + 0 + + + id + digital_binary_slicer_fb_0 + + + maxoutbuf + 0 + + + minoutbuf + 0 + + + + digital_clock_recovery_mm_xx + + alias + + + + comment + + + + affinity + + + + _enabled + True + + + _coordinate + (672, 496) + + + _rotation + 0 + + + gain_mu + 0.175 + + + gain_omega + 0.25*0.175*0.175 + + + id + digital_clock_recovery_mm_xx_0 + + + maxoutbuf + 0 + + + minoutbuf + 0 + + + mu + 0.5 + + + omega_relative_limit + 0.005 + + + omega + 2*(1+0.0) + + + type + float + + + + digital_correlate_access_code_xx_ts + + access_code + 01010101 + + + alias + + + + comment + Correlates with access code to extract the payload. + + + affinity + + + + _enabled + 1 + + + _coordinate + (264, 772) + + + _rotation + 0 + + + id + digital_correlate_access_code_xx_ts_1_0 + + + type + byte + + + maxoutbuf + 0 + + + minoutbuf + 0 + + + tagname + burst + + + threshold + 0 + + + + digital_gfsk_demod + + alias + + + + comment + + + + affinity + + + + _enabled + 0 + + + freq_error + 0 + + + _coordinate + (672, 344) + + + _rotation + 0 + + + gain_mu + 0.175 + + + id + digital_gfsk_demod_0 + + + log + False + + + maxoutbuf + 0 + + + minoutbuf + 0 + + + mu + 0.5 + + + omega_relative_limit + 0.005 + + + samples_per_symbol + 2 + + + sensitivity + ((3.1415/2)/2) + + + verbose + False + + + + low_pass_filter + + beta + 6.76 + + + alias + + + + comment + + + + affinity + + + + cutoff_freq + 1e6 + + + decim + 1 + + + _enabled + True + + + type + fir_filter_ccf + + + _coordinate + (440, 336) + + + _rotation + 0 + + + gain + 1 + + + id + low_pass_filter_0 + + + interp + 1 + + + maxoutbuf + 0 + + + minoutbuf + 0 + + + samp_rate + samp_rate + + + width + 250e3 + + + win + firdes.WIN_HAMMING + + + + nordic_nordic_rx + + address_length + 5 + + + alias + + + + crc_length + 2 + + + comment + + + + affinity + + + + data_rate + 2 + + + _enabled + 1 + + + _coordinate + (944, 360) + + + _rotation + 0 + + + id + nordic_nordic_rx_0 + + + maxoutbuf + 0 + + + minoutbuf + 0 + + + channel + 85 + + + + nordic_nordictap_printer + + alias + + + + comment + + + + affinity + + + + _enabled + 1 + + + _coordinate + (1120, 384) + + + _rotation + 0 + + + id + nordic_nordictap_printer_0 + + + + pluto_source + + bbdc + False + + + alias + + + + buffer_size + 0x8000*32 + + + comment + + + + affinity + + + + uri + + + + _enabled + True + + + auto_filter + True + + + filter + + + + _coordinate + (40, 304) + + + _rotation + 0 + + + gain + "fast_attack" + + + id + pluto_source_0 + + + frequency + 2485e6 + + + manual_gain + 60.0 + + + maxoutbuf + 0 + + + minoutbuf + 0 + + + quadrature + True + + + rfdc + False + + + bandwidth + 1500000 + + + samplerate + samp_rate + + + + qtgui_time_sink_x + + autoscale + False + + + axislabels + True + + + alias + + + + comment + + + + ctrlpanel + False + + + affinity + + + + entags + True + + + _enabled + 0 + + + _coordinate + (1056, 196) + + + gui_hint + + + + _rotation + 0 + + + grid + False + + + id + qtgui_time_sink_x_0 + + + legend + True + + + alpha1 + 1.0 + + + color1 + "blue" + + + label1 + + + + marker1 + -1 + + + style1 + 1 + + + width1 + 1 + + + alpha10 + 1.0 + + + color10 + "blue" + + + label10 + + + + marker10 + -1 + + + style10 + 1 + + + width10 + 1 + + + alpha2 + 1.0 + + + color2 + "red" + + + label2 + + + + marker2 + -1 + + + style2 + 1 + + + width2 + 1 + + + alpha3 + 1.0 + + + color3 + "green" + + + label3 + + + + marker3 + -1 + + + style3 + 1 + + + width3 + 1 + + + alpha4 + 1.0 + + + color4 + "black" + + + label4 + + + + marker4 + -1 + + + style4 + 1 + + + width4 + 1 + + + alpha5 + 1.0 + + + color5 + "cyan" + + + label5 + + + + marker5 + -1 + + + style5 + 1 + + + width5 + 1 + + + alpha6 + 1.0 + + + color6 + "magenta" + + + label6 + + + + marker6 + -1 + + + style6 + 1 + + + width6 + 1 + + + alpha7 + 1.0 + + + color7 + "yellow" + + + label7 + + + + marker7 + -1 + + + style7 + 1 + + + width7 + 1 + + + alpha8 + 1.0 + + + color8 + "dark red" + + + label8 + + + + marker8 + -1 + + + style8 + 1 + + + width8 + 1 + + + alpha9 + 1.0 + + + color9 + "dark green" + + + label9 + + + + marker9 + -1 + + + style9 + 1 + + + width9 + 1 + + + name + "" + + + nconnections + 1 + + + size + 1024*256*4 + + + srate + samp_rate + + + stemplot + False + + + tr_chan + 0 + + + tr_delay + 0 + + + tr_level + 0.0 + + + tr_mode + qtgui.TRIG_MODE_TAG + + + tr_slope + qtgui.TRIG_SLOPE_POS + + + tr_tag + "squelch_eob" + + + type + float + + + update_time + 0.10 + + + ylabel + Amplitude + + + yunit + "" + + + ymax + 1 + + + ymin + -1 + + + + qtgui_time_sink_x + + autoscale + True + + + axislabels + True + + + alias + + + + comment + + + + ctrlpanel + False + + + affinity + + + + entags + True + + + _enabled + 0 + + + _coordinate + (1104, 620) + + + gui_hint + + + + _rotation + 0 + + + grid + False + + + id + qtgui_time_sink_x_0_0 + + + legend + True + + + alpha1 + 1.0 + + + color1 + "blue" + + + label1 + + + + marker1 + -1 + + + style1 + 1 + + + width1 + 1 + + + alpha10 + 1.0 + + + color10 + "blue" + + + label10 + + + + marker10 + -1 + + + style10 + 1 + + + width10 + 1 + + + alpha2 + 1.0 + + + color2 + "red" + + + label2 + + + + marker2 + -1 + + + style2 + 1 + + + width2 + 1 + + + alpha3 + 1.0 + + + color3 + "green" + + + label3 + + + + marker3 + -1 + + + style3 + 1 + + + width3 + 1 + + + alpha4 + 1.0 + + + color4 + "black" + + + label4 + + + + marker4 + -1 + + + style4 + 1 + + + width4 + 1 + + + alpha5 + 1.0 + + + color5 + "cyan" + + + label5 + + + + marker5 + -1 + + + style5 + 1 + + + width5 + 1 + + + alpha6 + 1.0 + + + color6 + "magenta" + + + label6 + + + + marker6 + -1 + + + style6 + 1 + + + width6 + 1 + + + alpha7 + 1.0 + + + color7 + "yellow" + + + label7 + + + + marker7 + -1 + + + style7 + 1 + + + width7 + 1 + + + alpha8 + 1.0 + + + color8 + "dark red" + + + label8 + + + + marker8 + -1 + + + style8 + 1 + + + width8 + 1 + + + alpha9 + 1.0 + + + color9 + "dark green" + + + label9 + + + + marker9 + -1 + + + style9 + 1 + + + width9 + 1 + + + name + "" + + + nconnections + 1 + + + size + 1024*256*4 + + + srate + samp_rate/2 + + + stemplot + False + + + tr_chan + 0 + + + tr_delay + 0 + + + tr_level + 0.5 + + + tr_mode + qtgui.TRIG_MODE_TAG + + + tr_slope + qtgui.TRIG_SLOPE_NEG + + + tr_tag + "squelch_sob" + + + type + float + + + update_time + 0.10 + + + ylabel + Amplitude + + + yunit + "" + + + ymax + 1 + + + ymin + -1 + + + + qtgui_time_sink_x + + autoscale + False + + + axislabels + True + + + alias + + + + comment + + + + ctrlpanel + False + + + affinity + + + + entags + True + + + _enabled + 0 + + + _coordinate + (984, 900) + + + gui_hint + + + + _rotation + 0 + + + grid + False + + + id + qtgui_time_sink_x_0_1 + + + legend + True + + + alpha1 + 1.0 + + + color1 + "blue" + + + label1 + + + + marker1 + -1 + + + style1 + 1 + + + width1 + 1 + + + alpha10 + 1.0 + + + color10 + "blue" + + + label10 + + + + marker10 + -1 + + + style10 + 1 + + + width10 + 1 + + + alpha2 + 1.0 + + + color2 + "red" + + + label2 + + + + marker2 + -1 + + + style2 + 1 + + + width2 + 1 + + + alpha3 + 1.0 + + + color3 + "green" + + + label3 + + + + marker3 + -1 + + + style3 + 1 + + + width3 + 1 + + + alpha4 + 1.0 + + + color4 + "black" + + + label4 + + + + marker4 + -1 + + + style4 + 1 + + + width4 + 1 + + + alpha5 + 1.0 + + + color5 + "cyan" + + + label5 + + + + marker5 + -1 + + + style5 + 1 + + + width5 + 1 + + + alpha6 + 1.0 + + + color6 + "magenta" + + + label6 + + + + marker6 + -1 + + + style6 + 1 + + + width6 + 1 + + + alpha7 + 1.0 + + + color7 + "yellow" + + + label7 + + + + marker7 + -1 + + + style7 + 1 + + + width7 + 1 + + + alpha8 + 1.0 + + + color8 + "dark red" + + + label8 + + + + marker8 + -1 + + + style8 + 1 + + + width8 + 1 + + + alpha9 + 1.0 + + + color9 + "dark green" + + + label9 + + + + marker9 + -1 + + + style9 + 1 + + + width9 + 1 + + + name + "" + + + nconnections + 1 + + + size + 1024 + + + srate + samp_rate/4 + + + stemplot + False + + + tr_chan + 0 + + + tr_delay + 0 + + + tr_level + 0.0 + + + tr_mode + qtgui.TRIG_MODE_TAG + + + tr_slope + qtgui.TRIG_SLOPE_POS + + + tr_tag + "burst" + + + type + float + + + update_time + 0.10 + + + ylabel + Amplitude + + + yunit + "" + + + ymax + 1 + + + ymin + -1 + + + + qtgui_time_sink_x + + autoscale + True + + + axislabels + True + + + alias + + + + comment + + + + ctrlpanel + False + + + affinity + + + + entags + True + + + _enabled + 1 + + + _coordinate + (824, 700) + + + gui_hint + + + + _rotation + 0 + + + grid + False + + + id + qtgui_time_sink_x_0_2 + + + legend + True + + + alpha1 + 1.0 + + + color1 + "blue" + + + label1 + + + + marker1 + -1 + + + style1 + 1 + + + width1 + 1 + + + alpha10 + 1.0 + + + color10 + "blue" + + + label10 + + + + marker10 + -1 + + + style10 + 1 + + + width10 + 1 + + + alpha2 + 1.0 + + + color2 + "red" + + + label2 + + + + marker2 + -1 + + + style2 + 1 + + + width2 + 1 + + + alpha3 + 1.0 + + + color3 + "green" + + + label3 + + + + marker3 + -1 + + + style3 + 1 + + + width3 + 1 + + + alpha4 + 1.0 + + + color4 + "black" + + + label4 + + + + marker4 + -1 + + + style4 + 1 + + + width4 + 1 + + + alpha5 + 1.0 + + + color5 + "cyan" + + + label5 + + + + marker5 + -1 + + + style5 + 1 + + + width5 + 1 + + + alpha6 + 1.0 + + + color6 + "magenta" + + + label6 + + + + marker6 + -1 + + + style6 + 1 + + + width6 + 1 + + + alpha7 + 1.0 + + + color7 + "yellow" + + + label7 + + + + marker7 + -1 + + + style7 + 1 + + + width7 + 1 + + + alpha8 + 1.0 + + + color8 + "dark red" + + + label8 + + + + marker8 + -1 + + + style8 + 1 + + + width8 + 1 + + + alpha9 + 1.0 + + + color9 + "dark green" + + + label9 + + + + marker9 + -1 + + + style9 + 1 + + + width9 + 1 + + + name + "" + + + nconnections + 1 + + + size + 1024 + + + srate + samp_rate/2 + + + stemplot + False + + + tr_chan + 0 + + + tr_delay + 0 + + + tr_level + 0.0 + + + tr_mode + qtgui.TRIG_MODE_TAG + + + tr_slope + qtgui.TRIG_SLOPE_POS + + + tr_tag + "burst" + + + type + float + + + update_time + 0.10 + + + ylabel + Amplitude + + + yunit + "" + + + ymax + 1 + + + ymin + -1 + + + + qtgui_time_sink_x + + autoscale + False + + + axislabels + True + + + alias + + + + comment + + + + ctrlpanel + False + + + affinity + + + + entags + True + + + _enabled + 1 + + + _coordinate + (672, 236) + + + gui_hint + + + + _rotation + 0 + + + grid + False + + + id + qtgui_time_sink_x_1 + + + legend + True + + + alpha1 + 1.0 + + + color1 + "blue" + + + label1 + + + + marker1 + -1 + + + style1 + 1 + + + width1 + 1 + + + alpha10 + 1.0 + + + color10 + "blue" + + + label10 + + + + marker10 + -1 + + + style10 + 1 + + + width10 + 1 + + + alpha2 + 1.0 + + + color2 + "red" + + + label2 + + + + marker2 + -1 + + + style2 + 1 + + + width2 + 1 + + + alpha3 + 1.0 + + + color3 + "green" + + + label3 + + + + marker3 + -1 + + + style3 + 1 + + + width3 + 1 + + + alpha4 + 1.0 + + + color4 + "black" + + + label4 + + + + marker4 + -1 + + + style4 + 1 + + + width4 + 1 + + + alpha5 + 1.0 + + + color5 + "cyan" + + + label5 + + + + marker5 + -1 + + + style5 + 1 + + + width5 + 1 + + + alpha6 + 1.0 + + + color6 + "magenta" + + + label6 + + + + marker6 + -1 + + + style6 + 1 + + + width6 + 1 + + + alpha7 + 1.0 + + + color7 + "yellow" + + + label7 + + + + marker7 + -1 + + + style7 + 1 + + + width7 + 1 + + + alpha8 + 1.0 + + + color8 + "dark red" + + + label8 + + + + marker8 + -1 + + + style8 + 1 + + + width8 + 1 + + + alpha9 + 1.0 + + + color9 + "dark green" + + + label9 + + + + marker9 + -1 + + + style9 + 1 + + + width9 + 1 + + + name + "" + + + nconnections + 1 + + + size + 1024 + + + srate + samp_rate + + + stemplot + False + + + tr_chan + 0 + + + tr_delay + 0 + + + tr_level + 0.0 + + + tr_mode + qtgui.TRIG_MODE_TAG + + + tr_slope + qtgui.TRIG_SLOPE_POS + + + tr_tag + "squelch_sob" + + + type + complex + + + update_time + 0.10 + + + ylabel + Amplitude + + + yunit + "" + + + ymax + 1 + + + ymin + -1 + + + + analog_pwr_squelch_xx_0 + low_pass_filter_0 + 0 + 0 + + + analog_pwr_squelch_xx_0 + qtgui_time_sink_x_1 + 0 + 0 + + + analog_quadrature_demod_cf_0 + digital_clock_recovery_mm_xx_0 + 0 + 0 + + + analog_sig_source_x_0 + blocks_burst_tagger_0 + 0 + 1 + + + blocks_burst_tagger_0 + blocks_char_to_float_0_1 + 0 + 0 + + + blocks_char_to_float_0 + qtgui_time_sink_x_0 + 0 + 0 + + + blocks_char_to_float_0_0 + qtgui_time_sink_x_0_0 + 0 + 0 + + + blocks_char_to_float_0_1 + qtgui_time_sink_x_0_1 + 0 + 0 + + + blocks_char_to_float_0_2 + qtgui_time_sink_x_0_2 + 0 + 0 + + + blocks_repack_bits_bb_0_0_0 + blocks_tagged_stream_to_pdu_0 + 0 + 0 + + + blocks_tagged_stream_to_pdu_0 + blocks_message_debug_0 + pdus + print_pdu + + + digital_binary_slicer_fb_0 + blocks_char_to_float_0 + 0 + 0 + + + digital_binary_slicer_fb_0 + blocks_char_to_float_0_0 + 0 + 0 + + + digital_binary_slicer_fb_0 + digital_correlate_access_code_xx_ts_1_0 + 0 + 0 + + + digital_binary_slicer_fb_0 + nordic_nordic_rx_0 + 0 + 0 + + + digital_clock_recovery_mm_xx_0 + digital_binary_slicer_fb_0 + 0 + 0 + + + digital_correlate_access_code_xx_ts_1_0 + blocks_burst_tagger_0 + 0 + 0 + + + digital_correlate_access_code_xx_ts_1_0 + blocks_char_to_float_0_2 + 0 + 0 + + + digital_correlate_access_code_xx_ts_1_0 + blocks_repack_bits_bb_0_0_0 + 0 + 0 + + + digital_gfsk_demod_0 + nordic_nordic_rx_0 + 0 + 0 + + + low_pass_filter_0 + analog_quadrature_demod_cf_0 + 0 + 0 + + + low_pass_filter_0 + analog_quadrature_demod_cf_1 + 0 + 0 + + + low_pass_filter_0 + digital_gfsk_demod_0 + 0 + 0 + + + nordic_nordic_rx_0 + nordic_nordictap_printer_0 + nordictap_out + nordictap_in + + + pluto_source_0 + analog_pwr_squelch_xx_0 + 0 + 0 + + diff --git a/examples/nrf24_receiver.py b/examples/nrf24_receiver.py new file mode 100644 index 0000000..6c22b2c --- /dev/null +++ b/examples/nrf24_receiver.py @@ -0,0 +1,238 @@ +#!/usr/bin/env python2 +# -*- coding: utf-8 -*- +################################################## +# GNU Radio Python Flow Graph +# Title: Nrf24 Receiver +# Generated: Tue Jun 11 20:04:42 2019 +################################################## + +if __name__ == '__main__': + import ctypes + import sys + if sys.platform.startswith('linux'): + try: + x11 = ctypes.cdll.LoadLibrary('libX11.so') + x11.XInitThreads() + except: + print "Warning: failed to XInitThreads()" + +from PyQt4 import Qt +from gnuradio import analog +from gnuradio import blocks +from gnuradio import digital +from gnuradio import eng_notation +from gnuradio import filter +from gnuradio import gr +from gnuradio import iio +from gnuradio import qtgui +from gnuradio.eng_option import eng_option +from gnuradio.filter import firdes +from optparse import OptionParser +import math +import nordic +import sip +import sys +from gnuradio import qtgui + + +class nrf24_receiver(gr.top_block, Qt.QWidget): + + def __init__(self): + gr.top_block.__init__(self, "Nrf24 Receiver") + Qt.QWidget.__init__(self) + self.setWindowTitle("Nrf24 Receiver") + qtgui.util.check_set_qss() + 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", "nrf24_receiver") + self.restoreGeometry(self.settings.value("geometry").toByteArray()) + + + ################################################## + # Variables + ################################################## + self.samp_rate = samp_rate = 4e6 + + ################################################## + # Blocks + ################################################## + self.qtgui_time_sink_x_1 = qtgui.time_sink_c( + 1024, #size + samp_rate, #samp_rate + "", #name + 1 #number of inputs + ) + self.qtgui_time_sink_x_1.set_update_time(0.10) + self.qtgui_time_sink_x_1.set_y_axis(-1, 1) + + self.qtgui_time_sink_x_1.set_y_label('Amplitude', "") + + self.qtgui_time_sink_x_1.enable_tags(-1, True) + self.qtgui_time_sink_x_1.set_trigger_mode(qtgui.TRIG_MODE_TAG, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "squelch_sob") + self.qtgui_time_sink_x_1.enable_autoscale(False) + self.qtgui_time_sink_x_1.enable_grid(False) + self.qtgui_time_sink_x_1.enable_axis_labels(True) + self.qtgui_time_sink_x_1.enable_control_panel(False) + self.qtgui_time_sink_x_1.enable_stem_plot(False) + + if not True: + self.qtgui_time_sink_x_1.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(2): + if len(labels[i]) == 0: + if(i % 2 == 0): + self.qtgui_time_sink_x_1.set_line_label(i, "Re{{Data {0}}}".format(i/2)) + else: + self.qtgui_time_sink_x_1.set_line_label(i, "Im{{Data {0}}}".format(i/2)) + else: + self.qtgui_time_sink_x_1.set_line_label(i, labels[i]) + self.qtgui_time_sink_x_1.set_line_width(i, widths[i]) + self.qtgui_time_sink_x_1.set_line_color(i, colors[i]) + self.qtgui_time_sink_x_1.set_line_style(i, styles[i]) + self.qtgui_time_sink_x_1.set_line_marker(i, markers[i]) + self.qtgui_time_sink_x_1.set_line_alpha(i, alphas[i]) + + self._qtgui_time_sink_x_1_win = sip.wrapinstance(self.qtgui_time_sink_x_1.pyqwidget(), Qt.QWidget) + self.top_grid_layout.addWidget(self._qtgui_time_sink_x_1_win) + self.qtgui_time_sink_x_0_2 = qtgui.time_sink_f( + 1024, #size + samp_rate/2, #samp_rate + "", #name + 1 #number of inputs + ) + self.qtgui_time_sink_x_0_2.set_update_time(0.10) + self.qtgui_time_sink_x_0_2.set_y_axis(-1, 1) + + self.qtgui_time_sink_x_0_2.set_y_label('Amplitude', "") + + self.qtgui_time_sink_x_0_2.enable_tags(-1, True) + self.qtgui_time_sink_x_0_2.set_trigger_mode(qtgui.TRIG_MODE_TAG, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "burst") + self.qtgui_time_sink_x_0_2.enable_autoscale(True) + self.qtgui_time_sink_x_0_2.enable_grid(False) + self.qtgui_time_sink_x_0_2.enable_axis_labels(True) + self.qtgui_time_sink_x_0_2.enable_control_panel(False) + self.qtgui_time_sink_x_0_2.enable_stem_plot(False) + + if not True: + self.qtgui_time_sink_x_0_2.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_2.set_line_label(i, "Data {0}".format(i)) + else: + self.qtgui_time_sink_x_0_2.set_line_label(i, labels[i]) + self.qtgui_time_sink_x_0_2.set_line_width(i, widths[i]) + self.qtgui_time_sink_x_0_2.set_line_color(i, colors[i]) + self.qtgui_time_sink_x_0_2.set_line_style(i, styles[i]) + self.qtgui_time_sink_x_0_2.set_line_marker(i, markers[i]) + self.qtgui_time_sink_x_0_2.set_line_alpha(i, alphas[i]) + + self._qtgui_time_sink_x_0_2_win = sip.wrapinstance(self.qtgui_time_sink_x_0_2.pyqwidget(), Qt.QWidget) + self.top_grid_layout.addWidget(self._qtgui_time_sink_x_0_2_win) + self.pluto_source_0 = iio.pluto_source('', int(2485e6), int(samp_rate), int(1500000), 0x8000*32, True, False, False, "fast_attack", 60.0, '', True) + self.nordic_nordictap_printer_0 = nordic.nordictap_printer() + self.nordic_nordic_rx_0 = nordic.nordic_rx(85, 5, 2, 2) + self.low_pass_filter_0 = filter.fir_filter_ccf(1, firdes.low_pass( + 1, samp_rate, 1e6, 250e3, firdes.WIN_HAMMING, 6.76)) + self.digital_correlate_access_code_xx_ts_1_0 = digital.correlate_access_code_bb_ts('01010101', + 0, 'burst') + self.digital_clock_recovery_mm_xx_0 = digital.clock_recovery_mm_ff(2*(1+0.0), 0.25*0.175*0.175, 0.5, 0.175, 0.005) + self.digital_binary_slicer_fb_0 = digital.binary_slicer_fb() + self.blocks_char_to_float_0_2 = blocks.char_to_float(1, 1) + self.analog_quadrature_demod_cf_0 = analog.quadrature_demod_cf(1/((3.1415/2)/2)) + self.analog_pwr_squelch_xx_0 = analog.pwr_squelch_cc(-35, 5e-4, 0, False) + + + + ################################################## + # Connections + ################################################## + self.msg_connect((self.nordic_nordic_rx_0, 'nordictap_out'), (self.nordic_nordictap_printer_0, 'nordictap_in')) + self.connect((self.analog_pwr_squelch_xx_0, 0), (self.low_pass_filter_0, 0)) + self.connect((self.analog_pwr_squelch_xx_0, 0), (self.qtgui_time_sink_x_1, 0)) + self.connect((self.analog_quadrature_demod_cf_0, 0), (self.digital_clock_recovery_mm_xx_0, 0)) + self.connect((self.blocks_char_to_float_0_2, 0), (self.qtgui_time_sink_x_0_2, 0)) + self.connect((self.digital_binary_slicer_fb_0, 0), (self.digital_correlate_access_code_xx_ts_1_0, 0)) + self.connect((self.digital_binary_slicer_fb_0, 0), (self.nordic_nordic_rx_0, 0)) + self.connect((self.digital_clock_recovery_mm_xx_0, 0), (self.digital_binary_slicer_fb_0, 0)) + self.connect((self.digital_correlate_access_code_xx_ts_1_0, 0), (self.blocks_char_to_float_0_2, 0)) + self.connect((self.low_pass_filter_0, 0), (self.analog_quadrature_demod_cf_0, 0)) + self.connect((self.pluto_source_0, 0), (self.analog_pwr_squelch_xx_0, 0)) + + def closeEvent(self, event): + self.settings = Qt.QSettings("GNU Radio", "nrf24_receiver") + self.settings.setValue("geometry", self.saveGeometry()) + event.accept() + + def get_samp_rate(self): + return self.samp_rate + + def set_samp_rate(self, samp_rate): + self.samp_rate = samp_rate + self.qtgui_time_sink_x_1.set_samp_rate(self.samp_rate) + self.qtgui_time_sink_x_0_2.set_samp_rate(self.samp_rate/2) + self.pluto_source_0.set_params(int(2485e6), int(self.samp_rate), int(1500000), True, False, False, "fast_attack", 60.0, '', True) + self.low_pass_filter_0.set_taps(firdes.low_pass(1, self.samp_rate, 1e6, 250e3, firdes.WIN_HAMMING, 6.76)) + + +def main(top_block_cls=nrf24_receiver, options=None): + + from distutils.version import StrictVersion + if StrictVersion(Qt.qVersion()) >= StrictVersion("4.5.0"): + style = gr.prefs().get_string('qtgui', 'style', 'raster') + Qt.QApplication.setGraphicsSystem(style) + qapp = Qt.QApplication(sys.argv) + + tb = top_block_cls() + tb.start() + tb.show() + + def quitting(): + tb.stop() + tb.wait() + qapp.connect(qapp, Qt.SIGNAL("aboutToQuit()"), quitting) + qapp.exec_() + + +if __name__ == '__main__': + main() diff --git a/examples/nrf24_tx.grc b/examples/nrf24_tx.grc new file mode 100644 index 0000000..8e3002c --- /dev/null +++ b/examples/nrf24_tx.grc @@ -0,0 +1,419 @@ + + + + Sat Jun 1 10:08:12 2019 + + options + + author + + + + window_size + + + + category + [GRC Hier Blocks] + + + comment + + + + description + + + + _enabled + True + + + _coordinate + (8, 8) + + + _rotation + 0 + + + generate_options + qt_gui + + + hier_block_src_path + .: + + + id + top_block + + + max_nouts + 0 + + + qt_qss_theme + + + + realtime_scheduling + + + + run_command + {python} -u {filename} + + + run_options + prompt + + + run + True + + + sizing_mode + fixed + + + thread_safe_setters + + + + title + + + + placement + (0,0) + + + + variable + + comment + + + + _enabled + True + + + _coordinate + (16, 332) + + + _rotation + 0 + + + id + address + + + value + [0, 85, 2, 5, 8, 0, 0, 2, 85, 85, 85, 85, 85] + + + + variable + + comment + + + + _enabled + True + + + _coordinate + (16, 252) + + + _rotation + 0 + + + id + payload + + + value + " 20.0" + + + + variable + + comment + + + + _enabled + 1 + + + _coordinate + (16, 412) + + + _rotation + 0 + + + id + pkt_vec + + + value + address + [ ord(x) for x in payload ] + + + + variable_function_probe + + block_id + probe_signal + + + comment + + + + _enabled + True + + + function_args + + + + function_name + level + + + _coordinate + (584, 296) + + + _rotation + 0 + + + id + probe_var + + + value + 0 + + + poll_rate + 10 + + + + variable + + comment + + + + _enabled + True + + + _coordinate + (8, 160) + + + _rotation + 0 + + + id + samp_rate + + + value + 32000 + + + + variable_qtgui_entry + + comment + + + + value + probe_var + + + _enabled + True + + + _coordinate + (584, 116) + + + gui_hint + + + + _rotation + 0 + + + id + variable_qtgui_entry_0 + + + label + + + + type + int + + + + blocks_message_strobe + + alias + + + + comment + + + + affinity + + + + _enabled + 1 + + + _coordinate + (208, 196) + + + _rotation + 0 + + + id + blocks_message_strobe_0 + + + maxoutbuf + 0 + + + msg + pmt.init_u8vector( len(pkt_vec), pkt_vec) + + + minoutbuf + 0 + + + period + 500 + + + + nordic_nordic_tx + + alias + + + + comment + + + + affinity + + + + _enabled + True + + + _coordinate + (424, 208) + + + _rotation + 0 + + + id + nordic_nordic_tx_0 + + + maxoutbuf + 0 + + + minoutbuf + 0 + + + channel_count + 1 + + + + blocks_probe_signal_x + + alias + + + + comment + + + + affinity + + + + _enabled + True + + + _coordinate + (592, 208) + + + _rotation + 0 + + + id + probe_signal + + + type + byte + + + + blocks_message_strobe_0 + nordic_nordic_tx_0 + strobe + nordictap_in + + + nordic_nordic_tx_0 + probe_signal + 0 + 0 + + diff --git a/examples/nrf_scan.grc b/examples/nrf_scan.grc new file mode 100644 index 0000000..0da7ad1 --- /dev/null +++ b/examples/nrf_scan.grc @@ -0,0 +1,3008 @@ + + + + Fri May 10 17:04:46 2019 + + options + + author + + + + window_size + + + + category + [GRC Hier Blocks] + + + comment + + + + description + + + + _enabled + True + + + _coordinate + (8, 8) + + + _rotation + 0 + + + generate_options + qt_gui + + + hier_block_src_path + .: + + + id + nrf_scan + + + max_nouts + 0 + + + qt_qss_theme + + + + realtime_scheduling + + + + run_command + {python} -u {filename} + + + run_options + prompt + + + run + True + + + sizing_mode + fixed + + + thread_safe_setters + + + + title + + + + placement + (0,0) + + + + variable + + comment + + + + _enabled + True + + + _coordinate + (120, 164) + + + _rotation + 0 + + + id + fsk_deviation_hz + + + value + 320e3 + + + + variable + + comment + + + + _enabled + True + + + _coordinate + (8, 160) + + + _rotation + 0 + + + id + samp_rate + + + value + 4e6 + + + + analog_pwr_squelch_xx + + alpha + 5e-4 + + + alias + + + + comment + + + + affinity + + + + _enabled + True + + + _coordinate + (296, 216) + + + _rotation + 0 + + + gate + False + + + id + analog_pwr_squelch_xx_0 + + + maxoutbuf + 0 + + + minoutbuf + 0 + + + ramp + 0 + + + threshold + -35 + + + type + complex + + + + analog_quadrature_demod_cf + + alias + + + + comment + + + + affinity + + + + _enabled + 0 + + + _coordinate + (712, 52) + + + _rotation + 0 + + + gain + samp_rate/(2*math.pi*fsk_deviation_hz/8.0) + + + id + analog_quadrature_demod_cf_0 + + + maxoutbuf + 0 + + + minoutbuf + 0 + + + + analog_simple_squelch_cc + + alpha + 0.1 + + + alias + + + + comment + + + + affinity + + + + _enabled + 0 + + + _coordinate + (312, 316) + + + _rotation + 0 + + + id + analog_simple_squelch_cc_0 + + + maxoutbuf + 0 + + + minoutbuf + 0 + + + threshold + -35 + + + + blocks_file_sink + + append + False + + + alias + + + + comment + + + + affinity + + + + _enabled + 0 + + + file + /home/herve/nrf24_2500m_250k_2.bin + + + _coordinate + (1104, 276) + + + _rotation + 0 + + + id + blocks_file_sink_0 + + + type + float + + + unbuffered + False + + + vlen + 1 + + + + blocks_uchar_to_float + + alias + + + + comment + + + + affinity + + + + _enabled + 1 + + + _coordinate + (928, 176) + + + _rotation + 0 + + + id + blocks_uchar_to_float_0 + + + maxoutbuf + 0 + + + minoutbuf + 0 + + + + blocks_uchar_to_float + + alias + + + + comment + + + + affinity + + + + _enabled + 0 + + + _coordinate + (1064, 56) + + + _rotation + 0 + + + id + blocks_uchar_to_float_0_0 + + + maxoutbuf + 0 + + + minoutbuf + 0 + + + + digital_binary_slicer_fb + + alias + + + + comment + + + + affinity + + + + _enabled + 0 + + + _coordinate + (904, 56) + + + _rotation + 0 + + + id + digital_binary_slicer_fb_0 + + + maxoutbuf + 0 + + + minoutbuf + 0 + + + + digital_gfsk_demod + + alias + + + + comment + + + + affinity + + + + _enabled + 1 + + + freq_error + 0.0 + + + _coordinate + (712, 136) + + + _rotation + 0 + + + gain_mu + 0.175 + + + id + digital_gfsk_demod_0 + + + log + False + + + maxoutbuf + 0 + + + minoutbuf + 0 + + + mu + 0.5 + + + omega_relative_limit + 0.005 + + + samples_per_symbol + 2 + + + sensitivity + 1.0 + + + verbose + False + + + + low_pass_filter + + beta + 6.76 + + + alias + + + + comment + + + + affinity + + + + cutoff_freq + fsk_deviation_hz + + + decim + 2 + + + _enabled + True + + + type + fir_filter_ccf + + + _coordinate + (504, 280) + + + _rotation + 0 + + + gain + 1 + + + id + low_pass_filter_0 + + + interp + 1 + + + maxoutbuf + 0 + + + minoutbuf + 0 + + + samp_rate + samp_rate + + + width + 100e3 + + + win + firdes.WIN_HAMMING + + + + pluto_source + + bbdc + True + + + alias + + + + buffer_size + 0x8000*16 + + + comment + + + + affinity + + + + uri + + + + _enabled + True + + + auto_filter + True + + + filter + + + + _coordinate + (360, 480) + + + _rotation + 180 + + + gain + "manual" + + + id + pluto_source_0 + + + frequency + 2485e6 + + + manual_gain + 60.0 + + + maxoutbuf + 0 + + + minoutbuf + 0 + + + quadrature + True + + + rfdc + True + + + bandwidth + 2e6 + + + samplerate + samp_rate + + + + qtgui_freq_sink_x + + autoscale + False + + + average + 1.0 + + + axislabels + True + + + bw + samp_rate/2 + + + alias + + + + fc + 0 + + + comment + + + + ctrlpanel + False + + + affinity + + + + _enabled + True + + + fftsize + 1024*8 + + + _coordinate + (832, 308) + + + gui_hint + + + + _rotation + 0 + + + grid + False + + + id + qtgui_freq_sink_x_0 + + + legend + True + + + alpha1 + 1.0 + + + color1 + "blue" + + + label1 + + + + width1 + 1 + + + alpha10 + 1.0 + + + color10 + "dark blue" + + + label10 + + + + width10 + 1 + + + alpha2 + 1.0 + + + color2 + "red" + + + label2 + + + + width2 + 1 + + + alpha3 + 1.0 + + + color3 + "green" + + + label3 + + + + width3 + 1 + + + alpha4 + 1.0 + + + color4 + "black" + + + label4 + + + + width4 + 1 + + + alpha5 + 1.0 + + + color5 + "cyan" + + + label5 + + + + width5 + 1 + + + alpha6 + 1.0 + + + color6 + "magenta" + + + label6 + + + + width6 + 1 + + + alpha7 + 1.0 + + + color7 + "yellow" + + + label7 + + + + width7 + 1 + + + alpha8 + 1.0 + + + color8 + "dark red" + + + label8 + + + + width8 + 1 + + + alpha9 + 1.0 + + + color9 + "dark green" + + + label9 + + + + width9 + 1 + + + maxoutbuf + 0 + + + minoutbuf + 0 + + + name + "" + + + nconnections + 1 + + + showports + True + + + freqhalf + True + + + tr_chan + 0 + + + tr_level + 0.0 + + + tr_mode + qtgui.TRIG_MODE_FREE + + + tr_tag + "" + + + type + complex + + + update_time + 0.01 + + + wintype + firdes.WIN_BLACKMAN_hARRIS + + + label + Relative Gain + + + ymax + 10 + + + ymin + -140 + + + units + dB + + + + qtgui_time_sink_x + + autoscale + False + + + axislabels + True + + + alias + + + + comment + + + + ctrlpanel + False + + + affinity + + + + entags + True + + + _enabled + True + + + _coordinate + (1096, 156) + + + gui_hint + + + + _rotation + 0 + + + grid + False + + + id + qtgui_time_sink_x_0 + + + legend + True + + + alpha1 + 1.0 + + + color1 + "blue" + + + label1 + + + + marker1 + -1 + + + style1 + 1 + + + width1 + 1 + + + alpha10 + 1.0 + + + color10 + "blue" + + + label10 + + + + marker10 + -1 + + + style10 + 1 + + + width10 + 1 + + + alpha2 + 1.0 + + + color2 + "red" + + + label2 + + + + marker2 + -1 + + + style2 + 1 + + + width2 + 1 + + + alpha3 + 1.0 + + + color3 + "green" + + + label3 + + + + marker3 + -1 + + + style3 + 1 + + + width3 + 1 + + + alpha4 + 1.0 + + + color4 + "black" + + + label4 + + + + marker4 + -1 + + + style4 + 1 + + + width4 + 1 + + + alpha5 + 1.0 + + + color5 + "cyan" + + + label5 + + + + marker5 + -1 + + + style5 + 1 + + + width5 + 1 + + + alpha6 + 1.0 + + + color6 + "magenta" + + + label6 + + + + marker6 + -1 + + + style6 + 1 + + + width6 + 1 + + + alpha7 + 1.0 + + + color7 + "yellow" + + + label7 + + + + marker7 + -1 + + + style7 + 1 + + + width7 + 1 + + + alpha8 + 1.0 + + + color8 + "dark red" + + + label8 + + + + marker8 + -1 + + + style8 + 1 + + + width8 + 1 + + + alpha9 + 1.0 + + + color9 + "dark green" + + + label9 + + + + marker9 + -1 + + + style9 + 1 + + + width9 + 1 + + + name + "" + + + nconnections + 1 + + + size + 1024*256 + + + srate + samp_rate/2 + + + stemplot + False + + + tr_chan + 0 + + + tr_delay + 0 + + + tr_level + 0.0 + + + tr_mode + qtgui.TRIG_MODE_FREE + + + tr_slope + qtgui.TRIG_SLOPE_POS + + + tr_tag + "" + + + type + float + + + update_time + 0.10 + + + ylabel + Amplitude + + + yunit + "" + + + ymax + 2 + + + ymin + 0 + + + + qtgui_waterfall_sink_x + + axislabels + True + + + bw + samp_rate/2 + + + alias + + + + fc + 0 + + + comment + + + + affinity + + + + _enabled + 0 + + + fftsize + 1024*8 + + + _coordinate + (840, 444) + + + gui_hint + + + + _rotation + 0 + + + grid + False + + + id + qtgui_waterfall_sink_x_0 + + + int_max + 10 + + + int_min + -100 + + + legend + True + + + alpha1 + 1.0 + + + color1 + 0 + + + label1 + + + + alpha10 + 1.0 + + + color10 + 0 + + + label10 + + + + alpha2 + 1.0 + + + color2 + 0 + + + label2 + + + + alpha3 + 1.0 + + + color3 + 0 + + + label3 + + + + alpha4 + 1.0 + + + color4 + 0 + + + label4 + + + + alpha5 + 1.0 + + + color5 + 0 + + + label5 + + + + alpha6 + 1.0 + + + color6 + 0 + + + label6 + + + + alpha7 + 1.0 + + + color7 + 0 + + + label7 + + + + alpha8 + 1.0 + + + color8 + 0 + + + label8 + + + + alpha9 + 1.0 + + + color9 + 0 + + + label9 + + + + maxoutbuf + 0 + + + minoutbuf + 0 + + + name + "" + + + nconnections + 1 + + + showports + True + + + freqhalf + True + + + type + complex + + + update_time + 0.10 + + + wintype + firdes.WIN_BLACKMAN_hARRIS + + + + uhd_usrp_source + + alias + + + + ant0 + TX/RX + + + bw0 + 0 + + + center_freq0 + 2500e6 + + + dc_offs_enb0 + "" + + + iq_imbal_enb0 + "" + + + norm_gain0 + False + + + gain0 + 50 + + + lo_export0 + False + + + lo_source0 + internal + + + ant10 + + + + bw10 + 0 + + + center_freq10 + 0 + + + dc_offs_enb10 + "" + + + iq_imbal_enb10 + "" + + + norm_gain10 + False + + + gain10 + 0 + + + lo_export10 + False + + + lo_source10 + internal + + + ant11 + + + + bw11 + 0 + + + center_freq11 + 0 + + + dc_offs_enb11 + "" + + + iq_imbal_enb11 + "" + + + norm_gain11 + False + + + gain11 + 0 + + + lo_export11 + False + + + lo_source11 + internal + + + ant12 + + + + bw12 + 0 + + + center_freq12 + 0 + + + dc_offs_enb12 + "" + + + iq_imbal_enb12 + "" + + + norm_gain12 + False + + + gain12 + 0 + + + lo_export12 + False + + + lo_source12 + internal + + + ant13 + + + + bw13 + 0 + + + center_freq13 + 0 + + + dc_offs_enb13 + "" + + + iq_imbal_enb13 + "" + + + norm_gain13 + False + + + gain13 + 0 + + + lo_export13 + False + + + lo_source13 + internal + + + ant14 + + + + bw14 + 0 + + + center_freq14 + 0 + + + dc_offs_enb14 + "" + + + iq_imbal_enb14 + "" + + + norm_gain14 + False + + + gain14 + 0 + + + lo_export14 + False + + + lo_source14 + internal + + + ant15 + + + + bw15 + 0 + + + center_freq15 + 0 + + + dc_offs_enb15 + "" + + + iq_imbal_enb15 + "" + + + norm_gain15 + False + + + gain15 + 0 + + + lo_export15 + False + + + lo_source15 + internal + + + ant16 + + + + bw16 + 0 + + + center_freq16 + 0 + + + dc_offs_enb16 + "" + + + iq_imbal_enb16 + "" + + + norm_gain16 + False + + + gain16 + 0 + + + lo_export16 + False + + + lo_source16 + internal + + + ant17 + + + + bw17 + 0 + + + center_freq17 + 0 + + + dc_offs_enb17 + "" + + + iq_imbal_enb17 + "" + + + norm_gain17 + False + + + gain17 + 0 + + + lo_export17 + False + + + lo_source17 + internal + + + ant18 + + + + bw18 + 0 + + + center_freq18 + 0 + + + dc_offs_enb18 + "" + + + iq_imbal_enb18 + "" + + + norm_gain18 + False + + + gain18 + 0 + + + lo_export18 + False + + + lo_source18 + internal + + + ant19 + + + + bw19 + 0 + + + center_freq19 + 0 + + + dc_offs_enb19 + "" + + + iq_imbal_enb19 + "" + + + norm_gain19 + False + + + gain19 + 0 + + + lo_export19 + False + + + lo_source19 + internal + + + ant1 + + + + bw1 + 0 + + + center_freq1 + 0 + + + dc_offs_enb1 + "" + + + iq_imbal_enb1 + "" + + + norm_gain1 + False + + + gain1 + 0 + + + lo_export1 + False + + + lo_source1 + internal + + + ant20 + + + + bw20 + 0 + + + center_freq20 + 0 + + + dc_offs_enb20 + "" + + + iq_imbal_enb20 + "" + + + norm_gain20 + False + + + gain20 + 0 + + + lo_export20 + False + + + lo_source20 + internal + + + ant21 + + + + bw21 + 0 + + + center_freq21 + 0 + + + dc_offs_enb21 + "" + + + iq_imbal_enb21 + "" + + + norm_gain21 + False + + + gain21 + 0 + + + lo_export21 + False + + + lo_source21 + internal + + + ant22 + + + + bw22 + 0 + + + center_freq22 + 0 + + + dc_offs_enb22 + "" + + + iq_imbal_enb22 + "" + + + norm_gain22 + False + + + gain22 + 0 + + + lo_export22 + False + + + lo_source22 + internal + + + ant23 + + + + bw23 + 0 + + + center_freq23 + 0 + + + dc_offs_enb23 + "" + + + iq_imbal_enb23 + "" + + + norm_gain23 + False + + + gain23 + 0 + + + lo_export23 + False + + + lo_source23 + internal + + + ant24 + + + + bw24 + 0 + + + center_freq24 + 0 + + + dc_offs_enb24 + "" + + + iq_imbal_enb24 + "" + + + norm_gain24 + False + + + gain24 + 0 + + + lo_export24 + False + + + lo_source24 + internal + + + ant25 + + + + bw25 + 0 + + + center_freq25 + 0 + + + dc_offs_enb25 + "" + + + iq_imbal_enb25 + "" + + + norm_gain25 + False + + + gain25 + 0 + + + lo_export25 + False + + + lo_source25 + internal + + + ant26 + + + + bw26 + 0 + + + center_freq26 + 0 + + + dc_offs_enb26 + "" + + + iq_imbal_enb26 + "" + + + norm_gain26 + False + + + gain26 + 0 + + + lo_export26 + False + + + lo_source26 + internal + + + ant27 + + + + bw27 + 0 + + + center_freq27 + 0 + + + dc_offs_enb27 + "" + + + iq_imbal_enb27 + "" + + + norm_gain27 + False + + + gain27 + 0 + + + lo_export27 + False + + + lo_source27 + internal + + + ant28 + + + + bw28 + 0 + + + center_freq28 + 0 + + + dc_offs_enb28 + "" + + + iq_imbal_enb28 + "" + + + norm_gain28 + False + + + gain28 + 0 + + + lo_export28 + False + + + lo_source28 + internal + + + ant29 + + + + bw29 + 0 + + + center_freq29 + 0 + + + dc_offs_enb29 + "" + + + iq_imbal_enb29 + "" + + + norm_gain29 + False + + + gain29 + 0 + + + lo_export29 + False + + + lo_source29 + internal + + + ant2 + + + + bw2 + 0 + + + center_freq2 + 0 + + + dc_offs_enb2 + "" + + + iq_imbal_enb2 + "" + + + norm_gain2 + False + + + gain2 + 0 + + + lo_export2 + False + + + lo_source2 + internal + + + ant30 + + + + bw30 + 0 + + + center_freq30 + 0 + + + dc_offs_enb30 + "" + + + iq_imbal_enb30 + "" + + + norm_gain30 + False + + + gain30 + 0 + + + lo_export30 + False + + + lo_source30 + internal + + + ant31 + + + + bw31 + 0 + + + center_freq31 + 0 + + + dc_offs_enb31 + "" + + + iq_imbal_enb31 + "" + + + norm_gain31 + False + + + gain31 + 0 + + + lo_export31 + False + + + lo_source31 + internal + + + ant3 + + + + bw3 + 0 + + + center_freq3 + 0 + + + dc_offs_enb3 + "" + + + iq_imbal_enb3 + "" + + + norm_gain3 + False + + + gain3 + 0 + + + lo_export3 + False + + + lo_source3 + internal + + + ant4 + + + + bw4 + 0 + + + center_freq4 + 0 + + + dc_offs_enb4 + "" + + + iq_imbal_enb4 + "" + + + norm_gain4 + False + + + gain4 + 0 + + + lo_export4 + False + + + lo_source4 + internal + + + ant5 + + + + bw5 + 0 + + + center_freq5 + 0 + + + dc_offs_enb5 + "" + + + iq_imbal_enb5 + "" + + + norm_gain5 + False + + + gain5 + 0 + + + lo_export5 + False + + + lo_source5 + internal + + + ant6 + + + + bw6 + 0 + + + center_freq6 + 0 + + + dc_offs_enb6 + "" + + + iq_imbal_enb6 + "" + + + norm_gain6 + False + + + gain6 + 0 + + + lo_export6 + False + + + lo_source6 + internal + + + ant7 + + + + bw7 + 0 + + + center_freq7 + 0 + + + dc_offs_enb7 + "" + + + iq_imbal_enb7 + "" + + + norm_gain7 + False + + + gain7 + 0 + + + lo_export7 + False + + + lo_source7 + internal + + + ant8 + + + + bw8 + 0 + + + center_freq8 + 0 + + + dc_offs_enb8 + "" + + + iq_imbal_enb8 + "" + + + norm_gain8 + False + + + gain8 + 0 + + + lo_export8 + False + + + lo_source8 + internal + + + ant9 + + + + bw9 + 0 + + + center_freq9 + 0 + + + dc_offs_enb9 + "" + + + iq_imbal_enb9 + "" + + + norm_gain9 + False + + + gain9 + 0 + + + lo_export9 + False + + + lo_source9 + internal + + + clock_rate + 0.0 + + + comment + + + + affinity + + + + dev_addr + "type=b200" + + + dev_args + "" + + + _enabled + 0 + + + _coordinate + (80, 296) + + + _rotation + 0 + + + id + uhd_usrp_source_0 + + + maxoutbuf + 0 + + + clock_source0 + + + + sd_spec0 + + + + time_source0 + + + + clock_source1 + + + + sd_spec1 + + + + time_source1 + + + + clock_source2 + + + + sd_spec2 + + + + time_source2 + + + + clock_source3 + + + + sd_spec3 + + + + time_source3 + + + + clock_source4 + + + + sd_spec4 + + + + time_source4 + + + + clock_source5 + + + + sd_spec5 + + + + time_source5 + + + + clock_source6 + + + + sd_spec6 + + + + time_source6 + + + + clock_source7 + + + + sd_spec7 + + + + time_source7 + + + + minoutbuf + 0 + + + nchan + 1 + + + num_mboards + 1 + + + type + fc32 + + + samp_rate + samp_rate + + + hide_cmd_port + False + + + hide_lo_controls + True + + + stream_args + + + + stream_chans + [] + + + sync + + + + otw + + + + + analog_pwr_squelch_xx_0 + low_pass_filter_0 + 0 + 0 + + + analog_quadrature_demod_cf_0 + digital_binary_slicer_fb_0 + 0 + 0 + + + analog_simple_squelch_cc_0 + low_pass_filter_0 + 0 + 0 + + + blocks_uchar_to_float_0 + blocks_file_sink_0 + 0 + 0 + + + blocks_uchar_to_float_0 + qtgui_time_sink_x_0 + 0 + 0 + + + blocks_uchar_to_float_0_0 + qtgui_time_sink_x_0 + 0 + 0 + + + digital_binary_slicer_fb_0 + blocks_uchar_to_float_0_0 + 0 + 0 + + + digital_gfsk_demod_0 + blocks_uchar_to_float_0 + 0 + 0 + + + low_pass_filter_0 + analog_quadrature_demod_cf_0 + 0 + 0 + + + low_pass_filter_0 + digital_gfsk_demod_0 + 0 + 0 + + + low_pass_filter_0 + qtgui_freq_sink_x_0 + 0 + 0 + + + low_pass_filter_0 + qtgui_waterfall_sink_x_0 + 0 + 0 + + + pluto_source_0 + analog_pwr_squelch_xx_0 + 0 + 0 + + + uhd_usrp_source_0 + analog_simple_squelch_cc_0 + 0 + 0 + + diff --git a/examples/nrf_scan.py b/examples/nrf_scan.py new file mode 100644 index 0000000..7b10846 --- /dev/null +++ b/examples/nrf_scan.py @@ -0,0 +1,234 @@ +#!/usr/bin/env python2 +# -*- coding: utf-8 -*- +################################################## +# GNU Radio Python Flow Graph +# Title: Nrf Scan +# Generated: Thu May 30 21:27:51 2019 +################################################## + +if __name__ == '__main__': + import ctypes + import sys + if sys.platform.startswith('linux'): + try: + x11 = ctypes.cdll.LoadLibrary('libX11.so') + x11.XInitThreads() + except: + print "Warning: failed to XInitThreads()" + +from PyQt4 import Qt +from gnuradio import analog +from gnuradio import blocks +from gnuradio import digital +from gnuradio import eng_notation +from gnuradio import filter +from gnuradio import gr +from gnuradio import iio +from gnuradio import qtgui +from gnuradio.eng_option import eng_option +from gnuradio.filter import firdes +from optparse import OptionParser +import sip +import sys +from gnuradio import qtgui + + +class nrf_scan(gr.top_block, Qt.QWidget): + + def __init__(self): + gr.top_block.__init__(self, "Nrf Scan") + Qt.QWidget.__init__(self) + self.setWindowTitle("Nrf Scan") + qtgui.util.check_set_qss() + 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", "nrf_scan") + self.restoreGeometry(self.settings.value("geometry").toByteArray()) + + + ################################################## + # Variables + ################################################## + self.samp_rate = samp_rate = 4e6 + self.fsk_deviation_hz = fsk_deviation_hz = 320e3 + + ################################################## + # Blocks + ################################################## + self.qtgui_time_sink_x_0 = qtgui.time_sink_f( + 1024*256, #size + samp_rate/2, #samp_rate + "", #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(0, 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(False) + 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) + self.qtgui_time_sink_x_0.enable_stem_plot(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_grid_layout.addWidget(self._qtgui_time_sink_x_0_win) + self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c( + 1024*8, #size + firdes.WIN_BLACKMAN_hARRIS, #wintype + 0, #fc + samp_rate/2, #bw + "", #name + 1 #number of inputs + ) + self.qtgui_freq_sink_x_0.set_update_time(0.01) + self.qtgui_freq_sink_x_0.set_y_axis(-140, 10) + self.qtgui_freq_sink_x_0.set_y_label('Relative Gain', 'dB') + self.qtgui_freq_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") + self.qtgui_freq_sink_x_0.enable_autoscale(False) + self.qtgui_freq_sink_x_0.enable_grid(False) + self.qtgui_freq_sink_x_0.set_fft_average(1.0) + self.qtgui_freq_sink_x_0.enable_axis_labels(True) + self.qtgui_freq_sink_x_0.enable_control_panel(False) + + if not True: + self.qtgui_freq_sink_x_0.disable_legend() + + if "complex" == "float" or "complex" == "msg_float": + self.qtgui_freq_sink_x_0.set_plot_pos_half(not True) + + labels = ['', '', '', '', '', + '', '', '', '', ''] + widths = [1, 1, 1, 1, 1, + 1, 1, 1, 1, 1] + colors = ["blue", "red", "green", "black", "cyan", + "magenta", "yellow", "dark red", "dark green", "dark blue"] + 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_freq_sink_x_0.set_line_label(i, "Data {0}".format(i)) + else: + self.qtgui_freq_sink_x_0.set_line_label(i, labels[i]) + self.qtgui_freq_sink_x_0.set_line_width(i, widths[i]) + self.qtgui_freq_sink_x_0.set_line_color(i, colors[i]) + self.qtgui_freq_sink_x_0.set_line_alpha(i, alphas[i]) + + self._qtgui_freq_sink_x_0_win = sip.wrapinstance(self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget) + self.top_grid_layout.addWidget(self._qtgui_freq_sink_x_0_win) + self.pluto_source_0 = iio.pluto_source('', int(2485e6), int(samp_rate), int(2e6), 0x8000*16, True, True, True, "manual", 60.0, '', True) + self.low_pass_filter_0 = filter.fir_filter_ccf(2, firdes.low_pass( + 1, samp_rate, fsk_deviation_hz, 100e3, firdes.WIN_HAMMING, 6.76)) + self.digital_gfsk_demod_0 = digital.gfsk_demod( + samples_per_symbol=2, + sensitivity=1.0, + gain_mu=0.175, + mu=0.5, + omega_relative_limit=0.005, + freq_error=0.0, + verbose=False, + log=False, + ) + self.blocks_uchar_to_float_0 = blocks.uchar_to_float() + self.analog_pwr_squelch_xx_0 = analog.pwr_squelch_cc(-35, 5e-4, 0, False) + + + + ################################################## + # Connections + ################################################## + self.connect((self.analog_pwr_squelch_xx_0, 0), (self.low_pass_filter_0, 0)) + self.connect((self.blocks_uchar_to_float_0, 0), (self.qtgui_time_sink_x_0, 0)) + self.connect((self.digital_gfsk_demod_0, 0), (self.blocks_uchar_to_float_0, 0)) + self.connect((self.low_pass_filter_0, 0), (self.digital_gfsk_demod_0, 0)) + self.connect((self.low_pass_filter_0, 0), (self.qtgui_freq_sink_x_0, 0)) + self.connect((self.pluto_source_0, 0), (self.analog_pwr_squelch_xx_0, 0)) + + def closeEvent(self, event): + self.settings = Qt.QSettings("GNU Radio", "nrf_scan") + self.settings.setValue("geometry", self.saveGeometry()) + event.accept() + + def get_samp_rate(self): + return self.samp_rate + + def set_samp_rate(self, samp_rate): + self.samp_rate = samp_rate + self.qtgui_time_sink_x_0.set_samp_rate(self.samp_rate/2) + self.qtgui_freq_sink_x_0.set_frequency_range(0, self.samp_rate/2) + self.pluto_source_0.set_params(int(2485e6), int(self.samp_rate), int(2e6), True, True, True, "manual", 60.0, '', True) + self.low_pass_filter_0.set_taps(firdes.low_pass(1, self.samp_rate, self.fsk_deviation_hz, 100e3, firdes.WIN_HAMMING, 6.76)) + + def get_fsk_deviation_hz(self): + return self.fsk_deviation_hz + + def set_fsk_deviation_hz(self, fsk_deviation_hz): + self.fsk_deviation_hz = fsk_deviation_hz + self.low_pass_filter_0.set_taps(firdes.low_pass(1, self.samp_rate, self.fsk_deviation_hz, 100e3, firdes.WIN_HAMMING, 6.76)) + + +def main(top_block_cls=nrf_scan, options=None): + + from distutils.version import StrictVersion + if StrictVersion(Qt.qVersion()) >= StrictVersion("4.5.0"): + style = gr.prefs().get_string('qtgui', 'style', 'raster') + Qt.QApplication.setGraphicsSystem(style) + qapp = Qt.QApplication(sys.argv) + + tb = top_block_cls() + tb.start() + tb.show() + + def quitting(): + tb.stop() + tb.wait() + qapp.connect(qapp, Qt.SIGNAL("aboutToQuit()"), quitting) + qapp.exec_() + + +if __name__ == '__main__': + main() diff --git a/examples/nrz.dat b/examples/nrz.dat new file mode 100644 index 0000000..57ff99e Binary files /dev/null and b/examples/nrz.dat differ diff --git a/examples/pluto_rx.grc b/examples/pluto_rx.grc new file mode 100644 index 0000000..aa69439 --- /dev/null +++ b/examples/pluto_rx.grc @@ -0,0 +1,749 @@ + + + + Tue May 28 08:44:48 2019 + + options + + author + + + + window_size + + + + category + [GRC Hier Blocks] + + + comment + + + + description + + + + _enabled + True + + + _coordinate + (8, 8) + + + _rotation + 0 + + + generate_options + qt_gui + + + hier_block_src_path + .: + + + id + pluto_rx + + + max_nouts + 0 + + + qt_qss_theme + + + + realtime_scheduling + + + + run_command + {python} -u {filename} + + + run_options + prompt + + + run + True + + + sizing_mode + fixed + + + thread_safe_setters + + + + title + + + + placement + (0,0) + + + + variable + + comment + + + + _enabled + True + + + _coordinate + (8, 160) + + + _rotation + 0 + + + id + samp_rate + + + value + 4e6 + + + + analog_pwr_squelch_xx + + alpha + 5e-4 + + + alias + + + + comment + + + + affinity + + + + _enabled + 1 + + + _coordinate + (616, 304) + + + _rotation + 0 + + + gate + False + + + id + analog_pwr_squelch_xx_0 + + + maxoutbuf + 0 + + + minoutbuf + 0 + + + ramp + 0 + + + threshold + -35 + + + type + complex + + + + pluto_source + + bbdc + True + + + alias + + + + buffer_size + 0x8000*32 + + + comment + + + + affinity + + + + uri + + + + _enabled + True + + + auto_filter + True + + + filter + + + + _coordinate + (392, 128) + + + _rotation + 0 + + + gain + "manual" + + + id + pluto_source_0 + + + frequency + 2485e6+8e3 + + + manual_gain + 60.0 + + + maxoutbuf + 0 + + + minoutbuf + 0 + + + quadrature + True + + + rfdc + True + + + bandwidth + 2000000 + + + samplerate + samp_rate + + + + qtgui_sink_x + + bw + samp_rate + + + alias + + + + fc + 0 + + + freqchangevar + None + + + comment + + + + affinity + + + + _enabled + 0 + + + fftsize + 1024 + + + _coordinate + (816, 184) + + + gui_hint + + + + _rotation + 0 + + + id + qtgui_sink_x_0 + + + maxoutbuf + 0 + + + minoutbuf + 0 + + + name + "" + + + plotconst + True + + + plotfreq + True + + + plottime + True + + + plotwaterfall + True + + + showports + True + + + showrf + False + + + type + complex + + + rate + 100 + + + wintype + firdes.WIN_BLACKMAN_hARRIS + + + + qtgui_time_sink_x + + autoscale + False + + + axislabels + True + + + alias + + + + comment + + + + ctrlpanel + False + + + affinity + + + + entags + True + + + _enabled + 1 + + + _coordinate + (816, 308) + + + gui_hint + + + + _rotation + 0 + + + grid + False + + + id + qtgui_time_sink_x_0 + + + legend + True + + + alpha1 + 1.0 + + + color1 + "blue" + + + label1 + + + + marker1 + -1 + + + style1 + 1 + + + width1 + 1 + + + alpha10 + 1.0 + + + color10 + "blue" + + + label10 + + + + marker10 + -1 + + + style10 + 1 + + + width10 + 1 + + + alpha2 + 1.0 + + + color2 + "red" + + + label2 + + + + marker2 + -1 + + + style2 + 1 + + + width2 + 1 + + + alpha3 + 1.0 + + + color3 + "green" + + + label3 + + + + marker3 + -1 + + + style3 + 1 + + + width3 + 1 + + + alpha4 + 1.0 + + + color4 + "black" + + + label4 + + + + marker4 + -1 + + + style4 + 1 + + + width4 + 1 + + + alpha5 + 1.0 + + + color5 + "cyan" + + + label5 + + + + marker5 + -1 + + + style5 + 1 + + + width5 + 1 + + + alpha6 + 1.0 + + + color6 + "magenta" + + + label6 + + + + marker6 + -1 + + + style6 + 1 + + + width6 + 1 + + + alpha7 + 1.0 + + + color7 + "yellow" + + + label7 + + + + marker7 + -1 + + + style7 + 1 + + + width7 + 1 + + + alpha8 + 1.0 + + + color8 + "dark red" + + + label8 + + + + marker8 + -1 + + + style8 + 1 + + + width8 + 1 + + + alpha9 + 1.0 + + + color9 + "dark green" + + + label9 + + + + marker9 + -1 + + + style9 + 1 + + + width9 + 1 + + + name + "" + + + nconnections + 1 + + + size + 8192*128 + + + srate + samp_rate + + + stemplot + False + + + tr_chan + 0 + + + tr_delay + 0 + + + tr_level + 0.0 + + + tr_mode + qtgui.TRIG_MODE_FREE + + + tr_slope + qtgui.TRIG_SLOPE_POS + + + tr_tag + "" + + + type + complex + + + update_time + 0.25 + + + ylabel + Amplitude + + + yunit + "" + + + ymax + 1.5 + + + ymin + -1.5 + + + + analog_pwr_squelch_xx_0 + qtgui_time_sink_x_0 + 0 + 0 + + + pluto_source_0 + analog_pwr_squelch_xx_0 + 0 + 0 + + + pluto_source_0 + qtgui_sink_x_0 + 0 + 0 + + diff --git a/examples/pluto_rx.py b/examples/pluto_rx.py new file mode 100644 index 0000000..2281475 --- /dev/null +++ b/examples/pluto_rx.py @@ -0,0 +1,164 @@ +#!/usr/bin/env python2 +# -*- coding: utf-8 -*- +################################################## +# GNU Radio Python Flow Graph +# Title: Pluto Rx +# Generated: Sat Jun 1 14:28:11 2019 +################################################## + +if __name__ == '__main__': + import ctypes + import sys + if sys.platform.startswith('linux'): + try: + x11 = ctypes.cdll.LoadLibrary('libX11.so') + x11.XInitThreads() + except: + print "Warning: failed to XInitThreads()" + +from PyQt4 import Qt +from gnuradio import analog +from gnuradio import eng_notation +from gnuradio import gr +from gnuradio import iio +from gnuradio import qtgui +from gnuradio.eng_option import eng_option +from gnuradio.filter import firdes +from optparse import OptionParser +import sip +import sys +from gnuradio import qtgui + + +class pluto_rx(gr.top_block, Qt.QWidget): + + def __init__(self): + gr.top_block.__init__(self, "Pluto Rx") + Qt.QWidget.__init__(self) + self.setWindowTitle("Pluto Rx") + qtgui.util.check_set_qss() + 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", "pluto_rx") + self.restoreGeometry(self.settings.value("geometry").toByteArray()) + + + ################################################## + # Variables + ################################################## + self.samp_rate = samp_rate = 4e6 + + ################################################## + # Blocks + ################################################## + self.qtgui_time_sink_x_0 = qtgui.time_sink_c( + 8192*128, #size + samp_rate, #samp_rate + "", #name + 1 #number of inputs + ) + self.qtgui_time_sink_x_0.set_update_time(0.25) + self.qtgui_time_sink_x_0.set_y_axis(-1.5, 1.5) + + 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(False) + 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) + self.qtgui_time_sink_x_0.enable_stem_plot(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(2): + if len(labels[i]) == 0: + if(i % 2 == 0): + self.qtgui_time_sink_x_0.set_line_label(i, "Re{{Data {0}}}".format(i/2)) + else: + self.qtgui_time_sink_x_0.set_line_label(i, "Im{{Data {0}}}".format(i/2)) + 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_grid_layout.addWidget(self._qtgui_time_sink_x_0_win) + self.pluto_source_0 = iio.pluto_source('', int(2485e6+8e3), int(samp_rate), int(2000000), 0x8000*32, True, True, True, "manual", 60.0, '', True) + self.analog_pwr_squelch_xx_0 = analog.pwr_squelch_cc(-35, 5e-4, 0, False) + + + + ################################################## + # Connections + ################################################## + self.connect((self.analog_pwr_squelch_xx_0, 0), (self.qtgui_time_sink_x_0, 0)) + self.connect((self.pluto_source_0, 0), (self.analog_pwr_squelch_xx_0, 0)) + + def closeEvent(self, event): + self.settings = Qt.QSettings("GNU Radio", "pluto_rx") + self.settings.setValue("geometry", self.saveGeometry()) + event.accept() + + def get_samp_rate(self): + return self.samp_rate + + def set_samp_rate(self, samp_rate): + self.samp_rate = samp_rate + self.qtgui_time_sink_x_0.set_samp_rate(self.samp_rate) + self.pluto_source_0.set_params(int(2485e6+8e3), int(self.samp_rate), int(2000000), True, True, True, "manual", 60.0, '', True) + + +def main(top_block_cls=pluto_rx, options=None): + + from distutils.version import StrictVersion + if StrictVersion(Qt.qVersion()) >= StrictVersion("4.5.0"): + style = gr.prefs().get_string('qtgui', 'style', 'raster') + Qt.QApplication.setGraphicsSystem(style) + qapp = Qt.QApplication(sys.argv) + + tb = top_block_cls() + tb.start() + tb.show() + + def quitting(): + tb.stop() + tb.wait() + qapp.connect(qapp, Qt.SIGNAL("aboutToQuit()"), quitting) + qapp.exec_() + + +if __name__ == '__main__': + main() diff --git a/examples/simple_qt_gui.grc b/examples/simple_qt_gui.grc new file mode 100644 index 0000000..9f64167 --- /dev/null +++ b/examples/simple_qt_gui.grc @@ -0,0 +1,511 @@ + + + + Fri May 24 11:49:22 2019 + + options + + author + + + + window_size + + + + category + [GRC Hier Blocks] + + + comment + + + + description + + + + _enabled + True + + + _coordinate + (8, 8) + + + _rotation + 0 + + + generate_options + qt_gui + + + hier_block_src_path + .: + + + id + simple_qt_gui + + + max_nouts + 0 + + + qt_qss_theme + + + + realtime_scheduling + + + + run_command + {python} -u {filename} + + + run_options + prompt + + + run + True + + + sizing_mode + fixed + + + thread_safe_setters + + + + title + + + + placement + (0,0) + + + + variable + + comment + + + + _enabled + True + + + _coordinate + (8, 160) + + + _rotation + 0 + + + id + samp_rate + + + value + 32000 + + + + pluto_source + + bbdc + True + + + alias + + + + buffer_size + 0x8000 + + + comment + + + + affinity + + + + uri + + + + _enabled + True + + + auto_filter + True + + + filter + + + + _coordinate + (416, 256) + + + _rotation + 0 + + + gain + "manual" + + + id + pluto_source_0 + + + frequency + 2499e6 + + + manual_gain + 60.0 + + + maxoutbuf + 0 + + + minoutbuf + 0 + + + quadrature + True + + + rfdc + True + + + bandwidth + 2e6 + + + samplerate + samp_rate + + + + qtgui_freq_sink_x + + autoscale + False + + + average + 1.0 + + + axislabels + True + + + bw + samp_rate + + + alias + + + + fc + 0 + + + comment + + + + ctrlpanel + False + + + affinity + + + + _enabled + True + + + fftsize + 1024 + + + _coordinate + (656, 316) + + + gui_hint + + + + _rotation + 0 + + + grid + False + + + id + qtgui_freq_sink_x_0 + + + legend + True + + + alpha1 + 1.0 + + + color1 + "blue" + + + label1 + + + + width1 + 1 + + + alpha10 + 1.0 + + + color10 + "dark blue" + + + label10 + + + + width10 + 1 + + + alpha2 + 1.0 + + + color2 + "red" + + + label2 + + + + width2 + 1 + + + alpha3 + 1.0 + + + color3 + "green" + + + label3 + + + + width3 + 1 + + + alpha4 + 1.0 + + + color4 + "black" + + + label4 + + + + width4 + 1 + + + alpha5 + 1.0 + + + color5 + "cyan" + + + label5 + + + + width5 + 1 + + + alpha6 + 1.0 + + + color6 + "magenta" + + + label6 + + + + width6 + 1 + + + alpha7 + 1.0 + + + color7 + "yellow" + + + label7 + + + + width7 + 1 + + + alpha8 + 1.0 + + + color8 + "dark red" + + + label8 + + + + width8 + 1 + + + alpha9 + 1.0 + + + color9 + "dark green" + + + label9 + + + + width9 + 1 + + + maxoutbuf + 0 + + + minoutbuf + 0 + + + name + "" + + + nconnections + 1 + + + showports + True + + + freqhalf + True + + + tr_chan + 0 + + + tr_level + 0.0 + + + tr_mode + qtgui.TRIG_MODE_FREE + + + tr_tag + "" + + + type + complex + + + update_time + 0.10 + + + wintype + firdes.WIN_BLACKMAN_hARRIS + + + label + Relative Gain + + + ymax + 10 + + + ymin + -140 + + + units + dB + + + + pluto_source_0 + qtgui_freq_sink_x_0 + 0 + 0 + + diff --git a/examples/simple_qt_gui.py b/examples/simple_qt_gui.py new file mode 100644 index 0000000..b499852 --- /dev/null +++ b/examples/simple_qt_gui.py @@ -0,0 +1,153 @@ +#!/usr/bin/env python2 +# -*- coding: utf-8 -*- +################################################## +# GNU Radio Python Flow Graph +# Title: Simple Qt Gui +# Generated: Fri May 24 11:51:21 2019 +################################################## + +if __name__ == '__main__': + import ctypes + import sys + if sys.platform.startswith('linux'): + try: + x11 = ctypes.cdll.LoadLibrary('libX11.so') + x11.XInitThreads() + except: + print "Warning: failed to XInitThreads()" + +from PyQt4 import Qt +from gnuradio import eng_notation +from gnuradio import gr +from gnuradio import iio +from gnuradio import qtgui +from gnuradio.eng_option import eng_option +from gnuradio.filter import firdes +from optparse import OptionParser +import sip +import sys +from gnuradio import qtgui + + +class simple_qt_gui(gr.top_block, Qt.QWidget): + + def __init__(self): + gr.top_block.__init__(self, "Simple Qt Gui") + Qt.QWidget.__init__(self) + self.setWindowTitle("Simple Qt Gui") + qtgui.util.check_set_qss() + 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", "simple_qt_gui") + self.restoreGeometry(self.settings.value("geometry").toByteArray()) + + + ################################################## + # Variables + ################################################## + self.samp_rate = samp_rate = 32000 + + ################################################## + # Blocks + ################################################## + self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c( + 1024, #size + firdes.WIN_BLACKMAN_hARRIS, #wintype + 0, #fc + samp_rate, #bw + "", #name + 1 #number of inputs + ) + self.qtgui_freq_sink_x_0.set_update_time(0.10) + self.qtgui_freq_sink_x_0.set_y_axis(-140, 10) + self.qtgui_freq_sink_x_0.set_y_label('Relative Gain', 'dB') + self.qtgui_freq_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") + self.qtgui_freq_sink_x_0.enable_autoscale(False) + self.qtgui_freq_sink_x_0.enable_grid(False) + self.qtgui_freq_sink_x_0.set_fft_average(1.0) + self.qtgui_freq_sink_x_0.enable_axis_labels(True) + self.qtgui_freq_sink_x_0.enable_control_panel(False) + + if not True: + self.qtgui_freq_sink_x_0.disable_legend() + + if "complex" == "float" or "complex" == "msg_float": + self.qtgui_freq_sink_x_0.set_plot_pos_half(not True) + + labels = ['', '', '', '', '', + '', '', '', '', ''] + widths = [1, 1, 1, 1, 1, + 1, 1, 1, 1, 1] + colors = ["blue", "red", "green", "black", "cyan", + "magenta", "yellow", "dark red", "dark green", "dark blue"] + 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_freq_sink_x_0.set_line_label(i, "Data {0}".format(i)) + else: + self.qtgui_freq_sink_x_0.set_line_label(i, labels[i]) + self.qtgui_freq_sink_x_0.set_line_width(i, widths[i]) + self.qtgui_freq_sink_x_0.set_line_color(i, colors[i]) + self.qtgui_freq_sink_x_0.set_line_alpha(i, alphas[i]) + + self._qtgui_freq_sink_x_0_win = sip.wrapinstance(self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget) + self.top_grid_layout.addWidget(self._qtgui_freq_sink_x_0_win) + self.pluto_source_0 = iio.pluto_source('', int(2499e6), int(samp_rate), int(2e6), 0x8000, True, True, True, "manual", 60.0, '', True) + + + + ################################################## + # Connections + ################################################## + self.connect((self.pluto_source_0, 0), (self.qtgui_freq_sink_x_0, 0)) + + def closeEvent(self, event): + self.settings = Qt.QSettings("GNU Radio", "simple_qt_gui") + self.settings.setValue("geometry", self.saveGeometry()) + event.accept() + + def get_samp_rate(self): + return self.samp_rate + + def set_samp_rate(self, samp_rate): + self.samp_rate = samp_rate + self.qtgui_freq_sink_x_0.set_frequency_range(0, self.samp_rate) + self.pluto_source_0.set_params(int(2499e6), int(self.samp_rate), int(2e6), True, True, True, "manual", 60.0, '', True) + + +def main(top_block_cls=simple_qt_gui, options=None): + + from distutils.version import StrictVersion + if StrictVersion(Qt.qVersion()) >= StrictVersion("4.5.0"): + style = gr.prefs().get_string('qtgui', 'style', 'raster') + Qt.QApplication.setGraphicsSystem(style) + qapp = Qt.QApplication(sys.argv) + + tb = top_block_cls() + tb.start() + tb.show() + + def quitting(): + tb.stop() + tb.wait() + qapp.connect(qapp, Qt.SIGNAL("aboutToQuit()"), quitting) + qapp.exec_() + + +if __name__ == '__main__': + main() diff --git a/examples/test_gfsk_mod.grc b/examples/test_gfsk_mod.grc new file mode 100644 index 0000000..e92f44a --- /dev/null +++ b/examples/test_gfsk_mod.grc @@ -0,0 +1,348 @@ + + + + Tue May 28 09:36:25 2019 + + options + + author + + + + window_size + + + + category + [GRC Hier Blocks] + + + comment + + + + description + + + + _enabled + True + + + _coordinate + (8, 8) + + + _rotation + 0 + + + generate_options + qt_gui + + + hier_block_src_path + .: + + + id + test_gfsk_mod + + + max_nouts + 0 + + + qt_qss_theme + + + + realtime_scheduling + + + + run_command + {python} -u {filename} + + + run_options + prompt + + + run + True + + + sizing_mode + fixed + + + thread_safe_setters + + + + title + + + + placement + (0,0) + + + + variable + + comment + + + + _enabled + True + + + _coordinate + (8, 160) + + + _rotation + 0 + + + id + samp_rate + + + value + 500e3 + + + + blocks_file_source + + begin_tag + pmt.PMT_NIL + + + alias + + + + comment + + + + affinity + + + + _enabled + True + + + file + /home/herve/gr-nordic/examples/nordic_transmitter.py + + + _coordinate + (192, 148) + + + _rotation + 0 + + + id + blocks_file_source_0 + + + maxoutbuf + 0 + + + minoutbuf + 0 + + + type + byte + + + repeat + True + + + vlen + 1 + + + + digital_gfsk_mod + + bt + 0.35 + + + alias + + + + comment + + + + affinity + + + + _enabled + True + + + _coordinate + (520, 148) + + + _rotation + 0 + + + id + digital_gfsk_mod_0 + + + log + True + + + maxoutbuf + 0 + + + minoutbuf + 0 + + + samples_per_symbol + 2 + + + sensitivity + 1.0 + + + verbose + True + + + + qtgui_sink_x + + bw + samp_rate + + + alias + + + + fc + 0 + + + freqchangevar + None + + + comment + + + + affinity + + + + _enabled + True + + + fftsize + 1024 + + + _coordinate + (736, 144) + + + gui_hint + + + + _rotation + 0 + + + id + qtgui_sink_x_0 + + + maxoutbuf + 0 + + + minoutbuf + 0 + + + name + "" + + + plotconst + True + + + plotfreq + True + + + plottime + True + + + plotwaterfall + True + + + showports + True + + + showrf + False + + + type + complex + + + rate + 10 + + + wintype + firdes.WIN_BLACKMAN_hARRIS + + + + blocks_file_source_0 + digital_gfsk_mod_0 + 0 + 0 + + + digital_gfsk_mod_0 + qtgui_sink_x_0 + 0 + 0 + + diff --git a/examples/test_gfsk_mod.py b/examples/test_gfsk_mod.py new file mode 100644 index 0000000..b2b2b49 --- /dev/null +++ b/examples/test_gfsk_mod.py @@ -0,0 +1,139 @@ +#!/usr/bin/env python2 +# -*- coding: utf-8 -*- +################################################## +# GNU Radio Python Flow Graph +# Title: Test Gfsk Mod +# Generated: Tue May 28 10:21:00 2019 +################################################## + +if __name__ == '__main__': + import ctypes + import sys + if sys.platform.startswith('linux'): + try: + x11 = ctypes.cdll.LoadLibrary('libX11.so') + x11.XInitThreads() + except: + print "Warning: failed to XInitThreads()" + +from PyQt4 import Qt +from gnuradio import blocks +from gnuradio import digital +from gnuradio import eng_notation +from gnuradio import gr +from gnuradio import qtgui +from gnuradio.eng_option import eng_option +from gnuradio.filter import firdes +from optparse import OptionParser +import pmt +import sip +import sys +from gnuradio import qtgui + + +class test_gfsk_mod(gr.top_block, Qt.QWidget): + + def __init__(self): + gr.top_block.__init__(self, "Test Gfsk Mod") + Qt.QWidget.__init__(self) + self.setWindowTitle("Test Gfsk Mod") + qtgui.util.check_set_qss() + 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", "test_gfsk_mod") + self.restoreGeometry(self.settings.value("geometry").toByteArray()) + + + ################################################## + # Variables + ################################################## + self.samp_rate = samp_rate = 500e3 + + ################################################## + # Blocks + ################################################## + self.qtgui_sink_x_0 = qtgui.sink_c( + 1024, #fftsize + firdes.WIN_BLACKMAN_hARRIS, #wintype + 0, #fc + samp_rate, #bw + "", #name + True, #plotfreq + True, #plotwaterfall + True, #plottime + True, #plotconst + ) + self.qtgui_sink_x_0.set_update_time(1.0/10) + self._qtgui_sink_x_0_win = sip.wrapinstance(self.qtgui_sink_x_0.pyqwidget(), Qt.QWidget) + self.top_grid_layout.addWidget(self._qtgui_sink_x_0_win) + + self.qtgui_sink_x_0.enable_rf_freq(False) + + + + self.digital_gfsk_mod_0 = digital.gfsk_mod( + samples_per_symbol=2, + sensitivity=1.0, + bt=0.35, + verbose=True, + log=True, + ) + self.blocks_file_source_0 = blocks.file_source(gr.sizeof_char*1, '/home/herve/gr-nordic/examples/nordic_transmitter.py', True) + self.blocks_file_source_0.set_begin_tag(pmt.PMT_NIL) + + + + ################################################## + # Connections + ################################################## + self.connect((self.blocks_file_source_0, 0), (self.digital_gfsk_mod_0, 0)) + self.connect((self.digital_gfsk_mod_0, 0), (self.qtgui_sink_x_0, 0)) + + def closeEvent(self, event): + self.settings = Qt.QSettings("GNU Radio", "test_gfsk_mod") + self.settings.setValue("geometry", self.saveGeometry()) + event.accept() + + def get_samp_rate(self): + return self.samp_rate + + def set_samp_rate(self, samp_rate): + self.samp_rate = samp_rate + self.qtgui_sink_x_0.set_frequency_range(0, self.samp_rate) + + +def main(top_block_cls=test_gfsk_mod, options=None): + + from distutils.version import StrictVersion + if StrictVersion(Qt.qVersion()) >= StrictVersion("4.5.0"): + style = gr.prefs().get_string('qtgui', 'style', 'raster') + Qt.QApplication.setGraphicsSystem(style) + qapp = Qt.QApplication(sys.argv) + + tb = top_block_cls() + tb.start() + tb.show() + + def quitting(): + tb.stop() + tb.wait() + qapp.connect(qapp, Qt.SIGNAL("aboutToQuit()"), quitting) + qapp.exec_() + + +if __name__ == '__main__': + main() diff --git a/examples/test_gui.py b/examples/test_gui.py new file mode 100644 index 0000000..275db75 --- /dev/null +++ b/examples/test_gui.py @@ -0,0 +1,56 @@ +#!/usr/bin/env python + +from gnuradio import gr +from gnuradio import qtgui +from gnuradio import analog +from gnuradio import blocks +from gnuradio.filter import firdes + +from PyQt4 import QtGui +import sys, sip + +class my_tb(gr.top_block): + def __init__(self): + gr.top_block.__init__(self) + + # Make a local QtApp so we can start it from our side + self.qapp = QtGui.QApplication(sys.argv) + + samp_rate = 1e6 + fftsize = 2048 + + self.src = analog.sig_source_c(samp_rate, analog.GR_SIN_WAVE, 0.1, 1, 0) + self.nse = analog.noise_source_c(analog.GR_GAUSSIAN, 0.1) + self.add = blocks.add_cc() + self.thr = blocks.throttle(gr.sizeof_gr_complex, samp_rate, True) + + self.snk = qtgui.sink_c( + fftsize, #fftsize + firdes.WIN_BLACKMAN_hARRIS, #wintype + 0, #fc + samp_rate, #bw + "", #name + True, #plotfreq + True, #plotwaterfall + True, #plottime + True, #plotconst + ) + + self.connect(self.src, (self.add, 0)) + self.connect(self.nse, (self.add, 1)) + self.connect(self.add, self.thr, self.snk) + + # Tell the sink we want it displayed + self.pyobj = sip.wrapinstance(self.snk.pyqwidget(), QtGui.QWidget) + self.pyobj.show() + +def main(): + tb = my_tb() + tb.start() + tb.qapp.exec_() + +if __name__ == "__main__": + try: + main() + except KeyboardInterrupt: + pass diff --git a/examples/top_block.py b/examples/top_block.py new file mode 100644 index 0000000..42f3c87 --- /dev/null +++ b/examples/top_block.py @@ -0,0 +1,392 @@ +#!/usr/bin/env python2 +# -*- coding: utf-8 -*- +################################################## +# GNU Radio Python Flow Graph +# Title: HackRF - RTLSDR loop back test +# Author: Aaron Scher +# Description: Transmit and receive example +# Generated: Sat Jun 1 17:27:49 2019 +################################################## + +if __name__ == '__main__': + import ctypes + import sys + if sys.platform.startswith('linux'): + try: + x11 = ctypes.cdll.LoadLibrary('libX11.so') + x11.XInitThreads() + except: + print "Warning: failed to XInitThreads()" + +from PyQt4 import Qt +from gnuradio import analog +from gnuradio import blocks +from gnuradio import digital +from gnuradio import eng_notation +from gnuradio import filter +from gnuradio import gr +from gnuradio import iio +from gnuradio import qtgui +from gnuradio.eng_option import eng_option +from gnuradio.filter import firdes +from gnuradio.filter import pfb +from optparse import OptionParser +import epy_block_0 +import numpy +import osmosdr +import sip +import sys +import time +from gnuradio import qtgui + + +class top_block(gr.top_block, Qt.QWidget): + + def __init__(self, hdr_format=digital.header_format_default(digital.packet_utils.default_access_code, 0), my_const=digital.constellation_calcdist((digital.psk_2()[0]), (digital.psk_2()[1]), 2, 1).base()): + gr.top_block.__init__(self, "HackRF - RTLSDR loop back test") + Qt.QWidget.__init__(self) + self.setWindowTitle("HackRF - RTLSDR loop back test") + qtgui.util.check_set_qss() + 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", "top_block") + self.restoreGeometry(self.settings.value("geometry").toByteArray()) + + + ################################################## + # Parameters + ################################################## + self.hdr_format = hdr_format + self.my_const = my_const + + ################################################## + # Variables + ################################################## + self.sps_TX = sps_TX = 40 + self.nfilts = nfilts = 32 + self.EBW = EBW = .35 + self.sps_RX = sps_RX = 40/10 + self.samp_rate = samp_rate = 1e6 + self.freq_offset_value = freq_offset_value = 30E3 + self.center_freq = center_freq = 430E6 + + self.RRC_filter_taps = RRC_filter_taps = firdes.root_raised_cosine(nfilts, nfilts, 1.0, EBW, 5*sps_TX*nfilts) + + + ################################################## + # Blocks + ################################################## + self.rational_resampler_xxx_0 = filter.rational_resampler_ccc( + interpolation=1, + decimation=int(sps_TX/sps_RX), + taps=None, + fractional_bw=None, + ) + self.qtgui_time_sink_x_0 = qtgui.time_sink_c( + 1024*256, #size + samp_rate, #samp_rate + "", #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(-1, 1) + + 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, "len_key") + self.qtgui_time_sink_x_0.enable_autoscale(False) + 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) + self.qtgui_time_sink_x_0.enable_stem_plot(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(2): + if len(labels[i]) == 0: + if(i % 2 == 0): + self.qtgui_time_sink_x_0.set_line_label(i, "Re{{Data {0}}}".format(i/2)) + else: + self.qtgui_time_sink_x_0.set_line_label(i, "Im{{Data {0}}}".format(i/2)) + 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_grid_layout.addWidget(self._qtgui_time_sink_x_0_win) + self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c( + 1024, #size + firdes.WIN_BLACKMAN_hARRIS, #wintype + 0, #fc + samp_rate/int(sps_TX/sps_RX), #bw + "", #name + 1 #number of inputs + ) + self.qtgui_freq_sink_x_0.set_update_time(0.10) + self.qtgui_freq_sink_x_0.set_y_axis(-140, 10) + self.qtgui_freq_sink_x_0.set_y_label('Relative Gain', 'dB') + self.qtgui_freq_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") + self.qtgui_freq_sink_x_0.enable_autoscale(False) + self.qtgui_freq_sink_x_0.enable_grid(False) + self.qtgui_freq_sink_x_0.set_fft_average(1.0) + self.qtgui_freq_sink_x_0.enable_axis_labels(True) + self.qtgui_freq_sink_x_0.enable_control_panel(False) + + if not True: + self.qtgui_freq_sink_x_0.disable_legend() + + if "complex" == "float" or "complex" == "msg_float": + self.qtgui_freq_sink_x_0.set_plot_pos_half(not True) + + labels = ['', '', '', '', '', + '', '', '', '', ''] + widths = [1, 1, 1, 1, 1, + 1, 1, 1, 1, 1] + colors = ["blue", "red", "green", "black", "cyan", + "magenta", "yellow", "dark red", "dark green", "dark blue"] + 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_freq_sink_x_0.set_line_label(i, "Data {0}".format(i)) + else: + self.qtgui_freq_sink_x_0.set_line_label(i, labels[i]) + self.qtgui_freq_sink_x_0.set_line_width(i, widths[i]) + self.qtgui_freq_sink_x_0.set_line_color(i, colors[i]) + self.qtgui_freq_sink_x_0.set_line_alpha(i, alphas[i]) + + self._qtgui_freq_sink_x_0_win = sip.wrapinstance(self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget) + self.top_grid_layout.addWidget(self._qtgui_freq_sink_x_0_win) + 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_grid_layout.addWidget(self._qtgui_edit_box_msg_0_win) + self.pluto_source_0 = iio.pluto_source('', int(center_freq-40E3), int(samp_rate), int(1000000), 0x8000, True, True, True, "manual", 60.0, '', True) + self.pfb_arb_resampler_xxx_0 = pfb.arb_resampler_ccf( + sps_TX, + taps=(RRC_filter_taps), + flt_size=nfilts) + self.pfb_arb_resampler_xxx_0.declare_sample_delay(0) + + self.osmosdr_sink_0_0 = osmosdr.sink( args="numchan=" + str(1) + " " + '' ) + self.osmosdr_sink_0_0.set_sample_rate(samp_rate) + self.osmosdr_sink_0_0.set_center_freq(center_freq, 0) + self.osmosdr_sink_0_0.set_freq_corr(0, 0) + self.osmosdr_sink_0_0.set_gain(30, 0) + self.osmosdr_sink_0_0.set_if_gain(10, 0) + self.osmosdr_sink_0_0.set_bb_gain(20, 0) + self.osmosdr_sink_0_0.set_antenna('', 0) + self.osmosdr_sink_0_0.set_bandwidth(0, 0) + + self.epy_block_0 = epy_block_0.msg_block() + self.digital_protocol_formatter_bb_0 = digital.protocol_formatter_bb(hdr_format, 'len_key') + self.digital_pfb_clock_sync_xxx_0 = digital.pfb_clock_sync_ccf(sps_RX, 6.28/400.0*2, (RRC_filter_taps), nfilts, nfilts/2, 1.5, 1) + self.digital_fll_band_edge_cc_0 = digital.fll_band_edge_cc(sps_RX, EBW, 45, .02) + self.digital_diff_encoder_bb_0 = digital.diff_encoder_bb(2) + self.digital_diff_decoder_bb_0 = digital.diff_decoder_bb(2) + self.digital_crc32_async_bb_1 = digital.crc32_async_bb(False) + self.digital_crc32_async_bb_0 = digital.crc32_async_bb(True) + self.digital_costas_loop_cc_0 = digital.costas_loop_cc(.01, 2, False) + self.digital_correlate_access_code_xx_ts_1_0 = digital.correlate_access_code_bb_ts(digital.packet_utils.default_access_code, + 2, 'len_key2') + self.digital_constellation_soft_decoder_cf_0 = digital.constellation_soft_decoder_cf(my_const) + self.digital_cma_equalizer_cc_0 = digital.cma_equalizer_cc(11, 1, .01, 1) + self.digital_chunks_to_symbols_xx_0_0 = digital.chunks_to_symbols_bc((my_const.points()), 1) + self.digital_burst_shaper_xx_0 = digital.burst_shaper_cc((numpy.ones(500)), 4000, 4000, True, 'len_key') + (self.digital_burst_shaper_xx_0).set_block_alias("burst_shaper0") + self.digital_binary_slicer_fb_0 = digital.binary_slicer_fb() + self.blocks_tagged_stream_to_pdu_0 = blocks.tagged_stream_to_pdu(blocks.byte_t, 'len_key2') + self.blocks_tagged_stream_mux_0 = blocks.tagged_stream_mux(gr.sizeof_char*1, 'len_key', 0) + self.blocks_tagged_stream_multiply_length_0 = blocks.tagged_stream_multiply_length(gr.sizeof_gr_complex*1, 'len_key', sps_TX) + self.blocks_repack_bits_bb_0_0_0 = blocks.repack_bits_bb(1, 8, 'len_key2', False, gr.GR_MSB_FIRST) + self.blocks_repack_bits_bb_0_0 = blocks.repack_bits_bb(8, my_const.bits_per_symbol(), 'len_key', False, gr.GR_MSB_FIRST) + self.blocks_pdu_to_tagged_stream_1 = blocks.pdu_to_tagged_stream(blocks.byte_t, 'len_key') + self.blocks_multiply_xx_1 = blocks.multiply_vcc(1) + self.blocks_multiply_xx_0 = blocks.multiply_vcc(1) + self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc((0.5, )) + self.blocks_message_debug_0 = blocks.message_debug() + self.analog_sig_source_x_1 = analog.sig_source_c(samp_rate, analog.GR_COS_WAVE, -freq_offset_value, 1, 0) + self.analog_sig_source_x_0 = analog.sig_source_c(samp_rate, analog.GR_COS_WAVE, freq_offset_value, 1, 0) + + + + ################################################## + # Connections + ################################################## + self.msg_connect((self.blocks_tagged_stream_to_pdu_0, 'pdus'), (self.digital_crc32_async_bb_0, 'in')) + self.msg_connect((self.digital_crc32_async_bb_0, 'out'), (self.blocks_message_debug_0, 'print')) + self.msg_connect((self.digital_crc32_async_bb_1, 'out'), (self.blocks_pdu_to_tagged_stream_1, 'pdus')) + self.msg_connect((self.epy_block_0, 'msg_out'), (self.digital_crc32_async_bb_1, 'in')) + self.msg_connect((self.qtgui_edit_box_msg_0, 'msg'), (self.epy_block_0, 'msg_in')) + self.connect((self.analog_sig_source_x_0, 0), (self.blocks_multiply_xx_0, 1)) + self.connect((self.analog_sig_source_x_1, 0), (self.blocks_multiply_xx_1, 1)) + self.connect((self.blocks_multiply_const_vxx_0, 0), (self.blocks_multiply_xx_0, 0)) + self.connect((self.blocks_multiply_const_vxx_0, 0), (self.qtgui_time_sink_x_0, 0)) + self.connect((self.blocks_multiply_xx_0, 0), (self.osmosdr_sink_0_0, 0)) + self.connect((self.blocks_multiply_xx_1, 0), (self.rational_resampler_xxx_0, 0)) + self.connect((self.blocks_pdu_to_tagged_stream_1, 0), (self.blocks_tagged_stream_mux_0, 1)) + self.connect((self.blocks_pdu_to_tagged_stream_1, 0), (self.digital_protocol_formatter_bb_0, 0)) + self.connect((self.blocks_repack_bits_bb_0_0, 0), (self.digital_diff_encoder_bb_0, 0)) + self.connect((self.blocks_repack_bits_bb_0_0_0, 0), (self.blocks_tagged_stream_to_pdu_0, 0)) + self.connect((self.blocks_tagged_stream_multiply_length_0, 0), (self.blocks_multiply_const_vxx_0, 0)) + self.connect((self.blocks_tagged_stream_mux_0, 0), (self.blocks_repack_bits_bb_0_0, 0)) + self.connect((self.digital_binary_slicer_fb_0, 0), (self.digital_diff_decoder_bb_0, 0)) + self.connect((self.digital_burst_shaper_xx_0, 0), (self.pfb_arb_resampler_xxx_0, 0)) + self.connect((self.digital_chunks_to_symbols_xx_0_0, 0), (self.digital_burst_shaper_xx_0, 0)) + self.connect((self.digital_cma_equalizer_cc_0, 0), (self.digital_constellation_soft_decoder_cf_0, 0)) + self.connect((self.digital_constellation_soft_decoder_cf_0, 0), (self.digital_binary_slicer_fb_0, 0)) + self.connect((self.digital_correlate_access_code_xx_ts_1_0, 0), (self.blocks_repack_bits_bb_0_0_0, 0)) + self.connect((self.digital_costas_loop_cc_0, 0), (self.digital_cma_equalizer_cc_0, 0)) + self.connect((self.digital_diff_decoder_bb_0, 0), (self.digital_correlate_access_code_xx_ts_1_0, 0)) + self.connect((self.digital_diff_encoder_bb_0, 0), (self.digital_chunks_to_symbols_xx_0_0, 0)) + self.connect((self.digital_fll_band_edge_cc_0, 0), (self.digital_pfb_clock_sync_xxx_0, 0)) + self.connect((self.digital_pfb_clock_sync_xxx_0, 0), (self.digital_costas_loop_cc_0, 0)) + self.connect((self.digital_protocol_formatter_bb_0, 0), (self.blocks_tagged_stream_mux_0, 0)) + self.connect((self.pfb_arb_resampler_xxx_0, 0), (self.blocks_tagged_stream_multiply_length_0, 0)) + self.connect((self.pluto_source_0, 0), (self.blocks_multiply_xx_1, 0)) + self.connect((self.rational_resampler_xxx_0, 0), (self.digital_fll_band_edge_cc_0, 0)) + self.connect((self.rational_resampler_xxx_0, 0), (self.qtgui_freq_sink_x_0, 0)) + + def closeEvent(self, event): + self.settings = Qt.QSettings("GNU Radio", "top_block") + self.settings.setValue("geometry", self.saveGeometry()) + event.accept() + + def get_hdr_format(self): + return self.hdr_format + + def set_hdr_format(self, hdr_format): + self.hdr_format = hdr_format + + def get_my_const(self): + return self.my_const + + def set_my_const(self, my_const): + self.my_const = my_const + + def get_sps_TX(self): + return self.sps_TX + + def set_sps_TX(self, sps_TX): + self.sps_TX = sps_TX + self.qtgui_freq_sink_x_0.set_frequency_range(0, self.samp_rate/int(self.sps_TX/self.sps_RX)) + self.pfb_arb_resampler_xxx_0.set_rate(self.sps_TX) + self.blocks_tagged_stream_multiply_length_0.set_scalar(self.sps_TX) + + def get_nfilts(self): + return self.nfilts + + def set_nfilts(self, nfilts): + self.nfilts = nfilts + + def get_EBW(self): + return self.EBW + + def set_EBW(self, EBW): + self.EBW = EBW + + def get_sps_RX(self): + return self.sps_RX + + def set_sps_RX(self, sps_RX): + self.sps_RX = sps_RX + self.qtgui_freq_sink_x_0.set_frequency_range(0, self.samp_rate/int(self.sps_TX/self.sps_RX)) + + def get_samp_rate(self): + return self.samp_rate + + def set_samp_rate(self, samp_rate): + self.samp_rate = samp_rate + self.qtgui_time_sink_x_0.set_samp_rate(self.samp_rate) + self.qtgui_freq_sink_x_0.set_frequency_range(0, self.samp_rate/int(self.sps_TX/self.sps_RX)) + self.pluto_source_0.set_params(int(self.center_freq-40E3), int(self.samp_rate), int(1000000), True, True, True, "manual", 60.0, '', True) + self.osmosdr_sink_0_0.set_sample_rate(self.samp_rate) + self.analog_sig_source_x_1.set_sampling_freq(self.samp_rate) + self.analog_sig_source_x_0.set_sampling_freq(self.samp_rate) + + def get_freq_offset_value(self): + return self.freq_offset_value + + def set_freq_offset_value(self, freq_offset_value): + self.freq_offset_value = freq_offset_value + self.analog_sig_source_x_1.set_frequency(-self.freq_offset_value) + self.analog_sig_source_x_0.set_frequency(self.freq_offset_value) + + def get_center_freq(self): + return self.center_freq + + def set_center_freq(self, center_freq): + self.center_freq = center_freq + self.pluto_source_0.set_params(int(self.center_freq-40E3), int(self.samp_rate), int(1000000), True, True, True, "manual", 60.0, '', True) + self.osmosdr_sink_0_0.set_center_freq(self.center_freq, 0) + + def get_RRC_filter_taps(self): + return self.RRC_filter_taps + + def set_RRC_filter_taps(self, RRC_filter_taps): + self.RRC_filter_taps = RRC_filter_taps + self.pfb_arb_resampler_xxx_0.set_taps((self.RRC_filter_taps)) + self.digital_pfb_clock_sync_xxx_0.update_taps((self.RRC_filter_taps)) + + +def argument_parser(): + description = 'Transmit and receive example' + parser = OptionParser(usage="%prog: [options]", option_class=eng_option, description=description) + return parser + + +def main(top_block_cls=top_block, options=None): + if options is None: + options, _ = argument_parser().parse_args() + + from distutils.version import StrictVersion + if StrictVersion(Qt.qVersion()) >= StrictVersion("4.5.0"): + style = gr.prefs().get_string('qtgui', 'style', 'raster') + Qt.QApplication.setGraphicsSystem(style) + qapp = Qt.QApplication(sys.argv) + + tb = top_block_cls() + tb.start() + tb.show() + + def quitting(): + tb.stop() + tb.wait() + qapp.connect(qapp, Qt.SIGNAL("aboutToQuit()"), quitting) + qapp.exec_() + + +if __name__ == '__main__': + main() diff --git a/examples/tx_nrf.grc b/examples/tx_nrf.grc new file mode 100644 index 0000000..1f0b8dd --- /dev/null +++ b/examples/tx_nrf.grc @@ -0,0 +1,2575 @@ + + + + Fri May 24 20:19:36 2019 + + options + + author + + + + window_size + + + + category + [GRC Hier Blocks] + + + comment + + + + description + + + + _enabled + True + + + _coordinate + (8, 8) + + + _rotation + 0 + + + generate_options + qt_gui + + + hier_block_src_path + .: + + + id + tx_nrf + + + max_nouts + 0 + + + qt_qss_theme + + + + realtime_scheduling + + + + run_command + {python} -u {filename} + + + run_options + prompt + + + run + True + + + sizing_mode + fixed + + + thread_safe_setters + + + + title + + + + placement + (0,0) + + + + variable + + comment + + + + _enabled + True + + + _coordinate + (8, 324) + + + _rotation + 0 + + + id + address + + + value + [0, 85, 2, 5, 8, 0, 0, 2, 85, 85, 85, 85, 85] + + + + variable_qtgui_range + + comment + + + + value + 2485e6 + + + _enabled + 0 + + + _coordinate + (792, 8) + + + gui_hint + + + + _rotation + 0 + + + id + freq + + + label + + + + min_len + 100 + + + orient + Qt.Horizontal + + + start + 2484e6 + + + step + 1 + + + stop + 2486e6 + + + rangeType + float + + + widget + counter_slider + + + + variable + + comment + + + + _enabled + True + + + _coordinate + (128, 244) + + + _rotation + 0 + + + id + freq + + + value + 2485e6 + + + + variable + + comment + + + + _enabled + True + + + _coordinate + (8, 244) + + + _rotation + 0 + + + id + payload + + + value + " 20.0" + + + + variable + + comment + + + + _enabled + 1 + + + _coordinate + (8, 404) + + + _rotation + 0 + + + id + pkt_vec + + + value + address + [ ord(x) for x in payload ] + + + + variable_function_probe + + block_id + probe_signal + + + comment + + + + _enabled + 0 + + + function_args + + + + function_name + level + + + _coordinate + (744, 368) + + + _rotation + 0 + + + id + probe_var + + + value + 0 + + + poll_rate + 10 + + + + variable + + comment + + + + _enabled + True + + + _coordinate + (8, 160) + + + _rotation + 0 + + + id + samp_rate + + + value + 8e6 + + + + variable + + comment + + + + _enabled + True + + + _coordinate + (8, 484) + + + _rotation + 0 + + + id + symbol_rate + + + value + 2e6 + + + + variable_low_pass_filter_taps + + beta + 6.76 + + + comment + + + + cutoff_freq + (symbol_rate/2) + + + _enabled + True + + + _coordinate + (184, 8) + + + _rotation + 0 + + + gain + 1.0 + + + id + taps + + + samp_rate + samp_rate + + + width + 250e3 + + + win + firdes.WIN_HAMMING + + + + variable_qtgui_entry + + comment + + + + value + probe_var + + + _enabled + 0 + + + _coordinate + (560, 28) + + + gui_hint + + + + _rotation + 0 + + + id + variable_qtgui_entry_0 + + + label + + + + type + int + + + + blocks_message_debug + + alias + + + + comment + + + + affinity + + + + _enabled + 0 + + + _coordinate + (384, 360) + + + _rotation + 0 + + + id + blocks_message_debug_0 + + + + blocks_message_strobe + + alias + + + + comment + + + + affinity + + + + _enabled + 1 + + + _coordinate + (184, 172) + + + _rotation + 0 + + + id + blocks_message_strobe_0 + + + maxoutbuf + 0 + + + msg + pmt.init_u8vector( len(pkt_vec), pkt_vec) + + + minoutbuf + 0 + + + period + 1000 + + + + digital_gfsk_mod + + bt + 0.5 + + + alias + + + + comment + + + + affinity + + + + _enabled + True + + + _coordinate + (592, 156) + + + _rotation + 0 + + + id + digital_gfsk_mod_0 + + + log + False + + + maxoutbuf + 0 + + + minoutbuf + 0 + + + samples_per_symbol + 4 + + + sensitivity + 1.5707/4 + + + verbose + False + + + + nordic_nordic_tx + + alias + + + + comment + + + + affinity + + + + _enabled + True + + + _coordinate + (400, 184) + + + _rotation + 0 + + + id + nordic_nordic_tx_0 + + + maxoutbuf + 0 + + + minoutbuf + 0 + + + channel_count + 1 + + + + pfb_synthesizer_ccf + + twox + False + + + alias + + + + bus_conns + [[0,],] + + + ch_map + [] + + + numchans + 1 + + + comment + + + + connections + 1 + + + affinity + + + + _enabled + True + + + _coordinate + (792, 152) + + + _rotation + 0 + + + id + pfb_synthesizer_ccf_0 + + + maxoutbuf + 0 + + + minoutbuf + 0 + + + samp_delay + 0 + + + taps + taps + + + + pluto_sink + + attenuation + 10.0 + + + alias + + + + buffer_size + 0x8000 + + + comment + + + + affinity + + + + cyclic + True + + + _enabled + 0 + + + auto_filter + True + + + filter + + + + _coordinate + (1088, 132) + + + _rotation + 0 + + + id + pluto_sink_0 + + + uri + + + + frequency + 2485e6 + + + bandwidth + 2e6 + + + samplerate + int(samp_rate) + + + + blocks_probe_signal_x + + alias + + + + comment + + + + affinity + + + + _enabled + 0 + + + _coordinate + (624, 408) + + + _rotation + 0 + + + id + probe_signal + + + type + byte + + + + qtgui_freq_sink_x + + autoscale + False + + + average + 1.0 + + + axislabels + True + + + bw + samp_rate + + + alias + + + + fc + 0 + + + comment + + + + ctrlpanel + False + + + affinity + + + + _enabled + 0 + + + fftsize + 1024 + + + _coordinate + (1088, 36) + + + gui_hint + + + + _rotation + 0 + + + grid + False + + + id + qtgui_freq_sink_x_0 + + + legend + True + + + alpha1 + 1.0 + + + color1 + "blue" + + + label1 + + + + width1 + 1 + + + alpha10 + 1.0 + + + color10 + "dark blue" + + + label10 + + + + width10 + 1 + + + alpha2 + 1.0 + + + color2 + "red" + + + label2 + + + + width2 + 1 + + + alpha3 + 1.0 + + + color3 + "green" + + + label3 + + + + width3 + 1 + + + alpha4 + 1.0 + + + color4 + "black" + + + label4 + + + + width4 + 1 + + + alpha5 + 1.0 + + + color5 + "cyan" + + + label5 + + + + width5 + 1 + + + alpha6 + 1.0 + + + color6 + "magenta" + + + label6 + + + + width6 + 1 + + + alpha7 + 1.0 + + + color7 + "yellow" + + + label7 + + + + width7 + 1 + + + alpha8 + 1.0 + + + color8 + "dark red" + + + label8 + + + + width8 + 1 + + + alpha9 + 1.0 + + + color9 + "dark green" + + + label9 + + + + width9 + 1 + + + maxoutbuf + 0 + + + minoutbuf + 0 + + + name + "" + + + nconnections + 1 + + + showports + True + + + freqhalf + True + + + tr_chan + 0 + + + tr_level + 0.0 + + + tr_mode + qtgui.TRIG_MODE_FREE + + + tr_tag + "" + + + type + complex + + + update_time + 0.01 + + + wintype + firdes.WIN_BLACKMAN_hARRIS + + + label + Relative Gain + + + ymax + 10 + + + ymin + -140 + + + units + dB + + + + qtgui_number_sink + + autoscale + False + + + avg + 0 + + + alias + + + + comment + + + + affinity + + + + _enabled + 0 + + + _coordinate + (592, 268) + + + gui_hint + + + + _rotation + 0 + + + graph_type + qtgui.NUM_GRAPH_VERT + + + id + qtgui_number_sink_0 + + + type + byte + + + color1 + ("black", "black") + + + factor1 + 1 + + + label1 + + + + unit1 + + + + color10 + ("black", "black") + + + factor10 + 1 + + + label10 + + + + unit10 + + + + color2 + ("black", "black") + + + factor2 + 1 + + + label2 + + + + unit2 + + + + color3 + ("black", "black") + + + factor3 + 1 + + + label3 + + + + unit3 + + + + color4 + ("black", "black") + + + factor4 + 1 + + + label4 + + + + unit4 + + + + color5 + ("black", "black") + + + factor5 + 1 + + + label5 + + + + unit5 + + + + color6 + ("black", "black") + + + factor6 + 1 + + + label6 + + + + unit6 + + + + color7 + ("black", "black") + + + factor7 + 1 + + + label7 + + + + unit7 + + + + color8 + ("black", "black") + + + factor8 + 1 + + + label8 + + + + unit8 + + + + color9 + ("black", "black") + + + factor9 + 1 + + + label9 + + + + unit9 + + + + max + 255 + + + min + 0 + + + name + "" + + + nconnections + 1 + + + update_time + 0.10 + + + + qtgui_time_sink_x + + autoscale + False + + + axislabels + True + + + alias + + + + comment + + + + ctrlpanel + False + + + affinity + + + + entags + True + + + _enabled + True + + + _coordinate + (1016, 468) + + + gui_hint + + + + _rotation + 0 + + + grid + False + + + id + qtgui_time_sink_x_0 + + + legend + True + + + alpha1 + 1.0 + + + color1 + "blue" + + + label1 + + + + marker1 + -1 + + + style1 + 1 + + + width1 + 1 + + + alpha10 + 1.0 + + + color10 + "blue" + + + label10 + + + + marker10 + -1 + + + style10 + 1 + + + width10 + 1 + + + alpha2 + 1.0 + + + color2 + "red" + + + label2 + + + + marker2 + -1 + + + style2 + 1 + + + width2 + 1 + + + alpha3 + 1.0 + + + color3 + "green" + + + label3 + + + + marker3 + -1 + + + style3 + 1 + + + width3 + 1 + + + alpha4 + 1.0 + + + color4 + "black" + + + label4 + + + + marker4 + -1 + + + style4 + 1 + + + width4 + 1 + + + alpha5 + 1.0 + + + color5 + "cyan" + + + label5 + + + + marker5 + -1 + + + style5 + 1 + + + width5 + 1 + + + alpha6 + 1.0 + + + color6 + "magenta" + + + label6 + + + + marker6 + -1 + + + style6 + 1 + + + width6 + 1 + + + alpha7 + 1.0 + + + color7 + "yellow" + + + label7 + + + + marker7 + -1 + + + style7 + 1 + + + width7 + 1 + + + alpha8 + 1.0 + + + color8 + "dark red" + + + label8 + + + + marker8 + -1 + + + style8 + 1 + + + width8 + 1 + + + alpha9 + 1.0 + + + color9 + "dark green" + + + label9 + + + + marker9 + -1 + + + style9 + 1 + + + width9 + 1 + + + name + "" + + + nconnections + 1 + + + size + 1024*2 + + + srate + samp_rate + + + stemplot + False + + + tr_chan + 0 + + + tr_delay + 0 + + + tr_level + 0.0 + + + tr_mode + qtgui.TRIG_MODE_TAG + + + tr_slope + qtgui.TRIG_SLOPE_POS + + + tr_tag + "packet_len" + + + type + complex + + + update_time + 0.10 + + + ylabel + Amplitude + + + yunit + "" + + + ymax + 1 + + + ymin + -1 + + + + uhd_usrp_sink + + alias + + + + ant0 + TX/RX + + + bw0 + 2e6 + + + center_freq0 + freq + + + norm_gain0 + False + + + gain0 + 60 + + + ant10 + + + + bw10 + 0 + + + center_freq10 + 0 + + + norm_gain10 + False + + + gain10 + 0 + + + ant11 + + + + bw11 + 0 + + + center_freq11 + 0 + + + norm_gain11 + False + + + gain11 + 0 + + + ant12 + + + + bw12 + 0 + + + center_freq12 + 0 + + + norm_gain12 + False + + + gain12 + 0 + + + ant13 + + + + bw13 + 0 + + + center_freq13 + 0 + + + norm_gain13 + False + + + gain13 + 0 + + + ant14 + + + + bw14 + 0 + + + center_freq14 + 0 + + + norm_gain14 + False + + + gain14 + 0 + + + ant15 + + + + bw15 + 0 + + + center_freq15 + 0 + + + norm_gain15 + False + + + gain15 + 0 + + + ant16 + + + + bw16 + 0 + + + center_freq16 + 0 + + + norm_gain16 + False + + + gain16 + 0 + + + ant17 + + + + bw17 + 0 + + + center_freq17 + 0 + + + norm_gain17 + False + + + gain17 + 0 + + + ant18 + + + + bw18 + 0 + + + center_freq18 + 0 + + + norm_gain18 + False + + + gain18 + 0 + + + ant19 + + + + bw19 + 0 + + + center_freq19 + 0 + + + norm_gain19 + False + + + gain19 + 0 + + + ant1 + + + + bw1 + 0 + + + center_freq1 + 0 + + + norm_gain1 + False + + + gain1 + 0 + + + ant20 + + + + bw20 + 0 + + + center_freq20 + 0 + + + norm_gain20 + False + + + gain20 + 0 + + + ant21 + + + + bw21 + 0 + + + center_freq21 + 0 + + + norm_gain21 + False + + + gain21 + 0 + + + ant22 + + + + bw22 + 0 + + + center_freq22 + 0 + + + norm_gain22 + False + + + gain22 + 0 + + + ant23 + + + + bw23 + 0 + + + center_freq23 + 0 + + + norm_gain23 + False + + + gain23 + 0 + + + ant24 + + + + bw24 + 0 + + + center_freq24 + 0 + + + norm_gain24 + False + + + gain24 + 0 + + + ant25 + + + + bw25 + 0 + + + center_freq25 + 0 + + + norm_gain25 + False + + + gain25 + 0 + + + ant26 + + + + bw26 + 0 + + + center_freq26 + 0 + + + norm_gain26 + False + + + gain26 + 0 + + + ant27 + + + + bw27 + 0 + + + center_freq27 + 0 + + + norm_gain27 + False + + + gain27 + 0 + + + ant28 + + + + bw28 + 0 + + + center_freq28 + 0 + + + norm_gain28 + False + + + gain28 + 0 + + + ant29 + + + + bw29 + 0 + + + center_freq29 + 0 + + + norm_gain29 + False + + + gain29 + 0 + + + ant2 + + + + bw2 + 0 + + + center_freq2 + 0 + + + norm_gain2 + False + + + gain2 + 0 + + + ant30 + + + + bw30 + 0 + + + center_freq30 + 0 + + + norm_gain30 + False + + + gain30 + 0 + + + ant31 + + + + bw31 + 0 + + + center_freq31 + 0 + + + norm_gain31 + False + + + gain31 + 0 + + + ant3 + + + + bw3 + 0 + + + center_freq3 + 0 + + + norm_gain3 + False + + + gain3 + 0 + + + ant4 + + + + bw4 + 0 + + + center_freq4 + 0 + + + norm_gain4 + False + + + gain4 + 0 + + + ant5 + + + + bw5 + 0 + + + center_freq5 + 0 + + + norm_gain5 + False + + + gain5 + 0 + + + ant6 + + + + bw6 + 0 + + + center_freq6 + 0 + + + norm_gain6 + False + + + gain6 + 0 + + + ant7 + + + + bw7 + 0 + + + center_freq7 + 0 + + + norm_gain7 + False + + + gain7 + 0 + + + ant8 + + + + bw8 + 0 + + + center_freq8 + 0 + + + norm_gain8 + False + + + gain8 + 0 + + + ant9 + + + + bw9 + 0 + + + center_freq9 + 0 + + + norm_gain9 + False + + + gain9 + 0 + + + clock_rate + 0.0 + + + comment + + + + affinity + + + + dev_addr + "" + + + dev_args + "" + + + _enabled + 1 + + + _coordinate + (1096, 320) + + + _rotation + 0 + + + id + uhd_usrp_sink_0 + + + type + fc32 + + + clock_source0 + + + + sd_spec0 + + + + time_source0 + + + + clock_source1 + + + + sd_spec1 + + + + time_source1 + + + + clock_source2 + + + + sd_spec2 + + + + time_source2 + + + + clock_source3 + + + + sd_spec3 + + + + time_source3 + + + + clock_source4 + + + + sd_spec4 + + + + time_source4 + + + + clock_source5 + + + + sd_spec5 + + + + time_source5 + + + + clock_source6 + + + + sd_spec6 + + + + time_source6 + + + + clock_source7 + + + + sd_spec7 + + + + time_source7 + + + + nchan + 1 + + + num_mboards + 1 + + + samp_rate + samp_rate + + + hide_cmd_port + False + + + hide_lo_controls + True + + + stream_args + + + + stream_chans + [] + + + sync + + + + len_tag_name + + + + otw + + + + + blocks_message_strobe_0 + blocks_message_debug_0 + strobe + print_pdu + + + blocks_message_strobe_0 + nordic_nordic_tx_0 + strobe + nordictap_in + + + digital_gfsk_mod_0 + pfb_synthesizer_ccf_0 + 0 + 0 + + + digital_gfsk_mod_0 + qtgui_time_sink_x_0 + 0 + 0 + + + nordic_nordic_tx_0 + digital_gfsk_mod_0 + 0 + 0 + + + nordic_nordic_tx_0 + probe_signal + 0 + 0 + + + nordic_nordic_tx_0 + qtgui_number_sink_0 + 0 + 0 + + + pfb_synthesizer_ccf_0 + pluto_sink_0 + 0 + 0 + + + pfb_synthesizer_ccf_0 + qtgui_freq_sink_x_0 + 0 + 0 + + + pfb_synthesizer_ccf_0 + uhd_usrp_sink_0 + 0 + 0 + + diff --git a/examples/tx_nrf.py b/examples/tx_nrf.py new file mode 100644 index 0000000..c485d08 --- /dev/null +++ b/examples/tx_nrf.py @@ -0,0 +1,245 @@ +#!/usr/bin/env python2 +# -*- coding: utf-8 -*- +################################################## +# GNU Radio Python Flow Graph +# Title: Tx Nrf +# Generated: Sat Jun 8 16:04:18 2019 +################################################## + +if __name__ == '__main__': + import ctypes + import sys + if sys.platform.startswith('linux'): + try: + x11 = ctypes.cdll.LoadLibrary('libX11.so') + x11.XInitThreads() + except: + print "Warning: failed to XInitThreads()" + +from PyQt4 import Qt +from gnuradio import blocks +from gnuradio import digital +from gnuradio import eng_notation +from gnuradio import filter +from gnuradio import gr +from gnuradio import qtgui +from gnuradio import uhd +from gnuradio.eng_option import eng_option +from gnuradio.filter import firdes +from optparse import OptionParser +import nordic +import pmt +import sip +import sys +import time +from gnuradio import qtgui + + +class tx_nrf(gr.top_block, Qt.QWidget): + + def __init__(self): + gr.top_block.__init__(self, "Tx Nrf") + Qt.QWidget.__init__(self) + self.setWindowTitle("Tx Nrf") + qtgui.util.check_set_qss() + 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_nrf") + self.restoreGeometry(self.settings.value("geometry").toByteArray()) + + + ################################################## + # Variables + ################################################## + self.symbol_rate = symbol_rate = 2e6 + self.samp_rate = samp_rate = 8e6 + self.payload = payload = " 20.0" + self.address = address = [0, 85, 2, 5, 8, 0, 0, 2, 85, 85, 85, 85, 85] + + self.taps = taps = firdes.low_pass(1.0, samp_rate, (symbol_rate/2), 250e3, firdes.WIN_HAMMING, 6.76) + + self.pkt_vec = pkt_vec = address + [ ord(x) for x in payload ] + self.freq = freq = 2485e6 + + ################################################## + # Blocks + ################################################## + self.uhd_usrp_sink_0 = uhd.usrp_sink( + ",".join(("", "")), + uhd.stream_args( + cpu_format="fc32", + channels=range(1), + ), + ) + self.uhd_usrp_sink_0.set_samp_rate(samp_rate) + self.uhd_usrp_sink_0.set_center_freq(freq, 0) + self.uhd_usrp_sink_0.set_gain(60, 0) + self.uhd_usrp_sink_0.set_antenna('TX/RX', 0) + self.uhd_usrp_sink_0.set_bandwidth(2e6, 0) + self.qtgui_time_sink_x_0 = qtgui.time_sink_c( + 1024*2, #size + samp_rate, #samp_rate + "", #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(-1, 1) + + 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_TAG, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "packet_len") + self.qtgui_time_sink_x_0.enable_autoscale(False) + 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) + self.qtgui_time_sink_x_0.enable_stem_plot(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(2): + if len(labels[i]) == 0: + if(i % 2 == 0): + self.qtgui_time_sink_x_0.set_line_label(i, "Re{{Data {0}}}".format(i/2)) + else: + self.qtgui_time_sink_x_0.set_line_label(i, "Im{{Data {0}}}".format(i/2)) + 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_grid_layout.addWidget(self._qtgui_time_sink_x_0_win) + self.pfb_synthesizer_ccf_0 = filter.pfb_synthesizer_ccf( + 1, (taps), False) + self.pfb_synthesizer_ccf_0.set_channel_map(([])) + self.pfb_synthesizer_ccf_0.declare_sample_delay(0) + + self.nordic_nordic_tx_0 = nordic.nordic_tx(1) + self.digital_gfsk_mod_0 = digital.gfsk_mod( + samples_per_symbol=4, + sensitivity=1.5707/4, + bt=0.5, + verbose=False, + log=False, + ) + self.blocks_message_strobe_0 = blocks.message_strobe(pmt.init_u8vector( len(pkt_vec), pkt_vec), 1000) + + + + ################################################## + # Connections + ################################################## + self.msg_connect((self.blocks_message_strobe_0, 'strobe'), (self.nordic_nordic_tx_0, 'nordictap_in')) + self.connect((self.digital_gfsk_mod_0, 0), (self.pfb_synthesizer_ccf_0, 0)) + self.connect((self.digital_gfsk_mod_0, 0), (self.qtgui_time_sink_x_0, 0)) + self.connect((self.nordic_nordic_tx_0, 0), (self.digital_gfsk_mod_0, 0)) + self.connect((self.pfb_synthesizer_ccf_0, 0), (self.uhd_usrp_sink_0, 0)) + + def closeEvent(self, event): + self.settings = Qt.QSettings("GNU Radio", "tx_nrf") + self.settings.setValue("geometry", self.saveGeometry()) + event.accept() + + def get_symbol_rate(self): + return self.symbol_rate + + def set_symbol_rate(self, symbol_rate): + self.symbol_rate = symbol_rate + + def get_samp_rate(self): + return self.samp_rate + + def set_samp_rate(self, samp_rate): + self.samp_rate = samp_rate + self.uhd_usrp_sink_0.set_samp_rate(self.samp_rate) + self.qtgui_time_sink_x_0.set_samp_rate(self.samp_rate) + + def get_payload(self): + return self.payload + + def set_payload(self, payload): + self.payload = payload + self.set_pkt_vec(self.address + [ ord(x) for x in self.payload ]) + + def get_address(self): + return self.address + + def set_address(self, address): + self.address = address + self.set_pkt_vec(self.address + [ ord(x) for x in self.payload ]) + + def get_taps(self): + return self.taps + + def set_taps(self, taps): + self.taps = taps + self.pfb_synthesizer_ccf_0.set_taps((self.taps)) + + def get_pkt_vec(self): + return self.pkt_vec + + def set_pkt_vec(self, pkt_vec): + self.pkt_vec = pkt_vec + self.blocks_message_strobe_0.set_msg(pmt.init_u8vector( len(self.pkt_vec), self.pkt_vec)) + + def get_freq(self): + return self.freq + + def set_freq(self, freq): + self.freq = freq + self.uhd_usrp_sink_0.set_center_freq(self.freq, 0) + + +def main(top_block_cls=tx_nrf, options=None): + + from distutils.version import StrictVersion + if StrictVersion(Qt.qVersion()) >= StrictVersion("4.5.0"): + style = gr.prefs().get_string('qtgui', 'style', 'raster') + Qt.QApplication.setGraphicsSystem(style) + qapp = Qt.QApplication(sys.argv) + + tb = top_block_cls() + tb.start() + tb.show() + + def quitting(): + tb.stop() + tb.wait() + qapp.connect(qapp, Qt.SIGNAL("aboutToQuit()"), quitting) + qapp.exec_() + + +if __name__ == '__main__': + main() diff --git a/examples/tx_nrf_python_block.grc b/examples/tx_nrf_python_block.grc new file mode 100644 index 0000000..695ea6c --- /dev/null +++ b/examples/tx_nrf_python_block.grc @@ -0,0 +1,2756 @@ + + + + Mon May 27 21:24:56 2019 + + options + + author + + + + window_size + + + + category + [GRC Hier Blocks] + + + comment + + + + description + + + + _enabled + True + + + _coordinate + (8, 8) + + + _rotation + 0 + + + generate_options + qt_gui + + + hier_block_src_path + .: + + + id + tx_nrf_python_block + + + max_nouts + 0 + + + qt_qss_theme + + + + realtime_scheduling + + + + run_command + {python} -u {filename} + + + run_options + prompt + + + run + True + + + sizing_mode + fixed + + + thread_safe_setters + + + + title + + + + placement + (0,0) + + + + variable + + comment + + + + _enabled + True + + + _coordinate + (8, 160) + + + _rotation + 0 + + + id + samp_rate + + + value + 8e6 + + + + variable + + comment + + + + _enabled + True + + + _coordinate + (0, 236) + + + _rotation + 0 + + + id + symbol_rate + + + value + 2e6 + + + + variable_low_pass_filter_taps + + beta + 6.76 + + + comment + + + + cutoff_freq + (symbol_rate/2) + + + _enabled + True + + + _coordinate + (280, 8) + + + _rotation + 0 + + + gain + 1.0 + + + id + taps + + + samp_rate + samp_rate + + + width + 250e3 + + + win + firdes.WIN_HAMMING + + + + analog_random_uniform_source_x + + alias + + + + comment + + + + affinity + + + + _enabled + 0 + + + _coordinate + (176, 436) + + + _rotation + 0 + + + id + analog_random_uniform_source_x_0 + + + maxoutbuf + 0 + + + maximum + 255 + + + minoutbuf + 0 + + + minimum + 0 + + + type + byte + + + seed + 0 + + + + blocks_char_to_float + + alias + + + + comment + + + + affinity + + + + _enabled + 1 + + + _coordinate + (768, 660) + + + _rotation + 0 + + + id + blocks_char_to_float_0 + + + maxoutbuf + 0 + + + minoutbuf + 0 + + + scale + 1 + + + vlen + 1 + + + + blocks_file_sink + + append + False + + + alias + + + + comment + + + + affinity + + + + _enabled + 0 + + + file + /home/herve/nrf_gfsk.dat + + + _coordinate + (1056, 388) + + + _rotation + 0 + + + id + blocks_file_sink_0 + + + type + complex + + + unbuffered + False + + + vlen + 1 + + + + blocks_message_debug + + alias + + + + comment + + + + affinity + + + + _enabled + 0 + + + _coordinate + (536, 120) + + + _rotation + 0 + + + id + blocks_message_debug_0 + + + + blocks_message_strobe + + alias + + + + comment + + + + affinity + + + + _enabled + True + + + _coordinate + (176, 172) + + + _rotation + 0 + + + id + blocks_message_strobe_0 + + + maxoutbuf + 0 + + + msg + pmt.intern("trig") + + + minoutbuf + 0 + + + period + 1000 + + + + blocks_repack_bits_bb + + k + 8 + + + l + 1 + + + alias + + + + comment + + + + affinity + + + + _enabled + 1 + + + endianness + gr.GR_MSB_FIRST + + + _coordinate + (568, 652) + + + _rotation + 0 + + + id + blocks_repack_bits_bb_0 + + + len_tag_key + "" + + + maxoutbuf + 0 + + + minoutbuf + 0 + + + align_output + False + + + + digital_gfsk_mod + + bt + 0.5 + + + alias + + + + comment + + + + affinity + + + + _enabled + True + + + _coordinate + (496, 300) + + + _rotation + 0 + + + id + digital_gfsk_mod_0 + + + log + False + + + maxoutbuf + 0 + + + minoutbuf + 0 + + + samples_per_symbol + int(samp_rate/symbol_rate) + + + sensitivity + 1.5707/(samp_rate/symbol_rate) + + + verbose + False + + + + foo_burst_tagger + + alias + + + + comment + + + + affinity + + + + _enabled + True + + + _coordinate + (680, 420) + + + _rotation + 0 + + + id + foo_burst_tagger_0 + + + maxoutbuf + 0 + + + minoutbuf + 0 + + + mult + int(8*samp_rate/symbol_rate) + + + tag_name + pmt.intern("packet_len") + + + + freq_xlating_fir_filter_xxx + + alias + + + + center_freq + 0 + + + comment + + + + affinity + + + + decim + 1 + + + _enabled + 0 + + + _coordinate + (752, 56) + + + _rotation + 0 + + + id + freq_xlating_fir_filter_xxx_0 + + + maxoutbuf + 0 + + + minoutbuf + 0 + + + samp_rate + samp_rate + + + taps + taps + + + type + ccc + + + + nordic_nordic_tx + + alias + + + + comment + + + + affinity + + + + _enabled + 1 + + + _coordinate + (360, 320) + + + _rotation + 0 + + + id + nordic_nordic_tx_0 + + + maxoutbuf + 0 + + + minoutbuf + 0 + + + channel_count + 1 + + + + nordic_nordictap_transmitter + + address + '\x55\x55\x55\x55\x55' + + + alias + + + + channel_count + 85 + + + channel_index + 0 + + + comment + + + + affinity + + + + _enabled + 1 + + + _coordinate + (144, 288) + + + _rotation + 0 + + + id + nordic_nordictap_transmitter_0 + + + maxoutbuf + 0 + + + minoutbuf + 0 + + + payload + '\x20\x20\x20\x20\x32\x30\x2E\x30' + + + sequence_number + 0 + + + + pfb_synthesizer_ccf + + twox + False + + + alias + + + + bus_conns + [[0,],] + + + ch_map + [] + + + numchans + 1 + + + comment + + + + connections + 1 + + + affinity + + + + _enabled + 1 + + + _coordinate + (848, 296) + + + _rotation + 0 + + + id + pfb_synthesizer_ccf_0 + + + maxoutbuf + 0 + + + minoutbuf + 0 + + + samp_delay + 0 + + + taps + taps + + + + pluto_sink + + attenuation + 10.0 + + + alias + + + + buffer_size + 0x8000 + + + comment + + + + affinity + + + + cyclic + True + + + _enabled + 0 + + + auto_filter + True + + + filter + + + + _coordinate + (1016, 476) + + + _rotation + 0 + + + id + pluto_sink_0 + + + uri + + + + frequency + 2480e6 + + + bandwidth + 4e6 + + + samplerate + int(samp_rate) + + + + qtgui_number_sink + + autoscale + False + + + avg + 0 + + + alias + + + + comment + + + + affinity + + + + _enabled + 0 + + + _coordinate + (536, 524) + + + gui_hint + + + + _rotation + 0 + + + graph_type + qtgui.NUM_GRAPH_HORIZ + + + id + qtgui_number_sink_0 + + + type + byte + + + color1 + ("black", "black") + + + factor1 + 1 + + + label1 + + + + unit1 + + + + color10 + ("black", "black") + + + factor10 + 1 + + + label10 + + + + unit10 + + + + color2 + ("black", "black") + + + factor2 + 1 + + + label2 + + + + unit2 + + + + color3 + ("black", "black") + + + factor3 + 1 + + + label3 + + + + unit3 + + + + color4 + ("black", "black") + + + factor4 + 1 + + + label4 + + + + unit4 + + + + color5 + ("black", "black") + + + factor5 + 1 + + + label5 + + + + unit5 + + + + color6 + ("black", "black") + + + factor6 + 1 + + + label6 + + + + unit6 + + + + color7 + ("black", "black") + + + factor7 + 1 + + + label7 + + + + unit7 + + + + color8 + ("black", "black") + + + factor8 + 1 + + + label8 + + + + unit8 + + + + color9 + ("black", "black") + + + factor9 + 1 + + + label9 + + + + unit9 + + + + max + 255 + + + min + 0 + + + name + "" + + + nconnections + 1 + + + update_time + 0.10 + + + + qtgui_time_sink_x + + autoscale + False + + + axislabels + True + + + alias + + + + comment + + + + ctrlpanel + False + + + affinity + + + + entags + True + + + _enabled + 1 + + + _coordinate + (984, 156) + + + gui_hint + + + + _rotation + 0 + + + grid + False + + + id + qtgui_time_sink_x_0 + + + legend + True + + + alpha1 + 1.0 + + + color1 + "blue" + + + label1 + + + + marker1 + -1 + + + style1 + 1 + + + width1 + 1 + + + alpha10 + 1.0 + + + color10 + "blue" + + + label10 + + + + marker10 + -1 + + + style10 + 1 + + + width10 + 1 + + + alpha2 + 1.0 + + + color2 + "red" + + + label2 + + + + marker2 + -1 + + + style2 + 1 + + + width2 + 1 + + + alpha3 + 1.0 + + + color3 + "green" + + + label3 + + + + marker3 + -1 + + + style3 + 1 + + + width3 + 1 + + + alpha4 + 1.0 + + + color4 + "black" + + + label4 + + + + marker4 + -1 + + + style4 + 1 + + + width4 + 1 + + + alpha5 + 1.0 + + + color5 + "cyan" + + + label5 + + + + marker5 + -1 + + + style5 + 1 + + + width5 + 1 + + + alpha6 + 1.0 + + + color6 + "magenta" + + + label6 + + + + marker6 + -1 + + + style6 + 1 + + + width6 + 1 + + + alpha7 + 1.0 + + + color7 + "yellow" + + + label7 + + + + marker7 + -1 + + + style7 + 1 + + + width7 + 1 + + + alpha8 + 1.0 + + + color8 + "dark red" + + + label8 + + + + marker8 + -1 + + + style8 + 1 + + + width8 + 1 + + + alpha9 + 1.0 + + + color9 + "dark green" + + + label9 + + + + marker9 + -1 + + + style9 + 1 + + + width9 + 1 + + + name + "" + + + nconnections + 1 + + + size + 1024*2 + + + srate + samp_rate + + + stemplot + False + + + tr_chan + 0 + + + tr_delay + 0 + + + tr_level + 0.0 + + + tr_mode + qtgui.TRIG_MODE_TAG + + + tr_slope + qtgui.TRIG_SLOPE_POS + + + tr_tag + "packet_len" + + + type + complex + + + update_time + 0.10 + + + ylabel + Amplitude + + + yunit + "" + + + ymax + 1 + + + ymin + -1 + + + + qtgui_time_sink_x + + autoscale + False + + + axislabels + True + + + alias + + + + comment + + + + ctrlpanel + False + + + affinity + + + + entags + True + + + _enabled + 1 + + + _coordinate + (992, 644) + + + gui_hint + + + + _rotation + 0 + + + grid + False + + + id + qtgui_time_sink_x_0_0 + + + legend + True + + + alpha1 + 1.0 + + + color1 + "blue" + + + label1 + + + + marker1 + -1 + + + style1 + 1 + + + width1 + 1 + + + alpha10 + 1.0 + + + color10 + "blue" + + + label10 + + + + marker10 + -1 + + + style10 + 1 + + + width10 + 1 + + + alpha2 + 1.0 + + + color2 + "red" + + + label2 + + + + marker2 + -1 + + + style2 + 1 + + + width2 + 1 + + + alpha3 + 1.0 + + + color3 + "green" + + + label3 + + + + marker3 + -1 + + + style3 + 1 + + + width3 + 1 + + + alpha4 + 1.0 + + + color4 + "black" + + + label4 + + + + marker4 + -1 + + + style4 + 1 + + + width4 + 1 + + + alpha5 + 1.0 + + + color5 + "cyan" + + + label5 + + + + marker5 + -1 + + + style5 + 1 + + + width5 + 1 + + + alpha6 + 1.0 + + + color6 + "magenta" + + + label6 + + + + marker6 + -1 + + + style6 + 1 + + + width6 + 1 + + + alpha7 + 1.0 + + + color7 + "yellow" + + + label7 + + + + marker7 + -1 + + + style7 + 1 + + + width7 + 1 + + + alpha8 + 1.0 + + + color8 + "dark red" + + + label8 + + + + marker8 + -1 + + + style8 + 1 + + + width8 + 1 + + + alpha9 + 1.0 + + + color9 + "dark green" + + + label9 + + + + marker9 + -1 + + + style9 + 1 + + + width9 + 1 + + + name + "" + + + nconnections + 1 + + + size + 1024 + + + srate + samp_rate + + + stemplot + False + + + tr_chan + 0 + + + tr_delay + 0 + + + tr_level + 0.0 + + + tr_mode + qtgui.TRIG_MODE_FREE + + + tr_slope + qtgui.TRIG_SLOPE_POS + + + tr_tag + "" + + + type + float + + + update_time + 0.10 + + + ylabel + Amplitude + + + yunit + "" + + + ymax + 1 + + + ymin + -1 + + + + uhd_usrp_sink + + alias + + + + ant0 + TX/RX + + + bw0 + 0 + + + center_freq0 + 2485e6 + + + norm_gain0 + False + + + gain0 + 40 + + + ant10 + + + + bw10 + 0 + + + center_freq10 + 0 + + + norm_gain10 + False + + + gain10 + 0 + + + ant11 + + + + bw11 + 0 + + + center_freq11 + 0 + + + norm_gain11 + False + + + gain11 + 0 + + + ant12 + + + + bw12 + 0 + + + center_freq12 + 0 + + + norm_gain12 + False + + + gain12 + 0 + + + ant13 + + + + bw13 + 0 + + + center_freq13 + 0 + + + norm_gain13 + False + + + gain13 + 0 + + + ant14 + + + + bw14 + 0 + + + center_freq14 + 0 + + + norm_gain14 + False + + + gain14 + 0 + + + ant15 + + + + bw15 + 0 + + + center_freq15 + 0 + + + norm_gain15 + False + + + gain15 + 0 + + + ant16 + + + + bw16 + 0 + + + center_freq16 + 0 + + + norm_gain16 + False + + + gain16 + 0 + + + ant17 + + + + bw17 + 0 + + + center_freq17 + 0 + + + norm_gain17 + False + + + gain17 + 0 + + + ant18 + + + + bw18 + 0 + + + center_freq18 + 0 + + + norm_gain18 + False + + + gain18 + 0 + + + ant19 + + + + bw19 + 0 + + + center_freq19 + 0 + + + norm_gain19 + False + + + gain19 + 0 + + + ant1 + + + + bw1 + 0 + + + center_freq1 + 0 + + + norm_gain1 + False + + + gain1 + 0 + + + ant20 + + + + bw20 + 0 + + + center_freq20 + 0 + + + norm_gain20 + False + + + gain20 + 0 + + + ant21 + + + + bw21 + 0 + + + center_freq21 + 0 + + + norm_gain21 + False + + + gain21 + 0 + + + ant22 + + + + bw22 + 0 + + + center_freq22 + 0 + + + norm_gain22 + False + + + gain22 + 0 + + + ant23 + + + + bw23 + 0 + + + center_freq23 + 0 + + + norm_gain23 + False + + + gain23 + 0 + + + ant24 + + + + bw24 + 0 + + + center_freq24 + 0 + + + norm_gain24 + False + + + gain24 + 0 + + + ant25 + + + + bw25 + 0 + + + center_freq25 + 0 + + + norm_gain25 + False + + + gain25 + 0 + + + ant26 + + + + bw26 + 0 + + + center_freq26 + 0 + + + norm_gain26 + False + + + gain26 + 0 + + + ant27 + + + + bw27 + 0 + + + center_freq27 + 0 + + + norm_gain27 + False + + + gain27 + 0 + + + ant28 + + + + bw28 + 0 + + + center_freq28 + 0 + + + norm_gain28 + False + + + gain28 + 0 + + + ant29 + + + + bw29 + 0 + + + center_freq29 + 0 + + + norm_gain29 + False + + + gain29 + 0 + + + ant2 + + + + bw2 + 0 + + + center_freq2 + 0 + + + norm_gain2 + False + + + gain2 + 0 + + + ant30 + + + + bw30 + 0 + + + center_freq30 + 0 + + + norm_gain30 + False + + + gain30 + 0 + + + ant31 + + + + bw31 + 0 + + + center_freq31 + 0 + + + norm_gain31 + False + + + gain31 + 0 + + + ant3 + + + + bw3 + 0 + + + center_freq3 + 0 + + + norm_gain3 + False + + + gain3 + 0 + + + ant4 + + + + bw4 + 0 + + + center_freq4 + 0 + + + norm_gain4 + False + + + gain4 + 0 + + + ant5 + + + + bw5 + 0 + + + center_freq5 + 0 + + + norm_gain5 + False + + + gain5 + 0 + + + ant6 + + + + bw6 + 0 + + + center_freq6 + 0 + + + norm_gain6 + False + + + gain6 + 0 + + + ant7 + + + + bw7 + 0 + + + center_freq7 + 0 + + + norm_gain7 + False + + + gain7 + 0 + + + ant8 + + + + bw8 + 0 + + + center_freq8 + 0 + + + norm_gain8 + False + + + gain8 + 0 + + + ant9 + + + + bw9 + 0 + + + center_freq9 + 0 + + + norm_gain9 + False + + + gain9 + 0 + + + clock_rate + 0.0 + + + comment + + + + affinity + + + + dev_addr + "" + + + dev_args + "" + + + _enabled + True + + + _coordinate + (1056, 272) + + + _rotation + 0 + + + id + uhd_usrp_sink_0 + + + type + fc32 + + + clock_source0 + + + + sd_spec0 + + + + time_source0 + + + + clock_source1 + + + + sd_spec1 + + + + time_source1 + + + + clock_source2 + + + + sd_spec2 + + + + time_source2 + + + + clock_source3 + + + + sd_spec3 + + + + time_source3 + + + + clock_source4 + + + + sd_spec4 + + + + time_source4 + + + + clock_source5 + + + + sd_spec5 + + + + time_source5 + + + + clock_source6 + + + + sd_spec6 + + + + time_source6 + + + + clock_source7 + + + + sd_spec7 + + + + time_source7 + + + + nchan + 1 + + + num_mboards + 1 + + + samp_rate + samp_rate + + + hide_cmd_port + False + + + hide_lo_controls + True + + + stream_args + + + + stream_chans + [] + + + sync + + + + len_tag_name + + + + otw + + + + + analog_random_uniform_source_x_0 + digital_gfsk_mod_0 + 0 + 0 + + + analog_random_uniform_source_x_0 + qtgui_number_sink_0 + 0 + 0 + + + blocks_char_to_float_0 + qtgui_time_sink_x_0_0 + 0 + 0 + + + blocks_message_strobe_0 + nordic_nordictap_transmitter_0 + strobe + trig + + + blocks_repack_bits_bb_0 + blocks_char_to_float_0 + 0 + 0 + + + digital_gfsk_mod_0 + foo_burst_tagger_0 + 0 + 0 + + + foo_burst_tagger_0 + blocks_file_sink_0 + 0 + 0 + + + foo_burst_tagger_0 + pfb_synthesizer_ccf_0 + 0 + 0 + + + foo_burst_tagger_0 + qtgui_time_sink_x_0 + 0 + 0 + + + nordic_nordic_tx_0 + blocks_repack_bits_bb_0 + 0 + 0 + + + nordic_nordic_tx_0 + digital_gfsk_mod_0 + 0 + 0 + + + nordic_nordictap_transmitter_0 + blocks_message_debug_0 + nordictap_out + print_pdu + + + nordic_nordictap_transmitter_0 + nordic_nordic_tx_0 + nordictap_out + nordictap_in + + + pfb_synthesizer_ccf_0 + uhd_usrp_sink_0 + 0 + 0 + + diff --git a/examples/tx_nrf_python_block.py b/examples/tx_nrf_python_block.py new file mode 100644 index 0000000..897234e --- /dev/null +++ b/examples/tx_nrf_python_block.py @@ -0,0 +1,271 @@ +#!/usr/bin/env python2 +# -*- coding: utf-8 -*- +################################################## +# GNU Radio Python Flow Graph +# Title: Tx Nrf Python Block +# Generated: Fri Jun 14 08:02:03 2019 +################################################## + +if __name__ == '__main__': + import ctypes + import sys + if sys.platform.startswith('linux'): + try: + x11 = ctypes.cdll.LoadLibrary('libX11.so') + x11.XInitThreads() + except: + print "Warning: failed to XInitThreads()" + +from PyQt4 import Qt +from gnuradio import blocks +from gnuradio import digital +from gnuradio import eng_notation +from gnuradio import filter +from gnuradio import gr +from gnuradio import qtgui +from gnuradio import uhd +from gnuradio.eng_option import eng_option +from gnuradio.filter import firdes +from optparse import OptionParser +import foo +import nordic +import pmt +import sip +import sys +import time +from gnuradio import qtgui + + +class tx_nrf_python_block(gr.top_block, Qt.QWidget): + + def __init__(self): + gr.top_block.__init__(self, "Tx Nrf Python Block") + Qt.QWidget.__init__(self) + self.setWindowTitle("Tx Nrf Python Block") + qtgui.util.check_set_qss() + 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_nrf_python_block") + self.restoreGeometry(self.settings.value("geometry").toByteArray()) + + + ################################################## + # Variables + ################################################## + self.symbol_rate = symbol_rate = 2e6 + self.samp_rate = samp_rate = 8e6 + + self.taps = taps = firdes.low_pass(1.0, samp_rate, (symbol_rate/2), 250e3, firdes.WIN_HAMMING, 6.76) + + + ################################################## + # Blocks + ################################################## + self.uhd_usrp_sink_0 = uhd.usrp_sink( + ",".join(("", "")), + uhd.stream_args( + cpu_format="fc32", + channels=range(1), + ), + ) + self.uhd_usrp_sink_0.set_samp_rate(samp_rate) + self.uhd_usrp_sink_0.set_center_freq(2485e6, 0) + self.uhd_usrp_sink_0.set_gain(40, 0) + self.uhd_usrp_sink_0.set_antenna('TX/RX', 0) + self.qtgui_time_sink_x_0_0 = qtgui.time_sink_f( + 1024, #size + samp_rate, #samp_rate + "", #name + 1 #number of inputs + ) + self.qtgui_time_sink_x_0_0.set_update_time(0.10) + self.qtgui_time_sink_x_0_0.set_y_axis(-1, 1) + + self.qtgui_time_sink_x_0_0.set_y_label('Amplitude', "") + + self.qtgui_time_sink_x_0_0.enable_tags(-1, True) + self.qtgui_time_sink_x_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") + self.qtgui_time_sink_x_0_0.enable_autoscale(False) + self.qtgui_time_sink_x_0_0.enable_grid(False) + self.qtgui_time_sink_x_0_0.enable_axis_labels(True) + self.qtgui_time_sink_x_0_0.enable_control_panel(False) + self.qtgui_time_sink_x_0_0.enable_stem_plot(False) + + if not True: + self.qtgui_time_sink_x_0_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_0.set_line_label(i, "Data {0}".format(i)) + else: + self.qtgui_time_sink_x_0_0.set_line_label(i, labels[i]) + self.qtgui_time_sink_x_0_0.set_line_width(i, widths[i]) + self.qtgui_time_sink_x_0_0.set_line_color(i, colors[i]) + self.qtgui_time_sink_x_0_0.set_line_style(i, styles[i]) + self.qtgui_time_sink_x_0_0.set_line_marker(i, markers[i]) + self.qtgui_time_sink_x_0_0.set_line_alpha(i, alphas[i]) + + self._qtgui_time_sink_x_0_0_win = sip.wrapinstance(self.qtgui_time_sink_x_0_0.pyqwidget(), Qt.QWidget) + self.top_grid_layout.addWidget(self._qtgui_time_sink_x_0_0_win) + self.qtgui_time_sink_x_0 = qtgui.time_sink_c( + 1024*2, #size + samp_rate, #samp_rate + "", #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(-1, 1) + + 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_TAG, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "packet_len") + self.qtgui_time_sink_x_0.enable_autoscale(False) + 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) + self.qtgui_time_sink_x_0.enable_stem_plot(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(2): + if len(labels[i]) == 0: + if(i % 2 == 0): + self.qtgui_time_sink_x_0.set_line_label(i, "Re{{Data {0}}}".format(i/2)) + else: + self.qtgui_time_sink_x_0.set_line_label(i, "Im{{Data {0}}}".format(i/2)) + 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_grid_layout.addWidget(self._qtgui_time_sink_x_0_win) + self.pfb_synthesizer_ccf_0 = filter.pfb_synthesizer_ccf( + 1, (taps), False) + self.pfb_synthesizer_ccf_0.set_channel_map(([])) + self.pfb_synthesizer_ccf_0.declare_sample_delay(0) + + self.nordic_nordictap_transmitter_0 = nordic.nordictap_transmitter(85, '\x55\x55\x55\x55\x55', '\x20\x20\x20\x20\x32\x30\x2E\x30', 0, 0) + self.nordic_nordic_tx_0 = nordic.nordic_tx(1) + self.foo_burst_tagger_0 = foo.burst_tagger(pmt.intern("packet_len"), int(8*samp_rate/symbol_rate)) + self.digital_gfsk_mod_0 = digital.gfsk_mod( + samples_per_symbol=int(samp_rate/symbol_rate), + sensitivity=1.5707/(samp_rate/symbol_rate), + bt=0.5, + verbose=False, + log=False, + ) + self.blocks_repack_bits_bb_0 = blocks.repack_bits_bb(8, 1, "", False, gr.GR_MSB_FIRST) + self.blocks_message_strobe_0 = blocks.message_strobe(pmt.intern("trig"), 1000) + self.blocks_char_to_float_0 = blocks.char_to_float(1, 1) + + + + ################################################## + # Connections + ################################################## + self.msg_connect((self.blocks_message_strobe_0, 'strobe'), (self.nordic_nordictap_transmitter_0, 'trig')) + self.msg_connect((self.nordic_nordictap_transmitter_0, 'nordictap_out'), (self.nordic_nordic_tx_0, 'nordictap_in')) + self.connect((self.blocks_char_to_float_0, 0), (self.qtgui_time_sink_x_0_0, 0)) + self.connect((self.blocks_repack_bits_bb_0, 0), (self.blocks_char_to_float_0, 0)) + self.connect((self.digital_gfsk_mod_0, 0), (self.foo_burst_tagger_0, 0)) + self.connect((self.foo_burst_tagger_0, 0), (self.pfb_synthesizer_ccf_0, 0)) + self.connect((self.foo_burst_tagger_0, 0), (self.qtgui_time_sink_x_0, 0)) + self.connect((self.nordic_nordic_tx_0, 0), (self.blocks_repack_bits_bb_0, 0)) + self.connect((self.nordic_nordic_tx_0, 0), (self.digital_gfsk_mod_0, 0)) + self.connect((self.pfb_synthesizer_ccf_0, 0), (self.uhd_usrp_sink_0, 0)) + + def closeEvent(self, event): + self.settings = Qt.QSettings("GNU Radio", "tx_nrf_python_block") + self.settings.setValue("geometry", self.saveGeometry()) + event.accept() + + def get_symbol_rate(self): + return self.symbol_rate + + def set_symbol_rate(self, symbol_rate): + self.symbol_rate = symbol_rate + + def get_samp_rate(self): + return self.samp_rate + + def set_samp_rate(self, samp_rate): + self.samp_rate = samp_rate + self.uhd_usrp_sink_0.set_samp_rate(self.samp_rate) + self.qtgui_time_sink_x_0_0.set_samp_rate(self.samp_rate) + self.qtgui_time_sink_x_0.set_samp_rate(self.samp_rate) + + def get_taps(self): + return self.taps + + def set_taps(self, taps): + self.taps = taps + self.pfb_synthesizer_ccf_0.set_taps((self.taps)) + + +def main(top_block_cls=tx_nrf_python_block, options=None): + + from distutils.version import StrictVersion + if StrictVersion(Qt.qVersion()) >= StrictVersion("4.5.0"): + style = gr.prefs().get_string('qtgui', 'style', 'raster') + Qt.QApplication.setGraphicsSystem(style) + qapp = Qt.QApplication(sys.argv) + + tb = top_block_cls() + tb.start() + tb.show() + + def quitting(): + tb.stop() + tb.wait() + qapp.connect(qapp, Qt.SIGNAL("aboutToQuit()"), quitting) + qapp.exec_() + + +if __name__ == '__main__': + main() diff --git a/examples/tx_rx_loop.grc b/examples/tx_rx_loop.grc new file mode 100644 index 0000000..e7bc03f --- /dev/null +++ b/examples/tx_rx_loop.grc @@ -0,0 +1,946 @@ + + + + Sat Jun 1 09:24:33 2019 + + options + + author + + + + window_size + + + + category + [GRC Hier Blocks] + + + comment + + + + description + + + + _enabled + True + + + _coordinate + (8, 8) + + + _rotation + 0 + + + generate_options + qt_gui + + + hier_block_src_path + .: + + + id + tx_rx_loop + + + max_nouts + 0 + + + qt_qss_theme + + + + realtime_scheduling + + + + run_command + {python} -u {filename} + + + run_options + prompt + + + run + True + + + sizing_mode + fixed + + + thread_safe_setters + + + + title + + + + placement + (0,0) + + + + variable + + comment + + + + _enabled + True + + + _coordinate + (8, 316) + + + _rotation + 0 + + + id + address + + + value + [0, 85, 2, 5, 8, 0, 0, 2, 85, 85, 85, 85, 85] + + + + variable + + comment + + + + _enabled + True + + + _coordinate + (8, 236) + + + _rotation + 0 + + + id + payload + + + value + " 20.0" + + + + variable + + comment + + + + _enabled + 1 + + + _coordinate + (8, 396) + + + _rotation + 0 + + + id + pkt_vec + + + value + address + [ ord(x) for x in payload ] + + + + variable + + comment + + + + _enabled + True + + + _coordinate + (8, 160) + + + _rotation + 0 + + + id + samp_rate + + + value + 32000 + + + + blocks_char_to_float + + alias + + + + comment + + + + affinity + + + + _enabled + True + + + _coordinate + (768, 316) + + + _rotation + 0 + + + id + blocks_char_to_float_0 + + + maxoutbuf + 0 + + + minoutbuf + 0 + + + scale + 1 + + + vlen + 1 + + + + blocks_message_strobe + + alias + + + + comment + + + + affinity + + + + _enabled + 1 + + + _coordinate + (168, 180) + + + _rotation + 0 + + + id + blocks_message_strobe_0 + + + maxoutbuf + 0 + + + msg + pmt.init_u8vector( len(pkt_vec), pkt_vec) + + + minoutbuf + 0 + + + period + 500 + + + + blocks_repack_bits_bb + + k + 8 + + + l + 1 + + + alias + + + + comment + + + + affinity + + + + _enabled + True + + + endianness + gr.GR_MSB_FIRST + + + _coordinate + (488, 180) + + + _rotation + 0 + + + id + blocks_repack_bits_bb_0 + + + len_tag_key + "" + + + maxoutbuf + 0 + + + minoutbuf + 0 + + + align_output + False + + + + blocks_throttle + + alias + + + + comment + + + + affinity + + + + _enabled + True + + + _coordinate + (704, 188) + + + _rotation + 0 + + + id + blocks_throttle_0 + + + ignoretag + True + + + maxoutbuf + 0 + + + minoutbuf + 0 + + + samples_per_second + samp_rate + + + type + byte + + + vlen + 1 + + + + nordic_nordic_rx + + address_length + 5 + + + alias + + + + crc_length + 2 + + + comment + + + + affinity + + + + data_rate + 2 + + + _enabled + 1 + + + _coordinate + (888, 168) + + + _rotation + 0 + + + id + nordic_nordic_rx_0 + + + maxoutbuf + 0 + + + minoutbuf + 0 + + + channel + 85 + + + + nordic_nordic_tx + + alias + + + + comment + + + + affinity + + + + _enabled + True + + + _coordinate + (352, 192) + + + _rotation + 0 + + + id + nordic_nordic_tx_0 + + + maxoutbuf + 0 + + + minoutbuf + 0 + + + channel_count + 1 + + + + nordic_nordictap_printer + + alias + + + + comment + + + + affinity + + + + _enabled + 1 + + + _coordinate + (1072, 192) + + + _rotation + 0 + + + id + nordic_nordictap_printer_0 + + + + qtgui_time_sink_x + + autoscale + False + + + axislabels + True + + + alias + + + + comment + + + + ctrlpanel + False + + + affinity + + + + entags + True + + + _enabled + True + + + _coordinate + (920, 300) + + + gui_hint + + + + _rotation + 0 + + + grid + False + + + id + qtgui_time_sink_x_0 + + + legend + True + + + alpha1 + 1.0 + + + color1 + "blue" + + + label1 + + + + marker1 + -1 + + + style1 + 1 + + + width1 + 1 + + + alpha10 + 1.0 + + + color10 + "blue" + + + label10 + + + + marker10 + -1 + + + style10 + 1 + + + width10 + 1 + + + alpha2 + 1.0 + + + color2 + "red" + + + label2 + + + + marker2 + -1 + + + style2 + 1 + + + width2 + 1 + + + alpha3 + 1.0 + + + color3 + "green" + + + label3 + + + + marker3 + -1 + + + style3 + 1 + + + width3 + 1 + + + alpha4 + 1.0 + + + color4 + "black" + + + label4 + + + + marker4 + -1 + + + style4 + 1 + + + width4 + 1 + + + alpha5 + 1.0 + + + color5 + "cyan" + + + label5 + + + + marker5 + -1 + + + style5 + 1 + + + width5 + 1 + + + alpha6 + 1.0 + + + color6 + "magenta" + + + label6 + + + + marker6 + -1 + + + style6 + 1 + + + width6 + 1 + + + alpha7 + 1.0 + + + color7 + "yellow" + + + label7 + + + + marker7 + -1 + + + style7 + 1 + + + width7 + 1 + + + alpha8 + 1.0 + + + color8 + "dark red" + + + label8 + + + + marker8 + -1 + + + style8 + 1 + + + width8 + 1 + + + alpha9 + 1.0 + + + color9 + "dark green" + + + label9 + + + + marker9 + -1 + + + style9 + 1 + + + width9 + 1 + + + name + "" + + + nconnections + 1 + + + size + 1024 + + + srate + samp_rate + + + stemplot + False + + + tr_chan + 0 + + + tr_delay + 0 + + + tr_level + 0.0 + + + tr_mode + qtgui.TRIG_MODE_FREE + + + tr_slope + qtgui.TRIG_SLOPE_POS + + + tr_tag + "" + + + type + float + + + update_time + 0.10 + + + ylabel + Amplitude + + + yunit + "" + + + ymax + 1 + + + ymin + -1 + + + + blocks_char_to_float_0 + qtgui_time_sink_x_0 + 0 + 0 + + + blocks_message_strobe_0 + nordic_nordic_tx_0 + strobe + nordictap_in + + + blocks_repack_bits_bb_0 + blocks_char_to_float_0 + 0 + 0 + + + blocks_repack_bits_bb_0 + blocks_throttle_0 + 0 + 0 + + + blocks_throttle_0 + nordic_nordic_rx_0 + 0 + 0 + + + nordic_nordic_rx_0 + nordic_nordictap_printer_0 + nordictap_out + nordictap_in + + + nordic_nordic_tx_0 + blocks_repack_bits_bb_0 + 0 + 0 + + diff --git a/examples/tx_rx_loop.py b/examples/tx_rx_loop.py new file mode 100644 index 0000000..d4b6075 --- /dev/null +++ b/examples/tx_rx_loop.py @@ -0,0 +1,196 @@ +#!/usr/bin/env python2 +# -*- coding: utf-8 -*- +################################################## +# GNU Radio Python Flow Graph +# Title: Tx Rx Loop +# Generated: Fri Jun 7 20:50:40 2019 +################################################## + +if __name__ == '__main__': + import ctypes + import sys + if sys.platform.startswith('linux'): + try: + x11 = ctypes.cdll.LoadLibrary('libX11.so') + x11.XInitThreads() + except: + print "Warning: failed to XInitThreads()" + +from PyQt4 import Qt +from gnuradio import blocks +from gnuradio import eng_notation +from gnuradio import gr +from gnuradio import qtgui +from gnuradio.eng_option import eng_option +from gnuradio.filter import firdes +from optparse import OptionParser +import nordic +import pmt +import sip +import sys +from gnuradio import qtgui + + +class tx_rx_loop(gr.top_block, Qt.QWidget): + + def __init__(self): + gr.top_block.__init__(self, "Tx Rx Loop") + Qt.QWidget.__init__(self) + self.setWindowTitle("Tx Rx Loop") + qtgui.util.check_set_qss() + 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_rx_loop") + self.restoreGeometry(self.settings.value("geometry").toByteArray()) + + + ################################################## + # Variables + ################################################## + self.payload = payload = " 20.0" + self.address = address = [0, 85, 2, 5, 8, 0, 0, 2, 85, 85, 85, 85, 85] + self.samp_rate = samp_rate = 32000 + self.pkt_vec = pkt_vec = address + [ ord(x) for x in payload ] + + ################################################## + # Blocks + ################################################## + self.qtgui_time_sink_x_0 = qtgui.time_sink_f( + 1024, #size + samp_rate, #samp_rate + "", #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(-1, 1) + + 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(False) + 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) + self.qtgui_time_sink_x_0.enable_stem_plot(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_grid_layout.addWidget(self._qtgui_time_sink_x_0_win) + self.nordic_nordictap_printer_0 = nordic.nordictap_printer() + self.nordic_nordic_tx_0 = nordic.nordic_tx(1) + self.nordic_nordic_rx_0 = nordic.nordic_rx(85, 5, 2, 2) + self.blocks_throttle_0 = blocks.throttle(gr.sizeof_char*1, samp_rate,True) + self.blocks_repack_bits_bb_0 = blocks.repack_bits_bb(8, 1, "", False, gr.GR_MSB_FIRST) + self.blocks_message_strobe_0 = blocks.message_strobe(pmt.init_u8vector( len(pkt_vec), pkt_vec), 500) + self.blocks_char_to_float_0 = blocks.char_to_float(1, 1) + + + + ################################################## + # Connections + ################################################## + self.msg_connect((self.blocks_message_strobe_0, 'strobe'), (self.nordic_nordic_tx_0, 'nordictap_in')) + self.msg_connect((self.nordic_nordic_rx_0, 'nordictap_out'), (self.nordic_nordictap_printer_0, 'nordictap_in')) + self.connect((self.blocks_char_to_float_0, 0), (self.qtgui_time_sink_x_0, 0)) + self.connect((self.blocks_repack_bits_bb_0, 0), (self.blocks_char_to_float_0, 0)) + self.connect((self.blocks_repack_bits_bb_0, 0), (self.blocks_throttle_0, 0)) + self.connect((self.blocks_throttle_0, 0), (self.nordic_nordic_rx_0, 0)) + self.connect((self.nordic_nordic_tx_0, 0), (self.blocks_repack_bits_bb_0, 0)) + + def closeEvent(self, event): + self.settings = Qt.QSettings("GNU Radio", "tx_rx_loop") + self.settings.setValue("geometry", self.saveGeometry()) + event.accept() + + def get_payload(self): + return self.payload + + def set_payload(self, payload): + self.payload = payload + self.set_pkt_vec(self.address + [ ord(x) for x in self.payload ]) + + def get_address(self): + return self.address + + def set_address(self, address): + self.address = address + self.set_pkt_vec(self.address + [ ord(x) for x in self.payload ]) + + def get_samp_rate(self): + return self.samp_rate + + def set_samp_rate(self, samp_rate): + self.samp_rate = samp_rate + self.qtgui_time_sink_x_0.set_samp_rate(self.samp_rate) + self.blocks_throttle_0.set_sample_rate(self.samp_rate) + + def get_pkt_vec(self): + return self.pkt_vec + + def set_pkt_vec(self, pkt_vec): + self.pkt_vec = pkt_vec + self.blocks_message_strobe_0.set_msg(pmt.init_u8vector( len(self.pkt_vec), self.pkt_vec)) + + +def main(top_block_cls=tx_rx_loop, options=None): + + from distutils.version import StrictVersion + if StrictVersion(Qt.qVersion()) >= StrictVersion("4.5.0"): + style = gr.prefs().get_string('qtgui', 'style', 'raster') + Qt.QApplication.setGraphicsSystem(style) + qapp = Qt.QApplication(sys.argv) + + tb = top_block_cls() + tb.start() + tb.show() + + def quitting(): + tb.stop() + tb.wait() + qapp.connect(qapp, Qt.SIGNAL("aboutToQuit()"), quitting) + qapp.exec_() + + +if __name__ == '__main__': + main() diff --git a/grc/CMakeLists.txt b/grc/CMakeLists.txt index b456b1a..1fb6ed7 100644 --- a/grc/CMakeLists.txt +++ b/grc/CMakeLists.txt @@ -14,5 +14,7 @@ # along with this program. If not, see . install(FILES nordic_nordic_rx.xml + nordic_nordictap_transmitter.xml + nordic_nordictap_printer.xml nordic_nordic_tx.xml DESTINATION share/gnuradio/grc/blocks ) diff --git a/grc/nordic_nordic_rx.xml b/grc/nordic_nordic_rx.xml index d7f3b3e..6fc816a 100644 --- a/grc/nordic_nordic_rx.xml +++ b/grc/nordic_nordic_rx.xml @@ -2,37 +2,39 @@ nordic_rx nordic_nordic_rx - nordic + [Nordic] import nordic - nordic.nordic_rx() - + nordic.nordic_rx($channel, $address_length, $crc_length, $data_rate) - ... - ... - ... + RF Channel + channel + 85 + int + + + Address Length + address_length + 5 + int + + + CRC Length + crc_length + 2 + int + + + Data Rate + data_rate + 2 + int - - in - + byte - - - out - + nordictap_out + message diff --git a/grc/nordic_nordic_tx.xml b/grc/nordic_nordic_tx.xml index ef783c0..2347bde 100644 --- a/grc/nordic_nordic_tx.xml +++ b/grc/nordic_nordic_tx.xml @@ -2,37 +2,25 @@ nordic_tx nordic_nordic_tx - nordic + [Nordic] import nordic - nordic.nordic_tx() - - - ... - ... - ... - + nordic.nordic_tx($channel_count) + + + Number of channels + channel_count + 1 + int + - - - in - - + + nordictap_in + message + - - + out - - + byte + $channel_count + diff --git a/grc/nordic_nordictap_printer.xml b/grc/nordic_nordictap_printer.xml new file mode 100644 index 0000000..7df9030 --- /dev/null +++ b/grc/nordic_nordictap_printer.xml @@ -0,0 +1,13 @@ + + + nordictap_printer + nordic_nordictap_printer + [Nordic] + nordic + import nordic + nordic.nordictap_printer() + + nordictap_in + message + + diff --git a/grc/nordic_nordictap_transmitter.xml b/grc/nordic_nordictap_transmitter.xml new file mode 100644 index 0000000..bdc5d86 --- /dev/null +++ b/grc/nordic_nordictap_transmitter.xml @@ -0,0 +1,46 @@ + + + nordictap_transmitter + nordic_nordictap_transmitter + [Nordic] + import nordic + nordic.nordictap_transmitter($channel_count, $address, $payload, $channel_index, $sequence_number) + + Channel Count + channel_count + 4 + int + + + Address + address + '\x55\x55\x55\x55\x55' + string + + + Payload + payload + '\xAA\xAA\xAA\xAA\xAA' + string + + + Channel Index + channel_index + 0 + int + + + Sequence Number + sequence_number + 0 + int + + + trig + message + + + nordictap_out + message + + diff --git a/grc/nordictap_transmitter.xml b/grc/nordictap_transmitter.xml new file mode 100644 index 0000000..eb7451f --- /dev/null +++ b/grc/nordictap_transmitter.xml @@ -0,0 +1,37 @@ + + + nordictap_transmitter + nordic_nordictap_transmitter + nordic + import nordic + nordic.nordic_tx($channel_count) + transmit($address, $payload, $channel_index, $sequence_number) + + Address + address + \x55\x55\x55\x55\x55 + string + + + Payload + payload + \xAA\xAA\xAA\xAA\xAA + string + + + Channel Index + channel_index + 0 + int + + + Sequence Number + sequence_number + 0 + int + + + nordictap_out + message + + diff --git a/lib/nordic_tx_impl.cc b/lib/nordic_tx_impl.cc index 019f39e..b402763 100644 --- a/lib/nordic_tx_impl.cc +++ b/lib/nordic_tx_impl.cc @@ -24,6 +24,7 @@ #include #include +#include #include "nordic_tx_impl.h" #include "nordictap.h" #include "enhanced_shockburst_packet.h" @@ -63,6 +64,7 @@ namespace gr { void nordic_tx_impl::nordictap_message_handler(pmt::pmt_t msg) { m_tx_queue.push(msg); + //printf("Got new message\n"); } int @@ -78,7 +80,7 @@ namespace gr { // Get the blob std::vector vec = pmt::u8vector_elements(m_tx_queue.front()); uint8_t * blob = vec.data(); - + // Read the channel index uint8_t channel = blob[0]; @@ -107,14 +109,21 @@ namespace gr { // Remove the blob from the queue m_tx_queue.pop(); + //memset(output_items[channel], 0, packet->bytes_length()*2); // Write the output bytes uint8_t * out = (uint8_t *)output_items[channel]; + for(int b = 0; b < packet->bytes_length(); b++) + //for(int b = 0; b < noutput_items; b++) { out[b] = packet->bytes()[b]; + //printf(" ByteOut = %02X\n", out[b]); + //printf(" ByteIn = %02X\n", packet->bytes()[b]); out[packet->bytes_length()*2+b] = packet->bytes()[b]; + //printf(" Bytes = %02X\n", out[packet->bytes_length()*2+b]); + //out[packet->bytes_length()*3+b] = packet->bytes()[b]; } - + //memcpy(output_items[0],out, packet->bytes_length()*2); // Write zeros to the other channels' buffers for(int c = 0; c < m_channel_count; c++) { @@ -123,14 +132,23 @@ namespace gr { memset(output_items[c], 0, packet->bytes_length()*2); } } - + printf("Number of output items %d\n", noutput_items); + //printf("Channel = %d\n",blob[0]); + //printf("Packet length = %d\n",packet->bytes_length()); + packet->print(); // Cleanup delete[] address; delete[] payload; - delete packet; + int packet_length = packet->bytes_length()*2; + add_item_tag(0, // Port number + nitems_written(0), // Offset + pmt::mp("packet_len"), // Key + pmt::from_uint64(packet_length) // Value + ); + delete packet; //This is really stupid! // Return the number of bytes produced - return packet->bytes_length()*2; + return packet_length; } else { diff --git a/python/CMakeLists.txt b/python/CMakeLists.txt index 5e26f62..46fd489 100644 --- a/python/CMakeLists.txt +++ b/python/CMakeLists.txt @@ -27,6 +27,7 @@ endif() GR_PYTHON_INSTALL( FILES __init__.py + nordic_blocks.py DESTINATION ${GR_PYTHON_DIR}/nordic ) diff --git a/python/__init__.py b/python/__init__.py index ec593b2..cb80f50 100644 --- a/python/__init__.py +++ b/python/__init__.py @@ -26,6 +26,8 @@ try: # this might fail if the module is python-only from nordic_swig import * + # import any pure python here + from nordic_blocks import nordictap_transmitter, nordictap_printer except ImportError: pass diff --git a/python/nordic_blocks.py b/python/nordic_blocks.py new file mode 100644 index 0000000..9918055 --- /dev/null +++ b/python/nordic_blocks.py @@ -0,0 +1,100 @@ +#!/usr/bin/env python2 + +from gnuradio import gr, blocks, digital +import thread +import nordic +import pmt +import struct +import time +import numpy +import array +import random +import argparse +from bitstring import BitArray +from gnuradio import uhd +from Queue import Queue + +# Nordic transmitter strobe +class nordictap_transmitter(gr.sync_block): + + # Constructor + + def __init__(self, channel_map, address, payload, channel_index, sequence_number): + gr.sync_block.__init__( + self, name="Nordictap Transmitter", in_sig=None, out_sig=None) + + self.channel_map = [channel_map] + self.address = address + self.payload = payload + self.channel_index = channel_index + self.sequence_number = sequence_number + + # Packet output port + self.message_port_register_in(pmt.intern("trig")) + self.message_port_register_out(pmt.intern("nordictap_out")) + + self.set_msg_handler(pmt.intern("trig"), self.transmit) + + # Transmit a packet + def transmit(self, msg): + + channel = self.channel_map[self.channel_index] + #print address + # Build a payload + nordictap = [self.channel_index] + [ + channel, 2, len(self.address), len(self.payload), self.sequence_number, 0, 2] + for c in self.address: + nordictap.append(ord(c)) + for c in self.payload: + nordictap.append(ord(c)) + #print nordictap + # Transmit packet + #vec = pmt.make_u8vector(len(nordictap), 0) + vec = pmt.init_u8vector(len(nordictap), nordictap) + #for x in range(len(nordictap)): + # pmt.u8vector_set(vec, x, nordictap[x]) + self.message_port_pub(pmt.intern("nordictap_out"), vec) + #time.sleep(0.2) + + # Nordic Printer +class nordictap_printer(gr.sync_block): + + # Constructor + + def __init__(self): + gr.sync_block.__init__( + self, name="Nordictap Printer", in_sig=None, out_sig=None) + + # Received packet input port + self.message_port_register_in(pmt.intern("nordictap_in")) + self.set_msg_handler( + pmt.intern("nordictap_in"), self.nordictap_handler) + + # Handle incoming packets, and print payloads + def nordictap_handler(self, msg): + + # PMT to byte string + data = pmt.to_python(msg).tostring() + + # Unpack the header + values = struct.unpack('BBBBBBBB', data[0:8]) + channel = values[0] + data_rate = values[1] + address_length = values[2] + payload_length = values[3] + sequence_number = values[4] + no_ack = values[5] + crc_length = values[6] + + # Parse the address, payload, and crc + address = data[7:7 + address_length] + payload = data[7 + address_length:7 + address_length + payload_length] + crc = data[7 + address_length + payload_length: + 7 + address_length + payload_length + crc_length] + + # Print the channel, sequence number, address and payload + print 'CH=' + str(2400 + channel), + print 'SEQ=' + str(sequence_number), + print 'ADDR=' + ':'.join('%02X' % ord(b) for b in address), + print 'PLD=' + ':'.join('%02X' % ord(b) for b in payload), + print 'CRC=' + ':'.join('%02X' % ord(b) for b in crc)