summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPiotr Krysik <perper@o2.pl>2009-06-13 19:31:43 +0200
committerPiotr Krysik <perper@o2.pl>2009-06-13 19:31:43 +0200
commit46b8adbe2aaeccd7f4d0f700aaa3e1c097be202a (patch)
tree6298bfabe48791bc3c4a89ee76d78216e612c88d
parentc473876ed253c3c70143991e35f9faa9c34c6290 (diff)
added new file for usrp realtime receive - caution - this doesn't work well yet
-rw-r--r--src/lib/gsm_constants.h2
-rw-r--r--src/lib/gsm_receiver_cf.cc16
-rw-r--r--src/lib/gsm_receiver_cf.h2
-rwxr-xr-xsrc/python/gsm_findfcch_usrp.py122
4 files changed, 15 insertions, 127 deletions
diff --git a/src/lib/gsm_constants.h b/src/lib/gsm_constants.h
index 3f7ef04..1ebce1c 100644
--- a/src/lib/gsm_constants.h
+++ b/src/lib/gsm_constants.h
@@ -33,6 +33,8 @@
#define CHAN_IMP_RESP_LENGTH 5
+#define MAX_SCH_ERRORS 2 //maximum number of subsequent sch errors after which gsm receiver goes to find_next_fcch state
+
typedef enum {empty, fcch_burst, sch_burst, normal_burst, rach_burst, dummy} burst_type;
typedef enum {unknown, multiframe_26, multiframe_51} multiframe_type;
diff --git a/src/lib/gsm_receiver_cf.cc b/src/lib/gsm_receiver_cf.cc
index 7f91fa8..0fde642 100644
--- a/src/lib/gsm_receiver_cf.cc
+++ b/src/lib/gsm_receiver_cf.cc
@@ -55,10 +55,10 @@ void gsm_receiver_cf::process_normal_burst(burst_counter burst_nr, const unsigne
void gsm_receiver_cf::configure_receiver()
{
d_channel_conf.set_multiframe_type(TSC0, multiframe_51);
-
+
d_channel_conf.set_burst_types(TSC0, TEST_CCH_FRAMES, sizeof(TEST_CCH_FRAMES) / sizeof(unsigned), normal_burst);
d_channel_conf.set_burst_types(TSC0, FCCH_FRAMES, sizeof(FCCH_FRAMES) / sizeof(unsigned), fcch_burst);
-
+
// d_channel_conf.set_multiframe_type(TIMESLOT6, multiframe_26);
// d_channel_conf.set_burst_types(TIMESLOT6, TRAFFIC_CHANNEL_F, sizeof(TRAFFIC_CHANNEL_F) / sizeof(unsigned), normal_burst);
}
@@ -94,7 +94,8 @@ gsm_receiver_cf::gsm_receiver_cf(gr_feval_dd *tuner, int osr)
d_fcch_start_pos(0),
d_freq_offset(0),
d_state(first_fcch_search),
- d_burst_nr(osr)
+ d_burst_nr(osr),
+ d_failed_sch(0)
{
int i;
gmsk_mapper(SYNC_BITS, N_SYNC_BITS, d_sch_training_seq, gr_complex(0.0, -1.0));
@@ -102,7 +103,7 @@ gsm_receiver_cf::gsm_receiver_cf(gr_feval_dd *tuner, int osr)
for (i = 0; i < TRAIN_SEQ_NUM; i++) {
gmsk_mapper(train_seq[i], N_TRAIN_BITS, d_norm_training_seq[i], gr_complex(1.0, 0.0));
}
-
+
/* Initialize GSM Stack */
GS_new(&d_gs_ctx); //TODO: remove it! it'a not right place for a decoder
}
@@ -218,10 +219,16 @@ gsm_receiver_cf::general_work(int noutput_items,
detect_burst(input, &channel_imp_resp[0], burst_start, output_binary); //MLSE detection of bits
if (decode_sch(&output_binary[3], &t1, &t2, &t3, &d_ncc, &d_bcc) == 0) { //and decode SCH data
// d_burst_nr.set(t1, t2, t3, 0); //but only to check if burst_start value is correct
+ d_failed_sch = 0;
DCOUT("bcc: " << d_bcc << " ncc: " << d_ncc << " t1: " << t1 << " t2: " << t2 << " t3: " << t3);
offset = burst_start - floor((GUARD_PERIOD) * d_OSR); //compute offset from burst_start - burst should start after a guard period
DCOUT(offset);
to_consume += offset; //adjust with offset number of samples to be consumed
+ } else {
+ d_failed_sch++;
+ if(d_failed_sch >= MAX_SCH_ERRORS){
+ d_state = next_fcch_search;
+ }
}
}
break;
@@ -680,6 +687,5 @@ int gsm_receiver_cf::get_norm_chan_imp_resp(const gr_complex *input, gr_complex
//std::cout << " burst_start: " << burst_start << " center: " << ((float)(search_start_pos + strongest_window_nr + chan_imp_resp_center)) / d_OSR << " stronegest window nr: " << strongest_window_nr << "\n";
return burst_start;
-
}
diff --git a/src/lib/gsm_receiver_cf.h b/src/lib/gsm_receiver_cf.h
index af13618..c37813a 100644
--- a/src/lib/gsm_receiver_cf.h
+++ b/src/lib/gsm_receiver_cf.h
@@ -96,6 +96,8 @@ class gsm_receiver_cf : public gr_block
channel_configuration d_channel_conf; ///< mapping of burst_counter to burst_type
//@}
+ unsigned d_failed_sch; ///< number of subsequent erroneous SCH bursts
+
// GSM Stack
GS_CTX d_gs_ctx;//TODO: remove it! it'a not right place for a decoder
diff --git a/src/python/gsm_findfcch_usrp.py b/src/python/gsm_findfcch_usrp.py
deleted file mode 100755
index 7bf81f3..0000000
--- a/src/python/gsm_findfcch_usrp.py
+++ /dev/null
@@ -1,122 +0,0 @@
-#!/usr/bin/env python
-#!/usr/bin/env python
-
-from gnuradio import gr, gru, blks2
-from gnuradio import usrp
-#from gnuradio import gsm
-from gnuradio.eng_option import eng_option
-from optparse import OptionParser
-from os import sys
-#"""
-for extdir in ['../../debug/src/lib','../../debug/src/lib/.libs']:
- if extdir not in sys.path:
- sys.path.append(extdir)
-import gsm
-#"""
-def pick_subdevice(u):
- if u.db[0][0].dbid() >= 0:
- return (0, 0)
- if u.db[1][0].dbid() >= 0:
- return (1, 0)
- return (0, 0)
-
-class gsm_receiver_first_blood(gr.top_block):
- def __init__(self):
- gr.top_block.__init__(self)
- ( self.options, self.args) = self._przetworz_opcje()
- self._ustaw_taktowanie()
- self.zrodlo = self._ustaw_zrodlo()
- self.filtr = self._ustaw_filtr()
- self.interpolator = self._ustaw_interpolator()
- self.odbiornik = self._ustaw_odbiornik()
- self.konwerter = self._ustaw_konwerter()
- self.ujscie = self._ustaw_ujscie()
-
- self.connect(self.zrodlo, self.filtr, self.interpolator, self.odbiornik, self.konwerter, self.ujscie)
-# self.connect(self.zrodlo, self.ujscie)
-
- def _ustaw_ujscie(self):
- nazwa_pliku_wy = self.options.outputfile
- ujscie = gr.file_sink(gr.sizeof_float, nazwa_pliku_wy)
- return ujscie
-
- def _ustaw_zrodlo(self):
- options = self.options
- fusb_block_size = gr.prefs().get_long('fusb', 'block_size', 4096)
- fusb_nblocks = gr.prefs().get_long('fusb', 'nblocks', 16)
- self.usrp = usrp.source_c(decim_rate=options.decim, fusb_block_size=fusb_block_size, fusb_nblocks=fusb_nblocks)
-
- if options.rx_subdev_spec is None:
- options.rx_subdev_spec = pick_subdevice(self.usrp)
-
- self.usrp.set_mux(usrp.determine_rx_mux_value(self.usrp, options.rx_subdev_spec))
- # determine the daughterboard subdevice
- self.subdev = usrp.selected_subdev(self.usrp, options.rx_subdev_spec)
- input_rate = self.usrp.adc_freq() / self.usrp.decim_rate()
-
- # set initial values
- if options.gain is None:
- # if no gain was specified, use the mid-point in dB
- g = self.subdev.gain_range()
- options.gain = float(g[0]+g[1])/2
-
- r = self.usrp.tune(0, self.subdev, options.freq)
- self.subdev.set_gain(options.gain)
- return self.usrp
-
- def _ustaw_taktowanie(self):
- options = self.options
- clock_rate = 64e6
- self.clock_rate = clock_rate
- self.input_rate = clock_rate / options.decim
- self.gsm_symb_rate = 1625000.0 / 6.0
- self.sps = self.input_rate / self.gsm_symb_rate
-
- def _ustaw_filtr(self):
- filter_cutoff = 145e3
- filter_t_width = 10e3
- offset = 0
- print "input_rate:", self.input_rate, "sample rate:", self.sps, " filter_cutoff:", filter_cutoff, " filter_t_width:", filter_t_width
- filter_taps = gr.firdes.low_pass(1.0, self.input_rate, filter_cutoff, filter_t_width, gr.firdes.WIN_HAMMING)
- filtr = gr.freq_xlating_fir_filter_ccf(1, filter_taps, offset, self.input_rate)
- return filtr
-
- def _ustaw_konwerter(self):
- v2s = gr.vector_to_stream(gr.sizeof_float, 142)
- return v2s
-
- def _ustaw_interpolator(self):
- interpolator = gr.fractional_interpolator_cc(0, self.sps)
- return interpolator
-
- def _ustaw_odbiornik(self):
- odbiornik = gsm.receiver_cf(1)
- return odbiornik
-
- def _przetworz_opcje(self):
- parser = OptionParser(option_class=eng_option)
- parser.add_option("-d", "--decim", type="int", default=128,
- help="Set USRP decimation rate to DECIM [default=%default]")
- parser.add_option("-I", "--inputfile", type="string", default="cfile",
- help="Input filename")
- parser.add_option("-O", "--outputfile", type="string", default="cfile2.out",
- help="Output filename")
- parser.add_option("-R", "--rx-subdev-spec", type="subdev", default=None,
- help="Select USRP Rx side A or B (default=first one with a daughterboard)")
- parser.add_option("-f", "--freq", type="eng_float", default="950.4M",
- help="set frequency to FREQ", metavar="FREQ")
- parser.add_option("-g", "--gain", type="eng_float", default=None,
- help="Set gain in dB (default is midpoint)")
- (options, args) = parser.parse_args ()
- return (options, args)
-
-def main():
- try:
- gsm_receiver_first_blood().run()
- except KeyboardInterrupt:
- pass
-
-if __name__ == '__main__':
- main()
-
-
personal git repositories of Harald Welte. Your mileage may vary