IntelHexFile class

This class represents the interface to read and write Intel hex files.

To parse a file, simply read it as string and call the fromString() constructor. If you want to write a file with binary data, then you can create an empty file and add your data by calling addAll().

The contents of the file are stored as MemorySegment. The segments are managed in the base class MemorySegmentContainer.

Inheritance

Constructors

IntelHexFile({int? address, int? length})
Creates a file with a single segment if address is >= 0 and length is >= 0. Otherwise the file is empty.
IntelHexFile.fromData(Iterable<int> data, {int address = 0})
Creates a file with a single segment containing all bytes from data. The start address is 0 unless another value is provided.
IntelHexFile.fromString(String data, {String? startToken, bool allowDuplicateAddresses = false})
Parses the Intel Hex records in the data string and adds it to the segments in this object. All lines without ":" are ignored. In lines with a colon all preceding characters are ignored. After the colon, only valid characters for hexadecimal numbers (0-9a-fA-F) are allowed up until the end of the line.

Properties

format IntelHexFormat
Returns the format that can be used to represent the file.
no setter
hashCode int
The hash code for this object.
no setterinherited
lineLength int
Controls the number of bytes in a data record.
getter/setter pair
maxAddress int
Returns the max address of a segment in the container.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
segments List<MemorySegment>
Returns all segments in the container. To add data, use addSegment or addAll.
no setterinherited
startCode String
The start code for a record. The standard value is ":".
getter/setter pair
startLinearAddress int?
The start address where the code is executed (if supported by the CPU). This value may be null if it is not contained in the file.
getter/setter pair
startSegmentAddress StartSegmentAddress?
The start address where the code is executed (for 80x86 CPUs). This value may be null if it is not contained in the file.
getter/setter pair

Methods

addAll(int startAddress, Iterable<int> data) → void
Adds the data contained in data to the container at startAddress. Contents will be truncated to (0, 255). If there was data at any of the address in the range then the old data will be overwritten.
inherited
addSegment(MemorySegment segment) → void
Adds the segment to the container and overwrites data that was stored previously at the same addresses.
inherited
fileExtensions() List<String>
Returns a list of possible file extensions for intel hex files
mergeSegments() → void
Merges all overlapping segments. If addresses are duplicated, then the values of the segments starting at lower addresses are retained.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
segmentIsNew(MemorySegment next) bool
Verifies that the next memory segment to add has a unique address and is not overlapping with other segments in the container.
inherited
sortSegments() → void
Sorts the segments, so that they are ordered with increasing addresses.
inherited
toFileContents({IntelHexFormat format = IntelHexFormat.i32HEX, String? startToken, bool allowDuplicateAddresses = false}) String
Converts this instance of IntelHexFile to an Intel Hex file record block.
toString() String
Prints information about the file and its contents.
override
validateSegmentsAreUnique() bool
Validates that all segments have unique address and are not overlapping.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited