mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <s.hauer@pengutronix.de>
To: Barebox List <barebox@lists.infradead.org>
Subject: [PATCH 5/8] pyserial: decrease timeouts
Date: Fri,  8 Jan 2016 12:13:52 +0100	[thread overview]
Message-ID: <1452251635-14689-6-git-send-email-s.hauer@pengutronix.de> (raw)
In-Reply-To: <1452251635-14689-1-git-send-email-s.hauer@pengutronix.de>

pyserial has very generous timeouts which introduces quite big latencies
at least when used on rfc2217 ports. Decrease timeouts to make it more
reactive.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 scripts/serial/rfc2217.py | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/scripts/serial/rfc2217.py b/scripts/serial/rfc2217.py
index 4fe1a72..b65edd5 100644
--- a/scripts/serial/rfc2217.py
+++ b/scripts/serial/rfc2217.py
@@ -341,9 +341,9 @@ class TelnetSubnegotiation(object):
         """
         timeout_time = time.time() + timeout
         while time.time() < timeout_time:
-            time.sleep(0.05)    # prevent 100% CPU load
             if self.isReady():
                 break
+            time.sleep(0.001)    # prevent 100% CPU load
         else:
             raise SerialException("timeout while waiting for option %r" % (self.name))
 
@@ -443,9 +443,9 @@ class RFC2217Serial(SerialBase):
         # now wait until important options are negotiated
         timeout_time = time.time() + self._network_timeout
         while time.time() < timeout_time:
-            time.sleep(0.05)    # prevent 100% CPU load
             if sum(o.active for o in mandadory_options) == sum(o.state != INACTIVE for o in mandadory_options):
                 break
+            time.sleep(0.001)    # prevent 100% CPU load
         else:
             raise SerialException("Remote does not seem to support RFC2217 or BINARY mode %r" % mandadory_options)
         if self.logger:
@@ -488,9 +488,9 @@ class RFC2217Serial(SerialBase):
             self.logger.debug("Negotiating settings: %s" % (items,))
         timeout_time = time.time() + self._network_timeout
         while time.time() < timeout_time:
-            time.sleep(0.05)    # prevent 100% CPU load
             if sum(o.active for o in items) == len(items):
                 break
+            time.sleep(0.001)    # prevent 100% CPU load
         else:
             raise SerialException("Remote does not accept parameter change (RFC2217): %r" % items)
         if self.logger:
@@ -865,13 +865,13 @@ class RFC2217Serial(SerialBase):
             self.rfc2217SendSubnegotiation(NOTIFY_MODEMSTATE)
             timeout_time = time.time() + self._network_timeout
             while time.time() < timeout_time:
-                time.sleep(0.05)    # prevent 100% CPU load
                 # when expiration time is updated, it means that there is a new
                 # value
                 if self._modemstate_expires > time.time():
                     if self.logger:
                         self.logger.warning('poll for modem state failed')
                     break
+                time.sleep(0.001)    # prevent 100% CPU load
             # even when there is a timeout, do not generate an error just
             # return the last known value. this way we can support buggy
             # servers that do not respond to polls, but send automatic
-- 
2.6.4


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

  parent reply	other threads:[~2016-01-08 11:14 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-01-08 11:13 [PATCH] remote control support Sascha Hauer
2016-01-08 11:13 ` [PATCH 1/8] Add Reliable Asynchronous Transfer Protocol Sascha Hauer
2016-01-18  1:09   ` Andrey Smirnov
2016-01-08 11:13 ` [PATCH 2/8] barebox remote control Sascha Hauer
2016-01-11  2:10   ` Andrey Smirnov
2016-01-11  7:52     ` Sascha Hauer
2016-01-18  1:04       ` Andrey Smirnov
2016-01-18  2:39   ` Andrey Smirnov
2016-01-08 11:13 ` [PATCH 3/8] fs: Add RATP fs support Sascha Hauer
2016-01-18  1:10   ` Andrey Smirnov
2016-01-08 11:13 ` [PATCH 4/8] include pyserial trunk Sascha Hauer
2016-01-08 11:57   ` Yegor Yefremov
2016-01-08 12:00     ` Sascha Hauer
2016-01-08 11:13 ` Sascha Hauer [this message]
2016-01-08 11:13 ` [PATCH 6/8] host side for barebox remote control Sascha Hauer
2016-01-18  1:07   ` Andrey Smirnov
2016-01-18  9:32     ` Jan Lübbe
2016-01-08 11:13 ` [PATCH 7/8] defaultenv2: Add automount for RATPFS Sascha Hauer
2016-01-08 11:13 ` [PATCH 8/8] barebox remote control: Documentation Sascha Hauer
2016-01-18  1:16   ` Andrey Smirnov
2016-01-18  9:25     ` Sascha Hauer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1452251635-14689-6-git-send-email-s.hauer@pengutronix.de \
    --to=s.hauer@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox