You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.

100 lines
4.0 KiB

#!/usr/bin/env python
# Copyright 2005,2006,2007 Free Software Foundation, Inc.
# GNU Radio Multichannel APCO P25 Tx (c) Copyright 2009, KA1RBI
# This file is part of GNU Radio and part of OP25
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3, or (at your option)
# any later version.
# It is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this; see the file COPYING. If not, write to
# the Free Software Foundation, Inc., 51 Franklin Street,
# Boston, MA 02110-1301, USA.
This program is used in conjunction with
When is used with its -p option (selecting UDP input),
you should start this program beforehand, to start the data flow.
import time
from gnuradio import gr, gru, audio, eng_notation, blks2, optfir
from gnuradio.eng_option import eng_option
from optparse import OptionParser
from gnuradio import repeater
class app_top_block(gr.top_block):
def __init__(self, options, queue):
gr.top_block.__init__(self, "mhp")
self.audio_amps = []
self.converters = []
self.vocoders = []
self.output_files = []
input_audio_rate = 8000
self.audio_input = audio.source(input_audio_rate, options.audio_input)
for i in range (options.nchannels):
udp_port = options.udp_port + i
if options.output_files:
t = gr.file_sink(gr.sizeof_char, "baseband-%d.dat" % i)
udp_port = 0
t = gr.multiply_const_ff(32767 * options.audio_gain)
t = gr.float_to_short()
t = repeater.vocoder(True, # 0=Decode,True=Encode
options.verbose, # Verbose flag
options.stretch, # flex amount
options.udp_addr, # udp ip address
udp_port, # udp port or zero
False) # dump raw u vectors
for i in range (options.nchannels):
self.connect((self.audio_input, i), self.audio_amps[i], self.converters[i], self.vocoders[i])
if options.output_files:
self.connect(self.vocoders[i], self.output_files[i])
def main():
parser = OptionParser(option_class=eng_option)
parser.add_option("-a", "--udp-addr", type="string", default="", help="destination host IP address")
parser.add_option("-g", "--audio-gain", type="eng_float", default=1.0, help="gain factor")
parser.add_option("-n", "--nchannels", type="int", default=2, help="number of audio channels")
parser.add_option("-o", "--output-files", action="store_true", default=False, help="write P25 symbols to output files instead of UDP")
parser.add_option("-p", "--udp-port", type="int", default=2525, help="destination host port")
parser.add_option("-v", "--verbose", action="store_true", default=False, help="dump demodulation data")
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("-S", "--stretch", type="int", default=0)
(options, args) = parser.parse_args()
queue = gr.msg_queue()
tb = app_top_block(options, queue)
while 1:
if not queue.empty_p():
sys.stderr.write("main: q.delete_head()\n")
msg = queue.delete_head()
except KeyboardInterrupt:
if __name__ == "__main__":