IntelHex (intel_hex v0.2.1)

Copy Markdown View Source

Manipulate Intel HEX files

This is the main interface for loading, modifying and saving Intel HEX files. In general, you'll want to use methods here for most operations.

Internally, data is stored as lists of IntelHex.Block structs. See that module for transformations that aren't possible with the main functions.

Summary

Types

t()

Primary type for handling Intel Hex file data

Functions

Only keep data within the specified address range

Get the data at a specified address

Load an Intel Hex-formatted file into memory

Load an Intel Hex-formatted file into memory

Create an empty hex file

Save data to an Intel Hex-formatted file

Set a set of bytes at the specified address

Types

t()

@type t() :: %IntelHex{blocks: [IntelHex.Block.t()], path: String.t()}

Primary type for handling Intel Hex file data

Functions

crop(hex, address, length)

@spec crop(t(), non_neg_integer(), non_neg_integer()) :: t()

Only keep data within the specified address range

get(hex, address, num_bytes, options \\ [])

@spec get(t(), non_neg_integer(), non_neg_integer(), [{:fill, 0..255}]) :: binary()

Get the data at a specified address

Options:

  • :fill - value to use when none exists (defaults to 0)

load(path)

@spec load(Path.t()) :: {:ok, t()} | {:error, term()}

Load an Intel Hex-formatted file into memory

load!(path)

@spec load!(Path.t()) :: t()

Load an Intel Hex-formatted file into memory

Raises File.Error or IntelHex.DecodeError if an error occurs.

new()

@spec new() :: %IntelHex{blocks: [], path: String.t()}

Create an empty hex file

Use IntelHex.set/3 or other functions to populate it.

save(hex, path, options \\ [])

@spec save(t(), Path.t(), keyword()) :: :ok

Save data to an Intel Hex-formatted file

Options:

  • :block_size - the max data bytes per record. (defaults to 16)

set(hex, address, data)

@spec set(t(), non_neg_integer(), binary()) :: t()

Set a set of bytes at the specified address