View Source IntelHex.Block (intel_hex v0.2.1)

A block is a contiguous set of bytes at an address

If you're working with IntelHex only, then you don't need to worry about this module. However, handling blocks directly can enable more complex manipulations of the data stored in .hex files.

Generally programs pass around lists of Blocks. Functions in this library expect these lists to conform to the following rules:

  1. Sorted by address from lowest address to highest
  2. No overlaps between blocks
  3. A gap of one or more bytes separates each block

Calling normalize/1 will ensure that Block lists follow these rules.

Summary

Functions

Turn a list of memory blocks back to records

Create a new block

Normalize a list of blocks

Convert a list of records to memory blocks

Types

@type t() :: %IntelHex.Block{address: non_neg_integer(), data: binary()}

Functions

Link to this function

blocks_to_records(blocks, opts \\ [])

View Source
@spec blocks_to_records(
  [t()],
  keyword()
) :: [IntelHex.Record.t()]

Turn a list of memory blocks back to records

Only linear addressing is supported.

Options:

  • :block_size - the max data bytes per record. (defaults to 16)
@spec new(non_neg_integer(), binary()) :: t()

Create a new block

@spec normalize([t()]) :: [t()]

Normalize a list of blocks

This makes sure that they're sorted, non-overlapping and blocks that are next to each other get merged. This is normally done automatically, but if you're manually creating block lists and unsure whether there are overlaps or adjacent blocks, then it's recommended to run this.

Link to this function

records_to_blocks(records)

View Source
@spec records_to_blocks([IntelHex.Record.t()]) :: [t()]

Convert a list of records to memory blocks

The returned list of blocks is sorted, merged, and any overlaps resolved.