aboutsummaryrefslogtreecommitdiffstats
path: root/support
diff options
context:
space:
mode:
authorMichael Hope <michael.hope@linaro.org>2010-09-29 20:06:51 +1300
committerMichael Hope <michael.hope@linaro.org>2010-09-29 20:06:51 +1300
commit3b48e2101810db085972a02d682b576076f1f94c (patch)
treeb3a264a515ca7388fe0d1f431d4d33f2703d10e4 /support
parent1169dc6e3b34daf85e5b30183b8fc2979ab952ca (diff)
downloadlibrambutan-3b48e2101810db085972a02d682b576076f1f94c.tar.gz
librambutan-3b48e2101810db085972a02d682b576076f1f94c.zip
Changed the exception handling so that Ctrl-C passes through and isn't treated as a timeout.
Diffstat (limited to 'support')
-rwxr-xr-xsupport/stm32loader.py31
1 files changed, 16 insertions, 15 deletions
diff --git a/support/stm32loader.py b/support/stm32loader.py
index d8e1f9f..a817efc 100755
--- a/support/stm32loader.py
+++ b/support/stm32loader.py
@@ -59,23 +59,24 @@ class CommandInterface:
def _wait_for_ask(self, info = ""):
+ got = self.sp.read(1)
+
+ if not got:
+ raise CmdException("No response")
+
# wait for ask
- try:
- ask = ord(self.sp.read())
- except:
- raise CmdException("Can't read port or timeout")
+ ask = ord(got)
+
+ if ask == 0x79:
+ # ACK
+ return 1
else:
- if ask == 0x79:
- # ACK
- return 1
+ if ask == 0x1F:
+ # NACK
+ raise CmdException("NACK "+info)
else:
- if ask == 0x1F:
- # NACK
- raise CmdException("NACK "+info)
- else:
- # Unknow responce
- raise CmdException("Unknow response. "+info+": "+hex(ask))
-
+ # Unknow responce
+ raise CmdException("Unknow response. "+info+": "+hex(ask))
def reset(self):
self.sp.setDTR(0)
@@ -407,7 +408,7 @@ if __name__ == "__main__":
try:
try:
cmd.initChip()
- except:
+ except CmdException:
print "Can't init. Ensure that BOOT0 is enabled and reset device"
bootversion = cmd.cmdGet()