Beispiel #1
0
    def __init__(self,
                 verbosity,
                 config,
                 trunk_conf_file=None,
                 terminal_type=None,
                 track_errors=False,
                 udp_player=None):
        self.verbosity = verbosity
        gr.top_block.__init__(self)
        self.device_id_by_name = {}
        self.msg_types = {}
        self.terminal_type = terminal_type
        self.last_process_update = 0
        self.last_freq_params = {
            'freq': 0.0,
            'tgid': None,
            'tag': "",
            'tdma': None
        }
        self.trunk_rx = None
        self.track_errors = track_errors
        self.last_change_freq = 0
        self.sql_db = sql_dbi()
        self.input_q = gr.msg_queue(20)
        self.output_q = gr.msg_queue(20)
        self.last_voice_channel_id = 0
        self.terminal = op25_terminal(self.input_q, self.output_q,
                                      terminal_type)
        self.configure_devices(config['devices'])
        self.configure_channels(config['channels'])
        if trunk_conf_file:
            self.trunk_rx = trunking.rx_ctl(frequency_set=self.change_freq,
                                            debug=self.verbosity,
                                            conf_file=trunk_conf_file,
                                            logfile_workers=[],
                                            send_event=self.send_event)
        self.sinks = []
        for chan in self.channels:
            if len(chan.sinks):
                self.sinks += chan.sinks
        if self.is_http_term():
            for sink in self.sinks:
                sink.gnuplot.set_interval(_def_interval)
                sink.gnuplot.set_output_dir(_def_file_dir)

        if udp_player:
            chan = self.find_audio_channel()  # find chan used for audio
            self.audio = audio_thread("127.0.0.1", chan.audio_port,
                                      chan.audio_output, False,
                                      chan.audio_gain)
        else:
            self.audio = None
Beispiel #2
0
    def __build_graph(self, source, capture_rate):
        global speeds
        global WIRESHARK_PORT

        self.rx_q = gr.msg_queue(100)
        udp_port = 0

        if self.options.udp_player:
            self.options.vocoder = True
            self.options.wireshark = True
            self.options.wireshark_host = "127.0.0.1"

        if self.options.wireshark or (self.options.wireshark_host !=
                                      "127.0.0.1"):
            udp_port = self.options.wireshark_port

        self.tdma_state = False
        self.xor_cache = {}

        self.fft_state = False
        self.c4fm_state = False
        self.fscope_state = False
        self.corr_state = False
        self.fac_state = False
        self.fsk4_demod_connected = False
        self.psk_demod_connected = False
        self.fsk4_demod_mode = False
        self.corr_i_chan = False

        if self.baseband_input:
            self.demod = p25_demodulator.p25_demod_fb(
                input_rate=capture_rate, excess_bw=self.options.excess_bw)
        elif self.options.symbols:
            self.demod = None
        else:  # complex input
            # local osc
            self.lo_freq = self.options.offset
            if self.options.audio_if or self.options.ifile or self.options.input:
                self.lo_freq += self.options.calibration
            self.demod = p25_demodulator.p25_demod_cb(
                input_rate=capture_rate,
                demod_type=self.options.demod_type,
                relative_freq=self.lo_freq,
                offset=self.options.offset,
                if_rate=self.sps * 4800,
                gain_mu=self.options.gain_mu,
                costas_alpha=self.options.costas_alpha,
                excess_bw=self.options.excess_bw,
                symbol_rate=self.symbol_rate)

        num_ambe = 0
        if self.options.phase2_tdma:
            num_ambe = 1

        self.decoder = p25_decoder.p25_decoder_sink_b(
            dest='audio',
            do_imbe=self.options.vocoder,
            num_ambe=num_ambe,
            wireshark_host=self.options.wireshark_host,
            udp_port=udp_port,
            do_msgq=True,
            msgq=self.rx_q,
            audio_output=self.options.audio_output,
            debug=self.options.verbosity,
            nocrypt=self.options.nocrypt)

        # connect it all up
        if self.options.symbols:
            self.connect(source, self.decoder)
        else:
            self.connect(source, self.demod, self.decoder)

            if self.options.plot_mode == 'constellation':
                self.toggle_constellation()
            elif self.options.plot_mode == 'symbol':
                self.toggle_symbol()
            elif self.options.plot_mode == 'fft':
                self.toggle_fft()
            elif self.options.plot_mode == 'datascope':
                self.toggle_eye()
            elif self.options.plot_mode == 'mixer':
                self.toggle_mixer()

            if self.options.raw_symbols:
                sys.stderr.write("Saving raw symbols to file: %s\n" %
                                 self.options.raw_symbols)
                self.sink_sf = blocks.file_sink(gr.sizeof_char,
                                                self.options.raw_symbols)
                self.connect(self.demod, self.sink_sf)

        logfile_workers = []
        if self.options.phase2_tdma:
            num_ambe = 2
        if self.options.logfile_workers:
            for i in xrange(self.options.logfile_workers):
                demod = p25_demodulator.p25_demod_cb(
                    input_rate=capture_rate,
                    demod_type=self.options.demod_type,
                    offset=self.options.offset)
                decoder = p25_decoder.p25_decoder_sink_b(
                    debug=self.options.verbosity,
                    do_imbe=self.options.vocoder,
                    num_ambe=num_ambe)
                logfile_workers.append({
                    'demod': demod,
                    'decoder': decoder,
                    'active': False
                })
                self.connect(source, demod, decoder)

        self.trunk_rx = trunking.rx_ctl(frequency_set=self.change_freq,
                                        debug=self.options.verbosity,
                                        conf_file=self.options.trunk_conf_file,
                                        logfile_workers=logfile_workers,
                                        meta_update=self.meta_update)

        self.du_watcher = du_queue_watcher(self.rx_q,
                                           self.trunk_rx.process_qmsg)
Beispiel #3
0
    def __build_graph(self, source, capture_rate):
        global speeds
        global WIRESHARK_PORT

        sps = 5  # samples / symbol
        if_rate = sps * 4800

        self.rx_q = gr.msg_queue(100)
        udp_port = 0

        vocoder = self.options.vocoder
        wireshark = self.options.wireshark
        wireshark_host = self.options.wireshark_host
        if self.options.udp_player:
            vocoder = True
            wireshark = True
            wireshark_host = "127.0.0.1"

        if wireshark or (wireshark_host != "127.0.0.1"):
            udp_port = self.options.wireshark_port

        self.tdma_state = False
        self.xor_cache = {}

        if self.baseband_input:
            self.demod = p25_demodulator.p25_demod_fb(
                input_rate=capture_rate,
                excess_bw=self.options.excess_bw,
                if_rate=if_rate)
        else:  # complex input
            # local osc
            self.lo_freq = self.options.offset
            if self.options.audio_if or self.options.ifile or self.options.input:
                self.lo_freq += self.options.calibration
            self.demod = p25_demodulator.p25_demod_cb(
                input_rate=capture_rate,
                demod_type=self.options.demod_type,
                relative_freq=self.lo_freq,
                offset=self.options.offset,
                if_rate=if_rate,
                gain_mu=self.options.gain_mu,
                costas_alpha=self.options.costas_alpha,
                excess_bw=self.options.excess_bw,
                symbol_rate=self.symbol_rate)

        num_ambe = 0
        if self.options.phase2_tdma:
            num_ambe = 1

        self.decoder = p25_decoder.p25_decoder_sink_b(
            dest='audio',
            do_imbe=vocoder,
            num_ambe=num_ambe,
            wireshark_host=wireshark_host,
            udp_port=udp_port,
            do_msgq=True,
            msgq=self.rx_q,
            audio_output=self.options.audio_output,
            debug=self.options.verbosity)

        # connect it all up
        self.connect(source, self.demod, self.decoder)

        if self.baseband_input:
            sps = if_rate // 4800
        plot_modes = []
        if self.options.plot_mode is not None:
            plot_modes = self.options.plot_mode.split(',')
        for plot_mode in plot_modes:
            if plot_mode == 'constellation':
                assert self.options.demod_type == 'cqpsk'  ## constellation requires cqpsk demod-type
                sink = constellation_sink_c()
                self.plot_sinks.append(sink)
                self.demod.connect_complex('diffdec', sink)
            elif plot_mode == 'symbol':
                sink = symbol_sink_f()
                self.plot_sinks.append(sink)
                self.demod.connect_float(sink)
            elif plot_mode == 'fft':
                sink = fft_sink_c()
                self.plot_sinks.append(sink)
                self.spectrum_decim = filter.rational_resampler_ccf(
                    1, self.options.decim_amt)
                self.connect(self.spectrum_decim, sink)
                self.demod.connect_complex('src', self.spectrum_decim)
            elif plot_mode == 'mixer':
                sink = mixer_sink_c()
                self.plot_sinks.append(sink)
                self.demod.connect_complex('mixer', sink)
            elif plot_mode == 'datascope':
                assert self.options.demod_type == 'fsk4'  ## datascope requires fsk4 demod-type
                sink = eye_sink_f(sps=sps)
                self.plot_sinks.append(sink)
                self.demod.connect_bb('symbol_filter', sink)
            elif plot_mode == 'correlation':
                assert self.options.demod_type == 'fsk4'  ## correlation plot requires fsk4 demod type
                self.plot_sinks += setup_correlation(sps, "",
                                                     self.demod.connect_bb)
            else:
                raise ValueError('unsupported plot type: %s' % plot_mode)
        if self.is_http_term():
            for sink in self.plot_sinks:
                sink.gnuplot.set_interval(_def_interval)
                sink.gnuplot.set_output_dir(_def_file_dir)

        if self.options.raw_symbols:
            self.sink_sf = blocks.file_sink(gr.sizeof_char,
                                            self.options.raw_symbols)
            self.connect(self.demod, self.sink_sf)

        logfile_workers = []
        if self.options.phase2_tdma:
            num_ambe = 2
        if self.options.logfile_workers:
            for i in range(self.options.logfile_workers):
                demod = p25_demodulator.p25_demod_cb(
                    input_rate=capture_rate,
                    demod_type=self.options.demod_type,
                    offset=self.options.offset)
                decoder = p25_decoder.p25_decoder_sink_b(
                    debug=self.options.verbosity,
                    do_imbe=vocoder,
                    num_ambe=num_ambe)
                logfile_workers.append({
                    'demod': demod,
                    'decoder': decoder,
                    'active': False
                })
                self.connect(source, demod, decoder)

        self.trunk_rx = trunking.rx_ctl(frequency_set=self.change_freq,
                                        debug=self.options.verbosity,
                                        conf_file=self.options.trunk_conf_file,
                                        logfile_workers=logfile_workers)

        self.du_watcher = du_queue_watcher(self.rx_q,
                                           self.trunk_rx.process_qmsg)
Beispiel #4
0
    def __build_graph(self, source, capture_rate):
        global speeds
        global WIRESHARK_PORT
        # tell the scope the source rate

        self.rx_q = gr.msg_queue(100)
        udp_port = 0

        if self.options.udp_player or self.options.wireshark or (
                self.options.wireshark_host != "127.0.0.1"):
            udp_port = WIRESHARK_PORT

        self.tdma_state = False
        self.xor_cache = {}

        self.fft_state = False
        self.c4fm_state = False
        self.fscope_state = False
        self.corr_state = False
        self.fac_state = False
        self.fsk4_demod_connected = False
        self.psk_demod_connected = False
        self.fsk4_demod_mode = False
        self.corr_i_chan = False

        if self.baseband_input:
            self.demod = p25_demodulator.p25_demod_fb(input_rate=capture_rate)
        else:  # complex input
            # local osc
            self.lo_freq = self.options.offset + self.options.fine_tune
            if self.options.audio_if or self.options.ifile or self.options.input:
                self.lo_freq += self.options.calibration
            self.demod = p25_demodulator.p25_demod_cb(
                input_rate=capture_rate,
                demod_type=self.options.demod_type,
                relative_freq=self.lo_freq,
                offset=self.options.offset,
                if_rate=48000,
                gain_mu=self.options.gain_mu,
                costas_alpha=self.options.costas_alpha,
                symbol_rate=self.symbol_rate)

        num_ambe = 0
        if self.options.phase2_tdma:
            num_ambe = 1

        self.decoder = p25_decoder.p25_decoder_sink_b(
            dest='audio',
            do_imbe=True,
            num_ambe=num_ambe,
            wireshark_host=self.options.wireshark_host,
            udp_port=udp_port,
            do_msgq=True,
            msgq=self.rx_q,
            audio_output=self.options.audio_output,
            debug=self.options.verbosity)

        # connect it all up
        self.connect(source, self.demod, self.decoder)

        if self.options.plot_mode == 'constellation':
            assert self.options.demod_type == 'cqpsk'  ## constellation requires cqpsk demod-type
            self.constellation_sink = constellation_sink_c()
            self.demod.connect_complex('diffdec', self.constellation_sink)
            self.kill_sink = self.constellation_sink
        elif self.options.plot_mode == 'symbol':
            self.symbol_sink = symbol_sink_f()
            self.demod.connect_float(self.symbol_sink)
            self.kill_sink = self.symbol_sink
        elif self.options.plot_mode == 'fft':
            self.fft_sink = fft_sink_c()
            self.spectrum_decim = filter.rational_resampler_ccf(
                1, self.options.decim_amt)
            self.connect(self.spectrum_decim, self.fft_sink)
            self.demod.connect_complex('src', self.spectrum_decim)
            self.kill_sink = self.fft_sink
        elif self.options.plot_mode == 'datascope':
            assert self.options.demod_type == 'fsk4'  ## datascope requires fsk4 demod-type
            self.eye_sink = eye_sink_f(sps=10)
            self.demod.connect_bb('symbol_filter', self.eye_sink)
            self.kill_sink = self.eye_sink

        if self.options.raw_symbols:
            self.sink_sf = blocks.file_sink(gr.sizeof_char,
                                            self.options.raw_symbols)
            self.connect(self.demod, self.sink_sf)

        logfile_workers = []
        if self.options.phase2_tdma:
            num_ambe = 2
        if self.options.logfile_workers:
            for i in range(self.options.logfile_workers):
                demod = p25_demodulator.p25_demod_cb(
                    input_rate=capture_rate,
                    demod_type=self.options.demod_type,
                    offset=self.options.offset)
                decoder = p25_decoder.p25_decoder_sink_b(
                    debug=self.options.verbosity,
                    do_imbe=self.options.vocoder,
                    num_ambe=num_ambe)
                logfile_workers.append({
                    'demod': demod,
                    'decoder': decoder,
                    'active': False
                })
                self.connect(source, demod, decoder)

        self.trunk_rx = trunking.rx_ctl(frequency_set=self.change_freq,
                                        debug=self.options.verbosity,
                                        conf_file=self.options.trunk_conf_file,
                                        logfile_workers=logfile_workers)

        self.du_watcher = du_queue_watcher(self.rx_q,
                                           self.trunk_rx.process_qmsg)