# should only happen for audio channel print "I didn't get any samples; is your microphone or speaker OFF?" sys.exit(1) ################################# # process the received samples # make receiver r = Receiver(fc, opt.samplerate, opt.spb) demod_samples = r.demodulate(samples_rx) one, zero, thresh = r.detect_threshold(demod_samples) barker_start = r.detect_preamble(demod_samples, thresh, one) rcdbits = r.demap_and_check(demod_samples, barker_start) # push into sink sink = Sink() rcd_payload = sink.process(rcdbits) if len(rcd_payload) > 0: hd, err = common_srcsink.hamming(rcd_payload, src_payload) print 'Hamming distance for payload at frequency', fc,'Hz:', hd, 'BER:', err else: print 'Could not recover transmission.' if opt.graph: len_mod = len(mod_samples) - opt.spb*opt.silence len_demod = len_mod - opt.spb*(len(src_payload) - len(rcd_payload)) plot_graphs(mod_samples, samples_rx[barker_start:], demod_samples[barker_start:barker_start + len_demod], opt.spb, src.srctype, opt.silence)
# should only happen for audio channel print "I didn't get any samples; is your microphone or speaker OFF?" sys.exit(1) ################################# # process the received samples # make receiver r = Receiver(fc, opt.samplerate, opt.spb) demod_samples = r.demodulate(samples_rx) one, zero, thresh = r.detect_threshold(demod_samples) barker_start = r.detect_preamble(demod_samples, thresh, one) rcdbits = r.demap_and_check(demod_samples, barker_start) decoded_bits = r.decode(rcdbits) # push into sink sink = Sink() rcd_payload = sink.process(decoded_bits) if len(rcd_payload) > 0: hd, err = common_srcsink.hamming(decoded_bits, databits) print 'Hamming distance for payload at frequency', fc,'Hz:', hd, 'BER:', err else: print 'Could not recover transmission.' if opt.graph: len_mod = len(mod_samples) - opt.spb*opt.silence len_demod = len_mod - opt.spb*(len(src_payload) - len(rcd_payload)) plot_graphs(mod_samples, samples_rx[barker_start:], demod_samples[barker_start:barker_start + len_demod], opt.spb, src.srctype, opt.silence)
# should only happen for audio channel print "I didn't get any samples; is your microphone or speaker OFF?" sys.exit(1) ################################# # process the received samples # make receiver r = Receiver(fc, opt.samplerate, opt.spb) demod_samples = r.demodulate(samples_rx) one, zero, thresh = r.detect_threshold(demod_samples) barker_start = r.detect_preamble(demod_samples, thresh, one) rcdbits = r.demap_and_check(demod_samples, barker_start) decoded_bits = r.decode(rcdbits) # push into sink sink = Sink() rcd_payload = sink.process(databits)#sink.process(decoded_bits) if len(rcd_payload) > 0: hd, err = common_srcsink.hamming(decoded_bits, databits) print 'Hamming distance for payload at frequency', fc,'Hz:', hd, 'BER:', err else: print 'Could not recover transmission.' if opt.graph: len_mod = len(mod_samples) - opt.spb*opt.silence len_demod = len_mod - opt.spb*(len(src_payload) - len(rcd_payload)) plot_graphs(mod_samples, samples_rx[barker_start:], demod_samples[barker_start:barker_start + len_demod], opt.spb, src.srctype, opt.silence)
a, b, c = sou.process() srcbits = sink.process(c) # #testArr = np.array([1, 1, 1, 0, 0, 0, 0, 0]) # testArr = sou.text2bits("testfiles/Time.txt") # statistics_bits, encoded_bits = sou.huffman_encode(testArr) # print len(encoded_bits) # print "Encoded bits", encoded_bits # print # sink = Sink(1) # srcbits = sink.huffman_decode(encoded_bits, statistics_bits) # text = sink.bits2text(srcbits) # print # print # print text # print # print print print hamming(srcbits, a)
except ZeroDivisionError: # should only happen for audio channel print "I didn't get any samples; is your microphone or speaker OFF?" sys.exit(1) ################################# # process the received samples # make receiver r = Receiver(fc, opt.samplerate, opt.spb) demod_samples = r.demodulate(samples_rx) one, zero, thresh = r.detect_threshold(demod_samples) barker_start = r.detect_preamble(demod_samples, thresh, one) rcdbits = r.demap_and_check(demod_samples, barker_start) # push into sink sink = Sink() rcd_payload = sink.process(rcdbits) if len(rcd_payload) > 0: hd, err = common_srcsink.hamming(rcd_payload, src_payload) print 'Hamming distance for payload at frequency', fc, 'Hz:', hd, 'BER:', err else: print 'Could not recover transmission.' if opt.graph: len_mod = len(mod_samples) - opt.spb * opt.silence len_demod = len_mod - opt.spb * (len(src_payload) - len(rcd_payload)) plot_graphs(mod_samples, samples_rx[barker_start:], demod_samples[barker_start:barker_start + len_demod], opt.spb, src.srctype, opt.silence)
print "I didn't get any samples; is your microphone or speaker OFF?" sys.exit(1) ################################# # process the received samples # make receiver r = Receiver(fc, opt.samplerate, opt.spb) demod_samples = r.demodulate(samples_rx) one, zero, thresh = r.detect_threshold(demod_samples) barker_start = r.detect_preamble(demod_samples, thresh, one) rcdbits = r.demap_and_check(demod_samples, barker_start) if opt.cc_len!=0: rcdbits = r.decode(rcdbits) # push into sink sink = Sink(opt.compress) sink_bits = sink.process(rcdbits) if len(sink_bits) > 0: hd, err = common_srcsink.hamming(sink_bits, src_bits) print 'Hamming distance for payload at frequency', fc,'Hz:', hd, 'BER:', err else: print 'Could not recover transmission.' if opt.graph: len_mod = len(mod_samples) - opt.spb*opt.silence len_demod = len_mod - opt.spb*(len(src_payload) - len(rcd_payload)) plot_graphs(mod_samples, samples_rx[barker_start:], demod_samples[barker_start:barker_start + len_demod], opt.spb, src.srctype, opt.silence)
sys.exit(1) ################################# # process the received samples # make receiver r = Receiver(fc, opt.samplerate, opt.spb) demod_samples = r.demodulate(samples_rx) one, zero, thresh = r.detect_threshold(demod_samples) barker_start = r.detect_preamble(demod_samples, thresh, one) rcdbits = r.demap_and_check(demod_samples, barker_start) if opt.cc_len != 0: rcdbits = r.decode(rcdbits) # push into sink sink = Sink(opt.compress, opt.encrypt) sink_bits = sink.process(rcdbits, pubkey) if len(sink_bits) > 0: hd, err = common_srcsink.hamming(sink_bits, src_bits) print 'Hamming distance for payload at frequency', fc, 'Hz:', hd, 'BER:', err else: print 'Could not recover transmission.' if opt.graph: len_mod = len(mod_samples) - opt.spb * opt.silence len_demod = len_mod - opt.spb * (len(src_payload) - len(rcd_payload)) plot_graphs(mod_samples, samples_rx[barker_start:], demod_samples[barker_start:barker_start + len_demod], opt.spb, src.srctype, opt.silence)