Skip to content

Commit

Permalink
Fix determining "hiband" for linear LNBs
Browse files Browse the repository at this point in the history
  • Loading branch information
Jalle19 committed Jun 24, 2024
1 parent e049643 commit 99cbc43
Show file tree
Hide file tree
Showing 2 changed files with 52 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 @@ -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) {
Expand Down
51 changes: 49 additions & 2 deletions tests/test_adapter.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,22 @@
#include <string.h>
#include <linux/dvb/frontend.h>

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;
}

Expand All @@ -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 = {
Expand All @@ -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 = {
Expand All @@ -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;
Expand Down

0 comments on commit 99cbc43

Please sign in to comment.