#!/usr/bin/env python # # Copyright 2005,2006,2007,2009 Free Software Foundation, Inc. # # This file is part of GNU Radio # # GNU Radio is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 3, or (at your option) # any later version. # # GNU Radio is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with GNU Radio; see the file COPYING. If not, write to # the Free Software Foundation, Inc., 51 Franklin Street, # Boston, MA 02110-1301, USA. # from gnuradio import gr, gru, modulation_utils from gnuradio import usrp from gnuradio import eng_notation from gnuradio.eng_option import eng_option from optparse import OptionParser import random import struct import sys import time import binascii # from current dir import usrp_receive_path import operator # from current dir import usrp_transmit_path import usrp_receive_path #import os #print os.getpid() #raw_input('Attach and press enter') class my_top_block(gr.top_block): def __init__(self, modulator, demodulator, rx_callback, options): gr.top_block.__init__(self) self.rxpath = usrp_receive_path.usrp_receive_path(demodulator, rx_callback, options) self.txpath = usrp_transmit_path.usrp_transmit_path(modulator, options) self.connect(self.rxpath) self.connect(self.txpath) # ///////////////////////////////////////////////////////////////////////////// # main # ///////////////////////////////////////////////////////////////////////////// global n_rcvd, n_right def main(): global n_rcvd, n_right, re, a, l, coun def send_pkt(payload='', eof=False): return tb.txpath.send_pkt(payload, eof) def carrier_sensed(self): """ Return True if the receive path thinks there's carrier """ return self.rxpath.carrier_sensed() a=0 n_rcvd=0 n_right=0 coun=l=0 def rx_callback(ok, payload): global n_rcvd, n_right, coun, l (ide,pktno,) = struct.unpack('!cH', payload[0:3]) n_rcvd += 1 if ok: n_right += 1 print "ok = %5s pktno = %4d n_rcvd = %4d n_right = %4d ide=%1c" % ( ok, pktno, n_rcvd, n_right, ide) if(ide == 'a' or ide == 'c'): print("payload=",payload) a =ord(payload[3:options.size]) abin=bin(a)[2:] FILE1.write(payload[3:options.size]) #a=ord(payload[2:options.size]) print ('a = ' , a) print('abin=',abin) x =ord('a') #print('x=b=', x) t= operator.xor(a,x) #print("t=", t) tbin= bin(t)[2:] #print('tbin= ',tbin) i=0 l=len(abin)+l while i