mbed-os
Dependents: cobaLCDJoyMotor_Thread odometry_omni_3roda_v3 odometry_omni_3roda_v1 odometry_omni_3roda_v2 ... more
tools/dev/intel_hex_utils.py@0:b74591d5ab33, 2017-12-11 (annotated)
- Committer:
- be_bryan
- Date:
- Mon Dec 11 17:54:04 2017 +0000
- Revision:
- 0:b74591d5ab33
motor ++
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
be_bryan | 0:b74591d5ab33 | 1 | from intelhex import IntelHex |
be_bryan | 0:b74591d5ab33 | 2 | from cStringIO import StringIO |
be_bryan | 0:b74591d5ab33 | 3 | |
be_bryan | 0:b74591d5ab33 | 4 | |
be_bryan | 0:b74591d5ab33 | 5 | def sections(h): |
be_bryan | 0:b74591d5ab33 | 6 | start, last_address = None, None |
be_bryan | 0:b74591d5ab33 | 7 | for a in h.addresses(): |
be_bryan | 0:b74591d5ab33 | 8 | if last_address is None: |
be_bryan | 0:b74591d5ab33 | 9 | start, last_address = a, a |
be_bryan | 0:b74591d5ab33 | 10 | continue |
be_bryan | 0:b74591d5ab33 | 11 | |
be_bryan | 0:b74591d5ab33 | 12 | if a > last_address + 1: |
be_bryan | 0:b74591d5ab33 | 13 | yield (start, last_address) |
be_bryan | 0:b74591d5ab33 | 14 | start = a |
be_bryan | 0:b74591d5ab33 | 15 | |
be_bryan | 0:b74591d5ab33 | 16 | last_address = a |
be_bryan | 0:b74591d5ab33 | 17 | |
be_bryan | 0:b74591d5ab33 | 18 | if start: |
be_bryan | 0:b74591d5ab33 | 19 | yield (start, last_address) |
be_bryan | 0:b74591d5ab33 | 20 | |
be_bryan | 0:b74591d5ab33 | 21 | |
be_bryan | 0:b74591d5ab33 | 22 | def print_sections(h): |
be_bryan | 0:b74591d5ab33 | 23 | for s in sections(h): |
be_bryan | 0:b74591d5ab33 | 24 | print "[0x%08X - 0x%08X]" % s |
be_bryan | 0:b74591d5ab33 | 25 | |
be_bryan | 0:b74591d5ab33 | 26 | |
be_bryan | 0:b74591d5ab33 | 27 | def decode(record): |
be_bryan | 0:b74591d5ab33 | 28 | h = IntelHex() |
be_bryan | 0:b74591d5ab33 | 29 | f = StringIO(record) |
be_bryan | 0:b74591d5ab33 | 30 | h.loadhex(f) |
be_bryan | 0:b74591d5ab33 | 31 | h.dump() |