Skip to content

Commit

Permalink
satip/s400: Support carrier freq offset correction
Browse files Browse the repository at this point in the history
It is not unusual to have an LNB with LO frequency offset exceeding the
regular DVB-S2's coarse frequency offset estimation range. Hence, in
some cases, it is preferable to tune to a center frequency with a fixed
offset relative to the nominal value. This patch adds such an option
(named --freq-corr) on the satip and standalone receiver commands. With
the sat-ip receiver, the frequency correction has to be specified every
time on the launch command (blocksat-cli sat-ip). Meanwhile, with the
standalone demodulator (Novra S400), it has to be specified once on the
configuration step (blocksat-cli standalone cfg).
  • Loading branch information
blockstreamsatellite committed May 30, 2022
1 parent fdfbf28 commit 5ab7279
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 9 deletions.
22 changes: 17 additions & 5 deletions blocksatcli/satip.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand Down
19 changes: 15 additions & 4 deletions blocksatcli/standalone.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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):
Expand Down

0 comments on commit 5ab7279

Please sign in to comment.