📄 test_synch_ms.c
字号:
/*************************************************************************** synch_test_ms.c - SRadio testing of synchronisation - MS ------------------- begin : 2002 authors : Linus Gasser emails : linus.gasser@epfl.ch ***************************************************************************//*************************************************************************** Changes ------- date - name - description 02-10-16 - ineiti- begin 02-12-18 - ineiti - split up in MS and BS part **************************************************************************//*************************************************************************** * * * 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. * * * ***************************************************************************//** * Make a small little chain with the synch */#include "system.h"#include "spc.h"#include "antenna.h"#include "std.h"#include "stfa.h"#define ANTENNA 0#define DBG_LVL 4struct chain_t *test;int spf;#define MAX_SYNCH 15swr_sdb_id stfa, synch_rcv[ MAX_SLOTS ], energy[ MAX_SLOTS ];/* * The main thread, where the chain is set up and either * a synchronisation-signal is sent, or it waits for one. */void *start_it( void *arg ) { int en, max_en, max_pos, max_slot; int i, j, s; stfa = swr_sdb_instantiate_name( "stfa" ); // For a MS we do an energy-module on each stfa-output and // on each energy-module a synch_rcvroniser spf = swr_sdb_get_stats_int( stfa, "slots_per_frame" ); PR( "Slots per frame: %i\n", spf ); swr_memory_show(); for ( i=0; i<spf; i++ ) { swr_chain_create( 2, OLD_SPC_OUT( stfa, i ), NEW_SPC_VAR( "energy", energy[i] ) ); } for ( i=0; i<MAX_SYNCH; i++ ) { PR_DBG( 0, "Setting up connection energy[%i]->synch_rcv[%i]\n", MAX_SYNCH - i - 1, i ); swr_chain_create( 2, OLD_SPC( energy[ MAX_SYNCH - i - 1 ] ), NEW_SPC_VAR( "synch_rcv", synch_rcv[i] ) ); } PR( "Setting gains and starting\n" ); swr_stfa_go( stfa ); swr_ant_set_gains( ANTENNA, 0, 0 ); for ( s=0; s < 1; s++ ) { for ( i=0; i < 8192; i++ ) { usleep( 10000 ); max_en = max_pos = max_slot = 0; if ( !( i % 16 ) ) { for ( j=0; j < MAX_SYNCH; j++ ) { en = swr_sdb_get_stats_int( synch_rcv[j], "synch_amp" ); if ( en > max_en ) { max_en = en; max_pos = swr_sdb_get_stats_int( synch_rcv[j], "synch_pos" ); max_slot = j; } } PR_DBG( 4, "max=%i at pos %i in slot %i\n", max_en, max_pos, max_slot ); for ( j=0; j < spf; j++ ) { en = swr_sdb_get_stats_int( energy[ j ], "energy" ); PR_DBG( 4, "energy[%i] = %i\n", j, en ); } } } } usleep( 200000 ); PR_DBG( 4, "Stopping the STFA\n" ); swr_stfa_stop( stfa ); return 0;}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) { if ( swr_thread_init( &start, start_it, NULL ) ) { goto rrc_no_thread; } return 0;rrc_no_thread: PR_DBG( 0, "Couldn't init thread\n" ); return -1;}void um_module_exit( void ) { int i; swr_thread_free( &start, NULL ); PR_DBG( 0, "deleting synch and stfa\n" ); swr_memory_show(); swr_sdb_destroy( stfa ); for ( i=0; i < spf; i++ ) { swr_sdb_destroy( energy[i] ); swr_sdb_destroy( synch_rcv[i] ); }}module_init( um_module_init );module_exit( um_module_exit );EXPORT_SYMBOL(start_it);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -