示例#1
0
 def run(self):
     while self.keep_running:
         msg = self._msgq.delete_head()
         ok, payload = packet_utils.unmake_packet(msg.to_string(),
                                                  int(msg.arg1()))
         if self.callback:
             self.callback(ok, payload)
示例#2
0
 def post_data(self, data, type=None, arg1=None, arg2=None):
     ok, payload = packet_utils.unmake_packet(data, int(arg1), self.dewhiten)
     if not ok:
         #print "Packet of length %d failed CRC" % (len(data))    # Max len is 4095
         if not self.output_invalid:
             return
     payload = map(ord, list(payload))
     buf = pmt.init_u8vector(len(payload), payload)
     meta_dict = {'CRC_OK': ok}
     meta = pmt.to_pmt(meta_dict)
     self.message_port_pub(pmt.intern('pdu'), pmt.cons(meta, buf))
示例#3
0
 def post_data(self, data, type=None, arg1=None, arg2=None):
     ok, payload = packet_utils.unmake_packet(data, int(arg1),
                                              self.dewhiten)
     if not ok:
         #print "Packet of length %d failed CRC" % (len(data))    # Max len is 4095
         if not self.output_invalid:
             return
     payload = map(ord, list(payload))
     buf = pmt.init_u8vector(len(payload), payload)
     meta_dict = {'CRC_OK': ok}
     meta = pmt.to_pmt(meta_dict)
     self.message_port_pub(pmt.intern('pdu'), pmt.cons(meta, buf))
示例#4
0
 def work(self, input_items, output_items):
     while True:
         try: msg = self._msgq.delete_head()
         except: return -1
         ok, payload = packet_utils.unmake_packet(msg.to_string(), int(msg.arg1()))
         if ok:
             payload = numpy.fromstring(payload, numpy.uint8)
             try: blob = self._mgr.acquire(True) #block
             except: return -1
             pmt.pmt_blob_resize(blob, len(payload))
             pmt.pmt_blob_rw_data(blob)[:] = payload
             self.post_msg(0, pmt.pmt_string_to_symbol("ok"), blob)
         else:
             a = 0
示例#5
0
 def work(self, input_items, output_items):
     while True:
         try: msg = self._msgq.delete_head()
         except: return -1
         ok, payload = packet_utils.unmake_packet(msg.to_string(), int(msg.arg1()))
         if ok:
             payload = numpy.fromstring(payload, numpy.uint8)
             try: blob = self._mgr.acquire(True) #block
             except: return -1
             pmt.pmt_blob_resize(blob, len(payload))
             pmt.pmt_blob_rw_data(blob)[:] = payload
             self.post_msg(0, pmt.pmt_string_to_symbol("ok"), blob)
         else:
             a = 0
示例#6
0
 def work(self, input_items, output_items):
     while True:
         try: msg = self._msgq.delete_head()
         except: return -1
         ok, payload = packet_utils.unmake_packet(msg.to_string(), int(msg.arg1()), False) #remove the whitening for channel estimation
         #print 'pkt deframer get a payload'
         self.display_pkt_stats(payload, ok)
         if ok:
             payload = numpy.fromstring(payload, numpy.uint8)
             try: blob = self._mgr.acquire(True) #block
             except: return -1
             pmt.pmt_blob_resize(blob, len(payload))
             pmt.pmt_blob_rw_data(blob)[:] = payload
             #self.post_msg(0, pmt.pmt_string_to_symbol("ok"), blob)
         else:
             a = 0
示例#7
0
 def post_data(self, data, type=None, arg1=None, arg2=None):
     ok = True
     payload = ""
     if len(data) > 0:
         ok, payload = packet_utils.unmake_packet(data, int(arg1), self.dewhiten)
         if not ok:
             if self.log_invalid:
                 print "Packet of length %d failed CRC" % (len(data))    # Max len is 4095
             #if not self.output_invalid:
             #    return
     payload = map(ord, list(payload))
     buf = pmt.init_u8vector(len(payload), payload)
     meta_dict = {'CRC_OK': ok}
     if len(data) == 0:
         meta_dict['EMPTY'] = True
     meta = pmt.to_pmt(meta_dict)
     if ok or (self.output_invalid and not ok):
         self.message_port_pub(pmt.intern('pdu'), pmt.cons(meta, buf))
     else:
         self.message_port_pub(pmt.intern('invalid'), pmt.cons(meta, buf))
示例#8
0
 def work(self, input_items, output_items):
     while True:
         try:
             msg = self._msgq.delete_head()
         except:
             return -1
         ok, payload = packet_utils.unmake_packet(
             msg.to_string(), int(msg.arg1()),
             False)  #remove the whitening for channel estimation
         #print 'pkt deframer get a payload'
         self.display_pkt_stats(payload, ok)
         if ok:
             payload = numpy.fromstring(payload, numpy.uint8)
             try:
                 blob = self._mgr.acquire(True)  #block
             except:
                 return -1
             pmt.pmt_blob_resize(blob, len(payload))
             pmt.pmt_blob_rw_data(blob)[:] = payload
             #self.post_msg(0, pmt.pmt_string_to_symbol("ok"), blob)
         else:
             a = 0
示例#9
0
	def run(self):
		while self.keep_running:
			msg = self._msgq.delete_head()
			ok, payload = packet_utils.unmake_packet(msg.to_string(), int(msg.arg1()))
			if self.callback:
				self.callback(ok, payload)