From cac311da272dc0607979d7f8ad85c62a52fb80aa Mon Sep 17 00:00:00 2001 From: tvoid Date: Fri, 4 Apr 2008 00:25:27 -0600 Subject: tvoid working copy as of 2008-04-03 --- gsm-tvoid/src/lib/gsm_burst.h | 72 +++++++++++++++++++++++++++++++++---------- 1 file changed, 56 insertions(+), 16 deletions(-) (limited to 'gsm-tvoid/src/lib/gsm_burst.h') diff --git a/gsm-tvoid/src/lib/gsm_burst.h b/gsm-tvoid/src/lib/gsm_burst.h index 951cef2..15566a9 100755 --- a/gsm-tvoid/src/lib/gsm_burst.h +++ b/gsm-tvoid/src/lib/gsm_burst.h @@ -6,9 +6,10 @@ // everything but I/O & clocking & sync_state? // What about handling complex&diff&bin data? -#include +#include "gsm_constants.h" #include -#include "gsmstack.h" +//#include //for callback testing +#include //Console printing options #define PRINT_NOTHING 0x00000000 @@ -16,9 +17,10 @@ #define PRINT_BITS 0x00000001 #define PRINT_ALL_BITS 0x00000002 #define PRINT_CORR_BITS 0x00000004 +#define PRINT_STATE 0x00000008 #define PRINT_ALL_TYPES 0x00000FF0 -#define PRINT_KNOWN 0x00000008 +#define PRINT_KNOWN 0x00000FE0 #define PRINT_UNKNOWN 0x00000010 #define PRINT_TS0 0x00000020 #define PRINT_FCCH 0x00000040 @@ -26,6 +28,8 @@ #define PRINT_DUMMY 0x00000100 #define PRINT_NORMAL 0x00000200 +#define PRINT_HEX 0x00001000 + //Timing/clock options #define QB_NONE 0x00000000 #define QB_QUARTER 0x00000001 //only for internal clocked versions @@ -46,7 +50,7 @@ // G T D1 TS D2 T G // Start ^ -#define MAX_SYNC_WAIT 176 //Bursts between SCH before reverting to WAIT_FCCH. (TODO: 88 should be max?) +#define MAX_SYNC_WAIT 32 //Number of missed bursts before reverting to WAIT_FCCH. #define MAX_CORR_DIST 7 // 4 + 3 = 1/2 GUARD + TAIL #define SCH_CORR_THRESHOLD 0.80 @@ -65,13 +69,28 @@ enum EQ_TYPE { EQ_VITERBI }; +//typedef void (*PSTAT_FUNC)(int, void *); +//#define STAT_GOT_BURST 1 +//double gr_feval_callback(gr_feval_dd *f, double x); + +/* +class gsm_tuner_callback { +protected: + virtual void tune(double x); + +public: + virtual void do_tune(double x); +}; +*/ +//void do_tuner_callback(gsm_tuner_callback *t, double f); + class gsm_burst; class gsm_burst { protected: - gsm_burst(); + gsm_burst(gr_feval_dd *t); //Burst Buffer: Storage for burst data float d_burst_buffer[BBUF_SIZE]; @@ -80,29 +99,37 @@ protected: unsigned long d_sample_count; //sample count at end (TODO:beginning) of BBUF (bit count if external clock) unsigned long d_last_burst_s_count; //sample count from previous burst + unsigned char d_decoded_burst[USEFUL_BITS]; //Differentially Decoded burst buffer {0,1} + ///// Sync/training sequence correlation - //TODO: need all sync patterns float corr_sync[N_SYNC_BITS]; //encoded sync bits for correlation float corr_train_seq[10][N_TRAIN_BITS]; -// float d_corr[50]; const float *d_corr_pattern; int d_corr_pat_size; float d_corr_max; int d_corr_maxpos; int d_corr_center; - ///// GSM Stack - GS_CTX d_gs_ctx; - ///// Burst information SYNC_STATE d_sync_state; + SYNC_STATE d_last_sync_state; BURST_TYPE d_burst_type; unsigned d_ts; //timeslot 0-7 + unsigned long d_last_good; //Burst count of last good burst unsigned long d_burst_count; //Bursts received starting w/ initial FCCH reset after lost sync unsigned long d_last_sch; //Burst count of last SCH - float d_freq_offset; int d_color_code; + float d_freq_offset; + double d_freq_off_sum; + double d_freq_off_weight; + + //PSTAT_FUNC p_stat_func; + //void *stat_func_data; + + gr_feval_dd *p_tuner; + //gsm_tuner_callback *p_tuner; + //////// Methods int get_burst(void); BURST_TYPE get_fcch_burst(void); @@ -113,18 +140,31 @@ protected: void calc_freq_offset(void); void equalize(void); float correlate_pattern(const float *,const int,const int,const int); + void diff_decode_burst(void); + + void sync_reset(void); void print_bits(const float *data,int length); - void soft2hardbit(char *dst, const float *data, int len); + void print_hex(const unsigned char *data,int length); void print_burst(void); void diff_encode(const float *in,float *out,int length,float lastbit = 1.0); void diff_decode(const float *in,float *out,int length,float lastbit = 1.0); - public: ~gsm_burst (); + //Set status callback function, needed for quick tune() + //void py_set_status_callback(PyObject *pyfunc); + //void set_status_callback(PSTAT_FUNC func, void *clientdata); + + //void set_tuner_callback(gr_feval_dd *t); + + //use swig directors to privide a python override + //virtual void notify_status(int status); + + //void set_tuner_callback(gsm_tuner_callback *f); + ////// General Stats //TODO: Maybe there should be a burst_stats class? long d_sync_loss_count; @@ -141,11 +181,11 @@ public: EQ_TYPE d_equalizer_type; int sync_state() { return d_sync_state;} - float freq_offset() {return d_freq_offset;} + float last_freq_offset() {return d_freq_offset;} + double mean_freq_offset(void); //Methods - //TODO: reset state (e.g. channel change) - //void reset(void); + void full_reset(void); }; -- cgit v1.2.3