Ejemplo n.º 1
0
 def demodulate(self, samples):
     if self.demodtype == "envelope":
         demod_samples = demodulate.envelope(samples, self.fc, self.config)
     elif self.demodtype == "het":
         demod_samples = demodulate.heterodyne(samples, self.fc, self.config)
     elif self.demodtype == "quad":
         demod_samples = demodulate.quadrature(samples, self.fc, self.config)
     else:
         print 'Unsupported demodulation scheme'
         sys.exit(1)
     if self.filtertype == "avg":
         return demodulate.avgfilter(demod_samples, self.fc, self.config)
     elif self.filtertype == "sinc":
         return demodulate.lpfilter(demod_samples, self.fc, self.config)
     else:
         print 'Unsupported filter: %s' % self.filtertype
         sys.exit(1)
Ejemplo n.º 2
0
    try:
        samples_rx = channel.xmit_and_recv(mod_samples)
    except ZeroDivisionError:
        # should only happen for audio channel
        print "I didn't get any samples; is your microphone or speaker OFF?"
        print "Please turn them on!"
        sys.exit(1)

    if opt.demod == 'quad':
        plot_sig_spectrum(numpy.real(samples_rx), 'modulated samples')
        p.show()
        demod = demodulate.quadrature(samples_rx, opt.channel[0], opt)
        if opt.filter == 'sinc':
            plot_sig_spectrum(numpy.real(demod), 'demodulated samples')
        else:
            filtered = demodulate.avgfilter(demod, opt.channel[0], opt)
            plot_sig_spectrum(numpy.real(filtered), 'demodulated samples filtered by averaging')
        p.show()
    # process the received samples
    for fc in channels:
        # make receiver
        #r = ReceiverClass(opt.ktype, fc, opt.changap, opt.samplerate, opt.spb, opt.demod, preamble)
        r = ReceiverClass(opt, fc, preamble)
        rcdbits, softinfo, snr, demod_samples, hist_samples, offset = r.recv(samples_rx)
        # push into sink
        sink = Sink(r, opt.header, src[fc].srctype)
        if opt.fname is not None:
            rcd_payload = sink.process(rcdbits, softinfo, src[fc].fname)
        else:
            rcd_payload = sink.process(rcdbits, softinfo)
    
Ejemplo n.º 3
0
    try:
        samples_rx = channel.xmit_and_recv(mod_samples)
    except ZeroDivisionError:
        # should only happen for audio channel
        print "I didn't get any samples; is your microphone or speaker OFF?"
        print "Please turn them on!"
        sys.exit(1)

    if opt.demod == 'quad':
        plot_sig_spectrum(numpy.real(samples_rx), 'modulated samples')
        p.show()
        demod = demodulate.quadrature(samples_rx, opt.channel[0], opt)
        if opt.filter == 'sinc':
            plot_sig_spectrum(numpy.real(demod), 'demodulated samples')
        else:
            filtered = demodulate.avgfilter(demod, opt.channel[0], opt)
            plot_sig_spectrum(numpy.real(filtered),
                              'demodulated samples filtered by averaging')
        p.show()
    # process the received samples
    for fc in channels:
        # make receiver
        #r = ReceiverClass(opt.ktype, fc, opt.changap, opt.samplerate, opt.spb, opt.demod, preamble)
        r = ReceiverClass(opt, fc, preamble)
        rcdbits, softinfo, snr, demod_samples, hist_samples, offset = r.recv(
            samples_rx)
        # push into sink
        sink = Sink(r, opt.header, src[fc].srctype)
        if opt.fname is not None:
            rcd_payload = sink.process(rcdbits, softinfo, src[fc].fname)
        else: