summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTom van Leeuwen <tom.van.leeuwen@technolution.eu>2016-02-07 12:21:48 +0100
committerTom van Leeuwen <tom.van.leeuwen@technolution.eu>2016-02-07 13:42:00 +0100
commiteab073848965842caed9e99ae825d08a2dfe0d31 (patch)
tree83f853bb51013db8e40b62340897909a73d1e972
parent9250373500c74578d49b7e11baba3b732755e5dd (diff)
downloadtoprammer-eab073848965842caed9e99ae825d08a2dfe0d31.tar.xz
toprammer-eab073848965842caed9e99ae825d08a2dfe0d31.zip
Try to re-initialize the programmer several times, to prevent having to un-plug and re-plug the programmer after every time it has been used.
-rw-r--r--libtoprammer/main.py10
1 files changed, 9 insertions, 1 deletions
diff --git a/libtoprammer/main.py b/libtoprammer/main.py
index b0fac2e..965dbd3 100644
--- a/libtoprammer/main.py
+++ b/libtoprammer/main.py
@@ -199,7 +199,15 @@ class TOP(object):
(r"top2049\s+ver\s*(\d+\.\d+)", self.TYPE_TOP2049),
)
- versionString = self.hw.readVersionString()
+ # This is the first hardware access. Try several times since the programmer is in an unknown state.
+ for _ in range(25):
+ try:
+ versionString = self.hw.readVersionString()
+ break
+ except TOPException, e:
+ pass
+ else:
+ raise TOPException("Could not read version string from hardware")
for (regex, t) in versionRegex:
if t != self.topType:
continue
bues.ch cgit interface