Skip to content

Instantly share code, notes, and snippets.

@cjo20
Created January 9, 2017 21:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cjo20/da2f6c863b621b06f86594d8df99d03e to your computer and use it in GitHub Desktop.
Save cjo20/da2f6c863b621b06f86594d8df99d03e to your computer and use it in GitHub Desktop.
diff --git a/mmeowlink/handlers/stick.py b/mmeowlink/handlers/stick.py
index a40dd9d..78340e6 100644
--- a/mmeowlink/handlers/stick.py
+++ b/mmeowlink/handlers/stick.py
@@ -170,19 +170,12 @@ class Repeater (Sender):
buf = pkt.assemble( )
log.debug('Sending repeated message %s' % (str(buf).encode('hex')))
- self.link.write(buf, repetitions=repetitions)
+ self.link.write(buf, repetitions=repetitions, timeout=0.024 * repetitions)
- # The radio takes a while to send all the packets, so wait for a bit before
- # trying to talk to the radio, otherwise we can interrupt it.
- #
- # This multiplication factor is based on
- # testing, which shows that it takes 8.04 seconds to send 500 packets
- # (8.04/500 =~ 0.016 packets per second).
- # We don't want to miss the reply, so take off a bit:
- time.sleep((repetitions * 0.016) - 2.2)
+ done_time = time.time()
try:
- self.wait_for_ack()
+ self.wait_for_ack(timeout=ack_wait_seconds)
return True
except CommsException, InvalidPacketReceived:
log.error("%s - Response not received - retrying" % time.time())
@@ -223,7 +216,7 @@ class Pump (session.Pump):
self.command = commands.PowerControl(**dict(minutes=minutes, serial=self.serial))
repeater = Repeater(self.link)
- status = repeater(self.command, repetitions=500, ack_wait_seconds=20)
+ status = repeater(self.command, repetitions=500, ack_wait_seconds=12)
if status:
return True
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment