📄 test_snr.c
字号:
/*************************************************************************** test_snr.c - Module for testing the SNR-module ------------------- begin : 2003-03-24 authors : ineiti emails : linus.gasser@epfl.ch ***************************************************************************//*************************************************************************** Changes ------- date - name - description 03/08/x - ineiti - start 04/03/03 - ineiti - added a small comment **************************************************************************//*************************************************************************** * * * 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. * * * ***************************************************************************/char desc[] ="Description:\n""So that we can compare the SNR of the matched filter with a 'real'\n""calculated by-hand SNR, we wrote this test-chain. The output\n""is once for QAM and then rotated-by-pi/4 QAM and shows the comparison\n""of the 'calculated-by-hand' with the 'matched-filter' SNR. Usually,\n""both should be within 1/2 dB of SNR, due to the small lenght of\n""the matched filter.\n\n";#include "spc.h"#include "std.h"#define DBG_LVL 4struct chain_t *test_chain, *test_chain_2;void *start_it( void *arg ) { int i, type; swr_sdb_id rnd, rnd2, mafi, snr_rcv, snr_send, mid, block; test_chain = swr_chain_create( NEW_SPC_VAR( "random", rnd ), NEW_SPC_VAR( "snr_send", snr_send ), NEW_SPC_VAR( "midamble", mid ), NEW_SPC( "rrc" ), NEW_SPC_VAR( "block", block ), NEW_SPC_VAR( "matched_filter", mafi ), NEW_SPC_VAR( "snr_rcv", snr_rcv ), CHAIN_END ); test_chain_2 = swr_chain_create( NEW_SPC_VAR( "random", rnd2 ), OLD_SPC_IN( snr_rcv, 1 ), CHAIN_END ); // Make both rnd-chains the same swr_sdb_set_config_int( rnd, "seed", 0x1234 ); swr_sdb_set_config_int( rnd2, "seed", 0x1234 ); swr_sdb_set_config_int( block, "size", 6000 ); // Adjust the amplitudes swr_sdb_set_config_int( snr_send, "amplitude", 16384 / 4 ); swr_sdb_set_config_int( mid, "amplitude", 16384 / 4 ); PR( "Comparing SNR_midamble to SNR_module\n" ); for ( type = 0; type < 2; type ++ ) { PR( "Type: %i\n", type ); swr_sdb_set_config_int( snr_rcv, "type", type ); swr_sdb_set_config_int( snr_send, "type", type ); for ( i=0; i<50; i+=5 ) { swr_sdb_set_config_double( block, "sigma", i ); swr_sdb_send_msg( rnd, SUBS_MSG_USER, NULL, -1 ); swr_sdb_send_msg( rnd2, SUBS_MSG_USER, NULL, -1 ); PR( "Amp: %3i:%3i, Noise: %5i:%-5i SNR : %5.5g - %5.5g = %5.5g\n", swr_sdb_get_stats_int( mafi, "mid_amp" ), swr_sdb_get_stats_int( snr_rcv, "amp" ), swr_sdb_get_stats_int( mafi, "noise_var" ), swr_sdb_get_stats_int( snr_rcv, "var" ), swr_sdb_get_stats_double( mafi, "snr" ), swr_sdb_get_stats_double( snr_rcv, "snr" ), swr_sdb_get_stats_double( mafi, "snr" ) - swr_sdb_get_stats_double( snr_rcv, "snr" ) ); } } return 0;}swr_spc_id_t spm_id;struct thread start;/** * This function is called upon "insmod" and is used to register the * different parts of the module to the SPM. */int um_module_init(void) { PR_CL( desc ); test_chain = NULL; if ( swr_thread_init( &start, start_it, NULL ) < 0 ) goto first_no_stack; return 0;first_no_stack: PR_DBG( 0, "Couldn't allocate stack\n" ); return -1;}void um_module_exit( void ) { swr_thread_free( &start, NULL ); swr_chain_destroy( test_chain_2 ); swr_chain_destroy( test_chain );}module_init( um_module_init );module_exit( um_module_exit );
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -