16 | | hop_freq = 462.5625e6 |
17 | | while True |
18 | | tb.rxpath.min_freq = hop_freq - 80e3 |
19 | | tb.rxpath.max_freq = hop_freq + 80e3 |
20 | | tb.rxpath.get_avg_power(10) |
| 28 | |
| 29 | def rx_callback(ok, payload): |
| 30 | #print "inside rx callback" |
| 31 | global n_rcvd, n_right, sync_status,mode,hop_freq |
| 32 | |
| 33 | |
| 34 | |
| 35 | mods = modulation_utils.type_1_mods() |
| 36 | demods = modulation_utils.type_1_demods() |
| 37 | |
| 38 | #setting up the tx options parser |
| 39 | parser_tx = OptionParser(option_class=eng_option, conflict_handler="resolve") |
| 40 | expert_grp_tx = parser_tx.add_option_group("Expert_tx") |
| 41 | print "printing Expert_tx group",expert_grp_tx,"printing Expert_tx group" |
| 42 | parser_tx.add_option("-m", "--modulation", type="choice", choices=mods.keys(), |
| 43 | default='gmsk', |
| 44 | help="Select modulation from: %s [default=%%default]" |
| 45 | % (', '.join(mods.keys()),)) |
| 46 | |
| 47 | parser_tx.add_option("-s", "--size", type="eng_float", default=1500, |
| 48 | help="set packet size [default=%default]") |
| 49 | parser_tx.add_option("-M", "--megabytes", type="eng_float", default=1.0, |
| 50 | help="set megabytes to transmit [default=%default]") |
| 51 | parser_tx.add_option("","--discontinuous", action="store_true", default=False, |
| 52 | help="enable discontinous transmission (bursts of 5 packets)") |
| 53 | parser_tx.add_option("","--from-file", default=None, |
| 54 | help="use file for packet contents") |
| 55 | print "printing parser_tx",parser_tx,"printing parser_tx" |
| 56 | transmit_path.add_options(parser_tx, expert_grp_tx) |
| 57 | |
| 58 | for mod in mods.values(): |
| 59 | mod.add_options(expert_grp_tx) |
| 60 | |
| 61 | (options_tx, args_tx) = parser_tx.parse_args () |
| 62 | |
| 63 | if len(args_tx) != 0: |
| 64 | parser_tx.print_help() |
| 65 | sys.exit(1) |
| 66 | ############# Setting some default values for tx side of the block |
| 67 | options_tx.tx_freq = 462.5625e6 |
| 68 | options_tx.samples_per_symbol = 2 |
| 69 | options_tx.modulation = 'dbpsk' |
| 70 | options_tx.fusb_block_size = 4096 |
| 71 | options_tx.fusb_nblocks = 16 |
| 72 | options_tx.bitrate = 0.0125e6 |
| 73 | ############# |
| 74 | if options_tx.tx_freq is None: |
| 75 | sys.stderr.write("You must specify -f FREQ or --freq FREQ\n") |
| 76 | parser_tx.print_help(sys.stderr) |
| 77 | sys.exit(1) |
| 78 | |
| 79 | if options_tx.from_file is not None: |
| 80 | source_file = open(options_tx.from_file, 'r') |
| 81 | print "printing modulation type",mods[options_tx.modulation],"**" |
| 82 | # build the graph |
| 83 | print "printing tx options",options_tx,"&&&&\n" |
| 84 | #tb = my_top_block(mods[options_tx.modulation], options_tx) |
| 85 | |
| 86 | #r = gr.enable_realtime_scheduling() |
| 87 | #if r != gr.RT_OK: |
| 88 | # print "Warning: failed to enable realtime scheduling" |
| 89 | |
| 90 | #setting up rx options parser |
| 91 | |
| 92 | # Create Options Parser: |
| 93 | parser_rx = OptionParser (option_class=eng_option, conflict_handler="resolve") |
| 94 | print "printing parser_rx",parser_rx,"!!!!!\n" |
| 95 | print "after option parser" |
| 96 | expert_grp_rx = parser_rx.add_option_group("Expert_rx") |
| 97 | print "printing expert group rx",expert_grp_rx,"@@@@\n" |
| 98 | parser_rx.add_option("-m", "--modulation", type="choice", choices=demods.keys(), |
| 99 | default='gmsk', |
| 100 | help="Select modulation from: %s [default=%%default]" |
| 101 | % (', '.join(demods.keys()),)) |
| 102 | print "inside rx option parser" |
| 103 | receive_path.add_options(parser_rx, expert_grp_rx) |
| 104 | |
| 105 | for mod in demods.values(): |
| 106 | mod.add_options(expert_grp_rx) |
| 107 | |
| 108 | (options_rx, args_rx) = parser_rx.parse_args () |
| 109 | |
| 110 | if len(args_rx) != 0: |
| 111 | parser_rx.print_help(sys.stderr) |
| 112 | sys.exit(1) |
| 113 | ############# Setting some default values for rx side of the block |
| 114 | options_rx.rx_freq = 462.5625e6 #setting default rx_freq value |
| 115 | options_rx.samples_per_symbol = 2 |
| 116 | options_rx.modulation = 'dbpsk' |
| 117 | options_rx.fusb_block_size = 4096 |
| 118 | options_rx.fusb_nblocks = 16 |
| 119 | options_rx.bitrate = 0.0125e6 |
| 120 | ############# |
| 121 | if options_rx.rx_freq is None: |
| 122 | sys.stderr.write("You must specify -f FREQ or --freq FREQ\n") |
| 123 | parser_rx.print_help(sys.stderr) |
| 124 | sys.exit(1) |
| 125 | print "printing rx options",options_rx,"&&&&\n" |
| 126 | |
| 127 | |
| 128 | |
| 129 | ######################## adding another top block for usrp spectrum sense ######################## |
| 130 | #This is not needed anymore |
| 131 | #trials = 10 |
| 132 | |
| 133 | #tb_spec_sense = spec_sense_top_block(default_min_freq,default_min_freq) |
| 134 | #tb_spec_sense.subdev.select_rx_antenna('RX2') |
| 135 | #tb_spec_sense.start() # start executing flow graph in another thread... |
| 136 | #avg = tb_spec_sense.get_avg_power(trials) |
| 137 | #print "printing the average power ",avg, "\n" |
| 138 | #tb_spec_sense.stop() |
| 139 | |
| 140 | |
| 141 | ################################################################################################## |
| 142 | |
| 143 | # build the graph |
| 144 | |
| 145 | tb = my_top_block(mods[options_tx.modulation], |
| 146 | demods[options_rx.modulation], |
| 147 | rx_callback,options_tx, |
| 148 | options_rx) |
| 149 | r = gr.enable_realtime_scheduling() |
| 150 | if r != gr.RT_OK: |
| 151 | print "Warning: failed to enable realtime scheduling" |
| 152 | |
| 153 | tb.start() |
| 154 | hop_freq = 462.5625e6 |
| 155 | while True: |
| 156 | tb.rxpath.min_freq = hop_freq - 80e3 |
| 157 | tb.rxpath.max_freq = hop_freq + 80e3 |
| 158 | tb.rxpath.get_avg_power(10) |
| 159 | |
| 160 | |
| 161 | |
| 162 | |
| 163 | |