Skip to content

Commit 18572ba

Browse files
author
erki1993
committed
write_hex_file: new parameter byte_count, can choose hex data field length
1 parent 75e3912 commit 18572ba

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

intelhex/__init__.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -544,7 +544,7 @@ def _get_eol_textfile(eolstyle, platform):
544544
raise ValueError("wrong eolstyle %s" % repr(eolstyle))
545545
_get_eol_textfile = staticmethod(_get_eol_textfile)
546546

547-
def write_hex_file(self, f, write_start_addr=True, eolstyle='native'):
547+
def write_hex_file(self, f, write_start_addr=True, eolstyle='native', byte_count=16):
548548
"""Write data to file f in HEX format.
549549
550550
@param f filename or file-like object for writing
@@ -555,6 +555,7 @@ def write_hex_file(self, f, write_start_addr=True, eolstyle='native'):
555555
@param eolstyle can be used to force CRLF line-endings
556556
for output file on different platforms.
557557
Supported eol styles: 'native', 'CRLF'.
558+
@param byte_count number of bytes in the data field
558559
"""
559560
fwrite = getattr(f, "write", None)
560561
if fwrite:
@@ -656,7 +657,7 @@ def write_hex_file(self, f, write_start_addr=True, eolstyle='native'):
656657
# produce one record
657658
low_addr = cur_addr & 0x0FFFF
658659
# chain_len off by 1
659-
chain_len = min(15, 65535-low_addr, maxaddr-cur_addr)
660+
chain_len = min(byte_count - 1, 65535-low_addr, maxaddr-cur_addr)
660661

661662
# search continuous chain
662663
stop_addr = cur_addr + chain_len

0 commit comments

Comments
 (0)