def main0(): print "ST110" finish = False s = Serial(port=port, baudrate=115200) reader = Reader(s) reader.run = True t0 = time.clock() i = 0 while reader.run: out = reader.exec_() if out is not None: print(out) t1 = time.clock() if (t1 - t0 < 2): continue t0 = t1 if i < len(packets): if reader.send(packets[i]): i += 1 else: sys.stderr.write('resend {pkt}\n'.format(pkt=packets[i][0])) else: print('end of packets') break finish = True reader.run = not finish
def _inventory(self, *args, **kwargs): try: s = Serial(port=args[0], baudrate=115200) r = Reader(s, self.hb) r.inventory(cb=self.on_txt) finally: self.f_running = False self.set_status('Closed ' + self.selected_port())
def main(): print "ST110" finish = False s = Serial(port=port, baudrate=115200) b = False delay = 3 reader = Reader(s) #for i in range(5): #b ^= 1 #reader.set_heartbeat(b) #time.sleep(delay) #reader.run = False epc = reader.inventory() print epc
def _readfromtag(self, *args, **kwargs): membank = self._app.config.getint('section1', 'membank') length = self._app.config.getint('section1', 'length') startaddr = int(self._app.config.getint('section1', 'startaddr')) try: s = Serial(port=args[0], baudrate=115200) r = Reader(s, self.hb) tags = r.inventory(close=False) if len(tags) > 0: epc = tags[0] r.read_from_tag(epc=epc, membank=membank, length=length, startaddr=startaddr, cb=self.on_txt) else: r.run = False finally: self.f_running = False self.set_status('Closed ' + self.selected_port())