Skip to content

Commit

Permalink
Fix determining intermediate frequency for C-band LNBs
Browse files Browse the repository at this point in the history
Closes #1146
  • Loading branch information
Jalle19 committed Jun 24, 2024
1 parent 083c647 commit f6ee02e
Show file tree
Hide file tree
Showing 4 changed files with 108 additions and 5 deletions.
6 changes: 3 additions & 3 deletions src/adapter.c
Original file line number Diff line number Diff line change
Expand Up @@ -1224,9 +1224,9 @@ int get_lnb_int_freq(transponder *tp, diseqc *diseqc_param) {

if (tp->pol > 2 && diseqc_param->lnb_circular > 0)
return (freq - diseqc_param->lnb_circular);
if (freq < diseqc_param->lnb_switch)
return (freq - diseqc_param->lnb_low);
return (freq - diseqc_param->lnb_high);
if (diseqc_param->lnb_switch > 0 && freq > diseqc_param->lnb_switch)
return (freq - diseqc_param->lnb_high);
return abs(freq - diseqc_param->lnb_low);
}

int compare_tunning_parameters(int aid, transponder *tp) {
Expand Down
7 changes: 5 additions & 2 deletions src/minisatip.c
Original file line number Diff line number Diff line change
Expand Up @@ -404,8 +404,11 @@ Help\n\
\n\
* -L --lnb specifies the adapter and LNB parameters (low, high and switch frequency)\n\
* eg: -L *:9750-10600-11700 - sets all the adapters to use Universal LNB parameters (default)\n\
* eg: -L *:10750-10750-10750 - sets the parameters for Sky NZ LNB using 10750 Mhz\n\
* eg: -L 0:10750-10750-10750,1:9750-10600-11700 - adapter 0 has a SKY NZ LNB, adapter 1 has an Universal LNB\n\
* eg: -L *:10750-0-0 - sets all adapters to use 10750 MHz Ku-band LNB parameters (e.g. Sky NZ)\n\
* eg: -L *:5150-0-0 - sets all adapters to use 5150 MHz C-band LNB parameters\n\
* eg: -L 0:10750-0-0,1:9750-10600-11700 - adapter 0 has a SKY NZ LNB, adapter 1 has an Universal LNB\n\
\n\
For backward-compatibility reasons, linear LNB parameters may also be specified as *:5150-5150-5150 instead of *:5150-0-0\n\
\n\
* -m --mac xx: simulate xx as local mac address, generates UUID based on mac\n\
* eg: -m 001122334455 \n\
Expand Down
1 change: 1 addition & 0 deletions tests/Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ else
endif

SOURCES=\
test_adapter.c \
test_opts.c \
test_ca.c \
test_pmt.c \
Expand Down
99 changes: 99 additions & 0 deletions tests/test_adapter.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
/*
* Copyright (C) 2014-2022 Catalin Toda <catalinii@yahoo.com>
*
* 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 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* USA
*
*/
#define _GNU_SOURCE

#include "adapter.h"
#include "minisatip.h"
#include "utils.h"
#include "utils/testing.h"

#include <string.h>
#include <linux/dvb/frontend.h>

int test_get_lnb_hiband() {
return 0;
}

int test_get_lnb_int_freq_universal() {
transponder tp;
diseqc diseqc_param = {
.lnb_low = 9750000,
.lnb_high = 10600000,
.lnb_switch = 11700000
};

tp.freq = 10778000;
int freq = get_lnb_int_freq(&tp, &diseqc_param);
ASSERT(freq == 1028000, "Universal LNB IF parsed incorrectly");

tp.freq = 12322000;
freq = get_lnb_int_freq(&tp, &diseqc_param);
ASSERT(freq == 1722000, "Universal LNB IF parsed incorrectly");

return 0;
}

int test_get_lnb_int_freq_kuband() {
transponder tp;
diseqc diseqc_param = {
.lnb_low = 10750000,
.lnb_high = 0,
.lnb_switch = 0,
};

tp.freq = 12267000;
int freq = get_lnb_int_freq(&tp, &diseqc_param);
ASSERT(freq == 1517000, "Ku-band LNB IF parsed incorrectly");

return 0;
}

int test_get_lnb_int_freq_cband() {
transponder tp;
diseqc diseqc_param = {
.lnb_low = 5150000,
.lnb_high = 0,
.lnb_switch = 0
};

tp.freq = 3773000;
int freq = get_lnb_int_freq(&tp, &diseqc_param);
ASSERT(freq == 1377000, "C-band LNB IF parsed incorrectly");

// Should also work with low = high = switch
diseqc_param.lnb_high = diseqc_param.lnb_switch = 5150000;
freq = get_lnb_int_freq(&tp, &diseqc_param);
ASSERT(freq == 1377000, "C-band LNB IF parsed incorrectly");

return 0;
}

int main() {
opts.log = 1;
opts.debug = 255;
strcpy(thread_info[thread_index].thread_name, "test_adapter");

TEST_FUNC(test_get_lnb_hiband(), "test test_get_lnb_hiband with universal LNB parameters");
TEST_FUNC(test_get_lnb_int_freq_universal(), "test get_lnb_int_freq with universal LNB parameters");
TEST_FUNC(test_get_lnb_int_freq_kuband(), "test get_lnb_int_freq with typical Ku-band linear LNB parameters");
TEST_FUNC(test_get_lnb_int_freq_cband(), "test get_lnb_int_freq with C-band LNB parameters");

return 0;
}

0 comments on commit f6ee02e

Please sign in to comment.