diff --git a/op25/gr-op25_repeater/apps/scope.py b/op25/gr-op25_repeater/apps/scope.py index 641afbf..9162db0 100755 --- a/op25/gr-op25_repeater/apps/scope.py +++ b/op25/gr-op25_repeater/apps/scope.py @@ -119,6 +119,7 @@ class p25_rx_block (stdgui2.std_top_block): 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="plughw:0,0", help="audio output device name") + parser.add_option("-q", "--freq-corr", type="eng_float", default=0.0, help="frequency correction") (options, args) = parser.parse_args() if len(args) != 0: parser.print_help() @@ -151,6 +152,9 @@ class p25_rx_block (stdgui2.std_top_block): rates = self.src.get_sample_rates() print 'supported sample rates %d-%d step %d' % (rates.start(), rates.stop(), rates.step()) + if options.freq_corr: + self.src.set_freq_corr(options.freq_corr) + if options.audio: self.channel_rate = 48000 self.baseband_input = True @@ -306,7 +310,7 @@ class p25_rx_block (stdgui2.std_top_block): self.lo_freq += self.options.calibration self.lo = analog.sig_source_c (channel_rate, analog.GR_SIN_WAVE, self.lo_freq, 1.0, 0) self.mixer = blocks.multiply_cc() - lpf_coeffs = filter.firdes.low_pass(1.0, self.channel_rate, 12000, 1200, filter.firdes.WIN_HANN) + lpf_coeffs = filter.firdes.low_pass(1.0, self.channel_rate, 15000, 1500, filter.firdes.WIN_HANN) self.lpf = filter.fir_filter_ccf(1, lpf_coeffs) self.to_real = blocks.complex_to_real() @@ -699,9 +703,21 @@ class p25_rx_block (stdgui2.std_top_block): def change_freq(self, params): freq = params['freq'] offset = params['offset'] + center_freq = params['center_frequency'] if self.options.hamlib_model: self.hamlib.set_freq(freq) + elif params['center_frequency']: + relative_freq = center_freq - freq + if relative_freq + self.options.offset > self.channel_rate / 2: + print '***unable to tune Local Oscillator to offset %d Hz' % (relative_freq + self.options.offset) + print '***limit is one half of sample-rate %d = %d' % (self.channel_rate, self.channel_rate / 2) + print '***request for frequency %d rejected' % freq + + self.lo_freq = self.options.offset + relative_freq + self.lo.set_frequency(self.lo_freq + self.myform['freq_tune'].get_value()) + self.set_freq(center_freq + offset) + #self.spectrum.set_baseband_freq(center_freq) else: self.set_freq(freq + offset) @@ -764,7 +780,8 @@ class p25_rx_block (stdgui2.std_top_block): the result of that operation and our target_frequency to determine the value for the digital down converter. """ - r = self.src.set_center_freq(target_freq + self.options.calibration + self.options.offset) + tune_freq = target_freq + self.options.calibration + self.options.offset + r = self.src.set_center_freq(tune_freq) if r: #self.myform['freq'].set_value(target_freq) # update displayed va diff --git a/op25/gr-op25_repeater/apps/trunking.py b/op25/gr-op25_repeater/apps/trunking.py index 73489b5..96a7036 100644 --- a/op25/gr-op25_repeater/apps/trunking.py +++ b/op25/gr-op25_repeater/apps/trunking.py @@ -36,6 +36,12 @@ def crc16(dat,len): # slow version crc = crc ^ 0xffff return crc +def get_frequency(f): # return frequency in Hz + if f.find('.') == -1: # assume in Hz + return int(f) + else: # assume in MHz due to '.' + return int(float(f) * 1000000) + class trunked_system (object): def __init__(self, debug=0, config=None): self.debug = debug @@ -68,6 +74,7 @@ class trunked_system (object): self.offset = config['offset'] self.sysname = config['sysname'] self.trunk_cc = config['cclist'][0] # TODO: scan thru list + self.center_frequency = config['center_frequency'] def to_string(self): s = [] @@ -407,12 +414,9 @@ class rx_ctl (object): def setup_config(self, configs): for nac in configs: - self.configs[nac] = {'cclist':[], 'offset':0, 'whitelist':None, 'blacklist':{}, 'tgid_map':{}, 'sysname': configs[nac]['sysname']} + self.configs[nac] = {'cclist':[], 'offset':0, 'whitelist':None, 'blacklist':{}, 'tgid_map':{}, 'sysname': configs[nac]['sysname'], 'center_frequency': None} for f in configs[nac]['control_channel_list'].split(','): - if f.find('.') == -1: # assume in Hz - self.configs[nac]['cclist'].append(int(f)) - else: # assume in MHz due to '.' - self.configs[nac]['cclist'].append(int(float(f) * 1000000)) + self.configs[nac]['cclist'].append(get_frequency(f)) if 'offset' in configs[nac]: self.configs[nac]['offset'] = int(configs[nac]['offset']) if 'modulation' in configs[nac]: @@ -431,6 +435,8 @@ class rx_ctl (object): tgid = int(row[0]) txt = row[1] self.configs[nac]['tgid_map'][tgid] = txt + if 'center_frequency' in configs[nac]: + self.configs[nac]['center_frequency'] = get_frequency(configs[nac]['center_frequency']) self.add_trunked_system(nac) @@ -572,7 +578,7 @@ class rx_ctl (object): self.current_tgid = None if new_frequency: - self.set_frequency({'freq': new_frequency, 'tgid': self.current_tgid, 'offset': tsys.offset, 'tag': tsys.get_tag(self.current_tgid), 'nac': nac, 'system': tsys.sysname}) + self.set_frequency({'freq': new_frequency, 'tgid': self.current_tgid, 'offset': tsys.offset, 'tag': tsys.get_tag(self.current_tgid), 'nac': nac, 'system': tsys.sysname, 'center_frequency': tsys.center_frequency}) if new_state: self.current_state = new_state