Esempio n. 1
0
 def iterheaps(self):
     while self.is_connected:
         self.acc_num.seek(0)
         heap_cnt = '\x00' + self.acc_num.read()
         if heap_cnt == self._tx_heap.get(S.HEAP_CNT_ID,'XX')[1]:
             #logger.debug('BorphSpeadServer.iterheaps: Waiting for HEAP_CNT=%s (currently %s)' % (S.hexify(self._tx_heap.get(S.HEAP_CNT_ID,'XX')[1]), S.hexify(heap_cnt)))
             time.sleep(.001)
             continue
         tme = time.time()
         tme = int(tme*1000)
         htme = S.pack(S.mkfmt(('u',64)),[[tme]])
         self._tx_heap[TIMESTAMP_ID] = (S.DIRECTADDR,htme)
         logger.info('BorphSpeadServer.iterheaps: Sending HEAP_CNT=%s' % S.hexify(heap_cnt))
         self._tx_heap[S.HEAP_CNT_ID] = (S.IMMEDIATEADDR, heap_cnt)
         for id,bram in self.brams.iteritems():
             bram.seek(0)
             self._tx_heap[id] = (S.DIRECTADDR, bram.read())
         yield self._tx_heap
     return
Esempio n. 2
0
 def update(self, heap):
     items = heap.get_items()
     # First process items that are linked to FPGA resources
     for id in self.fpga_rx.keys():
         #logger.debug('BorphSpeadServer.update: Trying id=%d in %s' % (id, items.keys()))
         try: val = items[id]
         except(KeyError): continue
         filename,size = self.fpga_rx[id]
         logger.info('BorphSpeadServer.update: Updating id=%d (filename=%s) val=0x%s' % (id, filename, S.hexify(val)))
         logger.debug('BorphSpeadServer.update: Updating id=%d with value of length=%d' % (id, len(val)))
         if len(val) < size:
             logger.warn('BorphSpeadServer.update: Did not get enough data for id=%d (needed %d, got %d)' % (id, size, len(val)))
             continue
         f = open(filename,'w')
         f.write(val[-size:])
         f.close()
     S.ItemGroup.update(self, heap)