def __init__(self): self.trunk_rx = None self.kill_sink = None gr.top_block.__init__(self) # command line argument parsing parser = OptionParser(option_class=eng_option) parser.add_option("--args", type="string", default="", help="device args") parser.add_option("--antenna", type="string", default="", help="select antenna") parser.add_option("-a", "--audio", action="store_true", default=False, help="use direct audio input") parser.add_option( "-A", "--audio-if", action="store_true", default=False, help="soundcard IF mode (use --calibration to set IF freq)") parser.add_option( "-I", "--audio-input", type="string", default="", help="pcm input device name. E.g., hw:0,0 or /dev/dsp") parser.add_option("-i", "--input", default=None, help="input file name") parser.add_option("-b", "--excess-bw", type="eng_float", default=0.2, help="for RRC filter", metavar="Hz") parser.add_option("-c", "--calibration", type="eng_float", default=0.0, help="USRP offset or audio IF frequency", metavar="Hz") parser.add_option("-C", "--costas-alpha", type="eng_float", default=0.04, help="value of alpha for Costas loop", metavar="Hz") parser.add_option("-D", "--demod-type", type="choice", default="cqpsk", choices=('cqpsk', 'fsk4'), help="cqpsk | fsk4") parser.add_option("-P", "--plot-mode", type="choice", default=None, choices=(None, 'constellation', 'fft', 'symbol', 'datascope'), help="constellation | fft | symbol | datascope") parser.add_option("-f", "--frequency", type="eng_float", default=0.0, help="USRP center frequency", metavar="Hz") parser.add_option("-F", "--ifile", type="string", default=None, help="read input from complex capture file") parser.add_option("-H", "--hamlib-model", type="int", default=None, help="specify model for hamlib") parser.add_option("-s", "--seek", type="int", default=0, help="ifile seek in K") parser.add_option("-L", "--logfile-workers", type="int", default=None, help="number of demodulators to instantiate") parser.add_option("-S", "--sample-rate", type="int", default=320e3, help="source samp rate") parser.add_option("-t", "--tone-detect", action="store_true", default=False, help="use experimental tone detect algorithm") parser.add_option("-T", "--trunk-conf-file", type="string", default=None, help="trunking config file name") parser.add_option("-v", "--verbosity", type="int", default=0, help="message debug level") parser.add_option("-V", "--vocoder", action="store_true", default=False, help="voice codec") parser.add_option( "-o", "--offset", type="eng_float", default=0.0, help="tuning offset frequency [to circumvent DC offset]", metavar="Hz") parser.add_option("-p", "--pause", action="store_true", default=False, help="block on startup") parser.add_option("-w", "--wireshark", action="store_true", default=False, help="output data to Wireshark") parser.add_option("-W", "--wireshark-host", type="string", default="127.0.0.1", help="Wireshark host") parser.add_option("-r", "--raw-symbols", type="string", default=None, help="dump decoded symbols to file") parser.add_option("-R", "--rx-subdev-spec", type="subdev", default=(0, 0), help="select USRP Rx side A or B (default=A)") parser.add_option( "-g", "--gain", type="eng_float", default=None, help="set USRP gain in dB (default is midpoint) or set audio gain") parser.add_option("-G", "--gain-mu", type="eng_float", default=0.025, help="gardner gain") parser.add_option("-N", "--gains", type="string", default=None, help="gain settings") parser.add_option("-O", "--audio-output", type="string", default="default", help="audio output device name") parser.add_option("-U", "--udp-player", action="store_true", default=False, help="enable built-in udp audio player") parser.add_option("-q", "--freq-corr", type="eng_float", default=0.0, help="frequency correction") parser.add_option("-d", "--fine-tune", type="eng_float", default=0.0, help="fine tuning") parser.add_option("-2", "--phase2-tdma", action="store_true", default=False, help="enable phase2 tdma decode") parser.add_option("-Z", "--decim-amt", type="int", default=1, help="spectrum decimation") (options, args) = parser.parse_args() if len(args) != 0: parser.print_help() sys.exit(1) self.channel_rate = 0 self.baseband_input = False self.rtl_found = False self.channel_rate = options.sample_rate self.fft_sink = None self.src = None if not options.input: # check if osmocom is accessible try: import osmosdr self.src = osmosdr.source(options.args) except Exception: print("osmosdr source_c creation failure") ignore = True if "rtl" in options.args.lower(): #print "'rtl' has been found in options.args (%s)" % (options.args) self.rtl_found = True gain_names = self.src.get_gain_names() for name in gain_names: range = self.src.get_gain_range(name) print( "gain: name: %s range: start %d stop %d step %d" % (name, range[0].start(), range[0].stop(), range[0].step())) if options.gains: for tuple in options.gains.split(","): name, gain = tuple.split(":") gain = int(gain) print("setting gain %s to %d" % (name, gain)) self.src.set_gain(gain, name) rates = self.src.get_sample_rates() try: print('supported sample rates %d-%d step %d' % (rates.start(), rates.stop(), rates.step())) except: pass # ignore if options.freq_corr: self.src.set_freq_corr(options.freq_corr) if options.audio: self.channel_rate = 48000 self.baseband_input = True if options.audio_if: self.channel_rate = 96000 if options.ifile: self.channel_rate = 96000 # TODO: fixme # setup (read-only) attributes self.symbol_rate = 4800 self.symbol_deviation = 600.0 self.basic_rate = 48000 _default_speed = 4800 # keep track of flow graph connections self.cnxns = [] self.datascope_raw_input = False self.data_scope_connected = False self.constellation_scope_connected = False self.options = options for i in range(len(speeds)): if speeds[i] == _default_speed: self.current_speed = i self.default_speed_idx = i if options.hamlib_model: self.hamlib_attach(options.hamlib_model) # wait for gdb if options.pause: print('Ready for GDB to attach (pid = %d)' % (os.getpid(), )) input("Press 'Enter' to continue...") self.input_q = gr.msg_queue(10) self.output_q = gr.msg_queue(10) # configure specified data source if options.input: self.open_file(options.input) elif options.frequency: self.open_usrp() elif options.audio_if: self.open_audio_c(self.channel_rate, options.gain, options.audio_input) elif options.audio: self.open_audio(self.channel_rate, options.gain, options.audio_input) elif options.ifile: self.open_ifile(self.channel_rate, options.gain, options.ifile, options.seek) else: pass # attach terminal thread self.terminal = curses_terminal(self.input_q, self.output_q) # attach audio thread if self.options.udp_player: self.audio = socket_audio("127.0.0.1", WIRESHARK_PORT, self.options.audio_output) else: self.audio = None
def __init__(self, options): self.trunk_rx = None self.plot_sinks = [] gr.top_block.__init__(self) self.channel_rate = 0 self.baseband_input = False self.rtl_found = False self.channel_rate = options.sample_rate self.fft_sink = None self.constellation_sink = None self.symbol_sink = None self.eye_sink = None self.mixer_sink = None self.target_freq = 0.0 self.last_freq_params = { 'freq': 0.0, 'tgid': None, 'tag': "", 'tdma': None } self.src = None if (not options.input) and (not options.audio) and ( not options.audio_if): # check if osmocom is accessible try: import osmosdr self.src = osmosdr.source(options.args) except Exception: print "osmosdr source_c creation failure" ignore = True if any(x in options.args.lower() for x in ['rtl', 'airspy', 'hackrf', 'uhd']): #print "'rtl' has been found in options.args (%s)" % (options.args) self.rtl_found = True gain_names = self.src.get_gain_names() for name in gain_names: range = self.src.get_gain_range(name) print "gain: name: %s range: start %d stop %d step %d" % ( name, range[0].start(), range[0].stop(), range[0].step()) if options.gains: for tup in options.gains.split(","): name, gain = tup.split(":") gain = int(gain) print "setting gain %s to %d" % (name, gain) self.src.set_gain(gain, name) rates = self.src.get_sample_rates() try: print 'supported sample rates %d-%d step %d' % ( rates.start(), rates.stop(), rates.step()) except: pass # ignore if options.freq_corr: self.src.set_freq_corr(options.freq_corr) if options.audio: self.channel_rate = 48000 self.baseband_input = True if options.audio_if: self.channel_rate = 96000 if options.ifile: self.channel_rate = 96000 # TODO: fixme # setup (read-only) attributes self.symbol_rate = 4800 self.symbol_deviation = 600.0 self.basic_rate = 24000 _default_speed = 4800 self.options = options # keep track of flow graph connections self.cnxns = [] self.datascope_raw_input = False self.data_scope_connected = False self.constellation_scope_connected = False for i in xrange(len(speeds)): if speeds[i] == _default_speed: self.current_speed = i self.default_speed_idx = i if options.hamlib_model: self.hamlib_attach(options.hamlib_model) # wait for gdb if options.pause: print 'Ready for GDB to attach (pid = %d)' % (os.getpid(), ) raw_input("Press 'Enter' to continue...") self.input_q = gr.msg_queue(10) self.output_q = gr.msg_queue(10) # configure specified data source if options.input: self.open_file(options.input) elif (self.rtl_found or options.frequency): self.open_usrp() elif options.audio_if: self.open_audio_c(self.channel_rate, options.gain, options.audio_input) elif options.audio: self.open_audio(self.channel_rate, options.gain, options.audio_input) elif options.ifile: self.open_ifile(self.channel_rate, options.gain, options.ifile, options.seek) else: pass # attach terminal thread and make sure currently tuned frequency is displayed self.terminal = op25_terminal(self.input_q, self.output_q, self.options.terminal_type) if self.terminal is None: sys.exit(1) # attach audio thread if self.options.udp_player: self.audio = socket_audio("127.0.0.1", self.options.wireshark_port, self.options.audio_output, False, self.options.audio_gain) else: self.audio = None
# along with OP25; see the file COPYING. If not, write to the Free # Software Foundation, Inc., 51 Franklin Street, Boston, MA # 02110-1301, USA. import signal import sys import time from optparse import OptionParser from sockaudio import socket_audio def signal_handler(signal, frame): audiothread.stop() sys.exit(0) parser = OptionParser() parser.add_option("-O", "--audio-output", type="string", default="default", help="audio output device name") parser.add_option("--wireshark-port", type="int", default=23456, help="Wireshark port") (options, args) = parser.parse_args() if len(args) != 0: parser.print_help() sys.exit(1) audiothread = socket_audio("0.0.0.0", options.wireshark_port, options.audio_output) if __name__ == "__main__": signal.signal(signal.SIGINT, signal_handler) while True: time.sleep(1)
default=23456, help="Wireshark port") parser.add_option("-2", "--two-channel", action="store_true", default=False, help="single or two channel audio") parser.add_option("-x", "--audio-gain", type="float", default="1.0", help="audio gain (default = 1.0)") parser.add_option("-s", "--stdout", action="store_true", default=False, help="write to stdout instead of audio device") (options, args) = parser.parse_args() if len(args) != 0: parser.print_help() sys.exit(1) audio_handler = socket_audio("0.0.0.0", options.wireshark_port, options.audio_output, options.two_channel, options.audio_gain, options.stdout) if __name__ == "__main__": signal.signal(signal.SIGINT, signal_handler) audio_handler.run()
type="float", default="1.0", help="audio gain (default = 1.0)") parser.add_option("-s", "--stdout", action="store_true", default=False, help="write to stdout instead of audio device") parser.add_option("-S", "--silence", action="store_true", default=False, help="suppress output of zeros after timeout") (options, args) = parser.parse_args() if len(args) != 0: parser.print_help() sys.exit(1) audio_handler = socket_audio(options.host_ip, options.wireshark_port, options.audio_output, options.two_channel, options.audio_gain, options.stdout, silent_flag=options.silence) if __name__ == "__main__": signal.signal(signal.SIGINT, signal_handler) audio_handler.run()
help="audio output device name") parser.add_option("-u", "--wireshark-port", type="int", default=23456, help="Wireshark port") parser.add_option("-2", "--two-channel", action="store_true", default=False, help="single or two channel audio") parser.add_option("-x", "--audio-gain", type="float", default="1.0", help="audio gain (default = 1.0)") (options, args) = parser.parse_args() if len(args) != 0: parser.print_help() sys.exit(1) audiothread = socket_audio("0.0.0.0", options.wireshark_port, options.audio_output, options.two_channel, options.audio_gain) if __name__ == "__main__": signal.signal(signal.SIGINT, signal_handler) while True: time.sleep(1)
import signal import sys import time from optparse import OptionParser from sockaudio import socket_audio def signal_handler(signal, frame): audiothread.stop() sys.exit(0) parser = OptionParser() parser.add_option("-O", "--audio-output", type="string", default="default", help="audio output device name") parser.add_option("-H", "--host-ip", type="string", default="0.0.0.0", help="IP address to bind to") parser.add_option("-u", "--wireshark-port", type="int", default=23456, help="Wireshark port") parser.add_option("-2", "--two-channel", action="store_true", default=False, help="single or two channel audio") parser.add_option("-x", "--audio-gain", type="float", default="1.0", help="audio gain (default = 1.0)") (options, args) = parser.parse_args() if len(args) != 0: parser.print_help() sys.exit(1) audiothread = socket_audio(options.host_ip, options.wireshark_port, options.audio_output, options.two_channel, options.audio_gain) if __name__ == "__main__": signal.signal(signal.SIGINT, signal_handler) while True: time.sleep(1)