From b11470af5b162b6bfef7888417cd1e9734cc2592 Mon Sep 17 00:00:00 2001 From: "Joseph D. Gaeddert" Date: Fri, 8 Mar 2024 07:00:09 -0500 Subject: [PATCH] symsync: adding method to check lock state, tests --- include/liquid.h | 4 ++++ src/filter/src/symsync.proto.c | 8 ++++++- src/filter/tests/symsync_copy_autotest.c | 27 ++++++++++++++++++------ 3 files changed, 31 insertions(+), 8 deletions(-) diff --git a/include/liquid.h b/include/liquid.h index f5f2ab0ae..bbb18914f 100644 --- a/include/liquid.h +++ b/include/liquid.h @@ -4962,6 +4962,10 @@ int SYMSYNC(_lock)(SYMSYNC() _q); \ /* Unlock the symbol synchronizer's loop control */ \ int SYMSYNC(_unlock)(SYMSYNC() _q); \ \ +/* Check the lock state of the symbol synchronizer's loop control, */ \ +/* returning 1 if the object is locked, 0 if unlocked. */ \ +int SYMSYNC(_is_locked)(SYMSYNC() _q); \ + \ /* Set synchronizer output rate (samples/symbol) */ \ /* _q : synchronizer object */ \ /* _k_out : output samples/symbol, _k_out > 0 */ \ diff --git a/src/filter/src/symsync.proto.c b/src/filter/src/symsync.proto.c index 0702772f5..4a7a43bb6 100644 --- a/src/filter/src/symsync.proto.c +++ b/src/filter/src/symsync.proto.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007 - 2022 Joseph Gaeddert + * Copyright (c) 2007 - 2024 Joseph Gaeddert * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -377,6 +377,12 @@ int SYMSYNC(_unlock)(SYMSYNC() _q) return LIQUID_OK; } +// check lock state +int SYMSYNC(_is_locked)(SYMSYNC() _q) +{ + return _q->is_locked; +} + // set synchronizer output rate (samples/symbol) // _q : synchronizer object // _k_out : output samples/symbol diff --git a/src/filter/tests/symsync_copy_autotest.c b/src/filter/tests/symsync_copy_autotest.c index 5541d770a..4c304b733 100644 --- a/src/filter/tests/symsync_copy_autotest.c +++ b/src/filter/tests/symsync_copy_autotest.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007 - 2022 Joseph Gaeddert + * Copyright (c) 2007 - 2024 Joseph Gaeddert * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -85,15 +85,28 @@ void autotest_symsync_config() CONTEND_ISNULL( symsync_crcf_create(2, 12, NULL, 0) ); // h_len is too small CONTEND_ISNULL( symsync_crcf_create(2, 12, NULL, 47) ); // h_len is not divisible by M + CONTEND_ISNULL( symsync_crcf_create_kaiser(0, 12, 0.2, 48) ); // k is too small + CONTEND_ISNULL( symsync_crcf_create_kaiser(2, 0, 0.2, 48) ); // m is too small + CONTEND_ISNULL( symsync_crcf_create_kaiser(2, 12, 7.2, 48) ); // beta is too large + CONTEND_ISNULL( symsync_crcf_create_kaiser(2, 12, 0.2, 0) ); // M is too small + //CONTEND_ISNULL( symsync_crcf_create_nyquist(2, 12, NULL, 47) ); // h_len is not divisible by M - // // create valid object - // symsync_crcf q = symsync_crcf_create ... - // CONTEND_EQUALITY( LIQUID_OK, symsync_crcf_print(filter) ); + // create valid object + symsync_crcf q = symsync_crcf_create_kaiser(2, 12, 0.2, 48); + CONTEND_EQUALITY( LIQUID_OK, symsync_crcf_print(q) ); + + // check lock state + CONTEND_EQUALITY( symsync_crcf_lock(q), LIQUID_OK ); + CONTEND_TRUE ( symsync_crcf_is_locked(q) ); + CONTEND_EQUALITY( symsync_crcf_unlock(q), LIQUID_OK ); + CONTEND_FALSE ( symsync_crcf_is_locked(q) ); - // // check properties ... + // check invalid properties + CONTEND_EQUALITY( LIQUID_EICONFIG, symsync_crcf_set_output_rate(q, 0) ); + CONTEND_EQUALITY( LIQUID_EICONFIG, symsync_crcf_set_lf_bw(q, -1) ); - // // destroy object - // symsync_crcf_destroy(filter); + // destroy object + symsync_crcf_destroy(q); }