px4_uploader: Prevent spin-lock from hogging CPU

This commit is contained in:
Johan Jansen
2015-02-26 11:14:06 +01:00
parent 8240e90d26
commit a8f9caaaa5

View File

@@ -501,7 +501,8 @@ print("Loaded firmware for %x,%x, size: %d bytes, waiting for the bootloader..."
print("If the board does not respond within 1-2 seconds, unplug and re-plug the USB connector.")
# Spin waiting for a device to show up
while True:
try:
while True:
portlist = []
patterns = args.port.split(",")
# on unix-like platforms use glob to support wildcard ports. This allows
@@ -573,3 +574,11 @@ while True:
# we could loop here if we wanted to wait for more boards...
sys.exit(0)
#Rate-limit retries to prevent spin-lock from hogging the CPU
time.sleep(0.5)
#CTRL+C aborts the upload/spin-lock by interrupt mechanics
except KeyboardInterrupt:
print("\n Upload aborted by user.")
sys.exit(0)