summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorDaniel Campora <daniel@wipy.io>2015-09-27 00:16:20 +0200
committerDaniel Campora <daniel@wipy.io>2015-09-27 02:00:46 +0200
commit635ef164327f29c4f682c6234e3b6fe6c078e480 (patch)
tree3290fb2f2c73155d8f1959833144acb5ae64ce7f
parent57fa14b5be08736b37f1629475e47c92556c0629 (diff)
downloadmicropython-635ef164327f29c4f682c6234e3b6fe6c078e480.tar.gz
micropython-635ef164327f29c4f682c6234e3b6fe6c078e480.zip
cc3200/tools: Improve update script robustness.
-rw-r--r--cc3200/tools/update-wipy.py29
1 files changed, 20 insertions, 9 deletions
diff --git a/cc3200/tools/update-wipy.py b/cc3200/tools/update-wipy.py
index eeb159332d..857a3d650e 100644
--- a/cc3200/tools/update-wipy.py
+++ b/cc3200/tools/update-wipy.py
@@ -17,6 +17,7 @@ Or:
import sys
import argparse
import time
+import socket
from ftplib import FTP
from telnetlib import Telnet
@@ -121,12 +122,23 @@ def verify_update(args):
print("Error: verification failed, the git tag doesn't match")
return False
- try:
- # Specify a longer time out value here because the board has just been
- # reset and the wireless connection might not be fully established yet
- tn = Telnet(args.ip, timeout=15)
- print("Connected via telnet again, lets check the git tag")
+ retries = 0
+ while True:
+ try:
+ # Specify a longer time out value here because the board has just been
+ # reset and the wireless connection might not be fully established yet
+ tn = Telnet(args.ip, timeout=10)
+ print("Connected via telnet again, lets check the git tag")
+ break
+ except socket.timeout:
+ if retries < 5:
+ print("Timeout while connecting via telnet, retrying...")
+ retries += 1
+ else:
+ print('Error: Telnet connection timed out!')
+ return False
+ try:
firmware_tag = tn.read_until (b'with CC3200')
tag_file_path = args.file.rstrip('mcuimg.bin') + 'genhdr/mpversion.h'
@@ -170,10 +182,9 @@ def main():
if reset_board(args):
if args.verify:
print ('Waiting for the WiFi connection to come up again...')
- # this time is to allow the system's wireless network card to connect to the
- # WiPy again. Sometimes it might only take a couple of seconds, but let's
- # leave 15s to be on the safe side
- time.sleep(15)
+ # this time is to allow the system's wireless network card to
+ # connect to the WiPy again.
+ time.sleep(5)
if verify_update(args):
result = 0
else: