diff options
author | Thomas Gubler <thomasgubler@gmail.com> | 2015-01-21 14:41:03 +0100 |
---|---|---|
committer | Thomas Gubler <thomasgubler@gmail.com> | 2015-01-21 14:41:03 +0100 |
commit | dcdde8ea88bf57b0432d2b64ed3ce606795c8d00 (patch) | |
tree | 0bf6e997ffe7f7a9cda98c832dbce39601a9242f /Tools/px_uploader.py | |
parent | 3a38b0fe359296aa19ec43ab82743aebeadb335c (diff) | |
parent | e8e4a3b5da058bd2ab8575c095dd74a5484333be (diff) | |
download | px4-firmware-dcdde8ea88bf57b0432d2b64ed3ce606795c8d00.tar.gz px4-firmware-dcdde8ea88bf57b0432d2b64ed3ce606795c8d00.tar.bz2 px4-firmware-dcdde8ea88bf57b0432d2b64ed3ce606795c8d00.zip |
Merge remote-tracking branch 'upstream/master' into ros_messagelayer_merge
Conflicts:
src/modules/attitude_estimator_ekf/attitude_estimator_ekf_main.cpp
src/modules/uORB/topics/vehicle_attitude.h
Diffstat (limited to 'Tools/px_uploader.py')
-rwxr-xr-x | Tools/px_uploader.py | 53 |
1 files changed, 30 insertions, 23 deletions
diff --git a/Tools/px_uploader.py b/Tools/px_uploader.py index c46f6bede..95a3d4046 100755 --- a/Tools/px_uploader.py +++ b/Tools/px_uploader.py @@ -266,18 +266,19 @@ class uploader(object): self.__getSync() return value - def __drawProgressBar(self, progress, maxVal): + def __drawProgressBar(self, label, progress, maxVal): if maxVal < progress: progress = maxVal percent = (float(progress) / float(maxVal)) * 100.0 - sys.stdout.write("\rprogress:[%-20s] %.2f%%" % ('='*int(percent/5.0), percent)) + sys.stdout.write("\r%s: [%-20s] %.1f%%" % (label, '='*int(percent/5.0), percent)) sys.stdout.flush() # send the CHIP_ERASE command and wait for the bootloader to become ready - def __erase(self): + def __erase(self, label): + print("\n", end='') self.__send(uploader.CHIP_ERASE + uploader.EOC) @@ -288,15 +289,14 @@ class uploader(object): #Draw progress bar (erase usually takes about 9 seconds to complete) estimatedTimeRemaining = deadline-time.time() if estimatedTimeRemaining >= 9.0: - self.__drawProgressBar(20.0-estimatedTimeRemaining, 9.0) + self.__drawProgressBar(label, 20.0-estimatedTimeRemaining, 9.0) else: - self.__drawProgressBar(10.0, 10.0) + self.__drawProgressBar(label, 10.0, 10.0) sys.stdout.write(" (timeout: %d seconds) " % int(deadline-time.time()) ) sys.stdout.flush() if self.__trySync(): - self.__drawProgressBar(10.0, 10.0) - sys.stdout.write("\nerase complete!\n") + self.__drawProgressBar(label, 10.0, 10.0) return; raise RuntimeError("timed out waiting for erase") @@ -350,7 +350,8 @@ class uploader(object): return [seq[i:i+length] for i in range(0, len(seq), length)] # upload code - def __program(self, fw): + def __program(self, label, fw): + print("\n", end='') code = fw.image groups = self.__split_len(code, uploader.PROG_MULTI_MAX) @@ -361,31 +362,40 @@ class uploader(object): #Print upload progress (throttled, so it does not delay upload progress) uploadProgress += 1 if uploadProgress % 256 == 0: - self.__drawProgressBar(uploadProgress, len(groups)) - self.__drawProgressBar(100, 100) - print("\nprogram complete!") + self.__drawProgressBar(label, uploadProgress, len(groups)) + self.__drawProgressBar(label, 100, 100) # verify code - def __verify_v2(self, fw): + def __verify_v2(self, label, fw): + print("\n", end='') self.__send(uploader.CHIP_VERIFY + uploader.EOC) self.__getSync() code = fw.image groups = self.__split_len(code, uploader.READ_MULTI_MAX) + verifyProgress = 0 for bytes in groups: + verifyProgress += 1 + if verifyProgress % 256 == 0: + self.__drawProgressBar(label, verifyProgress, len(groups)) if (not self.__verify_multi(bytes)): raise RuntimeError("Verification failed") + self.__drawProgressBar(label, 100, 100) - def __verify_v3(self, fw): - expect_crc = fw.crc(self.fw_maxsize) + def __verify_v3(self, label, fw): + print("\n", end='') + self.__drawProgressBar(label, 1, 100) + expect_crc = fw.crc(self.fw_maxsize) self.__send(uploader.GET_CRC + uploader.EOC) report_crc = self.__recv_int() self.__getSync() + verifyProgress = 0 if report_crc != expect_crc: print("Expected 0x%x" % expect_crc) print("Got 0x%x" % report_crc) raise RuntimeError("Program CRC failed") + self.__drawProgressBar(label, 100, 100) # get basic data about the board def identify(self): @@ -439,19 +449,16 @@ class uploader(object): except Exception: # ignore bad character encodings pass - print("erase...") - self.__erase() - - print("program...") - self.__program(fw) + + self.__erase("Erase ") + self.__program("Program", fw) - print("verify...") if self.bl_rev == 2: - self.__verify_v2(fw) + self.__verify_v2("Verify ", fw) else: - self.__verify_v3(fw) + self.__verify_v3("Verify ", fw) - print("done, rebooting.") + print("\nRebooting.\n") self.__reboot() self.port.close() |