GithubHelp home page GithubHelp logo

cambrian-era / intel_hex Goto Github PK

View Code? Open in Web Editor NEW

This project forked from fhunleth/intel_hex

0.0 1.0 0.0 14 KB

Decode Intel hex records in Elixir

License: Apache License 2.0

Elixir 100.00%

intel_hex's Introduction

IntelHex

CircleCI Hex version

This is a small library to help decode Intel HEX records. This file format is frequently used for firmware images on microcontrollers.

The main interface returns a lowlevel view of the records:

iex> records = IntelHex.decode_file!("test/test.hex")
[
  %IntelHex.Record{address: 0, data: [0, 0], type: :extended_linear_address},
  %IntelHex.Record{
    address: 0,
    data: [2, 24, 0, 2, 24, 3, 8, 253, 9, 2, 0, 2, 24, 11, 11, 50],
    type: :data
  },
  %IntelHex.Record{
    address: 16,
    data: [11, 60, 34, 2, 24, 19, 10, 236, 11, 0],
    type: :data
  },
  ...
  %IntelHex.Record{address: 0, data: [], type: :eof}
]

If you'd like the records to be flattened back into a memory image, you can run IntelHex.flatten_to_list/2 against the records:

iex(2)> IntelHex.flatten_to_list(records)
[2, 24, 0, 2, 24, 3, 8, 253, 9, 2, 0, 2, 24, 11, 11, 50, 11, 60, 34, 2, 24, 19,
 10, 236, 11, 0, 255, 2, 24, 27, 70, 154, 2, 29, 225, 2, 24, 35, 228, 255, 225,
 64, 255, 2, 24, 43, 127, 7, 34, 211, ...]

IntelHex.flatten_to_list/2 takes keyword parameters to specify start offsets and default fill bytes for skipped locations. The default filler byte is 255 which can be seen in the above examples if you squint hard enough.

Installation

If available in Hex, the package can be installed by adding intel_hex to your list of dependencies in mix.exs:

def deps do
  [
    {:intel_hex, "~> 0.1.0"}
  ]
end

Future work

The library has a couple major missing features:

  1. Support for anything besides 16-bit Intel Hex files
  2. Encoder support

I don't currently have a use case for those, but if you do, I'd certainly work with you to get these included.

intel_hex's People

Contributors

fhunleth avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.