예제 #1
0
파일: qa_pmt.py 프로젝트: JLWebber/grextras
    def test03 (self):
        randints = numpy.random.randint(0, 256, 123)
        blob = pmt.pmt_make_blob(len(randints))
        blob_data = pmt.pmt_blob_data(blob)

        blob_data[:] = randints #assign rand ints to data
        self.assertItemsEqual(blob_data, randints)

        blob_data = pmt.pmt_blob_data(blob)
        self.assertItemsEqual(blob_data, randints)
예제 #2
0
    def test03(self):
        randints = numpy.random.randint(0, 256, 123)
        blob = pmt.pmt_make_blob(len(randints))
        blob_data = pmt.pmt_blob_data(blob)

        blob_data[:] = randints  #assign rand ints to data
        self.assertItemsEqual(blob_data, randints)

        blob_data = pmt.pmt_blob_data(blob)
        self.assertItemsEqual(blob_data, randints)
예제 #3
0
def numpy_to_blob(p):
    p = p.view(numpy.uint8)
    b = pmt.pmt_make_blob(len(p))
    pmt.pmt_blob_data(b)[:] = p
    return b
예제 #4
0
def numpy_to_blob(p):
    p = p.view(numpy.uint8)
    b = pmt.pmt_make_blob(len(p))
    pmt.pmt_blob_data(b)[:] = p
    return b
예제 #5
0
    def work(self, input_items, output_items):
        while not len(self._pkt):
            try: msg = self.pop_msg_queue()
            except: return -1
            if not pmt.pmt_is_blob(msg.value):
                self.tx_time,data,self.more_frame_cnt = pmt.to_python(msg.value)
                self.has_tx_time = True
                #print data
                #print tx_time
                #print data.tostring()
            else:
                data = pmt.pmt_blob_data(msg.value)
                #print data
                self.has_tx_time = False


            pkt = packet_utils.make_packet(
                data.tostring(),
                self._samples_per_symbol,
                self._bits_per_symbol,
                self._access_code,
                False, #pad_for_usrp,
                self._whitener_offset,
                )
            self._pkt = numpy.fromstring(pkt, numpy.uint8)
            if self._use_whitener_offset:
                self._whitener_offset = (self._whitener_offset + 1) % 16

            #shouldn't really need to send start of burst
            #only need to do sob if looking for timed transactions

            num_items = min(len(self._pkt), len(output_items[0]))
            output_items[0][:num_items] = self._pkt[:num_items]
            self._pkt = self._pkt[num_items:] #residue for next work()

            if len(self._pkt) == 0 :
                item_index = num_items #which output item gets the tag?
                offset = self.nitems_written(0) + item_index
                source = pmt.pmt_string_to_symbol("framer")

                #print 'frame cnt',self.more_frame_cnt

                if self.has_tx_time:
                    key = pmt.pmt_string_to_symbol("tx_sob")
                    self.add_item_tag(0, self.nitems_written(0), key, pmt.PMT_T, source)
                    key = pmt.pmt_string_to_symbol("tx_time")
                    self.add_item_tag(0, self.nitems_written(0), key, pmt.from_python(self.tx_time), source)
                    #if self.keep:
                    #    print 'bad order'
                    #self.keep = True


                if self.more_frame_cnt == 0:
                    key = pmt.pmt_string_to_symbol("tx_eob")
                    self.add_item_tag(0, offset - 1, key, pmt.PMT_T, source)
                    #if self.keep:
                    #    print 'good order'
                    #self.keep = False
                else:
                    self.more_frame_cnt -= 1



            return num_items