printcore.py: review resend request line parsing.

The new algorithm mangles the request string as before,
but then looks for the first valid number instead of
a number in fixed places. This hopefully works for
all firmwares.

To avoid future regressions, a list of sample strings was
started. Feel free to add more samples in.
master
Markus Hitter 2012-08-14 00:47:59 +02:00
parent d94bc0ca9e
commit 27f7e1de63
1 changed files with 12 additions and 6 deletions

View File

@ -147,13 +147,19 @@ class printcore():
pass
#callback for errors
pass
# Teststrings for resend parsing # Firmware exp. result
# line="rs N2 Expected checksum 67" # Teacup 2
if line.lower().startswith("resend") or line.startswith("rs"):
try:
toresend=int(line.replace("N:"," ").replace("N"," ").replace(":"," ").split()[-1])
except:
if line.startswith("rs"):
toresend=int(line.split()[1])
self.resendfrom=toresend
line=line.replace("N:"," ").replace("N"," ").replace(":"," ")
linewords=line.split()
while len(linewords) != 0:
try:
toresend=int(linewords.pop(0))
self.resendfrom=toresend
#print str(toresend)
break
except:
pass
self.clear=True
self.clear=True
#callback for disconnect