Exemple #1
0
    def __init__(self, options, args):
        gr.top_block.__init__(self)

        self.options = options
        self.args = args

        frekvens = options.freq

        # u = usrp.source_c(0)
        # u.set_decim_rate(256)
        # subdev_spec = (1,0)
        # u.set_mux(usrp.determine_rx_mux_value(u,subdev_spec))
        # subdev = usrp.selected_subdev(u,subdev_spec)
        # subdev.set_auto_tr(True)
        # subdev.set_gain(57)
        # usrp.tune(u,0,subdev,frekvens)#106.3e6)
        # samplerate = 64000000/256 # 250000
        self.u = uhd.usrp_source("", uhd.io_type_t.COMPLEX_FLOAT32, 1)
        self.u.set_subdev_spec("")
        # default should be good?
        self.u.set_samp_rate(250e3)
        samplerate = self.u.get_samp_rate()  # Retrieve what it actually does
        self.u.set_antenna("RX2", 0)

        if options.gain is None:  # set to halfway
            g = self.u.get_gain_range()
            options.gain = (g.start() + g.stop()) / 2.0

        if not (self.u.set_center_freq(frekvens, 0)):
            print "Failed to set frequency"
            sys.exit(1)

        print "Setting gain to %i" % options.gain
        self.u.set_gain(options.gain)

        coeffs = gr.firdes.low_pass(1, samplerate, 10000, 10000)
        filter = gr.fir_filter_ccf(5, coeffs)
        gang = gr.multiply_const_ff(10)

        lpcoeffs = gr.firdes.low_pass(1, samplerate, 8000, 3000)
        lpfilter = gr.fir_filter_fff(1, lpcoeffs)
        demod = gr.quadrature_demod_cf(0.5)

        clockrec = gr.clock_recovery_mm_ff(
            float(samplerate) / 5 / 9600, 0.25 * 0.175 * 0.175, 0.5, 0.175,
            0.005)
        #datadec = ais.ais_decoder_mysql("localhost","diverse","aisblock","elgelg")
        self.datadec = ais.ais_decoder_gearth(30003)

        slicer = gr.binary_slicer_fb()
        diff = gr.diff_decoder_bb(2)
        invert = ais.invert10_bb()
        # print subdev.name()
        self.connect(self.u, filter, demod, lpfilter, gang, clockrec, slicer,
                     diff, invert, self.datadec)
Exemple #2
0
    def __init__(self, options, args):
        gr.top_block.__init__(self)

        self.options = options
        self.args = args

        frekvens = options.freq

        # u = usrp.source_c(0)
        # u.set_decim_rate(256)
        # subdev_spec = (1,0)
        # u.set_mux(usrp.determine_rx_mux_value(u,subdev_spec))
        # subdev = usrp.selected_subdev(u,subdev_spec)
        # subdev.set_auto_tr(True)
        # subdev.set_gain(57)
        # usrp.tune(u,0,subdev,frekvens)#106.3e6)
        # samplerate = 64000000/256 # 250000
        self.u = uhd.usrp_source("", uhd.io_type_t.COMPLEX_FLOAT32,1)
        self.u.set_subdev_spec("");   # default should be good?
        self.u.set_samp_rate(250e3);
        samplerate = self.u.get_samp_rate() # Retrieve what it actually does
        self.u.set_antenna("RX2",0)

        if options.gain is None: # set to halfway
            g = self.u.get_gain_range()
            options.gain = (g.start()+g.stop()) / 2.0

        if not(self.u.set_center_freq(frekvens, 0)):
            print "Failed to set frequency"
            sys.exit(1)

        print "Setting gain to %i" % options.gain
        self.u.set_gain(options.gain)

        coeffs = gr.firdes.low_pass(1,samplerate,10000,10000)
        filter = gr.fir_filter_ccf(5,coeffs)
        gang = gr.multiply_const_ff(10)

        lpcoeffs = gr.firdes.low_pass(1,samplerate,8000,3000)
        lpfilter = gr.fir_filter_fff(1,lpcoeffs)
        demod = gr.quadrature_demod_cf(0.5)

        clockrec = gr.clock_recovery_mm_ff(float(samplerate)/5/9600,0.25*0.175*0.175,0.5,0.175,0.005)
        #datadec = ais.ais_decoder_mysql("localhost","diverse","aisblock","elgelg")
        self.datadec = ais.ais_decoder_gearth(30003)

        slicer = gr.binary_slicer_fb()
        diff = gr.diff_decoder_bb(2)
        invert = ais.invert10_bb()
        # print subdev.name()
        self.connect(self.u,filter,demod,lpfilter,gang,clockrec,
                     slicer,diff,invert,self.datadec)
Exemple #3
0
alle.append([0,0,0,0,0,1,0,0,0,1,0,0,1,0,1,0,0,1,1,0,0,0,0,0,1,0,0,1,0,1,1,0,1,0,1,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,1,0,1,0,0,1,0,0,0,0,0,0,0,0,1,1,0,0,1,0,1,0,0,0,1,0,1,0,1,1,0,0,0,1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,1,1,0,0,1,0,1,0,0,0,0,1,1,0,1,0,1,0,0,1,1,0,0,0,1,0,1,1,0,0,0,1,1,0,0,1,0,0,0,1,1,0,0,1,1,1,1,1,1,1,1,1,1,1,0,1,1,1,1,0,0,0,0,0,0,0,0,0,1,0,0,0,0,1,1,1,0,1,1,0,1,1,0,1])
src = ais.ais_source_f(alle[0], 500, True)

dst = gr.vector_sink_f()
slice = gr.binary_slicer_fb()
diffdec = gr.diff_decoder_bb(2)
invert = ais.invert10_bb()
dst2 = gr.vector_sink_b()


gaussian_taps = gr.firdes.gaussian(1,5,0.35,100)
sqwave = (1,) * 5
taps = numpy.convolve(numpy.array(gaussian_taps),numpy.array(sqwave))
gaussian_filter = gr.interp_fir_filter_fff(5,taps)
gange = gr.multiply_const_ff(0.3)
lydut = audio.sink(9600*5,"default")
filut = gr.file_sink(gr.sizeof_float,"filut.raw")


#fg.connect(src,dst)
#fg.connect(src,slice,diffdec,invert,dst2)
fg.connect(src,gaussian_filter,gange,lydut)
Exemple #4
0
src = audio.source(samplerate, "hw:1")
pluss = gr.add_const_ff(0.0)
lpcoeffs = gr.firdes.low_pass(1, samplerate, 8000, 3000)
lpfilter = gr.fir_filter_fff(1, lpcoeffs)

forsterk = gr.multiply_const_ff(5)
clockrec = gr.clock_recovery_mm_ff(
    float(samplerate) / 9600, 0.25 * 0.175 * 0.175, 0.5, 0.175, 0.005)

slicer = gr.binary_slicer_fb()
# Parameters: ([mysql-server],[database name],[database user],[database password])
datadec = ais.ais_decoder_mysql("localhost", "diverse", "ruben", "elg")
# You should use the create_mysql.sql to create the necessary tables
# in the database.
# See create_mysql.txt for help. Those files can be found in the root folder of
# the source tree.
diff = gr.diff_decoder_bb(2)

invert = ais.invert10_bb()

fg.connect(src, pluss, lpfilter, forsterk, clockrec, slicer, diff, invert,
           datadec)

fg.start()

raw_input("Receives AIS from soundcard ")
fg.stop()
print "Received correctly: ", datadec.received()
print "Wrong CRC: ", datadec.lost()
print "Wrong Size: ", datadec.lost2()