Exemple #1
0
def testSdr():
    sdr = rtlsdr.RtlSdr()
    
    radioQ = Queue.Queue()
    Qout = Queue.Queue()

    initRtlSdr(sdr, 105.3e6, 2.4e5, 22)
    getSamplesAsync(sdr, radioQ)
    
    p = pyaudio.PyAudio()
   
    play_t = threading.Thread( target = play_audio, args = (Qout, p, 48000.0) )
    play_t.start()
    
    dem = Demodulator(2.4e5, 80000.0, 48000.0, 16000.0)

    while(True):
       
        data = radioQ.get()
        audio = dem.fm_demodulate(data)
        #spectrogram(audio)
        Qout.put(audio)
Exemple #2
0
def testSdr():
    sdr = rtlsdr.RtlSdr()

    radioQ = Queue.Queue()
    Qout = Queue.Queue()

    initRtlSdr(sdr, 105.3e6, 2.4e5, 22)
    getSamplesAsync(sdr, radioQ)

    p = pyaudio.PyAudio()

    play_t = threading.Thread(target=play_audio, args=(Qout, p, 48000.0))
    play_t.start()

    dem = Demodulator(2.4e5, 80000.0, 48000.0, 16000.0)

    while (True):

        data = radioQ.get()
        audio = dem.fm_demodulate(data)
        #spectrogram(audio)
        Qout.put(audio)
Exemple #3
0
def main():

    fs_out = 44100.0
    fs_in = fs_out  #48000.0
    channel = 432.079e6

    sync_pulse = genSyncPulse2(4000, 1200,
                               t=.02)  # make sure t*fs < chunk size (1024)
    start_stop_pulse = genSyncPulse2(2400, 1200, t=.02)

    radioQ = Queue.Queue()
    Qin = Queue.Queue()
    Qout = Queue.Queue()

    sdr = rtlsdr.RtlSdr()
    initRtlSdr(sdr, channel, 2.4e5, 32)
    getSamplesAsync(sdr, radioQ)

    tx_data = np.random.randint(0, 2, 1000)

    transmission = np.append(
        tx_intro(fs_out),
        tx_fsk(tx_data, fs_out, 1200, 2400, 2, .01, 200, sync_pulse,
               start_stop_pulse))
    #transmission = tx_fsk(data, fs_out, 1200, 2400, 2, .005, 200, sync_pulse, start_stop_pulse)

    p = pyaudio.PyAudio()
    din, dout, dusbin, dusbout = audioDevNumbers(p)

    tx_t = threading.Thread(target=play_audio, args=(Qout, p, fs_out, dusbout))
    tx_t.start()
    Qout.put(transmission)

    play_t = threading.Thread(target=play_audio, args=(Qin, p, fs_in, dout))
    play_t.start()

    dem = Demodulator(2.4e5, 16000.0, fs_in, 4000.0)
    dec = Decoder(1200, 2400, 2, .01, sync_pulse, start_stop_pulse, 200, fs_in)

    data = radioQ.get()
    audio = dem.fm_demodulate(data)
    Qin.put(audio)  # play the incomming signal

    while (True):

        rx_signal = radioQ.get()
        audio = dem.fm_demodulate(rx_signal)
        #audio *= 2
        Qin.put(audio)  # play the incomming signal

        if (dec.process(audio)):
            break

    rx_data = dec.rec_data

    print tx_data[:20]
    print rx_data[:20]

    print np.sum(np.equal(tx_data, rx_data)) / 1000

    for i in range(400):
        if (tx_data[i] != rx_data[i]):
            print(i),

    p.terminate()
    sdr.close()
Exemple #4
0
def main():

   fs_out = 44100.0
   fs_in = fs_out #48000.0
   channel = 432.079e6

   sync_pulse = genSyncPulse2(4000, 1200,t=.02)        # make sure t*fs < chunk size (1024)
   start_stop_pulse = genSyncPulse2(2400, 1200, t=.02)

   radioQ = Queue.Queue()
   Qin = Queue.Queue()
   Qout = Queue.Queue()

   sdr = rtlsdr.RtlSdr()
   initRtlSdr(sdr, channel, 2.4e5, 32)
   getSamplesAsync(sdr, radioQ)

   tx_data = np.random.randint(0, 2, 1000)

   transmission = np.append(tx_intro(fs_out), tx_fsk(tx_data, fs_out, 1200, 2400, 2, .01, 200, sync_pulse, start_stop_pulse))
   #transmission = tx_fsk(data, fs_out, 1200, 2400, 2, .005, 200, sync_pulse, start_stop_pulse)

   p = pyaudio.PyAudio()
   din, dout, dusbin, dusbout = audioDevNumbers(p)
   
   tx_t = threading.Thread(target=play_audio, args = (Qout, p, fs_out, dusbout))
   tx_t.start()
   Qout.put(transmission)

   play_t = threading.Thread(target = play_audio, args = (Qin, p, fs_in, dout))
   play_t.start()

   dem = Demodulator(2.4e5,16000.0, fs_in, 4000.0)
   dec = Decoder(1200, 2400, 2, .01, sync_pulse, start_stop_pulse, 200, fs_in)

   data = radioQ.get()
   audio = dem.fm_demodulate(data)
   Qin.put(audio) # play the incomming signal

   while(True):
        
       rx_signal = radioQ.get()
       audio = dem.fm_demodulate(rx_signal)
       #audio *= 2
       Qin.put(audio) # play the incomming signal

       if(dec.process(audio)):
           break
    
   rx_data = dec.rec_data

   print tx_data[:20]
   print rx_data[:20]
   
   print np.sum(np.equal(tx_data, rx_data))/1000

   for i in range(400):
       if (tx_data[i] != rx_data[i]):
           print(i),

   p.terminate()
   sdr.close()