diff --git a/blocksatcli/satip.py b/blocksatcli/satip.py index afc402f..120a708 100644 --- a/blocksatcli/satip.py +++ b/blocksatcli/satip.py @@ -80,14 +80,20 @@ def _assert_addr(self): raise RuntimeError("Sat-IP device address must be discovered or " "informed first") - def set_dvbs2_params(self, info, target_modcod): - """Set the DVB-S2 and MPEG TS parameters of the target stream""" + def set_dvbs2_params(self, info, target_modcod, freq_corr): + """Set the DVB-S2 and MPEG TS parameters of the target stream + + Args: + info (dict): User info dictionary. + target_modcod (str): Target MODCOD. + freq_corr (float): Frequency correction in MHz. + """ modcod = _parse_modcod(target_modcod) pilots = 'on' if defs.pilots else 'off' sym_rate = defs.sym_rate[info['sat']['alias']] self.params = { 'src': 1, - 'freq': info['sat']['dl_freq'], + 'freq': info['sat']['dl_freq'] + freq_corr, 'pol': info['sat']['pol'].lower(), 'ro': defs.rolloff, 'msys': 'dvbs2', @@ -452,7 +458,8 @@ def _find_serving_frontend(self, active_frontends): except ValueError: continue - if fe_freq == self.params['freq'] and fe_pol == self.params['pol']: + if fe_freq == round(self.params['freq'], 2) and \ + fe_pol == self.params['pol']: candidate_frontends.append(fe) # If there is only one matching frontend, it's got to be ours. @@ -659,6 +666,10 @@ def subparser(subparsers): metavar='', help="DVB-S2 modulation and coding (MODCOD) scheme. " "Choose from: " + ", ".join(defs.modcods.keys())) + p.add_argument('--freq-corr', + default=0, + type=float, + help='Carrier frequency offset correction in kHz') p.add_argument('-u', '--username', default=DEFAULT_USERNAME, @@ -761,7 +772,8 @@ def launch(args): return # Tuning parameters - sat_ip.set_dvbs2_params(info, args.modcod) + freq_corr_mhz = args.freq_corr / 1e3 + sat_ip.set_dvbs2_params(info, args.modcod, freq_corr_mhz) url = "http://" + sat_ip.host + "/?" + urlencode(sat_ip.params) # Run tsp diff --git a/blocksatcli/standalone.py b/blocksatcli/standalone.py index 585177c..85d4450 100644 --- a/blocksatcli/standalone.py +++ b/blocksatcli/standalone.py @@ -381,13 +381,19 @@ def print_demod_config(self): print("- {}: {}".format(label, val)) return True - def configure(self, info): - """Configure the S400""" + def configure(self, info, freq_corr): + """Configure the S400 + + Args: + info (dict): User info dictionary. + freq_corr (float): Frequency correction in MHz. + + """ logger.info("Configuring the S400 receiver at {} via SNMP".format( self.address)) # Local parameters - l_band_freq = int(info['freqs']['l_band'] * 1e6) + l_band_freq = int((info['freqs']['l_band'] + freq_corr) * 1e6) lo_freq = int(info['freqs']['lo'] * 1e6) sym_rate = defs.sym_rate[info['sat']['alias']] if (info['lnb']['pol'].lower() == "dual" @@ -519,6 +525,10 @@ def subparser(subparsers): action='store_true', default=False, help="Print all commands but do not execute them") + p1.add_argument('--freq-corr', + default=0, + type=float, + help='Carrier frequency offset correction in kHz') p1.set_defaults(func=cfg_standalone) # Monitoring @@ -588,7 +598,8 @@ def cfg_standalone(args): if (not args.host_only): util.print_header("Receiver Configuration") s400 = S400Client(args.demod, rx_ip_addr, args.port, dry=args.dry_run) - s400.configure(user_info) + freq_corr_mhz = args.freq_corr / 1e3 + s400.configure(user_info, freq_corr_mhz) def monitor(args):