summaryrefslogtreecommitdiffstats
path: root/toprammer
diff options
context:
space:
mode:
authorMichael Buesch <mb@bu3sch.de>2010-02-23 21:48:58 +0100
committerMichael Buesch <mb@bu3sch.de>2010-02-23 21:48:58 +0100
commit8d74bbfda71408e0b1aee6d9aa1300a8eee6845c (patch)
treefaaf9d7885bf76c215ac9a85b59bd1f8a5c1e0cc /toprammer
parentb42508ebff8054387e58ead975a06a12cf0c281e (diff)
downloadtoprammer-8d74bbfda71408e0b1aee6d9aa1300a8eee6845c.tar.xz
toprammer-8d74bbfda71408e0b1aee6d9aa1300a8eee6845c.zip
Some ihex parser improvements
Signed-off-by: Michael Buesch <mb@bu3sch.de>
Diffstat (limited to 'toprammer')
-rwxr-xr-xtoprammer15
1 files changed, 10 insertions, 5 deletions
diff --git a/toprammer b/toprammer
index 16265df..5eceded 100755
--- a/toprammer
+++ b/toprammer
@@ -89,6 +89,8 @@ class IO_ihex:
def toBinary(self, ihexData):
bin = []
+ checksumWarned = False
+ doublewriteWarned = False
try:
lines = ihexData.splitlines()
hiAddr = 0
@@ -111,8 +113,9 @@ class IO_ihex:
byte = int(line[i:i+2], 16)
checksum = (checksum + byte) & 0xFF
checksum = checksum & 0xFF
- if checksum != 0:
- raise TOPException("Invalid IHEX format (checksum error)")
+ if checksum != 0 and not checksumWarned:
+ checksumWarned = True
+ print "WARNING: Invalid IHEX format (checksum error)"
if type == self.TYPE_EOF:
break
@@ -123,11 +126,13 @@ class IO_ihex:
continue
if type == self.TYPE_DATA:
if len(bin) < addr + count: # Reallocate
- bin += ['\0'] * (addr + count - len(bin))
+ bin += ['\xFF'] * (addr + count - len(bin))
for i in range(9, 9 + count * 2, 2):
byte = chr(int(line[i:i+2], 16))
- if bin[(i - 9) / 2 + addr] != '\0':
- raise TOPException("Invalid IHEX format (corruption)")
+ if bin[(i - 9) / 2 + addr] != '\xFF' and \
+ not doublewriteWarned:
+ doublewriteWarned = True
+ print "Invalid IHEX format (Wrote twice to same location)"
bin[(i - 9) / 2 + addr] = byte
continue
raise TOPException("Invalid IHEX format (unsup type %d)" % type)
bues.ch cgit interface