About¶
The hexformat Python package allows the processing of several HEX data formats. Supported formats are the Intel-Hex format, the Motorola S-Record format as well as the simple hex dump format. The first two are often used for programming microcontrollers while the last is often used to display binary data in a user readable way.
Files in the mentioned format can be created, modified (e.g. set, delete and fill data) and read from or written to files.
A base class MultiPartBuffer
is provided which implements the handling of multiple data parts where every part is identified by its corresponding start address.
This base class allows for the basic operations like reading and writing binary files as well as modifing the binary data.
The specific classes IntelHex
, SRecord
and HexDump
are derivated from it which implement the parsing and generating of the corresponding HEX formats as well as implementing file format specific features.
Motivation¶
This package was mainly created to replace the srecord command line tool and its complicated interface with a clean python interface for use with handling microcontroller HEX files. The existing Python library intelhex was used for a while, but then the need for the S-Record format appeared. Also intelhex.IntelHex did not provide a suitable interface for the most often used operations.
License¶
MIT License
Copyright (c) 2015-2022 by Martin Scharrer <martin.scharrer@web.de>
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Contents:
- About
- hexformat package
- Submodules
- hexformat.base module
- hexformat.fillpattern module
- hexformat.hexdump module
- hexformat.intelhex module
RT_DATA
RT_END_OF_FILE
RT_EXTENDED_SEGMENT_ADDRESS
RT_START_SEGMENT_ADDRESS
RT_EXTENDED_LINEAR_ADDRESS
RT_START_LINEAR_ADDRESS
IntelHex
IntelHex._DATALENGTH
IntelHex._VARIANTS
IntelHex._DEFAULT_BYTES_PER_LINE
IntelHex._DEFAULT_VARIANT
IntelHex._bytesperline
IntelHex._cs_ip
IntelHex._eip
IntelHex._variant
IntelHex.bytesperline
IntelHex.cs_ip
IntelHex.eip
IntelHex.fromihexfh()
IntelHex.fromihexfile()
IntelHex.loadihexfh()
IntelHex.loadihexfile()
IntelHex.toihexfh()
IntelHex.toihexfile()
IntelHex.variant
- hexformat.multipartbuffer module
MultiPartBuffer
MultiPartBuffer._STANDARD_FORMAT
MultiPartBuffer._padding
MultiPartBuffer.add()
MultiPartBuffer.blockfill()
MultiPartBuffer.blockfilter()
MultiPartBuffer.blockunfill()
MultiPartBuffer.copy()
MultiPartBuffer.crop()
MultiPartBuffer.delete()
MultiPartBuffer.end()
MultiPartBuffer.extract()
MultiPartBuffer.fill()
MultiPartBuffer.fillend()
MultiPartBuffer.fillfront()
MultiPartBuffer.fillgaps()
MultiPartBuffer.filter()
MultiPartBuffer.frombinfh()
MultiPartBuffer.frombinfile()
MultiPartBuffer.fromfh()
MultiPartBuffer.fromfile()
MultiPartBuffer.gaps()
MultiPartBuffer.get()
MultiPartBuffer.hasdata()
MultiPartBuffer.includesgaps()
MultiPartBuffer.loadbinfh()
MultiPartBuffer.loadbinfile()
MultiPartBuffer.loaddict()
MultiPartBuffer.loadfh()
MultiPartBuffer.loadfile()
MultiPartBuffer.offset()
MultiPartBuffer.parts()
MultiPartBuffer.range()
MultiPartBuffer.relocate()
MultiPartBuffer.set()
MultiPartBuffer.setint()
MultiPartBuffer.start()
MultiPartBuffer.tobinfh()
MultiPartBuffer.tobinfile()
MultiPartBuffer.todict()
MultiPartBuffer.tofh()
MultiPartBuffer.tofile()
MultiPartBuffer.unfill()
MultiPartBuffer.usedsize()
ensurebuffer()
int_to_bytes()
- hexformat.srecord module
RECORD_TYPE
RECORD_TYPE.COUNT_16
RECORD_TYPE.COUNT_24
RECORD_TYPE.DATA_16
RECORD_TYPE.DATA_24
RECORD_TYPE.DATA_32
RECORD_TYPE.FOOTER_16
RECORD_TYPE.FOOTER_24
RECORD_TYPE.FOOTER_32
RECORD_TYPE.HEADER
RECORD_TYPE.S0
RECORD_TYPE.S1
RECORD_TYPE.S2
RECORD_TYPE.S3
RECORD_TYPE.S5
RECORD_TYPE.S6
RECORD_TYPE.S7
RECORD_TYPE.S8
RECORD_TYPE.S9
SRecord
SRecord._SRECORD_ADDRESSLENGTH
SRecord._STANDARD_FORMAT
SRecord._startaddress
SRecord._header
SRecord.addresslength
SRecord.bytesperline
SRecord.fromsrecfh()
SRecord.fromsrecfile()
SRecord.header
SRecord.loadsrecfh()
SRecord.loadsrecfile()
SRecord.startaddress
SRecord.tosrecfh()
SRecord.tosrecfile()
SRecord.write_number_of_records
- hexformat.tektronix module
- Module contents
DecodeError
EncodeError
FillPattern
IntelHex
IntelHex._DATALENGTH
IntelHex._VARIANTS
IntelHex._DEFAULT_BYTES_PER_LINE
IntelHex._DEFAULT_VARIANT
IntelHex._bytesperline
IntelHex._cs_ip
IntelHex._eip
IntelHex._variant
IntelHex.bytesperline
IntelHex.cs_ip
IntelHex.eip
IntelHex.fromihexfh()
IntelHex.fromihexfile()
IntelHex.loadihexfh()
IntelHex.loadihexfile()
IntelHex.toihexfh()
IntelHex.toihexfile()
IntelHex.variant
RandomContent
SRecord
SRecord._SRECORD_ADDRESSLENGTH
SRecord._STANDARD_FORMAT
SRecord._startaddress
SRecord._header
SRecord.addresslength
SRecord.bytesperline
SRecord.fromsrecfh()
SRecord.fromsrecfile()
SRecord.header
SRecord.loadsrecfh()
SRecord.loadsrecfile()
SRecord.startaddress
SRecord.tosrecfh()
SRecord.tosrecfile()
SRecord.write_number_of_records
- How-to
- Changelog