Whole file

eerimoq/bincopy

The author described this change as Fix: issue 4: Intel hex bad addresses. It counts as a record because the check below fails on the code as it stood at e26a28166 and passes on c420fb248, with nothing else changed between the two runs.

Fix saved2016-06-01
Sharing licenceMIT · LICENSE
Change size+14 6

What the code was meant to do, written into the code itself as a save note

Fix: issue 4: Intel hex bad addresses

The change

88 import string
99
1010 __author__ = 'Erik Moqvist'
11-__version__ = '2.1.1'
11+__version__ = '2.1.2'
1212
1313 DEFAULT_WORD_SIZE = 8
1414
220220 self.list = []
221221
222222 def add(self, segment):
223+ """Add segments by ascending address.
224+
225+ """
226+
223227 if self.list:
224228 if segment.minimum == self.current_segment.maximum:
225229 # fast insertion for adjecent segments
446450 """
447451
448452 data_address = []
449- extmaximumed_address = -1
453+ extended_linear_address = 0
450454
451455 for address, data in self.segments.iter(size):
452456 address //= self.word_size_bytes
457+ address_upper_16_bits = (address >> 16)
458+ address_lower_16_bits = (address & 0xffff)
453459
454460 if address_length == 32:
455- if ((address >> 16) & 0xffff) > extmaximumed_address:
456- extmaximumed_address = ((address >> 16) & 0xffff)
461+ # All segments are sorted by address. Update the
462+ # extended linear address when required.
463+ if address_upper_16_bits > extended_linear_address:
464+ extended_linear_address = address_upper_16_bits
457465 packed = pack_ihex(4,
458466 0,
459467 2,
460468 binascii.unhexlify('%04X'
461- % extmaximumed_address))
469+ % extended_linear_address))
462470 data_address.append(packed)
463471 else:
464472 raise Error('unsupported address length %d'
465473 % address_length)
466474
467- data_address.append(pack_ihex(0, address, len(data), data))
475+ data_address.append(pack_ihex(0, address_lower_16_bits, len(data), data))
468476
469477 footer = []
470478

The check that tells the two apart

failpass·tests/test_bincopy.py::BinCopyTest::test_issue_4

Check file tests/test_bincopy.py, taken without changes from the fix and copied onto the older code, so the exact same check runs against both versions.

Origin and history

The code before ite26a28166573c1c99fba648a148657b3d09e728d
Broken version dated2016-05-01
Modulebincopy
Units changedFile, _Segments
Fingerprint95641a7968d696c4
Checked2026-08-18 by goldset/0.1

Every field above is generated by our program. None of it is written by hand.

Other bugs found in eerimoq/bincopy