def main(): """Test the scanner Gets options from parser Sets up the scanner Assigns a channel to lockout Executes scan cycles Prints channels as they change """ # Create parser object parser = prsr.CLParser() if len(parser.parser_args) != 0: parser.print_help() #pylint: disable=maybe-no-member raise SystemExit, 1 # Create scanner object ask_samp_rate = parser.ask_samp_rate num_demod = parser.num_demod hw_args = parser.hw_args record = parser.record lockout_file_name = parser.lockout_file_name scanner = Scanner(ask_samp_rate, num_demod, hw_args, record, lockout_file_name) # Set frequency, gain, squelch, and volume scanner.set_center_freq(parser.center_freq) scanner.set_gain(parser.gain_db) print "\n" print "Started %s at %.3f Msps" % (hw_args, scanner.samp_rate / 1E6) print "RX at %.3f MHz with %d dB gain" % (scanner.center_freq / 1E6, scanner.gain_db) scanner.set_squelch(parser.squelch_db) scanner.set_volume(parser.volume_db) print "%d demods at %d dB squelch and %d dB volume" % ( num_demod, scanner.squelch_db, scanner.volume_db) # Create this epmty list to allow printing to screen old_gui_tuned_channels = [] while 1: # No need to go faster than 10 Hz rate of GNU Radio probe time.sleep(0.1) # Execute a scan cycle scanner.scan_cycle() # Print the GUI tuned channels if they have changed if scanner.gui_tuned_channels != old_gui_tuned_channels: sys.stdout.write("Tuners at: ") for text in scanner.gui_tuned_channels: sys.stdout.write(text + " ") sys.stdout.write("\n") else: pass old_gui_tuned_channels = scanner.gui_tuned_channels
scanner.set_squelch(rxwin.squelch_db) rxwin.squelch_db = scanner.squelch_db # Set and update volume scanner.set_volume(rxwin.volume_db) rxwin.volume_db = scanner.volume_db # Send keystroke to lockout window and update lockout channels if True if lockoutwin.proc_keyb_set_lockout(keyb): # Subtract 48 from ascii keyb value to obtain 0 - 9 idx = keyb - 48 scanner.add_lockout(idx) if lockoutwin.proc_keyb_clear_lockout(keyb): scanner.clear_lockout() if __name__ == '__main__': try: # Do this since curses wrapper won't let parser write to screen PARSER = parser.CLParser() if len(PARSER.parser_args) != 0: PARSER.print_help() #pylint: disable=maybe-no-member raise SystemExit, 1 else: curses.wrapper(main) except KeyboardInterrupt: pass except RuntimeError: print "" print "RuntimeError: SDR hardware not detected or insufficient USB permissions. Try running as root." print ""
def main(): """Test the scanner Gets options from parser Sets up the scanner Assigns a channel to lockout Executes scan cycles Prints channels as they change """ # Create parser object parser = prsr.CLParser() if len(parser.parser_args) != 0: parser.print_help() #pylint: disable=maybe-no-member raise(SystemExit, 1) # Create scanner object ask_samp_rate = parser.ask_samp_rate num_demod = parser.num_demod type_demod = parser.type_demod hw_args = parser.hw_args freq_correction = parser.freq_correction record = parser.record lockout_file_name = parser.lockout_file_name priority_file_name = parser.priority_file_name channel_log_file_name = parser.channel_log_file_name audio_bps = parser.audio_bps max_demod_length = parser.max_demod_length channel_spacing = parser.channel_spacing min_file_size = parser.min_file_size center_freq = parser.center_freq freq_low = parser.freq_low freq_high = parser.freq_high scanner = Scanner(ask_samp_rate, num_demod, type_demod, hw_args, freq_correction, record, lockout_file_name, priority_file_name, channel_log_file_name, audio_bps, max_demod_length, channel_spacing, min_file_size, center_freq, freq_low, freq_high) # Set frequency, gain, squelch, and volume scanner.set_center_freq(parser.center_freq) print("\n") print("Started %s at %.3f Msps" % (hw_args, scanner.samp_rate/1E6)) print("RX at %.3f MHz" % (scanner.center_freq/1E6)) scanner.filter_and_set_gains(parser.gains) for gain in scanner.gains: print("gain %s at %d dB" % (gain["name"], gain["value"])) scanner.set_squelch(parser.squelch_db) scanner.set_volume(parser.volume_db) print("%d demods of type %d at %d dB squelch and %d dB volume" % \ (num_demod, type_demod, scanner.squelch_db, scanner.volume_db)) # Create this epmty list to allow printing to screen old_gui_tuned_channels = [] while 1: # No need to go faster than 10 Hz rate of GNU Radio probe time.sleep(0.1) # Execute a scan cycle scanner.scan_cycle() # Print the GUI tuned channels if they have changed if scanner.gui_tuned_channels != old_gui_tuned_channels: sys.stdout.write("Tuners at: ") for text in scanner.gui_tuned_channels: sys.stdout.write(text + " ") sys.stdout.write("\n") else: pass old_gui_tuned_channels = scanner.gui_tuned_channels