From ddec5132dc6770b277be28c2926be4b2672f2df2 Mon Sep 17 00:00:00 2001 From: Sam Stenvall Date: Mon, 24 Jun 2024 14:19:27 +0300 Subject: [PATCH] Fix determining "hiband" for linear LNBs --- src/adapter.c | 6 +++--- tests/test_adapter.c | 51 ++++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 52 insertions(+), 5 deletions(-) diff --git a/src/adapter.c b/src/adapter.c index 73412312cc..105465821f 100644 --- a/src/adapter.c +++ b/src/adapter.c @@ -1214,9 +1214,9 @@ int mark_pids_add(int sid, int aid, char *pids) { int get_lnb_hiband(transponder *tp, diseqc *diseqc_param) { if (tp->pol > 2 && diseqc_param->lnb_circular > 0) return 0; - if (tp->freq < diseqc_param->lnb_switch) - return 0; - return 1; + if (diseqc_param->lnb_switch > 0 && tp->freq > diseqc_param->lnb_switch) + return 1; + return 0; } int get_lnb_int_freq(transponder *tp, diseqc *diseqc_param) { diff --git a/tests/test_adapter.c b/tests/test_adapter.c index 20641c195a..e0f690dc52 100644 --- a/tests/test_adapter.c +++ b/tests/test_adapter.c @@ -27,7 +27,22 @@ #include #include -int test_get_lnb_hiband() { +int test_get_lnb_hiband_universal() { + transponder tp; + diseqc diseqc_param = { + .lnb_low = 9750000, + .lnb_high = 10600000, + .lnb_switch = 11700000 + }; + + tp.freq = 10778000; + int hiband = get_lnb_hiband(&tp, &diseqc_param); + ASSERT(hiband == 0, "Universal LNB hiband parsed incorrectly"); + + tp.freq = 12322000; + hiband = get_lnb_hiband(&tp, &diseqc_param); + ASSERT(hiband == 1, "Universal LNB hiband parsed incorrectly"); + return 0; } @@ -50,6 +65,21 @@ int test_get_lnb_int_freq_universal() { return 0; } +int test_get_lnb_hiband_kuband() { + transponder tp; + diseqc diseqc_param = { + .lnb_low = 10750000, + .lnb_high = 0, + .lnb_switch = 0, + }; + + tp.freq = 12267000; + int hiband = get_lnb_hiband(&tp, &diseqc_param); + ASSERT(hiband == 0, "Ku-band LNB hiband parsed incorrectly"); + + return 0; +} + int test_get_lnb_int_freq_kuband() { transponder tp; diseqc diseqc_param = { @@ -65,6 +95,21 @@ int test_get_lnb_int_freq_kuband() { return 0; } +int test_get_lnb_hiband_cband() { + transponder tp; + diseqc diseqc_param = { + .lnb_low = 5150000, + .lnb_high = 0, + .lnb_switch = 0, + }; + + tp.freq = 3773000; + int hiband = get_lnb_hiband(&tp, &diseqc_param); + ASSERT(hiband == 0, "C-band LNB hiband parsed incorrectly"); + + return 0; +} + int test_get_lnb_int_freq_cband() { transponder tp; diseqc diseqc_param = { @@ -90,9 +135,11 @@ int main() { 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_hiband_universal(), "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_hiband_kuband(), "test get_lnb_hiband with Ku-band linear 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_hiband_cband(), "test get_lnb_hiband with C-band linear LNB parameters"); TEST_FUNC(test_get_lnb_int_freq_cband(), "test get_lnb_int_freq with C-band LNB parameters"); return 0;