Skip to content

Commit

Permalink
pymavlink: reduced CPU usage on failed reads looping
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrew Tridgell committed Mar 24, 2014
1 parent c1f6c2f commit 2bf2f4e
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion pymavlink/mavutil.py
Original file line number Diff line number Diff line change
Expand Up @@ -687,7 +687,10 @@ def recv(self,n=None):
waiting = self.port.inWaiting()
if waiting < n:
n = waiting
return self.port.read(n)
ret = self.port.read(n)
if len(ret) == 0:
time.sleep(0.1)
return ret

def write(self, buf):
try:
Expand Down

0 comments on commit 2bf2f4e

Please sign in to comment.