Example #1
0
    def __init__(
        self,hop_interval,post_guard,pre_guard,tx_freq_list,rx_freq_list,lead_limit,link_bps
    ):
        """
        Inputs: complex stream from USRP, pkt in, ctrl in
        Outputs: pkt out, ctrl out
        """

        gr.block.__init__(
            self,
            name = "fhss_engine",
            in_sig = [numpy.complex64],
            out_sig = None,
            num_msg_inputs = 3,
            num_msg_outputs = 3,
        )
    
        self.mgr = pmt.pmt_mgr()
        for i in range(64):
            self.mgr.set(pmt.pmt_make_blob(10000))
        
        self.hop_interval = hop_interval
        self.post_guard = post_guard
        self.pre_guard = pre_guard
        self.lead_limit = lead_limit
        self.link_bps = link_bps
        self.tx_freq_list = map(float,tx_freq_list.split())
        self.tx_freq_list_length = len(self.tx_freq_list)
        self.rx_freq_list = map(float,tx_freq_list.split())
        self.rx_freq_list_length = len(self.tx_freq_list)
        self.hop_index = 0 
        
        self.bytes_per_slot = int( ( self.hop_interval - self.post_guard - self.pre_guard ) * self.link_bps / 8 )
        
        self.queue = Queue.Queue()                        #queue for msg destined for ARQ path
        self.tx_queue = Queue.Queue()
        
        self.last_rx_time = 0
        self.last_rx_rate = 0
        self.samples_since_last_rx_time = 0
        
        self.next_interval_start = 0
        self.next_transmit_start = 0

        self.know_time = False
        self.found_time = False
        self.found_rate = False
        self.set_tag_propagation_policy(gr_extras.TPP_DONT)    

        self.has_old_msg = False
        self.overhead = 20
        self.pad_data = numpy.zeros( ( 1, 40),dtype='uint8')[0]
        #print self.pad_data
        self.tx_slots_passed = 0
    
        self.rx_state = RX_SEARCH
        self.plkt_received = False
        self.tune_lead = 0.002
        self.rx_hop_index = 0
        self.consecutive_miss = 0
Example #2
0
    def __init__(
        self,period,key,value
    ):
        """
        The input is a pmt message blob.
        Non-blob messages will be ignored.
        The output is a byte stream for the modulator

        @param period: Time between blopbs
        @param key: String for key
        @param value: String for value
        """

		
        gr.block.__init__(
            self,
            name = "simple_mac",
            in_sig = None,
            out_sig = None,
            has_msg_input = False,
            num_msg_outputs = 1,
        )
    
        self.mgr = pmt.pmt_mgr()
        for i in range(64):
			self.mgr.set(pmt.pmt_make_blob(10000))
        self.period = period
        self.key = key
        self.value = value
Example #3
0
    def __init__(
        self,freq_list
    ):
        """
        Two msg ports in, two msg ports out
        """

        gr.block.__init__(
            self,
            name = "my_second_msg_block",
            in_sig = None,
            out_sig = None,
            num_msg_inputs = 2,
            num_msg_outputs = 2,
        )
    
        self.mgr = pmt.pmt_mgr()
        for i in range(64):
            self.mgr.set(pmt.pmt_make_blob(10000))
            
        self.freq_list = map(float,freq_list.split(','))
        self.freq_list_len = len(self.freq_list)
        print self.freq_list_len
        
        
        self.index = 0
    def __init__(
        self,
    ):
        """
        The input is a stream of bytes.
        Outputs a blob with value of current byte if it is different from last.
        """

		
        gr.block.__init__(
            self,
            name = "transition_detect",
            in_sig = [numpy.uint8],
            out_sig = None,
            has_msg_input = False,
            num_msg_outputs = 1,
            
        )
    
        self.mgr = pmt.pmt_mgr()
        for i in range(64):
			self.mgr.set(pmt.pmt_make_blob(10000))
        self.old_result = 0;
        
        self.key = pmt.pmt_string_to_symbol("example_key")
        self.value = pmt.pmt_string_to_symbol("example_value")
        self.trans_count = 0
Example #5
0
    def __init__(
        self,key
    ):
        """
        The input is a pmt message blob.
        Non-blob messages will be ignored.
        The output is pmt message blob

        @param key: String replacement for key
        """
        gr.block.__init__(
            self,
            name = "append_key",
            in_sig = None,
            out_sig = None,
            has_msg_input = True,
            num_msg_outputs = 1,
            
        )
    
        self.key = key


        self.mgr = pmt.pmt_mgr()
        for i in range(64):
			self.mgr.set(pmt.pmt_make_blob(10000))
Example #6
0
    def __init__(self, period, key, value):
        """
        The input is a pmt message blob.
        Non-blob messages will be ignored.
        The output is a byte stream for the modulator

        @param period: Time between blopbs
        @param key: String for key
        @param value: String for value
        """

        gr.block.__init__(
            self,
            name="simple_mac",
            in_sig=None,
            out_sig=None,
            has_msg_input=False,
            num_msg_outputs=1,
        )

        self.mgr = pmt.pmt_mgr()
        for i in range(64):
            self.mgr.set(pmt.pmt_make_blob(10000))
        self.period = period
        self.key = key
        self.value = value
Example #7
0
    def __init__(
        self,channel,arq
    ):
        """
        Sets the key of a blob as neccassary for simple_mac and similar blocks.
        Encodes information like destination radio addr, ARQ settings etc.
        
        Blob in, blob out.

        @param destination_addr: physical address of radio the pkt is destined for
        @param ARQ: Use ARQ or don't
       """

        gr.block.__init__(
            self,
            name = "virtual_channel_formatter",
            in_sig = None,
            out_sig = None,
            num_msg_inputs = 1,
            num_msg_outputs = 1,
        )
    
        self.mgr = pmt.pmt_mgr()
        for i in range(64):
            self.mgr.set(pmt.pmt_make_blob(10000))
        
        self.channel = channel
        self.arq = arq
    def __init__(
        self
    ):
        """
        First input is a state.
        Will hold state staticly until updated received on first input
        Will queue messages from second input.
        Will pass queued messages to output when state is '0'
       """

		
        gr.block.__init__(
            self,
            name = "channel_access_controller",
            in_sig = None,
            out_sig = None,
            num_msg_inputs = 2,
            num_msg_outputs = 1,
        )
    
        self.mgr = pmt.pmt_mgr()
        for i in range(64):
			self.mgr.set(pmt.pmt_make_blob(10000))
        
        self.q = Queue.Queue(maxsize=0)
        self.channel_state = READY
Example #9
0
    def __init__(self, hop_interval, post_guard, pre_guard, tx_freq_list,
                 lead_limit, link_bps):
        """
        Inputs: complex stream from USRP, pkt in, ctrl in
        Outputs: pkt out, ctrl out
        """

        gr.block.__init__(
            self,
            name="fhss_engine_tx",
            in_sig=[numpy.complex64],
            out_sig=None,
            num_msg_inputs=3,
            num_msg_outputs=3,
        )

        self.mgr = pmt.pmt_mgr()
        for i in range(64):
            self.mgr.set(pmt.pmt_make_blob(10000))

        self.hop_interval = hop_interval
        self.post_guard = post_guard
        self.pre_guard = pre_guard
        self.lead_limit = lead_limit
        self.link_bps = link_bps
        self.tx_freq_list = map(float, tx_freq_list.split(','))
        self.tx_freq_list_length = len(self.tx_freq_list)
        self.hop_index = 0

        self.bytes_per_slot = int(
            (self.hop_interval - self.post_guard - self.pre_guard) *
            self.link_bps / 8)

        self.queue = Queue.Queue()  #queue for msg destined for ARQ path
        self.tx_queue = Queue.Queue()

        self.last_rx_time = 0
        self.last_rx_rate = 0
        self.samples_since_last_rx_time = 0

        self.next_interval_start = 0
        self.next_transmit_start = 0

        self.know_time = False
        self.found_time = False
        self.found_rate = False
        self.set_tag_propagation_policy(gr_extras.TPP_DONT)

        self.has_old_msg = False
        self.overhead = 20
        self.pad_data = numpy.zeros((1, 1500), dtype='uint8')[0]
        #print self.pad_data
        self.tx_slots_passed = 0

        self.rx_state = RX_SEARCH
        self.plkt_received = False
        self.tune_lead = 0.003
        self.rx_hop_index = 0
        self.consecutive_miss = 0
Example #10
0
    def __init__(self, ber=0.01, bits_per_byte=1):
        gr.block.__init__(self, name='bsc' ,in_sig = None,
                          out_sig = None, num_msg_inputs = 1,
                          num_msg_outputs = 1)
        self.ber = ber
        self.bits_per_byte = bits_per_byte

        self.mgr = pmt.pmt_mgr()
        for i in range(64):
            self.mgr.set(pmt.pmt_make_blob(10000))
Example #11
0
 def __init__(self, msgq):
     gr.block.__init__(self,
                       name="_queue_to_blob",
                       in_sig=None,
                       out_sig=None,
                       num_msg_outputs=1)
     self._msgq = msgq
     self._mgr = pmt.pmt_mgr()
     for i in range(64):
         self._mgr.set(pmt.pmt_make_blob(10000))
Example #12
0
 def __init__(self, msgq):
     gr.block.__init__(
         self, name = "_queue_to_blob",
         in_sig = None, out_sig = None,
         num_msg_outputs = 1
     )
     self._msgq = msgq
     self._mgr = pmt.pmt_mgr()
     for i in range(64):
         self._mgr.set(pmt.pmt_make_blob(10000))
Example #13
0
    def __init__(self, device, parity, baudrate, stopbits, bytesize, wait_for_newline):
        """
        Serial port w/ blobs in and out
        """

        gr.block.__init__(self, name="serial_port", in_sig=None, out_sig=None, num_msg_inputs=1, num_msg_outputs=1)

        self.mgr = pmt.pmt_mgr()
        for i in range(64):
            self.mgr.set(pmt.pmt_make_blob(10000))

        self.device = device
        self.parity = parity
        self.baudrate = baudrate
        self.stopbits = stopbits
        self.bytesize = bytesize
        self.wait_for_newline = wait_for_newline

        # set parity

        if self.parity == NONE:
            self.parity = serial.PARITY_NONE
        elif self.parity == EVEN:
            self.parity = serial.PARITY_EVEN
        else:
            self.parity = serial.PARITY_ODD

        if self.stopbits == STOPBITS_ONE:
            self.stopbits = serial.STOPBITS_ONE
        elif self.stopbits == STOPBITS_TWO:
            self.stopbits = serial.STOPBITS_TWO

        if self.bytesize == WORD_SIZE_7:
            self.bytesize = serial.SEVENBITS
        else:
            self.bytesize = serial.EIGHTBITS

        # configure the serial connections (the parameters differs on the device you are connecting to)

        self.ser = serial.Serial(
            port=self.device, baudrate=self.baudrate, parity=self.parity, stopbits=self.stopbits, bytesize=self.bytesize
        )

        """
        self.ser = serial.Serial(
            port=self.device,
            baudrate=self.baudrate,
            parity=serial.PARITY_NONE,
            stopbits=serial.STOPBITS_ONE,
            bytesize=serial.EIGHTBITS
        )
        """
        print "Opened: ", self.ser.portstr  # check which port was really used
        self.ser.write("hel;lkfsdsa;lkfjdsaflo\n\r")  # write a string
Example #14
0
    def __init__(self, initial_slot, slot_interval, guard_interval, num_slots,
                 lead_limit, link_bps):
        """
        Inputs: complex stream from USRP, pkt in, ctrl in
        Outputs: pkt out, ctrl out
        """

        gr.block.__init__(
            self,
            name="tdma_engine",
            in_sig=[numpy.complex64],
            out_sig=None,
            num_msg_inputs=3,
            num_msg_outputs=2,
        )

        self.mgr = pmt.pmt_mgr()
        for i in range(64):
            self.mgr.set(pmt.pmt_make_blob(10000))

        self.initial_slot = initial_slot
        self.slot_interval = slot_interval
        self.guard_interval = guard_interval
        self.num_slots = num_slots
        self.lead_limit = lead_limit
        self.link_bps = link_bps

        self.bytes_per_slot = int(
            (self.slot_interval - self.guard_interval) * self.link_bps / 8)

        self.queue = Queue.Queue()  #queue for msg destined for ARQ path
        self.tx_queue = Queue.Queue()

        self.last_rx_time = 0
        self.last_rx_rate = 0
        self.samples_since_last_rx_time = 0

        self.next_interval_start = 0
        self.next_transmit_start = 0

        self.know_time = False
        self.found_time = False
        self.found_rate = False
        self.set_tag_propagation_policy(extras_swig.TPP_DONT)

        self.has_old_msg = False
        self.overhead = 15
        self.pad_data = numpy.fromstring(
            'this idsaf;lkjkfdjsd;lfjs;lkajskljf;klajdsfk', dtype='uint8')
        self.tx_slots_passed = 0
Example #15
0
    def __init__(
        self,initial_slot,slot_interval,guard_interval,num_slots,lead_limit,link_bps
    ):
        """
        Inputs: complex stream from USRP, pkt in, ctrl in
        Outputs: pkt out, ctrl out
        """

        gr.block.__init__(
            self,
            name = "tdma_engine",
            in_sig = [numpy.complex64],
            out_sig = None,
            num_msg_inputs = 3,
            num_msg_outputs = 2,
        )
    
        self.mgr = pmt.pmt_mgr()
        for i in range(64):
            self.mgr.set(pmt.pmt_make_blob(10000))
        
        self.initial_slot = initial_slot
        self.slot_interval = slot_interval
        self.guard_interval = guard_interval
        self.num_slots = num_slots
        self.lead_limit = lead_limit
        self.link_bps = link_bps
        
        self.bytes_per_slot = int( ( self.slot_interval - self.guard_interval ) * self.link_bps / 8 )
        
        self.queue = Queue.Queue()                        #queue for msg destined for ARQ path
        self.tx_queue = Queue.Queue()
        
        self.last_rx_time = 0
        self.last_rx_rate = 0
        self.samples_since_last_rx_time = 0
        
        self.next_interval_start = 0
        self.next_transmit_start = 0

        self.know_time = False
        self.found_time = False
        self.found_rate = False
        self.set_tag_propagation_policy(extras_swig.TPP_DONT)

        self.has_old_msg = False
        self.overhead = 15
        self.pad_data = numpy.fromstring('this idsaf;lkjkfdjsd;lfjs;lkajskljf;klajdsfk',dtype='uint8')
        self.tx_slots_passed = 0
Example #16
0
    def __init__(self, ):
        """
        Two msg ports in, two msg ports out
        """

        gr.block.__init__(
            self,
            name="my_first_msg_block",
            in_sig=None,
            out_sig=None,
            num_msg_inputs=2,
            num_msg_outputs=2,
        )

        self.mgr = pmt.pmt_mgr()
        for i in range(64):
            self.mgr.set(pmt.pmt_make_blob(10000))
Example #17
0
    def __init__(
        self,addr,timeout,max_attempts
    ):
        """
        three inputs: radio, from_app, ctrl_in
        Three outputs: radio, to_app, ctrl_out

        """

        
        gr.block.__init__(
            self,
            name = "simple_mac",
            in_sig = None,
            out_sig = None,
            num_msg_inputs = 3,
            num_msg_outputs = 3,
        )
    
        self.mgr = pmt.pmt_mgr()
        for i in range(64):
            self.mgr.set(pmt.pmt_make_blob(10000))
        
        self.addr = addr                                #MAC's address
        
        self.pkt_cnt_arq = 0                            #pkt_cnt for arq channel
        self.pkt_cnt_no_arq = 0                            #pkt_cnt for non_arq channel
        
        self.arq_expected_sequence_number = 0            #keep track for sequence error detection
        self.no_arq_expected_sequence_number = 0        #keep track for sequence error detection

        self.arq_sequence_error_cnt = 0                    #arq channel seq errors - VERY BAD
        self.no_arq_sequence_error_cnt = 0                #non-arq channel seq error count
        self.arq_pkts_txed = 0                            #how many arq packets we've transmitted
        self.arq_retxed = 0                                #how many times we've retransmitted
        self.failed_arq = 0
        self.max_attempts = max_attempts
        self.throw_away = False
                                
        self.arq_channel_state = ARQ_CHANNEL_IDLE
        self.expected_arq_id = 0                        #arq id we're expected to get ack for      
        self.timeout = timeout                            #arq timeout parameter
        self.time_of_tx = 0.0                            #time of last arq transmission
        
        self.queue = Queue.Queue()                        #queue for msg destined for ARQ path
Example #18
0
    def __init__(self, port_count):
        """
        The inputs are a pmt message blob.
        Non-blob messages will be ignored.
        """

        gr.block.__init__(
            self,
            name="virtual_channel_mux",
            in_sig=None,
            out_sig=None,
            num_msg_inputs=port_count,
            num_msg_outputs=1,
        )

        self.mgr = pmt.pmt_mgr()
        for i in range(64):
            self.mgr.set(pmt.pmt_make_blob(10000))
Example #19
0
    def __init__(self, hop_interval, post_guard, pre_guard, rx_freq_list, lead_limit, link_bps):
        """
        Inputs: complex stream from USRP, pkt in, ctrl in
        Outputs: pkt out, ctrl out
        """

        gr.block.__init__(
            self, name="fhss_engine_rx", in_sig=[numpy.complex64], out_sig=None, num_msg_inputs=2, num_msg_outputs=2
        )

        self.mgr = pmt.pmt_mgr()
        for i in range(64):
            self.mgr.set(pmt.pmt_make_blob(10000))

        self.hop_interval = hop_interval
        self.post_guard = post_guard
        self.pre_guard = pre_guard
        self.lead_limit = lead_limit
        self.link_bps = link_bps
        self.rx_freq_list = map(float, rx_freq_list.split(","))
        self.rx_freq_list_length = len(self.rx_freq_list)

        self.last_rx_time = 0
        self.last_rx_rate = 0
        self.samples_since_last_rx_time = 0

        self.next_interval_start = 0
        self.next_transmit_start = 0

        self.know_time = False
        self.found_time = False
        self.found_rate = False
        self.set_tag_propagation_policy(gr_extras.TPP_DONT)

        self.has_old_msg = False
        self.overhead = 20
        self.pad_data = numpy.zeros((1, 40), dtype="uint8")[0]
        self.tx_slots_passed = 0

        self.rx_state = RX_INIT
        self.plkt_received = False
        self.tune_lead = 0.010
        self.rx_hop_index = 0
        self.consecutive_miss = 0
Example #20
0
    def __init__(
        self,
    ):
        """
        Two msg ports in, two msg ports out
        """

        gr.block.__init__(
            self,
            name = "my_first_msg_block",
            in_sig = None,
            out_sig = None,
            num_msg_inputs = 2,
            num_msg_outputs = 2,
        )
    
        self.mgr = pmt.pmt_mgr()
        for i in range(64):
            self.mgr.set(pmt.pmt_make_blob(10000))
Example #21
0
    def __init__(self, addr, timeout, max_attempts):
        """
        three inputs: radio, from_app, ctrl_in
        Three outputs: radio, to_app, ctrl_out

        """

        gr.block.__init__(
            self,
            name="simple_mac",
            in_sig=None,
            out_sig=None,
            num_msg_inputs=3,
            num_msg_outputs=3,
        )

        self.mgr = pmt.pmt_mgr()
        for i in range(64):
            self.mgr.set(pmt.pmt_make_blob(10000))

        self.addr = addr  #MAC's address

        self.pkt_cnt_arq = 0  #pkt_cnt for arq channel
        self.pkt_cnt_no_arq = 0  #pkt_cnt for non_arq channel

        self.arq_expected_sequence_number = 0  #keep track for sequence error detection
        self.no_arq_expected_sequence_number = 0  #keep track for sequence error detection

        self.arq_sequence_error_cnt = 0  #arq channel seq errors - VERY BAD
        self.no_arq_sequence_error_cnt = 0  #non-arq channel seq error count
        self.arq_pkts_txed = 0  #how many arq packets we've transmitted
        self.arq_retxed = 0  #how many times we've retransmitted
        self.failed_arq = 0
        self.max_attempts = max_attempts
        self.throw_away = False

        self.arq_channel_state = ARQ_CHANNEL_IDLE
        self.expected_arq_id = 0  #arq id we're expected to get ack for
        self.timeout = timeout  #arq timeout parameter
        self.time_of_tx = 0.0  #time of last arq transmission

        self.queue = Queue.Queue()  #queue for msg destined for ARQ path
    def __init__(
        self,port_count
    ):
        """
        The inputs are a pmt message blob.
        Non-blob messages will be ignored.
        """

        gr.block.__init__(
            self,
            name = "virtual_channel_mux",
            in_sig = None,
            out_sig = None,
            num_msg_inputs = port_count,
            num_msg_outputs = 1,
        )
    
        self.mgr = pmt.pmt_mgr()
        for i in range(64):
            self.mgr.set(pmt.pmt_make_blob(10000))
Example #23
0
    def __init__(
        self,
    ):
        """
        Two msg ports in, two msg ports out
        """

        gr.block.__init__(
            self,
            name = "my_first_msg_block",
            in_sig = None,
            out_sig = None,
            num_msg_inputs = 0,#TODO - NOT VALID - specify correct number of ports
            num_msg_outputs = 0, #TODO - NOT VALID - specify correct number of ports
        )
    
        #we did this for you, this is a blob pmt manager
        self.mgr = pmt.pmt_mgr()
        for i in range(64):
            self.mgr.set(pmt.pmt_make_blob(10000))
Example #24
0
    def __init__(self, ):
        """
        Two msg ports in, two msg ports out
        """

        gr.block.__init__(
            self,
            name="my_first_msg_block",
            in_sig=None,
            out_sig=None,
            num_msg_inputs=
            0,  #TODO - NOT VALID - specify correct number of ports
            num_msg_outputs=
            0,  #TODO - NOT VALID - specify correct number of ports
        )

        #we did this for you, this is a blob pmt manager
        self.mgr = pmt.pmt_mgr()
        for i in range(64):
            self.mgr.set(pmt.pmt_make_blob(10000))
    def __init__(
        self,port_count
    ):
        """
        The input is a pmt message blob.
        Output are message blobs
        """

        gr.block.__init__(
            self,
            name = "virtual_channel_demux",
            in_sig = None,
            out_sig = None,
            num_msg_inputs = 1,
            num_msg_outputs = port_count,
        )
    
        self.mgr = pmt.pmt_mgr()
        for i in range(64):
            self.mgr.set(pmt.pmt_make_blob(10000))
            
        self.port_count = port_count
Example #26
0
    def __init__(self, ):
        """
        The input is a stream of bytes.
        Outputs a blob with value of current byte if it is different from last.
        """

        gr.block.__init__(
            self,
            name="transition_detect",
            in_sig=[numpy.uint8],
            out_sig=None,
            has_msg_input=False,
            num_msg_outputs=1,
        )

        self.mgr = pmt.pmt_mgr()
        for i in range(64):
            self.mgr.set(pmt.pmt_make_blob(10000))
        self.old_result = 0

        self.key = pmt.pmt_string_to_symbol("example_key")
        self.value = pmt.pmt_string_to_symbol("example_value")
        self.trans_count = 0
    def __init__(self):
        """
        First input is a state.
        Will hold state staticly until updated received on first input
        Will queue messages from second input.
        Will pass queued messages to output when state is '0'
       """

        gr.block.__init__(
            self,
            name="channel_access_controller",
            in_sig=None,
            out_sig=None,
            num_msg_inputs=2,
            num_msg_outputs=1,
        )

        self.mgr = pmt.pmt_mgr()
        for i in range(64):
            self.mgr.set(pmt.pmt_make_blob(10000))

        self.q = Queue.Queue(maxsize=0)
        self.channel_state = READY
Example #28
0
    def __init__(
        self,initial_slot,slot_interval,guard_interval,num_slots,lead_limit,link_bps,tx_addr,from_file, mimo
    ):
        """
        Inputs: complex stream from USRP, pkt in, ctrl in
        Outputs: pkt out, ctrl out
        """

        gr.block.__init__(
            self,
            name = "tdma_engine",
            in_sig = [numpy.complex64],
            out_sig = None,
            num_msg_inputs = 3,
            num_msg_outputs = 2,
        )

        self.mgr = pmt.pmt_mgr()
        for i in range(64):
            self.mgr.set(pmt.pmt_make_blob(10000))
        
        self.initial_slot = initial_slot
        self.num_slots = num_slots
        self.prefix_loc = 0
        self.prefix_len = 1
        self.mimo = mimo
        if mimo == True:
            self.prefix_loc = initial_slot
            print 'prefix_loc = %d' %(self.prefix_loc)
            self.prefix_len = 2 # number of PNs
            self.initial_slot = 1
        self.slot_interval = slot_interval
        self.guard_interval = guard_interval
        self.lead_limit = lead_limit
        self.link_bps = link_bps
	self.tx_addr = tx_addr
        self.from_file = from_file
        
        self.bytes_per_slot = int( ( self.slot_interval - self.guard_interval ) * self.link_bps / 8 )
        
        self.queue = Queue.Queue()                        #queue for msg destined for ARQ path
        self.tx_queue = Queue.Queue()
        
        self.last_rx_time = 0
        self.last_rx_rate = 0
        self.samples_since_last_rx_time = 0
        
        self.next_interval_start = 0
        self.next_transmit_start = 0

        self.know_time = False
        self.found_time = False
        self.found_rate = False
        self.set_tag_propagation_policy(extras_swig.TPP_DONT)

        self.has_old_msg = False
        self.overhead = 15
        #self.pad_data = numpy.fromstring('this idsaf;lkjkfdjsd;lfjs;lkajskljf;klajdsfk',dtype='uint8')
        self.pktno = 0

        if self.from_file:
            txfile_name = '/home/alexzh/' + self.tx_addr + '_randtx'
            self.sfile = open(txfile_name, 'r')
        
        self.tx_slots_passed = 0
Example #29
0
    def __init__(self, initial_slot, slot_interval, guard_interval, num_slots,
                 lead_limit, link_bps, tx_addr, from_file, mimo):
        """
        Inputs: complex stream from USRP, pkt in, ctrl in
        Outputs: pkt out, ctrl out
        """

        gr.block.__init__(
            self,
            name="tdma_engine",
            in_sig=[numpy.complex64],
            out_sig=None,
            num_msg_inputs=3,
            num_msg_outputs=2,
        )

        self.mgr = pmt.pmt_mgr()
        for i in range(64):
            self.mgr.set(pmt.pmt_make_blob(10000))

        self.initial_slot = initial_slot
        self.num_slots = num_slots
        self.prefix_loc = 0
        self.prefix_len = 1
        self.mimo = mimo
        if mimo == True:
            self.prefix_loc = initial_slot
            print 'prefix_loc = %d' % (self.prefix_loc)
            self.prefix_len = 2  # number of PNs
            self.initial_slot = 1
        self.slot_interval = slot_interval
        self.guard_interval = guard_interval
        self.lead_limit = lead_limit
        self.link_bps = link_bps
        self.tx_addr = tx_addr
        self.from_file = from_file

        self.bytes_per_slot = int(
            (self.slot_interval - self.guard_interval) * self.link_bps / 8)

        self.queue = Queue.Queue()  #queue for msg destined for ARQ path
        self.tx_queue = Queue.Queue()

        self.last_rx_time = 0
        self.last_rx_rate = 0
        self.samples_since_last_rx_time = 0

        self.next_interval_start = 0
        self.next_transmit_start = 0

        self.know_time = False
        self.found_time = False
        self.found_rate = False
        self.set_tag_propagation_policy(extras_swig.TPP_DONT)

        self.has_old_msg = False
        self.overhead = 15
        #self.pad_data = numpy.fromstring('this idsaf;lkjkfdjsd;lfjs;lkajskljf;klajdsfk',dtype='uint8')
        self.pktno = 0

        if self.from_file:
            txfile_name = '/home/alexzh/' + self.tx_addr + '_randtx'
            self.sfile = open(txfile_name, 'r')

        self.tx_slots_passed = 0
Example #30
0
    def __init__(self, device, parity, baudrate, stopbits, bytesize,
                 wait_for_newline):
        """
        Serial port w/ blobs in and out
        """

        gr.block.__init__(
            self,
            name="serial_port",
            in_sig=None,
            out_sig=None,
            num_msg_inputs=1,
            num_msg_outputs=1,
        )

        self.mgr = pmt.pmt_mgr()
        for i in range(64):
            self.mgr.set(pmt.pmt_make_blob(10000))

        self.device = device
        self.parity = parity
        self.baudrate = baudrate
        self.stopbits = stopbits
        self.bytesize = bytesize
        self.wait_for_newline = wait_for_newline

        #set parity

        if self.parity == NONE:
            self.parity = serial.PARITY_NONE
        elif self.parity == EVEN:
            self.parity = serial.PARITY_EVEN
        else:
            self.parity = serial.PARITY_ODD

        if self.stopbits == STOPBITS_ONE:
            self.stopbits = serial.STOPBITS_ONE
        elif self.stopbits == STOPBITS_TWO:
            self.stopbits = serial.STOPBITS_TWO

        if self.bytesize == WORD_SIZE_7:
            self.bytesize = serial.SEVENBITS
        else:
            self.bytesize = serial.EIGHTBITS

        # configure the serial connections (the parameters differs on the device you are connecting to)

        self.ser = serial.Serial(port=self.device,
                                 baudrate=self.baudrate,
                                 parity=self.parity,
                                 stopbits=self.stopbits,
                                 bytesize=self.bytesize)
        '''
        self.ser = serial.Serial(
            port=self.device,
            baudrate=self.baudrate,
            parity=serial.PARITY_NONE,
            stopbits=serial.STOPBITS_ONE,
            bytesize=serial.EIGHTBITS
        )
        '''
        print "Opened: ", self.ser.portstr  # check which port was really used
        self.ser.write("hel;lkfsdsa;lkfjdsaflo\n\r")  # write a string