Skip to content

Commit

Permalink
symsync: adding method to check lock state, tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jgaeddert committed Mar 8, 2024
1 parent e77b1a8 commit b11470a
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 8 deletions.
4 changes: 4 additions & 0 deletions include/liquid.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 */ \
Expand Down
8 changes: 7 additions & 1 deletion src/filter/src/symsync.proto.c
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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
Expand Down
27 changes: 20 additions & 7 deletions src/filter/tests/symsync_copy_autotest.c
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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);
}

0 comments on commit b11470a

Please sign in to comment.