From: realraum Date: Thu, 30 Apr 2009 15:08:05 +0000 (+0000) Subject: attempt to reduce delay. still has to acept multiple sockets.. X-Git-Url: https://git.realraum.at/?a=commitdiff_plain;h=8eb667a015ede707f676850a7561571291b4fc9d;p=svn42.git attempt to reduce delay. still has to acept multiple sockets.. --- diff --git a/door_daemon.py b/door_daemon.py index 8df0761..7453238 100755 --- a/door_daemon.py +++ b/door_daemon.py @@ -47,6 +47,7 @@ class ArduinoUSBThread ( threading.Thread ): self.running=True self.lastline="" self.last_status=None + self.shortsleep = 0 self.cv_updatestatus = threading.Condition(); #lock ist automatically created withing condition self.file_dev_ttyusb=file_dev_ttyusb #self.fh = open(self.file_dev_ttyusb,"w+") @@ -94,15 +95,17 @@ class ArduinoUSBThread ( threading.Thread ): self.cv_updatestatus.release() def send_reset(self): - logging.info("Resetting Door") - print("\nSending r..") + self.shortsleep = 20 + logging.info("Resetting Door") + #print("\nSending r..") self.fh.write("r"); - print("done\n") + #print("done\n") def send_statusrequest(self): - print("\nSending s..") + self.shortsleep = 20 + #print("\nSending s..") self.fh.write("s"); - print("done\n") + #print("done\n") self.cv_updatestatus.acquire() self.cv_updatestatus.wait(5.0) self.cv_updatestatus.release() @@ -112,7 +115,11 @@ class ArduinoUSBThread ( threading.Thread ): try: line = self.fh.readline(); except IOError, e: - time.sleep(0.5) + if self.shortsleep > 0: + time.sleep(0.05) + self.shortsleep -= 1 + else: + time.sleep(0.5) continue self.cv_updatestatus.acquire() self.lastline=line.strip() @@ -224,4 +231,4 @@ signal.signal(signal.SIGQUIT, exit_handler) logging.info("Door Daemon started") arduino.join() -ctrlfifo.join() \ No newline at end of file +ctrlfifo.join()